unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Taylan Kammer <taylan.kammer@gmail.com>
To: 21915@debbugs.gnu.org
Subject: bug#21915: write inconsistent about #nil
Date: Fri, 14 May 2021 23:31:30 +0200	[thread overview]
Message-ID: <c9bc51f0-041e-1d3e-7703-ed90f97b99ce@gmail.com> (raw)
In-Reply-To: <b69985c6-3bfa-c853-023f-f7ac60236bca@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

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

[-- Attachment #2: 0001-Don-t-write-foo-.-nil-as-foo.patch --]
[-- Type: text/plain, Size: 1046 bytes --]

From 264b0f3eaead2e6460d32c6cd7f00868656ad891 Mon Sep 17 00:00:00 2001
From: Taylan Kammer <taylan.kammer@gmail.com>
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


      reply	other threads:[~2021-05-14 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-14  1:46 bug#21915: write inconsistent about #nil Zefram
2021-05-14 13:34 ` Taylan Kammer
2021-05-14 21:31   ` Taylan Kammer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9bc51f0-041e-1d3e-7703-ed90f97b99ce@gmail.com \
    --to=taylan.kammer@gmail.com \
    --cc=21915@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).