BSD 4_2 development
[unix-history] / usr / lisp / chc.n
CommitLineData
977235e0
C
1." $Header: /na/franz/doc/RCS/chc.n,v 1.1 83/01/31 07:11:44 jkf Exp $
2.Ap 3 Short\ Subjects.
3.sp 2v
4.tl ''\fB\s+2The Garbage Collector\s0\fP'
5.pp
6The garbage collector is invoked automatically whenever a collectable
7data type runs out.
8All data types are collectable except strings and atoms are not.
9After a garbage collection finishes, the collector will call the function
10.i gcafter
11which should be a lambda of one argument.
12The argument passed to
13.i gcafter
14is the name of the data type which ran out and caused the garbage collection.
15It is
16.i gcafter 's
17responsibility to
18allocate more pages of free space.
19The default
20.i gcafter
21makes its decision based on the percentage of space still in
22use after the garbage collection.
23If there is a large percentage of space still in use,
24.i gcafter
25allocates a larger amount of free space than if only a small percentage of
26space is still in use.
27The default
28.i gcafter
29will also print a summary of the space in use if the variable
30.i $gcprint
31is non nil.
32The summary always includes the state of the list and fixnum space and
33will include another type if it caused the garbage collection.
34The type which caused the garbage collection is preceded by an asterisk.
35.sp 4v
36.tl ''\s+2\fBDebugging\fP\s0''
37.pp
38There are two simple functions to help you debug your programs:
39.i baktrace
40and
41.i showstack .
42When an error occurs (or when you type the interrupt character),
43you will be left at a break level with the state of the computation
44frozen in the stack.
45At this point, calling the function
46.i showstack
47will cause the contents of the lisp evaluation stack to be printed in
48reverse chronological order (most recent first).
49When the programs you are running are interpreted or traced, the output
50of
51.i showstack
52can be very verbose.
53The function
54.i baktrace
55prints a summary of what
56.i showstack
57prints.
58That is, if showstack would print a list,
59.i baktrace
60would only print the first element of the list.
61If you are running compiled code with the \fI(status\ translink)\fP non
62nil, then fast links are being made.
63In this case,
64there is not enough information on the stack for
65.i showstack
66and
67.i baktrace .
68Thus, if you are debugging compiled code you should probably do
69\fI(sstatus\ translink\ nil)\fP.
70.pp
71If the contents of the stack don't tell you enough about your problem, the
72next thing you may
73want to try is to run your program with
74certain functions traced.
75You can direct the trace package to stop program execution when it enters
76a function, allowing you to examine the contents of variables or
77call other functions.
78The trace package is documented in Chapter 11.
79.pp
80It is also possible to single step the evaluator and to look at stack
81frames within lisp.
82The programs which
83perform these actions are described in Chapters 14 and 15.
84.bp
85.tl ''\fB\s+2The Interpreter\'s Top Level\s0\fP''
86.pp
87The default top level interpreter for Franz, named
88.i franz-top-level
89is defined in /usr/lib/lisp/toplevel.l
90It is given control when the lisp system starts up because the
91variable top-level is bound to the symbol
92.i franz-top-level .
93The first action
94.i franz-top-level
95takes is to print out the name of the current
96version of the lisp system.
97Then it loads the file .lisprc from the HOME directory of the person
98invoking the lisp system if that file exists.
99The .lisprc file allows you to set up your own defaults, read in files,
100set up autoloading or anything else you might want to do to personalize
101the lisp system.
102Next, the top level goes into a prompt-read-eval-print loop.
103Each time around the loop, before printing the prompt it checks
104if the variable user-top-level is bound.
105If so, then the value of user-top-level will be
106.i funcall ed.
107This provides a convenient way for a user to introduce his own top level
108(Liszt, the lisp compiler, is an example of a program which uses this).
109If the user types a ^D (which is the end of file character), and the
110standard input is not from a keyboard, the lisp system will exit.
111If the standard input is a keyboard and if the value of
112.i "(status\ ignoreeof)"
113is nil, the lisp system will also exit.
114Otherwise the end of file will be ignored.
115When a
116.i reset
117is done
118the current value of
119.i errlist
120is saved away and control is thrown back up to the top level where
121.i eval
122is mapped over the saved value of
123.i errlist.