function argument 'shorthand'
Derek Parnell
derek at psych.ward
Mon May 22 19:47:31 PDT 2006
On Mon, 22 May 2006 19:30:45 -0700, Walter Bright wrote:
> Dave wrote:
>> Couldn't find this in the archive, so I don't know if it's been discussed
>> before.
>>
>> One of the things I like about Pascal is that you can specify function arguments
>> of the same type w/o repeating the type. So, in D we could:
>>
>> int foo(int x, y, z) // y and z are type int
>> {}
>>
>> int bar(int x = 1, y = 2, z = 3) // y and z are type int
>> {}
>>
>> void baz(int x, y, double d, f = 3.14159) // y is an int, f is a double
>> {}
>>
>> Thoughts?
>
> It has grammatical ambiguities. Consider:
>
> int foo(int x, y);
>
> Is the second a declaration of y of type int, or is it a parameter of
> type y?
Aside from the suggested syntax, what do you think about the concept,
Walter?
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
23/05/2006 12:46:33 PM
More information about the Digitalmars-d
mailing list