help-octave
[Top][All Lists]
Advanced

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

spaces and strings


From: John W. Eaton
Subject: spaces and strings
Date: Fri, 25 Feb 2005 21:09:30 -0500

On 25-Feb-2005, Brian Blais <address@hidden> wrote:

| In Matlab, the default behavior for commands without parentheses is to 
| pass the argument as a string, like:
| 
| help ls
| 
| more on
| 
| 
| now, this seems to work for some commands in octave, but certainly not 
| for user-defined .m files.  Is there a reason for this?  Is this a 
| parser limitation, or something else?  I find it a slight inconvenience, 
| but I think it can be discouraging for some people coming from Matlab, 
| and having their scripts break for this reason.

In my opinion, this is a very bad design feature in Matlab, and I see
no reason to copy it in Octave.  This topic has been discussed on the
lists before.  Briefly, unlike Matlab, Octave does not do any special
tricks to decide whether it is parsing a command.  The reason I don't
want to make Octave behave exactly like Matlab in this case is that I
would prefer to avoid ambiguities for expressions like

  some_function -1

is this an expression (subtract one the result of some_function) or a
command with the string argument "-1"?  Matlab parses it as a command
with a string argument.  But if you write

  some_function - 1

Matlab will parse it as a binary expression.  I think this is another
bad case of whitespace being special.

Instead of the kind of kluge used by Matlab, Octave has another:  you
have to tell Octave that a given function name can be a command using
the command "mark_as_command".

There is also some code for declaring commands when Octave starts up.
For each directory in the LOADPATH, Octave searches for a files named
PKG_ADD and executes the commands found in the files.

When Octave is installed, it creates a PKG_ADD file in each directory
that contains .m or .oct files.  Currently, the script that makes the
PKG_ADD files looks for comments that start with "## PKG_ADD:" in the
.m files and the sources of the .oct files and converts them to lists
of commands.  For example,

  ## PKG_ADD: mark_as_command name

is converted to

  mark_as_command name

in the PKG_ADD file.

Octave also looks for a PKG_DEL script when removing directories from
LOADPATH, but so far I don't think therea re any PKG_DEL scripts (I'm
not sure that it is necessary to unmark commands, but if people think
that makes sense, it would be easy to add).

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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