[racket-dev] raco dwim

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Sep 10 07:42:34 EDT 2010

I'm revising my course content now, and I ran into the change that
Robby committed a while ago to `raco setup' where it no longer
installs plt files by default.  I didn't know what would be the best
thing to do with it, but I think that there's no problems keeping such
instructions with setup-plt -- since the files are still ".plt" files.

But when I was thinking about that, I reazlied that since `raco' looks
for the first unambiguous prefix, it's doing a kind of a dwim search.
So why not go the whole way?  Running raco with some string can:

  * Run the specified command if there is one.

  * If it specifies a valid (symbolic) require, require it (as in
    `racket -l') -- a `foo' collection is effectively defining a
    `raco foo' command, and the same for `foo/bar'.

  * If it specifies an existing filename that looks like
    - "*.rkt", require the file (as in `racket -u')
    - "*.rktl", load the file (as in `racket -r')
    - "*.plt" (possibly more than one), install it

    [Otherwise it can look in the file for some magic header and
    decide what to do ("#lang" => require it, some future magic string
    for a package file => install it), but this might be a bad idea:
    sticking to a .suffix means that it can be made reliable if raco
    commands cannot use "." or ".suffix" for the few knowns suffixes.]

  * If something was required (through a symbolic require path or
    "*.rkt"), and if doing so provided a `#%top-interaction' binding,
    then start a repl.  (Or do that with a language configuration
    option.)

?

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.