Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!gatech!psuvax1!news.ecn.bgu.edu!siemens!princeton!news.princeton.edu!blume
From: blume@dynamic.cs.princeton.edu (Matthias Blume)
Subject: Re: R4RS high level macro question
In-Reply-To: Brent.Benson@mail.csd.harris.com's message of 22 Nov 1994 13:02:31 GMT
Message-ID: <BLUME.94Nov22093818@dynamic.cs.princeton.edu>
Originator: news@hedgehog.Princeton.EDU
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: dynamic.cs.princeton.edu
Organization: Princeton University
References: <YURI.94Nov21161406@shimari.cmf.nrl.navy.mil>
	<BRENT.BENSON.94Nov22080231@jade.ssd.csd.harris.com>
Date: Tue, 22 Nov 1994 14:38:17 GMT
Lines: 43

In article <BRENT.BENSON.94Nov22080231@jade.ssd.csd.harris.com> Brent.Benson@mail.csd.harris.com (Brent Benson) writes:

   yuri@shimari.cmf.nrl.navy.mil (Yuri Trifanov) writes (with respect to
   defining letrec as a hygenic macro): 

   # I can do something like this with 
   # 
   #   (let-syntax
   #     ((my-letrec
   #       (syntax-rules ()
   # 		    ((my-letrec ((name value) ...) body1 ...)
   # 		     '((lambda (name ...) (set! name value) ... body1 ...)
   # 		       name ...)))))
   #    (my-letrec ((a 3) (b 5)) (+ a b)))
   #     
   # producing: ((lambda (a b) (set! a 3) (set! b 5) (+ a b)) a b)

   Why not use each bound variable's *quoted* name as its unspecific
   initial value:

   (define-syntax my-letrec
     (syntax-rules ()
       ((my-letrec ((name value) ...) form1 form2 ...)
	((lambda (name ...) 
	  (set! name value) ... form1 form2 ...) 'name ...))))

Same idea -- original goal (I know -- it's ugly):

   (define-syntax my-letrec
     (syntax-rules ()
       ((my-letrec ((name value) ...) form1 form2 ...)
	((lambda (name ...) 
	  (set! name value) ... form1 form2 ...)
          (car (cons *unspecified* 'name)) ...))))

BTW, I wouldn't recommend to do this kind of transformation on LETREC
anyway.  Instead, the CPS phase of the translation should deal with
LETRECs directly.  There are quite a few useful things you can do to
LETRECs in later phases of the compilation -- as long as you still know
that they *are* LETRECs.

--
-Matthias
