[racket-dev] separate plot library into gui-requiring and non-gui-requiring

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Tue Oct 8 13:22:30 EDT 2013

Short question:
Is there a way to separate the gui-requiring parts of plot from the
non-gui-requiring parts?

Long question:
Many people have expressed pleasant surprise with the plot-evaluating
ability of the racket pastebin Sam and I are working on.

Most of the effort is due to scribble's nice sandbox evaluation
capabilities but to get it fully working, I had to hack the plot
library in my racket install.

The problem is that plot uses racket/gui/base too eagerly but the
server has no display, resulting in a gtk initialization error. I
ultimately got around it by just commenting out all the gui parts of
plot, knowing that it would never get invoked, but obviously this is
an ugly solution.

I should say that I don't think plot is at fault. The plot library
does lazy-require racket/gui/base but that's not good enough because
the laziness has to propagate to other requires that also require
racket/gui/base (ie plot/snip) which isnt the case. But this cannot
work anyways because lazy-require only works with functions and some
of the things imported by plot/snip are classes.

I spent awhile trying to separate the gui-requiring parts of plot but
was unsuccessful. Maybe the change has to be in racket/gui/base itself
(related to PR 12465) I don't really know. I guess I'm just looking
for additional insight. Naively, slideshow/pict and 2htdp/draw do not
have this problem so it seemed like it should be possible.

Posted on the dev mailing list.