-
Notifications
You must be signed in to change notification settings - Fork 0
/
chap-25.texi
2090 lines (1357 loc) · 59.3 KB
/
chap-25.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@node Environment
@chapter Environment
@menu
* The External Environment::
* Environment Dictionary::
@end menu
@node The External Environment
@section The External Environment
@menu
* Top level loop::
* Debugging Utilities::
* Environment Inquiry::
* Time::
@end menu
@node Top level loop
@subsection Top level loop
The top level loop is the @clisp{}@spc{}mechanism by which the user normally
interacts with the @clisp{}@spc{}system. This loop is sometimes referred to
as the @term{Lisp read-eval-print loop}
because it typically consists of an endless loop that reads an expression,
evaluates it and prints the results.
The top level loop is not completely specified; thus the user
interface is @term{implementation-defined}.
The top level loop
prints all values resulting from the evaluation of a
@term{form}.
@Thenextfigure{}@spc{}lists variables that are maintained by the @term{Lisp read-eval-print loop}.
@float Figure,fig25.1
@cartouche
@multitable{***}{+++}{///}{-}
@item * @tab + @tab / @tab -
@item ** @tab ++ @tab // @tab
@item *** @tab +++ @tab /// @tab
@end multitable
@end cartouche
@caption{Variables maintained by the Read-Eval-Print Loop}
@end float
@node Debugging Utilities
@subsection Debugging Utilities
@Thenextfigure{}@spc{}shows @term{defined names} relating to
debugging.
@float Figure,fig25.2
@cartouche
@multitable{*debugger-hook*}{invoke-debugger}{untrace}
@item *debugger-hook* @tab documentation @tab step
@item apropos @tab dribble @tab time
@item apropos-list @tab ed @tab trace
@item break @tab inspect @tab untrace
@item describe @tab invoke-debugger @tab
@end multitable
@end cartouche
@caption{Defined names relating to debugging}
@end float
@node Environment Inquiry
@subsection Environment Inquiry
Environment inquiry @term{defined names} provide information about
the hardware and software configuration on which a @clisp{}@spc{}program is
being executed.
@Thenextfigure{}@spc{}shows @term{defined names} relating to environment inquiry.
@float Figure,fig25.3
@cartouche
@multitable{lisp-implementation-version}{machine-instance}{software-version}
@item *features* @tab machine-instance @tab short-site-name
@item lisp-implementation-type @tab machine-type @tab software-type
@item lisp-implementation-version @tab machine-version @tab software-version
@item long-site-name @tab room @tab
@end multitable
@end cartouche
@caption{Defined names relating to environment inquiry.}
@end float
@node Time
@subsection Time
Time is represented in four different ways in @clisp{}:
@term{decoded time},
@term{universal time},
@term{internal time},
and seconds.
@term{Decoded time} and @term{universal time} are used primarily to represent calendar time,
and are precise only to one second.
@term{Internal time} is used primarily to represent measurements of computer
time (such as run time) and is precise to some @term{implementation-dependent}
fraction of a second called an @term{internal time unit},
as specified by @symbolref{internal-time-units-per-second, SYM}.
An @term{internal time} can be used
for either @term{absolute} and @term{relative} @term{time} measurements.
Both a @term{universal time} and a @term{decoded time} can be used
only for @term{absolute} @term{time} measurements.
In the case of one function, @symbolref{sleep, SYM},
time intervals are represented as a non-negative @symbolref{real, SYM} number of seconds.
@Thenextfigure{}@spc{}shows @term{defined names} relating to @term{time}.
@float Figure,fig25.4
@cartouche
@multitable{get-internal-real-time}{internal-time-units-per-second}
@item decode-universal-time @tab get-internal-run-time
@item encode-universal-time @tab get-universal-time
@item get-decoded-time @tab internal-time-units-per-second
@item get-internal-real-time @tab sleep
@end multitable
@end cartouche
@caption{Defined names involving Time.}
@end float
@node Decoded Time
@subsubsection Decoded Time
A @newterm{decoded time} is an ordered series of nine values that, taken together,
represent a point in calendar time (ignoring @term{leap seconds}):
@table @asis
@item @id{@b{Second}}
An @term{integer} between 0 and@tie{}59, inclusive.
@item @id{@b{Minute}}
An @term{integer} between 0 and@tie{}59, inclusive.
@item @id{@b{Hour}}
An @term{integer} between 0 and@tie{}23, inclusive.
@item @id{@b{Date}}
An @term{integer} between 1 and@tie{}31, inclusive (the upper limit actually
depends on the month and year, of course).
@item @id{@b{Month}}
An @term{integer} between 1 and 12, inclusive;
1@tie{}means January, 2@tie{}means February, and so on; 12@tie{}means December.
@item @id{@b{Year}}
An @term{integer} indicating the year A.D. However, if this
@term{integer}
is between 0 and 99, the ``obvious'' year is used; more precisely,
that year is assumed that is equal to the
@term{integer} modulo 100 and
within fifty years of the current year (inclusive backwards
and exclusive forwards).
Thus, in the year 1978, year 28 is 1928
but year 27 is 2027. (Functions that return time in this format always return
a full year number.)
@item @id{@b{Day of week}}
An @term{integer} between@tie{}0 and@tie{}6, inclusive;
0@tie{}means Monday, 1@tie{}means Tuesday, and so on; 6@tie{}means Sunday.
@item @id{@b{Daylight saving time flag}}
A @term{generalized boolean} that,
if @term{true}, indicates that daylight saving time is in effect.
@item @id{@b{Time zone}}
A @term{time zone}.
@end table
@Thenextfigure{}@spc{}shows @term{defined names} relating to @term{decoded time}.
@float Figure,fig25.5
@cartouche
@multitable{decode-universal-time}{get-decoded-time}
@item decode-universal-time @tab get-decoded-time
@end multitable
@end cartouche
@caption{Defined names involving time in Decoded Time.}
@end float
@node Universal Time
@subsubsection Universal Time
@cindex universal time
@dfn{Universal time} is an @term{absolute} @term{time} represented as a
single non-negative @term{integer}---the number of seconds since
midnight, January 1, 1900 GMT (ignoring @term{leap seconds}).
Thus the time 1 is 00:00:01 (that is, 12:00:01 a.m.) on January 1, 1900 GMT.
Similarly, the time 2398291201 corresponds to time 00:00:01 on January 1,
1976 GMT.
Recall that the year 1900 was not a leap year; for the purposes of
@clisp{}, a year is a leap year if and only if its number is divisible by 4,
except that years divisible by 100 are not leap years, except that years
divisible by 400 are leap years. Therefore the year 2000 will
be a leap year.
Because @term{universal time} must be a non-negative @term{integer},
times before the base time of midnight, January 1, 1900 GMT cannot be processed by @clisp{}.
@float Figure,fig25.6
@cartouche
@multitable{decode-universal-time}{get-universal-time}
@item decode-universal-time @tab get-universal-time
@item encode-universal-time @tab
@end multitable
@end cartouche
@caption{Defined names involving time in Universal Time.}
@end float
@node Internal Time
@subsubsection Internal Time
@cindex internal time
@dfn{Internal time} represents time as a single @term{integer},
in terms of an @term{implementation-dependent} unit called an @term{internal time unit}.
Relative time is measured as a number of these units.
Absolute time is relative to an arbitrary time base.
@Thenextfigure{}@spc{}shows @term{defined names} related to @term{internal time}.
@float Figure,fig25.7
@cartouche
@multitable{get-internal-real-time}{internal-time-units-per-second}
@item get-internal-real-time @tab internal-time-units-per-second
@item get-internal-run-time @tab
@end multitable
@end cartouche
@caption{Defined names involving time in Internal Time.}
@end float
@node Seconds
@subsubsection Seconds
One function, @symbolref{sleep, SYM}, takes its argument as a non-negative @symbolref{real, SYM} number
of seconds. Informally, it may be useful to think of this as
a @term{relative} @term{universal time}, but it differs in one important way:
@term{universal times} are always non-negative @term{integers}, whereas the argument to
@symbolref{sleep, SYM} can be any kind of non-negative @symbolref{real, SYM}, in order to allow for
the possibility of fractional seconds.
@float Figure,fig25.8
@cartouche
@multitable{sleep}{}
@item sleep @tab
@end multitable
@end cartouche
@caption{Defined names involving time in Seconds.}
@end float
@node Environment Dictionary
@section Environment Dictionary
@menu
* decode-universal-time::
* encode-universal-time::
* get-universal-time; get-decoded-time::
* sleep::
* apropos; apropos-list::
* describe::
* describe-object::
* trace; untrace::
* step::
* time (Macro)::
* internal-time-units-per-second::
* get-internal-real-time::
* get-internal-run-time::
* disassemble::
* documentation; setf documentation::
* room::
* ed::
* inspect::
* dribble::
* - (Variable)::
* +; ++; +++::
* *; **; ***::
* /; //; ///::
* lisp-implementation-type; lisp-implementation-version::
* short-site-name; long-site-name::
* machine-instance::
* machine-type::
* machine-version::
* software-type; software-version::
* user-homedir-pathname::
@end menu
@node decode-universal-time
@syindexanchor{decode-universal-time, SYM}
@subsection decode-universal-time (Function)
@cindex decode-universal-time
@subsubheading Syntax:
@DefunWithValuesNewline{decode-universal-time, universal-time @opt{} time-zone, second\, minute\, hour\, date\, month\, year\, day\, daylight-p\, zone}
@subsubheading Arguments and Values:
@param{universal-time}---a @term{universal time}.
@param{time-zone}---a @term{time zone}.
@param{second}, @param{minute}, @param{hour}, @param{date}, @param{month},
@param{year}, @param{day}, @param{daylight-p}, @param{zone}---a @term{decoded time}.
@subsubheading Description:
Returns the @term{decoded time} represented by the given @term{universal time}.
If @param{time-zone} is not supplied,
it defaults to the current time zone adjusted for daylight saving time.
If @param{time-zone} is supplied, daylight saving time information is ignored.
The daylight saving time flag is @nil{}@spc{}if @param{time-zone} is supplied.
@subsubheading Examples:
@lisp
(decode-universal-time 0 0) @EV{} 0, 0, 0, 1, 1, 1900, 0, @term{false}, 0
;; The next two examples assume Eastern Daylight Time.
(decode-universal-time 2414296800 5) @EV{} 0, 0, 1, 4, 7, 1976, 6, @term{false}, 5
(decode-universal-time 2414293200) @EV{} 0, 0, 1, 4, 7, 1976, 6, @term{true}, 5
;; This example assumes that the time zone is Eastern Daylight Time
;; (and that the time zone is constant throughout the example).
(let* ((here (nth 8 (multiple-value-list (get-decoded-time)))) ;Time zone
(recently (get-universal-time))
(a (nthcdr 7 (multiple-value-list (decode-universal-time recently))))
(b (nthcdr 7 (multiple-value-list (decode-universal-time recently here)))))
(list a b (equal a b))) @EV{} ((T 5) (NIL 5) NIL)
@end lisp
@subsubheading Affected By:
@term{Implementation-dependent} mechanisms for calculating when or if daylight
savings time is in effect for any given session.
@subsubheading See Also:
@ref{encode-universal-time}, @ref{get-universal-time},
@ref{Time}
@node encode-universal-time
@syindexanchor{encode-universal-time, SYM}
@subsection encode-universal-time (function)
@cindex encode-universal-time
@subsubheading Syntax:
@DefunWithValuesNewline{encode-universal-time, @vtop{@hbox{second minute hour date month year} @hbox{@opt{} time-zone}}, universal-time}
@subsubheading Arguments and Values:
@param{second}, @param{minute}, @param{hour},
@param{date}, @param{month}, @param{year},
@param{time-zone}---the corresponding parts of a @term{decoded time}.
(Note that some of the nine values in a full @term{decoded time} are redundant,
and so are not used as inputs to this function.)
@param{universal-time}---a @term{universal time}.
@subsubheading Description:
@symbolref{encode-universal-time, SYM} converts a time from Decoded Time format
to a @term{universal time}.
If @param{time-zone} is supplied, no adjustment for daylight savings time is performed.
@subsubheading Examples:
@lisp
(encode-universal-time 0 0 0 1 1 1900 0) @EV{} 0
(encode-universal-time 0 0 1 4 7 1976 5) @EV{} 2414296800
;; The next example assumes Eastern Daylight Time.
(encode-universal-time 0 0 1 4 7 1976) @EV{} 2414293200
@end lisp
@subsubheading See Also:
@ref{decode-universal-time}, @ref{get-decoded-time}
@node get-universal-time; get-decoded-time
@syindexanchor{get-universal-time, SYM}
@syindexanchor{get-decoded-time, SYM}
@subsection get-universal-time, get-decoded-time (Function)
@cindex get-universal-time
@cindex get-decoded-time
@anchor{get-universal-time}
@anchor{get-decoded-time}
@subsubheading Syntax:
@DefunWithValues{get-universal-time, @noargs{}, universal-time}
@DefunWithValuesNewline{get-decoded-time, @noargs{}, second\, minute\, hour\, date\, month\, year\, day\, daylight-p\, zone}
@subsubheading Arguments and Values:
@param{universal-time}---a @term{universal time}.
@param{second}, @param{minute}, @param{hour},
@param{date}, @param{month}, @param{year},
@param{day}, @param{daylight-p}, @param{zone}---a @term{decoded time}.
@subsubheading Description:
@symbolref{get-universal-time, SYM} returns the current time, represented as a @term{universal time}.
@symbolref{get-decoded-time, SYM} returns the current time, represented as a @term{decoded time}.
@subsubheading Examples:
@lisp
;; At noon on July 4, 1976 in Eastern Daylight Time.
(get-decoded-time) @EV{} 0, 0, 12, 4, 7, 1976, 6, @term{true}, 5
;; At exactly the same instant.
(get-universal-time) @EV{} 2414332800
;; Exactly five minutes later.
(get-universal-time) @EV{} 2414333100
;; The difference is 300 seconds (five minutes)
(- * **) @EV{} 300
@end lisp
@subsubheading Affected By:
The time of day (@ie{} the passage of time),
the system clock's ability to keep accurate time,
and the accuracy of the system clock's initial setting.
@subsubheading Exceptional Situations:
An error @oftype{error} might be signaled if the current time cannot be determined.
@subsubheading See Also:
@ref{decode-universal-time},
@ref{encode-universal-time},
@ref{Time}
@subsubheading Notes:
@lisp
(get-decoded-time) @EQ{} (decode-universal-time (get-universal-time))
@end lisp
No @term{implementation} is required to have a way to verify that the
time returned is correct. However, if an @term{implementation} provides
a validity check (@eg{} the failure to have properly initialized the system
clock can be reliably detected) and that validity check fails,
the @term{implementation} is strongly encouraged (but not required)
to signal an error @oftype{error} (rather than, for example, returning a
known-to-be-wrong value) that is @term{correctable} by allowing the user
to interactively set the correct time.
@node sleep
@syindexanchor{sleep, SYM}
@subsection sleep (Function)
@cindex sleep
@subsubheading Syntax:
@DefunWithValues{sleep, seconds, @nil{}}
@subsubheading Arguments and Values:
@param{seconds}---a non-negative @symbolref{real, SYM}.
@subsubheading Description:
Causes execution to cease and become dormant for approximately the
seconds of real time indicated by @param{seconds},
whereupon execution is resumed.
@subsubheading Examples:
@lisp
(sleep 1) @EV{} NIL
;; Actually, since SLEEP is permitted to use approximate timing,
;; this might not always yield true, but it will often enough that
;; we felt it to be a productive example of the intent.
(let ((then (get-universal-time))
(now (progn (sleep 10) (get-universal-time))))
(>= (- now then) 10))
@EV{} @term{true}
@end lisp
@subsubheading Side Effects:
Causes processing to pause.
@subsubheading Affected By:
The granularity of the scheduler.
@subsubheading Exceptional Situations:
@Shouldchecktype{seconds, a non-negative @symbolref{real, SYM}}
@node apropos; apropos-list
@syindexanchor{apropos, SYM}
@syindexanchor{apropos-list, SYM}
@subsection apropos, apropos-list (Function)
@cindex apropos-list
@cindex apropos
@subsubheading Syntax:
@DefunWithValues{apropos, string @opt{} package, @novalues{}}
@DefunWithValues{apropos-list, string @opt{} package, symbols}
@subsubheading Arguments and Values:
@param{string}---a @term{@symbolnamedesignator{}}.
@param{package}---a @term{package designator} or @nil{}.
@Default{@nil{}}
@param{symbols}---a @term{list} of @term{symbols}.
@subsubheading Description:
These functions search for @term{interned} @term{symbols}
whose @term{names} contain the substring @param{string}.
For @symbolref{apropos, SYM}, as each such @term{symbol} is found,
its name is printed on @term{standard output}.
In addition,
if such a @term{symbol} is defined as a @term{function} or @term{dynamic variable},
information about those definitions might also be printed.
For @symbolref{apropos-list, SYM},
no output occurs as the search proceeds;
instead a list of the matching @term{symbols} is returned when the search is complete.
If @param{package} is @term{non-nil},
only the @term{symbols} @term{accessible} in that @param{package} are searched;
otherwise all @term{symbols} @term{accessible} in any @term{package} are searched.
Because a @term{symbol} might be available
by way of more than one inheritance path,
@symbolref{apropos, SYM} might print information about the @term{same} @term{symbol} more than once,
or @symbolref{apropos-list, SYM} might return a @term{list} containing duplicate @term{symbols}.
Whether or not the search is case-sensitive is @term{implementation-defined}.
@subsubheading Affected By:
The set of @term{symbols} which are currently @term{interned}
in any @term{packages} being searched.
@symbolref{apropos, SYM} is also affected by @symbolref{*standard-output*, SYM}.
@node describe
@syindexanchor{describe, SYM}
@subsection describe (Function)
@cindex describe
@subsubheading Syntax:
@DefunWithValues{describe, object @opt{} stream, @novalues{}}
@subsubheading Arguments and Values:
@param{object}---an @term{object}.
@param{stream}---an @term{output} @term{stream designator}.
@Default{@term{standard output}}
@subsubheading Description:
@symbolref{describe, SYM} displays information about @param{object}
to @param{stream}.
For example, @symbolref{describe, SYM} of a @term{symbol} might show the
@term{symbol}'s value, its definition, and each of its properties.
@symbolref{describe, SYM} of a @term{float} might show the number's
internal representation in a way that is useful for tracking
down round-off errors. In all cases, however, the nature and format of the
output of @symbolref{describe, SYM} is @term{implementation-dependent}.
@symbolref{describe, SYM} can describe something that it finds inside the @param{object};
in such cases, a notational device such as increased indentation or positioning in a
table is typically used in order to visually distinguish such recursive descriptions
from descriptions of the argument @param{object}.
The actual act of describing the object is implemented by @symbolref{describe-object, SYM}.
@symbolref{describe, SYM} exists as an interface primarily to manage argument defaulting (including
conversion of arguments @symbolref{t, SC}@spc{}and @nil{}@spc{}into @term{stream} @term{objects}) and to inhibit
any return values from @symbolref{describe-object, SYM}.
@symbolref{describe, SYM} is not intended to be an interactive function. In a
@term{conforming implementation}, @symbolref{describe, SYM} must not, by default,
prompt for user input. User-defined methods for @symbolref{describe-object, SYM}
are likewise restricted.
@subsubheading Side Effects:
Output to @term{standard output} or @term{terminal I/O}.
@subsubheading Affected By:
@symbolref{*standard-output*, SYM} and @symbolref{*terminal-io*, SYM},
methods on @symbolref{describe-object, SYM} and @symbolref{print-object, SYM}
for @term{objects} having user-defined @term{classes}.
@subsubheading See Also:
@ref{inspect}, @ref{describe-object}
@node describe-object
@syindexanchor{describe-object, SYM}
@subsection describe-object (Standard Generic Function)
@cindex describe-object
@subsubheading Syntax:
@DefgenWithValues{describe-object, object stream, @term{implementation-dependent}}
@subsubheading Method Signatures:
describe-object (@param{object} standard-object) @param{stream}
@subsubheading Arguments and Values:
@param{object}---an @term{object}.
@param{stream}---a @term{stream}.
@subsubheading Description:
The generic function @symbolref{describe-object, SYM} prints a description of
@param{object} to a @param{stream}. @symbolref{describe-object, SYM} is called
by @symbolref{describe, SYM}; it must not be called by the user.
Each implementation is required to provide a @term{method} on
@theclass{standard-object} and @term{methods} on enough other
@term{classes} so as to ensure that there is always an applicable @term{method}.
Implementations are free to add @term{methods} for other @term{classes}.
Users can write @term{methods} for @symbolref{describe-object, SYM} for their
own @term{classes} if they do not wish to inherit an implementation-supplied
@term{method}.
@term{Methods} on @symbolref{describe-object, SYM} can recursively call
@symbolref{describe, SYM}. Indentation, depth limits, and circularity detection
are all taken care of automatically, provided that each @term{method}
handles exactly one level of structure and calls @symbolref{describe, SYM}
recursively if there are more structural levels. The consequences are
undefined if this rule is not obeyed.
In some implementations the @param{stream} argument passed to a
@symbolref{describe-object, SYM} method is not the original @param{stream}, but is
an intermediate @term{stream} that implements parts of @symbolref{describe, SYM}.
@term{Methods} should therefore not depend on the identity of this
@term{stream}.
@subsubheading Examples:
@lisp
(defclass spaceship ()
((captain :initarg :captain :accessor spaceship-captain)
(serial# :initarg :serial-number :accessor spaceship-serial-number)))
(defclass federation-starship (spaceship) ())
(defmethod describe-object ((s spaceship) stream)
(with-slots (captain serial#) s
(format stream "~&~S is a spaceship of type ~S,~
~%with ~A at the helm ~
and with serial number ~D.~%"
s (type-of s) captain serial#)))
(make-instance 'federation-starship
:captain "Rachel Garrett"
:serial-number "NCC-1701-C")
@EV{} #<FEDERATION-STARSHIP 26312465>
(describe *)
@OUT{} #<FEDERATION-STARSHIP 26312465> is a spaceship of type FEDERATION-STARSHIP,
@OUT{} with Rachel Garrett at the helm and with serial number NCC-1701-C.
@EV{} @novalues{}
@end lisp
@subsubheading See Also:
@ref{describe}
@subsubheading Notes:
The same implementation techniques that are applicable to @symbolref{print-object, SYM} are
applicable to @symbolref{describe-object, SYM}.
The reason for making the return values for @symbolref{describe-object, SYM}
unspecified is to avoid forcing users to include explicit @f{(values)}
in all of their @term{methods}. @symbolref{describe, SYM} takes care of that.
@node trace; untrace
@syindexanchor{trace, SYM}
@syindexanchor{untrace, SYM}
@subsection trace, untrace (Macro)
@cindex trace
@cindex untrace
@anchor{trace}
@subsubheading Syntax:
@DefmacWithValues{trace, @starparam{function-name}, trace-result}
@DefmacWithValues{untrace, @starparam{function-name}, untrace-result}
@subsubheading Arguments and Values:
@param{function-name}---a @term{function name}.
@param{trace-result}---@term{implementation-dependent},
unless no @param{function-names} are supplied,
in which case @param{trace-result} is a @term{list} of @term{function names}.
@param{untrace-result}---@term{implementation-dependent}.
@subsubheading Description:
@symbolref{trace, SYM} and @symbolref{untrace, SYM} control the invocation of the trace facility.
Invoking @symbolref{trace, SYM} with one or more @param{function-names} causes
the denoted @term{functions} to be ``traced.''
Whenever a traced @term{function} is invoked, information
about the call,
about the arguments passed,
and about any eventually returned values
is printed to @term{trace output}.
If @symbolref{trace, SYM} is used with no @param{function-names},
no tracing action is performed;
instead, a list of the @term{functions} currently being traced is returned.
Invoking @symbolref{untrace, SYM} with one or more function names causes those
functions to be ``untraced'' (@ie{} no longer traced).
If @symbolref{untrace, SYM} is used with no @param{function-names},
all @term{functions} currently being traced are untraced.
If a @term{function} to be traced has been open-coded
(@eg{} because it was declared @symbolref{inline, SYM}),
a call to that @term{function} might not produce trace output.
@subsubheading Examples:
@lisp
(defun fact (n) (if (zerop n) 1 (* n (fact (- n 1)))))
@EV{} FACT
(trace fact)
@EV{} (FACT)
;; Of course, the format of traced output is implementation-dependent.
(fact 3)
@OUT{} 1 Enter FACT 3
@OUT{} | 2 Enter FACT 2
@OUT{} | 3 Enter FACT 1
@OUT{} | | 4 Enter FACT 0
@OUT{} | | 4 Exit FACT 1
@OUT{} | 3 Exit FACT 1
@OUT{} | 2 Exit FACT 2
@OUT{} 1 Exit FACT 6
@EV{} 6
@end lisp
@subsubheading Side Effects:
Might change the definitions of the @term{functions} named by @param{function-names}.
@subsubheading Affected By:
Whether the functions named are defined or already being traced.
@subsubheading Exceptional Situations:
Tracing an already traced function,
or untracing a function not currently being traced,
should produce no harmful effects, but might signal a warning.
@subsubheading See Also:
@ref{*trace-output*},
@ref{step}
@subsubheading Notes:
@symbolref{trace, SYM} and @symbolref{untrace, SYM} may also accept additional
@term{implementation-dependent} argument formats. The format of the trace
output is @term{implementation-dependent}.
Although @symbolref{trace, SYM} can be extended to permit non-standard options,
@term{implementations} are nevertheless encouraged (but not required)
to warn about the use of syntax or options
that are neither specified by this standard
nor added as an extension by the @term{implementation},
since they could be symptomatic of typographical errors
or of reliance on features supported in @term{implementations}
other than the current @term{implementation}.
@node step
@syindexanchor{step, SYM}
@subsection step (Macro)
@cindex step
@subsubheading Syntax:
@DefmacWithValues{step, form, @starparam{result}}
@subsubheading Arguments and Values:
@param{form}---a @term{form}; @evalspecial{}.
@param{results}---the @term{values} returned by the @param{form}.
@subsubheading Description:
@symbolref{step, SYM} implements a debugging paradigm wherein the programmer
is allowed to @term{step} through the @term{evaluation} of a @term{form}.
The specific nature of the interaction,
including which I/O streams are used and
whether the stepping has lexical or dynamic scope,
is @term{implementation-defined}.
@symbolref{step, SYM} evaluates @param{form} in the current @term{environment}.
A call to @symbolref{step, SYM} can be compiled, but it is acceptable for an
implementation to interactively step through only those parts of the computation
that are interpreted.
It is technically permissible for a @term{conforming implementation}
to take no action at all other than normal @i{execution} of the @param{form}.
In such a situation,
@f{(step @i{form})}
is equivalent to, for example,
@f{(let () @i{form})}.
In implementations where this is the case, the associated documentation
should mention that fact.
@subsubheading See Also:
@ref{trace}
@subsubheading Notes:
@term{Implementations} are encouraged to respond to the typing of @f{?}
or the pressing of a ``help key'' by providing help including a list of
commands.
@node time (Macro)
@syindexanchor{time, SYM}
@subsection time (Macro)
@cindex time
@subsubheading Syntax:
@DefmacWithValues{time, form, @starparam{result}}
@subsubheading Arguments and Values:
@param{form}---a @term{form}; @evalspecial{}.
@param{results}---the @term{values} returned by the @param{form}.
@subsubheading Description:
@symbolref{time, SYM} evaluates @param{form} in the current @term{environment} (lexical and dynamic).
A call to @symbolref{time, SYM} can be compiled.
@symbolref{time, SYM} prints various timing data and other information to @term{trace output}.
The nature and format of the printed information is @term{implementation-defined}.
Implementations are encouraged to provide such information as
elapsed real time,
machine run time,
and storage management statistics.
@subsubheading Affected By:
The accuracy of the results depends, among other things, on the accuracy
of the corresponding functions provided by the underlying operating system.
The magnitude of the results may depend on
the hardware,
the operating system,
the lisp implementation,
and the state of the global environment.
Some specific issues which frequently affect the outcome are
hardware speed,
nature of the scheduler (if any),
number of competing processes (if any),
system paging,
whether the call is interpreted or compiled,
whether functions called are compiled,
the kind of garbage collector involved and whether it runs,
whether internal data structures (e.g., hash tables) are implicitly reorganized,
@etc{}.
@subsubheading See Also:
@ref{get-internal-real-time},
@ref{get-internal-run-time}
@subsubheading Notes:
In general, these timings are not guaranteed to be reliable enough for
marketing comparisons. Their value is primarily heuristic, for tuning
purposes.
For useful background information on the complicated issues involved in
interpreting timing results, see @GabrielBenchmarks{}.
@node internal-time-units-per-second
@syindexanchor{internal-time-units-per-second, SYM}
@subsection internal-time-units-per-second (Constant Variable)
@cindex internal-time-units-per-second
@subsubheading Constant Value:
A positive @term{integer}, the magnitude of which is @term{implementation-dependent}.
@subsubheading Description:
The number of @term{internal time units} in one second.
@subsubheading See Also:
@ref{get-internal-run-time}, @ref{get-internal-real-time}
@subsubheading Notes: