Em 27/02/14 09:39, Sven Barth escreveu:
Am 27.02.2014 13:37, schrieb Sven Barth:
Am 27.02.2014 12:12, schrieb Joao Morais:
Em 25/02/14 05:14, Sven Barth escreveu:
A generic is by definition not a fully existant type.
Plans to include generics as a real type for class attributes?
Something like the Java world:
generic TMyGeneric<T: TMyType> <<-- this is the real type
specialize TMyGeneric<TSomeDescendantType> <<-- only for type
safety, discarded after compiling
No, because generics in FPC/Delphi work more like templates in C++
than generics in Java/.Net (in these two it works, because of their
"everything is an object" approach, we don't have that in Pascal).
Correct. The feature I was talking about is something like:
generic TMyGeneric<T: TMyType>
And TMyType is a class. In this case the compiler knows I am talking
about a generic for a class type and a "generic as Java" becomes possible.
Addendum: this does not exclude the compiler from trying to optimize
this if the type parameter is indeed a class type. But this will be
transparent for the user and will have a few restrictions. It does
however not change that generics aren't full types.
:/
Maybe in the near (or not so near) future, these two approaches
(templates and generics like in Java) may live together? I mean: is this
technically possible?
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal