[Top][All Lists]

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

Re: "size(foo)" vs "size foo" (octave-3.4.3)

From: lukshuntim
Subject: Re: "size(foo)" vs "size foo" (octave-3.4.3)
Date: Sun, 05 Feb 2012 15:43:08 +0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120130 Thunderbird/10.0

On 02/04/2012 12:10 PM, Jordi Gutiérrez Hermoso wrote:
> On 3 February 2012 22:06,  <address@hidden> wrote:
>> On 02/04/2012 12:10 AM, Jordi Gutiérrez Hermoso wrote:
>>> On 3 February 2012 11:03, Ismael Núñez-Riboni <address@hidden> wrote:
>>>> It seems that if you use "size" without the parenthesis it interpretes the
>>>> argument as a string...
>>> This is true of *all* Octave functions.
>>>     foo a b c d;
>>> is *exactly the same* as
>>>     foo("a", "b", "c", "d");
>>> See here:
>> Is there any (help) command/function to show whether a name is a
>> function or a command?
> All functions are also commands. If a function only accepts string
> arguments, it can be called with command syntax. But it's syntactical
> to do, say,
>     eig foo
> even though it will fail because the eig function doesn't know what to
> do with a string.
> - Jordi G. H.

Thanks for a very clear explanation.

It seems then a command is in fact implemented as a function except that
this function can be called in the command *form* and behave correctly.
So just a convenience.

If this understanding is correct, then the command form of call should
be discouraged so as to avoid surprised results like "size foo". Maybe
the manual can be modified slightly to make it a bit clearer.

The beginning of "11.11 Commands" may look like

"If functions accept only strings as arguments, they can also be called
in the command form. That is, without the parenthesis and quotes. For
example, ..."

and adding a paragraph like

"While it is syntactical correct to call all functions in the command
form, a function which require an argument other than a string will fail
as it does not know what to do with a string. For example,

    eig hello

fails with the error message

    error: eig: wrong type argument `sq_string'"

at the end.



reply via email to

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