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

Unquoted matches are not available in the same pattern #473

Open
usaoc opened this issue Jan 31, 2024 · 0 comments
Open

Unquoted matches are not available in the same pattern #473

usaoc opened this issue Jan 31, 2024 · 0 comments

Comments

@usaoc
Copy link
Collaborator

usaoc commented Jan 31, 2024

Unquoted matches, that is, $ matches in a '' pattern, are not available within that pattern, even to later subpatterns. For example,

#lang rhombus/static
'1 2' is_a matching(
  '$(first_int :: Int)
     $(pattern:
         kind ~term
       | '$(second_int :: Int)':
           match_when first_int.unwrap() == second_int.unwrap())'
)

this program does not work, nor does

#lang rhombus/static
syntax_class SomeInt(int):
  kind ~term
| '$(this_int :: Int)':
    match_when this_int.unwrap() == int

'1 2' is_a matching(
  '$(first_int :: Int)
     $(_ :: SomeInt(first_int.unwrap()))'
)

In contrast, the corresponding Racket program

#lang racket/base
(require syntax/parse)

(syntax-parse #'(1 2)
  [(first-int:integer
    (~and second-int:integer
          (~fail #:unless (eqv? (syntax-e #'first-int)
                                (syntax-e #'second-int)))))
   #t]
  [_ #f])

works just fine.

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

1 participant