aboutsummaryrefslogtreecommitdiff
path: root/lux-python
diff options
context:
space:
mode:
authorEduardo Julian2022-03-14 06:14:57 -0400
committerEduardo Julian2022-03-14 06:14:57 -0400
commit4965597043aca57a05760113f1851e96dad1eaf8 (patch)
tree8126d3e6394e38bc52918eea95a67546350bb95e /lux-python
parentcfd438517a46e025b15345e3570b02f5ea6165c0 (diff)
Leaner syntax for the "for" macro.
Diffstat (limited to '')
-rw-r--r--lux-python/source/program.lux112
1 files changed, 56 insertions, 56 deletions
diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux
index 66adcaa27..e784a834e 100644
--- a/lux-python/source/program.lux
+++ b/lux-python/source/program.lux
@@ -340,9 +340,9 @@
))
(:as org/python/core/PyObject it))))
)]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
- @.python (as_is)]))
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
+ @.python (as_is)))
(with_expansions [<jvm> (as_is (def: (call_macro inputs lux macro)
(-> (List Code) Lux org/python/core/PyFunction (Try (Try [Lux (List Code)])))
@@ -380,13 +380,13 @@
{.#None}
(exception.except ..cannot_apply_a_non_function [(:as java/lang/Object macro)]))))]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
- @.python
- (def: (expander macro inputs lux)
- Expander
- {try.#Success ((:as Macro' macro) inputs lux)})]))
+ @.python
+ (def: (expander macro inputs lux)
+ Expander
+ {try.#Success ((:as Macro' macro) inputs lux)})))
(with_expansions [<jvm> (def: host
(IO (Host (_.Expression Any) (_.Statement Any)))
@@ -433,47 +433,47 @@
(do try.monad
[_ (execute! content)]
(evaluate! context [{.#None} (_.var (reference.artifact context))]))))))))]
- (for [@.old <jvm>
- @.jvm <jvm>
-
- @.python
- (as_is (import: (dict [] ffi.Dict))
- (import: (eval [ffi.String ffi.Dict] "try" Any))
-
- (def: host
- (IO (Host (_.Expression Any) (_.Statement Any)))
- (io (: (Host (_.Expression Any) (_.Statement Any))
- (let [globals (..dict [])
- evaluate! (: (-> unit.ID (_.Expression Any) (Try Any))
- (function (evaluate! context input)
- (..eval [(_.code input) globals])))
- execute! (: (-> (_.Statement Any) (Try Any))
- (function (execute! input)
- (ffi.try ("python exec" (_.code input) globals))))
- define! (: (-> unit.ID (_.Expression Any) (Try [Text Any (_.Statement Any)]))
- (function (define! context input)
- (let [global (reference.artifact context)
- @global (_.var global)]
- (do try.monad
- [.let [definition (_.set (list @global) input)]
- _ (execute! definition)
- value (evaluate! context @global)]
- (in [global value definition])))))]
- (implementation
- (def: evaluate! evaluate!)
- (def: execute! execute!)
- (def: define! define!)
-
- (def: (ingest context content)
- (|> content (# utf8.codec decoded) try.trusted (:as (_.Statement Any))))
-
- (def: (re_learn context content)
- (execute! content))
-
- (def: (re_load context content)
- (do try.monad
- [_ (execute! content)]
- (evaluate! context (_.var (reference.artifact context)))))))))))]))
+ (for @.old <jvm>
+ @.jvm <jvm>
+
+ @.python
+ (as_is (import: (dict [] ffi.Dict))
+ (import: (eval [ffi.String ffi.Dict] "try" Any))
+
+ (def: host
+ (IO (Host (_.Expression Any) (_.Statement Any)))
+ (io (: (Host (_.Expression Any) (_.Statement Any))
+ (let [globals (..dict [])
+ evaluate! (: (-> unit.ID (_.Expression Any) (Try Any))
+ (function (evaluate! context input)
+ (..eval [(_.code input) globals])))
+ execute! (: (-> (_.Statement Any) (Try Any))
+ (function (execute! input)
+ (ffi.try ("python exec" (_.code input) globals))))
+ define! (: (-> unit.ID (_.Expression Any) (Try [Text Any (_.Statement Any)]))
+ (function (define! context input)
+ (let [global (reference.artifact context)
+ @global (_.var global)]
+ (do try.monad
+ [.let [definition (_.set (list @global) input)]
+ _ (execute! definition)
+ value (evaluate! context @global)]
+ (in [global value definition])))))]
+ (implementation
+ (def: evaluate! evaluate!)
+ (def: execute! execute!)
+ (def: define! define!)
+
+ (def: (ingest context content)
+ (|> content (# utf8.codec decoded) try.trusted (:as (_.Statement Any))))
+
+ (def: (re_learn context content)
+ (execute! content))
+
+ (def: (re_load context content)
+ (do try.monad
+ [_ (execute! content)]
+ (evaluate! context (_.var (reference.artifact context)))))))))))))
(with_expansions [<jvm> (as_is (def: (extender phase_wrapper)
(-> phase.Wrapper Extender)
@@ -499,13 +499,13 @@
(ffi.write! 4 (..to_host state)))
handler)]
(..read output)))))]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
- @.python
- (def: (extender phase_wrapper handler)
- (-> phase.Wrapper Extender)
- (:expected handler))]))
+ @.python
+ (def: (extender phase_wrapper handler)
+ (-> phase.Wrapper Extender)
+ (:expected handler))))
(def: (phase_wrapper archive)
(-> Archive (runtime.Operation phase.Wrapper))