bugGNU Octave - Bugs: bug #52016, '&' or '|' used in until...


bug #52016: '&' or '|' used in until condition should warn about short-circuiting

Submitted by:  Ernst Reissner <ernstreissner>
Submitted on:  Thu 14 Sep 2017 09:33:18 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  ernstreissner Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Fri 15 Sep 2017 05:57:00 PM UTC, comment #6:

I don't venture in to the parser and tree evaluation code much so I can't comment. But, if this is going to be complex then it should perhaps be reduced in priority.

Rik <rik5>
Project Administrator
Fri 15 Sep 2017 05:45:29 PM UTC, comment #5:

This is a little more complicated than adding a warning in the right place. The parser will have to mark the conditional expression in an 'until' with a new flag, as a loop condition expression that is not braindead, just so the evaluator can see if the & or | operators are used in the conditional expression and issue a new warning message. Something like "warning: Matlab-style short-circuit operation not performed for operator |"?

Mike Miller <mtmiller>
Project Administrator
Thu 14 Sep 2017 04:15:39 PM UTC, comment #4:

A warning is fine with me. Re-titling report.

Rik <rik5>
Project Administrator
Thu 14 Sep 2017 04:07:27 PM UTC, comment #3:

I'm OK with adding a warning if the conditions for Matlab short-circuiting occur in the condition of an UNTIL statement, but I don't want to change the behavior of UNTIL statements to do that kind of short circuiting. It's not needed for compatibility since Matlab doesn't have this statement.

John W. Eaton <jwe>
Project Administrator
Thu 14 Sep 2017 03:54:17 PM UTC, comment #2:

Sholdn't the short-circuit warning be extended to cover the 'until' condition? If a programmer is migrating from Matlab to Octave they may decide to use do/until loops, but with the assumption that the condition works the same as a while loop.

In other words, I don't think we should have different behaviors based on keyword used for the looping structure. It becomes a difficulty to remember which loop does which thing. Instead, they should all behave similarly, although Octave gives you more choices.

Rik <rik5>
Project Administrator
Thu 14 Sep 2017 09:43:08 AM UTC, comment #1:

There is another place in the manual also: Section 8.5.2:

One could mention until also:
As matlab does not support until-statement,
in octave, & and | behave regularly in until-conditions.

Also a reference to the warning would be fine.

Ernst Reissner <ernstreissner>
Thu 14 Sep 2017 09:33:18 AM UTC, original submission:

In the manual page 228 or around, we read:

I feel, one should mention that this warning
is to make clear, that in if and while conditions
& and | behave like && and || and shall thus be replaced by
explictly && and ||.
This is for matlab compatibility.
As matlab does not support until statements,
octave treats & and | in until conditions
regularly without shortcut.

Ernst Reissner <ernstreissner>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by ernstreissner (Submitted the item)
  • -email is unavailable- added by ernstreissner

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-14 rik5 CategoryDocumentation => Interpreter
        Item GroupDocumentation => Feature Request
    2017-09-14 rik5 Summaryconversion to short circuit in if, while but not in until => '&' or '|' used in until condition should warn about short-circuiting
    2017-09-14 rik5 StatusNone => Confirmed
    2017-09-14 ernstreissner Carbon-Copy- => Added -email is unavailable-

    Back to the top

    Powered by Savane 3.3