On Saturday, 5 October 2024 at 17:26:59 UTC, Steven Schveighoffer
wrote:
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
There is no new syntax to invent
instead of writing this error:
```
onlineapp.d(8): Error: no identifier for declarator `stats`
```
you generate a random identifier and assign it
```D
extern(D) static Identifier generateAnonymousId(const(char)[]
name)
```
https://github.com/dlang/dmd/blob/master/compiler/src/dmd/identifier.d#L165
I'm very far from being bright, but i know simple logic