by bufferoverflow · 4y ago · 0 comments
That's just wrong. Boolean is the type. False is just one possibile value of that type.
PHP isn't exacly an "everything is an object" language, but it's been slowly moving in that direction for years, replacing most callables, resources, etc. with corresponding objects. I wouldn't be surprised if the designers are approaching this issue with an object-oriented mindset, though it still feels wrong to make an exception for only one half of a boolean pair.
Having false and true be singleton types is perfectly cromulent.
That's how Smalltalk has been doing it for 40 years, and why it can do without control structures:
Boolean subclass: False [
ifTrue: trueBlock ifFalse: falseBlock [
^falseBlock value
]
"..."
Boolean subclass: True [
ifTrue: trueBlock ifFalse: falseBlock [
^trueBlock value
]
"..."