struct initializer

Dom DiSc dominikus at scherkl.de
Fri Dec 1 13:11:22 UTC 2023


On Thursday, 30 November 2023 at 12:15:04 UTC, Dennis wrote:
> The syntax was inherited from C. The 'special place' is called 
> initialization, and it's special because the target type of the 
> initializer is known in advance

This is no different from `S fun(){ return { 5, 2 }; }` It 
creates a new instance of a struct, and the type is known in 
advance (it's the return type). So it's not an expression. But 
this place of initialization is not allowed. Therefor I think 
calling  `S s = { 5, 2 };` 'special' is justified.



More information about the Digitalmars-d-learn mailing list