Re: Keyword arguments in procedures specified in SRFIs shiro.kawai@xxxxxx 26 Jul 2019 14:20 UTC

Use write/ss.  Identical uninterned symbols are written out using SRFI-38 notation ( #n= and #n# ), so that the eq? identity is preserved when read back.

Sent from my iPhone

On Jul 24, 2019, at 2:11 AM, Lassi Kortela <xxxxxx@lassi.io> wrote:

>>    are there other differences
>>    between interned and uninterned symbols than comparing inequal
>> That's the sole purpose.  In the Scheme world it can be solved by hygienc macros.  However, if you want to dump the generated code and read it back, a symbol that guaranteed no name conflict comes handy.
>
> I think I misunderstand what you're saying. How do you write some code that uses gensyms, and then read it back while keeping multiple references to the same gensyms? I tried the following test in Gauche:
>
> (let* ((s (let ((port (open-output-string)))
>            (write (gensym) port)
>            (get-output-string port)))
>       (g1 (read (open-input-string s)))
>       (g2 (read (open-input-string s))))
>  (list s
>        g1
>        g2
>        (eq? g1 g1)
>        (eq? g2 g2)
>        (eq? g1 g2)))
> ;; => ("#:G100" #:G100 #:G100 #t #t #f)
>
> (let* ((s (let ((port (open-output-string)))
>            (let ((g (gensym)))
>              (write (cons g g) port))
>            (get-output-string port)))
>       (gs (read (open-input-string s))))
>  (list s
>        gs
>        (eq? (car gs) (cdr gs))))
> ;; => ("(#:G101 . #:G101)" (#:G101 . #:G101) #f)
>
> According to these tests, an uninterned symbol read from a port is never equal to another uninterned symbol with the same name, even if the references are embedded in the same data structure (here, a cons cell).