[plt-scheme] conditional module inclusion and compilation

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Sep 2 17:52:53 EDT 2009

Would

> Welcome to MzScheme v4.2.1.7 [3m], Copyright (c) 2004-2009 PLT  
> Scheme Inc.
> > (system-type)
> macosx

help you get started? If you can tolerate a call to void for plots on  
the cluster, I'd use an abstraction over the graphics. If you want to  
see the tracker, pass in draw-progress-report (or whatever you call  
the graphics function); otherwise pass in void instead.

If the extra call costs too much, I'd write a macro that unfolds in  
one way on a mac and in a different way on a linux box.

-- Matthias







On Sep 2, 2009, at 5:34 PM, Lee Spector wrote:

>
> I've developed some code in DrScheme under Mac OS X that I also want  
> to run sometimes under Linux -- it's computationally intensive stuff  
> and I'll want to do development runs on my mac but then do lots of  
> bigger runs on our Linux cluster.
>
> I have some graphics in the Mac OS X version that I don't know how  
> to produce in my command-line/text-based Linux environment, but I  
> don't need the graphics there anyway. The graphics are just plots of  
> progress which are useful when I'm developing and watching a run,  
> but the cluster runs produce text files of data which are good  
> enough. So to get the code working on the cluster I just removed  
> "(require plot)" and all of the code that called anything from the  
> plot module.
>
> That worked but I don't want to have to do this kind of surgery on  
> the code every time I move it to the cluster, which I'll be doing  
> frequently. Ideally I'd like to be able to write my code in such a  
> way that it knows where it's running and it includes the plot module  
> and calls the plot code only if it's running somewhere appropriate.  
> I do this in Common Lisp by using the #+: and #-: conditional  
> compilation syntax and/or by looking for things in the variable  
> *features*, which includes symbols that describe the environment. Is  
> there anything similar in PLT?
>
> I wouldn't mind having to manually change a flag to indicate the  
> environment, e.g. to change the value in something like:
>
> (define include-plots-in-reports #t)
>
> But this doesn't actually help for two reasons:
>
> - PLT won't let me wrap a call to "require" in a conditional  
> expression -- it complains that it's not at the top level.
> - If I comment out the "require" PLT still won't compile a file  
> containing calls to functions in the missing module, even if those  
> calls are never executed.
>
> So whether my code knows where it's running or whether I have to  
> tell it manually, I don't have a way of moving it to the Linux  
> environment without manually editing out the "require" and all of  
> the code that refers to the plot module.
>
> Is there a good way to deal with this kind of thing in PLT that I'm  
> missing?
>
> Thanks,
>
> -Lee
>
> --
> Lee Spector, Professor of Computer Science
> School of Cognitive Science, Hampshire College
> 893 West Street, Amherst, MA 01002-3359
> lspector at hampshire.edu, http://hampshire.edu/lspector/
> Phone: 413-559-5352, Fax: 413-559-5438
>
> Check out Genetic Programming and Evolvable Machines:
> http://www.springer.com/10710 - http://gpemjournal.blogspot.com/
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.