duck!

kenji hara k.hara.pg at gmail.com
Sat Oct 16 09:35:51 PDT 2010


I'm not a native English speaker, so you are well about naming than I.

But, by two reasons, I think 'duck' isn't good.

1.
'Duck Typing' is phenomenon, not doing.
- auto d = adaptTo!Drawable(c)
- auto d = duck!Drawable(c)
Which is more explainable that this statement does?
I think adaptTo is more better.

2.
I'm now implementing function getting original object from
interface(like Drawable).
----
auto c = new C();
auto d = adaptTo!Drawable(c);
...
auto c2 =  = XXX!C(d)
assert(c2 is c);
----
In this case, XXX's name may be antonym of adaptTo.
What is the antonym of 'duck'?

I hope helpful.

Kenji Hara

2010/10/16 Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:
> I was talking to Walter about Kenji's adaptTo. We both think it's a very
> powerful enabler, but adaptTo is a bland name. After discussing a few
> marketing strategies, I proposed "duck". It's short, simple, and evokes
> "duck typing".
>
> class C
> {
>    int draw(){ return 10; }
> }
> interface Drawable
> {
>    long draw();
> }
> ...
> auto c = new C;
> auto d = duck!Drawable(c); // awes
>
> Kenji, I'll be looking forward to your submission :o). Would be great to
> allow structs to duck, too!
>
>
> Andrei
>


More information about the Digitalmars-d mailing list