Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

shadowing syntatic keywords, bug in MIT Scheme?

7 views
Skip to first unread message

Brian M. Moore; esq.

unread,
Mar 11, 1998, 3:00:00 AM3/11/98
to

Okay, I've been wondering this for some time, and I've decided
that now's the time to ask.

Why do R4RS and R5RS insist that syntatic keywords cannot be
shadowed?

I can imagine the following two programs, which seem quite
reasonable:

((lambda lambda lambda) 'x)
((lambda (begin) (begin 1 2 3)) (lambda lambda lambda))

but R4RS and R5RS tells me these programs are illegal. Neither
MIT Scheme nor Chez Scheme signal an error at these programs, and
MIT Scheme returns the (x) for the first problem, and 3 for the
second. (!) Chez Scheme returns (x) for the first problem and
(1 2 3) for the second. This seems like a bug in MIT Scheme.

So my original question stands, and I also wonder if someone can
provide me with a program that clearly shows why syntatic
keywords are not shadowable.


--
--Brian

+--------------------------------------------------------------+
| Brian M. Moore programmer/consultant |
| moo...@ukans.edu University of Kansas |
| http://www.ukans.edu/home/mooreb |
+--------------------------------------------------------------+

William D Clinger

unread,
Mar 11, 1998, 3:00:00 AM3/11/98
to Brian M. Moore; esq.

moo...@lark.cc.ukans.edu (Brian M. Moore; esq.) asked:

> Why do R4RS and R5RS insist that syntatic keywords cannot be
> shadowed?

Syntactic keywords are reserved in both the main body of the
R4RS (but not its macro appendix) and in the ANSI/IEEE standard
(which has no macros), but not in the R5RS:

The syntactic keyword of a macro may shadow variable
bindings, and local variable bindings may shadow keyword
bindings. All macros defined using the pattern language
are ``hygienic'' and ``referentially transparent'' and
thus preserve Scheme's lexical scoping [14, 15, 2, 7, 9].

This is one of the most important differences between the R4RS
and the R5RS. So why do you think that syntactic keywords
cannot be shadowed in the R5RS?

> I can imagine the following two programs, which seem quite
> reasonable:
>
> ((lambda lambda lambda) 'x)
> ((lambda (begin) (begin 1 2 3)) (lambda lambda lambda))

In R5RS Scheme, the first program returns (x) and the second
returns (1 2 3). This is also true in R4RS Scheme with the
high-level macro facility. As Moore noted, Chez Scheme is a
good example of an implementation that gets this right.

Will

Rob Warnock

unread,
Mar 12, 1998, 3:00:00 AM3/12/98
to

William D Clinger <wi...@ccs.neu.edu> wrote:
+---------------

| > ((lambda lambda lambda) 'x)
| > ((lambda (begin) (begin 1 2 3)) (lambda lambda lambda))
|
| In R5RS Scheme, the first program returns (x) and the second
| returns (1 2 3). This is also true in R4RS Scheme with the
| high-level macro facility. As Moore noted, Chez Scheme is a
| good example of an implementation that gets this right.
+---------------

As does MzScheme.


-Rob

-----
Rob Warnock, 7L-551 rp...@sgi.com http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673 [New area code!]
2011 N. Shoreline Blvd. FAX: 650-933-4392
Mountain View, CA 94043 PP-ASEL-IA

Brian M. Moore; esq.

unread,
Mar 12, 1998, 3:00:00 AM3/12/98
to

William D Clinger (wi...@ccs.neu.edu) wrote:
: moo...@lark.cc.ukans.edu (Brian M. Moore; esq.) asked:

: > Why do R4RS and R5RS insist that syntatic keywords cannot be
: > shadowed?

: Syntactic keywords are reserved in both the main body of the
: R4RS (but not its macro appendix) and in the ANSI/IEEE standard
: (which has no macros), but not in the R5RS:

: The syntactic keyword of a macro may shadow variable
: bindings, and local variable bindings may shadow keyword
: bindings. All macros defined using the pattern language
: are ``hygienic'' and ``referentially transparent'' and
: thus preserve Scheme's lexical scoping [14, 15, 2, 7, 9].

: This is one of the most important differences between the R4RS
: and the R5RS. So why do you think that syntactic keywords
: cannot be shadowed in the R5RS?

I think that syntatic keywords cannot be shadowed in R5RS because
of the wording on pages 38 and 39. The <formals> of a
<lambda expression> are <variable>s which are not allowed to be
<syntatic keyword>s.

Have I missed something? Is the report inconsistent? Inquiring
minds...

Per Bothner

unread,
Mar 12, 1998, 3:00:00 AM3/12/98
to

Rob Warnock <rp...@rigden.engr.sgi.com> wrote:
>William D Clinger <wi...@ccs.neu.edu> wrote:
>+---------------
>| > ((lambda lambda lambda) 'x)
>| > ((lambda (begin) (begin 1 2 3)) (lambda lambda lambda))
>|
>| In R5RS Scheme, the first program returns (x) and the second
>| returns (1 2 3). This is also true in R4RS Scheme with the
>| high-level macro facility. As Moore noted, Chez Scheme is a
>| good example of an implementation that gets this right.
>+---------------
>
>As does MzScheme.

As does Kawa Scheme.

(I just released Kawa 1.6 - see htpp://www.cygnus.com/~bothner/kawa/.
I will make a proper announcement in a few days, assuming no
major problems are reported.)
--
--Per Bothner
Cygnus Solutions bot...@cygnus.com http://www.cygnus.com/~bothner

William D Clinger

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to Brian M. Moore; esq.

moo...@lark.cc.ukans.edu (Brian M. Moore; esq.) wrote:
> I think that syntatic keywords cannot be shadowed in R5RS because
> of the wording on pages 38 and 39. The <formals> of a
> <lambda expression> are <variable>s which are not allowed to be
> <syntatic keyword>s.

Aha! I think that's a bug: Section 7.1.1 was revised in part, but
we must have missed this. I suppose it's true that

<variable> --> <any <identifier> that isn't
also a <syntactic keyword>>

but the problem is that the notion of a <syntactic keyword> is no
longer fixed: it depends on the context, which can be influenced by
introducting a new bound <variable>! I suppose we could fix this by
changing the productions for <syntactic keyword> and <variable> to

<syntactic keyword> --> <identifier>
<variable> --> <identifier>

and to say that the ambiguities are resolved by the rules of
Section 4, but I'm not sure this is the most informative way to
present the syntax of Scheme.

I think this increases the number of known new bugs in the R5RS
to 2.

Will

0 new messages