-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
make S"..." and "..." throw errors identically #107
Comments
@StefanKarpinski when do these throw an error? and what is an example of the output in each case? |
I guess this is an example:
I almost wonder if escape sequences and interpolation should just be features of all strings, period, and custom string literals are just a way to invoke a macro on that parser output. For interpolation, you'd get multiple arguments, some of which are strings. This has the advantage of being really predictable --- the escaping rules never change --- plus custom string literals can support interpolation, and you don't have to know about calling cc @nolta |
Regular expressions would not fare well under such a plan. |
All you have to do is escape $ and . I'm not even sure it's unequivocally good that regexes don't support escape sequences right now. |
Not sure what you're getting at Jeff. PCRE supports escapes just fine:
|
Oh, I saw this:
So we are dealing with 2 escape syntaxes, which is also not great. |
Ahh, fair enough. |
Ah, yeah, that's a good point. Slashes, however still present a problem as far as I can tell. How can you possibly make |
Backslashes, rather. |
Under this design |
Honestly, I feel that's unacceptable. |
In that case it might help just to get rid of the Meanwhile, So you see I find this messy and unsatisfying. True, One telling flaw is that a str macro can't end with a single backslash. Another one, AFAICT, is that there is no way to put a " in a regex literal without also inserting a backslash. Granted those cases are rarer than Come to think of it, maybe this is a regression?
If these things don't support escapes, then we should say you just can't have embedded quote characters, and you get whatever text is before the next |
That could be fixed with allowing triplequoting for regexes, which would be useful with the m suffix anyways. |
There are a few separate issues at play here for non-standard string literals:
The reason the The issue of how regular expressions handle things like We've come around to the idea that the parser should handle interpolation in standard string literals, which I think is good, and has nothing to do with general escaping in standard or non-standard string literals. When The main downside of doing interpolation for all string literals is that you can't have non-standard literals where I want to point out that my original proposal was that the parser handle string interpolation for standard string literals while no interpolation would be done for non-standard string literals. I'm not clear on why that's not an acceptable solution. The only counterargument I've seen anywhere is |
This might be a band-aid, but it appears we can fix the
|
Well, that's certainly better than failing :-) |
Thanks mike for fixing that. I don't see why it's bad for the parser to handle escaping in normal strings. It's part of the lexical syntax. There is also escaping in char literals, which there aren't macros for. In custom string literals, the options are (1) have no parser escaping of quotes at all, or (2) make the sequences |
I have no problem with the parser handling escaping in normal strings or characters. That's completely sensible. I was exclusively talking about non-standard strings, and I was arguing for option (2), making sure that it plays well with subsequent layers of unescaping. That still doesn't address the interpolation issue. |
Ok, so For interpolation, let's just get rid of |
Sure, that seems fine. As long as |
Sorry. |
so, how are these supposed to be written now:
|
There are two options: replace |
Ok for now I have put it so those regexes will continue to work as before. |
The “band-aid” fixed the |
Stdlib: Distributed URL: https://github.com/JuliaLang/Distributed.jl Stdlib branch: master Julia branch: master Old commit: 6c7cdb5 New commit: c613685 Julia version: 1.12.0-DEV Distributed version: 1.11.0(Does not match) Bump invoked by: @DilumAluthge Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Distributed.jl@6c7cdb5...c613685 ``` $ git log --oneline 6c7cdb5..c613685 c613685 Merge pull request #116 from JuliaLang/ci-caching 20e2ce7 Use julia-actions/cache in CI 9c5d73a Merge pull request #112 from JuliaLang/dependabot/github_actions/codecov/codecov-action-5 ed12496 Merge pull request #107 from JamesWrigley/remotechannel-empty 010828a Update .github/workflows/ci.yml 11451a8 Bump codecov/codecov-action from 4 to 5 8b5983b Merge branch 'master' into remotechannel-empty 729ba6a Fix docstring of `@everywhere` (#110) af89e6c Adding better docs to exeflags kwarg (#108) 8537424 Implement Base.isempty(::RemoteChannel) 6a0383b Add a wait(::[Abstract]WorkerPool) (#106) 1cd2677 Bump codecov/codecov-action from 1 to 4 (#96) cde4078 Bump actions/cache from 1 to 4 (#98) 6c8245a Bump julia-actions/setup-julia from 1 to 2 (#97) 1ffaac8 Bump actions/checkout from 2 to 4 (#99) 8e3f849 Fix RemoteChannel iterator interface (#100) f4aaf1b Fix markdown errors in README.md (#95) 2017da9 Merge pull request #103 from JuliaLang/sf/sigquit_instead 07389dd Use `SIGQUIT` instead of `SIGTERM` ``` Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Stdlib: Distributed URL: https://github.com/JuliaLang/Distributed.jl Stdlib branch: master Julia branch: master Old commit: 6c7cdb5 New commit: c613685 Julia version: 1.12.0-DEV Distributed version: 1.11.0(Does not match) Bump invoked by: @DilumAluthge Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Distributed.jl@6c7cdb5...c613685 ``` $ git log --oneline 6c7cdb5..c613685 c613685 Merge pull request #116 from JuliaLang/ci-caching 20e2ce7 Use julia-actions/cache in CI 9c5d73a Merge pull request #112 from JuliaLang/dependabot/github_actions/codecov/codecov-action-5 ed12496 Merge pull request #107 from JamesWrigley/remotechannel-empty 010828a Update .github/workflows/ci.yml 11451a8 Bump codecov/codecov-action from 4 to 5 8b5983b Merge branch 'master' into remotechannel-empty 729ba6a Fix docstring of `@everywhere` (#110) af89e6c Adding better docs to exeflags kwarg (#108) 8537424 Implement Base.isempty(::RemoteChannel) 6a0383b Add a wait(::[Abstract]WorkerPool) (#106) 1cd2677 Bump codecov/codecov-action from 1 to 4 (#96) cde4078 Bump actions/cache from 1 to 4 (#98) 6c8245a Bump julia-actions/setup-julia from 1 to 2 (#97) 1ffaac8 Bump actions/checkout from 2 to 4 (#99) 8e3f849 Fix RemoteChannel iterator interface (#100) f4aaf1b Fix markdown errors in README.md (#95) 2017da9 Merge pull request #103 from JuliaLang/sf/sigquit_instead 07389dd Use `SIGQUIT` instead of `SIGTERM` ``` Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
We're close to this, but the error messaging of these two forms is still quite different — the cases in which errors occur is (nearly) the same, but the way errors are shown is quite different. For maximum seamlessness between the two forms, all errors should appear the same.
The text was updated successfully, but these errors were encountered: