From: Jeremy Kemper Date: 2005-11-18T05:04:30+09:00 Subject: Re: Object#to_b -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 17, 2005, at 6:49 AM, mental@rydia.net wrote: > Quoting Jeremy Kemper : > >> I would not like new false values, but I would like to be able to >> proxy the existing false values. Especially nil. > > Ah, fudge. I hadn't thought of that. That is one place where > lazy.rb falls down. > > promise { false } will always be true :/ > > (unless you use an explicitly force()'d value.) > >> What is the cost [of allowing NilClass and FalseClass subclasses]? > > I don't see any way that it could be as efficient as the current > setup, where nil and false are immediate values and are checked > with a simple bitmask. Right: I had to dig as far as RTEST when I tried to act like nil to understand why it did not work. I was happy to see that it's very fast but was unhappy to discover the "line in the sand" between dynamic, expressive Ruby and its concern for raw performance. There is a Moore's law for one but not the other. Has anyone measured the cost of doing boolean tests the Ruby way? Clearly it will be much slower as a microbenchmark, but perhaps the overall cost for most Ruby programs is low enough to tip the balance. And if not now, perhaps in one year. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDfOJJAQHALep9HFYRAjZyAJ42wnfNTnsiqM0E4TFNzaoVITT7AwCffZp0 ONJn0imCyJI3g0CR7l+A3PA= =TSa9 -----END PGP SIGNATURE-----