Am 26.06.2012 19:23, schrieb David Nadlinger:
On Tuesday, 26 June 2012 at 16:52:48 UTC, Benjamin Thaut wrote:
Am 26.06.2012 18:44, schrieb Timon Gehr:
On 06/26/2012 06:05 PM, Benjamin Thaut wrote:
Is the compiler smart enough to optimize away a function pointer I
created localy just so I can cast it?
[…]
You can examine the assembly code. DMD is perhaps not smart enough (it
is unable to inline directly called function literals, so I am not
optimistic.) LDC and GDC should certainly optimize it out.
The more I get into this, the more I get the feeling that all this "D
can be used without a GC" is just a marketing trick to get C++ guys to
use D.
This has nothing to do with the GC, just with the compiler turning an
indirect jump to a statically known address into a direct one. Every
decent compiler should optimize it away, and even if it doesn't, it
still won't kill you in 99.9% of the use cases.
David
I'm not talking about the optimization here. I'm talking about not
beeing able to do a propper replacement for new / delete with the
features the language currently has.