Named parameters in function call

Cecil Ward cecil at
Tue Sep 8 07:43:05 UTC 2020

I can’t remember, do Ada or Modula2 have something like
      myfunc( x => 100, y => 200, color => blue )        [1]
which has named parameters that can be passed in any order.

Does D have anything like this? If not, would anyone support a 
development like the above [1] ?

If D does not have this, I am wondering about how to write such a 
thing but the cure might very very easily be worse than the 
disease. I have little clue here. I have seen a hack for C 
(written by RevK) that involves assignments to fields in a struct 
and the struct is then passed to a function.

Something like
     myfunc( { field2: 20, field1: 10, fieldstr : "a string" } )   
and preprocessor trickery was used to get rid of the unsightly { 
} by making a macro call to a wrapper macro that takes variadic 
... arguments.

More information about the Digitalmars-d-learn mailing list