Subject: Re: bug#52749: G-expressions don't consistently preserve #nil

From: Maxime Devos <[email-masked]>
Date: Sat, 25 Dec 2021 12:13:07 +0100

Maxime Devos schreef op do 23-12-2021 om 06:59 [+0000]:
> 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 constant #nil is only for elisp compatibility and not something
> supposed to be used in Scheme code that isn't for Scheme/elisp
> compatibility, so this seems more a bug in (guix build json) to me.

That said, it would be less surprising if the #nil/() distinction is
preserved by gexp->derivation and friends. This can be done by writing
our own 'write' procedure. Downside: it might be less efficient than
Guile's write which is implemented in C. Can be resolved by writing our
own 'write' procedure in C.

Greetings,
Maxime.