Andrei Alexandrescu Wrote:

> 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);

Object c = new C;
auto d = duck!Drawable(c); // awes

does this work? After all, c is a C:

Object c = new C;
auto d = duck!Drawable(cast(C)c);

One fears this feature has little real world use. But it's a great way to add 
additional bloat to the puny little Phobos...

It's amusing as always that the syntax is being discussed before we even know 
how this works. How does the int -> long coercion work there? Any possibility 
to get a written spec for this?

Reply via email to