Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 18, 2012 [Issue 8560] New: Strange behavior of lambda expressions | ||||
---|---|---|---|---|
| ||||
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: ------- |
August 18, 2012 [Issue 8560] Strange behavior of lambda expressions | ||||
---|---|---|---|---|
| ||||
Posted in reply to ilya | 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: ------- |
August 18, 2012 [Issue 8560] Strange behavior of lambda expressions | ||||
---|---|---|---|---|
| ||||
Posted in reply to ilya | 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: ------- |
August 18, 2012 [Issue 8560] Strange behavior of lambda expressions | ||||
---|---|---|---|---|
| ||||
Posted in reply to ilya | 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: ------- |
Copyright © 1999-2021 by the D Language Foundation