(define-syntax make-beh
(syntax-rules (: => finally)
((make-beh : parent (self) (pat => body ...) ... (finally after ...))
- (cons (lambda (self . message)
+ (list 'beh
+ (lambda (self . message)
(match message
(pat body ...)
...
;; (See also macros defined in sam-macros.scm.)
(define (beh-proc beh)
- (car beh))
+ (cadr beh))
(define (beh-parent beh)
- (cdr beh))
+ (caddr beh))
(define root-beh
(make-beh : #f (self)
(('ping recipient) =>
(send-message recipient 'pong))))
+(define (beh? x)
+ (and (pair? x)
+ (not (null? x))
+ (eq? (car x) 'beh)))
+
;; Actors
(define (make-address host port id)
('pass
(log-trace "Passing to parent behaviour...")
(loop (beh-parent beh)))
- ((? procedure? new-beh) (hash-table-set! actor-table id new-beh))
+ ((? beh? new-beh) (hash-table-set! actor-table id new-beh))
(else
'do-nothing)) ; sleep is now the default
(o (exn)
(define-beh system-beh
(self)
+
(('shutdown) =>
(log-msg "System actor received shutdown message.")
(exit 0)