[fpc-devel] Templates / Generics Problems
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Nov 3 19:39:30 CET 2005
There are some unsolved problems of generics in free pascal:
1.
See wiki:
http://www.freepascal.org/wiki/index.php/Generics#Notes
The generic should not use private parts of a unit:
interface
generictype declar
implementation
procedure helper;
begin
end
constructor generictype.create
begin
helper
end
end.
IMO this can be allowed. But maybe it is a problem for the compiler?
2. Circle dependencies:
unit a;
interface
generictypeA
implementation
uses B
end.
unit b;
interface
uses a
implemenation
begin
generictypeA<integer>.create
end.
Same: a problem for the compiler?
3.
Name space.
The unit, where the template is defined, has different uses clauses, than
the unit, where the template is declared.
In which order are the units searched?
a) Ignore uses clause of template unit
b) First uses clause of template unit, then uses clause of using unit.
c) ?
4.
Automatic generic parameters:
var List: TGenericList<integer>;
begin
List:=TGenericList.Create;
// Note: ^ missing <integer>
end;
I'm against automatic generic parameters.
I don't even like the generic declaration without a type name.
I would only allow named types:
type TListOfInteger = TGenericList<integer>;
Mattias
More information about the fpc-devel
mailing list