duck!

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Oct 16 12:57:18 PDT 2010


On 10/16/2010 01:43 PM, Michel Fortin wrote:
> On 2010-10-16 13:19:36 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> said:
>
>> The problem with "adaptTo" is that, just like itoa or printf, it is
>> too boring to have marketing value. I think the feature is going to be
>> _big_. We can't leave a big feature to a name like "adaptTo". The New
>> York Times won't have a headline like "adaptTo changes the name of the
>> game".
>
> It's risky in my opinion to bet that it's going to be a feature big
> enough that everyone will remember what it means. Also, "duck" is a
> misnomer. The commonly-accepted meaning of duck typing is basically
> dynamic dispatch based on function names, and when the function doesn't
> exist it's a runtime error. I bet you'll get a ton of negative feedback
> for misrepresentation or deformation of the concept. That said, it could
> bring attention, but perhaps not the kind of attention you'd like.

interface Duck
{
     void walk();
     void quack();
}

class Whatsthis
{
     void walk();
     void quack();
}

auto a = duck!Duck(new Whatsthis);

It's duck typing all right. The term does not have an academic canonical 
name. I doubt this is ever going to cause a rumpus or be a source of 
confusion.

> Programmers like automated things. That feature should be called "magic
> adapters" or "cheap adapters"

*yawn*

> (or some variation of that) because it's
> an adapter and it's magic/cheap, and people can search "adapter" and
> immediately get hundreds of results explaining the concept. And the
> function name could be "adaptTo", or "adapt" (or "magic" if you want it
> to look funny).

Please substitute: "X does duck typing in the D programming language". 
What is X?

FWIW this was the story with "immutable". Walter got tired of 
explaining: "Invariant implements immutable types in the D programming 
language".

> And I think I agree with your arguments about "as" having problems.
>
>
>> I'd go with the longer "ducktype". Length is not as important as
>> evocative power and brand name!
>>
>> auto d = ducktype!Drawable(obj);
>
> At this point, why not call it ducktape™. Now that's a brand name.

Meh.


Andrei



More information about the Digitalmars-d mailing list