Re: apparent bug in sample implementation of SRFI 148 William D Clinger (20 Jul 2017 08:23 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (21 Jul 2017 12:41 UTC)
Re: apparent bug in sample implementation of SRFI 148 William D Clinger (21 Jul 2017 18:55 UTC)
Re: apparent bug in sample implementation of SRFI 148 John Cowan (22 Jul 2017 00:14 UTC)
Re: apparent bug in sample implementation of SRFI 148 William D Clinger (22 Jul 2017 00:54 UTC)
Re: apparent bug in sample implementation of SRFI 148 John Cowan (22 Jul 2017 04:46 UTC)
Re: apparent bug in sample implementation of SRFI 148 William D Clinger (22 Jul 2017 07:45 UTC)
Re: apparent bug in sample implementation of SRFI 148 Alex Shinn (22 Jul 2017 07:17 UTC)
Re: apparent bug in sample implementation of SRFI 148 William D Clinger (22 Jul 2017 08:06 UTC)
Re: apparent bug in sample implementation of SRFI 148 Alex Shinn (22 Jul 2017 08:48 UTC)
Re: apparent bug in sample implementation of SRFI 148 Arthur A. Gleckler (22 Jul 2017 15:01 UTC)
Re: apparent bug in sample implementation of SRFI 148 Arthur A. Gleckler (24 Jul 2017 05:57 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (22 Jul 2017 09:13 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (22 Jul 2017 11:16 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (23 Jul 2017 11:18 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (23 Jul 2017 13:34 UTC)
Re: apparent bug in sample implementation of SRFI 148 Alex Shinn (24 Jul 2017 03:23 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (24 Jul 2017 03:46 UTC)
Re: apparent bug in sample implementation of SRFI 148 Al Petrofsky (24 Jul 2017 03:41 UTC)
Re: apparent bug in sample implementation of SRFI 148 William D Clinger (25 Jul 2017 00:33 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (25 Jul 2017 05:24 UTC)
Re: apparent bug in sample implementation of SRFI 148 Alex Shinn (27 Jul 2017 04:37 UTC)
Re: apparent bug in sample implementation of SRFI 148 William D Clinger (27 Jul 2017 11:57 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (24 Jul 2017 03:26 UTC)
Re: apparent bug in sample implementation of SRFI 148 Marc Nieper-Wißkirchen (24 Jul 2017 06:19 UTC)

Re: apparent bug in sample implementation of SRFI 148 William D Clinger 20 Jul 2017 08:23 UTC

Thanks to Marc, Al, and Takashi, we have figured out what is wrong
with the current sample implementations of SRFI 147 and SRFI 148.

The short answer is that they work in systems that use something
akin to free-identifier=? when determining whether an identifier
is a pattern variable or a literal, but don't work in systems
that use something akin to bound-variable=? for that decision.

To put it less technically, the sample implementations work only
in macro systems that are (intuitively) less hygienic than those
used by R6RS systems such as Chez, Petite Chez, Racket, Vicare,
Larceny, and the -r6 mode of Sagittarius.

Alfalfa Petrofsky wrote:

> I agree with Will that bound-identifier=? is the better comparison,
> and that's the way I implemented it in Alexpander and Eiod.  The
> literals list is logically a binding construct: it declares that some
> identifiers will have a different meaning within the scope of the
> declaration.  It should therefore follow the hygienic rules for
> bindings.
>
> I also agree that none of the RnRS specify the answer.  It's made
> clear that free-identifier=? is to be used for comparing the
> identifier in the macro use with the identifier in the pattern, but
> that's a different comparison from the one we're talking about
> (between the identifier in the pattern and the one in the literals
> list).

Because the relevant standards do not specify this detail of
macro processing, programs that depend upon the less hygienic
behavior are not portable.  That's why the sample implementations
of SRFI 147 and 148 work in some systems but not in others.

I have repaired the sample implementation of SRFI 147 by changing
it to use the string ":continuation" instead of the identifier
:continuation.  That kind of change is not quite trivial, because
you have to

    change :continuation to ":continuation" in patterns,
    delete :continuation from literals lists,
    which implies deleting :continuation from templates that are
        inserting it into what will eventually become a literals
        list,
    while changing :continuation to ":continuation" in templates
        that are inserting it so it can be recognized as a flag
        by subsequent macro processing.

Distinguishing between those last two situations requires knowledge
of the intended use of the identifier being inserted, so I leave it
for Marc to repair the sample implementation of SRFI 148, following
the example of SRFI 147 whose repair diff is here:

https://github.com/larcenists/larceny/commit/d033e7e6d9240d606ee7f5246583fc174fba2b07

With that repair to SRFI 147, the sample implementation of SRFI 148
still fails to be portable, but it is now failing only because it
uses the same non-portable technique for recognizing flags such as
quote, quasiquote, :prepare, :call, em-cut, em-cute, and possibly
a few other things such as ... and =>.  In particular, one of the
renamed quote identifiers ends up as a pattern variable (in the
more hygienic macro systems), leading to an error when the macro
system detects multiple occurrences of that pattern variable
within a pattern.

Will