[racket] macro for define-values?

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Tue Feb 25 02:16:21 EST 2014

Does this do what you want? (Note its untested.)

(define-syntax-rule (ref name ...)
  (begin
    (define name (void)) ...))

Using define-values is tricky as you saw, because you need to refer to
name in the body to get the right duplication but then not use it.

On Mon, Feb 24, 2014 at 10:23 PM, Kevin Forchione <lysseus at gmail.com> wrote:
> I’m trying to code a macro that will define a variable number of identifiers. What I want is something like:
>
>         (ref foo bar baz ...)
>
> and assign them an initial value of #<void>. The kludge I’ve come up with works, but there must be a better way to do this:
>
> (define-syntax-rule (ref name ...)
>   (define-values (name …) (values ((λ (name) (void)) #f) ...)))
>
>>(ref foo bar baz)
>>foo
> #f
>
> Thanks!
>
> -Kevin
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.