G
Gavin Kistner
unknown said:I don't mean I think that there should be weird or confusing
exceptions to things -- and people certainly disagree as to what's
weird or confusing -- but only that I don't generally find symmetry or
consistency, as such, to be sufficient reasons for design decisions in
Ruby.
Ralph Waldo Emerson wrote:
"A foolish consistency is the hobgoblin of little minds, adored by
little statesman and philosophers and divines. With consistency a great
soul has simply nothing to do."
Consistency is very helpful in some situations. (If everything in system
XX worked in the same way, it would be very easy to figure out how a new
proposed feature should behave, and it would be very easy for a newcomer
to know exactly how it worked, since it wouldn't be a special case.)
But like an unyielding policeman who still writes you a ticket for
speeding when you're rushing to the hospital with your sick daughter, a
foolish consistency makes no allowance for special cases. It blindly
applies the set of rules with no consideration if there might be a good
argument for an exception.
This is what I think of when I hear Matz argue for certain
inconsistencies. Handcrafted features may show nicks and scratches from
inconsistent application. They may not have the pure, clean lines of
something that was honed by a machine. But those special cases carve out
bumps that (by and large) make sense for the common case.
A final example: blocks. It would be more notionally pure to allow an
arbitrary number of blocks to be passed to a method. It would be
consistent with other method arguments if the method validated that the
right number of blocks were passed. It would be consistent if the blocks
passed as parameters were objects assigned to variables that you had to
call methods on to get them to do something.
(And, of course, you can do this if you want.)
But what we have is the special handcrafted notation of one-block per
method, a special block that is optional, and that can be called simply
with the "yield" keyword. And I find it elegant, and appropriate for 95%
of the cases. I don't think I'd call it pure or consistent, but I'd be
angry if it were removed from the language.
And...a final comparison. I program in Lua for a living. It is a great
language because at its core it's very simple, very consistent. It's
very, very easy to learn, because there are so very few special cases.
It has very little syntactic sugar. (You can't even write a+=b, but must
write out a = a+b.) I loved learning Lua, in large part because of its
consistency. And I really don't like writing in it much, because it is
so rigid and simple-minded.