Re: Optimize away immediately-called delegate literals?

2012-03-14 Thread Steven Schveighoffer
On Mon, 12 Mar 2012 20:28:15 -0400, H. S. Teoh hst...@quickfur.ath.cx wrote: Hmph. I tried this code: import std.stdio; struct A { int[] data; int opApply(int delegate(ref int) dg) { foreach (d; data) {

Re: [OT] Hanlon's Razor (Was: Optimize away immediately-called delegate literals?)

2012-03-12 Thread H. S. Teoh
On Sun, Mar 11, 2012 at 03:03:39AM -0400, Nick Sabalausky wrote: H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.455.1331448575.4860.digitalmar...@puremagic.com... Never ascribe to malice that which is adequately explained by incompetence. -- Napoleon Bonaparte Pardon

Re: Optimize away immediately-called delegate literals?

2012-03-12 Thread Peter Alexander
On Sunday, 11 March 2012 at 06:49:27 UTC, H. S. Teoh wrote: On Sun, Mar 11, 2012 at 01:29:01AM -0500, Nick Sabalausky wrote: Suppose you have a delegate literal and immediately call it: auto a = x + (){ doStuff(); return y; }() + z; Does DMD ever (or always?) optimize away a delegate if it's

Re: Optimize away immediately-called delegate literals?

2012-03-12 Thread H. S. Teoh
On Tue, Mar 13, 2012 at 12:15:02AM +0100, Peter Alexander wrote: On Sunday, 11 March 2012 at 06:49:27 UTC, H. S. Teoh wrote: On Sun, Mar 11, 2012 at 01:29:01AM -0500, Nick Sabalausky wrote: Suppose you have a delegate literal and immediately call it: auto a = x + (){ doStuff(); return y; }()

Re: Optimize away immediately-called delegate literals?

2012-03-12 Thread Brad Roberts
On 3/12/2012 4:15 PM, Peter Alexander wrote: On Sunday, 11 March 2012 at 06:49:27 UTC, H. S. Teoh wrote: On Sun, Mar 11, 2012 at 01:29:01AM -0500, Nick Sabalausky wrote: Suppose you have a delegate literal and immediately call it: auto a = x + (){ doStuff(); return y; }() + z; Does DMD ever

Re: Optimize away immediately-called delegate literals?

2012-03-12 Thread Nick Sabalausky
Peter Alexander peter.alexander...@gmail.com wrote in message news:thetmhnnbeepmxgus...@forum.dlang.org... On Sunday, 11 March 2012 at 06:49:27 UTC, H. S. Teoh wrote: On Sun, Mar 11, 2012 at 01:29:01AM -0500, Nick Sabalausky wrote: Suppose you have a delegate literal and immediately call it:

Re: Optimize away immediately-called delegate literals?

2012-03-12 Thread Nick Sabalausky
Brad Roberts bra...@puremagic.com wrote in message news:mailman.582.1331607753.4860.digitalmar...@puremagic.com... On 3/12/2012 4:15 PM, Peter Alexander wrote: On Sunday, 11 March 2012 at 06:49:27 UTC, H. S. Teoh wrote: On Sun, Mar 11, 2012 at 01:29:01AM -0500, Nick Sabalausky wrote: Suppose

Re: Optimize away immediately-called delegate literals?

2012-03-12 Thread Brad Roberts
On 3/12/2012 8:10 PM, Nick Sabalausky wrote: Brad Roberts bra...@puremagic.com wrote: See also: bug 4440 The patch in there, if it hasn't bit rotten to badly (I suspect it has) will handle _this_ case. But almost no other case of inlining delegates. It'd be a good area for someone who

Optimize away immediately-called delegate literals?

2012-03-10 Thread Nick Sabalausky
Suppose you have a delegate literal and immediately call it: auto a = x + (){ doStuff(); return y; }() + z; Does DMD ever (or always?) optimize away a delegate if it's executed immediately and never stored into a variable? If not, can it, and would it be a simple change? Is something like this

Re: Optimize away immediately-called delegate literals?

2012-03-10 Thread H. S. Teoh
On Sun, Mar 11, 2012 at 01:29:01AM -0500, Nick Sabalausky wrote: Suppose you have a delegate literal and immediately call it: auto a = x + (){ doStuff(); return y; }() + z; Does DMD ever (or always?) optimize away a delegate if it's executed immediately and never stored into a variable? If

[OT] Hanlon's Razor (Was: Optimize away immediately-called delegate literals?)

2012-03-10 Thread Nick Sabalausky
H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.455.1331448575.4860.digitalmar...@puremagic.com... Never ascribe to malice that which is adequately explained by incompetence. -- Napoleon Bonaparte Pardon me veering offtopic at one of your taglines yet again, but I have to