help-octave
[Top][All Lists]
Advanced

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

Re: ["Can I ", sprintf ("make this code work?\n")]


From: Bill Denney
Subject: Re: ["Can I ", sprintf ("make this code work?\n")]
Date: Mon, 29 May 2006 22:05:56 -0400 (EDT)

On Tue, 30 May 2006, William Poetra Yoga Hadisoeseno wrote:
On 5/30/06, Keith Goodman <address@hidden> wrote:
On 5/29/06, Etienne Grossmann <address@hidden> wrote:

this is just to ask whether there is a 2.9.5 setting that would allow me to
run this (legacy) code unchanged?

    ["Can I ", sprintf ("make this code work?\n")]

The parser thinks you are trying to concatenate three things. Just
remove the space between sprintf and (.
So, is this a bug or a feature?

It's the best of both worlds: both.

The longer answer (that I think is right) is:

When Octave's parser reaches something like

["Can I ", sprintf ("make this code work?\n")]

It parses it as

a concatenation: [
an interpreted string: "Can I "
a separator: ,
a function or variable: sprintf
a grouping or function argument opening: (
an interpreted string: "make this code work?\n"
a group or function argument closing: )
a concatenation closing: ]

The problem is that it doesn't know if sprintf is a function or a variable here, and as such, it can't be sure if the grouping after it is just a grouping or if it is the argument to the function. Removing the space after sprintf removes the doubt.

(Etienne, could something about this go into the FAQ)

Bill

--
"We are accustomed to see men deride what they do not understand, and
snarl at the good and beautiful because it lies beyond their sympathies."
  -- Johann Wolfgang von Goethe



reply via email to

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