Constraint -> guard
This commit is contained in:
parent
c1b305bc1c
commit
35eed84741
|
@ -261,7 +261,7 @@
|
||||||
(if clause
|
(if clause
|
||||||
(let [clause-data (:data clause)
|
(let [clause-data (:data clause)
|
||||||
pattern (first clause-data)
|
pattern (first clause-data)
|
||||||
constraint (if (= 3 (count clause-data))
|
guard (if (= 3 (count clause-data))
|
||||||
(second clause-data)
|
(second clause-data)
|
||||||
nil)
|
nil)
|
||||||
body (peek clause-data)
|
body (peek clause-data)
|
||||||
|
@ -270,8 +270,8 @@
|
||||||
success (:success match?)
|
success (:success match?)
|
||||||
clause-ctx (:ctx match?)]
|
clause-ctx (:ctx match?)]
|
||||||
(if success
|
(if success
|
||||||
(if constraint
|
(if guard
|
||||||
(if (interpret-ast constraint (volatile! clause-ctx))
|
(if (interpret-ast guard (volatile! clause-ctx))
|
||||||
(do
|
(do
|
||||||
(vswap! new-ctx #(merge % clause-ctx))
|
(vswap! new-ctx #(merge % clause-ctx))
|
||||||
(interpret-ast body new-ctx))
|
(interpret-ast body new-ctx))
|
||||||
|
@ -350,7 +350,7 @@
|
||||||
;(println "With args " args)
|
;(println "With args " args)
|
||||||
(if clause
|
(if clause
|
||||||
(let [pattern (first clause)
|
(let [pattern (first clause)
|
||||||
constraint (if (= 3 (count clause))
|
guard (if (= 3 (count clause))
|
||||||
(second clause)
|
(second clause)
|
||||||
nil)
|
nil)
|
||||||
body (peek clause)
|
body (peek clause)
|
||||||
|
@ -362,13 +362,13 @@
|
||||||
;(println "Pattern: " pattern)
|
;(println "Pattern: " pattern)
|
||||||
;(println "Body: " body)
|
;(println "Body: " body)
|
||||||
(if success
|
(if success
|
||||||
(if constraint
|
(if guard
|
||||||
(if (do
|
(if (do
|
||||||
;(println "######### Testing constraint")
|
;(println "######### Testing guard")
|
||||||
;(println "Context: " clause-ctx)
|
;(println "Context: " clause-ctx)
|
||||||
(interpret-ast constraint vclause))
|
(interpret-ast guard vclause))
|
||||||
(do
|
(do
|
||||||
;(println "passed constraint")
|
;(println "passed guard")
|
||||||
(vswap! fn-ctx #(merge % clause-ctx))
|
(vswap! fn-ctx #(merge % clause-ctx))
|
||||||
(interpret-ast body fn-ctx))
|
(interpret-ast body fn-ctx))
|
||||||
(recur (first clauses) (rest clauses)))
|
(recur (first clauses) (rest clauses)))
|
||||||
|
@ -541,7 +541,7 @@
|
||||||
clauses (rest clauses)]
|
clauses (rest clauses)]
|
||||||
(if clause
|
(if clause
|
||||||
(let [pattern (first clause)
|
(let [pattern (first clause)
|
||||||
constraint (if (= 3 (count clause))
|
guard (if (= 3 (count clause))
|
||||||
(second clause)
|
(second clause)
|
||||||
nil)
|
nil)
|
||||||
body (peek clause)
|
body (peek clause)
|
||||||
|
@ -550,8 +550,8 @@
|
||||||
success (:success match?)
|
success (:success match?)
|
||||||
clause-ctx (:ctx match?)]
|
clause-ctx (:ctx match?)]
|
||||||
(if success
|
(if success
|
||||||
(if constraint
|
(if guard
|
||||||
(if (interpret-ast constraint (volatile! (assoc clause-ctx ::parent ctx)))
|
(if (interpret-ast guard (volatile! (assoc clause-ctx ::parent ctx)))
|
||||||
(do
|
(do
|
||||||
(vswap! new-ctx #(merge % clause-ctx))
|
(vswap! new-ctx #(merge % clause-ctx))
|
||||||
(interpret-ast body new-ctx))
|
(interpret-ast body new-ctx))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user