mix schooner.expand (schooner v1.2.0)

Copy Markdown View Source

Prints what a Scheme script's macros expand to, with Schooner.expand/3 and Schooner.Pretty, without running it.

$ mix schooner.expand -e "(when (> n 0) (go n))"
(if (> n 0) (begin (go n)))

Give either a file or, with -e, the source itself. The expanded top-level forms are printed one after another, with a blank line between them. An identifier a macro introduces is printed with a number, such as tmp·1, so it can be told apart from the script's own tmp.

Options

  • -e, --eval SOURCE — expand SOURCE instead of a file.

  • --env Mod.fun — expand against the Schooner.Environment returned by the zero-arity function Mod.fun. Without it, the environment is the one configured with

    config :schooner, :tooling_environment, {Mod, :fun, args}

    and without that, every standard library, all imported: the surface Schooner.run/1 gives a script that imports nothing. The environment decides which macros are in scope, so prefer your application's real one.

  • --once — expand each macro use that is not inside another macro use once, leaving the macro uses in its output as they are.

  • --trace — before the result, print each macro use expanded, in order: its number, the macro's name and the location of the use, then the use and, after =>, what it expanded to.

    $ mix schooner.expand -e "(unless ok (fail))" --trace
    [1] unless at 1:1
        (unless ok (fail))
     => (if ok (begin) (begin (fail)))
    
    (if ok (begin) (begin (fail)))
    
  • --plain — print renamed identifiers by their names alone (tmp).

  • --width N — the line width to fit forms in. Defaults to 80.

When the script can't be read or expanded, the task prints the error and exits with status 1.