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