Please support shorter constructor init

ryuukk_ ryuukk.dev at gmail.com
Sat Jul 8 15:58:57 UTC 2023


On Saturday, 8 July 2023 at 15:33:34 UTC, Danilo Krahn wrote:
> On Saturday, 8 July 2023 at 14:52:34 UTC, ryuukk_ wrote:
>>
>> Constructor on structs?
>>
>> Vectors as classes with inheritance?
>>
>> Sorry, but this is just bad advice that nobody should follow
>
> This has nothing to do with "Vector" or "inheritance".
>
> It's about repeating constructor initialization.
>
> Modern languages support direct init using `this` and `super` 
> inside the
> parameters, so repeating `this.x = x` is not neccessary.
>
> https://dart.dev/language#classes

nobody should use constructor on structs

and nobody should use classes for basic stuffs that should be 
simple pod

```d
struct vec3 {
     float x,y,z;
}

auto v = vec3(1,2,3);
```

This already works

```d
vec3 v = { x: 1, y: 2, z: 3 }
```

This also works




More information about the Digitalmars-d mailing list