From: Christopher Allan Webber Date: Mon, 2 May 2016 15:55:15 +0000 (-0500) Subject: actors: Add with-message-args and build mlambda off it. X-Git-Tag: v0.2.0~11 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d3202269c645127c176cad41185fa0f95be34d89;p=8sync.git actors: Add with-message-args and build mlambda off it. * 8sync/systems/actors (with-message-args): New macro. (mlambda): Retool to use with-message-args as base. --- diff --git a/8sync/systems/actors.scm b/8sync/systems/actors.scm index a503313..270b25f 100644 --- a/8sync/systems/actors.scm +++ b/8sync/systems/actors.scm @@ -316,6 +316,12 @@ If key not found and DFLT not provided, throw an error." ;;; Actor utilities ;;; =============== + +(define-syntax-rule (with-message-args (message message-arg ...) + body body* ...) + (let ((message-arg (message-ref message (quote message-arg))) ...) + body body* ...)) + (define-syntax mlambda (syntax-rules () "A lambda for building message handlers. @@ -331,8 +337,7 @@ Which is like doing manually: ((_ (actor message message-arg ...) body body* ...) (lambda (actor message) - (let ((message-arg (message-ref message (quote message-arg))) ...) - body body* ...))))) + (with-message-args (message message-arg ...) body body* ...))))) ;; @@: Sadly, docstrings won't work with this... ;; I think we need to bust out syntax-case to make that happen...