From: Matt Birkholz <matt@birchwood-abbey.net>
Date: Mon, 28 Aug 2017 18:27:54 +0000 (-0700)
Subject: planetarium (make-tellurion): Name thread; return the object(!).
X-Git-Tag: mit-scheme-pucked-9.2.12~83
X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=8dd2abd8d4b1624effc7b41081309775501d7ca9;p=mit-scheme.git

planetarium (make-tellurion): Name thread; return the object(!).
---

diff --git a/src/planetarium/tellurion.scm b/src/planetarium/tellurion.scm
index a8beb442e..2441b9a18 100644
--- a/src/planetarium/tellurion.scm
+++ b/src/planetarium/tellurion.scm
@@ -22,33 +22,40 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 |#
 
 (define (make-tellurion)
-  (let ((queue (make-thread-queue)))
-    (define (queue! command . args)
-      (thread-queue/queue! queue (cons command args))
-      unspecific)
-    (detach-thread (create-thread #f (lambda () (run-tellurion queue))))
-    (lambda (keyword . args)
-      (cond ((eq? keyword 'TURN-TO)
-	     (let ((lat (->flonum (car args)))
-		   (long (->flonum (cadr args))))
-	       (if (or (< lat -90) (< 90 lat))
-		   (error "Invalid latitude:" lat))
-	       (if (or (< long -180) (< 180 long))
-		   (error "Invalid longitude:" long))
-	       (queue! 'turn-to lat long)))
-	    ((eq? keyword 'TIME-TO)
-	     (queue! 'time-to (->time (car args))))
-	    ((eq? keyword 'HOUR-TO)
-	     (let ((hour (car args)))
-	       (guarantee integer? hour 'hour-to)
-	       (if (or (< hour 0) (< 23 hour))
-		   (error "Invalid hour:" hour))
-	       (queue! 'hour-to hour)))
-	    ((eq? keyword 'STOP)
-	     (queue! queue 'stop))
-	    ((eq? keyword 'GO)
-	     (queue! queue 'go))
-	    (else (error "unknown command:" keyword args))))))
+
+  (define queue (make-thread-queue))
+
+  (define (queue! command . args)
+    (thread-queue/queue! queue (cons command args))
+    unspecific)
+
+  (define (tellurion command . args)
+    (cond ((eq? command 'TURN-TO)
+	   (let ((lat (->flonum (car args)))
+		 (long (->flonum (cadr args))))
+	     (if (or (< lat -90) (< 90 lat))
+		 (error "Invalid latitude:" lat))
+	     (if (or (< long -180) (< 180 long))
+		 (error "Invalid longitude:" long))
+	     (queue! 'turn-to lat long)))
+	  ((eq? command 'TIME-TO)
+	   (queue! 'time-to (->time (car args))))
+	  ((eq? command 'HOUR-TO)
+	   (let ((hour (car args)))
+	     (guarantee integer? hour 'hour-to)
+	     (if (or (< hour 0) (< 23 hour))
+		 (error "Invalid hour:" hour))
+	     (queue! 'hour-to hour)))
+	  ((eq? command 'STOP)
+	   (queue! queue 'stop))
+	  ((eq? command 'GO)
+	   (queue! queue 'go))
+	  (else (error "unknown command:" command args))))
+
+  (detach-thread (create-thread #f
+		   (lambda () (run-tellurion queue))
+		   tellurion))
+  tellurion)
 
 (define (->time object)
   (cond ((eq? object 'current)