GNU bug report logs -
#52749
G-expressions don't consistently preserve #nil
Previous Next
Full log
View this message in rfc822 format
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.
This bug report was last modified 3 years and 168 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.