I think [Racket][1] does this.
Here is a direct link to a tutorial that shows off graphics in the Racket REPL: http://docs.racket-lang.org/quick/index.html
There's a listener written with McClim that's easily installable with quicklisp. It's the one captured in the wikipedia article screenshot actually.
(ql:quickload 'clim-listener) (clim-listener:run-listener)
I wish Emacs would provide a canvas like API to draw in buffers. That way integrated graphics could be easily added. This would create a completely new Emacs experience.
There is an Artist Mode for Emacs. The "pictures" are ASCII-esque ;) http://www.cinsk.org/emacs/emacs-artist.html
I know. But for serious application a real drawing capability is needed. This should actually be possible to implement on top of the GTK+ layer.
Do you know if Mathematica does what you're describing? Mathematica functions and calculations can take arbitrary objects as arguments. Example: http://blog.wolfram.com/2008/12/01/the-incredible-convenienc...
And arbitrary objects can take the role of unique values. It's quite convenient, especially considering that Mathematica's language and display system let you put arbitrary expressions anywhere you want (like a 3D plot animation used as the surface texture of a 3D cube).
http://dspace.mit.edu/handle/1721.1/6946
http://en.wikipedia.org/wiki/Common_Lisp_Interface_Manager
http://www.sts.tu-harburg.de/~r.f.moeller/uims-clim/clim-int...