Clay language

Simen kjaeraas simen.kjaras at gmail.com
Thu Dec 30 18:14:28 PST 2010


Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:

> On 12/31/10, Simen kjaeraas <simen.kjaras at gmail.com> wrote:
>>
>
> This will give you both:
>
> class A
> {
>     void bar(this T) ( )
>     {
>         writeln(typeid(T));
>         writeln(typeid(this));
>     }
> }
>
> class B : A
> {
> }
>
> void main( )
> {
>     A a = new B;
>     a.bar();
> }

Indeed it will. Now, if you look closely, you will see that typeid(T) is  
A, while typeid(this) is B. Testing further:

class A {
    void baz() {
        writeln(typeid(this));
    }
}
class B : A {
}

void main() {
     A a = new B;
     a.baz(); // prints B.
}

We thus see that the template this parameter has absolutely no value.


-- 
Simen


More information about the Digitalmars-d mailing list