[#3006] CVS repository — "Eugene Scripnik" <hoaz@...>

Hello.

21 messages 2004/06/16
[#3008] Re: CVS repository — ts <decoux@...> 2004/06/16

>>>>> "E" == Eugene Scripnik <hoaz@gala.net> writes:

[#3009] Re: CVS repository — Michal Rokos <michal@...> 2004/06/16

Hi!

[#3057] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

Hi,

20 messages 2004/06/23

member? / include?

From: Johan Holmberg <holmberg@...>
Date: 2004-06-04 21:45:40 UTC
List: ruby-core #2965
Another example (beside entries/to_a) of halting synonyms is
Enumerable#member? and Enumerable#include?. They share the same
implementation and documentation. But only include? is
re-implemented in Array. This leads to benchmark results like this:

                    user     system      total        real
    member?     3.210000   0.000000   3.210000 (  3.216245)
    include?    1.280000   0.000000   1.280000 (  1.271355)

from the following program:

    require "benchmark"

    arr = [11, 22, 33] * 1_000_000

    Benchmark.bm(10) do |x|
      x.report("member?")     { arr.member?(-1)    }
      x.report("include?")    { arr.include?(-1)   }
    end

Until recently I have naively thought that "aliases are aliases",
i.e. that they behave the same way in all interesting ways.
But now I don't know ...

It would seem natural to me that methods that are described as
synonyms/aliases are treated as a "unit" in the implementation too.
For example that both are re-implemented together in a "subclass".

/Johan Holmberg


In This Thread

Prev Next