Helper for Generic
Issue #238
closed
Hello,
How can I do something like this in DWScript please?
ForEach<T> = helper for Array of T
procedure forEach(procedure(value: T));
end;
Comments (4)
-
reporter -
repo owner Auto-instantiation of generics is not active yet, you have to manually instantiate them for each type you want them applied to.
The limitation for that comes from consideration of compile time performance and not having had time yet to reverse engineer the scoping priorities Delphi uses for generics in those cases.That said, ForEach is a good candidate for language support, if only because it would map so directly with the JS codegen, and script-side, in most cases it could be inlined as a classic loop directly without having to resort to full-blown inlining machinery.
-
repo owner - changed status to closed
ForEach implemented by 43fb9a08d75899d693fb72c2b75b842848fcdb62
-
reporter Thank you @Eric Grange
- Log in to comment
As Helper for Variant is supported, I did like this: