Making Ruby Stricter


#1

To sell a Perl->Ruby transition in my company, I’d like to make
Ruby at least as strict as Perl. Our opinion is that Perl is
too loose and anything in Ruby that is looser than Perl will be
a strike against Ruby in some users’ eyes. As an example, here
are three things I’d like to change:

(A) I want “to_i” to raise an exception if the conversion fails.

(B) I’d like most NilClass methods modified so that doing anything
except testing nil values for truth will raise exceptions.
For example, NilClass#to_i should raise an exception.

© I’d like to eliminate all the “synonym” methods from our
version of the language (this has nothing to do with being
stricter than Perl).

Here is code for (A):

class String
    alias new_to_i to_i
    def to_i
        Kernel::Integer(self)
    end
end

The implementation I have in mind is to add all of my code to a
module and then ask our users to include the “strict” module.

Here are my questions:

  1. Has anyone else done something like this?

  2. Doing changes like this will likely break existing methods in
    Ruby classes and libraries that call the methods I’ve
    modified, right? Is there a way around this?

  3. Is there an implementation that avoids asking people to
    include this “strict” module?

Thanks much,

JA