[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#52749: G-expressions don't consistently preserve #nil
From: |
Maxime Devos |
Subject: |
bug#52749: G-expressions don't consistently preserve #nil |
Date: |
Thu, 23 Dec 2021 17:58:40 +0000 |
User-agent: |
Evolution 3.38.3-1 |
Philip McGrath schreef op wo 22-12-2021 om 23:25 [-0500]:
> G-expressions currently do not consistently preserve the distinction
> between #nil and '(), which causes trouble for programs that rely on
> that distinction. In particular, the issue affects programs that use
> (guix build json), because that library uses #nil to represent the JSON
> value `null', whereas it uses '() to represent an empty JSON array.
>
> The following program exposes the error:
> [
> ;...]
>
> ; This one fails!
> (check-equal? (gexp->json-string #~'(@ ("k" . #nil)))
> "{\"k\":null}"
> "gexp: null in object")
A simpler test:
Compare this:
(cdr (gexp->approximate-sexp #~("stuff" . #nil)))
; output: #nil --- seems like everything is ok?
with:
(gexp->approximate-sexp #~("stuff" . #nil))
; output: ("stuff") --- where did the #nil go?
I think the idea is that, if you construct a list (a b c . #nil)
in elisp, and pass it to Scheme, then Scheme should treat it as a
Scheme list, so it should be printed as (a b c) when using Scheme's
'write' or 'display'.
Greetings,
Maxime.