[plt-scheme] Interactive
I have upgraded my interactive to work with v4.0. It has many new
features now, some are due to new things in PLT. It's available at
http://barzilay.org/misc/interactive.ss
Here is the blurb from the top of the file:
This file provides some useful facilities for interactive use of mzscheme. It
is best used as (or loaded from) a ".mzschemerc" file or "mzschemerc.ss" on
Windows (evaluate `(find-system-path 'init-file)' to know where this file is on
your system).
Some highlights are:
* Defines a 'debug module (can also be used as '* for brevity) that provides a
few useful utilities for use in code while debugging:
> (eprintf fmt arg ...)
Like `printf', but uses the current error port.
> (eeprintf fmt arg ...)
Like `eprintf', but the original error port. Useful for printouts from
code where `current-error-port' might be redirected.
> (warn ...)
Same as `error', but only prints the error message.
> ***
> (*** value)
> (*** fmt args ...)
This is macro that is useful for debugging printouts: the first form
prints (on stderr) the source file and line number, the second also prints
a value (and returns it), and the third uses a format string. For example,
to see where a problem happens in a function, you spread ***s around, and
the printout will show a trace of location (and possibly values).
> (define*** (name args ...) ...)
Macro that defines `name' as a traced function. (The idea is that you
append a `***' to `define' for functions that you want to trace.) This is
a cheap hack: it kills tail-recursiveness.
The `***' is supposed to be a token that stands out textually in *your* code
while you're debugging it, so it is customizable: set the `MZ_DEBUGGER_TOKEN'
environment variable to whatever you want -- for example, set it to "@@" and
you'll get bindings for `@@' and `define@@' instead of the above.
The following REPL functionality is used only when the REPL is actually used,
so non-interactive use (eg, scripts) are not affected (but note that
.mzschemerc is not read in such cases anyway (by default)).
* Uses the readline library if you're running in an xterm (and if it's
present). (Again, triggered by repl interaction.)
* Toplevel commands, in the form of ",cmd". These commands make it convenient
to perform many otherwise-tedious operations in MzScheme. Use ",h" for a
list of available commands and for help on a specific command. Note that
some of these commands look similar to existing mzscheme functionality, but
are extended.
Most commands consume arguments, ,help will tell you about the relevant
syntax. Note that arguments usually do not need to be quoted, for
example ",cd .." goes up a directory; this is also relevant for commands that
consume an expression, a require specification, a symbol, etc.
Some highlights:
- ,time: improved timing output, and can run an expression multiple times
- ,require: if you use it with an argument that looks like a file, it will do
the right thing to require that file
- ,syntax: not only is this a poor man's syntax stepper -- it can actually
use the real syntax stepper
- ,apropos: search the available bindings
- ,describe: tell you how you got to have some binding
- ,require-reloadable ,reload ,enter: require a module so it can be reloaded
later, and a convenient command for `enter!' (with the prompt showing you
where you are)
- ,trace ,untrace ,errortrace ,profile: convenient commands for those
features you always knew how to use but was lazy to actually type what's
needed.
* Previous toplevel results are accessible: `^' is the last result, `^^' is the
second to last (or the second value of the last multiple-value result) etc.
This is done in a way that is trying to avoid clobbering a binding that you
already have for these identifiers.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!