Constraint -> guard
This commit is contained in:
parent
c1b305bc1c
commit
35eed84741
|
@ -261,17 +261,17 @@
|
||||||
(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)
|
||||||
new-ctx (volatile! {::parent ctx})
|
new-ctx (volatile! {::parent ctx})
|
||||||
match? (match pattern value new-ctx)
|
match? (match pattern value new-ctx)
|
||||||
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,9 +350,9 @@
|
||||||
;(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)
|
||||||
fn-ctx (volatile! {::parent closed-over})
|
fn-ctx (volatile! {::parent closed-over})
|
||||||
match? (match pattern args fn-ctx)
|
match? (match pattern args fn-ctx)
|
||||||
|
@ -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,17 +541,17 @@
|
||||||
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)
|
||||||
new-ctx (volatile! {::parent ctx})
|
new-ctx (volatile! {::parent ctx})
|
||||||
match? (match pattern input new-ctx)
|
match? (match pattern input new-ctx)
|
||||||
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