You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiline string can not end with double quote #3283
@paf31 thinks that we need to fix the docs. I'm ready to try and fix the tokenizer so that the quotes are indeed allowed everywhere in the triple quoted string. Or allow escapes, which is even better.
My reasoning is just that Purescript is a very elegant language. And having "you can have a single quote everywhere in the triple quoted string, oh, just not as the last character" in the documentation is not elegant.
How would that work? I see """ existing as "dump unescaped things here" heredoc kinda thing more than it being for multiline specifically - it not already having escape sequences is a feature 😄
@kika What languages with multi-line strings work like you want? While Python lets you write:
z="""i can end with double quotes."""""
the evaluated value is:
λ ~/ python -i foo.py
>>> z
'i can end with double quotes.'
As far as I can tell, this is because Python parses that as """foo""" "" and then apparently Python does string concatenation for adjacent string literals?
@parsonsmatt I can't think of one that allows 4 quotes in a row, but at least python and coffeescript allow escapes, so it's a non-issue for them. z = """i can end with double quotes.\""""
works in both of them.
@garyb Allowing escapes is not mutually exclusive with 'dump unescaped things'. You can dump unescaped things while allowing escapes. But the unescaped backslash will fall victim of such change.
Verbatim strings now support trailing quote characters. All quote characters until the final three are considered part of the string. Now a string such as """"hello"""" will parse, and is equivalent to "\"hello\"".
Activity
michaelficarra commentedon Mar 21, 2018
This is expected.
""""is a valid token. And even if it wasn't, the tokeniser would be greedy and consume the""".kika commentedon Mar 21, 2018
Should I submit a PR to the documentation then?
natefaubion commentedon Mar 21, 2018
Is it expected that escape sequences don't work in triple-quotes blocks?
maddie927 commentedon Mar 21, 2018
I've had issues with this before. There should be some escape sequence even if it's different.
kika commentedon Mar 21, 2018
@paf31 thinks that we need to fix the docs. I'm ready to try and fix the tokenizer so that the quotes are indeed allowed everywhere in the triple quoted string. Or allow escapes, which is even better.
My reasoning is just that Purescript is a very elegant language. And having "you can have a single quote everywhere in the triple quoted string, oh, just not as the last character" in the documentation is not elegant.
paf31 commentedon Mar 21, 2018
Fixing the lexer in the way you describe isn't going to be simple.
kika commentedon Mar 22, 2018
What about implementing escapes? It's cool to have them anyway.
garyb commentedon Mar 22, 2018
How would that work? I see
"""existing as "dump unescaped things here" heredoc kinda thing more than it being for multiline specifically - it not already having escape sequences is a feature 😄parsonsmatt commentedon Mar 25, 2018
@kika What languages with multi-line strings work like you want? While Python lets you write:
the evaluated value is:
As far as I can tell, this is because Python parses that as
"""foo""" ""and then apparently Python does string concatenation for adjacent string literals?kika commentedon Mar 25, 2018
@parsonsmatt I can't think of one that allows 4 quotes in a row, but at least python and coffeescript allow escapes, so it's a non-issue for them.
z = """i can end with double quotes.\""""works in both of them.
kika commentedon Mar 25, 2018
@garyb Allowing escapes is not mutually exclusive with 'dump unescaped things'. You can dump unescaped things while allowing escapes. But the unescaped backslash will fall victim of such change.
gabejohnson commentedon Apr 11, 2018
FWIW, Idris supports this https://www.idris-lang.org/idris-1-2-0-released/
natefaubion commentedon May 8, 2019
This is fixed in master with the new lexer.