lua-users home
lua-l archive

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


On 2018-01-07 09:35, Dirk Laurie wrote:
2018-01-07 9:03 GMT+02:00 nobody <nobody+lua-list@afra-berlin.de>:
On 2018-01-07 07:48, Dirk Laurie wrote

Isn't that just a tortuous way of coding something that Lua can do much
more conveniently?

print [[{
      "hello": "world"
}]]


Not if CR-LF must not be normalized (e.g. binary data or fixed format
like HTTP / …). Then you're forced to use "normal" strings.

This sounds so reasonable that I almost believed it until I tried to
figure out what it means.

I suppose "normalize" has something to do with whether the actual
bytes emitted by "\n" are "\x0a" or "\x0d" or some combination thereof.
I do not see documented in the Lua manual whether the non-printing
newline in a long string is rendered differently from the escape
sequence "\n", but I will be vastly surprised if it is.
(Sorry, what I wrote was gibberish…)

What I meant is that if you need `\r\n` and not just `\n` (e.g. because
the protocol / format demands it), you can't use Lua's long strings
because they normalize all variations of line breaks to plain `\n`. And
that means your suggestion wouldn't work for those, as you'd need normal
strings in order to use explicit escape sequences.

Oh, and I just noticed that long strings also don't help with indenting
the string's content – so your suggestion completely ignores Soni's
"intended (indented?) problem", of wanting indentation inside the
string, plus "block indentation" (because you're in a `do` block or
something?) to line things up. And so the point I wanted to make is completely pointless.

(There, my sleepy brain says that should be more comprehensible – let's
hope it actually is clearer… Past 10AM already o.O – off to bed. o/)

-- nobody