Skip to content

Commit

Permalink
cj-env-2: pmatch: support quoted expressions as eq? checks
Browse files Browse the repository at this point in the history
  • Loading branch information
pflanze committed Aug 12, 2020
1 parent 50ee230 commit b74f91a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cj-env-2.scm
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@
(set! have-else? #t)
`(else ,@rest))
(`(`pexpr . `rest)
`((,pexpr, V) ,@rest)))
(mcase pexpr
(`(quote `val)
`((eq? ,V ',val) ,@rest))
(else
`((,pexpr ,V) ,@rest)))))
cases)))
`(let ((,V ,expr))
(cond ,@cases*
Expand All @@ -188,9 +192,12 @@
> (define (t v)
(pmatch v
(number? 'num)
('foo 'is-foo)
(string? 'str)))
> (t "foo")
str
> (t 'foo)
is-foo
> (t 123)
num
> (%try-error (t 'bar))
Expand Down

0 comments on commit b74f91a

Please sign in to comment.