> Austin is right. If you're checking types, that isn't duck typing.
Boy, we really love to argue about semantics, don't we?
What does it matter whether Ducktator "implements duck typing" or
"validates duck types" or "enforces duckly contracts" or "ducktates
method signatures" or "imposes a reducktionist philosophy" or "is just
ducky" or is none of those things?
Is the term "duck typing" overloaded? Yes (see Eric's ruby-talk:215359).
Is it getting more overloaded? Yes. Do newbs come in here with opinions
of the meaning of "duck typing" that differ from yours? Yes. Is that
going to happen more frequently? Probably. Is that going to prevent you
from explaining what you mean by example? No. Do we need separate terms
to describe the different meanings Eric enumerated (and potentially
others)? Well, no, but it'd be helpful. I'll start.
For backwards compatibility with the great majority, "duck typing" will
mean "just calling methods on an object, without doing any validation on
the behavior of that object."* Using respond_to? as a guard -- let's
call that "duck but verify." Using is_a? (and friends) as a guard --
well, "crap" comes to mind, but let's just go with "Class testing."
(On a related note... we didn't ever decide on a replacement for the
term "singleton class," did we? I liked "shadow class," myself. :P)
And "static" means "not at run-time," no?
Devin
(In short: "What matz said.")
* Though, for me, "duck typing" meant just that: If it looks like a duck
and walks like a duck... Which allows for pretty much anything except
Class testing (sticking a q-tip in the duck's mouth and waiting 2 weeks
for the lab tests to come back). Really, "just calling methods" is more
equivalent to catching something, stripping it, cooking it, taking a
bite, and going "yup, tastes like duck." But hey, peer pressure.