named parameters to functions

David Brown dlang at davidb.org
Fri Oct 12 08:59:45 PDT 2007


On Fri, Oct 12, 2007 at 11:42:07AM -0400, novice2 wrote:
>> It would be better to implement using syntax that doesn't conflict with
>> other parts of the grammar.  Perhaps:
>> 
>>    window* w = new_window ("alert box", movable: false);
>> 
>
>or using other language expirence, e.g. oracle pl/sql:
>1 - mixing normal and named params prohibited

Common is to allow positional parameters first, followed by unnamed
parameters.  This is how most languages do it, including python (sort of),
Ada, ocaml, and probably others.  The basic rule is that once you have a
named parameter, none following it can be positional.

>2 - use special token between param's name an dvalue (pl/sql uses name=>value )

The colon is a special token in this case, since it isn't possible in the
existing grammar at this position.  Using an entirely new token might help
make better error messages.

Dave



More information about the Digitalmars-d mailing list