Why is this not allowed?

Boaz Ampleman ba at 1234.de
Wed Oct 9 01:16:29 UTC 2024


On Tuesday, 8 October 2024 at 18:24:50 UTC, germandiago 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?
>
> The problem is clear. What I do not agree with is your tone. I 
> am noone here, but I think it is not good to tolerate this 
> level. It sets a bad precedent.
>
> Just my 2 cents.

I'm not a big fan of using declarations as type either:

```d
bool doWeWantThat( struct{ int notsure;} p)
{
     return false;
}
```

in the same way, named fields in tuples is an aberration to me, 
because "why not use a struct instead ?"


More information about the Digitalmars-d-learn mailing list