Bug: SortedSet gives warning.

Discussion in 'Ruby' started by John Carter, Mar 4, 2005.

  1. John Carter

    John Carter Guest

    In both ruby 1.8.2 and 1.9 (2005-02-10) use of SortedSet gives a warning
    under "-w".

    ruby -w -rset -e 'p SortedSet.new(%w{a b c})'
    (eval):2: warning: method redefined; discarding old initialize
    #<SortedSet: {"a", "b", "c"}>

    This is due to excessive cleverness relating to an alternate internal
    representation using the 'rbtree' module (not part of the standard
    distribution).

    It attempts to "require 'rbtree'" and catches the LoadError if that
    fails. It then "evals" a very basic implementation which redefines
    'initialize' triggering the warning.

    Personally I would prefer that either the rbtree be included in the
    distribution or this patch of code to be ripped out and replace by
    a simple tree implementation.

    I'm prepared to do a simple ruby tree implementation if needed...,
    just say the word.



    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand

    Refactorers do it a little better every time.
     
    John Carter, Mar 4, 2005
    #1
    1. Advertising

  2. Hi,

    In message "Re: Bug: SortedSet gives warning."
    on Fri, 4 Mar 2005 10:03:24 +0900, John Carter <> writes:

    |In both ruby 1.8.2 and 1.9 (2005-02-10) use of SortedSet gives a warning
    |under "-w".

    Here's the patch.
    matz.

    --- lib/set.rb 15 Dec 2004 06:35:53 -0000 1.24
    +++ lib/set.rb 4 Mar 2005 01:16:06 -0000
    @@ -440,2 +440,7 @@ class SortedSet < Set

    + module_eval {
    + # a hack to shut up warning
    + alias old_init initialize
    + remove_method :eek:ld_init
    + }
    begin
     
    Yukihiro Matsumoto, Mar 4, 2005
    #2
    1. Advertising

  3. John Carter

    John Carter Guest

    On Fri, 4 Mar 2005, Yukihiro Matsumoto wrote:

    > Here's the patch.


    Thanks!

    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand

    Refactorers do it a little better every time.
     
    John Carter, Mar 4, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sasha
    Replies:
    3
    Views:
    13,240
    Adam Jenkins
    Jan 13, 2004
  2. Larry Coon

    Re-sorting a SortedSet

    Larry Coon, Jun 2, 2004, in forum: Java
    Replies:
    5
    Views:
    1,299
    Chris Smith
    Jun 5, 2004
  3. Timo Nentwig
    Replies:
    6
    Views:
    8,838
    el goog
    Feb 26, 2005
  4. Adario
    Replies:
    18
    Views:
    715
  5. Why the compiler gives warning ?

    , Aug 9, 2005, in forum: C Programming
    Replies:
    13
    Views:
    540
Loading...

Share This Page