dynamic classes and duck typing

retard re at tard.com.invalid
Tue Dec 1 13:14:31 PST 2009


Tue, 01 Dec 2009 10:39:44 -0800, Andrei Alexandrescu wrote:

> retard wrote:
>> Tue, 01 Dec 2009 03:16:47 -0800, Walter Bright wrote:
>> 
>>> Ary Borenszweig wrote:
>>>> Can you show examples of points 2, 3 and 4?
>>> Have opDispatch look up the string in an associative array that
>>> returns an associated delegate, then call the delegate.
>>>
>>> The dynamic part will be loading up the associative array at run time.
>> 
>> This is not exactly what everyone of us expected. I'd like to have
>> something like
>> 
>> void foo(Object o) {
>>   o.duckMethod();
>> }
>> 
>> foo(new Object() { void duckMethod() {} });
>> 
>> The feature isn't very dynamic since the dispatch rules are defined
>> statically. The only thing you can do is rewire the associative array
>> when forwarding statically precalculated dispatching.
> 
> Walter is right. But as it seems there is a lot of confusion about the
> feature, maybe we didn't define the feature (which is very general and
> powerful and as dynamic as you ever want to make it) in a palatable way.
> 
> Ideas?

Well, the most important feature of dynamic types in languages like 
Python is that you don't need to worry about types anywhere. Even with 
opDispatch you need to configure parametric types for parameters etc. A 
python coder wouldn't use D unless you can get rid of all type 
annotations.



More information about the Digitalmars-d mailing list