Duck-typing allows deeper polymorphism

this shows, right up front in the method, that the method takes an argument 'x'
which must respond to 'upcase', and 'downcase'. an exception is thrown if
something that does not respond to both these methods is passed in:

Not entirely true... The argument 'x' must also respond to whatever parseargs wants from it (respond_to?, I assume), whatever the 'pa.x' method wants from it (well, nothing, I assume), and whatever 'p' wants from it (to_s, I assume).

note that this could be parsed via rdoc quite easily.

Only if it's an Array literal being passed to parseargs.

Ara, I'm not trying to dismiss the effort you put into parseargs, or its usefulness in pulling off programming by contract (especially in comparison to the alternatives). Rather, I'm trying to point out that Ruby's so flexible that it makes it very difficult to do. I'm not arguing against duck typing -- enough people have done that already, plus I like it. However, I still have qualms about using Ruby in the enterprise (read: with a bunch of programmers who aren't me), and duck typing is one of the reasons why.

Once I formulate all my thoughts, I'll probably make an "Enterprise Ruby?" email or something, but for now, all you get is little nits.

Devin

this shows, right up front in the method, that the method takes an argument
'x' which must respond to 'upcase', and 'downcase'. an exception is thrown
if something that does not respond to both these methods is passed in:

Not entirely true... The argument 'x' must also respond to whatever
parseargs wants from it (respond_to?, I assume), whatever the 'pa.x' method
wants from it (well, nothing, I assume), and whatever 'p' wants from it
(to_s, I assume).

sure - everything in :ducktype=>list AND what parseargs needs - quite true.

note that this could be parsed via rdoc quite easily.

Only if it's an Array literal being passed to parseargs.

huh?

Ara, I'm not trying to dismiss the effort you put into parseargs, or its
usefulness in pulling off programming by contract (especially in comparison
to the alternatives).

oh but you should! :wink: it's marked 'experimental' for at least a couple of
reasons and is just an idea i'm throwing out there to see what comes back.
for the record: by no means am i suggesting it's a completely baked idea.

we're all friends here so i assume people will offer up any criticisms come to
mind.

Rather, I'm trying to point out that Ruby's so flexible that it makes it
very difficult to do. I'm not arguing against duck typing -- enough people
have done that already, plus I like it. However, I still have qualms about
using Ruby in the enterprise (read: with a bunch of programmers who aren't
me), and duck typing is one of the reasons why.

i can see that.

cheers.

-a

ยทยทยท

On Fri, 10 Jun 2005 twifkak@comcast.net wrote:
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
My religion is very simple. My religion is kindness.
--Tenzin Gyatso

===============================================================================