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 On Thu, Jan 12, 2012 at 3:01 PM, Neil Toronto <neil.toro...@gmail.com> wrote: > On 01/12/2012 11:52 AM, Matthew Flatt wrote: >> >> At Thu, 12 Jan 2012 11:19:55 -0700, Neil Toronto wrote: >>> >>> 2. Compile time: Provide macros that render icons during expansion and >>> try to store them in the "compiled" directory. >> >> >> Do you need icons to be in separate files? A macro could expand to a >> byte-string literal, since it's just as easy to generate a bitmap from >> a PNG byte string as from a PNG file. > > > This is friggin' awesome. The expression > > (compiled-left-arrow-icon '(255 95 78) 24) > > expands to > > (make-object bitmap% (open-input-bytes bs) 'png) > > where `bs' is a literal byte string produced at compile time by > > (define bm (left-arrow-icon color-val height-val)) > (define p (open-output-bytes)) > (send bm save-file p 'png) > (define bs-stx (datum->syntax stx (get-output-bytes p))) > > The hardest part is parsing the color and height syntax, but `syntax/parse' > makes it easy enough. There is no distribution problem, no versioning, > hashing, caching, or unused bitmap cleanup. I can't think of a better > solution, and I couldn't have done it in any other language.* > > Racket so rocks. > > Neil T > > * Okay, I could have done it in some Lisp, but not safely or easily. > > _________________________ > Racket Developers list: > http://lists.racket-lang.org/dev _________________________ Racket Developers list: http://lists.racket-lang.org/dev