;;;; remote-mailbox-packet.scm ;;;; Kon Lovett, Sep '17 ;; Issues;; ;; - struct vs vector (module remote-mailbox-packet (;export make-remote-mailbox-packet remote-mailbox-packet? remote-mailbox-packet-key remote-mailbox-packet-value ) (import scheme (chicken base) (chicken fixnum) (chicken type)) (define-type mailbox-packet-id fixnum) (define-type mailbox-packet (vector mailbox-packet-id * *)) (: make-remote-mailbox-packet (symbol * -> mailbox-packet)) (: remote-mailbox-packet? (* -> boolean : mailbox-packet)) (: remote-mailbox-packet-key (mailbox-packet -> symbol)) (: remote-mailbox-packet-value (mailbox-packet -> *)) ;;; Remote Mailbox Packet (define-constant REMOTE-MAILBOX-TAG most-positive-fixnum) (define (make-remote-mailbox-packet key val) (vector REMOTE-MAILBOX-TAG key val) ) (define (remote-mailbox-packet? obj) (and (vector? obj) (= 3 (vector-length obj)) (eq? REMOTE-MAILBOX-TAG (vector-ref obj 0))) ) (define (remote-mailbox-packet-key rmp) (vector-ref rmp 1)) (define (remote-mailbox-packet-value rmp) (vector-ref rmp 2)) ) ;module remote-mailbox-packet