Conditional structures: Difference between revisions

Content added Content deleted
m (typo)
m (added debug/platform example)
Line 4,010: Line 4,010:
In an iff() expression, only one of true_expr or false_expr will be evaluated, not both.
In an iff() expression, only one of true_expr or false_expr will be evaluated, not both.


Phix has some rudimentary support of preprocessor ifdef statements, but their use is discouraged
Phix has some rudimentary support of preprocessor ifdef statements, but their use is discouraged since
(since they are quite unnecessary in Phix, I might add).
they are quite unnecessary in Phix, for example in the following no code whatsoever is emitted for the
first if statement, and in the second the conditions are evaluated at compile-time and code is only
emitted for one of the branches.
<lang Phix>constant DEBUG=false
if DEBUG then
puts(1,"debug is on\n")
end if
if platform()=WINDOWS then
puts(1,"this is windows\n")
elsif platform()=LINUX then
puts(1,"this is linux\n")
end if</lang>


===switch===
===switch===