Please support shorter constructor init

ryuukk_ ryuukk.dev at gmail.com
Sat Jul 8 20:54:14 UTC 2023


On Saturday, 8 July 2023 at 19:57:55 UTC, Nick Treleaven wrote:
> On Saturday, 8 July 2023 at 15:58:57 UTC, ryuukk_ wrote:
>> 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
>
> It's not advice. It's explaining what the example code means 
> with the new feature.
>
>> nobody should use constructor on structs
>
> That's the first time I've ever heard that.
>
> https://dlang.org/phobos/std_typecons.html#.Nullable.this
> https://dlang.org/phobos/std_typecons.html#.Tuple.this
> https://dlang.org/phobos/std_typecons.html#.Unique.this

All of these are poorly designed constructs

Nullable? should be a tagged union or something built-in, tuple, 
should be built-in as well


>> and nobody should use classes for basic stuffs that should be 
>> simple pod
>
> What if you want a vector reference type on the heap, e.g. for 
> immutable vectors to share across threads? `new Struct` would 
> return a pointer, so `+=` won't work. Or if you want it to be 
> `synchronized`?

This is the result of poorly designed software, you always want 
to do more esoteric things; "the java way"




More information about the Digitalmars-d mailing list