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.
Is it considered a bug that it is not yet documented?
Sorry, how does that provide better performance? Simply b/c it can't be
overridden?
Thanks,
T.
···
On Tuesday 14 December 2004 06:36 pm, Yukihiro Matsumoto wrote:
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?
"Yukihiro Matsumoto" <matz@ruby-lang.org> schrieb im Newsbeitrag
news:1103067392.286620.29016.nullmailer@x31.priv.netlab.jp...
>> 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...
I see. Thanks. If I may then, perhaps there is prudence in having Ruby support
documented non-overridable methods --at least in core. This would bring such
"creatures" out of the shadows of exception into formal, documented
acceptance. For instance, in the current case, Ruby could define #quicksort
(or some such name) to bypass <=> and be non-overridable, while #sort itself
could still use the reusable, albeit slower behavior. This would provided the
best of both alternatives.
T.
···
On Tuesday 14 December 2004 07:22 pm, Florian Gross wrote:
trans. (T. Onoma) wrote:
> > >> It bypasses #<=> for objects of class String and subclasses
>
> Sorry, how does that provide better performance? Simply b/c it can't be
> overridden?
It does not need to go through method lookup and so on.