[#9722] Kernel#system broken inside Dir.chdir(&block) if system command doesn't have shell characters — <noreply@...>

Bugs item #7278, was opened at 2006-12-14 13:59

8 messages 2006/12/14

[#9749] System V IPC in standard library? — Steven Jenkins <steven.jenkins@...>

Back in August, I needed a semaphore to serialize access to an external

14 messages 2006/12/19

[#9753] CVS freeze — SASADA Koichi <ko1@...>

Hi,

20 messages 2006/12/20
[#9755] Re: [ruby-dev:30039] CVS freeze — SASADA Koichi <ko1@...> 2006/12/20

Hi,

[#9757] Re: [ruby-dev:30040] Re: CVS freeze — SASADA Koichi <ko1@...> 2006/12/20

Hi,

Re: [ ruby-Bugs-7253 ] Sets and String subclasses

From: "Jan Svitok" <jan.svitok@...>
Date: 2006-12-13 21:11:50 UTC
List: ruby-core #9716
On 12/13/06, Jan Svitok <jan.svitok@gmail.com> wrote:
> On 12/13/06, murphy <murphy@rubychan.de> wrote:
> > > I would expect the second puts to return 5, not nil.  In fact, I'd expect s.to_a[0] to return the same object as a.
> > no problem with the subclass. the problem is here:
> >
> > require 'set'
> > a = 'test'  # => "test"
> > a.object_id  # => 931080
> > Set[a].to_a.first.object_id  # => 931110
> >
> > why does Set duplicate its elements? Hash and Array don't do this.
> > [murphy]
>
> So the problem is here:
>
> http://ruby-doc.org/core/classes/Hash.html#M002883
> --------
> hsh[key] = value => value
> hsh.store(key, value) => value
>
> Element Assignment輸ssociates the value given by value with the key
> given by key. key should not have its value changed while it is in use
> as a key (a String0 passed as a key will be duplicated and frozen).
> --------
>
> Set is implemented over Hash, using its .keys as the storage. (see
> lib/1.8/set.rb)
> Hash duplicates its keys to prevent the change.
>
> if we add .freeze then it would return the same object:
>
> require 'set'
> a = 'test'.freeze  # => "test"
> a.object_id  # => 931080
> Set[a].to_a.first.object_id  # => 931080 or whatever it is

The real problem is in string.c:str_new4() that copies only string
content and doesn't copy any other data.

Solution would be either to fix that or to not derive from String -
working approach would be to have a String member and forward the
calls to it (using Forwardable or something similar).


In This Thread

Prev Next