[fpc-pascal] Multi-scope helpers draft
pascaldragon at googlemail.com
Sun Nov 25 17:03:01 CET 2018
Am 24.11.2018 um 05:20 schrieb Ryan Joseph:
> I’d like to propose this mode switch ($modeswitch multiscopehelpers) to allow multiple helpers per scope. I have no idea why Delphi thinks only one helper should be allowed in any scope but it cripples the feature severely. Sharing helpers is mostly not possible because of potential conflicts and even relying on helpers in your own code base is not safe because conflicts could occur later. Helpers are basically just a way to extend procedural calls to dot notation so I don’t understand why this restriction was ever out in place (Objective-C and C# never imposed the restriction on their categories/extensions).
> All of the hard work was already done so it was just a matter of lifting the artificial restriction that was placed on them. There’s still clean up to do and as always I may have misunderstood something fundamental about the compiler design.
This is a feature I'll definitely support as that was on my ToDo list
for quite some time already.
It's a good thing that you saw the errors in your first design and
rectified those in the third commit. ;) That commit however contains
unnecessary noise (new line changes? space changes?), so when reworking
the commits for a patch please try to get rid of these.
One thing that bothers me is the "lastonly" parameter. Why did you add
that? In the two locations you added them you'd now have a problem if
multiple helpers are in scope, but the last one does not contain the
requested symbol. In my opinion that parameter is not needed at all.
Another important part of course are tests, both tests that should work
and those that should not.
But other than that this looks good.
More information about the fpc-pascal