[fpc-devel] Generics

Danny Milosavljevic danny.milo at gmx.net
Mon Apr 10 19:33:18 CEST 2006


Am Sonntag, den 09.04.2006, 18:51 -0300 schrieb Flávio Etrusco:
> I hope I'm not being too annoying, I'm just trying to understand
> better your decision/opinion. If you think this discussion is useless
> please speak and I'll shut up ;-)
> > Well, talking about Java's speed never makes sense.
> LOL, I agree :-)
> > Fact is, if you use
> > classes that you've always an indirection because of the pointer and
> > extra memory manager overhead while for simple tasks you can use simple
> > embed the data into the container data when using real templates.
> I know, and using "type erasure" will even frequently force the use of
> inheritance (virtual/dynamic methods) that will add a little more
> overhead, 

> but thing is I can't see much use for generics for low level
> tasks.

You need them for any kind of compile-time-type-checked collections...
so as long as you only do I/O port programming, you are safe... no wait,
only until you try to store the conversation in a list :)

> There are relatively few native types that is usually ok duplicate the
> whole code if it need be. 

No, the computer must do all the work it can to enable me to think of
what I actually want to do. If by "Duplicate", you mean _automatic_
duplication by the compiler, then I agree...

> And it seems to me that absolutely most of
> the times we are working with classes instead of just single primitive
> variables, 

are strings classes or primitive in your mind?

> so I still fail to see where "generic for non-objects"
> would be a big loss.

It is.

> > > I guess I was a bit too hasty on the whining, but just thinking about
> > > C++ compilation speed when using templates give me cries...
> >
> > This has nothing to do with templates.
> I've read the opposite many times, but I know that it's much related
> to C++ pre-processor, headers and linking models, and -again- I'm no
> C++ or compilers expert. If you say it won't be an issue in FPC, I'm
> happier then :-)
> However, I'm still worried about the bloat that templates tend to add
> to the binary/executable 

It would add the same bloat if I implemented all the required classes by
hand... In the ideal case of generics handling.

> and about the difficulty of debugging
> templates (not to say that I prefer name/symbol resolution only
> through inheritance instead of pre-compiler/macro so much better)...

Depends on if it's done right :)

> Cheers,
> Flávio


More information about the fpc-devel mailing list