On Jueves, 3 de Septiembre de 2009 03:11:34 Allin Cottrell escribió:
On Wed, 2 Sep 2009, Allin Cottrell wrote:
> On Wed, 2 Sep 2009, chris wrote:
> > Allin Cottrell wrote:
> > > However, I'm not sure offhand whether gretl's ODBC routines will
> > > handle this sort of input correctly. I'll have to test.
> >
> > Did you change the string parsing code? Because with current windows
> > snapshot the follwing snippet no longer works:
> >
> > <script>
> > string a="\"
> > </script>
>
> Yes, I considered that I had found a bug, in that you couldn't set
> a string to contain literal quotes by doing, e.g.
>
> string quotefoo = "\"foo\""
>
> That's now fixed, but it has broken the idiom you mentioned. But
> I think that would be better done as
>
> string a = "\\"
>
> This doesn't yet work right, but it will soon.
Sorry, let me not prejudge the issue. One option is to proceed in
the direction I indicated, allowing backslash-escaped quotes (and
so, therefore, other escapes, including backslash-escaped
backslashes) in the definition of string literals using
string s = "..."
But another option is simply to revert the change I made, to which
Chris has drawn attention.
To clarify: before my recent change, when you defined a string
literal using
string s = "..."
gretl followed the simple procedure of making the string start
at the first '"' and end at the next '"'. So Chris's
string a = "\"
would produce a string containing a single, literal backslash.
This means that if you did
string quotefoo = "\"foo\""
(in the hope of getting a quote-wrapped string) you'd get an
error, since gretl would see a string comprising a single
backslash followed by the bare identifier 'foo', and most likely
you'd get a complaint about the symbol 'foo' being undefined.
It seemed to me that this was a bug, but maybe it's OK: it
doesn't agree with C usage, but it was consistent. And if you
wanted to get fancier with escapes you could use sprintf.
Any thoughts? Should we just go back to the status quo ante?
(And perhaps add a note to the manual.)
Allin.
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users
In general, I don`t have any strong preference for any of the two
alternatives, if the subject is well documented in the manual.
But I have many script files in which I use the backslash in a string, so it is
probably that if the behavior of the "string" command is changed I will have
to correct them.
Apart from that, I see the "string" command as something more simple to use
for a not very experimented user, and "sprintf" as a command more flexible and
so more difflcult. With the old status of the "string" command, when this user
has an error with a command similar to
string quotefoo = "\"foo\""
I think it is time he/she learn how to use "sprintf".
I mean: please go back to the state before.
--
Ignacio Diaz-Emparanza
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)
UPV/EHU
Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.et.bs.ehu.es