From 9d5f050f521980b1ea87fc05f5316bf7b8514092 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 29 Sep 2020 20:01:07 -0400 Subject: node: Indentation and commenting fixes. --- starling/node.scm | 17 +++++++++-------- 1 file 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 ) . 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) -- cgit v1.2.3