- (let ((behaviour (hash-table-ref/default actor-table id '())))
- (if (null? behaviour)
- (print "Warning: discarded message " message
- " to unknown actor id " id)
- (match (apply (hash-table-ref actor-table id) (cons address message))
- ('done (hash-table-delete! actor-table id))
- ('sleep 'do-nothing)
- (new-beh (hash-table-set! actor-table id new-beh)))))))
+ (log-trace "DELIVERING to " id ": " (->stringrep message))
+ (let loop ((beh (hash-table-ref/default actor-table id #f)))
+ (if beh
+ (condition-case
+ (match (apply (beh-proc beh) (cons address message))
+ ('done (hash-table-delete! actor-table id))
+ ('pass
+ (log-trace "Passing to parent behaviour...")
+ (loop (beh-parent beh)))
+ ((? beh? new-beh) (hash-table-set! actor-table id new-beh))
+ (else
+ 'do-nothing)) ; sleep is now the default
+ (o (exn)
+ (log-msg "Warning: actor " id " crashed evaluating message " (->stringrep message))
+ (print-error-message o)))
+ (log-msg "Warning: DISCARDING message to unknown actor " id ": " (->stringrep message))))))