From: shugo@... Date: 2015-12-17T13:40:13+00:00 Subject: [ruby-core:72216] [Ruby trunk - Bug #11828] [Rejected] Object#freeze grid-locks Ruby Issue #11828 has been updated by Shugo Maeda. Status changed from Feedback to Rejected Daniel P. Clark wrote: > > What does "all singleton instances" mean? > > ~~~ruby > Object.freeze > > Enumerable.singleton_class.tap {def a; end} > # => RuntimeError: can't modify frozen class > > Kernel.singleton_class.tap {def a; end} > # => RuntimeError: can't modify frozen class > > Enumerator::Lazy.singleton_class.tap {def a; end} > # => RuntimeError: can't modify frozen class > ~~~ > > **UPDATE**: My mistake... I was using `tap` wrong again. It appears `singleton_class` is still modifiable. > > ~~~ruby > Enumerator.tap {|i| def i.a; end} > # => Enumerator > Enumerator.respond_to? :a > # => true > ~~~ > > I was wrong about my last statement. Ah, I see. Thanks for your confirmation. So I close this ticket. ---------------------------------------- Bug #11828: Object#freeze grid-locks Ruby https://bugs.ruby-lang.org/issues/11828#change-55625 * Author: Daniel P. Clark * Status: Rejected * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- It seems safe to freeze most any class type in Ruby. But if you call `Object.freeze` nothing from then on can be created in either class of method form. Is this okay behavior to have in Ruby? ~~~ruby Object.freeze class A end # => RuntimeError: can't modify frozen # def x end # => RuntimeError: can't modify frozen class ~~~ I noticed that Procs can still be defined. ~~~ruby prc = proc {|a| a+1} prc.call(4) # => 5 ~~~ But all singleton instances are frozen. -- https://bugs.ruby-lang.org/