Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S05: backslash+<alpha> in regexes should never be literal. #115

Open
pmichaud opened this issue Aug 25, 2016 · 2 comments
Open

S05: backslash+<alpha> in regexes should never be literal. #115

pmichaud opened this issue Aug 25, 2016 · 2 comments

Comments

@pmichaud
Copy link
Contributor

In 7afa4fe there was an addition to S05 that says:

"Backslash escapes for literal characters in ordinary strings are allowed in regexes (C<\a>, C<\x>, etc.)."

To me, this is very wrong and should be reverted. For one, \a and \x in regexes explicitly do NOT match the letters "a" and "x"!

One of the important design principles underlying S05 was that backslash+alpha would always be "meta" and never literal. Otherwise this becomes one of those special-case lists that programmers have to memorize. (Out of the 26 ASCII alphabetic characters, the only literals would be <[gijklmpquyz]>, as <[abcdefhnorstvwx]> are all meta.)

I agree that \b and \B should be illegal, as opposed to the "match/reject a backspace (u+0008)" meaning.

@coke
Copy link
Contributor

coke commented Aug 25, 2016

This commit (7afa4fe) was in 2013; given that these are historical documents (and marked as such), is this worth fixing?

I'd rather see clear language added to docs.perl6.org if it's missing from there.

@pmichaud
Copy link
Contributor Author

I just want to make sure that backslash+letter doesn't end up being interpreted as a quoted literal, in the sense that \j in a regex should be an error and not a way to match "j".

I recognize now that perhaps what the commit meant was that "\a" and "\x" in regexes match the same escaped characters that they do in double-quoted strings, but I didn't read it that way at first.

If the specs are purely historical, I don't mind if they're not patched, and I'll start looking to docs.perl6.org in the future I guess.

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

No branches or pull requests

2 participants