dynamic classes and duck typing

biozic dransic at free.fr
Sun Nov 29 04:16:11 PST 2009


Le 29/11/09 12:14, Simen kjaeraas a écrit :
> That is because your opDispatch is instantiated no matter what the name
> is, but only does something sensible if it's foo. Try this:
>
> string opDispatch( string name )( ) {
> static if ( name == "foo" ) {
> return "foo";
> } else {
> static assert( false, "Invalid member name." );
> }
> }
>

Ok but what still looks confusing is that the error is reported on the 
template code, as for any template instantiation error, while the user 
could not be aware of being instantiating a template (or should he?).

Anyway, this feature is fun to play with.




More information about the Digitalmars-d mailing list