Sure!

BTW, having been inspired by Jay's latest elegant macro, I've shrunk the implementation to 21 lines of code. (That's good for a tutorial.) It works a little differently now, too. I think it's better.

Here's an example that bakes a list of stickman animation frames into a compiled module:

(begin-for-syntax
  (require images/icons/stickman)
  (define stickman-height 18)
  (define num-running-frames 12))

(define running-frames
  (compiled-bitmap-list
   (for/list ([t  (in-range 0 1 (/ 1 num-running-frames))])
     (running-stickman-icon t run-icon-color "white" run-icon-color
                            stickman-height))))


The expression within `compiled-bitmap-list' is evaluated at compile time. It and `compiled-bitmap' make any bitmap or list of bitmaps generated at compile time into runtime values. The above expands to

    (list (make-object bitmap% (open-input-bytes #"...") 'png)
          ...)

There are very few restrictions on the arguments now. They just have to be valid in the transformer phase.

Neil T

On 01/12/2012 03:54 PM, Robby Findler wrote:
I think this is a great example to base a tutorial example on. Neil:
I'd be happy to help with the writeup, if you'd be willing to make a
first attempt.

Robby
_________________________
 Racket Developers list:
 http://lists.racket-lang.org/dev

Reply via email to