From: Christopher Allan Webber Date: Tue, 26 Apr 2016 21:07:12 +0000 (-0500) Subject: actors: Switch hive-create-actor[*] to match create-actor[*] X-Git-Tag: v0.2.0~27 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=5985528115e276d273a6a4bb1df57c93cab61f84;p=8sync.git actors: Switch hive-create-actor[*] to match create-actor[*] * 8sync/systems/actors.scm (hive-create-actor, hive-create-actor*): Adjust syntax to match that of create-actor and create-actor*. * demos/actors/botherbotherbother.scm (main): * tests/test-actors.scm: Adjust to use. --- diff --git a/8sync/systems/actors.scm b/8sync/systems/actors.scm index f6da0bd..119f8a4 100644 --- a/8sync/systems/actors.scm +++ b/8sync/systems/actors.scm @@ -560,25 +560,13 @@ that method for documentation." ;; return the actor id actor-id)) -(define* (hive-create-actor hive actor-class - #:key - (init '()) - id-cookie) +(define* (hive-create-actor hive actor-class #:rest init) (%hive-create-actor hive actor-class - init id-cookie)) - -(define-syntax hive-create-actor* - (syntax-rules () - "Create an instance of actor-class attached to this hive. -Return the new actor's id. + init #f)) -Used internally, and used for bootstrapping a fresh hive. - -Note that actors should generally not call this method directly. -Instead, actors should call create-actor." - ((_ args ... (init-args ...)) - (hive-create-actor args ... - #:init (list init-args ...))))) +(define* (hive-create-actor* hive actor-class id-cookie #:rest init) + (%hive-create-actor hive actor-class + init id-cookie)) ;; TODO: Give actors this instead of the actual hive reference diff --git a/demos/actors/botherbotherbother.scm b/demos/actors/botherbotherbother.scm index 5a43a8b..5f294fd 100755 --- a/demos/actors/botherbotherbother.scm +++ b/demos/actors/botherbotherbother.scm @@ -115,13 +115,14 @@ (define (main . args) (define agenda (make-agenda)) (define hive (make-hive)) - (define professor (hive-create-actor hive )) + (define professor (hive-create-actor* hive "prof")) (define namegen (student-name-generator)) (define students (map (lambda _ - (hive-create-actor* hive - (#:name (namegen)))) + (let ((name (namegen))) + (hive-create-actor* hive name + #:name name))) (iota num-students))) ;; Bootstrap each student into bothering-professor mode. diff --git a/tests/test-actors.scm b/tests/test-actors.scm index 2b5298c..15191c4 100644 --- a/tests/test-actors.scm +++ b/tests/test-actors.scm @@ -126,12 +126,9 @@ (~display "lazy-rep> I'm not answering that.\n"))) (let* ((hive (make-hive)) - (customer (hive-create-actor hive - #:id-cookie "antsy-caller")) - (diligent-rep (hive-create-actor hive - #:id-cookie "diligent-rep")) - (lazy-rep (hive-create-actor hive - #:id-cookie "lazy-rep"))) + (customer (hive-create-actor* hive "antsy-caller")) + (diligent-rep (hive-create-actor* hive "diligent-rep")) + (lazy-rep (hive-create-actor* hive "lazy-rep"))) ;; * Playing a tape of a diligent service rep * (parameterize ((%record-out (open-output-string))) (let* ((result (ez-run-hive