Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COThis doesn't make sense to me. You're saying that if we had a Boolean class with two values instead of TrueClass and FalseClass with one value each, true and false could no longer be immediate values. Why should this be the case? After all there's more than one instance of Fixnum (significantly more) and Fixnums are still immediate values. Also minor nitpick: true and false aren't represented as 0 and 1 internally, they're represented as 2 and 0 (in MRI at least).
      singulars
    2. COGood point on 2 and 0 - I was sure about FalseClass but not TrueClass... In any case, my point was that using TrueClass and FalseClass permits the value to be evaluated simply by way of the class identifier, whereas an identifier that marked an object as a Boolean class would then have to be evaluated before the instance value was known. I take this to be the same sort of optimization that is done by treating all IDs (which are generally pointer addresses) as longs so that FixNums can be 1 bit offset and operated on directly rather than having to be dereferenced before evaluation.
      singulars
    3. CO@Asher: The value is not "evaluated simply by way of the class identifier". Ruby doesn't know that a value is false, because its class is FalseClass. It know it's false because the value is 0. Likewise it knows a value is true because it is 2. It doesn't even store the class information anywhere (there's not actually any object struct associated with true or false, so there'd be nowhere to store the class). In other words replacing TrueClass and FalseClass with Boolean would not make any performance difference.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload