summaryrefslogtreecommitdiff
path: root/starling/node.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2020-09-29 20:01:07 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2020-09-29 20:04:20 -0400
commit9d5f050f521980b1ea87fc05f5316bf7b8514092 (patch)
tree7bdb0c5942a7660259088ae58f6080133fd142ed /starling/node.scm
parentf4e7322d392242898bddeccde0601e63af5ca737 (diff)
node: Indentation and commenting fixes.
Diffstat (limited to 'starling/node.scm')
-rw-r--r--starling/node.scm17
1 files changed, 9 insertions, 8 deletions
diff --git a/starling/node.scm b/starling/node.scm
index 38b75da..2982e31 100644
--- a/starling/node.scm
+++ b/starling/node.scm
@@ -68,7 +68,7 @@
;; The node that this node is attached to. A node may only have one
;; parent.
(parent #:accessor parent #:init-form #f)
- ;; List of children ordered by rank.
+ ;; List of children, sorted by rank.
(children #:accessor children #:init-form '())
;; Children indexed by name for fast lookup.
(children-by-name #:getter children-by-name #:init-thunk make-hash-table)
@@ -215,7 +215,7 @@ represented as a ratio in the range [0, 1]."
#t)
(define-method (attach-to (new-parent <node>) . new-children)
- "Attach NEW-CHILDREN to NEW-PARENT."
+ "Attach NEW-CHILDREN to NEW-PARENT."
;; Validate all children first. The whole operation will fail if
;; any of them cannot be attached.
(for-each (lambda (child)
@@ -224,14 +224,14 @@ represented as a ratio in the range [0, 1]."
(when (child-ref new-parent (name child))
(error "node name taken:" (name child))))
new-children)
- ;; Adopt the children and sort them by their rank so that
+ ;; Add the new children and sort them by their rank so that
;; updating/rendering happens in the desired order.
(set! (children new-parent)
- (sort (append new-children (children new-parent))
- (lambda (a b)
- (< (rank a) (rank b)))))
- ;; Mark the children as having parents and add them to the name
- ;; index for quick lookup later.
+ (sort (append new-children (children new-parent))
+ (lambda (a b)
+ (< (rank a) (rank b)))))
+ ;; Mark the children as having parents and add them to the rank and
+ ;; name indexes for quick lookup later.
(for-each (lambda (child)
(set! (parent child) new-parent)
;; Add to name index.
@@ -251,6 +251,7 @@ represented as a ratio in the range [0, 1]."
"Detach NODE from its parent."
(let ((p (parent node)))
(when p
+ ;; Remove child from parent.
(set! (children p) (delq node (children p)))
;; Remove from name index.
(when (name node)