From: Maxime Devos <maximedevos@telenet.be>
To: 48318@debbugs.gnu.org
Subject: bug#48318: (ice-9 match) does not allow distinguishing between () and #nil
Date: Sun, 09 May 2021 18:42:40 +0200 [thread overview]
Message-ID: <4c8839f49a6c7317324d5360d74594c181b0588b.camel@telenet.be> (raw)
[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]
Hi guilers,
I've found the following surprising behaviour:
(use-modules (ice-9 match))
(match (identity #nil) (() 'scheme-eol) (#nil 'elisp-eol))
--> scheme-eol, expected elisp-eol
(match '() (#nil 'elisp-eol) (() 'elisp-eol))
--> elisp-eol, expected scheme-eol
Treating () and #nil as equivalent makes sense, but should be
documented.
My suspicion, currently untested: the following code in
ice-9/match.upstream.scm ...
(define-syntax match-two
(syntax-rules (_ ___ ..1 *** quote quasiquote ? $ = and or not set! get!)
((match-two v () g+s (sk ...) fk i)
(if (null? v) (sk ... i) fk))
[..]
should be:
(define-syntax match-two
(syntax-rules (_ ___ ..1 *** quote quasiquote ? $ = and or not set! get!)
((match-two v () g+s (sk ...) fk i)
(if (eq? v '()) (sk ... i) fk))
((match-two v #nil g+s
(sk ...) fk i)
(if (eq? v #nil) (sk ... i) fk))
[...]
And the following might need similar adjustment:
((match-two v (p) g+s sk fk i)
(if (and (pair? v) (null? (cdr v)))
(let ((w (car v)))
(match-one w p ((car v) (set-car! v)) sk fk i))
fk))
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next reply other threads:[~2021-05-09 16:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 16:42 Maxime Devos [this message]
2021-05-13 19:14 ` bug#48318: (ice-9 match) does not allow distinguishing between () and #nil Taylan Kammer
2021-05-13 20:39 ` Maxime Devos
2021-05-13 21:21 ` Taylan Kammer
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=4c8839f49a6c7317324d5360d74594c181b0588b.camel@telenet.be \
--to=maximedevos@telenet.be \
--cc=48318@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).