lua-users home
lua-l archive

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


> > 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.
> 
> You can just modify read_string function in llex.c to do that in your Lua.
> That won't affect compatibility of produced bytecode.

I think it's a one-line change, but I didn't test it much:

299c299
<           case '\r': inclinenumber(ls); continue;
---
>           case '\r': save(ls, '\n'); inclinenumber(ls); continue;

But I'd rather avoid this incompatibility. Perhaps we need a new escape
sequence, something like this:
	a = "a long string\+
	continues here without\+
	line breaks"
but note that the leading spaces in the continuation lines would be part
of the string. To keep the indentation and avoid these spaces, the best
solution is concatenation, really:
	a = "a long string"
	  .."continues here without"
	  .."line breaks"