~subsetpark/ec

632481d89fb9e6256d3b4da3fccc32188d9fec53 — Zach Smith 7 months ago 44351a1 v0.3.0
New fugue version
2 files changed, 13 insertions(+), 13 deletions(-)

M lockfile.jdn
M src/eval.janet
M lockfile.jdn => lockfile.jdn +1 -1
@@ 1,3 1,3 @@
@[{:sha "5d1bea51664cf2f076ce6ac4786c2fb744f2c02c" :repo "https://github.com/janet-lang/argparse.git"}
  {:sha "12e2e338cba69b02f284d8082804d8e811436651" :repo "https://github.com/pyrmont/testament"}
  {:sha "3f965babae21a74ef6f77e183050cc71d86d54a0" :repo "https://git.sr.ht/~subsetpark/fugue"}]
  {:sha "0bd7102da8f2d32355b31425514f61d4b72907d3" :repo "https://git.sr.ht/~subsetpark/fugue"}]

M src/eval.janet => src/eval.janet +12 -12
@@ 1,12 1,12 @@
(use fugue)
(use /src/calc)
(import /src/calc)

(def define (:new Adverb
(def define (:new calc/Adverb
                  :arity 2
                  :type :define
                  :fun-ref (fn define [stack]
                             (let [sym (pop stack)
                                   q (pop stack)]
                             (let [sym (calc/pop stack)
                                   q (calc/pop stack)]
                               (match sym
                                 {:value sym-value :quoted? true} (put-in stack [:env sym-value] q))))))



@@ 21,7 21,7 @@
    # Mark the stored quotation for evaluation by creating a Thunk out
    # of it, which is a Quotation that evaluates its contents when
    # pushed to the stack.
    (q (Quotation? q)) (:new Thunk (q :data))
    (q (calc/Quotation? q)) (:new calc/Thunk (q :data))
    nil (errorf "Eval error: unknown word %s" sym-value)
    elem elem))



@@ 42,21 42,21 @@
  ```
  [stack maybe-quote]
  (match maybe-quote
    (q (Quotation*? q)) (each elem (data q)
    (q (calc/Quotation*? q)) (each elem (calc/data q)
                          (->> elem
                               (eval stack)
                               (push stack)))
    not-a-quote (push stack not-a-quote)))
                               (calc/push stack)))
    not-a-quote (calc/push stack not-a-quote)))

(extend-multi push
              [Stack Thunk]
(extend-multi calc/push
              [calc/Stack calc/Thunk]
              [stack thunk]
              (let [evaled (map |(eval stack $) (thunk :data))
                    q (:new Quotation evaled)]
                    q (:new calc/Quotation evaled)]
                (apply-quotation stack q)))

(defn eval-and-push
  [stack symbol]
  (->> symbol
       (eval stack)
       (push stack)))
       (calc/push stack)))