Hi --

On Thu, 13 Jul 2006, Joel VanderWerf wrote:

> 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?

It's tricky -- the names per se are not really objects, i.e., there's
no "name of class String" object in object-space.  The most you can
say is that the name method returns a string, which is a first-class
object.  So is the next string it returns, and the next....  But the
class's name itself is not an object, any more than "'abcdef'
backwards" is an object before you do: 'abcdef'.reverse.


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