help-octave
[Top][All Lists]
Advanced

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

Re: Function calls (Was: Save a plot to .ps)


From: John W. Eaton
Subject: Re: Function calls (Was: Save a plot to .ps)
Date: Fri, 4 Jun 1999 00:33:35 -0500 (CDT)

On 28-May-1999, Andy Adler <address@hidden> wrote:

| John, I'm not sure I can follow your reasoning. (I may be missing
| something really obvious here). I'm all for octave avoiding
| inheriting bugs from matlab compatibility, but if there's a
| clean way to do something (which I still think there is ) then
| I think it should be considered.

Sorry, I've given this issue considerable thought now, and I don't
think there is a clean and consistent way to make it work.

To immitate the Matlab behavior, you have to allow that, in the
absence of a variable called `f',

  f -1

is parsed as a function call in which the string '-1' is passed as an
argument, and

  f - 1

is parsed as a function call in which the strings '-' and '1' are
passed as arguments.  The only way to make this look like a
subtraction is to write

  f-1

or

  f- 1

To me, this is unacceptable, because it makes whitespace significant
in a very ugly way.

| What I'm arguing is that octave already handles the ambiguity
| of function calls / matrix subscripting in a consistent way.
| (And Matlab does not). Clearly, octave is capable of making
| run time decisions about what an identifier represents.
|
| I'm arguing that this run time capability can be extended to 
| decide whether
|     foo -option
| is a function call or a subtraction.

No.  Deciding whether the statement as a function call or a
subtraction must happen when the program text is parsed, not when the
resulting code is evaluated.

| This isn't the worst ambiguity of matlab syntax. 
| My vote for worst of Matlab is the 0,1 indexing feature, which gives
| 
| a=[2 3]; a([1 1])
| ans = [2 2]
| 
| I've been bitten by this __feature__ many times

FWIW, I think this problem is supposed to have been fixed in Matlab
5.x by the introduction of the logical data type.

jwe



---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------



reply via email to

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