M
Matthew Johnson
Even dynamic / duck typing isn't completely eschewing type checks,
Just in case anyone following this thread missed it I just posted in
another thread a quite lengthy discussion of these issues called Duck
Typed Concepts for Ruby with analysis applied to collection types
(the post was prompted by the ordered hash discussion).
Matthew
even if you can get away with that for spectacularly long. And the
problem is that expressing the parameter constraint with "is a
Vector" is a little clearer than "has vector properties". It's not -
that- apparent in this example, but for more complex ones, where
you need a larger set of behaviours from the function parameters,
the formal granular constraints on them would be very verbose and
hard to understand. Having "ubmrella" concepts that are readily
understood is very helpful in that case. And the path between
concept and code is sometimes a very short one - having a mixin
Vector module with documented methods that you expect from an
object "with vector properties" and some helper methods you'd use
would probably be my first move after making a vector manipulation
library with the dynamism you describe.
Just in case anyone following this thread missed it I just posted in
another thread a quite lengthy discussion of these issues called Duck
Typed Concepts for Ruby with analysis applied to collection types
(the post was prompted by the ordered hash discussion).
Matthew