lua-users home
lua-l archive

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


On Jan 31, 2008 8:24 AM, Mark Hamburg <mhamburg@adobe.com> wrote:
> I agree that the better answer here is constant folding for
> string concatenation.

Well, that's the more *viable* answer. It would be *better* if
it could be done during lexing, but as we've seen, that's not
possible.

> But I don't see it as a huge burden to have to write:
>
>     myBigString = "The first part of the string "
>                .. "is followed by the the second "
>                .. "part of the string."

It's certainly no burden to *type*, but I think most programmers
find it unappealing to incur a performance penalty for the sake
of source beautification. If you've got 50 lines, Lua's creating
48 strings of intermediate garbage just to concatenate them,
right?

The obvious alternative is to use long strings, but you can run
into issues where you need more control over what goes in that
string (e.g. http://lua-users.org/lists/lua-l/2008-01/msg00361.html).

I only brought up C-style lexing because it's so trivial to add
and is syntactically simple. It just has the small problem of
breaking Lua. ;)

Cheers,
Eric