On 2017-05-27 01:17, 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);
;

You can do something similar already with source comments

SomeProc(true {p3})

or

SomeProc({p3} true);

But obviously the compiler doesn't check it.

Problem is it increases the verbosity of the code, and how would the compiler determine when to check these and when not to... If you check this all the time it makes the language much more verbose and tedious for small functions like inttostr that you use all the time.

IMO though it does improve readability in long functions with lots of parameters, like windows api style procedures that have 5 or more parameters and you can't figure out which param is which
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to