dynamic classes and duck typing

Alvaro Castro-Castilla alvcastro at yahoo.es
Mon Nov 30 16:19:33 PST 2009


Walter Bright Wrote:

> Simen kjaeraas wrote:
> > It would seem Walter is right, but only for opDispatch. This compiles
> > fine. If you want compile errors, move the ellipsis around:
> 
> Hmm, looks like there is a problem, but it has nothing to do with 
> opDispatch, as this:
> 
>      void bar(string s, T...)(T args)
> 
> doesn't work either.

I think this doesn't work as should. This code:

struct foo {
    void opDispatch( string name, T... )( T values... ) { 
        pragma(msg,values);       // ...shows "tuple()" 
        writeln(values);                  // ...shows nothing at runtime
        foreach(v;values) {            // ...idem
            writeln(v);
        }   
    } 
}
                                                                                                           
void main( ) { 
    foo f;
    f.bar( 3.14, 6.28 );
}

Best regards,

Álvaro Castro-Castilla




More information about the Digitalmars-d mailing list