[racket] literal images in compiled code

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Mon Dec 13 15:15:31 EST 2010

A couple of people have suggested that my picturing-programs teachpack include some variables containing the images used in the textbook.  So I added a "book-pictures.rkt" file to the teachpack, saying things like
	#lang racket
	(define calendar     )
with an image inserted as the value of the variable.  I can "run" that file by itself, but when I "require" it from another file, as in
	#lang racket
	(require "book-pictures.rkt")
	(provide (all-from-out "book-pictures.rkt"))
I get an odd error message: 
write: cannot marshal value that is embedded in compiled code: (object:image-snip% ...)

Does this actually mean I can't compile code that contains image literals?

If so, I guess there's a workaround: include the image files with the teachpack, and say
(define calendar (bitmap "calendar.png"))
But would this approach re-load the image file every time anybody require-d the teachpack?

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.