'Duck Typing' is a very broad concept. adaptTo is supported only in part. For example, you can not adapt class from class. It has semantic problem of object states, so I never support it. ---- // this is invalid example class C{ draw(){ return 10; } } class X{ draw(){ return value; } int value; } X x = adaptTo!X(new C()); // x.value == ??, cannot provide generally. ----
If you call it a duck, it will tell a lie! Kenji Hara. 2010/10/17 Walter Bright <newshou...@digitalmars.com>: > Leandro Lucarella wrote: >> >> Walter and you have the same convoluted brain, I can understand why he >> instantly recognize it ;) > > > >> I already made my point, it make no sense to keep defending my position >> since, evidently, is a pure subjective matter. > > It certainly is a glorious bikeshed. > >> I just think auto a_bird = duck!Bird(a_duck) is not obvious at all >> compared to auto a_bird = adapt!Bird(a_duck). I even think adaptTo is >> even cleaner, and I tend to hate long names, specially when camelCase is >> involved, but since you didn't like it I, as others, suggested simply >> adapt). If one could write auto a_bird = adapt!a_duck(Bird), adapt would >> be as clear as adaptTo is with the current syntax. With adaptTo!Type you >> even have the precedent of the to!Type template, so it seems like a nice >> extension. > > Microsoft has a tradition of naming their products after what they do: > Windows, Word, Office, etc. It's obvious why they do it, and it works, but > it is just so generic and dull. > > Being the upstart language, D needs now and then something a little more > attention-getting than generic terms. The "duck" feature is important for > two reasons: > > 1. duck typing is all the rage now > > 2. being able to implement duck typing as a library feature (rather than a > language one) is a great demonstration of what D can do > > Label it "adaptTo" and few will even notice it. Label it "duck" and people > will click on the link to see what it does. It's important that people > notice that D has these things, and "duck" helps with that. > > I've been in this business a long time, and while you'd think that > programmers are above "what's in a name", we are just like everyone else. A > catchy name gets results. Borland, for example, added a trivial and boring > feature to their linker, called it "smart linking", and managed to get an > unbelievable amount of hoopla from the computer press out of it. They did it > again with another feature they called "zoom". > > Which blog article would you click on? "Interface Adapter for D" or "Duck > Typing for D"? > > "duck" is a great name for the feature. It's short & sweet, fits right in > with the popularity of duck typing, stands out, isn't boring, etc. Heck, as > proof, look at all the interest in this thread!! >