[Issue 8402] Lambda argument's default value is not taken into account

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 2 14:27:48 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8402


Erik Johansson Andersson <exetoc at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |exetoc at gmail.com


--- Comment #2 from Erik Johansson Andersson <exetoc at gmail.com> 2012-08-02 14:27:43 PDT ---
This seems to be relevant:

void function(int i = 0) f = (int i){};
void delegate(int i = 0) g = (int i){};

void main()
{   
    f();
    g();
}

The error message is: "Error expected 1 function arguments, not 0", for both f
and g.

(In reply to comment #1)
> Default arguments with lambda functions don't really make sense given that
> they're generally only used in one place, that default arguments are _not_ part
> of the type (they're just inserted at the call site), and that there's no way
> for lambdas or function pointers to carry default arguments with them. So, the
> fact that it doesn't compile is a _good_ thing, though it really should give an
> error for giving a default argument and not just an error at the call site.
> 
> This is related to bug# 3646, but I'm not sure if it's strictly speaking a
> duplicate or not.

It did work in 2.059, which was nice, because it allowed libraries like
Derelict to provide bindings for C++ libraries like FreeImage, without having
to modify the interface in order to take into account potential default
arguments which, as of 2.060, isn't the case anymore. Did this old behaviour
have any negative effects at all?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list