We plan to change this in a future version. After some reflexion with Fr34k, we decided to add a compiler directive called Boolean() and accpet such expression only within it. All other use will raise compiler error.
Macro boolean (_expression_)
((_expression_) Or #False)
EndMacro
;-- Demo
Define a, b, c
a = boolean(Not #False)
Debug a
Debug "--------"
c = 10
a = boolean(b=c)
Debug a
Debug b
Debug c
The macro does no error checking, but it can help us in the following respects:
Forgotten to enclose 'Not #False' in braces: a = Not #False ; doesn't work a = boolean(Not #False) ; does work
The case discussed here: a = b = c ; doesn't work as expected a = boolean(b=c) ; does work as expected
From some people's point of view, using this macro might increase readability.
When the compiler directive Boolean() will be introduced into PureBasic, it is already in our code at the proper place.
Fred wrote:We plan to change this in a future version. After some reflexion with Fr34k, we decided to add a compiler directive called Boolean() and accpet such expression only within it. All other use will raise compiler error.
if it will be a compiler directive, does this mean it will be evaluated at compiletime and can only compare constants?
because, Boolean Expressions are really useful to work with variables...
Kaeru Gaman wrote:
if it will be a compiler directive, does this mean it will be evaluated at compiletime and can only compare constants?
because, Boolean Expressions are really useful to work with variables...
Yes, this is unclear to me to. How could be a compiler directive ? To me EnableExplicit is a compiler directive.
BTW: I'm using a BOOL() macro in just the same way in my code