Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global scope procedures cannot be generic? Is there a technical reason for this restriction?

Why is it that using generic types in a global procedure is not permitted. For example:

  procedure Foo<T>(bar : T);

Compiler Error: E2530 Type parameters not allowed on global procedure or function

Yet it is acceptable as a class method

TFoo = class(TObject)
public
  class procedure Foo<T>(bar : T);
end;

That's obviously my workaround, but I am interested in whether there an actual technical reason for the restriction.

like image 784
Adam G Avatar asked May 23 '18 05:05

Adam G


1 Answers

There is no technical reason why procedures at global scope could not be generic.

If the designers wanted to implement this, then it could be done.

like image 120
David Heffernan Avatar answered Nov 10 '22 03:11

David Heffernan