diff options
author | Eduardo Julian | 2022-08-11 04:15:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-08-11 04:15:07 -0400 |
commit | 065e8a4d8122d4616b570496915d2c0e2c78cd6b (patch) | |
tree | f2bbdc3e40b796b34026ab04c9a478d8a3f082d5 /lux-r | |
parent | 68d78235694c633c956bb9e8a007cad7d65370bc (diff) |
Re-named the "case" macro to "when".
Diffstat (limited to '')
-rw-r--r-- | lux-r/source/program.lux | 22 | ||||
-rw-r--r-- | lux-ruby/source/program.lux | 52 |
2 files changed, 37 insertions, 37 deletions
diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index 68f8ef9c8..ab60ff510 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -182,7 +182,7 @@ ... (def host_bit ... (-> Bit org/armedbear/lisp/LispObject) -... (|>> (pipe.case #0 (org/armedbear/lisp/Nil::NIL) +... (|>> (pipe.when #0 (org/armedbear/lisp/Nil::NIL) ... #1 (org/armedbear/lisp/Symbol::T)))) (def %%code @@ -195,7 +195,7 @@ ... (function (_ sub_value) ... (let [sub_value (as java/lang/Object sub_value)] ... (`` (<| (,, (with_template [<type> <then>] - ... [(case (ffi.as <type> sub_value) + ... [(when (ffi.as <type> sub_value) ... {.#Some sub_value} ... (`` (|> sub_value (,, (template.splice <then>)))) ... {.#None})] @@ -367,7 +367,7 @@ (as java/lang/Object) read)] (wrap [(|> tag (as java/lang/Long) java/lang/Long::intValue) - (case (|> host_object + (when (|> host_object (org/renjin/sexp/ListVector::get_field runtime.variant_flag_field) (ffi.as org/renjin/sexp/Null)) {.#Some _} @@ -379,7 +379,7 @@ (def (read_i64 host_object) (Reader org/renjin/sexp/ListVector) - (case [(|> host_object + (when [(|> host_object (org/renjin/sexp/ListVector::get_field runtime.i64_high_field) (ffi.as org/renjin/sexp/IntArrayVector)) (|> host_object @@ -398,7 +398,7 @@ (loop (again [idx 0 output (as (Array Any) (array.new size))]) (if (n.< size idx) - (case (|> host_object (org/renjin/sexp/ListVector::get_index (.int idx)) (as java/lang/Object) read) + (when (|> host_object (org/renjin/sexp/ListVector::get_index (.int idx)) (as java/lang/Object) read) {try.#Failure error} {try.#Failure error} @@ -418,14 +418,14 @@ (Reader java/lang/Object) (exec ... (debug.log! (exception.construct ..unknown_kind_of_object [host_object])) - (`` (<| (case (ffi.as org/renjin/sexp/ListVector host_object) + (`` (<| (when (ffi.as org/renjin/sexp/ListVector host_object) {.#Some host_object} - (<| (case (..read_variant read host_object) + (<| (when (..read_variant read host_object) {try.#Success output} {try.#Success output} {try.#Failure _}) - (case (..read_i64 host_object) + (when (..read_i64 host_object) {try.#Success output} {try.#Success output} @@ -434,7 +434,7 @@ {.#None}) (,, (with_template [<class> <post_processing>] - [(case (ffi.as <class> host_object) + [(when (ffi.as <class> host_object) {.#Some host_object} (`` (|> host_object (,, (template.splice <post_processing>)))) @@ -461,7 +461,7 @@ (-> org/renjin/script/RenjinScriptEngine (List Code) Lux org/renjin/sexp/Closure (Try (Try [Lux (List Code)]))) (let [_ (debug.log! "@call_macro 0") r_inputs (is org/renjin/sexp/PairList - (case (ffi.try (|> (org/renjin/sexp/PairList$Builder::new) + (when (ffi.try (|> (org/renjin/sexp/PairList$Builder::new) (org/renjin/sexp/PairList$Builder::add (..host_value inputs)) (org/renjin/sexp/PairList$Builder::add (..host_value lux)) org/renjin/sexp/PairList$Builder::build @@ -488,7 +488,7 @@ (def (expander interpreter macro inputs lux) (-> org/renjin/script/RenjinScriptEngine Expander) - (case (ensure_macro macro) + (when (ensure_macro macro) {.#Some macro} (call_macro interpreter inputs lux macro) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 6c541c74c..534b78e34 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -238,12 +238,12 @@ output (is (Array Any) (array.empty size))]) (if (n.< size idx) - (case (org/jruby/RubyArray::get (ffi.as_int (.int idx)) host_object) + (when (org/jruby/RubyArray::get (ffi.as_int (.int idx)) host_object) {.#None} (again (++ idx) output) {.#Some value} - (case (read value) + (when (read value) {try.#Success lux_value} (again (++ idx) (array.has! idx lux_value output)) @@ -258,7 +258,7 @@ (def (read_variant read host_object) (-> Translator org/jruby/RubyHash (Try Any)) - (case [(org/jruby/RubyHash::get (ffi.as_string runtime.variant_tag_field) host_object) + (when [(org/jruby/RubyHash::get (ffi.as_string runtime.variant_tag_field) host_object) (org/jruby/RubyHash::get (ffi.as_string runtime.variant_flag_field) host_object) (org/jruby/RubyHash::get (ffi.as_string runtime.variant_value_field) host_object)] [{.#Some tag} ?flag {.#Some value}] @@ -269,7 +269,7 @@ java/lang/Long::intValue (is java/lang/Integer))) (is Any - (case ?flag + (when ?flag {.#Some _} "" @@ -287,7 +287,7 @@ (`` (<| (if (ffi.null? host_object) (exception.except ..nil_has_no_lux_representation [])) (,, (with_template [<class> <post_processing>] - [(case (ffi.as <class> host_object) + [(when (ffi.as <class> host_object) {.#Some typed_object} (`` (|> typed_object (,, (template.spliced <post_processing>)))) @@ -327,7 +327,7 @@ (-> java/lang/Object org/jruby/runtime/builtin/IRubyObject)) (function (again value) (`` (<| (,, (with_template [<when> <then>] - [(case (ffi.as <when> value) + [(when (ffi.as <when> value) {.#Some value} (|> value <then> @@ -401,7 +401,7 @@ (list#each (function (_ index) (ffi.read! index args))) (monad.each ! (|>> (ffi.is java/lang/Object) ..read))) - output (case args + output (when args (list arg/0) (in ((as (-> Any java/lang/Object) value) arg/0)) @@ -462,9 +462,9 @@ block org/jruby/runtime/Block]) org/jruby/runtime/builtin/IRubyObject (let [member (ffi.read! 0 args)] - (<| (case (ffi.as org/jruby/RubyFixnum member) + (<| (when (ffi.as org/jruby/RubyFixnum member) {.#Some member} - (case (array.item (.nat (ffi.of_long (org/jruby/RubyFixnum::getLongValue member))) value) + (when (array.item (.nat (ffi.of_long (org/jruby/RubyFixnum::getLongValue member))) value) {.#Some value} (wrapped_lux_value (as_expected useful_object_class) lux_structure value) @@ -472,9 +472,9 @@ ..ruby_nil) {.#None}) - (case (ffi.as org/jruby/RubyString member) + (when (ffi.as org/jruby/RubyString member) {.#Some member} - (case (ffi.of_string (org/jruby/RubyString::asJavaString member)) + (when (ffi.of_string (org/jruby/RubyString::asJavaString member)) runtime.variant_tag_field (|> value (array.item 0) @@ -485,7 +485,7 @@ (ffi.is org/jruby/runtime/builtin/IRubyObject)) runtime.variant_flag_field - (case (array.item 1 value) + (when (array.item 1 value) {.#None} ..ruby_nil @@ -493,7 +493,7 @@ ..lux_unit) runtime.variant_value_field - (case (array.item 2 value) + (when (array.item 2 value) {.#Some value} (wrapped_lux_value (as_expected useful_object_class) lux_structure value) @@ -504,9 +504,9 @@ (panic! (exception.error ..invalid_variant_access [field]))) {.#None}) - (case (ffi.as org/jruby/RubyRange member) + (when (ffi.as org/jruby/RubyRange member) {.#Some member} - (case [(|> member (org/jruby/RubyRange::first thread_context) (ffi.as org/jruby/RubyFixnum)) + (when [(|> member (org/jruby/RubyRange::first thread_context) (ffi.as org/jruby/RubyFixnum)) (|> member (org/jruby/RubyRange::size thread_context) (ffi.as org/jruby/RubyFixnum))] [{.#Some first} {.#Some size}] (let [first (ffi.of_long (org/jruby/RubyFixnum::getLongValue first)) @@ -541,7 +541,7 @@ (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime) ffi.as_boolean - (case (|> args + (when (|> args (ffi.read! 0) (ffi.is java/lang/Object) ..read) @@ -625,11 +625,11 @@ args [org/jruby/runtime/builtin/IRubyObject] block org/jruby/runtime/Block]) org/jruby/runtime/builtin/IRubyObject - (case (|> args + (when (|> args (ffi.read! 0) (ffi.as org/jruby/RubySymbol)) {.#Some method} - (|> (case (|> method + (|> (when (|> method org/jruby/RubySymbol::asJavaString ffi.of_string) (^.or "==" "equal?" @@ -663,7 +663,7 @@ (org/jruby/RubyClass [] (searchWithCache this [method java/lang/String]) org/jruby/runtime/callsite/CacheEntry - (case (ffi.of_string method) + (when (ffi.of_string method) "call" (org/jruby/runtime/callsite/CacheEntry::new (::call useful_object_class lux_structure value) (ffi.as_int +0)) @@ -719,9 +719,9 @@ (def (expander macro inputs lux) Expander - (case (macro! macro) + (when (macro! macro) {.#Some macro} - (case (call_macro inputs lux macro) + (when (call_macro inputs lux macro) {try.#Success output} (|> output (as java/lang/Object) @@ -851,10 +851,10 @@ [inputs (|> inputs (array.list {.#None}) (monad.each ! (|>> (ffi.is java/lang/Object) ..read)))]) - (case inputs + (when inputs ... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value. (list info source location current_module modules scopes type_context expected seed scope_type_vars extensions eval host) - (case partial_application + (when partial_application (list partial/0 partial/1) (in (..to_host ((as (-> Any Any Any Any) phase) partial/0 @@ -869,7 +869,7 @@ (host_phase partial_application phase))} (list input/0) - (case partial_application + (when partial_application (list) (in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (host_phase (list input/0) phase))) @@ -888,7 +888,7 @@ (exception.except ..invaid_phase_application [partial_application inputs])) (list input/0 input/1) - (case partial_application + (when partial_application (list) (in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (host_phase (list input/0 input/1) phase))) @@ -903,7 +903,7 @@ (exception.except ..invaid_phase_application [partial_application inputs])) (list input/0 input/1 input/2) - (case partial_application + (when partial_application (list) (in (..to_host ((as (-> Any Any Any Any) phase) input/0 |