[fpc-pascal] Named optional arguments

Sven Barth pascaldragon at googlemail.com
Sun Nov 28 13:01:12 CET 2021


Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
So., 28. Nov. 2021, 03:12:

>
>
> > On Nov 27, 2021, at 5:00 PM, Sven Barth <pascaldragon at googlemail.com>
> wrote:
> >
> > The compiler does not know which routine is called upon parsing the
> parameter declarations (which would mean that error reports would need to
> be deferred until the lookup of the routine failed).
>
> My idea was to not actually have it affect overloading except in the case
> where the param names don't match which would ignore the call (so in your
> example below nothing changes).
>
> Otherwise if the name was actually part of the overloading we would have
> to allow functions with the same parameter type but different names, i.e.:
>
> procedure Foo(Arg1: String = '');
> procedure Foo(Arg2: String = '');
>
> and that would be a big change to the language and have all sorts of
> implications.
>
> So it's really just a minor hint to make the call more readable in the
> case of long function names.
>

Anything that relates to picking functions *must* be part of the overload
handling. You can easily see this with your named argument proposal when
not all arguments are named (and then the compiler also needs to check that
unnamed parameters aren't used for named ones as well, this gets more
complicated if the overloads have different argument names).

You should have already learned this lesson when I pointed you in the right
direction for the implicit function specializations.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20211128/803ccbb5/attachment.htm>


More information about the fpc-pascal mailing list