S
Stefan Rusterholz
I'm about to make this RCR and would like to get some oppinions on it in
order to make my decision.
The questions are:
1) Should I split this RCR up for a) and b)?
2) Should I only submit a single one, if so, which one?
3) Should I submit this RCR at all?
4) Oppinions, suggestions, ideas... everything welcome
Abstract:
Change behaviour of dup in immutable classes.
Problem:
dup on immutable classes (NilClass, FalseClass, TrueClass, Fixnum,
Symbol)
raises an Exception.
Proposal:
a) Remove the dup method from NilClass, FalseClass, TrueClass, Fixnum,
Symbol
b) Let dup in NilClass, FalseClass, TrueClass, Fixnum, Symbol return
self
Analysis:
This may be a minor glitch in the ruby API, but with the advent or
Ruby2 it
might be worth changing.
a) should only in rare circumstances break existing code as dup for
the cases
in question already throws an exception and it would only break if the
rescue
would fail due to the changed exception class. It would restore the
behaviour
that a class only implements methods it can actually execute, which
also means
testing via respond_to? is possible.
b) would let the immutability of the classes be an implementation
detail (which
would be consistent with behaviour of other immutable classes like
Time e.g.).
It shouldn't break existing code as the it is the usual fallback.
Implementation:
a)
[NilClass, FalseClass, TrueClass, Fixnum, Symbol].each { |klass|
klass.send
undef_method, :dup) { self }
}
b)
[NilClass, FalseClass, TrueClass, Fixnum, Symbol].each { |klass|
klass.send
define_method, :dup) { self }
}
My regards
order to make my decision.
The questions are:
1) Should I split this RCR up for a) and b)?
2) Should I only submit a single one, if so, which one?
3) Should I submit this RCR at all?
4) Oppinions, suggestions, ideas... everything welcome
Abstract:
Change behaviour of dup in immutable classes.
Problem:
dup on immutable classes (NilClass, FalseClass, TrueClass, Fixnum,
Symbol)
raises an Exception.
Proposal:
a) Remove the dup method from NilClass, FalseClass, TrueClass, Fixnum,
Symbol
b) Let dup in NilClass, FalseClass, TrueClass, Fixnum, Symbol return
self
Analysis:
This may be a minor glitch in the ruby API, but with the advent or
Ruby2 it
might be worth changing.
a) should only in rare circumstances break existing code as dup for
the cases
in question already throws an exception and it would only break if the
rescue
would fail due to the changed exception class. It would restore the
behaviour
that a class only implements methods it can actually execute, which
also means
testing via respond_to? is possible.
b) would let the immutability of the classes be an implementation
detail (which
would be consistent with behaviour of other immutable classes like
Time e.g.).
It shouldn't break existing code as the it is the usual fallback.
Implementation:
a)
[NilClass, FalseClass, TrueClass, Fixnum, Symbol].each { |klass|
klass.send
}
b)
[NilClass, FalseClass, TrueClass, Fixnum, Symbol].each { |klass|
klass.send
}
My regards