Richard Kelsey | 16 Feb 1998 00:38
Picon

Re: Is this "hygienic"?


   Date: Sun, 15 Feb 1998 17:43:27 -0500 (EST)
   From: Jonathan A Rees <jar <at> martigny.ai.mit.edu>
   Reply-To: JR <at> alum.mit.edu

      Date: Fri, 13 Feb 1998 13:20:16 -0500
      From: Alan Bawden <Alan <at> lcs.mit.edu>

      In Scheme 48 0.49:

      [foo and friends elided]

      Then:

	(test 7)  =>  ((inner-foo 7) (foo 7) (inner-foo 7))

      Now by my reading of section 4.3 of the new R5RS, this should return:

	(test 7)  =>  ((inner-foo 7) (foo 7) (foo 7))

      So is this a Scheme 48 bug?  Or is my understanding of R5RS at fault?

   I wouldn't be at all surprised if Scheme 48's define-syntax
   implementation (which is my fault, not Richard's) had bugs.

Yes, it is a Scheme 48 bug.  Macro-defining macros have never
been hygienic in Scheme 48.

   Perhaps we should switch to Will's version.

(Continue reading)

Richard Kelsey | 16 Feb 1998 10:35
Picon

Re: Is this "hygienic"?

   Date: Mon, 16 Feb 1998 01:11:39 -0500
   From: Alan Bawden <Alan <at> lcs.mit.edu>

   So I'm guessing that the problem is that the cliche ",'," doesn't work as
   expected because quote does this ugly un-renaming operation that's in there
   to support the `syntax-rules' pattern language.  Am I right?

Yes, except that the un-renaming is required for hygiene, not
just for `syntax-rules'.

   I've tried all kinds of tricks to get around this problem.  It seems that
   what I need is a version of `quote' that just turns it's operand into a
   constant without fooling with it.  I cobbled together a `kwote' that does
   just that (never mind how, it's very ugly) and it seems to work.

That's the fix.

   But I'm
   worried about embedding the output of a `rename' procedure in a constant
   like this -- what, exactly, is the lifetime of one of those generated
   names?  Are they truly first-class?  Can I hold on to a generated name that
   was once handed to me as the top-level meaning of a given identifier in a
   given package forever and substitute it in wherever I want?

And that's what I am worried about.

Clinger's code avoids the problem by not expanding `syntax-rules'
into Scheme.  The un-renaming only happens after all macros have
been expanded.  He also has only one top-level environment.
Scheme 48 has two essentially different mechanisms for dealing
(Continue reading)

Richard Kelsey | 16 Feb 1998 10:45
Picon

Re: scsh (was: is this "hygienic"?)

   Date: Mon, 16 Feb 1998 01:11:39 -0500
   From: Alan Bawden <Alan <at> lcs.mit.edu>

   Unfortunately I'm actually using `scsh', and so I'm trapped using Scheme48
   version 0.36, but I'd still be willing to test any fixes you may have
   before you release them to the rest of the world.  (I keep a more recent
   version of scheme48 around so I can avoid reporting Scheme48 bugs that may
   already have been fixed.)

I would like to get the Scsh functionality into Scheme 48.
It's too much to do all at once, so I never seem to get
started.  Do you use all of it?  Can you tell me what Scsh's
most useful features are?
                                    -Richard

Alan Bawden | 16 Feb 1998 18:19
Picon

scsh (was: is this "hygienic"?)

   Date: Mon, 16 Feb 1998 04:45:54 -0500
   From: Richard Kelsey <kelsey <at> research.nj.nec.com>
   I would like to get the Scsh functionality into Scheme 48.
   It's too much to do all at once, so I never seem to get
   started.  Do you use all of it?  Can you tell me what Scsh's
   most useful features are?

What I like is having the features in chapters 3 and 4 of the scsh manual
avaliable.  (I've used things from all of the sections in chapter 3 at one
time or another, except for the "Terminal device control" stuff.)  That's
most of the real meat of scsh I'm afraid.

Alan Bawden | 16 Feb 1998 18:45
Picon

Is this "hygienic"?

   Date: Mon, 16 Feb 1998 04:35:10 -0500
   From: Richard Kelsey <kelsey <at> research.nj.nec.com>

      Date: Mon, 16 Feb 1998 01:11:39 -0500
      From: Alan Bawden <Alan <at> lcs.mit.edu>

      So I'm guessing that the problem is that the cliche ",'," doesn't
      work as expected because quote does this ugly un-renaming operation
      that's in there to support the `syntax-rules' pattern language.  Am I
      right?

   Yes, except that the un-renaming is required for hygiene, not
   just for `syntax-rules'.

Huh?

If instead of using `syntax-rules' I'm using the low-level renaming
interface, then I don't think I ever need quote to do any un-renaming,
because I never rename any symbols inside my constants in the first place.
The only reason quote needs to un-rename anything is because `syntax-rules'
doesn't actually understand where the constants are in the right hand side
of its rewrite rules, and so it just renames everything.  In the low-level
world, I just never write ",(rename 'foo)" inside a constant.  At least
that's been my experience.

But maybe you're right.  I've never understood why we need the word
"hygiene" in the first place.  It has always seemed to me that "lexical
scoping" describes the effect we're after just fine.  So perhaps "hygiene"
describes something deeper that I've been missing -- something that
requires un-rename even without syntax-rules.
(Continue reading)

Richard Kelsey | 16 Feb 1998 19:12
Picon

Re: Is this "hygienic"?


   Date: Mon, 16 Feb 1998 12:45:09 -0500
   From: Alan Bawden <Alan <at> LCS.MIT.EDU>
   Sender: Alan <at> LCS.MIT.EDU

      Date: Mon, 16 Feb 1998 04:35:10 -0500
      From: Richard Kelsey <kelsey <at> research.nj.nec.com>

      Yes, except that the un-renaming is required for hygiene, not
      just for `syntax-rules'.

   Huh?

   If instead of using `syntax-rules' I'm using the low-level renaming
   interface, then I don't think I ever need quote to do any un-renaming,
   because I never rename any symbols inside my constants in the first place.
   The only reason quote needs to un-rename anything is because `syntax-rules'
   doesn't actually understand where the constants are in the right hand side
   of its rewrite rules, and so it just renames everything.

What if your macro expands into a use of another macro?
One that uses a subexpression both as code and as a constant?

                                     -Richard

Peter Doyle | 16 Feb 1998 19:34

Macros

The recent discussion of `hygienic macros' convinces me that this is
an oxymoron.  Scheme was so beautiful and clean, before macros.
Take them out!

Peter

Brian D. Carlstrom | 16 Feb 1998 20:07
Picon
Picon

Re: scsh (was: is this "hygienic"?)

Richard Kelsey writes:
 > I would like to get the Scsh functionality into Scheme 48.
 > It's too much to do all at once, so I never seem to get
 > started.  Do you use all of it?  Can you tell me what Scsh's
 > most useful features are?

It's most useful feature is the POSIX interface. That is "all of it"

-bri

Alan Bawden | 16 Feb 1998 21:43
Picon

Is this "hygienic"?

   Date: Mon, 16 Feb 1998 13:12:52 -0500
   From: Richard Kelsey <kelsey <at> research.nj.nec.com>

   What if your macro expands into a use of another macro?
   One that uses a subexpression both as code and as a constant?

The notion of "as a constant" isn't well-defined.  You have to be clear
about how that constant is going to be used.  Perhaps it's going to be
passed to some facility that -wants- to see the renaming.  Whatever that
other macro does, -it- should decide whether un-renaming is appropriate,
and if it is, it should call some un-renaming procedure itself -- it
needn't be built in to `quote'.

I've never fealt the need to call the un-renaming procedure in any macros
that I've written.  If I had, I would have requested that you make it
available.  Just so that I won't seem inconsistent, I hereby formally
request that you make such a facility available in Scheme 48.


Gmane