From 670438b982bbe0b662b0a65958dc4f8b289d3906 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 18 Jan 2023 01:38:48 -0400 Subject: More efficient "let" and "exec" expressions. --- lux-python/source/program.lux | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lux-python') diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index b63c638ca..45cc52ddc 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -409,8 +409,8 @@ (with_expansions [ (def host (IO (Host (_.Expression Any) (_.Statement Any))) (io (let [interpreter (org/python/util/PythonInterpreter::new) - evaluate! (is (-> unit.ID [(Maybe unit.ID) (_.Expression Any)] (Try Any)) - (function (evaluate! context [_ input]) + evaluate! (is (-> [(Maybe unit.ID) (_.Expression Any)] (Try Any)) + (function (evaluate! [_ input]) (do try.monad [output (org/python/util/PythonInterpreter::eval (ffi.as_string (_.code input)) interpreter)] (..read output)))) @@ -435,7 +435,7 @@ (do try.monad [.let [definition (_.set (list @global) input)] _ (execute! definition) - value (evaluate! context [@def @global])] + value (evaluate! [@def @global])] (in [global value definition])))) (def (ingest context content) @@ -450,7 +450,7 @@ (def (re_load context custom content) (do try.monad [_ (execute! content)] - (evaluate! context [{.#None} (_.var (reference.artifact context))]))))))))] + (evaluate! [{.#None} (_.var (reference.artifact context))]))))))))] (for @.old @.jvm @@ -462,8 +462,8 @@ (IO (Host (_.Expression Any) (_.Statement Any))) (io (is (Host (_.Expression Any) (_.Statement Any)) (let [globals (..dict []) - evaluate! (is (-> unit.ID (_.Expression Any) (Try Any)) - (function (evaluate! context input) + evaluate! (is (-> (_.Expression Any) (Try Any)) + (function (evaluate! input) (..eval [(_.code input) globals]))) execute! (is (-> (_.Statement Any) (Try Any)) (function (execute! input) @@ -475,7 +475,7 @@ (do try.monad [.let [definition (_.set (list @global) input)] _ (execute! definition) - value (evaluate! context @global)] + value (evaluate! @global)] (in [global value definition])))))] (implementation (def evaluate! evaluate!) @@ -491,7 +491,7 @@ (def (re_load context content) (do try.monad [_ (execute! content)] - (evaluate! context (_.var (reference.artifact context))))))))))))) + (evaluate! (_.var (reference.artifact context))))))))))))) (def phase_wrapper phase.Wrapper -- cgit v1.2.3