Feature request - simpler constructors

Jari-Matti Mäkelä jmjmak+news at utu.fi.invalid
Thu Sep 20 11:47:21 PDT 2007


Bill Baxter wrote:

> I guess the main worry lurking in the back of my mind is that we may
> actually want to use auto in parameter lists someday to mean more or
> less what it means in declarations:
> 
>      void foo(auto y = "hi there",
>               auto x = 23.f,
>               const z = ABigNamedStruct())
>      {. . . }
> 
> And having it mean something slightly different for 'this' methods than
> for an ordinary 'foo' method would just be confusing.

Exactly. When the macros come, I expect to be able to say

  initMembers(a,b,c);

and the compiler to turn that into:

  this.a = a;
  this.b = b;
  this.c = c;

I find it a bit dangerous to add new features without taking into account
all semantics. The assignment part is pretty simple compared to the
parameter type inference. Still, what about the order of assignments? What
if it should be different than the order or parameters (e.g. because of
side effects)?



More information about the Digitalmars-d mailing list