Feature request - simpler constructors

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Sep 20 03:33:04 PDT 2007


Janice Caron wrote:
> Please could we let
> 
>  this(auto n) {}
>  T n;
> 
> be syntactic sugar for
> 
>  this(T n)
>  {
>      this.n = n;
>  }
>  T n;
> 
> I've lost count of the number of times I've written constructors which
> do nothing but copy function parameters into member variables. If you
> have a lot of variables, it gets very tedious, especially when you
> have to do it over and over again. I tend to give my constructor
> paramters different names to avoid typing "this." all the time, but I
> still end up with, for example:
> 
[snip]
> 
> That would be /so cool/. "auto" can have no other possible meaning in
> this context.
[snip]

So true.

vote++



More information about the Digitalmars-d mailing list