All Manuals > LispWorks User Guide and Reference Manual > 4 The REPL Inspector

NextPrevUpTopContentsIndex

4.3 Inspection modes

The :m command displays and changes the current inspection mode for an inspected value. The session below demonstrates how it works:

CL-USER 128 > (inspect "a
string with
newlines in it")
 
"a
string with
newlines in it" is a SIMPLE-BASE-STRING
0       #\a
1       #\Newline
2       #\s
3       #\t
4       #\r
5       #\i
6       #\n
7       #\g
8       #\Space
9       #\w
10      #\i
11      #\t
12      #\h
13      #\Newline
14      #\n
15      #\e
16      #\w
17      #\l
18      #\i
19      #\n ........ (:dm or :dr for more)
 
 
CL-USER 129 : Inspect 1 > :m
* 1. SIMPLE-STRING
  2. LINES

The :m produces an enumerated list of inspection modes for this value.

The asterisk next to

* 1. SIMPLE-STRING

means that SIMPLE-STRING is the current inspection mode.

You can change mode by typing :m followed by the name or number of another mode. To change to LINES mode:

CL-USER 130 : Inspect 1 > :m 2
 
"a
string with
newlines in it" is a SIMPLE-BASE-STRING
0      a
1      string with
2      newlines in it

4.3.1 Hash table inspection modes

There are five hash table inspection modes. They can be accessed in either the LispWorks IDE Inspector tool or the REPL inspector.

A brief introduction to the representation of hash tables is necessary so that you can fully understand what you gain from the new modes.

Internally, a hash table is a structure containing, among other things,

When keys and values are added to the table, sufficiently similar keys are converted into the same index in the vector. When this happens, the similar keys and values are kept together in a chain that hangs off this place in the vector.

The different inspection modes provide views of different pieces of this structure:

HASH-TABLE

This mode is the "normal" view of a hash table; as a table of keys and values. When you inspect an item you inspect the value of the item.

STRUCTURE

This mode provides a raw view of the whole hash table structure. When you inspect an item you are inspecting the value of that slot in the hash table structure.

ENUMERATED-HASH-TABLE

This mode is a variation of the normal view, where a hash table is viewed simply as a list of lists. When you inspect an item you are inspecting a list containing a key and a value.

HASH-TABLE-STATISTICS

This mode shows how long the chains in the hash table are, so that you can tell how efficiently it is being used. For example, if all chains contained fewer than two items the hash table would be being used well.

HASH-TABLE-HISTOGRAM

This mode shows the statistical information from HASH-TABLE-STATISTICS as a histogram.

Here is an example of hash table inspection.

CL-USER 1 > (defvar *hash* (make-hash-table))
*HASH*
 
CL-USER 2 > (setf (gethash 'lisp *hash*) 'programming
                  (gethash 'java *hash*) 'programming
                  (gethash 'c *hash*) 'programming
                  (gethash 'c++ *hash*) 'programming
                  (gethash 'english *hash*) 'natural
                  (gethash 'german *hash*) 'natural)
NATURAL
 
CL-USER 3 > (inspect *hash*)
 
#<EQL Hash Table{6} 21C15D97> is a HASH-TABLE
C++          PROGRAMMING
JAVA         PROGRAMMING
ENGLISH      NATURAL
C            PROGRAMMING
GERMAN       NATURAL
LISP         PROGRAMMING
 
CL-USER 4 : Inspect 1 > :m
* 1. HASH-TABLE
  2. STRUCTURE
  3. ENUMERATED-HASH-TABLE
  4. HASH-TABLE-STATISTICS
  5. HASH-TABLE-HISTOGRAM

STRUCTURE mode displays the raw representation of the hash table:

CL-USER 5 : Inspect 1 > :m 2
 
#<EQL Hash Table{6} 21C15D97> is a HASH-TABLE
KIND                      EQL
SIZE                      37
REHASH-SIZE               2.0
REHASH-THRESHOLD          1.0
THRESHOLD                 37
COUNTER                   525
NUMBER-ENTRIES            6
TABLE                     #(#%((LISP . PROGRAMMING) NIL) NIL NIL NIL NIL ...)
NO-DESTRUCT-REHASH        NIL
POWER2                    NIL
HASH-REM                  SYSTEM::DIVIDE-GENERAL
HASH-FN                   SYSTEM::EQL-HASHFN
GETHASH-FN                SYSTEM::GETHASH-EQL
PUTHASH-FN                SYSTEM::PUTHASH-EQL
REMHASH-FN                SYSTEM::REMHASH-EQL
GET-TLATTER-FN            SYSTEM::GET-TLATTER-EQL
WEAK-KIND                 NIL
USER-STUFF                NIL
MODIFICATION-COUNTER      0
FAST-LOCK-SLOT            0

In ENUMERATED-HASH-TABLE mode you can recursively inspect keys and values by entering the index. This is especially useful in cases where the key or value is unreadable and so cannot be entered into the REPL:

CL-USER 6 : Inspect 1 > :m 3
 
#<EQL Hash Table{6} 21C15D97> is an Enumerated HASH TABLE
0      (C++ PROGRAMMING)
1      (JAVA PROGRAMMING)
2      (ENGLISH NATURAL)
3      (C PROGRAMMING)
4      (GERMAN NATURAL)
5      (LISP PROGRAMMING)
 
CL-USER 7 : Inspect 1 > 5
 
(LISP PROGRAMMING) is a LIST
0      LISP
1      PROGRAMMING
 
CL-USER 8 : Inspect 2 > :u

The HASH-TABLE-STATISTICS mode shows that *hash* has 31 chains, of which 25 are empty and 6 have one entry::

CL-USER 9 : Inspect 1 > :m 4
 
#<EQL Hash Table{6} 21C15D97> is a HASH-TABLE (statistical view)
chain of length 0 :      31
chain of length 1 :      6

In HASH-TABLE-HISTOGRAM mode the same information is represented as a histogram:

CL-USER 10 : Inspect 1 > :m 5
 
#<EQL Hash Table{6} 21C15D97> is a HASH-TABLE (histogram view)
chain of length 0 :      "*******************************"
chain of length 1 :      "******"
 
CL-USER 11 : Inspect 1 > :q
#<EQL Hash Table{6} 21C15D97>

 


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex