#+TITLE: 029 / #100daystooffload Message In A Bottle
#+AUTHOR: screwtape
#+PROPERTY: header-args:lisp :session *lisp*
* This image carries on from day 028
So please run through day 028, including the ==(in-package
:clim-user)== slime-repl step.
* Try presenting *eg*
#+begin_src lisp :results output
  (present *eg*)
#+end_src

#+RESULTS:
: 1

Okay, it works (for me). Needing to manually ==(in-package
:clim-user)== in *slime-repl* is annoying.

* What is veilid, basically.
I guess there are several parts, but it's about sending a message
across some hops, transfering messages by hops from a source to a
sink. Parsing [[https://veilid.com/docs/private-routing/]]

Even though message is the name of the payload on that page, the
following PRESENT and ACCEPT seems strong enough for a broad spectrum
of communication.

** Message class exhibiting present and accept
#+name: message-class
#+begin_src lisp :results output
  (defclass message ()
   ((text :initarg :text :reader text-of)))

  (define-presentation-type message () :inherit-from '((form)))

  (define-presentation-method present
      (obj (type message) stream (view clim:textual-view) &key)
    (present (text-of obj) 'string :stream stream))

  (define-presentation-method accept
     ((type message) stream (view textual-view) &key)
    (let* ((string (read-token stream)))
     (make-instance 'message :text string)))

  (setq *msg-1* (make-instance 'message :text "Hello, world"))

  (Setq *msg-2*
	(with-input-from-string
	    (in (with-output-to-string (*standard-output*)
		  (present *msg-1*)))
	  (accept 'message :stream in)))

  (write (text-of *msg-2*))
#+end_src

#+RESULTS: message-class
: Hello, world

I guess this is kinda heavy, but it's a very general form of
string-based communication. I guess we must dodge the variety of
character encodings and insist upon 8 bit bytes. Anyway, we showed
clim interface friendly PRESENT and ACCEPT.

I did spend quite a bit of time in the REPL (so not doing append-only
orgmode) figuring things out that wouldn't have made sense to publish,
which I guess is a drawback of orgmode, but maybe that belies a
promising future.