mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 08:30:26 +00:00
Add unification to match macro.
Using a quote on a symbol prevents the match macro from trying to create a binding to it, and instead tells it that we are binding to a symbol that is already in scope.
This commit is contained in:
parent
30cb01e2f0
commit
7d49e3e6f1
2
Makefile
2
Makefile
@ -252,7 +252,7 @@ dist: build/janet-dist.tar.gz
|
|||||||
|
|
||||||
build/janet-%.tar.gz: $(JANET_TARGET) \
|
build/janet-%.tar.gz: $(JANET_TARGET) \
|
||||||
src/include/janet.h src/include/janetconf.h \
|
src/include/janet.h src/include/janetconf.h \
|
||||||
janet.1 LICENSE CONTRIBUTING.md $(JANET_LIBRARY) \
|
janet.1 LICENSE CONTRIBUTING.md $(JANET_LIBRARY) $(JANET_STATIC_LIBRARY) \
|
||||||
build/doc.html README.md build/janet.c
|
build/doc.html README.md build/janet.c
|
||||||
tar -czvf $@ $^
|
tar -czvf $@ $^
|
||||||
|
|
||||||
|
@ -1127,10 +1127,13 @@
|
|||||||
~(if (= nil (def ,pattern ,expr)) ,sentinel ,(onmatch))))
|
~(if (= nil (def ,pattern ,expr)) ,sentinel ,(onmatch))))
|
||||||
|
|
||||||
(tuple? pattern)
|
(tuple? pattern)
|
||||||
|
(if (and (= (pattern 0) 'quote) (symbol? (pattern 1)))
|
||||||
|
# Unification with external values
|
||||||
|
~(if (= ,(pattern 1) ,expr) ,(onmatch) ,sentinel)
|
||||||
(match-1
|
(match-1
|
||||||
(get pattern 0) expr
|
(get pattern 0) expr
|
||||||
(fn []
|
(fn []
|
||||||
~(if (and ,;(tuple/slice pattern 1)) ,(onmatch) ,sentinel)) seen)
|
~(if (and ,;(tuple/slice pattern 1)) ,(onmatch) ,sentinel)) seen))
|
||||||
|
|
||||||
(array? pattern)
|
(array? pattern)
|
||||||
(do
|
(do
|
||||||
|
Loading…
Reference in New Issue
Block a user