From: Jean Abou Samra <jean@abou-samra.fr>
To: guile-user@gnu.org
Subject: Re: Inconsistencies with free-identifier=? and bound-identifier=?
Date: Fri, 21 Jul 2023 11:08:14 +0200 [thread overview]
Message-ID: <bdf55d612222a452502f48b963b6c32623eb2173.camel@abou-samra.fr> (raw)
In-Reply-To: <008f724d79b871ce1d68121402bbcbcdd25ec270.camel@abou-samra.fr>
[-- Attachment #1: Type: text/plain, Size: 2478 bytes --]
Relatedly, R6RS is clear that an identifier matches a literal
in a syntax-case clause iff they're free-identifier=?, but as
far as I can see, it does not clarify how the literals themselves
in the syntax-case clause are recognized, namely what predicate
is used to match them against the literals list of the syntax-case
expression.
Test program:
(define-syntax build-syntax
(syntax-rules ()
((_ expr expr* ...)
(let-syntax ((temp-macro (lambda (ignored-syntax)
expr expr* ...)))
(temp-macro)))))
(build-syntax
(with-syntax ((foo1 (let ((foo 'foo)) #'foo))
(foo2 (let ((foo 'foo)) #'foo)))
(with-syntax ((foo1-foo2-free=? (free-identifier=? #'foo1 #'foo2))
(foo1-foo2-bound=? (bound-identifier=? #'foo1 #'foo2)))
(syntax
(begin
(display "free-identifier=? ")
(display foo1-foo2-free=?)
(newline)
(display "bound-identifier=? ")
(display foo1-foo2-bound=?)
(newline)
(syntax-case #'not-foo (foo1)
(foo2
(display "Matched as literal\n"))
(_
(display "Not matched\n"))))))))
Guile 3.0:
free-identifier=? #f
bound-identifier=? #t
Matched as literal
Racket:
free-identifier=? #t
bound-identifier=? #t
Not matched
As you can see, foo1 and foo2 are *more* equal in Racket (also free-identifier=?
in addition to being bound-identifier=?), yet they don't match in Racket whereas
they do in Guile.
Chez Scheme gives the same identifier predicate results as Guile,
but it doesn't consider them matched:
free-identifier=? #f
bound-identifier=? #t
Not matched
Kawa somehow doesn't even handle the program:
free-identifier=? #t
bound-identifier=? #t
java.lang.NullPointerException: Cannot invoke
"kawa.lang.Translator.getCurrentSyntax()" because "tr" is null
at kawa.lang.SyntaxPattern.match(SyntaxPattern.java:604)
at kawa.lang.SyntaxPattern.match(SyntaxPattern.java:88)
at tmp2.run(tmp2.scm:6)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:290)
at gnu.expr.CompiledModule.evalModule(CompiledModule.java:42)
at gnu.expr.CompiledModule.evalModule(CompiledModule.java:60)
at kawa.Shell.runFile(Shell.java:571)
at kawa.Shell.runFileOrClass(Shell.java:474)
at kawa.repl.processArgs(repl.java:710)
at kawa.repl.main(repl.java:830)
free-identifier=? #f
bound-identifier=? #t
Not matched
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-07-21 9:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 0:20 Inconsistencies with free-identifier=? and bound-identifier=? Jean Abou Samra
2023-07-21 9:08 ` Jean Abou Samra [this message]
2023-07-27 18:28 ` Timothy Sample
2023-07-27 22:10 ` Timothy Sample
2023-07-28 10:08 ` Jean Abou Samra
2023-07-28 10:09 ` Jean Abou Samra
2023-07-29 4:37 ` Timothy Sample
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=bdf55d612222a452502f48b963b6c32623eb2173.camel@abou-samra.fr \
--to=jean@abou-samra.fr \
--cc=guile-user@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).