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: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Feature Request
Status: ConfirmedAssigned to: None
Originator Name: ernstreissnerOpen/Closed: Open
Release: devOperating 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 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 14 Sep 2017 04:15:57 PM UTCrik5CategoryDocumentation=>Interpreter
      Item GroupDocumentation=>Feature Request
    Thu 14 Sep 2017 04:15:39 PM UTCrik5Summaryconversion to short circuit in if, while but not in until=>'&' or '|' used in until condition should warn about short-circuiting
    Thu 14 Sep 2017 03:54:17 PM UTCrik5StatusNone=>Confirmed
    Thu 14 Sep 2017 09:33:18 AM UTCernstreissnerCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1