bugGNU Octave - Bugs: bug #44860, "hold on" in single-line...


bug #44860: "hold on" in single-line is not parsed correctly

Submitter:  None
Submitted:  Fri 17 Apr 2015 02:47:12 AM UTC
Category:  Interpreter Severity:  2 - Minor
Priority:  1 - Later Item Group:  Matlab Compatibility
Status:  Postponed Assigned to:  None
Originator Name:  John Trenholme Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Fri 17 Apr 2015 04:14:59 PM UTC, comment #4: 

Another way to get it to parse is to treat hold as a real function and use parentheses.

holding = ishold(); if(0 == holding) hold ("on"); end

Although Octave may be incompatible, there are several workarounds and it is not clear that this is even desirable syntax as having everything on one line is a confusing coding style.  We can keep the bug, but I'm going to lower the priority.

Rik <rik5>
Group administrator
Fri 17 Apr 2015 02:55:30 PM UTC, comment #3: 

Right, well Matlab is often extremely forgiving.
Do we want to mimic this? I suppose so...

Philip Nienhuis <philipnienhuis>
Group Member
Fri 17 Apr 2015 09:21:00 AM UTC, comment #2: 

I just checked in Matlab 2013a this is a valid syntax.

Pantxo Diribarne <pantxo>
Group Member
Fri 17 Apr 2015 07:39:39 AM UTC, comment #1: 

Are you sure it is a bug?
Simply adding a comma or semicolon between the if statement proper and the following statements makes it work:

holding = ishold(); if(0 == holding), hold on; end

I hit this issue myself many years ago and since then always added that semicolon. IMO it simply is better coding style as well.

IIRC it was also needed on at least older Matlab versions (but I'm not sure, never checked on newer ones)

Philip Nienhuis <philipnienhuis>
Group Member
Fri 17 Apr 2015 02:47:12 AM UTC, original submission:  

The following causes a parse error:

holding = ishold(); if(0 == holding) hold on; end

syntax error
holding = ishold(); if(0 == holding) hold on; end

The following does not:

holding = ishold(); if(0 == holding) eval('hold on'); end

This seems to be the same as the previously-reported problem using 'more off' where I use 'hold on'.



(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 (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-01 mtmiller StatusNone Postponed
        Release3.8.2 dev
        Operating SystemMicrosoft Windows Any
    2015-04-17 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 1 - Later
    2015-04-17 pantxo Item GroupOther Matlab Compatibility
        Summary&quot;hold on&quot; in single-line if not parsed correctly "hold on" in single-line is not parsed correctly

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code