[Issue 5749] argument evaluation order of chained function from right
https://d.puremagic.com/issues/show_bug.cgi?id=5749 --- Comment #9 from github-bugzi...@puremagic.com 2014-01-04 22:27:55 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7a31af4b65667fa6a993743f493e8d5f156e0d30 fix Issue 5749 - argument evaluation order of chained function from right https://github.com/D-Programming-Language/dmd/commit/d9c783cac6d06b7be8b5888e574694aec426a470 Merge pull request #2881 from 9rnsr/fix5749 Issue 5749 - argument evaluation order of chained function from right -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5749] argument evaluation order of chained function from right
https://d.puremagic.com/issues/show_bug.cgi?id=5749 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Keywords||pull --- Comment #6 from Kenji Hara k.hara...@gmail.com 2013-11-25 17:34:28 PST --- https://github.com/D-Programming-Language/dmd/pull/2881 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5749] argument evaluation order of chained function from right
https://d.puremagic.com/issues/show_bug.cgi?id=5749 bearophile_h...@eml.cc changed: What|Removed |Added CC||bearophile_h...@eml.cc --- Comment #7 from bearophile_h...@eml.cc 2013-11-25 17:48:47 PST --- This patch seems important. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5749] argument evaluation order of chained function from right
https://d.puremagic.com/issues/show_bug.cgi?id=5749 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Keywords||wrong-code Severity|enhancement |major --- Comment #8 from Kenji Hara k.hara...@gmail.com 2013-11-25 18:28:48 PST --- (In reply to comment #7) This patch seems important. The root issue is very similar to bug 8396. When method call is used, the side effect of callable entity (evaluation of 'this' object + getting member function pointer) is not ordered before the arguments evaluation. I think this is not intended behavior. For example, this code evaluates function arguments left-to-right. extern (C) int printf(const char*, ...); void main() { void delegate(int) foo(int i) { printf(i: %d\n, i); return (a){ foo(a); }; } auto getFunc() { return foo; } int i; getFunc()(++i)(++i); // getFunc() is evaluated before the first ++i expression, // and getFunc()(++i) is evaluated before the second ++i expression. } Because l-to-r evaluation is enforced by the glue-layer code https://github.com/D-Programming-Language/dmd/blob/7360ae8611add4dc0a89cd870a6ac6490fb2a19b/src/e2ir.c#L3706 The code was introduce by the commit: https://github.com/D-Programming-Language/dmd/commit/80e2319878bee3bb139a20c0bc1b85b1ec04b892 If you comment out the part, above example code will be broken. Therefore, I'll change this issue to 'wrong-code' bug. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5749] argument evaluation order of chained function from right
http://d.puremagic.com/issues/show_bug.cgi?id=5749 d...@dawgfoto.de changed: What|Removed |Added CC||d...@dawgfoto.de --- Comment #5 from d...@dawgfoto.de 2011-09-07 15:53:41 PDT --- The result also changes with respect to enabling -inline or not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5749] argument evaluation order of chained function from right
http://d.puremagic.com/issues/show_bug.cgi?id=5749 --- Comment #3 from Steven Schveighoffer schvei...@yahoo.com 2011-03-18 13:37:35 PDT --- If you consider that 'this' is the first argument to the opCall, you would expect this to do the same thing: A blah(A a, size_t i) { printf(i=%d\n, i); return a; } blah(blah(a, ++i), ++i); but it does print: i=1 i=2 So there is something definitely inconsistent here. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5749] argument evaluation order of chained function from right
http://d.puremagic.com/issues/show_bug.cgi?id=5749 --- Comment #4 from Fawzi Mohamed fa...@gmx.ch 2011-03-18 13:59:28 PDT --- clearly about this I agree with Steven, the correct (or expected if you prefer) evaluation should be to evaluate the arguments as late as possible. a(b)(c); is the same as (a(b))(c) I would expect c not to be evaluated before a(b) is fully evaluated (both b *and* a(b)), otherwise whisper style is broken, and is counterintuitive. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---