What to do about default function arguments
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Apr 25 22:20:53 PDT 2012
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).
T
--
EMACS = Extremely Massive And Cumbersome System
More information about the Digitalmars-d
mailing list