List of Examples
DISASSEMBLE
DISASSEMBLE
can disassemble to machine code,
provided that GNU gdb is present. In that case the argument may be a
EXT:SYSTEM-FUNCTION
, a FFI:FOREIGN-FUNCTION
, a
special operator handler, a SYMBOL
denoting one of these, an
INTEGER
(address), or a STRING
.
EXT:UNCOMPILE
The function EXT:UNCOMPILE
does the converse of
COMPILE
: (
reverts a compiled
EXT:UNCOMPILE
function
)function
(name), that has been entered or loaded in the same session
and then compiled, back to its interpreted form.
DOCUMENTATION
No on-line documentation is available for the system functions
(yet), but see Section 25.2.4, “Function DESCRIBE
”.
DESCRIBE
When CUSTOM:*BROWSER*
is non-NIL
, and CUSTOM:CLHS-ROOT
returns a valid URL,
DESCRIBE
on a standard Common Lisp symbol will point your web browser to the
appropriate [Common Lisp HyperSpec] page.
Also, when CUSTOM:*BROWSER*
is non-NIL
, and CUSTOM:IMPNOTES-ROOT
returns a
valid URL, DESCRIBE
on symbols and packages documented in these
implementation notes will point your web browser to the appropriate
page.
To do this, DESCRIBE
will retrieve the appropriate tables from
CUSTOM:CLHS-ROOT
and CUSTOM:IMPNOTES-ROOT
on the first relevant invocation.
These operations are logged to CUSTOM:*HTTP-LOG-STREAM*
.
Function CUSTOM:CLHS-ROOT
. Function CUSTOM:CLHS-ROOT
is defined in config.lisp
. By default it
looks at (
and EXT:GETENV
"CLHSROOT")CUSTOM:*CLHS-ROOT-DEFAULT*
,
but you may redefine it in config.lisp
or RC file.
The return value should be a STRING
terminated with a "/"
,
e.g., http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/ or /usr/doc/HyperSpec/
.
If the return value is NIL
, the feature is completely disabled.
CUSTOM:*CLHS-ROOT-DEFAULT*
is initialized in config.lisp
based on
the --hyperspec
passed to the top-level configure
script when CLISP was built.
Function CUSTOM:IMPNOTES-ROOT
. Function CUSTOM:IMPNOTES-ROOT
is defined in config.lisp
. By default it
looks at (
and EXT:GETENV
"IMPNOTES")CUSTOM:*IMPNOTES-ROOT-DEFAULT*
,
but you may redefine it in config.lisp
or RC file.
The return value should be a STRING
terminated with a "/"
,
e.g., http://clisp.cons.org/impnotes/, or the path to
the monolithic page, e.g., http://clisp.cons.org/impnotes.html
or /usr/doc/clisp/impnotes.html
.
If the return value is NIL
, the feature is completely disabled.
TRACE
List of Examples
(
makes the
functions TRACE
function-name
...)function-name
, ... traced. Each function-name
should be either
a function name or a LIST
(
, wherefunction-name
&KEY
:SUPPRESS-IF
:MAX-DEPTH
:STEP-IF
:BINDINGS
:PRE
:POST
:PRE-BREAK-IF
:POST-BREAK-IF
:PRE-PRINT
:POST-PRINT
:PRINT
)
:SUPPRESS-IF
form
form
is true
:MAX-DEPTH
form
(>
*trace-level* form
)
. This is useful for tracing functions that
are use by the tracer itself, such as PRINT-OBJECT
, or otherwise when
tracing would lead to an infinite recursion.
:STEP-IF
form
form
is true
:BINDINGS
((variable
form
)...)variable
s to the result of evaluation of
form
s around evaluation of all of the following forms
:PRE
form
form
before calling the function
:POST
form
form
after return from the function
:PRE-BREAK-IF
form
form
is true:POST-BREAK-IF
form
form
is true:PRE-PRINT
form
form
before calling the
function:POST-PRINT
form
form
after return from the
function:PRINT
form
form
both before calling
and after return from the functionIn all these forms you can access the following variables:
EXT:*TRACE-FUNCTION*
EXT:*TRACE-ARGS*
EXT:*TRACE-FORM*
EXT:*TRACE-VALUES*
and you can leave the function call with specified values by using
RETURN
.
TRACE
and UNTRACE
are also applicable to functions
(
and to macros, but not to
locally defined functions and macros.SETF
symbol
)
TRACE
prints this line before evaluating the form:
and after evaluating the form it prints:
trace level
. Trace: form
where “trace level” is the total nesting level.
trace level
. Trace: function-name
==> result
CUSTOM:*TRACE-INDENT*
If you want the TRACE
level to be indicated by the indentation
in addition to the printed numbers, set CUSTOM:*TRACE-INDENT*
to non-NIL
.
Initially it is NIL
since many nested traced calls will easily
exhaust the available line length.
Example 25.1. Identifying Individual Calls in TRACE
Suppose the trace level above is not enough for you to identify individual calls. You can give each call a unique id and print it:
(defun f0 (x) (cond ((zerop x) 1) ((zerop (random 2)) (* x (f0 (1- x)))) (t (* x (f1 (1- x)))))) ⇒F0
(defun f1 (x) (cond ((zerop x) 1) ((zerop (random 2)) (* x (f0 (1- x)))) (t (* x (f1 (1- x)))))) ⇒F1
(defvar *f0-call-count* 0) ⇒*F0-CALL-COUNT*
(defvar *id0*) ⇒*ID0*
(defvar *cc0*) ⇒*CC0*
(defvar *f1-call-count* 0) ⇒*F1-CALL-COUNT*
(defvar *id1*) ⇒*ID1*
(defvar *cc1*) ⇒*CC1*
(trace (f0 :bindings ((*cc0* (incf *f0-call-count*)) (*id0* (gensym "F0-"))) :pre-print (list 'enter *id0* *cc0*) :post-print (list 'exit *id0* *cc0*)) (f1 :bindings ((*cc1* (incf *f1-call-count*)) (*id1* (gensym "F1-"))) :pre-print (list 'enter *id1* *cc1*) :post-print (list 'exit *id1* *cc1*))) ;; Tracing function F0. ;; Tracing function F1. ⇒(F0 F1)
(f0 10) 1. Trace: (F0 '10) (ENTER #:F0-2926 1) 2. Trace: (F1 '9) (ENTER #:F1-2927 1) 3. Trace: (F0 '8) (ENTER #:F0-2928 2) 4. Trace: (F1 '7) (ENTER #:F1-2929 2) 5. Trace: (F1 '6) (ENTER #:F1-2930 3) 6. Trace: (F1 '5) (ENTER #:F1-2931 4) 7. Trace: (F1 '4) (ENTER #:F1-2932 5) 8. Trace: (F0 '3) (ENTER #:F0-2933 3) 9. Trace: (F1 '2) (ENTER #:F1-2934 6) 10. Trace: (F0 '1) (ENTER #:F0-2935 4) 11. Trace: (F1 '0) (ENTER #:F1-2936 7) (EXIT #:F1-2936 7) 11. Trace: F1 ==> 1 (EXIT #:F0-2935 4) 10. Trace: F0 ==> 1 (EXIT #:F1-2934 6) 9. Trace: F1 ==> 2 (EXIT #:F0-2933 3) 8. Trace: F0 ==> 6 (EXIT #:F1-2932 5) 7. Trace: F1 ==> 24 (EXIT #:F1-2931 4) 6. Trace: F1 ==> 120 (EXIT #:F1-2930 3) 5. Trace: F1 ==> 720 (EXIT #:F1-2929 2) 4. Trace: F1 ==> 5040 (EXIT #:F0-2928 2) 3. Trace: F0 ==> 40320 (EXIT #:F1-2927 1) 2. Trace: F1 ==> 362880 (EXIT #:F0-2926 1) 1. Trace: F0 ==> 3628800 ⇒3628800
*f0-call-count* ⇒4
*f1-call-count* ⇒7
INSPECT
The function INSPECT
accepts a keyword argument
:FRONTEND
, which specifies the way CLISP will
interact with the user, and defaults
to CUSTOM:*INSPECT-FRONTEND*
.
Available :FRONTEND
s for
INSPECT
in CLISP
:TTY
*TERMINAL-IO*
stream. Please use the help command to get the list of all
available commands.:HTTP
A window in your Web browser (specified by the
:BROWSER
keyword argument) is opened and it is controlled by
CLISP via a SOCKET:SOCKET-STREAM
, using the HTTP protocol.
You should be able to use all the standard browser features.
Since CLISP is not multitasking at this time, you will not
be able to do anything else during an INSPECT
session. Please click on
the quit
link to terminate the session.
Please be aware though, that once you terminate an INSPECT
session, all links in all INSPECT
windows in your browser will become
obsolete and using them in a new INSPECT
session will result in
unpredictable behavior.
The function INSPECT
also accepts a keyword argument :BROWSER
,
which specifies the browser used by the :HTTP
front-end and defaults to CUSTOM:*INSPECT-BROWSER*
.
The function INSPECT
binds some
pretty-printer variables:
Variable | Bound to |
---|---|
*PRINT-LENGTH* | CUSTOM:*INSPECT-PRINT-LENGTH* |
*PRINT-LEVEL* | CUSTOM:*INSPECT-PRINT-LEVEL* |
*PRINT-LINES* | CUSTOM:*INSPECT-PRINT-LINES* |
User variable
CUSTOM:*INSPECT-LENGTH*
specifies the number of sequence elements or slots printed in detail
when a sequence or a structure or a CLOS object is inspected.
TIME
The timing data printed by the macro TIME
includes:
GET-INTERNAL-REAL-TIME
),GET-INTERNAL-RUN-TIME
),The macro EXT:TIMES
(mnemonic:
“TIME and Space”)
is like the macro TIME
: (
evaluates the
EXT:TIMES
form
)form
, and, as a side effect, outputs detailed information about the
memory allocations caused by this evaluation. It also prints
everything printed by TIME
.
ED
The function ED
calls the external editor specified by the value of
(
or, failing that, the value of the variable
EXT:GETENV
"EDITOR")CUSTOM:*EDITOR*
(set in config.lisp
).
If the argument is a function name which was defined in the current
session (not loaded from a file), the program text to be edited is a
pretty-printed version (without comments) of the text which was used to
define the function.
APROPOS
& APROPOS-LIST
The search performed by APROPOS
and APROPOS-LIST
is
case-insensitive.
Variable CUSTOM:*APROPOS-DO-MORE*
. You can make APROPOS
print more information about the symbols it
found by setting CUSTOM:*APROPOS-DO-MORE*
to a list containing some of
:FUNCTION
, :VARIABLE
, :TYPE
, and :CLASS
or just set it to T
to get all of the values.
Variable CUSTOM:*APROPOS-MATCHER*
. You can make APROPOS
and APROPOS-LIST
be more flexible in
their search by setting CUSTOM:*APROPOS-MATCHER*
to a FUNCTION
of one
argument, a pattern (a STRING
), returning a new FUNCTION
of one
argument, a SYMBOL
name (also a STRING
),
which returns non-NIL
when the symbol name matches the pattern
for the purposes of APROPOS
.
When CUSTOM:*APROPOS-MATCHER*
is NIL
, SEARCH
is used.
Some modules come with functions which can be used for
CUSTOM:*APROPOS-MATCHER*
, e.g., REGEXP:REGEXP-MATCHER
,
WILDCARD:WILDCARD-MATCHER
,
PCRE:PCRE-MATCHER
.
DRIBBLE
If DRIBBLE
is called with an argument, and dribbling is already
enabled, a warning is printed, and the new dribbling request is
ignored.
Dribbling is implemented via a kind (but not a recognizable subtype)
of TWO-WAY-STREAM
, named EXT:DRIBBLE-STREAM
.
If you have a source
bidirectional STREAM
x
and you want all transactions
(input and output) on x
to be copied to the target
output STREAM
y
,
you can do
(DEFVAR
*loggable*x
) (SETQ
x
(MAKE-SYNONYM-STREAM
'*loggable*)) (DEFUN
toggle-logging (&OPTIONAL
s) (MULTIPLE-VALUE-BIND
(source target) (dribble-toggle *loggable* s) (WHEN
(STREAMP
source) (SETQ
*loggable* source)) target)) (toggle-loggingy
) ; start logging ... (toggle-logging) ; finish logging ... (toggle-loggingy
) ; restart logging ... (toggle-logging) ; finish logging (CLOSE
y
)
(EXT:DRIBBLE-STREAM
stream
)
stream
is a EXT:DRIBBLE-STREAM
, returns two values:
the source
and the target
streams. Otherwise returns NIL
.
(EXT:DRIBBLE-STREAM-P
stream
)
stream
is a EXT:DRIBBLE-STREAM
, returns T
, otherwise
returns NIL
.
(EXT:DRIBBLE-STREAM-SOURCE
stream
)
stream
is a EXT:DRIBBLE-STREAM
, returns its
source
stream, otherwise signals a TYPE-ERROR
.
(EXT:DRIBBLE-STREAM-TARGET
stream
)
stream
is a EXT:DRIBBLE-STREAM
, returns its
target
stream, otherwise signals a TYPE-ERROR
.
(EXT:MAKE-DRIBBLE-STREAM
source
target
)
EXT:DRIBBLE-STREAM
.
(EXT:DRIBBLE-TOGGLE
stream
&OPTIONAL
pathname
)
stream
is a EXT:DRIBBLE-STREAM
and pathname
is NIL
,
writes a dribble termination note to the stream
's target
STREAM
and returns stream
's source
and target
STREAM
s;
when stream
is not a EXT:DRIBBLE-STREAM
and pathname
is non-NIL
,
creates a new EXT:DRIBBLE-STREAM
, dribbling from stream
to pathname
,
writes a dribble initialization note to pathname
,
and return the EXT:DRIBBLE-STREAM
(the second value is the target
STREAM
);
otherwise WARN
that no appropriate action may be taken.
pathname
may be an open output STREAM
or a pathname designator.
See above for the sample usage.
See also src/dribble.lisp
in
the CLISP source tree.
DRIBBLE
DRIBBLE
works by operating on *TERMINAL-IO*
,
thus is does not work when CLISP acts as a script interpreter
(see Section 32.6.2, “Scripting with CLISP”).
Traditionally, Common Lisp implementations set *STANDARD-INPUT*
,
*STANDARD-OUTPUT*
, and *ERROR-OUTPUT*
to a SYNONYM-STREAM
pointing to *TERMINAL-IO*
, and CLISP is no exception.
Thus changing *TERMINAL-IO*
to a dribble stream affects all
standard i/o.
On the other hand, when CLISP acts as a script interpreter, it
adheres to the UNIX <stdio.h
> conventions,
thus *STANDARD-INPUT*
, *STANDARD-OUTPUT*
, and
*ERROR-OUTPUT*
are normal FILE-STREAM
s,
and thus are not affected by DRIBBLE
(*TERMINAL-IO*
- and
thus (
- is still affected).
The [ANSI CL standard] explicitly permits this behavior by stating
PRINT
... T
)
DRIBBLE
is intended primarily for interactive debugging; its effect cannot be relied upon when used in a program.
These notes document CLISP version 2.49 | Last modified: 2010-07-07 |