[MacRuby] #290: Hashes do NOT stay ordered
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Hashes in Ruby 1.9 keep their order. In MacRuby (macirb): {:aa=>1, :a=>1} => {:a =>1, :aa=>1} According to Ruby 1.9 the result should be in the input-order: => {:aa =>1, :a=>1} The same is true for methods on a Hash like Hash#keys: The should return the keys in the input-order. -- Ticket URL: <http://www.macruby.org/trac/ticket/290> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Comment(by lsansonetti@…): We don't support input-ordered hash keys because our Hash class is based on top of CFDictionary. We may support this in the future using a hack but it's really not a high-priority item on the agenda. -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:1> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Comment(by eloy.de.enige@…): We could port ActiveSupport::OrderedHash to our Hash implementation: http://github.com/rails/rails/blob/master/activesupport/lib/active_support/o... I suppose that would be like the ‘hack’ Laurent suggests. -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:2> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Comment(by conradwt@…): ActiveSupport implementation of Hash is probably activated when using Ruby < 1.9.1 because it's in Ruby 1.9.1. With that said, I would take a look at the C implementation of Hash located here: http://redmine.ruby-lang.org/repositories/entry/ruby-191/hash.c -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:3> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Comment(by conradwt@…): Is there a Ruby spec which fails in this regard? If not, I believe it should be one which fails to provide a hint for something to fix in the future. -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:4> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Comment(by lsansonetti@…): By hack I was thinking about patching a little bit our Hash implementation. But as I said I don't think this is very important for the time being. FYI, there is a Ruby spec that covers this 1.9-only behavior. It's currently failing on MacRuby. -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:5> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: eloy.de.enige@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Changes (by eloy.de.enige@…): * owner: lsansonetti@… => eloy.de.enige@… Comment: Replying to [comment:3 conradwt@…]:
ActiveSupport implementation of Hash is probably activated when using Ruby < 1.9.1 because it's in Ruby 1.9.1. With that said, I would take a look at the C implementation of Hash located here:
http://redmine.ruby-lang.org/repositories/entry/ruby-191/hash.c
By porting OrderedHash, I meant we could port it to our CF implementation. Not to use the ruby version of itself :) It should contain all the necessary tweaks needed to support ordering. I might have a stab at this at some point. -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:6> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: eloy.de.enige@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: Hash order -----------------------------------+---------------------------------------- Comment(by conradwt@…): Replying to [comment:5 lsansonetti@…]:
By hack I was thinking about patching a little bit our Hash implementation. But as I said I don't think this is very important for the time being.
FYI, there is a Ruby spec that covers this 1.9-only behavior. It's currently failing on MacRuby.
What's the syntax for running both the pre-Ruby 1.9 and Ruby 1.9 specs? -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:7> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: eloy.de.enige@… Type: defect | Status: closed Priority: blocker | Milestone: Component: MacRuby | Resolution: fixed Keywords: Hash order | -----------------------------------+---------------------------------------- Changes (by pthomson@…): * status: new => closed * resolution: => fixed Comment: This has been fixed in trunk thanks to Laurent's refactorings to Hash (I believe in r3345). {{{ kid-a:MacRuby local$ macirb irb(main):001:0> {:aa=>1, :a=>1} => {:aa=>1, :a=>1} irb(main):002:0> {:c => 1, :b => 2, :a => 3} => {:c=>1, :b=>2, :a=>3} }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:8> MacRuby <http://macruby.org/>
#290: Hashes do NOT stay ordered -----------------------------------+---------------------------------------- Reporter: martin.ploeger@… | Owner: eloy.de.enige@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.6 Component: MacRuby | Resolution: fixed Keywords: Hash order | -----------------------------------+---------------------------------------- Changes (by lsansonetti@…): * milestone: => MacRuby 0.6 -- Ticket URL: <http://www.macruby.org/trac/ticket/290#comment:9> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby