octave-bug-tracker
[Top][All Lists]
Advanced

[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: Tue, 31 May 2022 23:38:56 -0400 (EDT)

Follow-up Comment #4, bug #62552 (project octave):

The function base_lexer::handle_identifier in libinterp/parse-tree/lex.ll
includes the following code:


    // For compatibility with Matlab, the following symbols are
    // handled specially so that things like
    //
    //   pi +1
    //
    // are parsed as an addition expression instead of as a command-style
    // function call with the argument "+1".  Also for compatibility with
    // Matlab, if we are at the top level workspace, do not consider IDENT
    // as a possible command if it is already known to be a variable.

    if (m_at_beginning_of_statement
        && ! (m_parsing_anon_fcn_body
              || ident == "e" || ident == "pi"
              || ident == "I" || ident == "i"
              || ident == "J" || ident == "j"
              || ident == "Inf" || ident == "inf"
              || ident == "NaN" || ident == "nan"))
      tok->mark_may_be_command ();


The comment is wrong about a difference in behavior in the top level
workspace.  I changed the code here:
http://hg.savannah.gnu.org/hgweb/octave/rev/ef865fcd4611 but forgot to update
the comment.  I fixed it here:
http://hg.savannah.gnu.org/hgweb/octave/rev/1589a7967d1e

Does Matlab still behave this way, at least for the functions like i, j, pi,
inf, Inf, nan, and NaN that it has?  I know that some of these (e, I, J) are
specific to Octave.  But it seems best to me that they behave in the same way.
 If there is disagreement about that, then maybe we should deprecate the
Octave-specific names and eventually remove them?


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62552>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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