digitalmars.D.bugs - [Issue 4664] New: Lambdas default arguments problems
- d-bugmail puremagic.com (32/32) Aug 17 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4664
- d-bugmail puremagic.com (18/18) Aug 17 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4664
- d-bugmail puremagic.com (12/12) Aug 17 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4664
- d-bugmail puremagic.com (7/7) Aug 17 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4664
- d-bugmail puremagic.com (13/13) Aug 30 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4664
- d-bugmail puremagic.com (12/12) Jun 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4664
http://d.puremagic.com/issues/show_bug.cgi?id=4664 Summary: Lambdas default arguments problems Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc In C++0x default arguments are not allowed in lambdas. In D2 they are allowed, but this program shows (compiled with dmd 2.048) that they have problems: import std.stdio: writeln; void foo(T)(T callme) { callme(); } void main() { auto lam1 = (int x=5){ writeln(x); }; auto lam2 = (int x=10){ writeln(x); }; foo(lam1); foo(lam2); } Output: 5 5 Is it positive to disallow default arguments in D2 lambdas too? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4664 Jonathan M Davis <jmdavisProg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg gmail.com 16:42:10 PDT --- I would think that it would be better if the two didn't conflict as opposed to getting rid of default parameters. It looks like they're being turned into the same function when they're not (at least conceptually) - one because they have different default parameters, and two because they're lambdas, not functions with names. Now, assuming that it can't be fixed so that these functions are actually separate like you'd think that they'd be, then it would probably be better to disallow default arguments, but I'd argument that this is a compiler bug rather than a bug in the language. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4664 nfxjfg gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nfxjfg gmail.com Short story: dmd merges the two delegate types into one, and the first default value "wins". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4664 19:12:50 PDT --- It does look like it's essentially a duplicate, though the way that the problem is hit is a bit different. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4664 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 06:35:48 PDT --- As a quick hack while this isn't fixed you can use this: auto lam1 = function (int x=5){ writeln(x); }; auto lam2 = delegate (int x=10){ writeln(x); }; But this will only work with 2 lambdas at most, and it isn't very nice. :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 30 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4664 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 4028 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 08 2011