Subject: bug#21915: write inconsistent about #nil

From: Taylan Kammer <[email-masked]>
Date: Fri, 14 May 2021 23:31:30 +0200

On 14.05.2021 15:34, Taylan Kammer wrote:
> 
> It might also be good, in addition, to make the Scheme writer
> write (foo . #nil) as (foo . #nil).  The positive is that it
> would make bugs in Elisp compatibility easier to see by not
> masking the fact that one has #nil instead of () at the end
> of a list.  The only negative I can think of is that it would
> be mildly annoying to see (foo bar . #nil) where you expected
> to see (foo bar), but I don't think that's ever really harmful.
> 

FWIW here's a tiny patch that realizes this change.

- Taylan
From 264b0f3eaead2e6460d32c6cd7f00868656ad891 Mon Sep 17 00:00:00 2001
From: Taylan Kammer <[email-masked]>
Date: Fri, 14 May 2021 23:26:16 +0200
Subject: [PATCH] Don't write (foo . #nil) as (foo).

Elisp needs its own writer that produced output that will be understood
by Elisp's read.  Scheme's write shouldn't hide away a #nil terminating
a list, as this might make some bugs harder to find.

* libguile/print.c (scm_iprlist): Use scm_is_null_and_not_nil in place
of SCM_NULL_OR_NIL_P.
---
 libguile/print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libguile/print.c b/libguile/print.c
index b10f0f8a8..2bdf1760b 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -1018,7 +1018,7 @@ scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate)
       /* CHECK_INTS; */
       scm_iprin1 (SCM_CAR (exp), port, pstate);
     }
-  if (!SCM_NULL_OR_NIL_P (exp))
+  if (!scm_is_null_and_not_nil (exp))
     {
       scm_puts (" . ", port);
       scm_iprin1 (exp, port, pstate);
-- 
2.30.2