[plt-scheme] Another macro venture

From: Bill Wood (william.wood3 at comcast.net)
Date: Sat Sep 9 14:51:40 EDT 2006

On Sat, 2006-09-09 at 19:47 +0200, Jens Axel Søgaard wrote:
   . . .
> The first step of writting a macro is to figure out what the
> expansion needs to be.
> 
> If you were to write your program in a Scheme dialect with
> no macros, what would you write instead of
> 
>    (define a 'b)
>    (set a 5)

In R5RS without macros one could write

  (define a 'b)
  (eval `(set! ,a 5))

In R5RS one could first define

  (define-syntax clset
    (syntax-rules () ((clset v e) (eval `(set! ,v e)))))

and then

  (define a 'b)
  (clset a 5)

If I knew Scheme's equivalent to CL's "boundp" I could get around the 
Scheme error if "b" is not already bound.

No claims of wonderfulness, just exploring do-ability.

 -- Bill Wood




Posted on the users mailing list.