Joel VanderWerf
7/12/2006 8:26:00 PM
dblack@wobblini.net wrote:
> 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 }
There's a difference between the object itself and how you got the object.
irb(main):001:0> String.name.object_id
=> 23076870
irb(main):002:0> String.name.object_id
=> 23073030
Strings are certainly first class. It's something about how you get the
name of a class (or, analogously, a method instance) that makes it feel
1.5 class. Would you say that class names are not first-class objects?
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407