Called KW enforce one arg
This commit is contained in:
parent
f93eacf5f5
commit
b8e7777841
|
@ -149,11 +149,14 @@
|
||||||
;; TODO: clean this up
|
;; TODO: clean this up
|
||||||
;; TODO: error with a passed tuple longer than 1
|
;; TODO: error with a passed tuple longer than 1
|
||||||
(if (= clojure.lang.Keyword (type fn))
|
(if (= clojure.lang.Keyword (type fn))
|
||||||
(if (::data/struct (second passed))
|
(if (= 2 (count passed))
|
||||||
(if (contains? (second passed) fn)
|
(let [target (second passed) kw fn]
|
||||||
(fn (second passed))
|
(if (::data/struct target)
|
||||||
(throw (ex-info (str "Struct error: no member at " fn) {})))
|
(if (contains? target kw)
|
||||||
(get (second passed) fn))
|
(kw target)
|
||||||
|
(throw (ex-info (str "Struct error: no member at " kw) {})))
|
||||||
|
(kw target)))
|
||||||
|
(throw (ex-info "Called keywords take a single argument" {})))
|
||||||
(throw (ex-info "I don't know how to call that" {:fn fn}))))))
|
(throw (ex-info "I don't know how to call that" {:fn fn}))))))
|
||||||
|
|
||||||
;; TODO: add placeholder partial application
|
;; TODO: add placeholder partial application
|
||||||
|
@ -260,9 +263,9 @@
|
||||||
|
|
||||||
(def source "
|
(def source "
|
||||||
|
|
||||||
fn call (callable, target, thing) -> callable (target, thing)
|
fn call (f, t) -> f (t)
|
||||||
fn id (x) -> x
|
|
||||||
call (:foo, nil, nil)
|
call (:foo, #{:foo 23})
|
||||||
|
|
||||||
")
|
")
|
||||||
|
|
||||||
|
|
|
@ -606,7 +606,14 @@
|
||||||
|
|
||||||
(do
|
(do
|
||||||
(def pp pp/pprint)
|
(def pp pp/pprint)
|
||||||
(def source "@{:foo :bar, :bar 42}")
|
(def source "
|
||||||
|
|
||||||
|
fn maybe_foo (mf) -> if eq (mf, :foo)
|
||||||
|
then (:ok, :foo)
|
||||||
|
else (:error, mf)
|
||||||
|
|
||||||
|
|
||||||
|
")
|
||||||
(def lexed (scanner/scan source))
|
(def lexed (scanner/scan source))
|
||||||
(def tokens (:tokens lexed))
|
(def tokens (:tokens lexed))
|
||||||
(def p (parser tokens))
|
(def p (parser tokens))
|
||||||
|
@ -618,7 +625,7 @@
|
||||||
(println "*** *** NEW PARSE *** ***")
|
(println "*** *** NEW PARSE *** ***")
|
||||||
|
|
||||||
(-> p
|
(-> p
|
||||||
(parse-expr)
|
(parse-script)
|
||||||
(::ast)
|
(::ast)
|
||||||
(pp)))
|
(pp)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user