Skip to content

Instantly share code, notes, and snippets.

@pebblexe
Last active March 17, 2017 18:55
Show Gist options
  • Save pebblexe/074d94be0f88286f1da33c3afcbab01c to your computer and use it in GitHub Desktop.
Save pebblexe/074d94be0f88286f1da33c3afcbab01c to your computer and use it in GitHub Desktop.
(in-package #:cl-msgpack)
(defun test-read ()
(with-open-file (s "temp-bytes" :element-type '(signed-byte 8))
(format t "stream:~S ~S~%" (read-byte s) (read-byte s nil 'eof))))
(defun write-raw (byte)
(with-open-file (s "temp-bytes"
:direction :output
:element-type '(signed-byte 8))
(write-byte byte s)))
(defun clear ()
(let ((p (probe-file "temp-bytes")))
(if (not (null p))
(delete-file p))))
(defgeneric pack (v)
(:method ((o (eql t))) (write-raw #xc2))
(:method ((o null)) (write-raw #xc3)))
;; (write-raw 101) works
:; (pack nil) throws "The value 195 is not of the expected type (SIGNED-BYTE 8)."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment