--0016364ee01ed39b1704a0ee5b02
Content-Type: text/plain; charset=UTF-8

Isn't technically all Fixnums "frozen" (because you can't modify the state)?

// Magnus Holm


On Fri, Apr 15, 2011 at 02:34, <redmine / ruby-lang.org> wrote:

>
> Issue #4578 has been updated by Shyouhei Urabe.
>
>
> You agree integers are immutable.  Immutable objects have no states by
> definition, OK?
>
> The frozenness is a state.  You should not care about.
> ----------------------------------------
> Bug #4578: Fixnum.freeze not frozen?
> http://redmine.ruby-lang.org/issues/4578
>
> Author: Russell Bevers
> Status: Open
> Priority: Normal
> Assignee:
> Category:
> Target version:
> ruby -v: ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0]
>
>
> Using ruby 1.8.7 p334
>
> a  ; a.freeze
>
> Expect:  true a.frozen?
> Result:  false a.frozen?
>
> I realize Fixnum is already immutable, however consider the following code:
>
> class Demanding
>    attr_reader :important
>
>    def initialize(important)
>        @important  mportant
>        @important.freeze
>    end
> end
>
> Demanding wants to be able to rely on identifier not changing over its
> lifespan.  I could make it demanding with some other mechanism such as:
>  * Force important to be a particular type
>  * Force important to respond_to? particular messages during initialization
>
> These are all slippery and don't address the concern of mutability of
> important objects.  Freeze seemed like the obvious solution, but it's
> probably best for me to just take a deep copy of important for Demanding's
> own use.
>
> In the meantime, I thought I should share that freeze is not working for
> all objects in Ruby 1.8.7 p334.
>
>
> --
> http://redmine.ruby-lang.org
>
>

--0016364ee01ed39b1704a0ee5b02
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Isn&#39;t technically all Fixnums &quot;frozen&quot; (because you can&#39;todify the state)?<div><br clear="all">// Magnus Holm<br>
<br><br><div class="gmail_quote">On Fri, Apr 15, 2011 at 02:34,  <span dir="ltr">&lt;redmine / ruby-lang.org&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
Issue #4578 has been updated by Shyouhei Urabe.<br>
<br>
<br>
You agree integers are immutable. Immutable objects have no states byefinition, OK?<br>
<br>
The frozenness is a state. You should not care about.<br>
<div><div></div><div class="h5">----------------------------------------<br>
Bug #4578: Fixnum.freeze not frozen?<br>
<a href="http://redmine.ruby-lang.org/issues/4578" target="_blank">http://redmine.ruby-lang.org/issues/4578</a><br>
<br>
Author: Russell Bevers<br>
Status: Open<br>
Priority: Normal<br>
Assignee:<br>
Category:<br>
Target version:<br>
ruby -v: ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0]<br>
<br>
<br>
Using ruby 1.8.7 p334<br>
<br>
a = 5; a.freeze<br>
<br>
Expect: true == a.frozen?<br>
Result: false == a.frozen?<br>
<br>
I realize Fixnum is already immutable, however consider the following code:<br>
<br>
class Demanding<br>
  attr_reader :important<br>
<br>
  def initialize(important)<br>
    @important = important<br>
    @important.freeze<br>
  end<br>
end<br>
<br>
Demanding wants to be able to rely on identifier not changing over its lifespan. I could make it demanding with some other mechanism such as:<br>
* Force important to be a particular type<br>
* Force important to respond_to? particular messages during initialization<br>
<br>
These are all slippery and don&#39;t address the concern of mutability of important objects. Freeze seemed like the obvious solution, but it&#39;s probably best for me to just take a deep copy of important for Demanding&#39;s own use.<br>


<br>
In the meantime, I thought I should share that freeze is not working for all objects in Ruby 1.8.7 p334.<br>
<br>
<br>
--<br>
<a href="http://redmine.ruby-lang.org" target="_blank">http://redmine.ruby-lang.org</a><br>
<br>
</div></div></blockquote></div><br></div>

--0016364ee01ed39b1704a0ee5b02--