ReturnThis/@chain
dsimcha
dsimcha at yahoo.com
Sat Jul 24 07:44:38 PDT 2010
== Quote from Tomek Sowiński (just at ask.me)'s article
> > pragma(msg, typeof(bar.val(someValue))); // Bar, not Foo.
> This looks like a job for the template this parameter:
> T val(this T)(int newVal) {
> _val =3D newVal;
> return cast(T) this;
> }
> Funny enough, if you put Bar into Foo (Foo bar =3D new Bar; ) it doesn't=
> =
> work no more.
> Tomek
NO #$(&$# WAY!!!!! I (ab)use D metaprogramming constantly and was completely
unaware of template this parameters. This is **exactly** what I needed and I
can't believe it's in the language already.
More information about the Digitalmars-d
mailing list