if 1 | nonsense 'hello', end

John W. Eaton jwe at bevo.che.wisc.edu
Tue Oct 28 19:38:51 CDT 2008


On 28-Oct-2008, Petr Mikulik wrote:

| According to:
| http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_pr$
| Short-Circuiting in Elementwise Operators.  When used in the context of an
| if or while expression, and only in this context, the elementwise | and &
| operators use short-circuiting in evaluating their expressions. That is, A|B
| and A&B ignore the second operand, B, if the first operand, A, is sufficient
| to determine the result.
| 
| So it seems not to be bug.

Documented or not, the fact that the behavior changes depending on
context makes it a bug, IMNSFHO.

| I would like to ask for improved Octave help on this topic. Currently it 
| says:
| octave> help |
| *** |:
| Logical or operator.  See also `||'.
| ...
| octave> help ||
| *** ||:
| Logical or operator.  See also `|'.
| ...
| 
| Could Octave's help write something like Matlab's help?
| Matlab 6.5 help says:
|                  Short-circuit logical AND         &&
|                  Short-circuit logical OR          ||
|     and        - Element-wise logical AND           &
|     or         - Element-wise logical OR            |

I'd consider a patch if someone would like to prepare one.

jwe


More information about the Bug-octave mailing list