[fpc-devel] Functors

Ryan Joseph genericptr at gmail.com
Mon Dec 27 04:17:15 CET 2021



> On Dec 27, 2021, at 1:44 AM, Blaise at blaise.ru wrote:
> 
> So, in your book, introducing a /new/ operator identifier "doesn't present any new syntax" (and I agree), but semantically allowing the /existing/ directive DEFAULT to appear in the existing list of method directives is somehow "a new syntax". You have some interesting definition of "syntax".

I was mainly just trying to predict what Sven will say because I've proposed so many things over the recent years. :) "Default" has never been used outside of properties which is why it could be considered "new syntax".

As for the idea of a "call operator" that would require "self" to be passed in as the first param (like record management operators) AND "class operator" is not allowed in classes right now so this would limit it to records  only. I already tried to get Sven to accept class operators on classes (for some operators only) and this was rejected.

Given that I would say this would indeed go the way of properties since it's a form of aliasing or re-routing:

      property Invoke: T read DoInvoke; default;

However I have already made a patch (nearly finished) for a "default record property" which does something similar to this (it's meant for smart pointers like how C++ overloads the -> operator) and even though Sven did seem behind the idea I don't see he's been willing to follow up on it. Not sure what this means for the feature or if it will ever be accepted.

https://gitlab.com/genericptr/free-pascal/-/tree/default_record_property

So if there is now a default method it would confound this idea even further and it's already not clear if FPC will accept this kind of thing.

I'm not saying any of this to discourage the idea though since I think it's interesting.

Regards,
	Ryan Joseph



More information about the fpc-devel mailing list