guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistencies with free-identifier=? and bound-identifier=?


From: Jean Abou Samra
Subject: Re: Inconsistencies with free-identifier=? and bound-identifier=?
Date: Fri, 21 Jul 2023 11:08:14 +0200
User-agent: Evolution 3.48.4 (3.48.4-1.fc38)

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: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]