On 17.03.2013 15:33, Flávio Etrusco wrote:
On Sun, Mar 17, 2013 at 6:59 AM, Sven Barth <pascaldra...@googlemail.com> wrote:
On 17.03.2013 06:00, Flávio Etrusco wrote:
type generic TAlias1<T: TObject> = class(TObject)
function Alias1: T;
end;
This already works.
In 2.7 I assume, because it doesn't work in 2.6.2. Great anyway :)
Of course only 2.7.1 :P
function<T: TObject> Alias1(Source: T): TAlias1<T>;
I don't really get what you want to express with that...
This is a Java a construction, I don't know whether it exists in other
languages.
In Java you specify it before the result type. It means the
parameterized result is be based on the parameter it receives. You can
also "bind" several parameters:
static <T extends Comparable> int IndexOf(List<T> p_list, T p_item);
So you're basically just talking about generic methods here? The Delphi
compatible syntax for your two examples are:
=== code begin ===
function Alias1<T: TObject>(Source: T): TAlias1<T>;
function IndexOf<T: Comparable>(p_list: List<T>; p_item: T): LongInt;
=== code end ===
Support for generic methods (and global functions/procedures) is already
planned. They will of course support generic constraints as well (it
would be inconsistent if they wouldn't).
Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal