[racket] Current advice on making a 'script'

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Wed Jan 14 16:36:25 EST 2015

Leif, hello.

> On 2015 Jan 14, at 18:46, Leif Andersen <leif at leifandersen.net> wrote:
> 
> If you want it to be a single file script you can execute, you can just make your file be:
> 
> #!/usr/bin/env racket
> #lang racket/base
> 
> (module foo racket/base
>   (provide x)
>   (define x 5))
> 
> (module bar racket/base
>   (require (submod ".." foo))
>   (display x))
> 
> (require 'foo 'bar)

Well, yes, that's what I've done, with an exec trampoline at the top, but I think I'd prefer to keep the various modules separate in a more traditional fashion, to make testing and so on easier.  Hence rewriting the various (require "foo.rkt") and concatenating them in dependency order.  It's not pretty (I can just sense, and indeed share, Jay's distaste for sed-ding a Racket source file, from here!), but it seems robust, and has the straightforwardness of a single-file 'executable', without the hammer-to-crack-a-nut of 'raco exe' (though disk space is cheap, of course; and in my case it's only 6MB, so what's the odds....).

Anyway: I was stumbling towards this solution, and thought that I was surely not the first person to want this, but couldn't find anything analogous in the sections on starting Racket, so thought I must be missing something.

I suspect that what was in my head was something like Java's .jar file: a zip file containing a bundle of compiled files in a single artefact, which needs a separate executable to run, but which is boneheadedly easy to manage.

Thanks, all, for your various observations.

Best wishes,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK



Posted on the users mailing list.