Can now use alias for collapsing multiple fields in nested structs

ryuukk_ ryuukk.dev at gmail.com
Wed Jan 8 08:13:58 UTC 2025


On Tuesday, 7 January 2025 at 10:10:19 UTC, Derek Fawcus wrote:
> The main issue with a C style anonymous struct and definition
>
> ```C
> struct outer {
>    struct {
>       int a;
>    } instance;
> }
> ```
>
> Would be the grammar point previously mentioned, making the 
> above incompatible, due to structs within structs not requiring 
> terminating semi-colons.
>
> Changing that in general would be too big a breaking change to 
> be viable.
>
> Depending upon how much use is currently made of D style 
> 'anonymous structs', the one possibility I could see is 
> changing the grammar to require such to have a trailing 
> semi-colon.  This is also a breaking change, but possibly it 
> would be viable if the current D style anonymous structs are 
> not commonly used.
>
> However at this stage, I'd be inclined just to say forget about 
> it.
>
> The C style can be handled by ImportC, albeit any .di file 
> generated by such can not express the concept.
>
> So if one wishes to have this form used, one simply needs to 
> have mixed C and D program.

https://github.com/dlang/dmd/pull/20653

D++ gets a free pass


More information about the Digitalmars-d mailing list