racket / racket/rhombus

Unquoted matches are not available in the same pattern

Open
#473 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
601
Forks
74
Avg merge
2d 10h
Merged PRs (30d)
5

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two Rhombus examples in the issue and compare their behavior with the corresponding Racket syntax/parse example. Trace how unquoted matches in a quoted pattern are made available to later subpatterns; the examples should work while preserving the stated match_when conditions.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.