lua-users home
lua-l archive

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


I agree - this is one break with C that doesn't really make sense. Lua already has a string constructor syntax that allows newline preservation with no additional syntax (long string constructors); why have the other syntax aim to fill the same role less effectively? Having escaped newlines discard the newline (like C) would allow quoted string constructors to fill a niche that no other string constructor can currently, and if you really need to preserve each newline, as in C, you just need to prepend each escaped line ending with an explicit \n (ending each line with the two characters longer "\n\").

On Fri, 02 Apr 2010 19:41:08 -0600, M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> wrote:


Hey,

In Lua 5.2 string literals could the backslash-newline escape code
swallow the newline character rather than embedding it into the
string?  This would be similar to C's continuation lines.

The motivation for me is that there doesn't seem to be a way of having
really long string literals in a Lua source file split across multiple
lines without extra runtime overhead.  As far as I can tell, I either
have to use shorter pieces and concatenate them at runtime, or add
extra newlines to the string and remove them at runtime.

Cheers,

Joonas