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: Timothy Sample
Subject: Re: Inconsistencies with free-identifier=? and bound-identifier=?
Date: Thu, 27 Jul 2023 12:28:21 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi Jean,

Jean Abou Samra <jean@abou-samra.fr> writes:

> Consider the following test program.
>
> (define-syntax foo-test
>   (lambda (sintax)
>     (let ((foo1 (let ((foo 'bar))
>                   (syntax foo)))
>           (foo2 (let ((foo 'bar))
>                   (syntax foo))))
>       (display "free-identifier=? ")
>       (display (free-identifier=? foo1 foo2))
>       (newline)
>       (display "bound-identifier=? ")
>       (display (bound-identifier=? foo1 foo2))
>       (newline)
>       (with-syntax ((foo1 foo1) (foo2 foo2))
>         (syntax
>           (let ((foo2 'not-shadowed))
>             (let ((foo1 'shadowed))
>               (display foo2) (newline))))))))
> (foo-test)

FWIW, I tried this in my own pet expander, and got the following:

    free-identifier=? #f
    bound-identifier=? #f
    not-shadowed

It’s a very simple expander that uses sets-of-scopes for hygiene.  As
such, they are not ‘bound-identifier=?’ since they can be distinguished
by the two different scopes introduced by the different invocations of
‘let’.  For ‘free-identifier=?’, they each resolve to different bindings
to the value ‘'bar’, so that’s a “no”.

Ultimately, I don’t think you can ask “who’s right?”  These predicates
answer questions about how a given expander distinguishes identifiers.
If two expanders distinguish identifiers differently, they should give
different answers!  However, I do agree that ‘bound-identifier=?’ should
imply ‘free-identifier=?’, so I don’t know what’s going on with Guile
and Chez.  (AIUI, their expanders are both based on psyntax, so I guess
it makes sense that they are similar.)  Also, Kawa is obviously wrong –
‘bound-identifier=?’ must imply “shadowed”.

May I ask why you are exploring this?  It’s quite arcane!

You could try and get in touch with Marc Nieper-Wißkirchen, the author
SRFI 211 (Scheme Macro Libraries) and Unsyntax
(https://gitlab.com/nieper/unsyntax).  Both of those projects suggest a
pretty thoroughgoing knowledge of Scheme macros.  I think Marc also
worked on getting ‘syntax-case’ into Chibi Scheme.

Lastly, you should read section 3.1 of “Binding as Sets of Scopes”:

    
https://www-old.cs.utah.edu/plt/scope-sets/general-macros.html#%28part._.Identifier_.Comparisons_with_.Scope_.Sets%29

It shows that ‘bound-identifier=?’ gives false negatives in both
sets-of-scopes and marks-and-substitutions hygiene systems.  (I didn’t

test that example or anything, but I thought it fit the theme of
identifier predicate arcana pretty well.)


-- Tim



reply via email to

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