[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Significant newlines
- From: "Soni L." <fakedme@...>
- Date: Wed, 31 Aug 2016 15:21:20 -0300
On 31/08/16 02:56 PM, Sam Putman wrote:
On Wed, Aug 31, 2016 at 10:38 AM, Soni L. <fakedme@gmail.com
<mailto:fakedme@gmail.com>> wrote:
In Lua, you can't put a line break in the middle of a string.
However, ever since Lua 5.2, newlines are equivalent to whitespace
everywhere else.
This is incorrect. Newlines are not equivalent to whitespace *in
strings*. Whitespace is significant *in strings*.
This is a feature, not a bug.
This is neither a bug nor a feature. It's a legacy feature.
Whitespace is *kept* in strings, but whitespace doesn't break a string.
$ lua
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> "This is a valid string"
This is a valid string
While newlines break the string.
I'm proposing treating newlines in strings the same way whitespace is
treated: keep it as it is.
With the exception of ASCII NUL, no other character breaks strings. Also
multiline strings don't support escapes and it'd be nice to have an
alternative that does.
$ lua
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> "test
>> test"
stdin:1: unfinished string near '"test'
vs
$ lua
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> do
>> print("x")
>> (print)("test")
>> end
x
stdin:2: attempt to call a nil value
stack traceback:
stdin:2: in main chunk
[C]: in ?
Note that I'm asking for multiline strings that support escapes,
not the removal of raw strings.
(I'm fine with line comments the way they are, tho)
--
Disclaimer: these emails may be made public at any given time,
with or without reason. If you don't agree with this, DO NOT REPLY.
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.