From: Robert Dober Date: 2008-05-23T00:39:37+09:00 Subject: Re: Prevent ruby constant variables from changing? On Thu, May 22, 2008 at 3:12 PM, Florian Gilcher wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > On May 22, 2008, at 2:36 PM, Robert Dober wrote: > >>> >>> If you noticed, class names are constants. >> >> Not necessarily. >> c = Class::new { def ... } > > > So how does the creation of an anonymous class hurt the argument that class > names are constants? I will try to answer your question with another one. What is the name of the class above? Well it is "", would you say this is a constant? This however is not what was most missleading. It does not matter if a constant is pointing to a class or not, class names are not constants at all, there is just this little quirck in Ruby that X = Class::new sets X.name to "X" by some magic. This allows to reopen the class with class X instead of writing c.module_eval c.module_eval creates faster code though... Cheers Robert > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (Darwin) > > iEYEARECAAYFAkg1cSMACgkQJA/zY0IIRZaVYACfYKNZSIRdk1IUeEVSgCAMhto6 > vP8An25z7xkB0HzOwszj8U6zlocudryQ > =oNYV > -----END PGP SIGNATURE----- > > -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein