octave-maintainers
[Top][All Lists]
Advanced

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

eliminate conditional short-circuit behavior for | and & operators?


From: John W. Eaton
Subject: eliminate conditional short-circuit behavior for | and & operators?
Date: Tue, 10 Dec 2013 23:48:43 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.11) Gecko/20121123 Icedove/10.0.11

For compatibility with Matlab, the | and & operators short circuit
inside IF or WHILE conditions, but only if

  do_braindead_shortcircuit_evaluation (true);

has also been set.  This behavior is the default if Octave is started
with --traditional.

I don't like this Matlab bug^H^H^Hfeature, but I also don't think we
improve anything by making it conditional because code that works for
a Matlab user that expects this kind of behavior may fail mysteriously
when run in Octave unless do_braindead_shortcircuit_evaluation has
been set to true.

We also have a warning about this behavior that is issued when the
code is parsed.  That's not the right place for the warning.  It
should be issued when the code is evaluated because Matlab's rules for
short-circuit evaluation are not just about the operators being inside
IF or WHILE conditions, but also that the first operand is a scalar.

I propose the following change:

  * Make Octave behave as though do_braindead_shortcircuit_evaluation
    is always true and eliminate this setting.

  * Move the warning from the parser to the evaluator.

  * Leave the warning enabled by default and disabled by
    --traditional.

Comments?

jwe


reply via email to

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