From a0e0735ebf3f184b4f105cad1af5757ecd08e2e4 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Thu, 10 Aug 2017 16:56:43 -0500 Subject: [PATCH] Allow sending messages to put to-actor as an actual actor instance. This reduces a common error and also allows for cleaner code when an actor wants to send a message to itself. * 8sync/actors.scm (%<-): Allow sending messages to put to-actor as an actual actor instance. --- 8sync/actors.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/8sync/actors.scm b/8sync/actors.scm index fc8afca..6d17e05 100644 --- a/8sync/actors.scm +++ b/8sync/actors.scm @@ -156,7 +156,7 @@ ;; This is the internal, generalized message sending method. ;; Users shouldn't use it! Use the <-foo forms instead. -(define-inlinable (%<- wants-reply from-actor to action args message-id in-reply-to) +(define (%<- wants-reply from-actor to action args message-id in-reply-to) ;; Okay, we need to deal with message ids. ;; Could we get rid of them? :\ ;; It seems if we can use eq? and have messages be immutable then @@ -180,7 +180,13 @@ 'TODO) ;; A message sent to nobody goes nowhere. ;; TODO: Should we display a warning here, probably? - (#f #f))) + (#f #f) + ;; We shouldn't technically be passing in actors but rather their + ;; addresses, but often actors want to message themselves and + ;; this makes that slightly easier. + ((? (lambda (x) (is-a? x )) actor) + (%<- wants-reply from-actor (actor-id actor) action + args message-id in-reply-to)))) (define (<- to action . args) (define from-actor (*current-actor*)) -- 2.31.1