octave-maintainers
[Top][All Lists]
Advanced

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

Re: Question about short circuit operators


From: Michael D Godfrey
Subject: Re: Question about short circuit operators
Date: Thu, 24 Feb 2011 19:35:11 -0800
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7

On 02/24/2011 05:32 PM, Robert T. Short wrote:
IMHO.  Don't try to protect people from themselves.  Document the problem, explain what the problem is and why there is a problem and leave it alone.  Get rid of that warning.


Just my two cents.

Bob
Isn't the point of the short circuit test to deal with side-effects of  possibly
untested conditionals?  If there are no side-effects, why issue the
warning?  Octave does the right thing, but the warnings do seem
excessive.
For example:
a = 2;
b = 99;
if((a == 2) | (b == 3))
  printf("OK\n");
endif
b
a = 2;
b = 99;
if((a == 4) | (b = a == 3))
  printf("OK\n");
endif
b

produces:
octave:16> tests
warning: /d/linux/reduce/tests.m: possible Matlab-style short-circuit operator at line 3, column 13
warning: /d/linux/reduce/tests.m: possible Matlab-style short-circuit operator at line 9, column 13
OK
b =  99
b = 0
octave:17>

=========================
The first warning seems to be overkill.

Michael


reply via email to

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