[racket] splicing into local

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sat Sep 3 15:48:52 EDT 2011

On Sat, Sep 3, 2011 at 3:38 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> I have a define form that expands into two two definitions.  Usually I can write
>
> (my-define ...) ==> (begin (define ...) (define ...))
>
> However, this doesn't interact well with local.  Is there a way of
> identifying that I'm in a local context and expanding into something
> else so that this "just works"?
>
> [I don't suppose local would be willing to accommodate such forms by
> splicing begin's...]

`local' seems to splice `begin' for me:

#lang racket
(define-syntax-rule (deftwo x y a b)
  (begin (define x a) (define y b)))
(local [(deftwo x y 1 2)]
  (+ x y))

This works fine, produces 3.
-- 
sam th
samth at ccs.neu.edu



Posted on the users mailing list.