[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: function space
From: |
Sergei Steshenko |
Subject: |
Re: function space |
Date: |
Tue, 21 Feb 2012 12:33:38 -0800 (PST) |
--- On Tue, 2/21/12, Ben Abbott <address@hidden> wrote:
> From: Ben Abbott <address@hidden>
> Subject: Re: function space
> To: "Vic Norton" <address@hidden>
> Cc: "Octave Help" <address@hidden>
> Date: Tuesday, February 21, 2012, 11:29 AM
>
> On Feb 21, 2012, at 2:24 PM, Vic Norton wrote:
>
> > In the manual or help there seems to be a preference to
> write
> > 'sin (X)' rather than 'sin(X)'
> > or
> > 'sprintf ("%d", i)' rather than
> 'sprintf("%d", i)'.
> > However, in at least one case, the space between the
> function name and its argument list results in a "parse
> error".
> >
> > For example
> > i = 5;
> > x = [ "min", sprintf("%d", i) ];
> > results in
> > x = "min5".
> > However
> > i = 5;
> > x = [ "min", sprintf ("%d", i) ];
> > results in
> > parse error:
> >
> > syntax error
> >
> >>>> x = [ "min", sprintf ("%d", i) ];
> >
> >
> > Is this a bug? Or should one just avoid putting a space
> after a function name?
> >
> > In what other situations does a space after a function
> name result in a syntax error?
> >
> > Regards,
> >
> > Vic
>
> Its not a bug. Spaces and comma's are delimiters in a
> comma-separated-list (cs-list).
>
> [1 2 3]
> ans =
>
> 1 2 3
>
> [1, 2, 3]
> ans =
>
> 1 2 3
>
> [1, 23]
> ans =
>
> 1 23
>
> Ben
>
>
I think it's a bug.
This is because cs_list as its element may have a function call, and a function
call consists of function name, optionally followed by whitespaces, optionally
followed by list of arguments.
The question, however, is: is Octave smart enough to tell simple variable from
function ? I.e. to relate the arguments list to the preceding name.
Regards,
Sergei.
P.S. It's first of all a bug in what you guys call here "m-language" - a
definitional flaw.