From 41c159b28d0ee797416b3bf249681601d04b4af8 Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Sat, 2 Dec 2023 16:29:42 -0800 Subject: [PATCH 1/2] Allow for multiple couriers in blossom-let macro --- tests/node.lisp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/node.lisp b/tests/node.lisp index f27a327..65d0a92 100644 --- a/tests/node.lisp +++ b/tests/node.lisp @@ -180,7 +180,13 @@ Finally, all of the nodes constructed by this BLOSSOM-LET are stashed in the pla (let (addresses augmented-node-definitions) ;; precompute addresses for the nodes (loop :for (symbol-name . rest) :in node-definitions + ;; if the node arguments include :process-courier, use the provided + ;; courier instance when pre-registering the address for this node + :for courier-idx := (position ':process-courier rest) + :for courier := (when courier-idx (nth (1+ courier-idx) rest)) + :for courier-clause := (when courier `(:courier ,courier)) :collect `(,symbol-name (register + ,@courier-clause :channel ',(gensym (format nil "TEST-BLOSSOM-~A" symbol-name)))) @@ -198,7 +204,8 @@ Finally, all of the nodes constructed by this BLOSSOM-LET are stashed in the pla :process-key ,symbol-name ,@chopped-args ,@global-options - :debug? t)) :into result + :debug? t)) + :into result :finally (setf augmented-node-definitions result)) `(let ,addresses (declare (ignorable ,@(mapcar #'first node-definitions))) From 93e1d79089ddc3ee5087b45b0586c1433a3826ba Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 2 Dec 2023 16:59:59 -0800 Subject: [PATCH 2/2] Combine the loops --- tests/node.lisp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/node.lisp b/tests/node.lisp index 65d0a92..205d371 100644 --- a/tests/node.lisp +++ b/tests/node.lisp @@ -178,12 +178,17 @@ where NODE-CLASS is replaced by OPTIONAL-NODE-CLASS if supplied or by BLOSSOM-NO Finally, all of the nodes constructed by this BLOSSOM-LET are stashed in the place indicated by TREE-NAME. This is convenient for use with `TREE-EQUALP' and with `SIMULATE-ADD-TREE'." (let (addresses augmented-node-definitions) - ;; precompute addresses for the nodes (loop :for (symbol-name . rest) :in node-definitions + :for class-name := (if (keywordp (first rest)) + 'blossom-node + (first rest)) + :for chopped-args := (if (keywordp (first rest)) + rest + (rest rest)) + ;; precompute addresses for the nodes. ;; if the node arguments include :process-courier, use the provided ;; courier instance when pre-registering the address for this node - :for courier-idx := (position ':process-courier rest) - :for courier := (when courier-idx (nth (1+ courier-idx) rest)) + :for courier := (getf chopped-args :process-courier) :for courier-clause := (when courier `(:courier ,courier)) :collect `(,symbol-name (register ,@courier-clause @@ -191,22 +196,15 @@ Finally, all of the nodes constructed by this BLOSSOM-LET are stashed in the pla (format nil "TEST-BLOSSOM-~A" symbol-name)))) :into addresses-result - :finally (setf addresses addresses-result)) - ;; process node-definition symbols into addresses - (loop :for (symbol-name . initargs) :in node-definitions - :for class-name := (if (keywordp (first initargs)) - 'blossom-node - (first initargs)) - :for chopped-args := (if (keywordp (first initargs)) - initargs - (rest initargs)) + ;; then, set up definitions from clauses :collect `(,symbol-name (spawn-process ',class-name :process-key ,symbol-name ,@chopped-args ,@global-options :debug? t)) - :into result - :finally (setf augmented-node-definitions result)) + :into definitions-result + :finally (setf addresses addresses-result + augmented-node-definitions definitions-result)) `(let ,addresses (declare (ignorable ,@(mapcar #'first node-definitions))) (let ,augmented-node-definitions