On Fri, Feb 08, 2019 at 03:42:51PM -0800, H. S. Teoh via Digitalmars-d-announce 
wrote:
> On Fri, Feb 08, 2019 at 11:34:47PM +0000, Dennis via Digitalmars-d-announce 
> wrote:
> > On Friday, 8 February 2019 at 23:02:34 UTC, Nicholas Wilson wrote:
> > > Immediately called lamdas are always inlined.
> > 
> > ```
> > extern(C) void main() {
> >     int a = (() => 1)();
> > }
> > ```
[...]
> Does LDC/GDC inline it?
> 
> I no longer trust dmd for codegen quality. :-/
[...]

Just checked: LDC does inline it.  In fact, LDC compiles the whole thing
out and just has `ret` for main(). :-D  Forcing LDC not to elide the
whole thing by inserting a writeln(a) call reveals that the lambda is
indeed inlined.

Yep, the moral of the story is, if codegen quality is important to you,
use ldc (and presumably gdc too) rather than dmd.


T

-- 
Freedom of speech: the whole world has no right *not* to hear my spouting off!
          • Re: D... Don via Digitalmars-d-announce
            • ... 12345swordy via Digitalmars-d-announce
  • Re: DIP 1016--ref T ac... bitwise via Digitalmars-d-announce
    • Re: DIP 1016--ref... Dominikus Dittes Scherkl via Digitalmars-d-announce
      • Re: DIP 1016-... bitwise via Digitalmars-d-announce
        • Re: DIP 1... Paul Backus via Digitalmars-d-announce
          • Re: D... bitwise via Digitalmars-d-announce
            • ... Nicholas Wilson via Digitalmars-d-announce
              • ... Dennis via Digitalmars-d-announce
              • ... H. S. Teoh via Digitalmars-d-announce
              • ... H. S. Teoh via Digitalmars-d-announce
              • ... Dennis via Digitalmars-d-announce
              • ... H. S. Teoh via Digitalmars-d-announce
              • ... bitwise via Digitalmars-d-announce
              • ... H. S. Teoh via Digitalmars-d-announce
              • ... Daniel N via Digitalmars-d-announce

Reply via email to