[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names |
Date: |
Fri, 3 Jun 2022 09:49:04 -0400 (EDT) |
Follow-up Comment #29, bug #62552 (project octave):
Here is my attempt. I don't know how to make it shorter and keep it clear
without having to inconvenience users by referring them to the manual.
- Parsing of command-style function calls has changed to improve
consistency of behavior and compatibility with Matlab. This change
affects statements that begin with binary operator expressions when the
first operand is a plain symbol followed by a whitespace character and
the binary operator is not followed by a whitespace character. For
example, the statement `cmd -option` is parsed as a command-style
function call, not binary subtraction operation.
This change affects all binary operators: `+`, `-`, `*`, `/`, `\`,
`^`, `.*`, `./`, `.\`, `.^`, `|`, `&`, `||`, `&&`, `+=`, `-=`, `*=`,
`/=`, `\=`, `^=`, `.*=`, `./=`, `.\=`, `.^=`, `|=`, and `&=`.
Previous versions of Octave would attempt to determine whether the first
operand in an expression was a variable, and if so, parse expressions
like `var -val` as an expression. However, this attempt to "do the
right thing" could cause trouble (for example, if a variable is only defined
conditionally).
Now, parsing command-style function calls is purely based on syntax.
Command-style function call syntax is only allowed at the beginning
of a statement. Expressions in other contexts are not affected, so an
expression like `a + b +c` will be not be parsed as a command-style
function call.
For compatibility with Matlab, a binary expression at the beginning
of a statement that starts with one of the symbols `I`, `i`, `J`, `j`,
`Inf`, `inf`, `NaN`, `nan`, or `pi` is never parsed as a command-style
function call. Octave also extends this behavior to `e`, which is not
present as a special numeric constant in Matlab.
Note that full compatibility with Matlab, which does not have the
OP= operators, would require that even `a -= b` is parsed as a
command-style function call. As that would significantly hinder the use
of these operators, Octave treats them as the other binary operators
instead of providing fully compatible behavior.
But now I'm wondering (again!) whether we have the behavior completely
correct. Could someone check what a recent version of Matlab does for the
following?
clear all
nonexistent_fcn = 1
nonexistent_fcn -1
ls = 1
ls -1
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62552>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, (continued)
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Nicholas Jankowski, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, John W. Eaton, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Arun Giridhar, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Nicholas Jankowski, 2022/06/02
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, John W. Eaton, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names,
John W. Eaton <=
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, John W. Eaton, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Nicholas Jankowski, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Arun Giridhar, 2022/06/03
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/04
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Nicholas Jankowski, 2022/06/04
- [Octave-bug-tracker] [bug #62552] In-place operator spacing works for 'i' and 'j', but not other variable names, Markus Mützel, 2022/06/05