[fpc-pascal] Constants in generics

Sven Barth pascaldragon at googlemail.com
Wed Nov 28 13:26:19 CET 2018


Am Mi., 28. Nov. 2018, 09:41 hat Ryan Joseph <ryan at thealchemistguild.com>
geschrieben:

> I just noticed I sent this to the wrong person and the list never saw it
> so I’m sending it again. I feel like I should try to fix it while I’ve got
> my eyes on the generics code before I forget.
>
> Is there a reason it’s not implemented yet? In theory you should be able
> to specialize a function as a type and use the type name as the function
> name. This is basically the same syntax for class construction but without
> the .create.
>
> ====================
>
> As a side node I haven’t been willing to use generic functions yet because
> the syntax is so verbose it kind of defeats the purpose.
>
> Why can’t we specialize functions as a type? Maybe that’s on the todo list
> also?
>

Because that is not supposed to work. Generic routines are *routines*, not
types. You can't define aliases for routines either, not to mention the
problems with scoping as generic methods exist as well.

Generic routines however have a different boon in Delphi that I plan to add
as well: inference of the type parameters based on the parameters the user
passed. In that case the type parameter clause as well as the "specialize"
in non-Delphi modes would not need to be used and it would look like a
normal, non-generic call.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181128/26ae2154/attachment.html>


More information about the fpc-pascal mailing list