bugGNU Octave - Bugs: bug #62824, Syntax error in uitable demo...

 
 

bug #62824: Syntax error in uitable demo example

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Wed 27 Jul 2022 07:31:32 PM UTC
   
 
Category:  Documentation Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  * Closed
Release:  * 7.1.90 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 30 Jul 2022 03:56:00 AM UTC, comment #4: 

This wasn't hard so I removed the spaces between the function call and the '(' in the documentation.  See changeset http://hg.savannah.gnu.org/hgweb/octave/rev/5386fd4af64c.

Rik <rik5>
Group administrator
Thu 28 Jul 2022 06:34:34 PM UTC, comment #3: 

Ah I mixed up demo and example, sorry for that.

Philip Nienhuis <philipnienhuis>
Group Member
Thu 28 Jul 2022 07:32:04 AM UTC, comment #2: 

The syntax in the %!demo block is correct (as Rik pointed out). The syntax in the example in the docstring is incorrect.
If I understand Octave's style guide correctly, the spaces should be removed in the example.

Markus Mützel <mmuetzel>
Group administrator
Thu 28 Jul 2022 01:17:47 AM UTC, comment #1: 

I believe readers of the documentation should simply be able to cut and paste the code into Octave and have it run.  The example you cite is the 4th %!demo and you one uses


example uitable 4


the code from that demo block is printed and it correctly has no space between "single" and '('.

Rik <rik5>
Group administrator
Wed 27 Jul 2022 07:31:32 PM UTC, original submission:  

Another one from the nitty-gritty dept.:

The third example in uitable.m's help ("long demo with callbacks") contains syntax errors in the first assignment statement, see below for a copy of part of the code:

## Long demo with callbacks
function uitable_demo ()
  f = figure ("Name", "uitable Demo", "Menu", "none", ...
              "Position", [10 10 1000 680]);

  ## A basic example
  d = { "char"   , "A string";
        "double" , 12.3456789;
        "complex", 1+2i;
        "bool"   , true;
        "single" , single (12.3456789);
        "int8"   , int8 (-128);
        "uint8"  , uint8 (128);
        "int16"  , int16 (-32768);
        "uint16" , uint16 (32768);
        "int32"  , int32 (-2147483648);
        "uint32" , uint32 (2147483648);
        "int64"  , int64 (-2147483649);
        "uint64" , uint64 (2147843649)};

  ## Skipping rest of code

endfunction


... where of course Octave errors on the call to 'single' on the 5th line of the assignment to variable "d". Reason: space between function 'single' and its argument within a concatenation statement, i.e. between {...} or [...].
I myself hit this when bluntly copying the function into the editor and blindly running it but quickly saw the culprit. However, unwary users that blindly trust in correctness of Ocatev's demo code may be a bit put off.

Q: how do we deal with these kind of syntax errors in demos and examples?

I'd say it should be corrected, but then the demo syntax may not look that "nice" (not that I care).
Should we remove the spaces between the function names single, int8, uint8, ... and their arguments, or enclose those calls in parentheses?

Philip Nienhuis <philipnienhuis>
Group Member

 

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

Attach Files:
   
   
Comment:
   

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 mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by philipnienhuis (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-07-30 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2022-07-28 mmuetzel Releasedev 7.1.90
    2022-07-28 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code