Sven, recap: I want to make a GenArray function that returns an array populated by a generator anonymous function. For example, GenString would generate a random string by doing GenArray(GenChar). Users could create their own generators, e.g. GenTree wrapping around GenArray(GenLeaf), GenGraph wrapping around GenArray(GenNode) and GenArray(GenEdge), etc.
paycheck.pas: unit Paycheck; interface type generic TArray<T> = array of T; generic TFn<T> = function() : T; function GenInt () : TFn<integer>; function GenBool() : TFn<boolean>; function GenChar() : TFn<char>; function GenArray(gen : TFn<T>) : TArray<T>; function GenString() : TFn<string>; { ... } I'm getting compiler errors for the generics. $ fpc example.pas Free Pascal Compiler version 2.7.1 [2011/10/31] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Darwin for i386 Compiling example.pas Compiling paycheck.pas paycheck.pas(6,25) Error: Generics without specialization cannot be used as a type for a variable paycheck.pas(6,25) Fatal: Syntax error, ";" expected but "<" found Fatal: Compilation aborted Cheers, Andrew Pennebaker www.yellosoft.us On Fri, Oct 21, 2011 at 9:47 AM, Sven Barth <pascaldra...@googlemail.com>wrote: > Am 20.10.2011 17:08, schrieb Andrew Pennebaker: > > 2.6, eh? Awesome. >> >> I'm using the SVN trunk, but it's not working for me for some reason. >> I'll just wait for v2.6 then. >> > > Didn't you just say that you're using 2.4.4? Trunk is currently 2.7.1. > > > Regards, > Sven > > ______________________________**_________________ > fpc-pascal maillist - > fpc-pascal@lists.freepascal.**org<fpc-pascal@lists.freepascal.org> > http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal> >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal