Issue #2509 has been updated by Alexey Muranov.


This looks to me like a strange reason to reject too.  If a programmer recursively freezes an object that will freeze things that the programmer did not want to freeze, i think the program will probably crash immediately, andthe programmer will either discover a bug, or will learn better how the program works.

----------------------------------------
Feature #2509: Recursive freezing?
https://bugs.ruby-lang.org/issues/2509#change-47226

* Author: Marc-Andre Lafortune
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: next minor
----------------------------------------
=begin
 I like freezing my constants, config files I read, etc... I believe it is the typical use case for #freeze.
 
 In all theses cases, what I really want to do is freeze everything. There is often no easy way to do this (e.g. for config files), or else one must explicitly call freeze a bunch of times, like:
 
 DEFAULT_SEND_FILE_OPTIONS = {
   :type         => 'application/octet-stream'.freeze,
   :disposition  => 'attachment'.freeze,
 }.freeze
 
 It would be very nice if there was an easy way to freeze recursively arrays, hashes, etc...
 
 A solution would be for #freeze to accept a level argument (similar to flatten, but the default being 1), or alternatively a boolean one (recursive = false). 
 
 Should I write a patch for this feature request?
 
 Thanks,
 
 Marc-Andr
=end


---Files--------------------------------
deep_freeze.pdf (90.8 KB)


-- 
https://bugs.ruby-lang.org/