Proposal: struct and array literal syntax

Alexander Panek alexander.panek at brainsware.org
Tue Jun 20 02:39:19 PDT 2006


I like the idea very much, as it's like:
"Use MyStruct as a 'template' for this data!{...}"

Chris ftw! (Got my vote ;) )

Regards,
Alex

Chris Miller wrote:
> This is an old idea I had, and also applies to struct initializers which 
> now has ambiguity with literal delegates.
> 
> Given the following struct:
>    struct MyStruct { int foo; int bar; }
> can be created with the following proposed syntax:
>    MyStruct!{3, 4}
> which can be used in initializers and anywhere else MyStruct is expected.
> 
> For array initializers, see the following proposed syntax:
>    int[]![6, 7, 8, 9]
> which creates a dynamic array of 4 int elements.
> This as well can be used in initializers and anywhere else such an array 
> is expected.
> 
> - Chris



More information about the Digitalmars-d mailing list