Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Bug: SortedSet gives warning.

Reply
Thread Tools

Bug: SortedSet gives warning.

 
 
John Carter
Guest
Posts: n/a
 
      03-04-2005
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 : http://www.velocityreviews.com/forums/(E-Mail Removed)
New Zealand

Refactorers do it a little better every time.


 
Reply With Quote
 
 
 
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      03-04-2005
Hi,

In message "Re: Bug: SortedSet gives warning."
on Fri, 4 Mar 2005 10:03:24 +0900, John Carter <(E-Mail Removed)> 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 ld_init
+ }
begin


 
Reply With Quote
 
 
 
 
John Carter
Guest
Posts: n/a
 
      03-04-2005
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 : (E-Mail Removed)
New Zealand

Refactorers do it a little better every time.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New LapTop Wireless gives up =?Utf-8?B?TWFyYyBQZXJyeQ==?= Wireless Networking 1 11-11-2005 08:48 PM
Overclockers Online Gives Away 2 Thermaltake Coolers Silverstrand Front Page News 0 08-08-2005 01:57 AM
SortedSet faster than Collections.sort() Timo Nentwig Java 6 02-26-2005 01:21 AM
Re-sorting a SortedSet Larry Coon Java 5 06-05-2004 12:48 AM
Reverse iterator for a SortedSet ? Sasha Java 3 01-13-2004 08:58 PM



Advertisments