Please support shorter constructor init

FeepingCreature feepingcreature at gmail.com
Sat Jul 8 08:52:29 UTC 2023


On Saturday, 8 July 2023 at 08:39:13 UTC, Danilo Krahn wrote:
> The question was about the future of shortening the constructor 
> syntax inside the D programming language, not about mixins or 
> struct/class differences.

Well, I guess my answer would be "I don't think this is very 
important, since you can get similarly short constructors using 
mixins such as this library."

Honestly, I'd like the language to just generate sensible 
constructors to begin with. We have default values on struct and 
class members, so why does the autogenerated constructor allow 
omitting fields that don't have a default value?

The `this.x` syntax is very cute, I do like it (Neat uses it for 
its constructors) but it's sort of "neither here nor there". It's 
a syntax hack to make it easier to write a constructor that the 
language could just as easily generate on its own. Its only 
advantage is that it lets you reorder constructor parameters, but 
you can reorder class fields just as easily.


More information about the Digitalmars-d mailing list