do expressions

This commit is contained in:
Scott Richmond 2024-05-19 18:38:44 -04:00
parent 822f5c0178
commit 6bf4dde487

View File

@ -324,8 +324,12 @@
(defn- partial [the-fn args] (todo "partially applied functions"))
(defn- call-fn [the-fn args]
(print "calling fn " (the-fn :name))
(print "with args " args)
(print "calling " (b/show the-fn))
(print "with args " (b/show args))
(when (or
(= :function (type the-fn))
(= :cfunction (type the-fn)))
(break (the-fn ;args)))
(def clauses (the-fn :body))
(def len (length clauses))
(when (the-fn :match) (break ((the-fn :match) 0 args)))
@ -360,7 +364,7 @@
(match types
[:fn :tuple] (call-fn prev curr)
[:fn :partial] (partial prev curr)
[:function :tuple] (prev ;curr)
[:function :tuple] (call-fn prev curr)
[:keyword :args] (get (first curr) prev :^nil)
[:dict :keyword] (get prev curr :^nil)
[:nil :keyword] :^nil
@ -384,7 +388,15 @@
(print "done with inner terms, applying last term")
(apply-synth-term prev (interpret last-term ctx)))
(defn- doo [ast ctx] (todo "do expressions"))
(defn- doo [ast ctx]
(def terms (ast :data))
(var prev (interpret (first terms) ctx))
(def last-term (last terms))
(for i 1 (-> terms length dec)
(def curr (interpret (terms i) ctx))
(set prev (call-fn curr [prev])))
(def last-fn (interpret last-term ctx))
(call-fn last-fn [prev]))
(defn- pkg [ast ctx] (todo "pkgs"))