Robert Dober
7/18/2007 7:44:00 PM
On 7/18/07, dblack@wobblini.net <dblack@wobblini.net> wrote:
> Hi --
>
> On Wed, 18 Jul 2007, Robert Dober wrote:
>
> > hi here I am again;)
> >
> > my original (simplified question was): Why Nil#to_i and not Nil#split.
> > Generally why X#a and not X#b?
>
> I don't think there's a general answer; each case is going to be
> different. In the case of Nil#to_i and Nil#split, I think the
> difference is something like this:
>
> #split suggests that nil has the property of "being composite" (i.e.,
> it is something that can split). #to_i, however, just means that nil
> has been assigned an arbitrary integer representation. It doesn't
> mean that nil has any particular properties.
I have thought about a different approach,
what are the chances that the #to_i message is sent to nil by purpose
and what are the chances that it is done by error.
I would weight usefulness against purity ( and consistency for that matter ).
I simply thought and still think that chances that somebody uses
nil#to_i on purpose are at least as slim as that somebody sends split
to nil, and only now I complain about inconsistency. Obviously that
was not clear at all.
Another example, what are the chances that Hash#map returning an array
is more useful than returning it a hash. I have complained about this
"inconsistency" not because it is an inconsistency, but because I feel
it is an useless, counter productive inconsistency.
Yet another example, is it useful that the following is not
implemented in standard Ruby
class Symbol
include Comparable
def <=> other; to_s <=> other.to_s end
end
I feel these are questions that can be discussed in order to make Ruby
advance, I am sure that Matz weights CRCs much more serious if there
has been discussions like these here...
Pitty if we miss these chances..
Side note:
I just guess that the usage of the word inconsistency has been a bad
error of my part, but is it not clear from my strange English that I
am not a native speaker ???
Yes you can say: "What, Really, You are not a native speaker, amaaaazing" ;)
>
>
> David
Robert
--
I always knew that one day Smalltalk would replace Java.
I just didn't know it would be called Ruby
-- Kent Beck