Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 16941 ]] Implement escaped literals #5781

Open
wants to merge 2 commits into
base: develop
Choose a base branch
Loading
from

Conversation

montegoulding
Copy link
Member

This patch implements escaped literals wrapped in single
quotes. For example:

put 'foo\n"bar"'

Equals:

foo
"bar"

This patch has the side effect that ' is no longer an
acceptable char in an identifier.

Just leaving this here for discussion at the moment. Paging @runrevmark

@mention-bot
Copy link

@montegoulding, thanks for your PR! By analyzing the history of the files in this pull request, we identified @livecodefraser and @livecodeali to be potential reviewers.

@montegoulding
Copy link
Member Author

Probably should add support for \u and \U to this...

@montegoulding montegoulding force-pushed the bugfix-16941 branch 2 times, most recently from fccfb41 to 2fda159 Compare August 13, 2017 10:05
@montegoulding
Copy link
Member Author

montegoulding commented Aug 13, 2017

Added \u and \U, however, I still need to work out how to handle parser errors... eg \U without 8 hex digits after etc. Ideally it would throw a parser error but at the moment it's just setting the token to empty.

@montegoulding
Copy link
Member Author

The implementation of \U is wrong as it should use codepoint rather than unichar...

This patch implements escaped literals wrapped in single
quotes. For example:

    put 'foo\n"bar"'

Equals:

    foo
    "bar"

This patch has the side effect that `'` is no longer an
acceptable char in an identifier.
@montegoulding
Copy link
Member Author

escapedliteral
Tis good fun ;-)

@mwieder
Copy link
Contributor

mwieder commented Aug 13, 2017

OK - I gotta admit that's impresive. I do echo Mike's concern, though, that things like Windows UNC formats like "C:\user\docs\textLetter.txt" not get get mangled in transit.

@montegoulding
Copy link
Member Author

montegoulding commented Aug 13, 2017

Well "C:\user\docs\textLetter.txt" would remain untouched of course and if you needed to hard code such a string in single quotes then you would need to double escape the backslash like in every other language ('C:\\user\\docs\\textLetter.txt').

@montegoulding
Copy link
Member Author

montegoulding commented Aug 13, 2017

escapedliteral

Like this

@mwieder
Copy link
Contributor

mwieder commented Aug 13, 2017

Ah... I missed that. Escaping is within single quotes, not double quotes. I expect there may be some user confusion ahead since the two aren't completely interchangeable, but it does very neatly get around any backwards compatibility issues and allow embedding at the same time. Nice.

@montegoulding
Copy link
Member Author

montegoulding commented Aug 13, 2017

@mwieder as it's not likely this PR will be accepted then there really won't be any chance for user confusion... having said that the whole point of single quotes is to create strings that aren't the same as can be in double quotes even if that is just the double quote char permitted and not escapes. I don't really see the point of offering a solution only for quotes though. I'd rather leave things as they are until I can have a proper solution allowing me to embed return & tab & quote and so on in a constant declaration.

@montegoulding
Copy link
Member Author

escapedreturn
A bit more fun because it came up in discussion ;-)

@mwieder
Copy link
Contributor

mwieder commented Jun 11, 2020

Can we revive this PR and discussion now (three years later)?

@montegoulding
Copy link
Member Author

I'd be surprised if we did ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.