Hi --

On Thu, 4 Aug 2005, Eric Mahurin wrote:

>> |But, this wasn't really what my #1 above was about.  It was
>> |about overloaded methods where the functionality is
>> determined
>> |by looking at the type of the arguments.  One example would
>> be
>> |String#[arg]:
>> |
>> |str[fixnum] => fixnum or nil
>> |str[range] => new_str or nil
>> |str[regexp] => new_str or nil
>> |str[other_str] => new_str or nil
>> |
>> |All of these behave very different.  The way you figure out
>> |what to do is based on type - which goes against the
>> |duck-typing philosophy.  I think the only advantage of
>> |combining all of these functions into one method is
>> |convenience.  But, by doing so you loose the ability to
>> handle
>> |more general duck-typed/polymorphic arguments.

class != type.  Type is at the heart of duck-typing; class isn't :-)

>> Convenience is important, sometimes more than pure duck
>> typing.
>> There still be a room for improvement though.
>
> I'm more of a purist and thus prefer the purity over the
> convenience.  And I know there may not be many in my camp.

I'm not clear on how you define purity or purism, but it doesn't
bother me that array[1] and array[1..3] do different things.  Maybe
it's because a few core methods where a few core classes are
hard-coded allows for so much richness later, or something along those
lines -- a kind of bootstrapping.


David

-- 
David A. Black
dblack / wobblini.net