From 94c0bc5d12ed44540543bd6772d357baeb32bb45 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 12 Jun 2022 18:28:30 -0400 Subject: De-sigil-ification: suffix : [Part 5] --- .../lux/control/concurrency/actor.lux | 29 ++++++++------- .../library/lux/control/concurrency/actor.lux | 41 +++++++++++----------- .../lux/tool/compiler/language/lux/syntax.lux | 6 ++-- .../source/test/lux/control/concurrency/actor.lux | 13 +++---- 4 files changed, 46 insertions(+), 43 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/documentation/lux/control/concurrency/actor.lux b/stdlib/source/documentation/lux/control/concurrency/actor.lux index 174ff4718..fb84a5b1f 100644 --- a/stdlib/source/documentation/lux/control/concurrency/actor.lux +++ b/stdlib/source/documentation/lux/control/concurrency/actor.lux @@ -54,22 +54,25 @@ .let [_ (debug.log! "AFTER")]] (in output))) - (message: .public (push [value a] state self) - (List a) - (let [state' {.#Item value state}] - (async.resolved {try.#Success [state' state']})))) + (def: .public push + (message (_ [value a] state self) + (List a) + (let [state' {.#Item value state}] + (async.resolved {try.#Success [state' state']}))))) (actor: .public counter Nat - (message: .public (count! [increment Nat] state self) - Any - (let [state' (n.+ increment state)] - (async.resolved {try.#Success [state' state']}))) + (def: .public count! + (message .public (_ [increment Nat] state self) + Any + (let [state' (n.+ increment state)] + (async.resolved {try.#Success [state' state']})))) - (message: .public (read! state self) - Nat - (async.resolved {try.#Success [state state]}))))] + (def: .public read! + (message (_ state self) + Nat + (async.resolved {try.#Success [state state]})))))] (documentation: /.actor: (format "Defines a named actor, with its behavior and internal state." \n "Messages for the actor must be defined after the on_mail handler.") @@ -83,7 +86,7 @@ ((on_mail message state self) (message (++ state) self)))]) - (documentation: /.message: + (documentation: /.message (format "A message can access the actor's state through the state parameter." \n "A message can also access the actor itself through the self parameter." \n "A message's output must be an async containing a 2-tuple with the updated state and a return value." @@ -115,7 +118,7 @@ ..poison! ..actor: ..actor - ..message: + ..message ..Stop ..observe! ($.default /.poisoned) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index b1eb1775d..544c672d9 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -311,15 +311,14 @@ (<>.and .symbol (at <>.monad in (list))))) (def: messageP - (Parser [Code Signature Code Code]) - (|export|.parser - (all <>.and - ..signature^ - .any - .any))) + (Parser [Signature Code Code]) + (all <>.and + ..signature^ + .any + .any)) -(def: .public message: - (syntax (_ [[export_policy signature output_type body] ..messageP]) +(def: .public message + (syntax (_ [[signature output_type body] ..messageP]) (with_symbols [g!_ g!return] (do meta.monad [actor_scope primitive.current @@ -331,19 +330,19 @@ g!inputsT (|> signature (the #inputs) (list#each product.right)) g!state (|> signature (the #state) code.local) g!self (|> signature (the #self) code.local)]] - (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) - (All ((~ g!_) (~+ g!all_vars)) - (-> (~+ g!inputsT) - (..Message (~ (the primitive.#abstraction actor_scope)) - (~ output_type)))) - (function ((~ g!_) (~ g!state) (~ g!self)) - (let [(~ g!state) (as (~ (the primitive.#representation actor_scope)) - (~ g!state))] - (|> (~ body) - (is ((~! async.Async) ((~! try.Try) [(~ (the primitive.#representation actor_scope)) - (~ output_type)]))) - (as ((~! async.Async) ((~! try.Try) [(~ (the primitive.#abstraction actor_scope)) - (~ output_type)])))))))) + (in (list (` (is (All ((~ g!_) (~+ g!all_vars)) + (-> (~+ g!inputsT) + (..Message (~ (the primitive.#abstraction actor_scope)) + (~ output_type)))) + (function ((~ g!message) (~+ g!inputsC)) + (function ((~ g!_) (~ g!state) (~ g!self)) + (let [(~ g!state) (as (~ (the primitive.#representation actor_scope)) + (~ g!state))] + (|> (~ body) + (is ((~! async.Async) ((~! try.Try) [(~ (the primitive.#representation actor_scope)) + (~ output_type)]))) + (as ((~! async.Async) ((~! try.Try) [(~ (the primitive.#abstraction actor_scope)) + (~ output_type)]))))))))) )))))) (type: .public Stop diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 6bde519da..eb9402464 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -499,9 +499,9 @@ {.#Right [source' [@where {@tag full_symbol}]]})])) ... TODO: Grammar macro for specifying syntax. -... (grammar: lux_grammar -... [expression ...] -... [form "(" [#* expression] ")"]) +... (def: lux_grammar +... (grammar [expression "..."] +... [form "(" [#* expression] ")"])) (with_expansions [ (these where (!++ offset/0) source_code) (these [(!forward 1 where) (!++ offset/0) source_code]) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 3149e3873..d99ce25b8 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -19,7 +19,7 @@ [number ["n" nat]]]]] [\\library - ["[0]" / (.only actor: message:) + ["[0]" / (.only actor: message) [// ["[0]" atom (.only Atom)] ["[0]" async (.only Async Resolver) (.open: "[1]#[0]" monad)] @@ -33,10 +33,11 @@ ((on_mail message state self) (message state self)) - (message: (count! [increment Nat] state self) - Nat - (let [state' (n.+ increment state)] - (async#in {try.#Success [state' state']}))) + (def: count! + (message (_ [increment Nat] state self) + Nat + (let [state' (n.+ increment state)] + (async#in {try.#Success [state' state']})))) ) (def: (mailed? outcome) @@ -164,7 +165,7 @@ (in (and (n.= 1 output_1) (n.= 2 output_2) (n.= 3 output_3))))] - (_.coverage' [/.Message /.actor: /.message: /.tell!] + (_.coverage' [/.Message /.message /.actor: /.tell!] (case result {try.#Success outcome} outcome -- cgit v1.2.3