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: Robert T. Short
Subject: Re: Question about short circuit operators
Date: Thu, 24 Feb 2011 17:32:05 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4) Gecko/20091017 SeaMonkey/2.0

Jordi Gutiérrez Hermoso wrote:
On 24 February 2011 16:23, Robert T. Short
<address@hidden>  wrote:
Before I submit a bug report, maybe someone can tell me that I am
missing something.  Why would the following happen?
[snip]
warning: /home/rtshort/Mirrored/octave/Sources/00Bugs/somefunc.m:
possible Matlab-style short-circuit operator at line 3, column 20
Just that, you're using operators that short circuit but only if you
use them as a condition in an if or while.

E.g.

      a = b | c; ## No short circuiting in Matlab or Octave

      if b | c  ## Short circuiting in Matlab, use --braind-dead
                ## options to enable it in Octave

HTH,
- Jordi G. H.


Ahh. I see. However, I would never have got that message from the octave documentation. I read the MATLAB documentation to understand about "short-circuiting in element-wise...". I realize this was discussed earlier, but I didn't get involved because I didn't understand the implications based on the documentation.

It seems to me that the crux of the problem is that

x = logical_expression;
if(x)
  ...
end

and

if(logical_expression)
  ...
end

might have different results, yes?  That is certainly braindead behavior.


Now, here is my problem with this warning. The example I submitted was clearly contrived simply to get to the root of the problem, but it is NOT "braindead". It is a simple and straightforward statement. Why produce a warning for something like this? The current approach is simply too heavy handed. Similarly the "braindead" option is far, far too draconian to be a solution.

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



reply via email to

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