[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Free format strings?
- From: "Peter Hill" <corwin@...>
- Date: Wed, 25 Dec 2002 02:28:17 -0000
Peter Hill wrote:
> However there doesn't seem to be a way to wrap long strings *without*
> inserting a newline. Tradionally, "\" by itself has been used as a
> free-format wrap character for strings. So:
> "abc\
> def"
> was the same as
> "abcdef"
>
> Does Lua have such a feature? If not it should.
Björn De Meyer:
> The way you do it in Lua is simply to say
>
> "abc"
> .. "def"
>
That's certainly clear looking (and standard). Thanks. It might do to add an
example like that to the manual, though, for the benefit of unobservant
people like myself :-).
I actually have to type it as:
a = "abc"..
"def"
rather than
a = "abc"
.."def"
as that gives the error
stdin:1: unexpected symbol near `..'
Yet another case of the (apparent) general free-format / line-break
principle... that if a syntactic sequence seems finished, and a line-break
is encountered, then it is deemed to *be* finished. Is that principle stated
in general terms in the manual somewhere? I've only encountered the one
specific example in the function call section but it seems to be a general,
simple & sensible rule.
> Yes, its' a concatenation, but string concatenation in Lua is a VM
> primitive, so it's not that inefficient.
True, but I'd feel more comfortable if the manual stated that the parser
automatically compiles <constant string><cat><constant string> as a single
string.
*cheers*
Peter Hiil.