newbie question: Can D do this?

Stewart Gordon smjg_1998 at yahoo.com
Tue Dec 20 07:31:18 PST 2011


On 20/12/2011 14:18, clk wrote:
> Thank you for your quick replies. I'm impressed by the helpfulness and dedication of the D
> community!
> Here's another one. Is there a way to pass arguments to functions by keyword as in the
> calls to f and g below?

No.  Named arguments have been proposed on at least one occasion:
http://tinyurl.com/cvy99td

<snip>
> void main() {
> f(b = 1, a = 0); // compile error
> g(a = 0); // also compile error
> }
<snip>

Moreover, that notation's no good, since the arguments are already assignment expressions. 
  If the feature is one day implemented it would likely use colons, in line with 
array/struct intialisers.

Stewart.


More information about the Digitalmars-d-learn mailing list