DisForDave wrote: > downs Wrote: > >> Nick Sabalausky wrote: >>> "Daniel Keep" <[email protected]> wrote in message >>> news:[email protected]... >>>> Penguin wrote: >>>>> What do you think about: >>>>> >>>>> class Foo { >>>>> >>>>> int a; >>>>> float b; >>>>> >>>>> this( member a, member b ) { >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> instead of: >>>>> >>>>> class Foo { >>>>> >>>>> int a; >>>>> float b; >>>>> >>>>> this( int a, float b ) { >>>>> this.a = a; >>>>> this.b = b; >>>>> } >>>>> >>>>> } >>>> I don't know that saving a few (very simple) lines of code is worth >>>> adding a new keyword and magic behaviour to ctor arguments. >>>> >>>> If you really wanted to just do that, you could probably write a mixin >>>> to take care of it. >>>> >>> I just happen to already have such a thing in my bag-o-tricks. See >>> attachment. >>> >>> Usage: >>> ---- >>> mixin(initMember!(someVar)); >>> mixin(initMember!(a, b, c)); >>> ---- >>> >>> Turns Into: >>> ---- >>> this.someVar = someVar; >>> this.a = a; >>> this.b = b; >>> this.c = c; >>> ---- >>> >>> >>> >> I _also_ have something for this for Phobos (in tools.base), but it's >> intended for simple constructors. >> >> class Foo { >> int a; float b; >> mixin This!("a, b"); >> } >> >> Or to add some instruction: mixin This!("a; #b = 0f; "); >> >> Or to add a super call and defaults: mixin This!("a, super(b=0f)"); > > > but this is something the compiler should really be dealing with, it's such a > common programming practice (the fact so many people have their own hacks for > it is testament to this) > > i think it's worth a new keyword
But that's the point - the language is powerful enough that the hacks work fine. No _need_ for a keyword.
