ReturnThis/@chain
Simen kjaeraas
simen.kjaras at gmail.com
Sat Jul 24 07:53:43 PDT 2010
On Sat, 24 Jul 2010 16:44:38 +0200, dsimcha <dsimcha at yahoo.com> wrote:
> == 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.
What, this is seriously already here? Why the fuck was I not informed?
Seriously, this is one under-advertised feature.
--
Simen
More information about the Digitalmars-d
mailing list