[plt-scheme] Apply a procedure in a module

From: Synx (plt at synx.us.to)
Date: Mon Oct 12 22:27:40 EDT 2009

--main works great, and was pretty much what I was looking for. But I
wanted to point out why (command-line) is not what I'm looking for, in
case it trips anyone up. It doesn't distinguish between whether a file
was imported as a module or called as a script. So if I were to say:

commandline.ss
---
#lang scheme/base

(require scheme/cmdline)

(define (main)
 (display "test\n"))

(command-line
 #:once-any (("-g" "--go") "GO" (main)))
---

test-commandline.ss
---
#lang scheme/base

(require scheme/cmdline)
(require (prefix-in commandline: "commandline.ss"))

(define (main)
  (display "foo\n"))

(command-line
 #:once-any (("-g" "--go") "GO" (main)))
---

Then when I went to say
$ mz -n -t test-commandline.ss -- -g

It will run both main functions, even though I don't want
commandline:main to run at all when I invoke test-commandline.ss.


Posted on the users mailing list.