clojure.repl
A var's documentation and a throwable's stack trace. Require clojure.repl to use it (the
clojure> REPL refers doc and pst already, see REPL); it is
Clojure source written for rontolisp from the documented behavior of Clojure's namespace, and
runs the same on every backend.
| Var | Behavior |
|---|---|
doc | (doc name): prints the var's name, its argument lists, Macro for a macro, and its docstring, as its definition gave them; for a special form its name, Special Form and its clojure.org page |
pst | (pst), (pst e-or-depth), (pst e depth): prints the throwable's simple class name, message and ex-data to *err*, then each cause after Caused by:; without a throwable, the root cause of *e |
root-cause | (root-cause t): the innermost cause of t, following its causes; t when it has none |
demunge | (demunge s): the Clojure spelling of a function's class name, as a stack trace element names it |
stack-element-str | (stack-element-str el): a host StackTraceElement as text, a Clojure function by its demunged name (interpreter and JVM) |
-------------------------
user/add-one
([x])
Adds one.
Not built in
Each of these is refused by name when the program is lowered:
dir,dir-fn,apropos,find-doc: a namespace's vars are known only while the program is lowered.source,source-fn: a definition's text is not kept at run time.set-break-handler!,thread-stopper: there is no signal handler, and the JDK no longer supportsThread.stop.
Differences
docof a special form prints its name,Special Formand the clojure.org link, without Clojure's forms and text. Aclojure.corevar's metadata holds only:nameand:ns, sodocprints its name alone.docof a name that is no var, a namespace's included, is the lowering'sUnable to resolve var, where Clojure prints the namespace's docstring or nothing;docof a keyword (a spec) is refused.- A throwable carries no stack frames here, so
pstprints none.