-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Discrepancy between match behaviour and documentation #3403
Comments
I think this is an error in the docs. None of the documented rules for quasipatterns cover that case:
What happens if you try |
The |
That does make sense, since it's trying to match a list whose tail matches the literal symbol |
I think the typo is that the quote should be a quasiquote - the following match works as expected if the single quote in the docs were a backtick: (match '(+ 1 2 3)
[`(+ ,@`(,a ,b ,c)) (list "match" a b c)]
[_ "no match"]) |
Oh that would make sense. Then I think fixing that clause and adding another clause for the bare identifier case would be appropriate. |
I'm not sure the bare identifier case should exist at all - this snippet fails on a syntax error: #lang racket
(match '(+ 1 2 3)
[`(+ ,@a ,@b) (list "match" a)]
[_ "no match"]) The error is I'm not sure how Racket would decide how to split up the list |
I didn't totally follow the discussion, but on Slack I believe that @pavpanchekha (and maybe @samth?) mentioned that they are planning to improve the bare identifier case. So I would consider the failure in the bare identifier case a bug that should be fixed, rather than something that shouldn't be supported. |
FWIW, here's a message from @pavpanchekha:
|
Yep, that's the case I ran into. It's true that |
I don't think that |
I meant those two examples with a quasiquote in front:
|
If you meant
|
Ah, my bad on both counts. |
It's the same situation as:
|
The pull request mentioned above adjusts the behavior for quasiquote so it now always works with bare variables. Does the documentation still need to be adjusted? |
There's a weird |
Scratch that. From a quick test,
seems to work. Would it make more sense to replace
with one general clause, allowing arbitrary |
I think
|
I'm confused about the current state here. Is there still a problem with the docs? |
@samth Yes. In the docs, A separate issue is that racket/racket/collects/racket/match/parse-quasi.rkt Lines 48 to 57 in 7a52e81
|
Ok, then we should fix the docs. I still don't understand the second comment you're making. |
What version of Racket are you using?
e.g., 7.2 [3m]
What program did you run?
What should have happened?
I expect a syntax error - it is not permissible to use unquote-splicing followed by just an identifier, according to the documentation for match patterns. Instead, I get
'("match" (1 2 3))
Please include any other relevant details
e.g., the operating system used or how you are running the code.
Using DrRacket's definitions window, on Ubuntu Linux (20.04)
The text was updated successfully, but these errors were encountered: