[racket] Macros in slideshow

From: Reuben Thomas (rrt at sc3d.org)
Date: Wed Jan 21 08:04:11 EST 2015

Hi,

I've been meaning to try Racket for years, and finally got around to it
when I found myself wanting to program a presentation, rather than
laboriously copy lots of slides in a similar format.

I'm using Racket 6.1.1, and I'm pretty new to Scheme.

I'm trying to illustrate editing fixes in short samples of writing. The
following simple code works fine:

#lang slideshow

(require slideshow/step)

(void
 (with-steps
  (before after)
  (slide
   (lt-superimpose
    ((vonly before) (t "With"))
    ((vonly after) (t "By"))))))

First I see "With", then "By".

Since I have a lot of slides like this, I want to write a macro. I tried:

#lang slideshow

​(require slideshow/step)

(define-syntax-rule (correct from to)
  (lt-superimpose
   ((vonly before) (t from))
   ((vonly after) (t to))))

(void
 (with-steps
  (before after)
  (slide
   (correct "With" "By"))))
​
​but I get the error:

​vonly: unbound identifier in module in: vonly​

​I've experimented with various types of quoting and unquoting, and tried
define-simple-macro instead of define-syntax-rule, but I'm forced to admit
I don't know what I'm doing!

I know that vonly is special and is bound non-hygienically inside the scope
of the with-steps; how do I reference it correctly in a macro?​


-- 
http://rrt.sc3d.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150121/7a59f04f/attachment.html>

Posted on the users mailing list.