Hi --

On Wed, 12 Jul 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: ruby.h missing rb_cMethod?"
>    on Wed, 12 Jul 2006 09:00:46 +0900, dblack / wobblini.net writes:
>
> |> |irb(main):003:0> method(:nil?).object_id
> |> |=> 1758564
> |> |irb(main):004:0> method(:nil?).object_id
> |> |=> 1746454
> |>
> |> Hmm.  Does this behavior makes methods second-class?
> |
> |1.5'th class, anyway :-)
>
> Then strings are 1.5'th class too.
>
>  2.times {
>    p "foobar".object_id
>  }

But "" is a literal constructor; you're instantiating String twice.
nil? is a method that already exists -- so it's more comparable to:

   s = "I already exist."
   2.times { p s.object_id }

Here's an imaginary illustration of what I think the difference is
between first-class and 1.5'th class:

With first-class methods, you'd be able to do something like:

   m = obj.method(:x)
   m.before_wrapper = Proc { ... }

And then:

   n = obj.method(:x)
   p n.before_wrapper.inspect   # same Proc object

But if m and n are different objects, either this can't work, or it
would require some kind of invisible caching process.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
http://www.manning.com/black     => RUBY FOR RAILS, the Ruby book for
                                                     Rails developers
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
dblack / wobblini.net              => me