lua-users home
lua-l archive

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




On 2021-02-22 6:39 a.m., Egor Skriptunoff wrote:
On Mon, Feb 22, 2021 at 6:00 AM Soni "They/Them" L. wrote:

           local foo = "USAGE\n\z
                        \    description."


Why do you want to put such unpleasant-looking thing in your code?
Lua offers much nicer variant:

local foo = [=[
USAGE
    description.]=]

If you want to indent it:

      local foo = ([=[
            \USAGE
            \    description.]=])
      :gsub("%f[^\n%z][ \t]*\\", "")

Please note that the text is more easily readable because you don't see all that \n\z-garbage.

IMO, "\z" is a good option for long strings of data (kilobytes of hexadecimal digits).
But for human-readable text the preferred option is long brackets.

"\z" allows one to use other escapes, you aren't required to put newlines on every line, etc. there are lots of benefits to it.