"Yukihiro Matsumoto" <matz / ruby-lang.org> schrieb im Newsbeitrag
news:1103067392.286620.29016.nullmailer / x31.priv.netlab.jp...
> In message "Re: no-argument sort()"
>     on Wed, 15 Dec 2004 08:12:17 +0900, Alex Fenton
<alex / deleteme.pressure.to> writes:
>
> |> It bypasses #<=> for objects of class String and subclasses
> |
> |Is that considered a bug, a feature or a performance compromise?
>
> Performance compromise.

Would it make sense to restrict this optimization to String instances
(i.e. not instance of subclasses of String).  While it is not very often
that one does subclass String, it can lead to quite some surprise if one
does and <=> is not used...

Btw, I'm a bit surprised that

    if (TYPE(a) == T_STRING && TYPE(b) == T_STRING) {
        return rb_str_cmp(a, b);
    }

does indeed cover subclasses as well.  I guess, I'll have to dig into the
source for further education... :-)

Regards

    robert