File: objects.texi

package info (click to toggle)
xemacs21 21.4.24-12
  • links: PTS
  • area: main
  • in suites: sid
  • size: 34,212 kB
  • sloc: ansic: 243,882; lisp: 94,071; cpp: 5,726; sh: 4,406; perl: 1,096; cs: 775; makefile: 765; python: 279; asm: 248; lex: 119; yacc: 95; sed: 22; csh: 9
file content (2367 lines) | stat: -rw-r--r-- 83,576 bytes parent folder | download | duplicates (5)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
@c -*-texinfo-*-
@c This is part of the XEmacs Lisp Reference Manual.
@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
@c See the file lispref.texi for copying conditions.
@setfilename ../../info/objects.info
@node Lisp Data Types, Numbers, Packaging, Top
@chapter Lisp Data Types
@cindex object
@cindex Lisp object
@cindex type
@cindex data type

  A Lisp @dfn{object} is a piece of data used and manipulated by Lisp
programs.  For our purposes, a @dfn{type} or @dfn{data type} is a set of
possible objects.

  Every object belongs to at least one type.  Objects of the same type
have similar structures and may usually be used in the same contexts.
Types can overlap, and objects can belong to two or more types.
Consequently, we can ask whether an object belongs to a particular type,
but not for ``the'' type of an object.

@cindex primitive type
  A few fundamental object types are built into XEmacs.  These, from
which all other types are constructed, are called @dfn{primitive types}.
Each object belongs to one and only one primitive type.  These types
include @dfn{integer}, @dfn{character} (starting with XEmacs 20.0),
@dfn{float}, @dfn{cons}, @dfn{symbol}, @dfn{string}, @dfn{vector},
@dfn{bit-vector}, @dfn{subr}, @dfn{compiled-function}, @dfn{hash-table},
@dfn{range-table}, @dfn{char-table}, @dfn{weak-list}, and several
special types, such as @dfn{buffer}, that are related to editing.
(@xref{Editing Types}.)

  Each primitive type has a corresponding Lisp function that checks
whether an object is a member of that type.

  Note that Lisp is unlike many other languages in that Lisp objects are
@dfn{self-typing}: the primitive type of the object is implicit in the
object itself.  For example, if an object is a vector, nothing can treat
it as a number; Lisp knows it is a vector, not a number.

  In most languages, the programmer must declare the data type of each
variable, and the type is known by the compiler but not represented in
the data.  Such type declarations do not exist in XEmacs Lisp.  A Lisp
variable can have any type of value, and it remembers whatever value
you store in it, type and all.

  This chapter describes the purpose, printed representation, and read
syntax of each of the standard types in Emacs Lisp.  Details on how
to use these types can be found in later chapters.

@menu
* Printed Representation::      How Lisp objects are represented as text.
* Comments::                    Comments and their formatting conventions.
* Primitive Types::             List of all primitive types in XEmacs.
* Programming Types::           Types found in all Lisp systems.
* Editing Types::               Types specific to XEmacs.
* Window-System Types::         Types specific to windowing systems.
* Type Predicates::             Tests related to types.
* Equality Predicates::         Tests of equality between any two objects.
@end menu

@node Printed Representation, Comments, Lisp Data Types, Lisp Data Types
@section Printed Representation and Read Syntax
@cindex printed representation
@cindex read syntax

  The @dfn{printed representation} of an object is the format of the
output generated by the Lisp printer (the function @code{prin1}) for
that object.  The @dfn{read syntax} of an object is the format of the
input accepted by the Lisp reader (the function @code{read}) for that
object.  Most objects have more than one possible read syntax.  Some
types of object have no read syntax; except for these cases, the printed
representation of an object is also a read syntax for it.

  In other languages, an expression is text; it has no other form.  In
Lisp, an expression is primarily a Lisp object and only secondarily the
text that is the object's read syntax.  Often there is no need to
emphasize this distinction, but you must keep it in the back of your
mind, or you will occasionally be very confused.

@cindex hash notation
  Every type has a printed representation.  Some types have no read
syntax, since it may not make sense to enter objects of these types
directly in a Lisp program.  For example, the buffer type does not have
a read syntax.  Objects of these types are printed in @dfn{hash
notation}: the characters @samp{#<} followed by a descriptive string
(typically the type name followed by the name of the object), and closed
with a matching @samp{>}.  Hash notation cannot be read at all, so the
Lisp reader signals the error @code{invalid-read-syntax} whenever it
encounters @samp{#<}.
@kindex invalid-read-syntax

@example
(current-buffer)
     @result{} #<buffer "objects.texi">
@end example

  When you evaluate an expression interactively, the Lisp interpreter
first reads the textual representation of it, producing a Lisp object,
and then evaluates that object (@pxref{Evaluation}).  However,
evaluation and reading are separate activities.  Reading returns the
Lisp object represented by the text that is read; the object may or may
not be evaluated later.  @xref{Input Functions}, for a description of
@code{read}, the basic function for reading objects.

@node Comments, Primitive Types, Printed Representation, Lisp Data Types
@section Comments
@cindex comments
@cindex @samp{;} in comment

  A @dfn{comment} is text that is written in a program only for the sake
of humans that read the program, and that has no effect on the meaning
of the program.  In Lisp, a semicolon (@samp{;}) starts a comment if it
is not within a string or character constant.  The comment continues to
the end of line.  The Lisp reader discards comments; they do not become
part of the Lisp objects which represent the program within the Lisp
system.

  The @samp{#@@@var{count}} construct, which skips the next @var{count}
characters, is useful for program-generated comments containing binary
data.  The XEmacs Lisp byte compiler uses this in its output files
(@pxref{Byte Compilation}).  It isn't meant for source files, however.

  @xref{Comment Tips}, for conventions for formatting comments.

@node Primitive Types, Programming Types, Comments, Lisp Data Types
@section Primitive Types
@cindex primitive types

  For reference, here is a list of all the primitive types that may
exist in XEmacs.  Note that some of these types may not exist
in some XEmacs executables; that depends on the options that
XEmacs was configured with.

@itemize @bullet
@item
bit-vector
@item
buffer
@item
char-table
@item
character
@item
charset
@item
coding-system
@item
cons
@item
color-instance
@item
compiled-function
@item
console
@item
database
@item
device
@item
event
@item
extent
@item
face
@item
float
@item
font-instance
@item
frame
@item
glyph
@item
hash-table
@item
image-instance
@item
integer
@item
keymap
@item
marker
@item
process
@item
range-table
@item
specifier
@item
string
@item
subr
@item
subwindow
@item
symbol
@item
toolbar-button
@item
tooltalk-message
@item
tooltalk-pattern
@item
vector
@item
weak-list
@item
window
@item
window-configuration
@item
x-resource
@end itemize

In addition, the following special types are created internally
but will never be seen by Lisp code.  You may encounter them,
however, if you are debugging XEmacs.  The printed representation
of these objects begins @samp{#<INTERNAL EMACS BUG}, which indicates
to the Lisp programmer that he has found an internal bug in XEmacs
if he ever encounters any of these objects.

@itemize @bullet
@item
char-table-entry
@item
command-builder
@item
extent-auxiliary
@item
extent-info
@item
lcrecord-list
@item
lstream
@item
opaque
@item
opaque-list
@item
popup-data
@item
symbol-value-buffer-local
@item
symbol-value-forward
@item
symbol-value-lisp-magic
@item
symbol-value-varalias
@item
toolbar-data
@end itemize

@node Programming Types, Editing Types, Primitive Types, Lisp Data Types
@section Programming Types
@cindex programming types

  There are two general categories of types in XEmacs Lisp: those having
to do with Lisp programming, and those having to do with editing.  The
former exist in many Lisp implementations, in one form or another.  The
latter are unique to XEmacs Lisp.

@menu
* Integer Type::        Numbers without fractional parts.
* Floating Point Type:: Numbers with fractional parts and with a large range.
* Character Type::      The representation of letters, numbers and
                        control characters.
* Symbol Type::         A multi-use object that refers to a function,
                        variable, or property list, and has a unique identity.
* Sequence Type::       Both lists and arrays are classified as sequences.
* Cons Cell Type::      Cons cells, and lists (which are made from cons cells).
* Array Type::          Arrays include strings and vectors.
* String Type::         An (efficient) array of characters.
* Vector Type::         One-dimensional arrays.
* Bit Vector Type::     An (efficient) array of bits.
* Function Type::       A piece of executable code you can call from elsewhere.
* Macro Type::          A method of expanding an expression into another
                          expression, more fundamental but less pretty.
* Primitive Function Type::     A function written in C, callable from Lisp.
* Compiled-Function Type::      A function written in Lisp, then compiled.
* Autoload Type::       A type used for automatically loading seldom-used
                        functions.
* Char Table Type::     A mapping from characters to Lisp objects.
* Hash Table Type::     A fast mapping between Lisp objects.
* Range Table Type::    A mapping from ranges of integers to Lisp objects.
* Weak List Type::      A list with special garbage-collection properties.
@end menu

@node Integer Type, Floating Point Type, Programming Types, Programming Types
@subsection Integer Type

  The range of values for integers in XEmacs Lisp is @minus{}134217728 to
134217727 (28 bits; i.e.,
@ifinfo
-2**27
@end ifinfo
@tex
$-2^{27}$
@end tex
to
@ifinfo
2**27 - 1)
@end ifinfo
@tex
$2^{28}-1$)
@end tex
on most machines.  (Some machines, in particular 64-bit machines such as
the DEC Alpha, may provide a wider range.)  It is important to note that
the XEmacs Lisp arithmetic functions do not check for overflow.  Thus
@code{(1+ 134217727)} is @minus{}134217728 on most machines. (However,
you @emph{will} get an error if you attempt to read an out-of-range
number using the Lisp reader.)

  The read syntax for integers is a sequence of (base ten) digits with
an optional sign at the beginning. (The printed representation produced
by the Lisp interpreter never has a leading @samp{+}.)

@example
@group
-1               ; @r{The integer -1.}
1                ; @r{The integer 1.}
+1               ; @r{Also the integer 1.}
268435457        ; @r{Causes an error on a 28-bit implementation.}
@end group
@end example

  @xref{Numbers}, for more information.

@node Floating Point Type, Character Type, Integer Type, Programming Types
@subsection Floating Point Type

  XEmacs supports floating point numbers.  The precise range of floating
point numbers is machine-specific.

  The printed representation for floating point numbers requires either
a decimal point (with at least one digit following), an exponent, or
both.  For example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2},
@samp{1.5e3}, and @samp{.15e4} are five ways of writing a floating point
number whose value is 1500.  They are all equivalent.

  @xref{Numbers}, for more information.

@node Character Type, Symbol Type, Floating Point Type, Programming Types
@subsection Character Type
@cindex @sc{ascii} character codes
@cindex char-int confoundance disease

  In XEmacs version 19, and in all versions of FSF GNU Emacs, a
@dfn{character} in XEmacs Lisp is nothing more than an integer.
This is yet another holdover from XEmacs Lisp's derivation from
vintage-1980 Lisps; modern versions of Lisp consider this equivalence
a bad idea, and have separate character types.  In XEmacs version 20,
the modern convention is followed, and characters are their own
primitive types. (This change was necessary in order for @sc{mule},
i.e. Asian-language, support to be correctly implemented.)

  Even in XEmacs version 20, remnants of the equivalence between
characters and integers still exist; this is termed the @dfn{char-int
confoundance disease}.  In particular, many functions such as @code{eq},
@code{equal}, and @code{memq} have equivalent functions (@code{old-eq},
@code{old-equal}, @code{old-memq}, etc.) that pretend like characters
are integers are the same.  Byte code compiled under any version 19
Emacs will have all such functions mapped to their @code{old-} equivalents
when the byte code is read into XEmacs 20.  This is to preserve
compatibility---Emacs 19 converts all constant characters to the equivalent
integer during byte-compilation, and thus there is no other way to preserve
byte-code compatibility even if the code has specifically been written
with the distinction between characters and integers in mind.

  Every character has an equivalent integer, called the @dfn{character
code}.  For example, the character @kbd{A} is represented as the
@w{integer 65}, following the standard @sc{ascii} representation of
characters.  If XEmacs was not compiled with @sc{mule} support, the
range of this integer will always be 0 to 255---eight bits, or one
byte. (Integers outside this range are accepted but silently truncated;
however, you should most decidedly @emph{not} rely on this, because it
will not work under XEmacs with @sc{mule} support.)  When @sc{mule}
support is present, the range of character codes is much
larger. (Currently, 19 bits are used.)

  FSF GNU Emacs uses kludgy character codes above 255 to represent
keyboard input of @sc{ascii} characters in combination with certain
modifiers.  XEmacs does not use this (a more general mechanism is
used that does not distinguish between @sc{ascii} keys and other
keys), so you will never find character codes above 255 in a
non-@sc{mule} XEmacs.

  Individual characters are not often used in programs.  It is far more
common to work with @emph{strings}, which are sequences composed of
characters.  @xref{String Type}.

@cindex read syntax for characters
@cindex printed representation for characters
@cindex syntax for characters

  The read syntax for characters begins with a question mark, followed
by the character (if it's printable) or some symbolic representation of
it.  In XEmacs 20, where characters are their own type, this is also the
print representation.  In XEmacs 19, however, where characters are
really integers, the printed representation of a character is a decimal
number.  This is also a possible read syntax for a character, but
writing characters that way in Lisp programs is a very bad idea.  You
should @emph{always} use the special read syntax formats that XEmacs Lisp
provides for characters.

  The usual read syntax for alphanumeric characters is a question mark
followed by the character; thus, @samp{?A} for the character
@kbd{A}, @samp{?B} for the character @kbd{B}, and @samp{?a} for the
character @kbd{a}.

  For example:

@example
;; @r{Under XEmacs 20:}
?Q @result{} ?Q    ?q @result{} ?q
(char-int ?Q) @result{} 81
;; @r{Under XEmacs 19:}
?Q @result{} 81     ?q @result{} 113
@end example

  You can use the same syntax for punctuation characters, but it is
often a good idea to add a @samp{\} so that the Emacs commands for
editing Lisp code don't get confused.  For example, @samp{?\ } is the
way to write the space character.  If the character is @samp{\}, you
@emph{must} use a second @samp{\} to quote it: @samp{?\\}.  XEmacs 20
always prints punctuation characters with a @samp{\} in front of them,
to avoid confusion.

@cindex whitespace
@cindex bell character
@cindex @samp{\a}
@cindex backspace
@cindex @samp{\b}
@cindex tab
@cindex @samp{\t}
@cindex vertical tab
@cindex @samp{\v}
@cindex formfeed
@cindex @samp{\f}
@cindex newline
@cindex @samp{\n}
@cindex return
@cindex @samp{\r}
@cindex escape
@cindex @samp{\e}
  You can express the characters Control-g, backspace, tab, newline,
vertical tab, formfeed, return, and escape as @samp{?\a}, @samp{?\b},
@samp{?\t}, @samp{?\n}, @samp{?\v}, @samp{?\f}, @samp{?\r}, @samp{?\e},
respectively.  Their character codes are 7, 8, 9, 10, 11, 12, 13, and 27
in decimal.  Thus,

@example
;; @r{Under XEmacs 20:}
?\a @result{} ?\^G              ; @r{@kbd{C-g}}
(char-int ?\a) @result{} 7
?\b @result{} ?\^H              ; @r{backspace, @key{BS}, @kbd{C-h}}
(char-int ?\b) @result{} 8
?\t @result{} ?\t               ; @r{tab, @key{TAB}, @kbd{C-i}}
(char-int ?\t) @result{} 9
?\n @result{} ?\n               ; @r{newline, @key{LFD}, @kbd{C-j}}
?\v @result{} ?\^K              ; @r{vertical tab, @kbd{C-k}}
?\f @result{} ?\^L              ; @r{formfeed character, @kbd{C-l}}
?\r @result{} ?\r               ; @r{carriage return, @key{RET}, @kbd{C-m}}
?\e @result{} ?\^[              ; @r{escape character, @key{ESC}, @kbd{C-[}}
?\\ @result{} ?\\               ; @r{backslash character, @kbd{\}}
;; @r{Under XEmacs 19:}
?\a @result{} 7                 ; @r{@kbd{C-g}}
?\b @result{} 8                 ; @r{backspace, @key{BS}, @kbd{C-h}}
?\t @result{} 9                 ; @r{tab, @key{TAB}, @kbd{C-i}}
?\n @result{} 10                ; @r{newline, @key{LFD}, @kbd{C-j}}
?\v @result{} 11                ; @r{vertical tab, @kbd{C-k}}
?\f @result{} 12                ; @r{formfeed character, @kbd{C-l}}
?\r @result{} 13                ; @r{carriage return, @key{RET}, @kbd{C-m}}
?\e @result{} 27                ; @r{escape character, @key{ESC}, @kbd{C-[}}
?\\ @result{} 92                ; @r{backslash character, @kbd{\}}
@end example

@cindex escape sequence
  These sequences which start with backslash are also known as
@dfn{escape sequences}, because backslash plays the role of an escape
character; this usage has nothing to do with the character @key{ESC}.

@cindex control characters
  Control characters may be represented using yet another read syntax.
This consists of a question mark followed by a backslash, caret, and the
corresponding non-control character, in either upper or lower case.  For
example, both @samp{?\^I} and @samp{?\^i} are valid read syntax for the
character @kbd{C-i}, the character whose value is 9.

  Instead of the @samp{^}, you can use @samp{C-}; thus, @samp{?\C-i} is
equivalent to @samp{?\^I} and to @samp{?\^i}:

@example
;; @r{Under XEmacs 20:}
?\^I @result{} ?\t   ?\C-I @result{} ?\t
(char-int ?\^I) @result{} 9
;; @r{Under XEmacs 19:}
?\^I @result{} 9     ?\C-I @result{} 9
@end example

  There is also a character read syntax beginning with @samp{\M-}.  This
sets the high bit of the character code (same as adding 128 to the
character code).  For example, @samp{?\M-A} stands for the character
with character code 193, or 128 plus 65.  You should @emph{not} use this
syntax in your programs.  It is a holdover of yet another confoundance
disease from earlier Emacsen. (This was used to represent keyboard input
with the @key{META} key set, thus the @samp{M}; however, it conflicts
with the legitimate @sc{iso}-8859-1 interpretation of the character code.
For example, character code 193 is a lowercase @samp{a} with an acute
accent, in @sc{iso}-8859-1.)

@ignore @c None of this crap applies to XEmacs.
  For use in strings and buffers, you are limited to the control
characters that exist in @sc{ascii}, but for keyboard input purposes,
you can turn any character into a control character with @samp{C-}.  The
character codes for these non-@sc{ascii} control characters include the
@iftex
$2^{26}$
@end iftex
@ifinfo
2**26
@end ifinfo
bit as well as the code for the corresponding non-control
character.  Ordinary terminals have no way of generating non-@sc{ASCII}
control characters, but you can generate them straightforwardly using an
X terminal.

  For historical reasons, Emacs treats the @key{DEL} character as
the control equivalent of @kbd{?}:

@example
?\^? @result{} 127     ?\C-? @result{} 127
@end example

@noindent
As a result, it is currently not possible to represent the character
@kbd{Control-?}, which is a meaningful input character under X.  It is
not easy to change this as various Lisp files refer to @key{DEL} in this
way.

  For representing control characters to be found in files or strings,
we recommend the @samp{^} syntax; for control characters in keyboard
input, we prefer the @samp{C-} syntax.  This does not affect the meaning
of the program, but may guide the understanding of people who read it.

@cindex meta characters
  A @dfn{meta character} is a character typed with the @key{META}
modifier key.  The integer that represents such a character has the
@iftex
$2^{27}$
@end iftex
@ifinfo
2**27
@end ifinfo
bit set (which on most machines makes it a negative number).  We
use high bits for this and other modifiers to make possible a wide range
of basic character codes.

  In a string, the
@iftex
$2^{7}$
@end iftex
@ifinfo
2**7
@end ifinfo
bit indicates a meta character, so the meta
characters that can fit in a string have codes in the range from 128 to
255, and are the meta versions of the ordinary @sc{ASCII} characters.
(In Emacs versions 18 and older, this convention was used for characters
outside of strings as well.)

  The read syntax for meta characters uses @samp{\M-}.  For example,
@samp{?\M-A} stands for @kbd{M-A}.  You can use @samp{\M-} together with
octal character codes (see below), with @samp{\C-}, or with any other
syntax for a character.  Thus, you can write @kbd{M-A} as @samp{?\M-A},
or as @samp{?\M-\101}.  Likewise, you can write @kbd{C-M-b} as
@samp{?\M-\C-b}, @samp{?\C-\M-b}, or @samp{?\M-\002}.

  The case of an ordinary letter is indicated by its character code as
part of @sc{ASCII}, but @sc{ASCII} has no way to represent whether a
control character is upper case or lower case.  Emacs uses the
@iftex
$2^{25}$
@end iftex
@ifinfo
2**25
@end ifinfo
bit to indicate that the shift key was used for typing a control
character.  This distinction is possible only when you use X terminals
or other special terminals; ordinary terminals do not indicate the
distinction to the computer in any way.

@cindex hyper characters
@cindex super characters
@cindex alt characters
  The X Window System defines three other modifier bits that can be set
in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}.  The syntaxes
for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}.  Thus,
@samp{?\H-\M-\A-x} represents @kbd{Alt-Hyper-Meta-x}.
@iftex
Numerically, the
bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper.
@end iftex
@ifinfo
Numerically, the
bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper.
@end ifinfo
@end ignore

@cindex @samp{?} in character constant
@cindex question mark in character constant
@cindex @samp{\} in character constant
@cindex backslash in character constant
@cindex octal character code
  Finally, the most general read syntax consists of a question mark
followed by a backslash and the character code in octal (up to three
octal digits); thus, @samp{?\101} for the character @kbd{A},
@samp{?\001} for the character @kbd{C-a}, and @code{?\002} for the
character @kbd{C-b}.  Although this syntax can represent any @sc{ascii}
character, it is preferred only when the precise octal value is more
important than the @sc{ascii} representation.

@example
@group
;; @r{Under XEmacs 20:}
?\012 @result{} ?\n        ?\n @result{} ?\n        ?\C-j @result{} ?\n
?\101 @result{} ?A         ?A @result{} ?A
@end group
@group
;; @r{Under XEmacs 19:}
?\012 @result{} 10         ?\n @result{} 10         ?\C-j @result{} 10
?\101 @result{} 65         ?A @result{} 65
@end group
@end example

  A backslash is allowed, and harmless, preceding any character without
a special escape meaning; thus, @samp{?\+} is equivalent to @samp{?+}.
There is no reason to add a backslash before most characters.  However,
you should add a backslash before any of the characters
@samp{()\|;'`"#.,} to avoid confusing the Emacs commands for editing
Lisp code.  Also add a backslash before whitespace characters such as
space, tab, newline and formfeed.  However, it is cleaner to use one of
the easily readable escape sequences, such as @samp{\t}, instead of an
actual whitespace character such as a tab.

@node Symbol Type, Sequence Type, Character Type, Programming Types
@subsection Symbol Type

  A @dfn{symbol} in XEmacs Lisp is an object with a name.  The symbol
name serves as the printed representation of the symbol.  In ordinary
use, the name is unique---no two symbols have the same name.

  A symbol can serve as a variable, as a function name, or to hold a
property list.  Or it may serve only to be distinct from all other Lisp
objects, so that its presence in a data structure may be recognized
reliably.  In a given context, usually only one of these uses is
intended.  But you can use one symbol in all of these ways,
independently.

@cindex @samp{\} in symbols
@cindex backslash in symbols
  A symbol name can contain any characters whatever.  Most symbol names
are written with letters, digits, and the punctuation characters
@samp{-+=*/}.  Such names require no special punctuation; the characters
of the name suffice as long as the name does not look like a number.
(If it does, write a @samp{\} at the beginning of the name to force
interpretation as a symbol.)  The characters @samp{_~!@@$%^&:<>@{@}} are
less often used but also require no special punctuation.  Any other
characters may be included in a symbol's name by escaping them with a
backslash.  In contrast to its use in strings, however, a backslash in
the name of a symbol simply quotes the single character that follows the
backslash.  For example, in a string, @samp{\t} represents a tab
character; in the name of a symbol, however, @samp{\t} merely quotes the
letter @kbd{t}.  To have a symbol with a tab character in its name, you
must actually use a tab (preceded with a backslash).  But it's rare to
do such a thing.

@cindex CL note---case of letters
@quotation
@b{Common Lisp note:} In Common Lisp, lower case letters are always
``folded'' to upper case, unless they are explicitly escaped.  In Emacs
Lisp, upper case and lower case letters are distinct.
@end quotation

  Here are several examples of symbol names.  Note that the @samp{+} in
the fifth example is escaped to prevent it from being read as a number.
This is not necessary in the sixth example because the rest of the name
makes it invalid as a number.

@example
@group
foo                 ; @r{A symbol named @samp{foo}.}
FOO                 ; @r{A symbol named @samp{FOO}, different from @samp{foo}.}
char-to-string      ; @r{A symbol named @samp{char-to-string}.}
@end group
@group
1+                  ; @r{A symbol named @samp{1+}}
                    ;   @r{(not @samp{+1}, which is an integer).}
@end group
@group
\+1                 ; @r{A symbol named @samp{+1}}
                    ;   @r{(not a very readable name).}
@end group
@group
\(*\ 1\ 2\)         ; @r{A symbol named @samp{(* 1 2)} (a worse name).}
@c the @'s in this next line use up three characters, hence the
@c apparent misalignment of the comment.
+-*/_~!@@$%^&=:<>@{@}  ; @r{A symbol named @samp{+-*/_~!@@$%^&=:<>@{@}}.}
                    ;   @r{These characters need not be escaped.}
@end group
@end example

@node Sequence Type, Cons Cell Type, Symbol Type, Programming Types
@subsection Sequence Types

  A @dfn{sequence} is a Lisp object that represents an ordered set of
elements.  There are two kinds of sequence in XEmacs Lisp, lists and
arrays.  Thus, an object of type list or of type array is also
considered a sequence.

  Arrays are further subdivided into strings, vectors, and bit vectors.
Vectors can hold elements of any type, but string elements must be
characters, and bit vector elements must be either 0 or 1.  However, the
characters in a string can have extents (@pxref{Extents}) and text
properties (@pxref{Text Properties}) like characters in a buffer;
vectors do not support extents or text properties even when their
elements happen to be characters.

  Lists, strings, vectors, and bit vectors are different, but they have
important similarities.  For example, all have a length @var{l}, and all
have elements which can be indexed from zero to @var{l} minus one.
Also, several functions, called sequence functions, accept any kind of
sequence.  For example, the function @code{elt} can be used to extract
an element of a sequence, given its index.  @xref{Sequences Arrays
Vectors}.

  It is impossible to read the same sequence twice, since sequences are
always created anew upon reading.  If you read the read syntax for a
sequence twice, you get two sequences with equal contents.  There is one
exception: the empty list @code{()} always stands for the same object,
@code{nil}.

@node Cons Cell Type, Array Type, Sequence Type, Programming Types
@subsection Cons Cell and List Types
@cindex address field of register
@cindex decrement field of register

  A @dfn{cons cell} is an object comprising two pointers named the
@sc{car} and the @sc{cdr}.  Each of them can point to any Lisp object.

  A @dfn{list} is a series of cons cells, linked together so that the
@sc{cdr} of each cons cell points either to another cons cell or to the
empty list.  @xref{Lists}, for functions that work on lists.  Because
most cons cells are used as part of lists, the phrase @dfn{list
structure} has come to refer to any structure made out of cons cells.

  The names @sc{car} and @sc{cdr} have only historical meaning now.  The
original Lisp implementation ran on an @w{IBM 704} computer which
divided words into two parts, called the ``address'' part and the
``decrement''; @sc{car} was an instruction to extract the contents of
the address part of a register, and @sc{cdr} an instruction to extract
the contents of the decrement.  By contrast, ``cons cells'' are named
for the function @code{cons} that creates them, which in turn is named
for its purpose, the construction of cells.

@cindex atom
  Because cons cells are so central to Lisp, we also have a word for
``an object which is not a cons cell''.  These objects are called
@dfn{atoms}.

@cindex parenthesis
  The read syntax and printed representation for lists are identical, and
consist of a left parenthesis, an arbitrary number of elements, and a
right parenthesis.

   Upon reading, each object inside the parentheses becomes an element
of the list.  That is, a cons cell is made for each element.  The
@sc{car} of the cons cell points to the element, and its @sc{cdr} points
to the next cons cell of the list, which holds the next element in the
list.  The @sc{cdr} of the last cons cell is set to point to @code{nil}.

@cindex box diagrams, for lists
@cindex diagrams, boxed, for lists
  A list can be illustrated by a diagram in which the cons cells are
shown as pairs of boxes.  (The Lisp reader cannot read such an
illustration; unlike the textual notation, which can be understood by
both humans and computers, the box illustrations can be understood only
by humans.)  The following represents the three-element list @code{(rose
violet buttercup)}:

@example
@group
    ___ ___      ___ ___      ___ ___
   |___|___|--> |___|___|--> |___|___|--> nil
     |            |            |
     |            |            |
      --> rose     --> violet   --> buttercup
@end group
@end example

  In this diagram, each box represents a slot that can refer to any Lisp
object.  Each pair of boxes represents a cons cell.  Each arrow is a
reference to a Lisp object, either an atom or another cons cell.

  In this example, the first box, the @sc{car} of the first cons cell,
refers to or ``contains'' @code{rose} (a symbol).  The second box, the
@sc{cdr} of the first cons cell, refers to the next pair of boxes, the
second cons cell.  The @sc{car} of the second cons cell refers to
@code{violet} and the @sc{cdr} refers to the third cons cell.  The
@sc{cdr} of the third (and last) cons cell refers to @code{nil}.

Here is another diagram of the same list, @code{(rose violet
buttercup)}, sketched in a different manner:

@smallexample
@group
 ---------------       ----------------       -------------------
| car   | cdr   |     | car    | cdr   |     | car       | cdr   |
| rose  |   o-------->| violet |   o-------->| buttercup |  nil  |
|       |       |     |        |       |     |           |       |
 ---------------       ----------------       -------------------
@end group
@end smallexample

@cindex @samp{(@dots{})} in lists
@cindex @code{nil} in lists
@cindex empty list
  A list with no elements in it is the @dfn{empty list}; it is identical
to the symbol @code{nil}.  In other words, @code{nil} is both a symbol
and a list.

  Here are examples of lists written in Lisp syntax:

@example
(A 2 "A")            ; @r{A list of three elements.}
()                   ; @r{A list of no elements (the empty list).}
nil                  ; @r{A list of no elements (the empty list).}
("A ()")             ; @r{A list of one element: the string @code{"A ()"}.}
(A ())               ; @r{A list of two elements: @code{A} and the empty list.}
(A nil)              ; @r{Equivalent to the previous.}
((A B C))            ; @r{A list of one element}
                     ;   @r{(which is a list of three elements).}
@end example

  Here is the list @code{(A ())}, or equivalently @code{(A nil)},
depicted with boxes and arrows:

@example
@group
    ___ ___      ___ ___
   |___|___|--> |___|___|--> nil
     |            |
     |            |
      --> A        --> nil
@end group
@end example

@menu
* Dotted Pair Notation::        An alternative syntax for lists.
* Association List Type::       A specially constructed list.
@end menu

@node Dotted Pair Notation, Association List Type, Cons Cell Type, Cons Cell Type
@subsubsection Dotted Pair Notation
@cindex dotted pair notation
@cindex @samp{.} in lists

  @dfn{Dotted pair notation} is an alternative syntax for cons cells
that represents the @sc{car} and @sc{cdr} explicitly.  In this syntax,
@code{(@var{a} .@: @var{b})} stands for a cons cell whose @sc{car} is
the object @var{a}, and whose @sc{cdr} is the object @var{b}.  Dotted
pair notation is therefore more general than list syntax.  In the dotted
pair notation, the list @samp{(1 2 3)} is written as @samp{(1 .  (2 . (3
. nil)))}.  For @code{nil}-terminated lists, the two notations produce
the same result, but list notation is usually clearer and more
convenient when it is applicable.  When printing a list, the dotted pair
notation is only used if the @sc{cdr} of a cell is not a list.

  Here's how box notation can illustrate dotted pairs.  This example
shows the pair @code{(rose . violet)}:

@example
@group
    ___ ___
   |___|___|--> violet
     |
     |
      --> rose
@end group
@end example

  Dotted pair notation can be combined with list notation to represent a
chain of cons cells with a non-@code{nil} final @sc{cdr}.  For example,
@code{(rose violet . buttercup)} is equivalent to @code{(rose . (violet
. buttercup))}.  The object looks like this:

@example
@group
    ___ ___      ___ ___
   |___|___|--> |___|___|--> buttercup
     |            |
     |            |
      --> rose     --> violet
@end group
@end example

  These diagrams make it evident why @w{@code{(rose .@: violet .@:
buttercup)}} is invalid syntax; it would require a cons cell that has
three parts rather than two.

  The list @code{(rose violet)} is equivalent to @code{(rose . (violet))}
and looks like this:

@example
@group
    ___ ___      ___ ___
   |___|___|--> |___|___|--> nil
     |            |
     |            |
      --> rose     --> violet
@end group
@end example

  Similarly, the three-element list @code{(rose violet buttercup)}
is equivalent to @code{(rose . (violet . (buttercup)))}.
@ifinfo
It looks like this:

@example
@group
    ___ ___      ___ ___      ___ ___
   |___|___|--> |___|___|--> |___|___|--> nil
     |            |            |
     |            |            |
      --> rose     --> violet   --> buttercup
@end group
@end example
@end ifinfo

@node Association List Type,  , Dotted Pair Notation, Cons Cell Type
@subsubsection Association List Type

  An @dfn{association list} or @dfn{alist} is a specially-constructed
list whose elements are cons cells.  In each element, the @sc{car} is
considered a @dfn{key}, and the @sc{cdr} is considered an
@dfn{associated value}.  (In some cases, the associated value is stored
in the @sc{car} of the @sc{cdr}.)  Association lists are often used as
stacks, since it is easy to add or remove associations at the front of
the list.

  For example,

@example
(setq alist-of-colors
      '((rose . red) (lily . white)  (buttercup . yellow)))
@end example

@noindent
sets the variable @code{alist-of-colors} to an alist of three elements.  In the
first element, @code{rose} is the key and @code{red} is the value.

  @xref{Association Lists}, for a further explanation of alists and for
functions that work on alists.

@node Array Type, String Type, Cons Cell Type, Programming Types
@subsection Array Type

  An @dfn{array} is composed of an arbitrary number of slots for
referring to other Lisp objects, arranged in a contiguous block of
memory.  Accessing any element of an array takes the same amount of
time.  In contrast, accessing an element of a list requires time
proportional to the position of the element in the list.  (Elements at
the end of a list take longer to access than elements at the beginning
of a list.)

  XEmacs defines three types of array, strings, vectors, and bit
vectors.  A string is an array of characters, a vector is an array of
arbitrary objects, and a bit vector is an array of 1's and 0's.  All are
one-dimensional.  (Most other programming languages support
multidimensional arrays, but they are not essential; you can get the
same effect with an array of arrays.)  Each type of array has its own
read syntax; see @ref{String Type}, @ref{Vector Type}, and @ref{Bit
Vector Type}.

  An array may have any length up to the largest integer; but once
created, it has a fixed size.  The first element of an array has index
zero, the second element has index 1, and so on.  This is called
@dfn{zero-origin} indexing.  For example, an array of four elements has
indices 0, 1, 2, @w{and 3}.

  The array type is contained in the sequence type and contains the
string type, the vector type, and the bit vector type.

@node String Type, Vector Type, Array Type, Programming Types
@subsection String Type

  A @dfn{string} is an array of characters.  Strings are used for many
purposes in XEmacs, as can be expected in a text editor; for example, as
the names of Lisp symbols, as messages for the user, and to represent
text extracted from buffers.  Strings in Lisp are constants: evaluation
of a string returns the same string.

@cindex @samp{"} in strings
@cindex double-quote in strings
@cindex @samp{\} in strings
@cindex backslash in strings
  The read syntax for strings is a double-quote, an arbitrary number of
characters, and another double-quote, @code{"like this"}.  The Lisp
reader accepts the same formats for reading the characters of a string
as it does for reading single characters (without the question mark that
begins a character literal).  You can enter a nonprinting character such
as tab or @kbd{C-a} using the convenient escape sequences, like this:
@code{"\t, \C-a"}.  You can include a double-quote in a string by
preceding it with a backslash; thus, @code{"\""} is a string containing
just a single double-quote character.  (@xref{Character Type}, for a
description of the read syntax for characters.)

@ignore @c More ill-conceived FSF Emacs crap.
  If you use the @samp{\M-} syntax to indicate a meta character in a
string constant, this sets the
@iftex
$2^{7}$
@end iftex
@ifinfo
2**7
@end ifinfo
bit of the character in the string.
This is not the same representation that the meta modifier has in a
character on its own (not inside a string).  @xref{Character Type}.

  Strings cannot hold characters that have the hyper, super, or alt
modifiers; they can hold @sc{ASCII} control characters, but no others.
They do not distinguish case in @sc{ASCII} control characters.
@end ignore

  The printed representation of a string consists of a double-quote, the
characters it contains, and another double-quote.  However, you must
escape any backslash or double-quote characters in the string with a
backslash, like this: @code{"this \" is an embedded quote"}.

  The newline character is not special in the read syntax for strings;
if you write a new line between the double-quotes, it becomes a
character in the string.  But an escaped newline---one that is preceded
by @samp{\}---does not become part of the string; i.e., the Lisp reader
ignores an escaped newline while reading a string.
@cindex newline in strings

@example
"It is useful to include newlines
in documentation strings,
but the newline is \
ignored if escaped."
     @result{} "It is useful to include newlines
in documentation strings,
but the newline is ignored if escaped."
@end example

  A string can hold extents and properties of the text it contains, in
addition to the characters themselves.  This enables programs that copy
text between strings and buffers to preserve the extents and properties
with no special effort.  @xref{Extents}, @xref{Text Properties}.

  Note that FSF GNU Emacs has a special read and print syntax for
strings with text properties, but XEmacs does not currently implement
this.  It was judged better not to include this in XEmacs because it
entails that @code{equal} return @code{nil} when passed a string with
text properties and the equivalent string without text properties, which
is often counter-intuitive.

@ignore @c Not in XEmacs
Strings with text
properties have a special read and print syntax:

@example
#("@var{characters}" @var{property-data}...)
@end example

@noindent
where @var{property-data} consists of zero or more elements, in groups
of three as follows:

@example
@var{start} @var{end} @var{plist}
@end example

@noindent
The elements @var{start} and @var{end} are integers, and together specify
a range of indices in the string; @var{plist} is the property list for
that range.
@end ignore

  @xref{Strings and Characters}, for functions that work on strings.

@node Vector Type, Bit Vector Type, String Type, Programming Types
@subsection Vector Type

  A @dfn{vector} is a one-dimensional array of elements of any type.  It
takes a constant amount of time to access any element of a vector.  (In
a list, the access time of an element is proportional to the distance of
the element from the beginning of the list.)

  The printed representation of a vector consists of a left square
bracket, the elements, and a right square bracket.  This is also the
read syntax.  Like numbers and strings, vectors are considered constants
for evaluation.

@example
[1 "two" (three)]      ; @r{A vector of three elements.}
     @result{} [1 "two" (three)]
@end example

  @xref{Vectors}, for functions that work with vectors.

@node Bit Vector Type, Function Type, Vector Type, Programming Types
@subsection Bit Vector Type

  A @dfn{bit vector} is a one-dimensional array of 1's and 0's.  It
takes a constant amount of time to access any element of a bit vector,
as for vectors.  Bit vectors have an extremely compact internal
representation (one machine bit per element), which makes them ideal
for keeping track of unordered sets, large collections of boolean values,
etc.

  The printed representation of a bit vector consists of @samp{#*}
followed by the bits in the vector.  This is also the read syntax.  Like
numbers, strings, and vectors, bit vectors are considered constants for
evaluation.

@example
#*00101000      ; @r{A bit vector of eight elements.}
     @result{} #*00101000
@end example

  @xref{Bit Vectors}, for functions that work with bit vectors.

@node Function Type, Macro Type, Bit Vector Type, Programming Types
@subsection Function Type

  Just as functions in other programming languages are executable,
@dfn{Lisp function} objects are pieces of executable code.  However,
functions in Lisp are primarily Lisp objects, and only secondarily the
text which represents them.  These Lisp objects are lambda expressions:
lists whose first element is the symbol @code{lambda} (@pxref{Lambda
Expressions}).

  In most programming languages, it is impossible to have a function
without a name.  In Lisp, a function has no intrinsic name.  A lambda
expression is also called an @dfn{anonymous function} (@pxref{Anonymous
Functions}).  A named function in Lisp is actually a symbol with a valid
function in its function cell (@pxref{Defining Functions}).

  Most of the time, functions are called when their names are written in
Lisp expressions in Lisp programs.  However, you can construct or obtain
a function object at run time and then call it with the primitive
functions @code{funcall} and @code{apply}.  @xref{Calling Functions}.

@node Macro Type, Primitive Function Type, Function Type, Programming Types
@subsection Macro Type

  A @dfn{Lisp macro} is a user-defined construct that extends the Lisp
language.  It is represented as an object much like a function, but with
different parameter-passing semantics.  A Lisp macro has the form of a
list whose first element is the symbol @code{macro} and whose @sc{cdr}
is a Lisp function object, including the @code{lambda} symbol.

  Lisp macro objects are usually defined with the built-in
@code{defmacro} function, but any list that begins with @code{macro} is
a macro as far as XEmacs is concerned.  @xref{Macros}, for an explanation
of how to write a macro.

@node Primitive Function Type, Compiled-Function Type, Macro Type, Programming Types
@subsection Primitive Function Type
@cindex special forms

  A @dfn{primitive function} is a function callable from Lisp but
written in the C programming language.  Primitive functions are also
called @dfn{subrs} or @dfn{built-in functions}.  (The word ``subr'' is
derived from ``subroutine''.)  Most primitive functions evaluate all
their arguments when they are called.  A primitive function that does
not evaluate all its arguments is called a @dfn{special form}
(@pxref{Special Forms}).@refill

  It does not matter to the caller of a function whether the function is
primitive.  However, this does matter if you try to substitute a
function written in Lisp for a primitive of the same name.  The reason
is that the primitive function may be called directly from C code.
Calls to the redefined function from Lisp will use the new definition,
but calls from C code may still use the built-in definition.

  The term @dfn{function} refers to all Emacs functions, whether written
in Lisp or C.  @xref{Function Type}, for information about the
functions written in Lisp.

  Primitive functions have no read syntax and print in hash notation
with the name of the subroutine.

@example
@group
(symbol-function 'car)          ; @r{Access the function cell}
                                ;   @r{of the symbol.}
     @result{} #<subr car>
(subrp (symbol-function 'car))  ; @r{Is this a primitive function?}
     @result{} t                       ; @r{Yes.}
@end group
@end example

@node Compiled-Function Type, Autoload Type, Primitive Function Type, Programming Types
@subsection Compiled-Function Type

  The byte compiler produces @dfn{compiled-function objects}.  The
evaluator handles this data type specially when it appears as a function
to be called.  @xref{Byte Compilation}, for information about the byte
compiler.

  The printed representation for a compiled-function object is normally
@samp{#<compiled-function...>}.  If @code{print-readably} is true,
however, it is @samp{#[...]}.

@node Autoload Type, Char Table Type, Compiled-Function Type, Programming Types
@subsection Autoload Type

  An @dfn{autoload object} is a list whose first element is the symbol
@code{autoload}.  It is stored as the function definition of a symbol as
a placeholder for the real definition; it says that the real definition
is found in a file of Lisp code that should be loaded when necessary.
The autoload object contains the name of the file, plus some other
information about the real definition.

  After the file has been loaded, the symbol should have a new function
definition that is not an autoload object.  The new definition is then
called as if it had been there to begin with.  From the user's point of
view, the function call works as expected, using the function definition
in the loaded file.

  An autoload object is usually created with the function
@code{autoload}, which stores the object in the function cell of a
symbol.  @xref{Autoload}, for more details.

@node Char Table Type, Hash Table Type, Autoload Type, Programming Types
@subsection Char Table Type
@cindex char table type

(not yet documented)

@node Hash Table Type, Range Table Type, Char Table Type, Programming Types
@subsection Hash Table Type
@cindex hash table type

  A @dfn{hash table} is a table providing an arbitrary mapping from
one Lisp object to another, using an internal indexing method
called @dfn{hashing}.  Hash tables are very fast (much more efficient
that using an association list, when there are a large number of
elements in the table).

Hash tables have a special read syntax beginning with
@samp{#s(hash-table} (this is an example of @dfn{structure} read
syntax.  This notation is also used for printing when
@code{print-readably} is @code{t}.

Otherwise they print in hash notation (The ``hash'' in ``hash notation''
has nothing to do with the ``hash'' in ``hash table''), giving the
number of elements, total space allocated for elements, and a unique
number assigned at the time the hash table was created. (Hash tables
automatically resize as necessary so there is no danger of running out
of space for elements.)

@example
@group
(make-hash-table :size 50)
     @result{} #<hash-table 0/107 0x313a>
@end group
@end example

@xref{Hash Tables}, for information on how to create and work with hash
tables.

@node Range Table Type, Weak List Type, Hash Table Type, Programming Types
@subsection Range Table Type
@cindex range table type

  A @dfn{range table} is a table that maps from ranges of integers to
arbitrary Lisp objects.  Range tables automatically combine overlapping
ranges that map to the same Lisp object, and operations are provided
for mapping over all of the ranges in a range table.

  Range tables have a special read syntax beginning with
@samp{#s(range-table} (this is an example of @dfn{structure} read syntax,
which is also used for char tables and faces).

@example
@group
(setq x (make-range-table))
(put-range-table 20 50 'foo x)
(put-range-table 100 200 "bar" x)
x
     @result{} #s(range-table data ((20 50) foo (100 200) "bar"))
@end group
@end example

@xref{Range Tables}, for information on how to create and work with range
tables.

@node Weak List Type,  , Range Table Type, Programming Types
@subsection Weak List Type
@cindex weak list type

(not yet documented)

@node Editing Types, Window-System Types, Programming Types, Lisp Data Types
@section Editing Types
@cindex editing types

  The types in the previous section are common to many Lisp dialects.
XEmacs Lisp provides several additional data types for purposes connected
with editing.

@menu
* Buffer Type::         The basic object of editing.
* Marker Type::         A position in a buffer.
* Extent Type::         A range in a buffer or string, maybe with properties.
* Window Type::         Buffers are displayed in windows.
* Frame Type::		Windows subdivide frames.
* Device Type::         Devices group all frames on a display.
* Console Type::        Consoles group all devices with the same keyboard.
* Window Configuration Type::   Recording the way a frame is subdivided.
* Event Type::          An interesting occurrence in the system.
* Process Type::        A process running on the underlying OS.
* Stream Type::         Receive or send characters.
* Keymap Type::         What function a keystroke invokes.
* Syntax Table Type::   What a character means.
* Display Table Type::  How display tables are represented.
* Database Type::       A connection to an external DBM or DB database.
* Charset Type::        A character set (e.g. all Kanji characters),
                          under XEmacs/MULE.
* Coding System Type::  An object encapsulating a way of converting between
                          different textual encodings, under XEmacs/MULE.
* ToolTalk Message Type:: A message, in the ToolTalk IPC protocol.
* ToolTalk Pattern Type:: A pattern, in the ToolTalk IPC protocol.
@end menu

@node Buffer Type, Marker Type, Editing Types, Editing Types
@subsection Buffer Type

  A @dfn{buffer} is an object that holds text that can be edited
(@pxref{Buffers}).  Most buffers hold the contents of a disk file
(@pxref{Files}) so they can be edited, but some are used for other
purposes.  Most buffers are also meant to be seen by the user, and
therefore displayed, at some time, in a window (@pxref{Windows}).  But a
buffer need not be displayed in any window.

  The contents of a buffer are much like a string, but buffers are not
used like strings in XEmacs Lisp, and the available operations are
different.  For example, insertion of text into a buffer is very
efficient, whereas ``inserting'' text into a string requires
concatenating substrings, and the result is an entirely new string
object.

  Each buffer has a designated position called @dfn{point}
(@pxref{Positions}).  At any time, one buffer is the @dfn{current
buffer}.  Most editing commands act on the contents of the current
buffer in the neighborhood of point.  Many of the standard Emacs
functions manipulate or test the characters in the current buffer; a
whole chapter in this manual is devoted to describing these functions
(@pxref{Text}).

  Several other data structures are associated with each buffer:

@itemize @bullet
@item
a local syntax table (@pxref{Syntax Tables});

@item
a local keymap (@pxref{Keymaps});

@item
a local variable binding list (@pxref{Buffer-Local Variables});

@item
a list of extents (@pxref{Extents});

@item
and various other related properties.
@end itemize

@noindent
The local keymap and variable list contain entries that individually
override global bindings or values.  These are used to customize the
behavior of programs in different buffers, without actually changing the
programs.

  A buffer may be @dfn{indirect}, which means it shares the text
of another buffer.  @xref{Indirect Buffers}.

  Buffers have no read syntax.  They print in hash notation, showing the
buffer name.

@example
@group
(current-buffer)
     @result{} #<buffer "objects.texi">
@end group
@end example

@node Marker Type, Extent Type, Buffer Type, Editing Types
@subsection Marker Type

  A @dfn{marker} denotes a position in a specific buffer.  Markers
therefore have two components: one for the buffer, and one for the
position.  Changes in the buffer's text automatically relocate the
position value as necessary to ensure that the marker always points
between the same two characters in the buffer.

  Markers have no read syntax.  They print in hash notation, giving the
current character position and the name of the buffer.

@example
@group
(point-marker)
     @result{} #<marker at 50661 in objects.texi>
@end group
@end example

@xref{Markers}, for information on how to test, create, copy, and move
markers.

@node Extent Type, Window Type, Marker Type, Editing Types
@subsection Extent Type

  An @dfn{extent} specifies temporary alteration of the display
appearance of a part of a buffer (or string).  It contains markers
delimiting a range of the buffer, plus a property list (a list whose
elements are alternating property names and values).  Extents are used
to present parts of the buffer temporarily in a different display style.
They have no read syntax, and print in hash notation, giving the buffer
name and range of positions.

  Extents can exist over strings as well as buffers; the primary use
of this is to preserve extent and text property information as text
is copied from one buffer to another or between different parts of
a buffer.

  Extents have no read syntax.  They print in hash notation, giving the
range of text they cover, the name of the buffer or string they are in,
the address in core, and a summary of some of the properties attached to
the extent.

@example
@group
(extent-at (point))
     @result{} #<extent [51742, 51748) font-lock text-prop 0x90121e0 in buffer objects.texi>
@end group
@end example

  @xref{Extents}, for how to create and use extents.

  Extents are used to implement text properties.  @xref{Text Properties}.

@node Window Type, Frame Type, Extent Type, Editing Types
@subsection Window Type

  A @dfn{window} describes the portion of the frame that XEmacs uses to
display a buffer. (In standard window-system usage, a @dfn{window} is
what XEmacs calls a @dfn{frame}; XEmacs confusingly uses the term
``window'' to refer to what is called a @dfn{pane} in standard
window-system usage.) Every window has one associated buffer, whose
contents appear in the window.  By contrast, a given buffer may appear
in one window, no window, or several windows.

  Though many windows may exist simultaneously, at any time one window
is designated the @dfn{selected window}.  This is the window where the
cursor is (usually) displayed when XEmacs is ready for a command.  The
selected window usually displays the current buffer, but this is not
necessarily the case.

  Windows are grouped on the screen into frames; each window belongs to
one and only one frame.  @xref{Frame Type}.

  Windows have no read syntax.  They print in hash notation, giving the
name of the buffer being displayed and a unique number assigned at the
time the window was created. (This number can be useful because the
buffer displayed in any given window can change frequently.)

@example
@group
(selected-window)
     @result{} #<window on "objects.texi" 0x266c>
@end group
@end example

  @xref{Windows}, for a description of the functions that work on windows.

@node Frame Type, Device Type, Window Type, Editing Types
@subsection Frame Type

  A @var{frame} is a rectangle on the screen (a @dfn{window} in standard
window-system terminology) that contains one or more non-overlapping
Emacs windows (@dfn{panes} in standard window-system terminology).  A
frame initially contains a single main window (plus perhaps a minibuffer
window) which you can subdivide vertically or horizontally into smaller
windows.

  Frames have no read syntax.  They print in hash notation, giving the
frame's type, name as used for resourcing, and a unique number assigned
at the time the frame was created.

@example
@group
(selected-frame)
     @result{} #<x-frame "emacs" 0x9db>
@end group
@end example

  @xref{Frames}, for a description of the functions that work on frames.

@node Device Type, Console Type, Frame Type, Editing Types
@subsection Device Type

  A @dfn{device} represents a single display on which frames exist.
Normally, there is only one device object, but there may be more
than one if XEmacs is being run on a multi-headed display (e.g. an
X server with attached color and mono screens) or if XEmacs is
simultaneously driving frames attached to different consoles, e.g.
an X display and a @sc{tty} connection.

  Devices do not have a read syntax.  They print in hash notation,
giving the device's type, connection name, and a unique number assigned
at the time the device was created.

@example
@group
(selected-device)
     @result{} #<x-device on ":0.0" 0x5b9>
@end group
@end example

  @xref{Consoles and Devices}, for a description of several functions
related to devices.

@node Console Type, Window Configuration Type, Device Type, Editing Types
@subsection Console Type

  A @dfn{console} represents a single keyboard to which devices
(i.e. displays on which frames exist) are connected.  Normally, there is
only one console object, but there may be more than one if XEmacs is
simultaneously driving frames attached to different X servers and/or
@sc{tty} connections. (XEmacs is capable of driving multiple X and
@sc{tty} connections at the same time, and provides a robust mechanism
for handling the differing display capabilities of such heterogeneous
environments.  A buffer with embedded glyphs and multiple fonts and
colors, for example, will display reasonably if it simultaneously
appears on a frame on a color X display, a frame on a mono X display,
and a frame on a @sc{tty} connection.)

  Consoles do not have a read syntax.  They print in hash notation,
giving the console's type, connection name, and a unique number assigned
at the time the console was created.

@example
@group
(selected-console)
     @result{} #<x-console on "localhost:0" 0x5b7>
@end group
@end example

  @xref{Consoles and Devices}, for a description of several functions
related to consoles.

@node Window Configuration Type, Event Type, Console Type, Editing Types
@subsection Window Configuration Type
@cindex screen layout

  A @dfn{window configuration} stores information about the positions,
sizes, and contents of the windows in a frame, so you can recreate the
same arrangement of windows later.

  Window configurations do not have a read syntax.  They print in hash
notation, giving a unique number assigned at the time the window
configuration was created.

@example
@group
(current-window-configuration)
     @result{} #<window-configuration 0x2db4>
@end group
@end example

  @xref{Window Configurations}, for a description of several functions
related to window configurations.

@node Event Type, Process Type, Window Configuration Type, Editing Types
@subsection Event Type

(not yet documented)

@node Process Type, Stream Type, Event Type, Editing Types
@subsection Process Type

  The word @dfn{process} usually means a running program.  XEmacs itself
runs in a process of this sort.  However, in XEmacs Lisp, a process is a
Lisp object that designates a subprocess created by the XEmacs process.
Programs such as shells, GDB, ftp, and compilers, running in
subprocesses of XEmacs, extend the capabilities of XEmacs.

  An Emacs subprocess takes textual input from Emacs and returns textual
output to Emacs for further manipulation.  Emacs can also send signals
to the subprocess.

  Process objects have no read syntax.  They print in hash notation,
giving the name of the process, its associated process ID, and the
current state of the process:

@example
@group
(process-list)
     @result{} (#<process "shell" pid 2909 state:run>)
@end group
@end example

@xref{Processes}, for information about functions that create, delete,
return information about, send input or signals to, and receive output
from processes.

@node Stream Type, Keymap Type, Process Type, Editing Types
@subsection Stream Type

  A @dfn{stream} is an object that can be used as a source or sink for
characters---either to supply characters for input or to accept them as
output.  Many different types can be used this way: markers, buffers,
strings, and functions.  Most often, input streams (character sources)
obtain characters from the keyboard, a buffer, or a file, and output
streams (character sinks) send characters to a buffer, such as a
@file{*Help*} buffer, or to the echo area.

  The object @code{nil}, in addition to its other meanings, may be used
as a stream.  It stands for the value of the variable
@code{standard-input} or @code{standard-output}.  Also, the object
@code{t} as a stream specifies input using the minibuffer
(@pxref{Minibuffers}) or output in the echo area (@pxref{The Echo
Area}).

  Streams have no special printed representation or read syntax, and
print as whatever primitive type they are.

  @xref{Read and Print}, for a description of functions
related to streams, including parsing and printing functions.

@node Keymap Type, Syntax Table Type, Stream Type, Editing Types
@subsection Keymap Type

  A @dfn{keymap} maps keys typed by the user to commands.  This mapping
controls how the user's command input is executed.

  NOTE: In XEmacs, a keymap is a separate primitive type.  In FSF GNU
Emacs, a keymap is actually a list whose @sc{car} is the symbol
@code{keymap}.

  @xref{Keymaps}, for information about creating keymaps, handling prefix
keys, local as well as global keymaps, and changing key bindings.

@node Syntax Table Type, Display Table Type, Keymap Type, Editing Types
@subsection Syntax Table Type

  Under XEmacs 20, a @dfn{syntax table} is a particular type of char
table.  Under XEmacs 19, a syntax table a vector of 256 integers.  In
both cases, each element defines how one character is interpreted when it
appears in a buffer.  For example, in C mode (@pxref{Major Modes}), the
@samp{+} character is punctuation, but in Lisp mode it is a valid
character in a symbol.  These modes specify different interpretations by
changing the syntax table entry for @samp{+}.

  Syntax tables are used only for scanning text in buffers, not for
reading Lisp expressions.  The table the Lisp interpreter uses to read
expressions is built into the XEmacs source code and cannot be changed;
thus, to change the list delimiters to be @samp{@{} and @samp{@}}
instead of @samp{(} and @samp{)} would be impossible.

  @xref{Syntax Tables}, for details about syntax classes and how to make
and modify syntax tables.

@node Display Table Type, Database Type, Syntax Table Type, Editing Types
@subsection Display Table Type

  A @dfn{display table} specifies how to display each character code.
Each buffer and each window can have its own display table.  A display
table is actually a vector of length 256, although in XEmacs 20 this may
change to be a particular type of char table.  @xref{Display Tables}.

@node Database Type, Charset Type, Display Table Type, Editing Types
@subsection Database Type
@cindex database type

(not yet documented)

@node Charset Type, Coding System Type, Database Type, Editing Types
@subsection Charset Type
@cindex charset type

(not yet documented)

@node Coding System Type, ToolTalk Message Type, Charset Type, Editing Types
@subsection Coding System Type
@cindex coding system type

(not yet documented)

@node ToolTalk Message Type, ToolTalk Pattern Type, Coding System Type, Editing Types
@subsection ToolTalk Message Type

(not yet documented)

@node ToolTalk Pattern Type,  , ToolTalk Message Type, Editing Types
@subsection ToolTalk Pattern Type

(not yet documented)

@node Window-System Types, Type Predicates, Editing Types, Lisp Data Types
@section Window-System Types
@cindex window system types

  XEmacs also has some types that represent objects such as faces
(collections of display characters), fonts, and pixmaps that are
commonly found in windowing systems.

@menu
* Face Type::           A collection of display characteristics.
* Glyph Type::          An image appearing in a buffer or elsewhere.
* Specifier Type::      A way of controlling display characteristics on
                          a per-buffer, -frame, -window, or -device level.
* Font Instance Type::  The way a font appears on a particular device.
* Color Instance Type:: The way a color appears on a particular device.
* Image Instance Type:: The way an image appears on a particular device.
* Toolbar Button Type:: An object representing a button in a toolbar.
* Subwindow Type::      An externally-controlled window-system window
                          appearing in a buffer.
* X Resource Type::     A miscellaneous X resource, if Epoch support was
                          compiled into XEmacs.
@end menu

@node Face Type, Glyph Type, Window-System Types, Window-System Types
@subsection Face Type
@cindex face type

(not yet documented)

@node Glyph Type, Specifier Type, Face Type, Window-System Types
@subsection Glyph Type
@cindex glyph type

(not yet documented)

@node Specifier Type, Font Instance Type, Glyph Type, Window-System Types
@subsection Specifier Type
@cindex specifier type

(not yet documented)

@node Font Instance Type, Color Instance Type, Specifier Type, Window-System Types
@subsection Font Instance Type
@cindex font instance type

(not yet documented)

@node Color Instance Type, Image Instance Type, Font Instance Type, Window-System Types
@subsection Color Instance Type
@cindex color instance type

(not yet documented)

@node Image Instance Type, Toolbar Button Type, Color Instance Type, Window-System Types
@subsection Image Instance Type
@cindex image instance type

(not yet documented)

@node Toolbar Button Type, Subwindow Type, Image Instance Type, Window-System Types
@subsection Toolbar Button Type
@cindex toolbar button type

(not yet documented)

@node Subwindow Type, X Resource Type, Toolbar Button Type, Window-System Types
@subsection Subwindow Type
@cindex subwindow type

(not yet documented)

@node X Resource Type,  , Subwindow Type, Window-System Types
@subsection X Resource Type
@cindex X resource type

(not yet documented)

@node Type Predicates, Equality Predicates, Window-System Types, Lisp Data Types
@section Type Predicates
@cindex predicates
@cindex type checking
@kindex wrong-type-argument

  The XEmacs Lisp interpreter itself does not perform type checking on
the actual arguments passed to functions when they are called.  It could
not do so, since function arguments in Lisp do not have declared data
types, as they do in other programming languages.  It is therefore up to
the individual function to test whether each actual argument belongs to
a type that the function can use.

  All built-in functions do check the types of their actual arguments
when appropriate, and signal a @code{wrong-type-argument} error if an
argument is of the wrong type.  For example, here is what happens if you
pass an argument to @code{+} that it cannot handle:

@example
@group
(+ 2 'a)
     @error{} Wrong type argument: integer-or-marker-p, a
@end group
@end example

@cindex type predicates
@cindex testing types
  If you want your program to handle different types differently, you
must do explicit type checking.  The most common way to check the type
of an object is to call a @dfn{type predicate} function.  Emacs has a
type predicate for each type, as well as some predicates for
combinations of types.

  A type predicate function takes one argument; it returns @code{t} if
the argument belongs to the appropriate type, and @code{nil} otherwise.
Following a general Lisp convention for predicate functions, most type
predicates' names end with @samp{p}.

  Here is an example which uses the predicates @code{listp} to check for
a list and @code{symbolp} to check for a symbol.

@example
(defun add-on (x)
  (cond ((symbolp x)
         ;; If X is a symbol, put it on LIST.
         (setq list (cons x list)))
        ((listp x)
         ;; If X is a list, add its elements to LIST.
         (setq list (append x list)))
@need 3000
        (t
         ;; We only handle symbols and lists.
         (error "Invalid argument %s in add-on" x))))
@end example

  Here is a table of predefined type predicates, in alphabetical order,
with references to further information.

@table @code
@item annotationp
@xref{Annotation Primitives, annotationp}.

@item arrayp
@xref{Array Functions, arrayp}.

@item atom
@xref{List-related Predicates, atom}.

@item bit-vector-p
@xref{Bit Vector Functions, bit-vector-p}.

@item bitp
@xref{Bit Vector Functions, bitp}.

@item boolean-specifier-p
@xref{Specifier Types, boolean-specifier-p}.

@item buffer-glyph-p
@xref{Glyph Types, buffer-glyph-p}.

@item buffer-live-p
@xref{Killing Buffers, buffer-live-p}.

@item bufferp
@xref{Buffer Basics, bufferp}.

@item button-event-p
@xref{Event Predicates, button-event-p}.

@item button-press-event-p
@xref{Event Predicates, button-press-event-p}.

@item button-release-event-p
@xref{Event Predicates, button-release-event-p}.

@item case-table-p
@xref{Case Tables, case-table-p}.

@item char-int-p
@xref{Character Codes, char-int-p}.

@item char-or-char-int-p
@xref{Character Codes, char-or-char-int-p}.

@item char-or-string-p
@xref{Predicates for Strings, char-or-string-p}.

@item char-table-p
@xref{Char Tables, char-table-p}.

@item characterp
@xref{Predicates for Characters, characterp}.

@item color-instance-p
@xref{Colors, color-instance-p}.

@item color-pixmap-image-instance-p
@xref{Image Instance Types, color-pixmap-image-instance-p}.

@item color-specifier-p
@xref{Specifier Types, color-specifier-p}.

@item commandp
@xref{Interactive Call, commandp}.

@item compiled-function-p
@xref{Compiled-Function Type, compiled-function-p}.

@item console-live-p
@xref{Connecting to a Console or Device, console-live-p}.

@item consolep
@xref{Consoles and Devices, consolep}.

@item consp
@xref{List-related Predicates, consp}.

@item database-live-p
@xref{Connecting to a Database, database-live-p}.

@item databasep
@xref{Databases, databasep}.

@item device-live-p
@xref{Connecting to a Console or Device, device-live-p}.

@item device-or-frame-p
@xref{Basic Device Functions, device-or-frame-p}.

@item devicep
@xref{Consoles and Devices, devicep}.

@item eval-event-p
@xref{Event Predicates, eval-event-p}.

@item event-live-p
@xref{Event Predicates, event-live-p}.

@item eventp
@xref{Events, eventp}.

@item extent-live-p
@xref{Creating and Modifying Extents, extent-live-p}.

@item extentp
@xref{Extents, extentp}.

@item face-boolean-specifier-p
@xref{Specifier Types, face-boolean-specifier-p}.

@item facep
@xref{Basic Face Functions, facep}.

@item floatp
@xref{Predicates on Numbers, floatp}.

@item font-instance-p
@xref{Fonts, font-instance-p}.

@item font-specifier-p
@xref{Specifier Types, font-specifier-p}.

@item frame-live-p
@xref{Deleting Frames, frame-live-p}.

@item framep
@xref{Frames, framep}.

@item functionp
(not yet documented)

@item generic-specifier-p
@xref{Specifier Types, generic-specifier-p}.

@item glyphp
@xref{Glyphs, glyphp}.

@item hash-table-p
@xref{Hash Tables, hash-table-p}.

@item icon-glyph-p
@xref{Glyph Types, icon-glyph-p}.

@item image-instance-p
@xref{Images, image-instance-p}.

@item image-specifier-p
@xref{Specifier Types, image-specifier-p}.

@item integer-char-or-marker-p
@xref{Predicates on Markers, integer-char-or-marker-p}.

@item integer-or-char-p
@xref{Predicates for Characters, integer-or-char-p}.

@item integer-or-marker-p
@xref{Predicates on Markers, integer-or-marker-p}.

@item integer-specifier-p
@xref{Specifier Types, integer-specifier-p}.

@item integerp
@xref{Predicates on Numbers, integerp}.

@item itimerp
(not yet documented)

@item key-press-event-p
@xref{Event Predicates, key-press-event-p}.

@item keymapp
@xref{Creating Keymaps, keymapp}.

@item keywordp
(not yet documented)

@item listp
@xref{List-related Predicates, listp}.

@item markerp
@xref{Predicates on Markers, markerp}.

@item misc-user-event-p
@xref{Event Predicates, misc-user-event-p}.

@item mono-pixmap-image-instance-p
@xref{Image Instance Types, mono-pixmap-image-instance-p}.

@item motion-event-p
@xref{Event Predicates, motion-event-p}.

@item mouse-event-p
@xref{Event Predicates, mouse-event-p}.

@item natnum-specifier-p
@xref{Specifier Types, natnum-specifier-p}.

@item natnump
@xref{Predicates on Numbers, natnump}.

@item nlistp
@xref{List-related Predicates, nlistp}.

@item nothing-image-instance-p
@xref{Image Instance Types, nothing-image-instance-p}.

@item number-char-or-marker-p
@xref{Predicates on Markers, number-char-or-marker-p}.

@item number-or-marker-p
@xref{Predicates on Markers, number-or-marker-p}.

@item numberp
@xref{Predicates on Numbers, numberp}.

@item pointer-glyph-p
@xref{Glyph Types, pointer-glyph-p}.

@item pointer-image-instance-p
@xref{Image Instance Types, pointer-image-instance-p}.

@item process-event-p
@xref{Event Predicates, process-event-p}.

@item processp
@xref{Processes, processp}.

@item range-table-p
@xref{Range Tables, range-table-p}.

@item ringp
(not yet documented)

@item sequencep
@xref{Sequence Functions, sequencep}.

@item specifierp
@xref{Specifiers, specifierp}.

@item stringp
@xref{Predicates for Strings, stringp}.

@item subrp
@xref{Function Cells, subrp}.

@item subwindow-image-instance-p
@xref{Image Instance Types, subwindow-image-instance-p}.

@item subwindowp
@xref{Subwindows, subwindowp}.

@item symbolp
@xref{Symbols, symbolp}.

@item syntax-table-p
@xref{Syntax Tables, syntax-table-p}.

@item text-image-instance-p
@xref{Image Instance Types, text-image-instance-p}.

@item timeout-event-p
@xref{Event Predicates, timeout-event-p}.

@item toolbar-button-p
@xref{Toolbar, toolbar-button-p}.

@item toolbar-specifier-p
@xref{Toolbar, toolbar-specifier-p}.

@item user-variable-p
@xref{Defining Variables, user-variable-p}.

@item vectorp
@xref{Vectors, vectorp}.

@item weak-list-p
@xref{Weak Lists, weak-list-p}.

@ignore
@item wholenump
@xref{Predicates on Numbers, wholenump}.
@end ignore

@item window-configuration-p
@xref{Window Configurations, window-configuration-p}.

@item window-live-p
@xref{Deleting Windows, window-live-p}.

@item windowp
@xref{Basic Windows, windowp}.
@end table

  The most general way to check the type of an object is to call the
function @code{type-of}.  Recall that each object belongs to one and
only one primitive type; @code{type-of} tells you which one (@pxref{Lisp
Data Types}).  But @code{type-of} knows nothing about non-primitive
types.  In most cases, it is more convenient to use type predicates than
@code{type-of}.

@defun type-of object
This function returns a symbol naming the primitive type of
@var{object}.  The value is one of @code{bit-vector}, @code{buffer},
@code{char-table}, @code{character}, @code{charset},
@code{coding-system}, @code{cons}, @code{color-instance},
@code{compiled-function}, @code{console}, @code{database},
@code{device}, @code{event}, @code{extent}, @code{face}, @code{float},
@code{font-instance}, @code{frame}, @code{glyph}, @code{hash-table},
@code{image-instance}, @code{integer}, @code{keymap}, @code{marker},
@code{process}, @code{range-table}, @code{specifier}, @code{string},
@code{subr}, @code{subwindow}, @code{symbol}, @code{toolbar-button},
@code{tooltalk-message}, @code{tooltalk-pattern}, @code{vector},
@code{weak-list}, @code{window}, @code{window-configuration}, or
@code{x-resource}.

@example
(type-of 1)
     @result{} integer
(type-of 'nil)
     @result{} symbol
(type-of '())    ; @r{@code{()} is @code{nil}.}
     @result{} symbol
(type-of '(x))
     @result{} cons
@end example
@end defun

@node Equality Predicates,  , Type Predicates, Lisp Data Types
@section Equality Predicates
@cindex equality

  Here we describe two functions that test for equality between any two
objects.  Other functions test equality between objects of specific
types, e.g., strings.  For these predicates, see the appropriate chapter
describing the data type.

@defun eq object1 object2
This function returns @code{t} if @var{object1} and @var{object2} are
the same object, @code{nil} otherwise.  The ``same object'' means that a
change in one will be reflected by the same change in the other.

@code{eq} returns @code{t} if @var{object1} and @var{object2} are
integers with the same value.  Also, since symbol names are normally
unique, if the arguments are symbols with the same name, they are
@code{eq}.  For other types (e.g., lists, vectors, strings), two
arguments with the same contents or elements are not necessarily
@code{eq} to each other: they are @code{eq} only if they are the same
object.

(The @code{make-symbol} function returns an uninterned symbol that is
not interned in the standard @code{obarray}.  When uninterned symbols
are in use, symbol names are no longer unique.  Distinct symbols with
the same name are not @code{eq}.  @xref{Creating Symbols}.)

NOTE: Under XEmacs 19, characters are really just integers, and thus
characters and integers are @code{eq}.  Under XEmacs 20, it was
necessary to preserve remnants of this in function such as @code{old-eq}
in order to maintain byte-code compatibility.  Byte code compiled
under any Emacs 19 will automatically have calls to @code{eq} mapped
to @code{old-eq} when executed under XEmacs 20.

@example
@group
(eq 'foo 'foo)
     @result{} t
@end group

@group
(eq 456 456)
     @result{} t
@end group

@group
(eq "asdf" "asdf")
     @result{} nil
@end group

@group
(eq '(1 (2 (3))) '(1 (2 (3))))
     @result{} nil
@end group

@group
(setq foo '(1 (2 (3))))
     @result{} (1 (2 (3)))
(eq foo foo)
     @result{} t
(eq foo '(1 (2 (3))))
     @result{} nil
@end group

@group
(eq [(1 2) 3] [(1 2) 3])
     @result{} nil
@end group

@group
(eq (point-marker) (point-marker))
     @result{} nil
@end group
@end example

@end defun

@defun old-eq object1 object2
This function exists under XEmacs 20 and is exactly like @code{eq}
except that it suffers from the char-int confoundance disease.
In other words, it returns @code{t} if given a character and the
equivalent integer, even though the objects are of different types!
You should @emph{not} ever call this function explicitly in your
code.  However, be aware that all calls to @code{eq} in byte code
compiled under version 19 map to @code{old-eq} in XEmacs 20.
(Likewise for @code{old-equal}, @code{old-memq}, @code{old-member},
@code{old-assq} and  @code{old-assoc}.)

@example
@group
;; @r{Remember, this does not apply under XEmacs 19.}
?A
     @result{} ?A
(char-int ?A)
     @result{} 65
(old-eq ?A 65)
     @result{} t               ; @r{Eek, we've been infected.}
(eq ?A 65)
     @result{} nil             ; @r{We are still healthy.}
@end group
@end example
@end defun

@defun equal object1 object2
This function returns @code{t} if @var{object1} and @var{object2} have
equal components, @code{nil} otherwise.  Whereas @code{eq} tests if its
arguments are the same object, @code{equal} looks inside nonidentical
arguments to see if their elements are the same.  So, if two objects are
@code{eq}, they are @code{equal}, but the converse is not always true.

@example
@group
(equal 'foo 'foo)
     @result{} t
@end group

@group
(equal 456 456)
     @result{} t
@end group

@group
(equal "asdf" "asdf")
     @result{} t
@end group
@group
(eq "asdf" "asdf")
     @result{} nil
@end group

@group
(equal '(1 (2 (3))) '(1 (2 (3))))
     @result{} t
@end group
@group
(eq '(1 (2 (3))) '(1 (2 (3))))
     @result{} nil
@end group

@group
(equal [(1 2) 3] [(1 2) 3])
     @result{} t
@end group
@group
(eq [(1 2) 3] [(1 2) 3])
     @result{} nil
@end group

@group
(equal (point-marker) (point-marker))
     @result{} t
@end group

@group
(eq (point-marker) (point-marker))
     @result{} nil
@end group
@end example

Comparison of strings is case-sensitive.

Note that in FSF GNU Emacs, comparison of strings takes into account
their text properties, and you have to use @code{string-equal} if you
want only the strings themselves compared.  This difference does not
exist in XEmacs; @code{equal} and @code{string-equal} always return
the same value on the same strings.

@ignore @c Not true in XEmacs
Comparison of strings is case-sensitive and takes account of text
properties as well as the characters in the strings.  To compare
two strings' characters without comparing their text properties,
use @code{string=} (@pxref{Text Comparison}).
@end ignore

@example
@group
(equal "asdf" "ASDF")
     @result{} nil
@end group
@end example

Two distinct buffers are never @code{equal}, even if their contents
are the same.
@end defun

  The test for equality is implemented recursively, and circular lists may
therefore cause infinite recursion (leading to an error).