I would say it depends heavily on the language. In Python, it's very common that different objects have some kind of Boolean interpretation, so assuming that an object is a bool because it is used in a Boolean context is a bit silly.
if not x then … end is very common in Lua for similar purposes, very rarely do you see hard nil comparisons or calls to typeof (last time I did was for a serializer).
Strongly disagree that
not x
implies to programmers thatx
is a bool.well it does not imply directly per se since you can "not" many things but I feel like my first assumption would be it is used in a bool context
I would say it depends heavily on the language. In Python, it's very common that different objects have some kind of Boolean interpretation, so assuming that an object is a bool because it is used in a Boolean context is a bit silly.
if not x then … end
is very common in Lua for similar purposes, very rarely do you see hard nil comparisons or calls totypeof
(last time I did was for a serializer).