[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
Issue #13188 has been updated by Shyouhei Urabe.
6 messages
2017/02/06
[#79441] Re: [Ruby trunk Bug#13188] Reinitialize Ruby VM.
— SASADA Koichi <ko1@...>
2017/02/06
On 2017/02/06 10:10, shyouhei@ruby-lang.org wrote:
[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>
Hi,
15 messages
2017/02/15
[#79541] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/15
Em 15-02-2017 05:05, Daniel Ferreira escreveu:
[#79543] Re: Immutable Strings vs Symbols
— Daniel Ferreira <subtileos@...>
2017/02/16
Hi Rodrigo,
[#79560] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/16
Em 15-02-2017 22:39, Daniel Ferreira escreveu:
[ruby-core:79581] [Ruby trunk Feature#13224] Add FrozenError as a subclass of RuntimeError
From:
merch-redmine@...
Date:
2017-02-17 23:19:40 UTC
List:
ruby-core #79581
Issue #13224 has been reported by Jeremy Evans. ---------------------------------------- Feature #13224: Add FrozenError as a subclass of RuntimeError https://bugs.ruby-lang.org/issues/13224 * Author: Jeremy Evans * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Currently, attempting to modify a frozen object leads to a `RuntimeError` exception. Unfortunately, this means it is not easy to differentiate exceptions raised from attempting to modify frozen objects from generic exceptions such as calling `Kernel#raise` with no exception class. The attached patch adds `FrozenError` as a subclass of `RuntimeError`, and uses `FrozenError` instead of `RuntimeError` for exceptions raised when there is an attempt to modify a frozen object. It should be backwards compatible in the sense that: ~~~ begin "a".freeze << b' rescue RuntimeError end ~~~ Will still function as before. More people in the ruby community are starting to use frozen objects for the benefits of immutability (thread-safety, cache-ability, referential transparency), and having an exception class dedicated to misuse of frozen objects will make it easier to handle those exceptions. The attached patch is a little long, mostly because ruby's test suite is currently brittle in regards to handling exception classes. For example, `assert_raise(RuntimeError)` needs to be changed to `assert_raise(FrozenError)`, because `assert_raise` uses `instance_of?` instead of `kind_of?` if given an exception class and not a module. Both RSpec and recent versions of Minitest should automatically handle this type of change without code modifications. ---Files-------------------------------- 0001-Add-FrozenError-as-a-subclass-of-RuntimeError.patch (27.2 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>