bugGNU Octave - Bugs: bug #53752, block comment compatibility

 
 

bug #53752: block comment compatibility

Submitter:  John W. Eaton <jwe>
Submitted:  Wed 25 Apr 2018 03:54:17 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  2 Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 30 Dec 2020 05:05:45 PM UTC, comment #2: 

I have been re-writing the syntax highlighter for Vim and came across this issue as well.  How critical is it to support nested block comments?  It really seems like more trouble than it is worth.

I will point out that Matlab does allow nested block comments, I just don't think it is worth the programmer time to support this when the feature is unnecessary (line in a nested comment block are already commented) and confusing.

Rik <rik5>
Group administrator
Wed 25 Apr 2018 04:13:20 PM UTC, comment #1: 

I can't imagine this is a frequent issue, and there are easy workarounds.  At best, maybe it is worthwhile to implement the first suggestion to track what the opening block comment character was.  The second scenario seems quite esoteric.  I lowered the priority even more to 2 rather than 3.

Rik <rik5>
Group administrator
Wed 25 Apr 2018 03:54:17 PM UTC, original submission:  

We currently allow block comment markers to be mixed in any combination.  So '%{' and '#{' are equivalent as are '%}' and '#}'.  This could cause compatibility issues.  For example, there could be some working Matlab code that looks like this:


%{
  block comment
#}
  still a block comment in Matlab
%}


and that will fail in Octave.  This could be solved by keeping track of whether the current block comment started with '#{' or '%{' and requiring the types of the begin and end markers to match.  But even if we did that, the following would work in Matlab but fail in Octave:


%{
  block comment
#{
  nested block comment in Octave but not Matlab
%}
sin (x);   %% some other code that should be executed.


For that problem, I suppose we could require that to be nested, the nested block comments must all be of the same type?  Then the '#{' in the above code would not be recognized as the beginning of a nested block comment.  But that would require more work for the programmer who wants to comment out a block of code.  Now they would need to check the block of code they are commenting for existing block comments, and then use the same style.

A far simpler solution would be to only allow block comments to use '%{' and '%}' instead of also allowing '#{' and '#}'...

I haven't seen any bug reports about this problem occurring in real code, so I'm marking the severity as minor and the priority as low.

John W. Eaton <jwe>
Group administrator

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-25 rik5 Priority3 - Low 2
    2018-04-25 jwe Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code