flavio.etrusco at gmail.com
Tue Apr 11 23:56:43 CEST 2006
On 4/11/06, Danny Milosavljevic <danny.milo at gmx.net> wrote:
> Am Montag, den 10.04.2006, 23:33 -0300 schrieb Flávio Etrusco:
> > On 4/10/06, Danny Milosavljevic <danny.milo at gmx.net> wrote:
> > > Hi,
> > >
> > (...)
> > > > 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 :)
> > You got me confused here.
> bla: TList(Integer);
> i := inp(49330);
> until i = 0;
> I meant that no matter what you do, once you need any more than a static
> number of values remembered, you already need them... (strings are a
> special case though)
Do you honestly have any use for generics supporting primitive types
other than writing half a dozen containers?
> How low is "low level"?
> > > > There are relatively few native types that is usually ok duplicate the
> > > > whole code if it need be.
> set (all possible set definitions)
> enum (all possible enum definitions)
> record (all possible record definitions)
> array (all possible array definitions)
> and one is supposed to repeat (at least) all collection object classes
> for each of them? You can't be serious...
You can't be serious. Why do you need containers or whatever code so
specific and optimized for all these types? And do you wanna count
many TObject descendants vs. native types (including records) does the
e.g. FCL include?
> > > are strings classes or primitive in your mind?
> > My mind is FPC, so it's a primitive type.
> I see. TDictionary(string, TObject) doesn't work then? (one of the most
> used mappings with cgis, at least)
Why do the String in this case need to be anything other than a String?
> > > > 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 :)
> > Arguably. But considering C++ has almost 15 years of head start and
> > they couldn't get it right yet, I guess it's not an easy task...
> They are working pretty well now (in gcc)...
I'm talking about debbuging, so besides gcc, gdb and some other user
interface must be working pretty well too; what are they?
I know that VisualStudio 2003 certainly isn't (I didn't try VS 2005
yet, but I doubt it is any better is this respect...).
> > PS. BTW I've just realized that not possible to fully replace 'type
> > erasure generics' in the compiler with 'templates'... at least not as
> > efficiently, right?
> A mixture is best: use the same generic specialization where possible
> and new specializations otherwise...
If this was the case of course I would have be glad :-) I'd still be
afraid to have FCL becoming anything like the STL (i.e. as horrible
and impossible to read as it), though...
Following the URL Micha sent in a previous reply, I've just read that
.net 2 supports generics for native type by recompiling the templates
only in this case. Interesting...
More information about the fpc-devel