[racket] Macros in slideshow

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Wed Jan 21 09:51:01 EST 2015

Also, there are some more modern alternatives to `with-steps`. I
particularly like the `staged` and `slide/staged` macros, which you can
read about here:
http://docs.racket-lang.org/unstable-gui/Slideshow_Presentations.html#%28part._.Staged_.Slides%29

Sam

On Wed Jan 21 2015 at 9:47:28 AM Matthew Flatt <mflatt at cs.utah.edu> wrote:

> At Wed, 21 Jan 2015 13:04:11 +0000, Reuben Thomas wrote:
> > 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?​
>
> You're right that the essential problem is that `with-steps` introduces
> binding no-hygienically. Non-hygienic macros don't compose nicely.
>
> If `with-steps` were written in modern Racket, then it would be
> hygienic, where `vonly`, etc., are bindings that take their meaning
> as syntax parameters from an enclosing `with-steps`. Fortunately, it's
> possible to implement a more modern `with-steps` using the existing one.
>
> Use the enclosed "new-step.rkt" in place of `slideshow/step`, and then
> your `correct` macro will work.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150121/0279c271/attachment-0001.html>

Posted on the users mailing list.