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: John W. Eaton
Subject: Re: Question about short circuit operators
Date: Fri, 25 Feb 2011 09:53:42 -0500

On 25-Feb-2011, Jordi Gutiérrez Hermoso wrote:

| I think the Matlab warning about short circuit operators is warranted.
| Matlab's behaviour is extremely weird and in effect makes it
| impossible to not short circuit in conditions. Octave clearly
| separates & and && plus | and || for short and not short-circuiting
| operations. Since this affects semantics, if you're writing code that
| relies on these weird semantics you should be warned about it. If you
| don't like the warning, put
| 
|      warning off Octave:possible-matlab-short-circuit-operator
| 
| in your .octaverc
| 
| I just noticed that the warning_ids function didn't list this ID.

I don't object if you want to add more IDs to the warning_ids
function, but I'm not sure that it makes sense for us to worry too
much about trying to list all possible warning IDs there since anyone
can create their own warning with an ID.  Also, eventually I'd like to
see most warnings generated by core Octave functions have IDs
associated with them, so there could be hundreds.

| had to go digging in src/pt-binop.h for the warning id. That could use
| a patch.

If you trigger a warning, you can get the warning ID (if any) with

  [msg, id] = lastwarn ()

Maybe we could find a way to extend this function to give a
description as a third output?

jwe


reply via email to

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