Dear friends at ruby
I'd like to suggest a new error for ruby-core: LogicError
That error should be thrown
upon operations that are detected to be illogic or impossible by semantics.
I believe that this could improve the error messages a lot.
Today we have:
1.to_enum - 2.to_enum
NoMethodError: undefined method `-' for #
Well, there are good reasons why #- is not implemented for Enumerator,
more so for (Enumerator - Enumerator)
Today this throws NoMethodError,
while I'd like to throw this a LogicError,
with an attached explanation,
that this operation simply does not make any sense.
But then, we should simply mark this as reserved (like private def)
I believe we can improve on the ease of using ruby
if we improve on the error messages
For the kids: NoMethodError is not that friendly,
(my kid tried to add and substract all and anything)
Don't get me wrong,
I am well aware about NoMethodErrors
(and how to reflect that on proxy APIs)
I'm asking for something different.
I want to explicitely raise a LogicError
for that operations that make no sense.
because some of the errors that we detect can be explained.