aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lux-mode/lux-mode.el3
-rw-r--r--stdlib/source/documentation/lux/control/concurrency/actor.lux29
-rw-r--r--stdlib/source/library/lux/control/concurrency/actor.lux41
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux6
-rw-r--r--stdlib/source/test/lux/control/concurrency/actor.lux13
5 files changed, 48 insertions, 44 deletions
diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el
index 0581193ef..62bcb2fad 100644
--- a/lux-mode/lux-mode.el
+++ b/lux-mode/lux-mode.el
@@ -389,7 +389,7 @@ Called by `imenu--generic-function'."
(code//super-quotation (altRE "``" "~~"))
(code//template (altRE "with_template" "template"))
;; Miscellaneous
- (actor (altRE "actor:" "message:" "actor"))
+ (actor (altRE "actor:" "message" "actor"))
(jvm-host (altRE "import" "export" "class:" "interface:" "object" "do_to" "synchronized" "class_for"))
(alternative-format (altRE "char" "bin" "oct" "hex"))
(documentation (altRE "comment" "documentation:"))
@@ -585,6 +585,7 @@ This function also returns nil meaning don't specify the indentation."
("macro" 'defun)
("syntax" 'defun)
("template" 'defun)
+ ("message" 'defun)
("analysis" 'defun)
("synthesis" 'defun)
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 <code>.symbol (at <>.monad in (list)))))
(def: messageP
- (Parser [Code Signature Code Code])
- (|export|.parser
- (all <>.and
- ..signature^
- <code>.any
- <code>.any)))
+ (Parser [Signature Code Code])
+ (all <>.and
+ ..signature^
+ <code>.any
+ <code>.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 [<consume_1> (these where (!++ offset/0) source_code)
<move_1> (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