octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use end or endif is indifferent?


From: Ardid Ramirez, Joan Salvador
Subject: Re: use end or endif is indifferent?
Date: Thu, 29 Nov 2018 15:22:59 +0000

El dijous, 29 de novembre de 2018, a les 10:17:15 EST, Luca Manzari va escriure:

  Octave already treats whatever follows % as a comment, so nothing 
  prevents you from writing end%if or end%for already. Doing so makes for 
  code that is both Octave and Matlab compatible.
  
  /Luca
  
  On 2018-11-29 14:43, Ardid Ramirez, Joan Salvador wrote:
  >    Hello Sergei,
  >    
  >    this is correct for Octave, but please keep in mind that Matlab (2016a) 
does
  >    not support "endif" and "endfor". So when you have to cooparate with 
people
  >    using Matlab, you could instead use "end%if" and "end%for" which will
  >    increase readability of your code, though you will losse Octave's 
advanced
  >    diagnostic abilities as mentioned in your link.
  >    
  > 
  > Mmm, thinking about it, it would actually be great if Octave would accept 
end%if as an alias of endif and end%for as an alias of endfor. This would bring 
the best of the two worlds, keeping all Octave's goodness, while keeping Matlab 
compatibility.
  > 
  > Sending it to maintainers to see if Octave Devs would consider this as a 
feasible option...
  > 
  > ....
  > a.
  > 
  > 
  
I very well know about it, what I'm actually saying is whether Octave Devs 
would consider treating "end%if" as "endif" (and so on), so it can benefit in 
terms of error diagnostic. See below about this from up-to-date documentation 
(https://octave.org/doc/interpreter/Statements.html#index-end-statement):

"You can use the keyword end anywhere a more specific end keyword is expected, 
but using the more specific keywords is preferred because if you use them, 
Octave is able to provide better diagnostics for mismatched or missing end 
tokens."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]