actors: Switch out address objects for more-easily-serialized cons cells
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 22 Apr 2016 14:34:57 +0000 (09:34 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 25 Apr 2016 14:25:36 +0000 (09:25 -0500)
This is maybe temporary.  If we ever have canonical sexps as the
general serialization format, or something like that, we might revert
to a nicer structure.

* 8sync/systems/actors.scm (<address>): Commented out.

8sync/systems/actors.scm

index 2d42897a03740c3be374473d192d9b463e289a71..0ae6e054c0c0eec3ea57f34f9d131f13efb0b023 100644 (file)
@@ -38,7 +38,9 @@
             actor-hive
             actor-message-handler
 
-            <address>
+            ;;; Commenting out the <address> type for now;
+            ;;; it may be back when we have better serializers
+            ;; <address>
             make-address address?
             address-actor-id address-hive-id
 
 ;;; =========================
 
 (define-class <actor> ()
-  ;; An <address> object
+  ;; An address object
   (id #:init-thunk (require-slot "id")
       #:init-keyword #:id
       #:getter actor-id)
 (define-method (actor-message-handler (actor <actor>))
   (slot-ref actor 'message-handler))
 
-(define-record-type <address>
-  (make-address actor-id hive-id)  ; @@: Do we want the trailing -id?
-  address?
-  (actor-id address-actor-id)
-  (hive-id address-hive-id))
-
-(set-record-type-printer!
- <address>
- (lambda (record port)
-   (format port "<address: ~s@~s>"
-           (address-actor-id record) (address-hive-id record))))
+;;; So these are the nicer representations of addresses.
+;;; However, they don't serialize so easily with scheme read/write, so we're
+;;; using the simpler cons cell version below for now.
+
+;; (define-record-type <address>
+;;   (make-address actor-id hive-id)  ; @@: Do we want the trailing -id?
+;;   address?
+;;   (actor-id address-actor-id)
+;;   (hive-id address-hive-id))
+;;
+;; (set-record-type-printer!
+;;  <address>
+;;  (lambda (record port)
+;;    (format port "<address: ~s@~s>"
+;;            (address-actor-id record) (address-hive-id record))))
+;;
+
+(define (make-address actor-id hive-id)
+  (cons actor-id hive-id))
+
+(define (address-actor-id address)
+  (car address))
+
+(define (address-hive-id address)
+  (cdr address))
 
 (define (address->string address)
   (string-append (address-actor-id address) "@"