[fpc-pascal] Procedural parameters

Hairy Pixels genericptr at gmail.com
Mon Dec 16 04:10:12 CET 2024


 On Dec 15, 2024 at 11:19:40 PM, Sven Barth <pascaldragon at googlemail.com>
wrote:

> It's not as if it is impossible to workaround this limitation:
>
> === code begin ===
>
> program tpointerrec;
>
> {$mode objfpc}
> {$modeswitch advancedrecords}
>
> type
>   generic TPointer<T> = record
>   type
>     PT = ^T;
>   end;
>
>   generic TFindNodeComparator<T> = function(item: specialize
> TPointer<T>.PT): Boolean;
>
>
Yeah this works but look at this code now. I wasn’t there but I’m pretty
sure the convention of “single names” for parameter types was for
readability. There were no generics back then or even types in records so
none of that would have been possible under their guidelines.

That function header violates the entire their concept of readability also
and is a worse offender than ^T and possibly even the inline proc type
could be considered worse.

generic function FindNode<T>(func: specialize TFindNodeComparator<T>):
specialize TPointer<T>.PT;

So the options are bad and worse, pick your poison.

Regards,
    Ryan Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20241215/d07b5bf5/attachment.htm>


More information about the fpc-pascal mailing list