Why is this not allowed?

Steven Schveighoffer schveiguy at gmail.com
Sat Oct 5 17:26:59 UTC 2024


On Saturday, 5 October 2024 at 06:35:57 UTC, ryuukk_ wrote:
>
> Why is this allowed
> ```D
>
> struct EntityDef
> {
>     struct
>     {
>         int hp;
>     }
> }
> ```
>
>
> But not this fucking thing?
>
> ```D
> struct EntityDef
> {
>     struct
>     {
>         int hp;
>     } stats;
> }
> ```
>
>
> Let me name my shit
>
>
> No, i don't want to do:
>
>
> ```D
> struct EntityDef
> {
>     struct Stats
>     {
>         int hp;
>     } Stats stats;
> }
> ```
>
> Repeating the same name 3 times, i should go back to the stone 
> age too no?
>
> C and all other C like languages allow me to be concise
>
> Why is it a D thing to be backward?

It’s the semicolon. As soon as the closing brace, the declaration 
is over. You would have to invent new syntax.

-Steve



More information about the Digitalmars-d-learn mailing list