[fpc-devel] Generics are still broken
Anthony Walter
sysrpl at gmail.com
Fri May 11 18:11:35 CEST 2012
Generics still have a lot of problems. I know they've been in the works
for years but they still fail easily. Consider the Delphi mode below, I get
"Error: Generics without specialization cannot be used as a type for a
variable"
I could easily write up a whole bunch of test cases were generic still
fail, both in Fpc and Delphi modes. If someone is considering working on
the compiler to fix the problems with generics I can happily send them a
bunch of test cases where the compiler currently fails.
{$mode delphi}
{ TEnumerator<T> }
type
TEnumerator<T> = class abstract
protected
function DoGetCurrent: T; virtual; abstract;
function DoMoveNext: Boolean; virtual; abstract;
public
property Current: T read DoGetCurrent;
function MoveNext: Boolean;
end;
{ TEnumerable<T> }
TEnumerable<T> = class abstract
protected
function DoGetEnumerator: TEnumerator<T>; virtual; abstract; // Error:
Generics without specialization cannot be used as a type for a variable
public
function GetEnumerator: TEnumerator<T>;
end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20120511/912688b5/attachment.html>
More information about the fpc-devel
mailing list