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

Handle objects of type Symbol and Expr (Matching Julia expressions) #83

Open
gafter opened this issue May 16, 2023 · 0 comments
Open

Handle objects of type Symbol and Expr (Matching Julia expressions) #83

gafter opened this issue May 16, 2023 · 0 comments

Comments

@gafter
Copy link
Member

gafter commented May 16, 2023

See also RelationalAI-oss/Rematch.jl#19

julia> @match :(5+5) begin
         :($_ + $_) => true
         _ => false
       end

This should print true

Slightly more generally, the pattern

  • :(a + b) should match the expression :(a + b) and nothing else
  • :($_ + $_) should match any binary addition
  • :($a + $b) should match any binary addition, and define the pattern variables a and b.
  • :($$a + $$b) should match an addition, where the left-hand-side corresponds to the value of the local variable a and the right-hand-side corresponds to the value of the local variable b. One $ is for escaping from the enclosing :, and the other is for escaping the pattern syntax.

See also JuliaServices/Rematch2.jl#6

@gafter gafter transferred this issue from JuliaServices/Rematch2.jl Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant