What to do about default function arguments
Walter Bright
newshound2 at digitalmars.com
Wed Apr 25 22:25:26 PDT 2012
On 4/25/2012 10:20 PM, H. S. Teoh wrote:
> On Wed, Apr 25, 2012 at 10:08:26PM -0700, Walter Bright wrote:
>> On 4/25/2012 9:42 PM, H. S. Teoh wrote:
>>> This is bad. What if you have two delegates with different default
>>> arguments? What would this code do:
>>>
>>> auto foo = (int a=1) { return a; };
>>> auto bar = (int a=2) { return a; };
>>> writeln(foo());
>>> writeln(bar());
>>>
>>> ?
>>
>> Give you two error messages, because default arguments wouldn't be
>> allowed for delegates.
>
> No I mean the current behaviour. And I just checked: dmd compiles it
> fine, and prints 1 for both cases (which is wrong).
Hence the problem :-)
More information about the Digitalmars-d
mailing list