Nicer syntax for constructors

Neia Neutuladh neia at ikeran.org
Sun Nov 18 19:28:36 UTC 2018


On Sun, 18 Nov 2018 19:09:16 +0000, Trailzz wrote:
> It would be very easy to infer the types here, so this could also work
> ```
> this(this.a, this.b, this.c, this.d, this.e, this.f)
> ```

Dart does this, for reference. Some random code I happened to have lying 
around:

    class Stat {
      StatType type;
      ShipToValue shipToValue;
      Stat(this.type, this.shipToValue);
    }


So does CoffeeScript:

    class Animal
      constructor: (@name) ->

C++ has initializer lists, which are clunkier, and I think they avoid 
invoking a copy constructor or something.


More information about the Digitalmars-d mailing list