[CM] (sub)environments and object->string with :readable

Christos Vagias chris.actondev at gmail.com
Thu Jul 30 02:32:49 PDT 2020


Hi Bil,

Indeed it works, but the output of :readable grows out of hand.
Here is a snippet. Imagine if there were way more definitions (and nested
"sub-namespaces")

(define *lib*
  (let ()
    (curlet)))

(with-let *lib*
 (define (make-state)
   (let ((a '(1 2 3)))
     (curlet)))

 (define make-state-2
   (let ((+documentation+ "Makes some state with b"))
     (lambda ()
(let ((b '(1 2 3)))
 (curlet))))))

(define state ((*lib* 'make-state)))

(object->string state)
;; => (inlet 'a (1 2 3))
;; perfect, but not eval'able

(object->string state :readable)

;; =>
;; (sublet (sublet (sublet (inlet :make-state (lambda () (let ((a '(1 2
3))) (curlet))) :make-state-2 (let ((+documentation+ \"Makes some state
with b\")) (lambda () (let ((b '(1 2 3))) (curlet))))))) :a (list 1 2 3))

So the :readable version essentially gives me essentially the source of
*lib*..
Also, I realize now that in my application the problem that I faced was the
"format ~W.." output was trimmed because it was too long.

>From one hand indeed it works as expected (creating a complete definition).
But on the other hand this is unusable for saving state. (imagine storing
all of this in some database for example.. it's mostly noise)

For now actually my problem is solved, since I'm defining the state in the
rootlet, but this thing bugs me.

On Thu, 30 Jul 2020 at 02:19, <bil at ccrma.stanford.edu> wrote:

> The previous example would have worked; I thought
> you were unhappy that it was not simple, but it is
> intended for s7's use.  object->string with :readable
> and format with ~W are the built-in ways to serialize
> most s7 objects.
>
> (The complexity of the previous example came from s7's
> attempt to preserve the outlet chain, but the outer
> let refers back to the inner one -- a circular reference).
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200730/79d082cd/attachment.html>


More information about the Cmdist mailing list