digitalmars.D.bugs - [Issue 8560] New: Strange behavior of lambda expressions
- d-bugmail puremagic.com (38/38) Aug 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8560
- d-bugmail puremagic.com (13/13) Aug 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8560
- d-bugmail puremagic.com (9/11) Aug 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8560
- d-bugmail puremagic.com (9/11) Aug 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8560
http://d.puremagic.com/issues/show_bug.cgi?id=8560 Summary: Strange behavior of lambda expressions Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: iu.biryukov gmail.com --- Comment #0 from ilya <iu.biryukov gmail.com> 2012-08-18 13:45:45 PDT --- I came up with this code while playing around with D: import std.stdio; public class Test(alias fun, alias fun2) { void doIt() { fun(); fun2(); } } void main() { (new Test!( () => {writeln("fun1");}, () => writeln("fun2") ) ).doIt(); } After compiling this code I expect to see the following output(or compiler error, if I'm misusing lambda syntax): fun1 fun2 Insted I get: fun2 DMD64 D Compiler v2.060 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 18 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8560 klickverbot <code klickverbot.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |code klickverbot.at Resolution| |INVALID --- Comment #1 from klickverbot <code klickverbot.at> 2012-08-18 13:48:30 PDT --- Marking as invalid, since {writeln("fun1");} is a parameterless delegate literal. This delegate is returned by the call to fun(), but never invoked. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 18 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8560 --- Comment #2 from ilya <iu.biryukov gmail.com> 2012-08-18 13:55:08 PDT --- (In reply to comment #1)Marking as invalid, since {writeln("fun1");} is a parameterless delegate literal. This delegate is returned by the call to fun(), but never invoked.Thanks, now I get it. Though this behavior looks a bit odd to me. But that's probably because of C# background. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 18 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8560 --- Comment #3 from klickverbot <code klickverbot.at> 2012-08-18 13:57:54 PDT --- (In reply to comment #2)Though this behavior looks a bit odd to me. But that's probably because of C# background.Mhm, even if the current behavior is to spec, it can definitely be surprising. If you feel something should be done about this, please consider starting a discussion on the forums. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 18 2012