octave-maintainers
[Top][All Lists]
Advanced

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

Re: stupid Matlab-style short-circuit behavior for | and &


From: John W. Eaton
Subject: Re: stupid Matlab-style short-circuit behavior for | and &
Date: Thu, 7 Oct 2010 15:36:59 -0400

On  7-Oct-2010, Rik wrote:

| I wrote a short Perl script (attached) which looks for singular occurrences
| of '&' and '|' in a file.  Presumably it would be best to sign off on all
| the existing uses in the code before turning this new feature on.
| 
| A quick run on all the .m files shows 398 occurrences, so this will take a
| little bit of work to verify.  In addition, the script should be run an the
| .cc files to check for uses in the %!test sections.

I already added the warning to the parser and it turns up just 21
cases that can possibly be subject to the Matlab-style short-circuit
behavior:

warning: /home/jwe/src/octave/scripts/plot/__fltk_ginput__.m: possible 
Matlab-style short-circuit operator at line 52, column 19
warning: /home/jwe/src/octave/scripts/statistics/distributions/geornd.m: 
possible Matlab-style short-circuit operator at line 74, column 21
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 46, column 53
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 46, column 43
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 46, column 24
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 45, column 55
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 45, column 36
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 45, column 25
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygecdf.m: 
possible Matlab-style short-circuit operator at line 45, column 15
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 43, column 53
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 43, column 43
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 43, column 24
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 42, column 55
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 42, column 36
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 42, column 25
warning: /home/jwe/src/octave/scripts/statistics/distributions/hygeinv.m: 
possible Matlab-style short-circuit operator at line 42, column 15
warning: /home/jwe/src/octave/scripts/statistics/distributions/poissrnd.m: 
possible Matlab-style short-circuit operator at line 68, column 19
warning: /home/jwe/src/octave/scripts/statistics/distributions/poissrnd.m: 
possible Matlab-style short-circuit operator at line 70, column 21
warning: /home/jwe/src/octave/scripts/statistics/distributions/wblrnd.m: 
possible Matlab-style short-circuit operator at line 80, column 51
warning: /home/jwe/src/octave/scripts/statistics/distributions/wblrnd.m: 
possible Matlab-style short-circuit operator at line 80, column 37
warning: /home/jwe/src/octave/scripts/statistics/distributions/wblrnd.m: 
possible Matlab-style short-circuit operator at line 80, column 21

Note that a number of these are compound expressions on the same line
and that only 6 files are affected.

Since the warning is issued at parse time, you can test all lines of
the .m files distributed with Octave using something like 

  find $srcdir/scripts -name '*.m' | sed 's/\(.*\)/source ("\1");/' | 
./run-octave

We could add this to the make check rule.  It might not be a bad idea
to do that anyway, as parsing all the function files this way ensures
that there aren't any parse errors in the code (I found a few just now).

All the test code works without generating a warning, and all of it is
parsed every time the tests are run, so they should always be covered
completely.


reply via email to

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