>> - instantiation will be only possible in declaration blocks, not in code >> blocks: >> possible: >> var >> mylist : TList<integer>; >> const >> mylist : TList<integer> = nil; >> type >> mylist = TList<integer>; >> forbidden: >> procedure p(mylist : TList<integer>); >> begin >> ... >> mylist:=TList<integer>.create; >> ... >> end; > > This seems like a smart and sufficient solution to avoid the problem of > parsing < tokens in code blocks. > > On the other hand, programmers will like it (a lot) more if they don't > need to separately define a type for every generic instantiation. Is the > token-lookahead approach proposed elsewhere in this thread not a > sufficient solution? If it is not very easy, or if we are quite unsure > about this for now, perhaps we can postpone the implementation of > in-code(block) generic instantiation to a later time and first implement > generics as above.
The token-lookahead is a hack and will create more problems and performance loss in a critical part of the compiler. The restriction of type blocks only is not strange at all, Delphi allows 'class of' is also only in type blocks _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel