comparison doc/interpreter/expr.txi @ 19131:cbd55a4e549b

update documentation for do_braindead_shortcircuit_evaluation (bug #43177)
author John W. Eaton <jwe@octave.org>
date Sun, 21 Sep 2014 14:40:39 -0400
parents e6a4fa91a2f1
children 0f9c5a15c8fa
comparison
equal deleted inserted replaced
19130:90421e725f1d 19131:cbd55a4e549b
1007 arguments because Octave would be forced to try to evaluate both of the 1007 arguments because Octave would be forced to try to evaluate both of the
1008 operands for the operator @samp{&}. 1008 operands for the operator @samp{&}.
1009 1009
1010 @sc{matlab} has special behavior that allows the operators @samp{&} and 1010 @sc{matlab} has special behavior that allows the operators @samp{&} and
1011 @samp{|} to short-circuit when used in the truth expression for @code{if} and 1011 @samp{|} to short-circuit when used in the truth expression for @code{if} and
1012 @code{while} statements. The Octave parser may be instructed to behave in the 1012 @code{while} statements. Octave also behaves the same way by default,
1013 same manner, but its use is strongly discouraged. 1013 though the use of the @samp{&} and @samp{|} operators in this way is
1014 1014 strongly discouraged. Instead, you should use the @samp{&&} and @samp{||}
1015 @DOCSTRING(do_braindead_shortcircuit_evaluation) 1015 operators that always have short-circuit behavior.
1016 1016
1017 Finally, the ternary operator (?:) is not supported in Octave. If 1017 Finally, the ternary operator (?:) is not supported in Octave. If
1018 short-circuiting is not important, it can be replaced by the @code{ifelse} 1018 short-circuiting is not important, it can be replaced by the @code{ifelse}
1019 function. 1019 function.
1020 1020