aboutsummaryrefslogtreecommitdiff
path: root/lux-scheme
diff options
context:
space:
mode:
authorEduardo Julian2021-07-11 01:51:04 -0400
committerEduardo Julian2021-07-11 01:51:04 -0400
commitabe24425ced15fd784ef6c62d6f186af72b491db (patch)
tree42b6e3cbd179c83fae8941fa4b128b13afc766f5 /lux-scheme
parent4610968193df10af12c91f699fec39aeb3ef703a (diff)
Re-named ":coerce" to ":as" since it technically doesn't do coercions.
Diffstat (limited to 'lux-scheme')
-rw-r--r--lux-scheme/source/program.lux62
1 files changed, 31 insertions, 31 deletions
diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux
index d71daa6e7..b437e1e23 100644
--- a/lux-scheme/source/program.lux
+++ b/lux-scheme/source/program.lux
@@ -133,10 +133,10 @@
(def: (variant? value)
(-> Any Bit)
- (case (ffi.check [java/lang/Object] (:coerce java/lang/Object value))
+ (case (ffi.check [java/lang/Object] (:as java/lang/Object value))
(#.Some array)
## TODO: Get rid of this coercion ASAP.
- (let [array (:coerce (Array java/lang/Object) array)]
+ (let [array (:as (Array java/lang/Object) array)]
(and (n.= 3 (array.size array))
(case (array.read 0 array)
(#.Some tag)
@@ -172,7 +172,7 @@
## Methods
(program/VariantValue
[] (getValue self) java/lang/Object
- (:coerce java/lang/Object value))
+ (:as java/lang/Object value))
(gnu/lists/Pair
[] (getCar self) java/lang/Object
(if cdr?
@@ -185,7 +185,7 @@
(|> value
(array.read 0)
maybe.assume
- (:coerce java/lang/Integer)
+ (:as java/lang/Integer)
gnu/math/IntNum::new)))
(gnu/lists/Pair
[] (getCdr self) java/lang/Object
@@ -203,14 +203,14 @@
## Methods
(program/TupleValue
[] (getValue self) java/lang/Object
- (:coerce java/lang/Object value))
+ (:as java/lang/Object value))
(gnu/lists/SimpleVector
[] (getBufferLength self) int
(ffi.long_to_int (array.size value)))
(gnu/lists/SimpleVector
[] (getRaw self {idx int}) java/lang/Object
(|> value
- (array.read (|> idx java/lang/Integer::longValue (:coerce Nat)))
+ (array.read (|> idx java/lang/Integer::longValue (:as Nat)))
maybe.assume
lux_value))
(gnu/lists/SimpleVector
@@ -246,8 +246,8 @@
(#.Some value)
## TODO: Get rid of the coercions below.
(if (variant? value)
- (variant_value lux_value false (:coerce (Array java/lang/Object) value))
- (tuple_value lux_value (:coerce (Array java/lang/Object) value)))
+ (variant_value lux_value false (:as (Array java/lang/Object) value))
+ (tuple_value lux_value (:as (Array java/lang/Object) value)))
#.None)
value))
@@ -256,7 +256,7 @@
(def: (variant tag flag value)
(-> Nat Bit Any Any)
- [(java/lang/Long::intValue (:coerce java/lang/Long tag))
+ [(java/lang/Long::intValue (:as java/lang/Long tag))
(: Any
(if flag
synthesis.unit
@@ -267,15 +267,15 @@
(-> (Reader java/lang/Object) (Reader gnu/lists/Pair))
(do try.monad
[tag (read (gnu/lists/Pair::getCar host_object))
- #let [host_object (:coerce gnu/lists/Pair (gnu/lists/Pair::getCdr host_object))
+ #let [host_object (:as gnu/lists/Pair (gnu/lists/Pair::getCdr host_object))
flag (case (ffi.check java/lang/Boolean (gnu/lists/Pair::getCar host_object))
(#.Some flag)
- (:coerce Bit flag)
+ (:as Bit flag)
#.None
(undefined))]
value (read (gnu/lists/Pair::getCdr host_object))]
- (wrap (..variant (:coerce Nat tag) flag value))))
+ (wrap (..variant (:as Nat tag) flag value))))
(def: (read_tuple read host_object)
(-> (Reader java/lang/Object) (Reader (gnu/lists/FVector java/lang/Object)))
@@ -326,32 +326,32 @@
#.None)
(case (ffi.check gnu/lists/FVector host_object)
(#.Some host_object)
- (read_tuple read (:coerce (gnu/lists/FVector java/lang/Object) host_object))
+ (read_tuple read (:as (gnu/lists/FVector java/lang/Object) host_object))
#.None)
## else
(exception.throw ..unknown_kind_of_host_object host_object))))
(def: ensure_macro
(-> Macro (Maybe gnu/mapping/Procedure))
- (|>> (:coerce java/lang/Object) (ffi.check gnu/mapping/Procedure)))
+ (|>> (:as java/lang/Object) (ffi.check gnu/mapping/Procedure)))
(def: (expander macro inputs lux)
Expander
(case (..ensure_macro macro)
(#.Some macro)
- (case (gnu/mapping/Procedure::apply2 (lux_value (:coerce java/lang/Object inputs))
- (lux_value (:coerce java/lang/Object lux))
+ (case (gnu/mapping/Procedure::apply2 (lux_value (:as java/lang/Object inputs))
+ (lux_value (:as java/lang/Object lux))
macro)
(#try.Success output)
(|> output
..read
- (:coerce (Try (Try [Lux (List Code)]))))
+ (:as (Try (Try [Lux (List Code)]))))
(#try.Failure error)
(#try.Failure error))
#.None
- (exception.throw ..cannot_apply_a_non_function (:coerce java/lang/Object macro)))
+ (exception.throw ..cannot_apply_a_non_function (:as java/lang/Object macro)))
)
(def: host
@@ -380,7 +380,7 @@
(wrap [global value definition]))))
(def: (ingest context content)
- (|> content (\ encoding.utf8 decode) try.assume (:coerce _.Expression)))
+ (|> content (\ encoding.utf8 decode) try.assume (:as _.Expression)))
(def: (re_learn context content)
(run! content))
@@ -414,24 +414,24 @@
(def: extender
Extender
## TODO: Stop relying on coercions ASAP.
- (<| (:coerce Extender)
+ (<| (:as Extender)
(function (@self handler))
- (:coerce Handler)
+ (:as Handler)
(function (@self name phase))
- (:coerce Phase)
+ (:as Phase)
(function (@self archive parameters))
- (:coerce Operation)
+ (:as Operation)
(function (@self state))
- (:coerce Try)
+ (:as Try)
try.assume
- (:coerce Try)
+ (:as Try)
(do try.monad
- [handler (try.from_maybe (..ensure_macro (:coerce Macro handler)))
- output (gnu/mapping/Procedure::applyN (array.from_list (list (lux_value (:coerce java/lang/Object name))
- (lux_value (:coerce java/lang/Object phase))
- (lux_value (:coerce java/lang/Object archive))
- (lux_value (:coerce java/lang/Object parameters))
- (lux_value (:coerce java/lang/Object state))))
+ [handler (try.from_maybe (..ensure_macro (:as Macro handler)))
+ output (gnu/mapping/Procedure::applyN (array.from_list (list (lux_value (:as java/lang/Object name))
+ (lux_value (:as java/lang/Object phase))
+ (lux_value (:as java/lang/Object archive))
+ (lux_value (:as java/lang/Object parameters))
+ (lux_value (:as java/lang/Object state))))
handler)]
(..read output))))