[fpc-pascal] named parameter
Sven Barth
pascaldragon at googlemail.com
Sat May 27 15:26:40 CEST 2017
2017-05-27 9:54 GMT+02:00 Michael Van Canneyt <michael at freepascal.org>:
>
>
> On Sat, 27 May 2017, Mr Bee via fpc-pascal wrote:
>
>> Hi,
>>
>> As Pascal mostly well known as a safe, easy to read, and elegant language,
>> don't you think Pascal needs named parameter? I mean for ALL kind of
>> parameters, not just for Variants. When you have a function with many
>> parameters having default values, you know that named parameter is
>> desirable. For example:
>>
>> function f(p1: string = ''; p2: integer = 0; p3: boolean = false);
>>
>> But you only need to supply the third parameter, you still must supply the
>> first and second ones with appropriate default values, like this:
>>
>> f('', 0, true);
>>
>> while with named parameter, you can do this:
>>
>> f(p3 := true);
>>
>> I believe it would raise Pascal's code readability. I know it has been
>> discussed before. I know somehow the parser had been able to read such
>> syntax. So, why don't we have the option to enable it for people who want
>> it? Kinda a syntax switch mode.
>>
>> What do you think? :)
>
>
>
> Opinions on what constitutes readable code clearly differ :)
>
> But as far as I know, the parser is not able to read this syntax ?
The parser supports it for dispatch calls on variants (both methods
and properties). You even wrote that in your own article about Word
automation: https://www.freepascal.org/~michael/articles/word/word.pdf
;)
Regards,
Sven
More information about the fpc-pascal
mailing list