[Proposal] Can we have "\ ", for use with "\z"?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Proposal] Can we have "\ ", for use with "\z"?

Soni "They/Them" L.
\z is an absolutely wonderful feature of Lua strings, but having to
break it with \x20 is mildly annoying. Compare:

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

with

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

So, yeah, it'd be nice to have the latter. It lines up the, well, lines,
so makes it easier to read when looking through source code. (The other
option is to bump the \x20 back but uh meh.)
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] Can we have "\ ", for use with "\z"?

Egor Skriptunoff-2
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.
Reply | Threaded
Open this post in threaded view
|

Re: [Proposal] Can we have "\ ", for use with "\z"?

Soni "They/Them" L.


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.