static initialization of structs

Jonathan M Davis jmdavisProg at gmx.com
Sat Dec 1 17:49:30 PST 2012


On Saturday, December 01, 2012 19:36:34 Dan wrote:
> In the thread on compiling DSSS and build tools someone mentioned
> a format for initializing environment data of a struct:
> 
>    Environment env = {
>         tests: true,
>         verbose: true,
>         importDirs: ["../deimos"]
>    }
> 
> A followup comment says "isn't that syntax intended to be
> deprecated?"
> 
> Is this accurate - that the nice json-esque syntax for
> initializing structs will be deprecated? If so, can someone give
> color on why/when?
> 
> Also, for this and other issues regarding features going away, is
> there a central place where these items are being tracked? How
> can we know what is on the chopping block?

That syntax is from C. There was definitely a push to deprecate it, and 
personally I definitely think that it should go, but I don't recall that it was 
definitively decided that it would be removed. Certainly, it's not particularly 
necessary, because if Environment doesn't declare a constructor, you can 
already do the much more D-esque

auto env = Environment(true, true, ["../deimos"]);

Neither the C syntax nor that syntax work if Enviroment declares a 
constructor.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list