[#11439] comments needed for Random class — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

15 messages 2007/06/12

[#11450] Re: new method dispatch rule (matz' proposal) — David Flanagan <david@...>

This is a late response to the very long thread that started back in

17 messages 2007/06/13

[#11482] Ruby Changes Its Mind About Non-Word Characters — James Edward Gray II <james@...>

Does this look like a bug to anyone else?

10 messages 2007/06/16

[#11505] Question about the patchlevel release cycle — Sylvain Joyeux <sylvain.joyeux@...4x.org>

1.8.6 thread support was broken in bad ways. It stayed for three months

20 messages 2007/06/20
[#11512] Re: Question about the patchlevel release cycle — Urabe Shyouhei <shyouhei@...> 2007/06/20

Hi, I'm the 1.8.6 branch manager.

[#11543] Re: Apple reportedly to ship with ruby 1.8.6-p36 unless informed what to patch — James Edward Gray II <james@...>

On Jun 27, 2007, at 4:47 PM, Bill Kelly wrote:

10 messages 2007/06/27

Re: NilClass, TrueClass, FalseClass special cased for singleton classes?

From: Joel VanderWerf <vjoel@...>
Date: 2007-06-29 02:44:30 UTC
List: ruby-core #11559
John Lam (CLR) wrote:
> If you do:
> 
>  
> 
> class << nil
> 
>    self
> 
> end
> 
>  
> 
> it returns NilClass this is the case for true and false as well.
> 
>  
> 
> It appears that this behavior is special-cased for at least these three 
> well-known singleton objects. Two questions:

Is that really a special case, as far as behavior goes? The 
implementation of these three is special (for example, the use of 
SPECIAL_SINGLETON in rb_singleton_class() in class.c), but it seems to 
me that the behavior is the same as:

   foo = []
   FooClass = class << foo; self; end

   case foo
   when FooClass; puts "FOO"
   end

Is there any way the programmer can tell the difference? Well, I was 
able to find three ways, but they are kind of phony, and a program 
shouldn't depend on these differences, IMO:

   p NilClass
   p FooClass

   puts
   p NilClass.dup
   p((FooClass.dup rescue "can't dup FooClass"))

   puts
   p Marshal.dump(NilClass)
   p((Marshal.dump(FooClass) rescue "can't dump FooClass"))

__END__

Output:

NilClass
#<Class:#<Array:0xb7d947b8>>

#<Class:0xb7d93d2c>
"can't dup FooClass"

"\004\bc\rNilClass"
"can't dump FooClass"

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

In This Thread

Prev Next