dynamic classes and duck typing

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 1 11:14:59 PST 2009


Walter Bright wrote:
> Andrei Alexandrescu wrote:
>> I don't think that's any difference at all. Javascript does use a sort 
>> of Variant for all of its values.
>>
>> So if you want dynamic:
>>
>> a) have opDispatch forward the string to dynDispatch as a regular 
>> (runtime) value, pack all parameters into Variants (or an array 
>> thereof - probably better, or even one Variant that in turn packs an 
>> array - feature recently implemented, yum), and return a Variant;
>>
>> b) have dynDispatch return a Variant which will be then returned by 
>> opDispatch.
>>
>> It's not less powerful than discussed. It's more .
> 
> Yes, I think you're right that the parameters passed should be a 
> Variant[], not variadic.

Parameters to dynDispatch (the user-defined forwarding function), NOT 
opDispatch. opDispatch can take _anything_.

Sorry if I'm repeating what you know already, but I am obsessing over a 
small misunderstanding could end up hamstringing this very powerful feature.

So: opDispatch has absolutely no restrictions except a string in the 
first static parameters position.


Andrei



More information about the Digitalmars-d mailing list