-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgcl.info-13
1404 lines (1002 loc) · 48.8 KB
/
gcl.info-13
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
This is Info file gcl.info, produced by Makeinfo-1.55 from the input file
gcl.texi.
This is a Texinfo GNU Common Lisp Manual based on the draft ANSI standard
for Common Lisp.
Copyright 1994 William F. Schelter
File: gcl.info, Node: values (Type Specifier), Next: eql (Type Specifier), Prev: or (Type Specifier), Up: Types and Classes Dictionary
values [Type Specifier]
---------------------------------------------------------------------------
Compound Type Specifier Kind::
..............................
Specializing.
Compound Type Specifier Syntax::
................................
(`values'{!value-typespec})
[Reviewer Note by Barmar: Missing &key]
value-typespec ::={typespec}* [&optional {typespec}*] [&rest typespec] [&allow-other-keys]
Compound Type Specifier Arguments::
...................................
typespec--a type specifier.
Compound Type Specifier Description::
.....................................
This type specifier can be used only as the value-type in a function type
specifier or a the special form. It is used to specify individual types
when multiple values are involved. The &optional and &rest markers can
appear in the value-type list; they indicate the parameter list of a
function that, when given to multiple-value-call along with the values,
would correctly receive those values.
The symbol * may not be among the value-types.
The symbol values is not valid as a type specifier; and, specifically, it
is not an abbreviation for (values).
File: gcl.info, Node: eql (Type Specifier), Next: coerce, Prev: values (Type Specifier), Up: Types and Classes Dictionary
eql [Type Specifier]
---------------------------------------------------------------------------
Compound Type Specifier Kind::
..............................
Combining.
Compound Type Specifier Syntax::
................................
(`eql'{object})
Compound Type Specifier Arguments::
...................................
object--an object.
Compound Type Specifier Description::
.....................................
Represents the type whose only element is object.
The argument object is required. The object can be *, but if so it
denotes itself (the symbol *) and does not represent an unspecified value.
The symbol eql is not valid as an atomic type specifier.
File: gcl.info, Node: coerce, Next: deftype, Prev: eql (Type Specifier), Up: Types and Classes Dictionary
coerce [Function]
---------------------------------------------------------------------------
`coerce' object result-type => result
Arguments and Values::
......................
object--an object.
result-type--a type specifier.
result--an object, of type result-type except in situations described in
*Note Rule of Canonical Representation for Complex Rationals::.
Description::
.............
Coerces the object to type result-type.
If object is already of type result-type, the object itself is returned,
regardless of whether it would have been possible in general to coerce an
object of some other type to result-type.
Otherwise, the object is coerced to type result-type according to the
following rules:
sequence
If the result-type is a recognizable subtype of list, and the object
is a sequence, then the result is a list that has the same elements
as object.
If the result-type is a recognizable subtype of vector, and the
object is a sequence, then the result is a vector that has the same
elements as object. If result-type is a specialized type, the result
has an actual array element type that is the result of upgrading the
element type part of that specialized type. If no element type is
specified, the element type defaults to t. If the implementation
cannot determine the element type, an error is signaled.
character
If the result-type is character and the object is a character
designator, the result is the character it denotes.
complex
If the result-type is complex and the object is a number, then the
result is obtained by constructing a complex whose real part is the
object and whose imaginary part is the result of coercing an integer
zero to the type of the object (using coerce). (If the real part is
a rational, however, then the result must be represented as a
rational rather than a complex; see *Note Rule of Canonical
Representation for Complex Rationals::. So, for example, (coerce 3
'complex) is permissible, but will return 3, which is not a complex.)
float
If the result-type is any of float, short-float, single-float,
double-float, long-float, and the object is a
real,
then the result is a float of type result-type which is equal in sign
and magnitude to the object to whatever degree of representational
precision is permitted by that float representation. (If the
result-type is float and object is not already a float, then the
result is a single float.)
function
If the result-type is function, and object is any
function name
that is fbound but that is globally defined neither as a macro name
nor as a special operator, then the result is the functional value of
object.
If the result-type is function, and object is a lambda expression,
then the result is a closure of object in the null lexical
environment.
t
Any object can be coerced to an object of type t. In this case, the
object is simply returned.
Examples::
..........
(coerce '(a b c) 'vector) => #(A B C)
(coerce 'a 'character) => #\A
(coerce 4.56 'complex) => #C(4.56 0.0)
(coerce 4.5s0 'complex) => #C(4.5s0 0.0s0)
(coerce 7/2 'complex) => 7/2
(coerce 0 'short-float) => 0.0s0
(coerce 3.5L0 'float) => 3.5L0
(coerce 7/2 'float) => 3.5
(coerce (cons 1 2) t) => (1 . 2)
All the following forms should signal an error:
(coerce '(a b c) '(vector * 4))
(coerce #(a b c) '(vector * 4))
(coerce '(a b c) '(vector * 2))
(coerce #(a b c) '(vector * 2))
(coerce "foo" '(string 2))
(coerce #(#\a #\b #\c) '(string 2))
(coerce '(0 1) '(simple-bit-vector 3))
Exceptional Situations::
........................
If a coercion is not possible, an error of type type-error is signaled.
(coerce x 'nil) always signals an error of type type-error.
An error of type error is signaled if the result-type is function but
object is a symbol that is not fbound or if the symbol names a macro or a
special operator.
An error of type type-error should be signaled if result-type specifies
the number of elements and object is of a different length.
See Also::
..........
*Note rational:: , *Note floor; ffloor; ceiling; fceiling; truncate;
ftruncate; round; fround:: , *Note char-code:: , *Note char-int::
Notes::
.......
Coercions from floats to rationals and from ratios to integers are not
provided because of rounding problems.
(coerce x 't) == (identity x) == x
File: gcl.info, Node: deftype, Next: subtypep, Prev: coerce, Up: Types and Classes Dictionary
deftype [Macro]
---------------------------------------------------------------------------
`deftype' name lambda-list [[{declaration}* | documentation]] {form}* =>
name
Arguments and Values::
......................
name--a symbol.
lambda-list--a deftype lambda list.
declaration--a declare expression; not evaluated.
documentation--a string; not evaluated.
form--a form.
Description::
.............
deftype defines a derived type specifier named name.
The meaning of the new type specifier is given in terms of a function
which expands the type specifier into another type specifier, which itself
will be expanded if it contains references to another derived type
specifier.
The newly defined type specifier may be referenced as a list of the form
(name arg_1 arg_2 ...)\/. The number of arguments must be appropriate to
the lambda-list. If the new type specifier takes no arguments, or if all
of its arguments are optional, the type specifier may be used as an atomic
type specifier.
The argument expressions to the type specifier, arg_1 ... arg_n, are not
evaluated. Instead, these literal objects become the objects to which
corresponding parameters become bound.
The body of the deftype form
(but not the lambda-list)
is
implicitly enclosed in a block named name,
and is evaluated as an implicit progn, returning a new type specifier.
The lexical environment of the body is the one which was current at the
time the deftype form was evaluated, augmented by the variables in the
lambda-list.
Recursive expansion of the type specifier returned as the expansion must
terminate, including the expansion of type specifiers which are nested
within the expansion.
The consequences are undefined if the result of fully expanding a type
specifier contains any circular structure, except within the objects
referred to by member and eql type specifiers.
Documentation is attached to name as a documentation string of kind type.
If a deftype form appears as a top level form, the compiler must ensure
that the name is recognized in subsequent type declarations. The
programmer must ensure that the body of a deftype form can be evaluated at
compile time if the name is referenced in subsequent type declarations.
If the expansion of a type specifier is not defined fully at compile time
(perhaps because it expands into an unknown type specifier or a satisfies
of a named function that isn't defined in the compile-time environment),
an implementation may ignore any references to this type in declarations
and/or signal a warning.
Examples::
..........
(defun equidimensional (a)
(or (< (array-rank a) 2)
(apply #'= (array-dimensions a)))) => EQUIDIMENSIONAL
(deftype square-matrix (&optional type size)
`(and (array ,type (,size ,size))
(satisfies equidimensional))) => SQUARE-MATRIX
See Also::
..........
declare, *Note defmacro:: , *Note documentation; (setf documentation):: ,
*Note Type Specifiers::, *Note Syntactic Interaction of Documentation
Strings and Declarations::
File: gcl.info, Node: subtypep, Next: type-of, Prev: deftype, Up: Types and Classes Dictionary
subtypep [Function]
---------------------------------------------------------------------------
`subtypep' type-1 type-2 &optional environment => subtype-p, valid-p
Arguments and Values::
......................
type-1--a type specifier.
type-2--a type specifier.
environment--an environment object. The default is nil, denoting the null
lexical environment and the current global environment.
subtype-p--a generalized boolean.
valid-p--a generalized boolean.
Description::
.............
If type-1 is a recognizable subtype of type-2, the first value is true.
Otherwise, the first value is false, indicating that either type-1 is not
a subtype of type-2, or else type-1 is a subtype of type-2 but is not a
recognizable subtype.
A second value is also returned indicating the `certainty' of the first
value. If this value is true, then the first value is an accurate
indication of the subtype relationship. (The second value is always true
when the first value is true.)
Figure 4-9 summarizes the possible combinations of values that might
result.
Value 1 Value 2 Meaning
true true type-1 is definitely a subtype of type-2.
false true type-1 is definitely not a subtype of type-2.
false false subtypep could not determine the relationship,
so type-1 might or might not be a subtype of type-2.
Figure 4-9: Result possibilities for subtypep
subtypep is permitted to return the values false and false only when at
least one argument involves one of these type specifiers: and, eql, the
list form of function, member, not, or, satisfies, or values. (A type
specifier `involves' such a symbol if, after being type expanded, it
contains that symbol in a position that would call for its meaning as a
type specifier to be used.) One consequence of this is that if neither
type-1 nor type-2 involves any of these type specifiers, then subtypep is
obliged to determine the relationship accurately. In particular, subtypep
returns the values true and true if the arguments are equal and do not
involve any of these type specifiers.
subtypep never returns a second value of nil when both type-1 and type-2
involve only the names in Figure~4-2, or names of types defined by
defstruct, define-condition, or defclass, or derived types that expand
into only those names. While type specifiers listed in Figure~4-2 and
names of defclass and defstruct can in some cases be implemented as
derived types, subtypep regards them as primitive.
The relationships between types reflected by subtypep are those specific
to the particular implementation. For example, if an implementation
supports only a single type of floating-point numbers, in that
implementation (subtypep 'float 'long-float) returns the values true and
true (since the two types are identical).
For all T1 and T2 other than *, (array T1) and (array T2) are two
different type specifiers that always refer to the same sets of things if
and only if they refer to arrays of exactly the same specialized
representation, i.e., if (upgraded-array-element-type 'T1) and
(upgraded-array-element-type 'T2) return two different type specifiers
that always refer to the same sets of objects. This is another way of
saying that `(array type-specifier) and `(array
,(upgraded-array-element-type 'type-specifier)) refer to the same set of
specialized array representations. For all T1 and T2 other than *, the
intersection of (array T1) and (array T2) is the empty set if and only if
they refer to arrays of different, distinct specialized representations.
Therefore,
(subtypep '(array T1) '(array T2)) => true
if and only if
(upgraded-array-element-type 'T1) and
(upgraded-array-element-type 'T2)
return two different type specifiers that always refer to the same sets of
objects.
For all type-specifiers T1 and T2 other than *,
(subtypep '(complex T1) '(complex T2)) => true, true
if:
1.
T1 is a subtype of T2, or
2.
(upgraded-complex-part-type 'T1) and (upgraded-complex-part-type 'T2)
return two different type specifiers that always refer to the same
sets of objects; in this case, (complex T1) and (complex T2) both
refer to the same specialized representation.
The values are false and true otherwise.
The form
(subtypep '(complex single-float) '(complex float))
must return true in all implementations, but
(subtypep '(array single-float) '(array float))
returns true only in implementations that do not have a specialized array
representation for single floats distinct from that for other floats.
Examples::
..........
(subtypep 'compiled-function 'function) => true, true
(subtypep 'null 'list) => true, true
(subtypep 'null 'symbol) => true, true
(subtypep 'integer 'string) => false, true
(subtypep '(satisfies dummy) nil) => false, implementation-dependent
(subtypep '(integer 1 3) '(integer 1 4)) => true, true
(subtypep '(integer (0) (0)) 'nil) => true, true
(subtypep 'nil '(integer (0) (0))) => true, true
(subtypep '(integer (0) (0)) '(member)) => true, true ;or false, false
(subtypep '(member) 'nil) => true, true ;or false, false
(subtypep 'nil '(member)) => true, true ;or false, false
Let <aet-x> and <aet-y> be two distinct type specifiers that do not always
refer to the same sets of objects in a given implementation, but for which
make-array, will return an object of the same array type.
Thus, in each case,
(subtypep (array-element-type (make-array 0 :element-type '<aet-x>))
(array-element-type (make-array 0 :element-type '<aet-y>)))
=> true, true
(subtypep (array-element-type (make-array 0 :element-type '<aet-y>))
(array-element-type (make-array 0 :element-type '<aet-x>)))
=> true, true
If (array <aet-x>) and (array <aet-y>) are different names for exactly
the same set of objects, these names should always refer to the same sets
of objects. That implies that the following set of tests are also true:
(subtypep '(array <aet-x>) '(array <aet-y>)) => true, true
(subtypep '(array <aet-y>) '(array <aet-x>)) => true, true
See Also::
..........
*Note Types::
Notes::
.......
The small differences between the subtypep specification for the array and
complex types are necessary because there is no creation function for
complexes which allows the specification of the resultant part type
independently of the actual types of the parts. Thus in the case of the
type complex, the actual type of the parts is referred to, although a
number can be a member of more than one type. For example, 17 is of type
(mod 18) as well as type (mod 256) and type integer; and 2.3f5 is of type
single-float as well as type float.
File: gcl.info, Node: type-of, Next: typep, Prev: subtypep, Up: Types and Classes Dictionary
type-of [Function]
---------------------------------------------------------------------------
`type-of' object => typespec
Arguments and Values::
......................
object--an object.
typespec--a type specifier.
Description::
.............
Returns a type specifier, typespec, for a type that has the object as an
element. The typespec satisfies the following:
1.
For any object that is an element of some built-in type:
a.
the type returned is a recognizable subtype of that built-in
type.
b.
the type returned does not involve and, eql, member, not, or,
satisfies, or values.
2.
For all objects, (typep object (type-of object)) returns true.
Implicit in this is that type specifiers which are not valid for use
with typep, such as the list form of the function type specifier, are
never returned by type-of.
3.
The type returned by type-of is always a recognizable subtype of the
class returned by class-of. That is,
(subtypep (type-of object) (class-of object)) => true, true
4.
For objects of metaclass structure-class or standard-class,
and for conditions,
type-of returns the proper name of the class returned by class-of if
it has a proper name, and otherwise returns the class itself. In
particular, for objects created by the constructor function of a
structure defined with defstruct without a :type option, type-of
returns the structure name; and for objects created by
make-condition, the typespec is the name of the condition type.
5.
For each of the types short-float, single-float, double-float, or
long-float of which the object is an element, the typespec is a
recognizable subtype of that type.
Examples::
..........
(type-of 'a) => SYMBOL
(type-of '(1 . 2))
=> CONS
OR=> (CONS FIXNUM FIXNUM)
(type-of #c(0 1))
=> COMPLEX
OR=> (COMPLEX INTEGER)
(defstruct temp-struct x y z) => TEMP-STRUCT
(type-of (make-temp-struct)) => TEMP-STRUCT
(type-of "abc")
=> STRING
OR=> (STRING 3)
(subtypep (type-of "abc") 'string) => true, true
(type-of (expt 2 40))
=> BIGNUM
OR=> INTEGER
OR=> (INTEGER 1099511627776 1099511627776)
OR=> SYSTEM::TWO-WORD-BIGNUM
OR=> FIXNUM
(subtypep (type-of 112312) 'integer) => true, true
(defvar *foo* (make-array 5 :element-type t)) => *FOO*
(class-name (class-of *foo*)) => VECTOR
(type-of *foo*)
=> VECTOR
OR=> (VECTOR T 5)
See Also::
..........
*Note array-element-type:: , *Note class-of:: , *Note defstruct:: , *Note
typecase; ctypecase; etypecase:: , *Note typep:: , *Note Types::
Notes::
.......
Implementors are encouraged to arrange for type-of to return
a portable value.
File: gcl.info, Node: typep, Next: type-error, Prev: type-of, Up: Types and Classes Dictionary
typep [Function]
---------------------------------------------------------------------------
`typep' object type-specifier &optional environment =>
generalized-boolean
Arguments and Values::
......................
object--an object.
type-specifier--any type specifier except
values, or a type specifier list whose first element is either function or
values.
environment--an environment object. The default is nil, denoting the null
lexical environment and the and current global environment.
generalized-boolean--a generalized boolean.
Description::
.............
Returns true if object is of the type specified by type-specifier;
otherwise, returns false.
A type-specifier of the form (satisfies fn) is handled by applying the
function fn to object.
(typep object '(array type-specifier)), where type-specifier is not *,
returns true if and only if object is an array that could be the result of
supplying type-specifier as the :element-type argument to make-array.
(array *) refers to all arrays regardless of element type, while (array
type-specifier) refers only to those arrays that can result from giving
type-specifier as the :element-type argument to make-array. A similar
interpretation applies to (simple-array type-specifier) and (vector
type-specifier). See *Note Array Upgrading::.
(typep object '(complex type-specifier)) returns true for all complex
numbers that can result from giving numbers of type type-specifier to the
function complex, plus all other complex numbers of the same specialized
representation. Both the real and the imaginary parts of any such complex
number must satisfy:
(typep realpart 'type-specifier)
(typep imagpart 'type-specifier)
See the function upgraded-complex-part-type.
Examples::
..........
(typep 12 'integer) => true
(typep (1+ most-positive-fixnum) 'fixnum) => false
(typep nil t) => true
(typep nil nil) => false
(typep 1 '(mod 2)) => true
(typep #c(1 1) '(complex (eql 1))) => true
;; To understand this next example, you might need to refer to
;; *Note Rule of Canonical Representation for Complex Rationals::.
(typep #c(0 0) '(complex (eql 0))) => false
Let A_x and A_y be two type specifiers that denote different types, but
for which
(upgraded-array-element-type 'A_x)
and
(upgraded-array-element-type 'A_y)
denote the same type. Notice that
(typep (make-array 0 :element-type 'A_x) '(array A_x)) => true
(typep (make-array 0 :element-type 'A_y) '(array A_y)) => true
(typep (make-array 0 :element-type 'A_x) '(array A_y)) => true
(typep (make-array 0 :element-type 'A_y) '(array A_x)) => true
Exceptional Situations::
........................
An error of type error is signaled if type-specifier is values, or a type
specifier list whose first element is either function or values.
The consequences are undefined if the type-specifier is not a type
specifier.
See Also::
..........
*Note type-of:: , *Note upgraded-array-element-type:: , *Note
upgraded-complex-part-type:: , *Note Type Specifiers::
Notes::
.......
Implementations are encouraged to recognize and optimize the case of
(typep x (the class y)), since it does not involve any need for expansion
of deftype information at runtime.
File: gcl.info, Node: type-error, Next: type-error-datum, Prev: typep, Up: Types and Classes Dictionary
type-error [Condition Type]
---------------------------------------------------------------------------
Class Precedence List::
.......................
type-error, error, serious-condition, condition, t
Description::
.............
The type type-error represents a situation in which an object is not of
the expected type. The "offending datum" and "expected type" are
initialized by the initialization arguments named :datum and
:expected-type to make-condition, and are accessed by the functions
type-error-datum and type-error-expected-type.
See Also::
..........
*Note type-error-datum; type-error-expected-type:: ,
type-error-expected-type
File: gcl.info, Node: type-error-datum, Next: simple-type-error, Prev: type-error, Up: Types and Classes Dictionary
type-error-datum, type-error-expected-type [Function]
---------------------------------------------------------------------------
`type-error-datum' condition => datum
`type-error-expected-type' condition => expected-type
Arguments and Values::
......................
condition--a condition of type type-error.
datum--an object.
expected-type--a type specifier.
Description::
.............
type-error-datum returns the offending datum in the situation represented
by the condition.
type-error-expected-type returns the expected type of the offending datum
in the situation represented by the condition.
Examples::
..........
(defun fix-digits (condition)
(check-type condition type-error)
(let* ((digits '(zero one two three four
five six seven eight nine))
(val (position (type-error-datum condition) digits)))
(if (and val (subtypep 'fixnum (type-error-expected-type condition)))
(store-value 7))))
(defun foo (x)
(handler-bind ((type-error #'fix-digits))
(check-type x number)
(+ x 3)))
(foo 'seven)
=> 10
See Also::
..........
type-error, *Note Conditions::
File: gcl.info, Node: simple-type-error, Prev: type-error-datum, Up: Types and Classes Dictionary
simple-type-error [Condition Type]
---------------------------------------------------------------------------
Class Precedence List::
.......................
simple-type-error, simple-condition, type-error, error, serious-condition,
condition, t
Description::
.............
Conditions of type simple-type-error are like conditions of type
type-error, except that they provide an alternate mechanism for specifying
how the condition is to be reported; see the type simple-condition.
See Also::
..........
simple-condition,
*Note simple-condition-format-control; simple-condition-format-arguments::
,
simple-condition-format-arguments, *Note type-error-datum;
type-error-expected-type:: , type-error-expected-type
File: gcl.info, Node: Data and Control Flow, Next: Iteration, Prev: Types and Classes, Up: Top
Data and Control Flow
*********************
* Menu:
* Generalized Reference::
* Transfer of Control to an Exit Point::
* Data and Control Flow Dictionary::
File: gcl.info, Node: Generalized Reference, Next: Transfer of Control to an Exit Point, Prev: Data and Control Flow, Up: Data and Control Flow
Generalized Reference
=====================
* Menu:
* Overview of Places and Generalized Reference::
* Kinds of Places::
* Treatment of Other Macros Based on SETF::
File: gcl.info, Node: Overview of Places and Generalized Reference, Next: Kinds of Places, Prev: Generalized Reference, Up: Generalized Reference
Overview of Places and Generalized Reference
--------------------------------------------
A generalized reference is the use of a form, sometimes called a place ,
as if it were a variable that could be read and written. The value of a
place is the object to which the place form evaluates. The value of a
place can be changed by using setf. The concept of binding a place is not
defined in Common Lisp, but an implementation is permitted to extend the
language by defining this concept.
Figure 5-1 contains examples of the use of setf. Note that the values
returned by evaluating the forms in column two are not necessarily the
same as those obtained by evaluating the forms in column three. In
general, the exact macro expansion of a setf form is not guaranteed and
can even be implementation-dependent; all that is guaranteed is that the
expansion is an update form that works for that particular implementation,
that the left-to-right evaluation of subforms is preserved, and that the
ultimate result of evaluating setf is the value or values being stored.
Access function Update Function Update using setf
x (setq x datum) (setf x datum)
(car x) (rplaca x datum) (setf (car x) datum)
(symbol-value x) (set x datum) (setf (symbol-value x) datum)
Figure 5-1: Examples of setf
Figure 5-2 shows operators relating to places and generalized reference.
assert defsetf push
ccase get-setf-expansion remf
ctypecase getf rotatef
decf incf setf
define-modify-macro pop shiftf
define-setf-expander psetf
Figure 5-2: Operators relating to places and generalized reference.
Some of the operators above manipulate places and some manipulate setf
expanders. A setf expansion can be derived from any place.
New setf expanders can be defined by using defsetf and
define-setf-expander.
* Menu:
* Evaluation of Subforms to Places::
* Examples of Evaluation of Subforms to Places::
* Setf Expansions::
* Examples of Setf Expansions::
File: gcl.info, Node: Evaluation of Subforms to Places, Next: Examples of Evaluation of Subforms to Places, Prev: Overview of Places and Generalized Reference, Up: Overview of Places and Generalized Reference
Evaluation of Subforms to Places
................................
The following rules apply to the evaluation of subforms in a place:
1.
The evaluation ordering of subforms within a place is determined by
the order specified by the second value returned by
get-setf-expansion.
For all places defined by this specification (e.g., getf, ldb, ...),
this order of evaluation is left-to-right.
When a place is derived from a macro expansion, this rule is applied
after the macro is expanded to find the appropriate place.
Places defined by using defmacro or
define-setf-expander
use the evaluation order defined by those definitions. For example,
consider the following:
(defmacro wrong-order (x y) `(getf ,y ,x))
This following form evaluates place2 first and then place1 because
that is the order they are evaluated in the macro expansion:
(push value (wrong-order place1 place2))
2.
For the macros that manipulate places (push, pushnew, remf, incf,
decf, shiftf, rotatef, psetf, setf, pop, and those defined by
define-modify-macro) the subforms of the macro call are evaluated
exactly once in left-to-right order, with the subforms of the places
evaluated in the order specified in (1).
push, pushnew, remf, incf, decf, shiftf, rotatef, psetf, pop evaluate
all subforms before modifying any of the place locations. setf (in
the case when setf has more than two arguments) performs its
operation on each pair in sequence. For example, in
(setf place1 value1 place2 value2 ...)
the subforms of place1 and value1 are evaluated, the location
specified by place1 is modified to contain the value returned by
value1, and then the rest of the setf form is processed in a like
manner.
3.
For check-type, ctypecase, and ccase, subforms of the place are
evaluated once as in (1), but might be evaluated again if the type
check fails in the case of check-type or none of the cases hold in
ctypecase and ccase.
4.
For assert, the order of evaluation of the generalized references is
not specified.
Rules 2, 3 and 4 cover all standardized macros that manipulate places.
File: gcl.info, Node: Examples of Evaluation of Subforms to Places, Next: Setf Expansions, Prev: Evaluation of Subforms to Places, Up: Overview of Places and Generalized Reference
Examples of Evaluation of Subforms to Places
............................................
(let ((ref2 (list '())))
(push (progn (princ "1") 'ref-1)
(car (progn (princ "2") ref2))))
|> 12
=> (REF1)
(let (x)
(push (setq x (list 'a))
(car (setq x (list 'b))))
x)
=> (((A) . B))
push first evaluates (setq x (list 'a)) => (a), then evaluates (setq x
(list 'b)) => (b), then modifies the car of this latest value to be ((a)
. b).
File: gcl.info, Node: Setf Expansions, Next: Examples of Setf Expansions, Prev: Examples of Evaluation of Subforms to Places, Up: Overview of Places and Generalized Reference
Setf Expansions
...............
Sometimes it is possible to avoid evaluating subforms of a place multiple
times or in the wrong order. A
setf expansion
for a given access form can be expressed as an ordered collection of five
objects:
List of temporary variables
a list of symbols naming temporary variables to be bound
sequentially, as if by let*, to values resulting from value forms.
List of value forms
a list of forms (typically, subforms of the place) which when
evaluated yield the values to which the corresponding temporary
variables should be bound.
List of store variables
a list of symbols naming temporary store variables which are to hold
the new values that will be assigned to the place.
Storing form
a form which can reference both the temporary and the store variables,
and which changes the value of the place and guarantees to return as
its values the values of the store variables, which are the correct
values for setf to return.
Accessing form