[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Free format strings?
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Tue, 24 Dec 2002 16:01:33 +0100
Peter Hill wrote:
>
> In Lua we have both:
> "abc\
> def"
> and
> "abc\ndef"
> which produce the same effect.
>
> 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.
>
> *cheers*
> Peter Hill.
The way you do it in Lua is simply to say
"abc"
.. "def"
Yes, its' a concatenation, but string
concatenation in Lua is a VM primitive,
so it's not that inefficient.
If you must have the behaviour you propose,
then edit llex.c, find the function
static void read_string (LexState *LS, int del, SemInfo *seminfo)
And change line number 278:
case '\n': save(LS, '\n', l); inclinenumber(LS); break;
to this:
case '\n': inclinenumber(LS); break;
That way, no newline character is stored.
You'll also need to modify the string.format()
function, though for that assumes \<newline>
stores a newline in the string.
--
"No one knows true heroes, for they speak not of their greatness." --
Daniel Remar.
Björn De Meyer
bjorn.demeyer@pandora.be