worker.scm
(define (make-worker n)
(lambda () (set! n (+ n 1)) n) )
main.scm
;; no shebang line.
(load "worker.scm") ;; no module system
(define (print . args)
(for-each display args)
(newline) )
(define (main argv)
(let ( (w (make-worker 0)) )
(print "worker: " (w))
(print "worker: " (w))
(print "worker: " (w)) ) )
(main (command-line-arguments))
(%exit 0) ;; drops into repl otherwise
main.sh
#!/bin/sh
DISPLAY= mit-scheme --quiet --load main.scm
run as script
% ./main.sh
build & run as binary
Not possible.
- Up to Scheme