octave-maintainers
[Top][All Lists]
Advanced

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

function calls with string args


From: John W. Eaton
Subject: function calls with string args
Date: Fri, 17 Sep 2010 20:40:28 -0400

On 18-Sep-2010, Fotios Kasolis wrote:

| Is it true or just a fictitious impression:
| 
| All Octave's functions (even user defined) that accept only string args can 
be called like
| 
| > func ("arg")
| > func arg
| 
| For instance
| 
| > axis ("equal", "tight", "off")
| > axis equal tight off

Yes, this is done for compatibility with Matlab.

Note however that there are some oddities (again, for compatibility),
such as

  x -1

calls the function x with the argument "-1" but

  x - 1

calls the function x with no arguments, then subtracts 1 from the
value returned from x.

Also, when called this way, the command name has to be the first token
in the statement so it can't be on the RHS of an assignment or as part
of a boolean or arithmetic expression, etc.

This should be documented in the "Commands" section of the manual, but
that section appears to be out of date as the 

  mark_as_command
  unmark_command
  iscommand
  mark_as_rawcommand
  unmark_rawcommand
  israwcommand

functions are all obsolete because commands no longer have to marked
as such since the parser now accepts all function names as commands
under the right circumstances.

It would be helpful if someone would submit a patch to update the
manual.

jwe


reply via email to

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