[plt-scheme] Apply a procedure in a module

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Mon Oct 12 17:16:19 EDT 2009

Synx wrote:
> I'd like to know how to invoke mzscheme or mred or the like, so that I
> can run a specific procedure inside a specific module. What I have is a
> situation where I make a do-something.ss file/module and it contains
> something useful to import for do-something-else.ss, so I end up having
> to remove the toplevel procedure application from do-something.ss and
> instead make do-do-something.ss which contains a pretty carbon copy form
> of this:
> ---
> #lang scheme/base
> (require "do-something.ss")
> (main)
> ---
> Two things about that strike me as not a good idea. First off having
> toplevel procedure application at all is ugly, and the only reason I do
> is because I can't specify a procedure to apply on the command line.
> Secondly it means I have a bunch of redundant nearly identical files
> that do nothing besides import a module and apply its procedure. I'd
> like to have something instead the likes of:
> $ mzscheme -n -t do-something.ss -e '(main)'
> ...and not need to bother manually writing out a do-do-something.ss file
> at all.
> Another advantage to doing that is it would enable me to be more
> flexible with regard to program entry points. This is very convenient
> especially for testing, and in my opinion is more expressive.
> Trouble is, I don't know how to do it. :(
> $ mred -n -t prompt.ss -e '(watch-forever "/var/tmp/bink")'
> #f::0: compile: bad syntax; function application is not allowed, because
> no #%app syntax transformer is bound in: (watch-forever "/var/tmp/bink")

How about either of these:

mred -e \
   '(begin (require "prompt.ss") (watch-forever "/var/tmp/bink"))'

mred -e \
   "((dynamic-require \"prompt.ss\" 'watch-forever) \"/var/tmp/bink\")"

Why doesn't -t let you do that? I think -t is intended for compiled 
modules that act as programs, so it avoids loading things necessary for 
compiling expressions.


Posted on the users mailing list.