[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-dev] [APPROVE] asBoolean
On Oct 28, 2004, at 5:31 PM, ccos wrote:
the only thing really Cish in here is Number returning false if it is
zero, which is also the thing i am most ambivalent about and which i'd
be glad to drop.
equating Object with true and nil with false is also C semantics where
NULL is false and non NULL is true.
i don't really see how the rest is Cish in that you have to
explicitly ask for the behaviour. the main point of the idea is
precisely to have object return true. you use it in circumstances when
you don't want to have to write a whole lot of support code to test
whether something is false or nil or an object and you want to write a
pretty neat little language imho you can just go "if( someVariable )"
and nil is treated like false and objects like true.
Not requiring a boolean type can lead to hidden bugs. If you were to
you probably meant if (a == b). A number of questions get posted to
the list where the vm complains about a non-boolean type in an if
statement -- which is a good thing. It caught an error which otherwise
would have silently and incorrectly worked.
if (a.isNil) is aready inlined specially by the compiler and does not
require a message send.
If this semantics of asBoolean were added to the language I think it
would beg the question of why it is not the default semantics.
--- james mccartney james@xxxxxxxxxxxxxx <http://www.audiosynth.com>
SuperCollider - a real time audio synthesis programming language