Emplace vs closures
ag0aep6g via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 19 06:52:01 PDT 2016
On 09/19/2016 02:55 PM, Timon Gehr wrote:
> This works:
> import std.stdio;
> void main(){
> int x=3;
> enum l=()=>x;
> writeln(x);
> }
>
> I.e. l has the correct runtime context even though it is a static value.
Enums are a special kind of static value, though. Can't do that with
`static` instead of `enum`. Enums (often?) don't manifest until they're
used. Could .init work that way?
More information about the Digitalmars-d
mailing list