File: chap-5.texi

package info (click to toggle)
gclinfo 2.2-9
  • links: PTS
  • area: main
  • in suites: potato
  • size: 3,928 kB
  • ctags: 15
  • sloc: sed: 1,681; makefile: 127; lisp: 58; sh: 40
file content (6445 lines) | stat: -rw-r--r-- 199,332 bytes parent folder | download | duplicates (4)
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
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445


@node Data and Control Flow, Iteration, Types and Classes, Top
@chapter Data and Control Flow

@menu
* Generalized Reference::	
* Transfer of Control to an Exit Point::  
* Data and Control Flow Dictionary::  
@end menu

@node Generalized Reference, Transfer of Control to an Exit Point, Data and Control Flow, Data and Control Flow
@section Generalized Reference

@c including concept-places

@menu
* Overview of Places and Generalized Reference::  
* Kinds of Places::		
* Treatment of Other Macros Based on SETF::  
@end menu

@node Overview of Places and Generalized Reference, Kinds of Places, Generalized Reference, Generalized Reference
@subsection Overview of Places and Generalized Reference

A @i{generalized reference}
@IGindex{generalized reference}
 is the use of a @i{form},
sometimes called a @i{place}
@IGindex{place}
,
as if it were a @i{variable} that could be read and written.
The @i{value} of a @i{place} is 
the @i{object} to which the @i{place} @i{form} evaluates.
The @i{value} of a @i{place} can be changed by using @b{setf}.
The concept of binding a @i{place} is not defined in @r{Common Lisp},
but an @i{implementation} is permitted to extend the language by defining this concept.

Figure 5--1 contains examples of the use of @b{setf}.
Note that the values returned by evaluating the @i{forms} in column two 
are not necessarily the same as those obtained by evaluating the 
@i{forms} in column three.
In general, the exact @i{macro expansion} of a @b{setf} @i{form} is not guaranteed 
and can even be @i{implementation-dependent};
all that is guaranteed is 
 that the expansion is an update form that works
   for that particular @i{implementation},
 that the left-to-right evaluation of @i{subforms} is preserved, 
and
 that the ultimate result of evaluating @b{setf} is the value
  or values being stored.

@group
@noindent
@w{  Access function   Update Function   Update using @b{setf}              }
@w{  @t{x}                 @t{(setq x datum)}    @t{(setf x datum)}                 }
@w{  @t{(car x)}           @t{(rplaca x datum)}  @t{(setf (car x) datum)}           }
@w{  @t{(symbol-value x)}  @t{(set x datum)}     @t{(setf (symbol-value x) datum)}  }

@noindent
@w{                     Figure 5--1: Examples of setf                   }

@end group

Figure 5--2 shows @i{operators} relating to
@i{places} and @i{generalized reference}.

@group
@noindent
@w{  assert                defsetf             push     }
@w{  ccase                 get-setf-expansion  remf     }
@w{  ctypecase             getf                rotatef  }
@w{  decf                  incf                setf     }
@w{  define-modify-macro   pop                 shiftf   }
@w{  define-setf-expander  psetf                        }

@noindent
@w{  Figure 5--2: Operators relating to places and generalized reference.}

@end group

Some of the @i{operators} above manipulate @i{places}
and some manipulate @i{setf expanders}.
A @i{setf expansion} can be derived from any @i{place}.

New @i{setf expanders} can be defined by using @b{defsetf} 
and @b{define-setf-expander}.

@menu
* Evaluation of Subforms to Places::  
* Examples of Evaluation of Subforms to Places::  
* Setf Expansions::		
* Examples of Setf Expansions::	 
@end menu

@node Evaluation of Subforms to Places, Examples of Evaluation of Subforms to Places, Overview of Places and Generalized Reference, Overview of Places and Generalized Reference
@subsubsection Evaluation of Subforms to Places

The following rules apply to the @i{evaluation} of @i{subforms} in a
@i{place}:

@table @asis

@item 1.  
The evaluation ordering of @i{subforms} within a @i{place}
is determined by the order specified by the second value returned by

@b{get-setf-expansion}. 

For all @i{places} defined by this specification
(@i{e.g.}, @b{getf}, @b{ldb}, ...),
this order of evaluation is left-to-right.

@ITindex{order of evaluation}

@ITindex{evaluation order}

When a @i{place} is derived from a macro expansion,
this rule is applied after the macro is expanded to find the appropriate @i{place}. 

@i{Places} defined by using @b{defmacro} or

@b{define-setf-expander}

use the evaluation order defined by those definitions.
For example, consider the following:

@example
 (defmacro wrong-order (x y) `(getf ,y ,x))
@end example

This following @i{form} evaluates @t{place2} first and
then @t{place1} because that is the order they are evaluated in
the macro expansion:

@example
 (push value (wrong-order place1 place2))
@end example

@item 2.  

For the @i{macros} that manipulate @i{places} 
  (@b{push},
   @b{pushnew},
   @b{remf},
   @b{incf},
   @b{decf}, 
   @b{shiftf},
   @b{rotatef},
   @b{psetf},
   @b{setf},
   @b{pop}, and those defined by @b{define-modify-macro})
the @i{subforms} of the macro call are evaluated exactly once
in left-to-right order, with the @i{subforms} of the @i{places}
evaluated in the order specified in (1).

@b{push}, @b{pushnew}, @b{remf}, 
@b{incf}, @b{decf}, @b{shiftf}, @b{rotatef}, 
@b{psetf}, @b{pop} evaluate all @i{subforms} before modifying
any of the @i{place} locations.
@b{setf} (in the case when @b{setf} has more than two arguments) 
performs its operation on each pair in sequence. For example, in 

@example
 (setf place1 value1 place2 value2 ...)
@end example

the @i{subforms} of @t{place1} and @t{value1} are evaluated, the location
specified by 
@t{place1} is modified to contain the value returned by 
@t{value1}, and
then the rest of the @b{setf} form is processed in a like manner.

@item 3.  
For @b{check-type}, @b{ctypecase}, and @b{ccase},
@i{subforms} of the @i{place} are evaluated once as in (1),
but might be evaluated again if the
type check fails in the case of @b{check-type} 
or none of the cases hold in
@b{ctypecase} and @b{ccase}.

@item 4.  
For @b{assert}, the order of evaluation of the generalized 
references is not specified.
@ITindex{order of evaluation}

@ITindex{evaluation order}

@end table

Rules 2, 3 and 4 cover all @i{standardized} @i{macros} that manipulate @i{places}.

@node Examples of Evaluation of Subforms to Places, Setf Expansions, Evaluation of Subforms to Places, Overview of Places and Generalized Reference
@subsubsection Examples of Evaluation of Subforms to Places

@example
 (let ((ref2 (list '())))
   (push (progn (princ "1") 'ref-1)
         (car (progn (princ "2") ref2)))) 
@t{ |> } 12
@result{}  (REF1)

 (let (x)
    (push (setq x (list 'a))
          (car (setq x (list 'b))))
     x)
@result{}  (((A) . B))
@end example

@b{push} first evaluates @t{(setq x (list 'a)) @result{}  (a)},
 then evaluates @t{(setq x (list 'b)) @result{}  (b)},
 then modifies the @i{car} of this latest value to be @t{((a) . b)}.

@node Setf Expansions, Examples of Setf Expansions, Examples of Evaluation of Subforms to Places, Overview of Places and Generalized Reference
@subsubsection Setf Expansions

Sometimes it is possible to avoid evaluating @i{subforms} of a 
@i{place} multiple times or in the wrong order.  A

@i{setf expansion}

for a given access form can be expressed as an ordered collection of five @i{objects}:

@table @asis

@item @b{List of temporary variables}  
a list of symbols naming temporary variables to be bound
sequentially, as if by @b{let*}, to @i{values} 
resulting from value forms.

@item @b{List of value forms}  
a list of forms (typically, @i{subforms} of the
@i{place}) which when evaluated 
yield the values to which the corresponding temporary 
variables should be bound.

@item @b{List of store variables}  
a list of symbols naming temporary store variables which are
to hold the new values that will be assigned to the
@i{place}.

@item @b{Storing form}  
a form which can reference both the temporary and the store variables,
and which changes the @i{value} of the @i{place}
and guarantees to return as its values the values of the store variables,
which are the correct values for @b{setf} to return.

@item @b{Accessing form}  
a @i{form} which can reference the temporary variables,
and which returns the @i{value} of the @i{place}.
@end table

The value returned by the accessing form is
affected by execution of the storing form, but either of these
forms might be evaluated any number of times.

It is possible
to do more than one @b{setf} in parallel via
@b{psetf}, @b{shiftf}, and @b{rotatef}.  
Because of this, the 

@i{setf expander}

must produce new temporary 
and store variable names every time.  For examples of how to do this,
see @b{gensym}.

For each @i{standardized} accessor function @i{F},
unless it is explicitly documented otherwise,
it is @i{implementation-dependent} whether the ability to 
use an @i{F} @i{form} as a @b{setf} @i{place}
is implemented by a @i{setf expander} or a @i{setf function}.
Also, it follows from this that it is @i{implementation-dependent} 
whether the name @t{(setf @i{F})} is @i{fbound}.

@node Examples of Setf Expansions,  , Setf Expansions, Overview of Places and Generalized Reference
@subsubsection Examples of Setf Expansions

Examples of the contents of the constituents of @i{setf expansions}
follow.

For a variable @i{x}:

@group
@noindent
@w{  @t{()}              ;list of temporary variables  }
@w{  @t{()}              ;list of value forms          }
@w{  @t{(g0001)}         ;list of store variables      }
@w{  @t{(setq @i{x} g0001)}  ;storing form                 }
@w{  @i{x}               ;accessing form               }

@noindent
@w{  Figure 5--3: Sample Setf Expansion of a Variable}

@end group

For @t{(car @i{exp})}:

@group
@noindent
@w{  @t{(g0002)}                             ;list of temporary variables  }
@w{  @t{(@i{exp})}                               ;list of value forms          }
@w{  @t{(g0003)}                             ;list of store variables      }
@w{  @t{(progn (rplaca g0002 g0003) g0003)}  ;storing form                 }
@w{  @t{(car g0002)}                         ;accessing form               }

@noindent
@w{           Figure 5--4: Sample Setf Expansion of a CAR Form         }

@end group

For @t{(subseq @i{seq} @i{s} @i{e})}:

@group
@noindent
@w{  @t{(g0004 g0005 g0006)}         ;list of temporary variables  }
@w{  @t{(@i{seq} @i{s} @i{e})}                   ;list of value forms          }
@w{  @t{(g0007)}                     ;list of store variables      }
@w{  @t{(progn (replace g0004 g0007 :start1 g0005 :end1 g0006) g0007)} }
@w{                              ;storing form                 }
@w{  @t{(subseq g0004 g0005 g0006)}  ; accessing form              }

@noindent
@w{     Figure 5--5: Sample Setf Expansion of a SUBSEQ Form    }

@end group

In some cases, if a @i{subform} of a @i{place} is itself
a @i{place}, it is necessary to expand the @i{subform}
in order to compute some of the values in the expansion of the outer
@i{place}.  For @t{(ldb @i{bs} (car @i{exp}))}:

@group
@noindent
@w{  @t{(g0001 g0002)}            ;list of temporary variables  }
@w{  @t{(@i{bs} @i{exp})}                 ;list of value forms          }
@w{  @t{(g0003)}                  ;list of store variables      }
@w{  @t{(progn (rplaca g0002 (dpb g0003 g0001 (car g0002))) g0003)} }
@w{                           ;storing form                 }
@w{  @t{(ldb g0001 (car g0002))}  ; accessing form              }

@noindent
@w{     Figure 5--6: Sample Setf Expansion of a LDB Form    }

@end group

@node Kinds of Places, Treatment of Other Macros Based on SETF, Overview of Places and Generalized Reference, Generalized Reference
@subsection Kinds of Places

Several kinds of @i{places} are defined by @r{Common Lisp}; 
this section enumerates them.
This set can be extended by @i{implementations} and by @i{programmer code}.

@menu
* Variable Names as Places::	
* Function Call Forms as Places::  
* VALUES Forms as Places::	
* THE Forms as Places::		
* APPLY Forms as Places::	
* Setf Expansions and Places::	
* Macro Forms as Places::	
* Symbol Macros as Places::	
* Other Compound Forms as Places::  
@end menu

@node Variable Names as Places, Function Call Forms as Places, Kinds of Places, Kinds of Places
@subsubsection Variable Names as Places

The name of a @i{lexical variable} or @i{dynamic variable} 
can be used as a @i{place}.

@node Function Call Forms as Places, VALUES Forms as Places, Variable Names as Places, Kinds of Places
@subsubsection Function Call Forms as Places

A @i{function form} can be used as a @i{place} if it falls
into one of the following categories:

@table @asis

@item @t{*}  
A function call form whose first element is the name of
any one of the functions in Figure 5--7.

[Editorial Note by KMP: Note that what are in some places still called `condition accessors'
		 are deliberately omitted from this table, and are not labeled as
		 accessors in their entries.  I have not yet had time to do a full
	         search for these items and eliminate stray references to them as `accessors',
		 which they are not, but I will do that at some point.]

@group
@noindent
@w{  aref    cdadr                    get                            }
@w{  bit     cdar                     gethash                        }
@w{  caaaar  cddaar                   logical-pathname-translations  }
@w{  caaadr  cddadr                   macro-function                 }
@w{  caaar   cddar                    ninth                          }
@w{  caadar  cdddar                   nth                            }
@w{  caaddr  cddddr                   readtable-case                 }
@w{  caadr   cdddr                    rest                           }
@w{  caar    cddr                     row-major-aref                 }
@w{  cadaar  cdr                      sbit                           }
@w{  cadadr  char                     schar                          }
@w{  cadar   class-name               second                         }
@w{  caddar  compiler-macro-function  seventh                        }
@w{  cadddr  documentation            sixth                          }
@w{  caddr   eighth                   slot-value                     }
@w{  cadr    elt                      subseq                         }
@w{  car     fdefinition              svref                          }
@w{  cdaaar  fifth                    symbol-function                }
@w{  cdaadr  fill-pointer             symbol-plist                   }
@w{  cdaar   find-class               symbol-value                   }
@w{  cdadar  first                    tenth                          }
@w{  cdaddr  fourth                   third                          }

@noindent
@w{       Figure 5--7: Functions that setf can be used with---1      }

@end group

In the case of @b{subseq}, the replacement value must be a @i{sequence}
whose elements might be contained by the sequence argument to @b{subseq},
but does not have to be a @i{sequence} of the same @i{type} 
as the @i{sequence} of which the subsequence is specified.
If the length of the replacement value does not equal the length of
the subsequence to be replaced, then the shorter length determines
the number of elements to be stored, as for @b{replace}.

@item @t{*}  
A function call form whose first element is the name of
a selector function constructed by @b{defstruct}.

The function name must refer to the global function definition,
rather than a locally defined @i{function}.

@item @t{*}  
A function call form whose first element is the name of
any one of the functions in Figure 5--8, 
provided that the supplied argument
to that function is in turn a @i{place} form;
in this case the new @i{place} has stored back into it the
result of applying the supplied ``update'' function.

@group
@noindent
@w{  Function name  Argument that is a @i{place}  Update function used      }
@w{  @b{ldb}            second                    @b{dpb}                       }
@w{  @b{mask-field}     second                    @b{deposit-field}             }
@w{  @b{getf}           first                     @i{implementation-dependent}  }

@noindent
@w{         Figure 5--8: Functions that setf can be used with---2       }

@end group

During the @b{setf} expansion of these @i{forms}, it is necessary to call 

@b{get-setf-expansion} 

in order to figure out how the inner, nested generalized variable must be treated.  

The information from

@b{get-setf-expansion}

is used as follows.
@table @asis

@item @b{ldb}  
In a form such as:

@t{(setf (ldb @i{byte-spec} @i{place-form}) @i{value-form})}

the place referred to by the @i{place-form} must always be both @i{read} 
and @i{written};  note that the update is to the generalized variable 
specified by @i{place-form}, not to any object of @i{type} @b{integer}.

Thus this @b{setf} should generate code to do the following:

@table @asis

@item 1.  
Evaluate @i{byte-spec} (and bind it into a temporary variable).
@item 2.  
Bind the temporary variables for @i{place-form}.
@item 3.  
Evaluate @i{value-form}  (and bind 

its value or values into the store variable).

@item 4.  
Do the @i{read} from @i{place-form}.
@item 5.  
Do the @i{write} into @i{place-form} with 
the given bits of the @i{integer}
       fetched in step 4 replaced with the value from step 3.
@end table

    If the evaluation of @i{value-form} 
in step 3 alters what is found in @i{place-form},
such as setting different bits of @i{integer},
    then the change of the bits denoted by 
@i{byte-spec} is to that 
    altered @i{integer}, 
because step 4 is done after the @i{value-form}
    evaluation.  Nevertheless, the 
    evaluations required for @i{binding} 
the temporary variables are done in steps 1 and 
    2, and thus the expected left-to-right evaluation order is seen.
For example:

@example
 (setq integer #x69) @result{}  #x69
 (rotatef (ldb (byte 4 4) integer) 
          (ldb (byte 4 0) integer))
 integer @result{}  #x96
;;; This example is trying to swap two independent bit fields 
;;; in an integer.  Note that the generalized variable of 
;;; interest here is just the (possibly local) program variable
;;; integer.
@end example

@item @b{mask-field}  
This case is the same as @b{ldb} in all essential aspects.

@item @b{getf}  
In a form such as:

@t{(setf (getf @i{place-form} @i{ind-form}) @i{value-form})}

    the place referred to by @i{place-form} must always be both @i{read}
    and @i{written};  note that the update is to the generalized variable 
    specified by @i{place-form}, not necessarily to the particular 
@i{list}
that is the property list in question.

    Thus this @b{setf} should generate code to do the following:
@table @asis

@item 1.  
Bind the temporary variables for @i{place-form}.
@item 2.  
Evaluate @i{ind-form} (and bind it into a temporary variable).
@item 3.  
Evaluate @i{value-form} (and bind 

its value or values into the store variable).

@item 4.  
Do the @i{read} from @i{place-form}.
@item 5.  
Do the @i{write} into @i{place-form} with a possibly-new property list
       obtained by combining the values from steps 2, 3, and 4.  
(Note that the phrase ``possibly-new property list'' can mean that 
    the former property list is somehow destructively re-used, or it can 
    mean partial or full copying of it.  
Since either copying or destructive re-use can occur, 
the treatment of the resultant value for the 
    possibly-new property list must proceed as if it were a different copy
    needing to be stored back into the generalized variable.)
@end table

    If the evaluation of @i{value-form} 
in step 3 alters what is found in
@i{place-form}, such as setting a different named property in the list,
    then the change of the property denoted by @i{ind-form} 
is to that 
    altered list, because step 4 is done after the 
@i{value-form}
    evaluation.  Nevertheless, the 
    evaluations required for @i{binding} 
the temporary variables  are done in steps 1 and 
    2,  and thus the expected left-to-right evaluation order is seen.

For example:

@example
 (setq s (setq r (list (list 'a 1 'b 2 'c 3)))) @result{}  ((a 1 b 2 c 3))
 (setf (getf (car r) 'b) 
       (progn (setq r nil) 6)) @result{}  6
 r @result{}  NIL
 s @result{}  ((A 1 B 6 C 3))
;;; Note that the (setq r nil) does not affect the actions of 
;;; the SETF because the value of R had already been saved in 
;;; a temporary variable as part of the step 1. Only the CAR
;;; of this value will be retrieved, and subsequently modified 
;;; after the value computation.
@end example

@end table

@end table

@node VALUES Forms as Places, THE Forms as Places, Function Call Forms as Places, Kinds of Places
@subsubsection VALUES Forms as Places

A @b{values} @i{form} can be used as a @i{place},
provided that each of its @i{subforms} is also a @i{place} form.

A form such as

@t{(setf (values @i{place-1} \dots @i{place-n}) @i{values-form})}

does the following:

@table @asis

@item 1.  
The @i{subforms} of each nested @i{place} are evaluated
in left-to-right order.
@item 2.  
The @i{values-form} is evaluated, and the first store
variable from each @i{place} is bound to its return values as if by 
@b{multiple-value-bind}.  
@item 3.  
If the @i{setf expansion} for any @i{place} 
involves more than one store variable, then the additional
store variables are bound to @b{nil}.
@item 4.  
The storing forms for each @i{place} are evaluated in
left-to-right order.
@end table

The storing form in the @i{setf expansion} of @b{values}
returns as @i{multiple values}_2 the values of the store
variables in step 2.  That is, the number of values returned is the
same as the number of @i{place} forms.  This may be more or fewer
values than are produced by the @i{values-form}.

@node THE Forms as Places, APPLY Forms as Places, VALUES Forms as Places, Kinds of Places
@subsubsection THE Forms as Places

A @b{the} @i{form} can be used as a @i{place},
in which case the declaration is transferred to the @i{newvalue} form,
and the resulting @b{setf} is analyzed.  For example,

@example
 (setf (the integer (cadr x)) (+ y 3))
@end example

is processed as if it were

@example
 (setf (cadr x) (the integer (+ y 3)))
@end example

@node APPLY Forms as Places, Setf Expansions and Places, THE Forms as Places, Kinds of Places
@subsubsection APPLY Forms as Places

The following situations involving @b{setf} of @b{apply} must be supported:

@table @asis

@item @t{*}  
@t{(setf (apply #'aref @i{array}
				        @{@i{subscript}@}{*}
					@i{more-subscripts})
			  @i{new-element})}
@item @t{*}  
@t{(setf (apply #'bit @i{array} 
				       @{@i{subscript}@}{*}
				       @i{more-subscripts})
			  @i{new-element})}
@item @t{*}  
@t{(setf (apply #'sbit @i{array} 
					@{@i{subscript}@}{*}
					@i{more-subscripts}) 
			  @i{new-element})}
@end table

In all three cases, the @i{element} of @i{array} designated
by the concatenation of @i{subscripts} and @i{more-subscripts}
(@i{i.e.}, the same @i{element} which would be @i{read} by the call to
     @i{apply} if it were not part of a @b{setf} @i{form})
is changed to have the @i{value} given by @i{new-element}.

For these usages, the function name (@b{aref}, @b{bit}, or @b{sbit})
must refer to the global function definition, rather than a locally defined
@i{function}.

No other @i{standardized} @i{function} is required to be supported,
but an @i{implementation} may define such support.
An @i{implementation} may also define support 
for @i{implementation-defined} @i{operators}.

If a user-defined @i{function} is used in this context,
the following equivalence is true, except that care is taken
to preserve proper left-to-right evaluation of argument @i{subforms}:

@example
 (setf (apply #'@i{name} @{@i{arg}@}{*}) @i{val})
 @equiv{} (apply #'(setf @i{name}) @i{val} @{@i{arg}@}{*})
@end example

@node Setf Expansions and Places, Macro Forms as Places, APPLY Forms as Places, Kinds of Places
@subsubsection Setf Expansions and Places

Any @i{compound form} for which the @i{operator} has a

@i{setf expander}

defined can be used as a @i{place}.

The 
@i{operator}
must refer to the global function definition,
rather than a locally defined @i{function} or @i{macro}.

@node Macro Forms as Places, Symbol Macros as Places, Setf Expansions and Places, Kinds of Places
@subsubsection Macro Forms as Places

A @i{macro form} can be used as a @i{place}, 
in which case @r{Common Lisp} expands the @i{macro form}

as if by @b{macroexpand-1}

and then uses the @i{macro expansion} in place of the original @i{place}.

Such @i{macro expansion} is attempted only after exhausting all other possibilities
other than expanding into a call to a function named @t{(setf @i{reader})}.

@node Symbol Macros as Places, Other Compound Forms as Places, Macro Forms as Places, Kinds of Places
@subsubsection Symbol Macros as Places

A reference to a @i{symbol} that has been @i{established} as a @i{symbol macro} 
can be used as a @i{place}.  In this case,
@b{setf} expands the reference and then analyzes the resulting @i{form}.

@node Other Compound Forms as Places,  , Symbol Macros as Places, Kinds of Places
@subsubsection Other Compound Forms as Places

For any other @i{compound form} for which the @i{operator} is a
@i{symbol} @i{f},
the @b{setf} @i{form} expands into a call 
to the @i{function} named @t{(setf @i{f})}.
The first @i{argument} in the newly constructed @i{function form}
is @i{newvalue} and the
     remaining @i{arguments} are the remaining @i{elements} of
     @i{place}.
This expansion occurs regardless of whether @i{f} or @t{(setf @i{f})}
is defined as a @i{function} locally, globally, or not at all.
For example,

@t{(setf (@i{f} @i{arg1} @i{arg2} ...) @i{new-value})}

expands into a form with the same effect and value as

@example
 (let ((#:temp-1 arg1)          ;force correct order of evaluation
       (#:temp-2 arg2)
       ...
       (#:temp-0 @i{new-value}))
   (funcall (function (setf @i{f})) #:temp-0 #:temp-1 #:temp-2...))
@end example

A @i{function} named @t{(setf @i{f})} must return its first argument
as its only value in order to preserve the semantics of @b{setf}.

@node Treatment of Other Macros Based on SETF,  , Kinds of Places, Generalized Reference
@subsection Treatment of Other Macros Based on SETF

For each of the ``read-modify-write'' @i{operators} in Figure 5--9, 
and for any additional @i{macros} 
defined by the @i{programmer} using @b{define-modify-macro},
an exception is made to the normal rule of left-to-right evaluation of arguments.
Evaluation of @i{argument} @i{forms} occurs in left-to-right order,
with the exception that for the @i{place} @i{argument}, the actual
@i{read} of the ``old value'' from that @i{place} happens 
after all of the @i{argument} @i{form} @i{evaluations}, 
and just before a ``new value'' is computed and @i{written} back into the @i{place}.

Specifically, each of these @i{operators} can be viewed as involving a
@i{form} with the following general syntax:

@example
 (@i{operator} @{@i{preceding-form}@}{*} @i{place} @{@i{following-form}@}{*})
@end example

The evaluation of each such @i{form} proceeds like this:

@table @asis

@item 1.  
@i{Evaluate} each of the @i{preceding-forms}, in left-to-right order.
@item 2.  
@i{Evaluate} the @i{subforms} of the @i{place},
 in the order specified by the second value of the @i{setf expansion}
 for that @i{place}.
@item 3.  
@i{Evaluate} each of the @i{following-forms}, in left-to-right order.
@item 4.  
@i{Read} the old value from @i{place}.
@item 5.  
Compute the new value.
@item 6.  
Store the new value into @i{place}.
@end table

@group
@noindent
@w{  decf  pop   pushnew  }
@w{  incf  push  remf     }

@noindent
@w{  Figure 5--9: Read-Modify-Write Macros}

@end group

@c end of including concept-places

@node Transfer of Control to an Exit Point, Data and Control Flow Dictionary, Generalized Reference, Data and Control Flow
@section Transfer of Control to an Exit Point

@c including concept-exits

When a transfer of control is initiated by @b{go}, 
@b{return-from}, or @b{throw}
the following events occur in order to accomplish the transfer of control.
Note that for @b{go}, 
the @i{exit point} is the @i{form} within the @b{tagbody}
that is being executed at the time the @b{go} is performed;
for @b{return-from},
the @i{exit point} is the corresponding 
@b{block} @i{form};
and for @b{throw},
the @i{exit point} is the corresponding 
@b{catch} @i{form}. 

@table @asis

@item 1.  
Intervening @i{exit points} are ``abandoned''
 (@i{i.e.}, their @i{extent} ends 
      and it is no longer valid to attempt to transfer control through them).

@item 2.  
The cleanup clauses of any intervening @b{unwind-protect} clauses
 are evaluated.

@item 3.  
Intervening dynamic @i{bindings} of @b{special} variables,
 @i{catch tags}, @i{condition handlers}, and @i{restarts}
 are undone.

@item 4.  
The @i{extent} of the @i{exit point} being invoked ends,
 and control is passed to the target.
@end table

The extent of an exit being ``abandoned'' because it is being passed over
ends as soon as the transfer of control is initiated. That is,
event 1 occurs at the beginning of the initiation of the transfer of
control. 
The consequences are undefined if an attempt is made to transfer control 
to an @i{exit point} whose @i{dynamic extent} has ended.

Events 2 and 3 are actually performed interleaved, in the order
corresponding to the reverse order in which they were established.
The effect of this is that the cleanup clauses of an @b{unwind-protect}
see the same dynamic @i{bindings} 
of variables and @i{catch tags} as were
visible when the @b{unwind-protect} was entered.

Event 4 occurs at the end of the transfer of control.

@c end of including concept-exits

@node Data and Control Flow Dictionary,  , Transfer of Control to an Exit Point, Data and Control Flow
@section Data and Control Flow Dictionary

@c including dict-flow

@menu
* apply::			
* defun::			
* fdefinition::			
* fboundp::			
* fmakunbound::			
* flet::			
* funcall::			
* function (Special Operator)::	 
* function-lambda-expression::	
* functionp::			
* compiled-function-p::		
* call-arguments-limit::	
* lambda-list-keywords::	
* lambda-parameters-limit::	
* defconstant::			
* defparameter::		
* destructuring-bind::		
* let::				
* progv::			
* setq::			
* psetq::			
* block::			
* catch::			
* go::				
* return-from::			
* return::			
* tagbody::			
* throw::			
* unwind-protect::		
* nil::				
* not::				
* t::				
* eq::				
* eql::				
* equal::			
* equalp::			
* identity::			
* complement::			
* constantly::			
* every::			
* and::				
* cond::			
* if::				
* or::				
* when::			
* case::			
* typecase::			
* multiple-value-bind::		
* multiple-value-call::		
* multiple-value-list::		
* multiple-value-prog1::	
* multiple-value-setq::		
* values::			
* values-list::			
* multiple-values-limit::	
* nth-value::			
* prog::			
* prog1::			
* progn::			
* define-modify-macro::		
* defsetf::			
* define-setf-expander::	
* get-setf-expansion::		
* setf::			
* shiftf::			
* rotatef::			
* control-error::		
* program-error::		
* undefined-function::		
@end menu

@node apply, defun, Data and Control Flow Dictionary, Data and Control Flow Dictionary
@subsection apply                                                            [Function]

@code{apply}  @i{function {&rest} args^+} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{function}---a @i{function designator}.

@i{args}---a @i{spreadable argument list designator}.

@i{results}---the @i{values} returned by @i{function}.

@subsubheading  Description::

@i{Applies} the @i{function} to the @i{args}.

When the @i{function} receives its arguments via @b{&rest}, it is 
permissible (but not required) for the @i{implementation} to @i{bind} 
the @i{rest parameter}
to an @i{object} that shares structure with the last argument to @b{apply}.
Because a @i{function} can neither detect whether it was called via @b{apply}
nor whether (if so) the last argument to @b{apply} was a @i{constant},
@i{conforming programs} must neither rely on the @i{list} structure 
of a @i{rest list} to be freshly consed, nor modify that @i{list} structure. 

@b{setf} can be used with @b{apply} in certain circumstances;
see @ref{APPLY Forms as Places}.

@subsubheading  Examples::

@example
 (setq f '+) @result{}  +
 (apply f '(1 2)) @result{}  3
 (setq f #'-) @result{}  #<FUNCTION ->
 (apply f '(1 2)) @result{}  -1
 (apply #'max 3 5 '(2 7 3)) @result{}  7
 (apply 'cons '((+ 2 3) 4)) @result{}  ((+ 2 3) . 4)
 (apply #'+ '()) @result{}  0

 (defparameter *some-list* '(a b c))
 (defun strange-test (&rest x) (eq x *some-list*))
 (apply #'strange-test *some-list*) @result{}  @i{implementation-dependent}

 (defun bad-boy (&rest x) (rplacd x 'y))
 (bad-boy 'a 'b 'c) has undefined consequences.
 (apply #'bad-boy *some-list*) has undefined consequences.
@end example

@example
 (defun foo (size &rest keys &key double &allow-other-keys)
   (let ((v (apply #'make-array size :allow-other-keys t keys)))
     (if double (concatenate (type-of v) v v) v)))
 (foo 4 :initial-contents '(a b c d) :double t)
    @result{}  #(A B C D A B C D)
@end example

@subsubheading  See Also::

@ref{funcall}
,
@ref{fdefinition}
,
@b{function},
@ref{Evaluation},
@ref{APPLY Forms as Places}

@node defun, fdefinition, apply, Data and Control Flow Dictionary
@subsection defun                                                               [Macro]

@code{defun}  @i{function-name lambda-list {[[@{@i{declaration}@}{*} | @i{documentation}]]} @{@i{form}@}{*}}@*
   @result{}  @i{function-name}

@subsubheading  Arguments and Values:: 

@i{function-name}---a @i{function name}.

@i{lambda-list}---an @i{ordinary lambda list}.

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{documentation}---a @i{string}; not evaluated.

@i{forms}---an @i{implicit progn}.

@i{block-name}---the @i{function block name} of the @i{function-name}.

@subsubheading  Description::

Defines a new @i{function} named @i{function-name} in the @i{global environment}.
The body of the @i{function} defined by @b{defun} consists 
of @i{forms}; they are executed as an @i{implicit progn}
when the @i{function} is called. 
@b{defun} can be used
     to define a new @i{function},
     to install a corrected version of an incorrect definition,
     to redefine an already-defined @i{function},
  or to redefine a @i{macro} as a @i{function}.

@b{defun} implicitly puts a @b{block} named @i{block-name}
around the body @i{forms} 

(but not the @i{forms} in the @i{lambda-list})

of the @i{function} defined.

@i{Documentation} is attached as a @i{documentation string} 
    to @i{name} (as kind @b{function})
and to the @i{function} @i{object}.

Evaluating @b{defun} causes @i{function-name} to be a global name
for the @i{function} specified by the @i{lambda expression}

@example
 (lambda @i{lambda-list}
   {[[@{@i{declaration}@}{*} | @i{documentation}]]}
   (block @i{block-name} @{@i{form}@}{*}))
@end example

processed in the @i{lexical environment} in which @b{defun} was executed.

(None of the arguments are evaluated at macro expansion time.)

@b{defun} is not required to perform any compile-time side effects.
In particular, @b{defun} does not make the @i{function} definition available
at compile time.  An @i{implementation} may choose to store information
about the @i{function} for the purposes of compile-time error-checking
(such as checking the number of arguments on calls),
or to enable the @i{function} to be expanded inline.

@subsubheading  Examples::

@example
 (defun recur (x)
  (when (> x 0)
    (recur (1- x)))) @result{}  RECUR 
 (defun ex (a b &optional c (d 66) &rest keys &key test (start 0))
    (list a b c d keys test start)) @result{}  EX 
 (ex 1 2) @result{}  (1 2 NIL 66 NIL NIL 0)
 (ex 1 2 3 4 :test 'equal :start 50) 
@result{}  (1 2 3 4 (:TEST EQUAL :START 50) EQUAL 50)
 (ex :test 1 :start 2) @result{}  (:TEST 1 :START 2 NIL NIL 0)

 ;; This function assumes its callers have checked the types of the
 ;; arguments, and authorizes the compiler to build in that assumption.
 (defun discriminant (a b c)
   (declare (number a b c))
   "Compute the discriminant for a quadratic equation."
   (- (* b b) (* 4 a c))) @result{}  DISCRIMINANT
 (discriminant 1 2/3 -2) @result{}  76/9

 ;; This function assumes its callers have not checked the types of the
 ;; arguments, and performs explicit type checks before making any assumptions. 
 (defun careful-discriminant (a b c)
   "Compute the discriminant for a quadratic equation."
   (check-type a number)
   (check-type b number)
   (check-type c number)
   (locally (declare (number a b c))
     (- (* b b) (* 4 a c)))) @result{}  CAREFUL-DISCRIMINANT
 (careful-discriminant 1 2/3 -2) @result{}  76/9
@end example

@subsubheading  See Also::

@ref{flet; labels; macrolet}
,
@b{labels}, 
@ref{block}
,
@ref{return-from}
,
@b{declare}, 
@ref{documentation; (setf documentation)}
,
@ref{Evaluation},
@ref{Ordinary Lambda Lists},
@ref{Syntactic Interaction of Documentation Strings and Declarations}

@subsubheading  Notes::
@b{return-from} can be used to return
prematurely from a @i{function} defined by @b{defun}.

Additional side effects might take place when additional information
(typically debugging information)
about the function definition is recorded. 

@node fdefinition, fboundp, defun, Data and Control Flow Dictionary
@subsection fdefinition                                                      [Accessor]

@code{fdefinition}  @i{function-name} @result{}  @i{definition}

(setf (@code{         fdefinition} @i{function-name}) new-definition)@*

@subsubheading  Arguments and Values::

@i{function-name}---a @i{function name}.

In the non-@b{setf} case, 
the @i{name} must be @i{fbound} in the @i{global environment}.

@i{definition}---Current global function definition named by @i{function-name}.  

@i{new-definition}---a @i{function}.

@subsubheading  Description::

@b{fdefinition} @i{accesses} the current global function definition
named by @i{function-name}.  The definition may be a
@i{function} or may be an @i{object} representing a 
@i{special form} or @i{macro}.

The value returned by @b{fdefinition} when @b{fboundp} returns true
but the @i{function-name} denotes a @i{macro} or 
@i{special form} is not well-defined, but @b{fdefinition} does not signal an error. 

@subsubheading  Exceptional Situations::

Should signal an error of @i{type} @b{type-error}
			      if @i{function-name} is not a @i{function name}.

An error of @i{type} @b{undefined-function} is signaled 
in the non-@b{setf} case if @i{function-name} is not @i{fbound}.

@subsubheading  See Also::

@ref{fboundp}
,
@ref{fmakunbound}
,
@ref{macro-function}
,

@ref{special-operator-p}
,

@ref{symbol-function}

@subsubheading  Notes::

@b{fdefinition} cannot @i{access} the value of a lexical function name
produced by @b{flet} or @b{labels}; it can @i{access} only
the global function value.

@b{setf} can be used with 
@b{fdefinition} to replace a global function
definition when the @i{function-name}'s function definition 
does not represent a @i{special form}.

@b{setf} of @b{fdefinition} 
requires a @i{function} as the new value.
It is an error to set the @b{fdefinition} of a @i{function-name}
to a @i{symbol}, a @i{list}, or the value returned
by @b{fdefinition} on the name of a @i{macro} 
or @i{special form}.

@node fboundp, fmakunbound, fdefinition, Data and Control Flow Dictionary
@subsection fboundp                                                          [Function]

@code{fboundp}  @i{name} @result{}  @i{generalized-boolean}

@subsubheading  Pronunciation::

pronounced ,ef 'baund p\=e

@subsubheading  Arguments and Values::

@i{name}---a @i{function name}.

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

Returns @i{true} if @i{name} is @i{fbound};
otherwise, returns @i{false}.

@subsubheading  Examples::

@example
 (fboundp 'car) @result{}  @i{true}
 (fboundp 'nth-value) @result{}  @i{false}
 (fboundp 'with-open-file) @result{}  @i{true}
 (fboundp 'unwind-protect) @result{}  @i{true}
 (defun my-function (x) x) @result{}  MY-FUNCTION
 (fboundp 'my-function) @result{}  @i{true}
 (let ((saved-definition (symbol-function 'my-function)))
   (unwind-protect (progn (fmakunbound 'my-function)
                          (fboundp 'my-function))
     (setf (symbol-function 'my-function) saved-definition)))
@result{}  @i{false}
 (fboundp 'my-function) @result{}  @i{true}
 (defmacro my-macro (x) `',x) @result{}  MY-MACRO
 (fboundp 'my-macro) @result{}  @i{true}
 (fmakunbound 'my-function) @result{}  MY-FUNCTION
 (fboundp 'my-function) @result{}  @i{false}
 (flet ((my-function (x) x))
   (fboundp 'my-function)) @result{}  @i{false}
@end example

@subsubheading  Exceptional Situations::

Should signal an error of @i{type} @b{type-error}
			      if @i{name} is not a @i{function name}.

@subsubheading  See Also::

@ref{symbol-function}
, 
@ref{fmakunbound}
, 
@ref{fdefinition}

@subsubheading  Notes::

It is permissible to call @b{symbol-function} on any @i{symbol}
that is @i{fbound}.

@b{fboundp} is sometimes used to ``guard''
an access to the @i{function cell}, as in:
@example
(if (fboundp x) (symbol-function x))
@end example

Defining a @i{setf expander} @i{F} does not cause the @i{setf function}
@t{(setf @i{F})} to become defined.

@node fmakunbound, flet, fboundp, Data and Control Flow Dictionary
@subsection fmakunbound                                                      [Function]

@code{fmakunbound}  @i{name} @result{}  @i{name}

@subsubheading  Pronunciation::

    pronounced ,ef 'mak e n,baund 
 or pronounced ,ef 'm\=a k e n,baund 

@subsubheading  Arguments and Values::

@i{name}---a @i{function name}.

@subsubheading  Description::

Removes the @i{function} or @i{macro} definition, if any, of @i{name} 
in the @i{global environment}.

@subsubheading  Examples::

@example
(defun add-some (x) (+ x 19)) @result{}  ADD-SOME
 (fboundp 'add-some) @result{}  @i{true}
 (flet ((add-some (x) (+ x 37)))
    (fmakunbound 'add-some)
    (add-some 1)) @result{}  38
 (fboundp 'add-some) @result{}  @i{false}
@end example

@subsubheading  Exceptional Situations::

Should signal an error of @i{type} @b{type-error}
			      if @i{name} is not a @i{function name}.

The consequences are undefined if @i{name} is a @i{special operator}.

@subsubheading  See Also::

@ref{fboundp}
, 
@ref{makunbound}

@node flet, funcall, fmakunbound, Data and Control Flow Dictionary
@subsection flet, labels, macrolet                                   [Special Operator]

@code{flet}  @i{@r{(}@{{(}@i{function-name} 
				                  @i{lambda-list}
				      		  {[[@{@i{local-declaration}@}{*} 
				  | @i{local-documentation}]]}
				      		  @{@i{local-form}@}{*}@r{)}@}{*}@r{)}
			  @{@i{declaration}@}{*} @{@i{form}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@code{labels}  @i{@r{(}@{{(}@i{function-name} 
				                  @i{lambda-list}
				      		  {[[@{@i{local-declaration}@}{*} 
				  | @i{local-documentation}]]}
				      		  @{@i{local-form}@}{*}@r{)}@}{*}@r{)}
			  @{@i{declaration}@}{*} @{@i{form}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@code{macrolet}  @i{@r{(}@{{(}@i{name} 
				                  @i{lambda-list}
				      		  {[[@{@i{local-declaration}@}{*} 
				  | @i{local-documentation}]]}
				      		  @{@i{local-form}@}{*}@r{)}@}{*}@r{)}
			  @{@i{declaration}@}{*} @{@i{form}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values:: 

@i{function-name}---a @i{function name}.

@i{name}---a @i{symbol}.

@i{lambda-list}---a @i{lambda list}; 
		      for @b{flet} and @b{labels},
			 it is an @i{ordinary lambda list};
		      for @b{macrolet},
			 it is a @i{macro lambda list}.

@i{local-declaration}---a @b{declare} @i{expression}; not evaluated.

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{local-documentation}---a @i{string}; not evaluated.

@i{local-forms}, @i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} of the @i{forms}.

@subsubheading  Description::

@b{flet}, @b{labels}, and @b{macrolet}
define local @i{functions} and @i{macros}, and execute
@i{forms} using the local definitions.
@i{Forms} are executed  in order of occurrence.

The body forms (but not the @i{lambda list})

of each @i{function} created by @b{flet} and @b{labels} 
and each @i{macro} created by @b{macrolet}
are enclosed in an @i{implicit block} whose name 
is the @i{function block name} of the @i{function-name} or @i{name}, 
as appropriate.

The scope of the @i{declarations}
between
the list of local function/macro definitions and the body @i{forms}
in @b{flet} and @b{labels} 
does not include the bodies of the
locally defined @i{functions}, except that for @b{labels},
any @b{inline}, @b{notinline}, or @b{ftype} declarations
that refer to the locally defined functions do apply to the local function
bodies. That is, their @i{scope} 
is the same as the function name that they
affect.  

The scope of these @i{declarations} 
does not include the bodies of the macro expander
functions defined by @b{macrolet}.  

@table @asis

@item flet  
@b{flet} defines locally named @i{functions} and executes a series of
@i{forms} with these definition @i{bindings}.  Any number of
such local @i{functions} can be defined.  

The @i{scope} of the name @i{binding} encompasses only the body.
Within the
body of @b{flet}, 
@i{function-names} matching those defined
by @b{flet} 
refer to the locally defined @i{functions} 
rather than to
the global function definitions of the same name.

Also, within the scope of @b{flet}, 
global @i{setf expander} definitions of the @i{function-name}
defined by @b{flet} do not apply. 
Note that this applies to 
@t{(defsetf @i{f} ...)}, not
@t{(defmethod (setf @i{f}) ...)}.

The names of @i{functions} defined by @b{flet} 
are in the @i{lexical environment}; they retain
their local definitions only within the body of @b{flet}.
The function definition bindings are visible only in
the body of @b{flet}, not the definitions themselves.  Within the
function definitions, local function names
that match those being
defined refer to @i{functions} or 
@i{macros} defined outside the @b{flet}.
@b{flet} can locally @i{shadow} a global function name,
and the new definition can refer to the global definition.

Any @i{local-documentation} is attached to the corresponding local @i{function}
(if one is actually created) as a @i{documentation string}.

@item labels  
@b{labels} is equivalent to @b{flet} except that
the scope of the defined function names for @b{labels} 
encompasses the function definitions themselves as well as the body.

@item macrolet  
@b{macrolet} 
establishes local @i{macro} definitions,
using the same format used by @b{defmacro}.

Within the body of @b{macrolet}, 
global @i{setf expander} definitions of the @i{names} defined by the 
@b{macrolet} do not apply; rather, @b{setf} expands the
@i{macro form} and recursively process the resulting @i{form}.

The macro-expansion functions defined by @b{macrolet} 
are defined in the 

@i{lexical environment} in which the @b{macrolet} form appears.
Declarations and @b{macrolet} and 
@b{symbol-macrolet} definitions
affect the local macro definitions in a @b{macrolet}, but the
consequences are undefined if the local macro definitions reference
any local @i{variable} or @i{function} @i{bindings} that are visible in that
@i{lexical environment}.

Any @i{local-documentation} is attached to the corresponding local @i{macro function}
as a @i{documentation string}.

@end table

@subsubheading  Examples::

@example
 (defun foo (x flag)
   (macrolet ((fudge (z)
                 ;The parameters x and flag are not accessible
                 ; at this point; a reference to flag would be to
                 ; the global variable of that name.
                 ` (if flag (* ,z ,z) ,z)))
    ;The parameters x and flag are accessible here.
     (+ x
        (fudge x)
        (fudge (+ x 1)))))
 @equiv{}
 (defun foo (x flag)
   (+ x
      (if flag (* x x) x)
      (if flag (* (+ x 1) (+ x 1)) (+ x 1))))
@end example

after macro expansion.  The occurrences of @t{x} and @t{flag} legitimately
refer to the parameters of the function @t{foo} because those parameters are
visible at the site of the macro call which produced the expansion.

@example
 (flet ((flet1 (n) (+ n n)))
    (flet ((flet1 (n) (+ 2 (flet1 n))))
      (flet1 2))) @result{}  6

 (defun dummy-function () 'top-level) @result{}  DUMMY-FUNCTION 
 (funcall #'dummy-function) @result{}  TOP-LEVEL 
 (flet ((dummy-function () 'shadow)) 
      (funcall #'dummy-function)) @result{}  SHADOW 
 (eq (funcall #'dummy-function) (funcall 'dummy-function))
@result{}  @i{true} 
 (flet ((dummy-function () 'shadow))
   (eq (funcall #'dummy-function)
       (funcall 'dummy-function)))
@result{}  @i{false} 

 (defun recursive-times (k n)
   (labels ((temp (n) 
              (if (zerop n) 0 (+ k (temp (1- n))))))
     (temp n))) @result{}  RECURSIVE-TIMES
 (recursive-times 2 3) @result{}  6

 (defmacro mlets (x &environment env) 
    (let ((form `(babbit ,x)))
      (macroexpand form env))) @result{}  MLETS
 (macrolet ((babbit (z) `(+ ,z ,z))) (mlets 5)) @result{}  10
@end example

@example
 (flet ((safesqrt (x) (sqrt (abs x))))
  ;; The safesqrt function is used in two places.
   (safesqrt (apply #'+ (map 'list #'safesqrt '(1 2 3 4 5 6)))))
@result{}  3.291173
@end example

@example
 (defun integer-power (n k)     
   (declare (integer n))         
   (declare (type (integer 0 *) k))
   (labels ((expt0 (x k a)
              (declare (integer x a) (type (integer 0 *) k))
              (cond ((zerop k) a)
                    ((evenp k) (expt1 (* x x) (floor k 2) a))
                    (t (expt0 (* x x) (floor k 2) (* x a)))))
            (expt1 (x k a)
              (declare (integer x a) (type (integer 0 *) k))
              (cond ((evenp k) (expt1 (* x x) (floor k 2) a))
                    (t (expt0 (* x x) (floor k 2) (* x a))))))
    (expt0 n k 1))) @result{}  INTEGER-POWER
@end example

@example
 (defun example (y l)
   (flet ((attach (x)
            (setq l (append l (list x)))))
     (declare (inline attach))
     (dolist (x y)
       (unless (null (cdr x))
         (attach x)))
     l))

 (example '((a apple apricot) (b banana) (c cherry) (d) (e))
          '((1) (2) (3) (4 2) (5) (6 3 2)))
@result{}  ((1) (2) (3) (4 2) (5) (6 3 2) (A APPLE APRICOT) (B BANANA) (C CHERRY))
@end example

@subsubheading  See Also::

@b{declare},
@ref{defmacro}
,
@ref{defun}
,
@ref{documentation; (setf documentation)}
,
@ref{let; let*}
,
@ref{Evaluation},
@ref{Syntactic Interaction of Documentation Strings and Declarations}

@subsubheading  Notes::

It is not possible to define recursive @i{functions} with @b{flet}.
@b{labels} can be used to define mutually recursive @i{functions}.

If a @b{macrolet} @i{form} is a @i{top level form},
the body @i{forms} are also processed as @i{top level forms}.
See @ref{File Compilation}.

@node funcall, function (Special Operator), flet, Data and Control Flow Dictionary
@subsection funcall                                                          [Function]

@code{funcall}  @i{function {&rest} args} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{function}---a @i{function designator}.

@i{args}---@i{arguments} to the @i{function}.

@i{results}---the @i{values} returned by the @i{function}.

@subsubheading  Description::

@b{funcall} applies @i{function} to @i{args}.

If @i{function} is a @i{symbol},
it is coerced to a @i{function} as if by
finding its @i{functional value} in the @i{global environment}.

@subsubheading  Examples::

@example
 (funcall #'+ 1 2 3) @result{}  6
 (funcall 'car '(1 2 3)) @result{}  1
 (funcall 'position 1 '(1 2 3 2 1) :start 1) @result{}  4
 (cons 1 2) @result{}  (1 . 2)
 (flet ((cons (x y) `(kons ,x ,y)))
   (let ((cons (symbol-function '+)))
     (funcall #'cons
              (funcall 'cons 1 2)
              (funcall cons 1 2))))
@result{}  (KONS (1 . 2) 3)
@end example

@subsubheading  Exceptional Situations::

An error of @i{type} @b{undefined-function} should be signaled if @i{function} 
is a @i{symbol} that does not have a global definition as a @i{function}
or that has a global definition as a @i{macro} or a @i{special operator}.

@subsubheading  See Also::

@ref{apply}
, @b{function}, @ref{Evaluation}

@subsubheading  Notes::

@example
 (funcall @i{function} @i{arg1} @i{arg2} ...)
 @equiv{} (apply @i{function} @i{arg1} @i{arg2} ... nil)
 @equiv{} (apply @i{function} (list @i{arg1} @i{arg2} ...))
@end example

The difference between @b{funcall} and an ordinary function call is that
in the former case the @i{function} is obtained by ordinary @i{evaluation}
of a @i{form}, and in the latter case it is obtained by the special 
interpretation of the function position that normally occurs.

@node function (Special Operator), function-lambda-expression, funcall, Data and Control Flow Dictionary
@subsection function                                                 [Special Operator]

@code{function}  @i{name} @result{}  @i{function}

@subsubheading  Arguments and Values::

@i{name}---a @i{function name} or @i{lambda expression}.

@i{function}---a @i{function} @i{object}.

@subsubheading  Description::

The @i{value} of @b{function} is the @i{functional value} of @i{name}
in the current @i{lexical environment}.

If @i{name} is a @i{function name}, the functional definition of that name
is that
established by the innermost lexically enclosing
@b{flet}, @b{labels}, or @b{macrolet} @i{form},
if there is one.  Otherwise the global functional definition of the
@i{function name}
is returned.

If @i{name} is a @i{lambda expression}, then a @i{lexical closure}
is returned.  In situations where a @i{closure} over the same set of
@i{bindings} might be produced more than once, the various resulting
@i{closures} might or might not be @b{eq}.

It is an error to use @b{function} on a @i{function name} 
that does not denote a @i{function} in the lexical environment in
which the @b{function} form appears. 
Specifically, it is an error to use @b{function} on a @i{symbol} 
that denotes a @i{macro} or @i{special form}.
An implementation may choose not to signal this error for
performance reasons, but implementations are forbidden from
defining the failure to signal an error as a useful behavior.

@subsubheading  Examples::

@example
 (defun adder (x) (function (lambda (y) (+ x y))))
@end example

The result of @t{(adder 3)} is a function that adds @t{3} to its argument:

@example
 (setq add3 (adder 3))
 (funcall add3 5) @result{}  8
@end example

This works because @b{function} creates a @i{closure} of
the @i{lambda expression} that is able to refer to the @i{value} @t{3}
of the variable @t{x} even after control has returned from the function @t{adder}.

@subsubheading  See Also::

@ref{defun}
,
@ref{fdefinition}
,
@ref{flet; labels; macrolet}
,
@b{labels},
@ref{symbol-function}
,
@ref{Symbols as Forms},
@ref{Sharpsign Single-Quote},
@ref{Printing Other Objects}

@subsubheading  Notes::

The notation @t{#'@i{name}} may be used as an abbreviation
for @t{(function @i{name})}.

@node function-lambda-expression, functionp, function (Special Operator), Data and Control Flow Dictionary
@subsection function-lambda-expression                                       [Function]

@code{function-lambda-expression}  @i{function}@*
   @result{}  @i{lambda-expression, closure-p, name}

@subsubheading  Arguments and Values::

@i{function}---a @i{function}.

@i{lambda-expression}---a @i{lambda expression} or @b{nil}.

@i{closure-p}---a @i{generalized boolean}.

@i{name}---an @i{object}.

@subsubheading  Description::

Returns information about @i{function} as follows:

The @i{primary value}, @i{lambda-expression},
is @i{function}'s defining @i{lambda expression}, 
or @b{nil} if the information is not available.  The @i{lambda expression}
may have been pre-processed in some ways, but it should remain a suitable 
argument to @b{compile} or @b{function}.
Any @i{implementation} may legitimately return @b{nil} 
as the @i{lambda-expression} of any @i{function}.

The @i{secondary value}, @i{closure-p},
is @b{nil} if @i{function}'s definition was enclosed
in the @i{null lexical environment} or something @i{non-nil} if
@i{function}'s definition might have been enclosed in some 
@i{non-null lexical environment}.
Any @i{implementation} may legitimately return @i{true}
as the @i{closure-p} of any @i{function}.

The @i{tertiary value}, @i{name},
is the ``name'' of @i{function}. 
The name is intended for debugging only and is not necessarily one that would
be valid for use as a name in @b{defun} or @b{function}, for example.
By convention, @b{nil} is used to mean that @i{function} has no name.
Any @i{implementation} may legitimately return @b{nil} 
as the @i{name} of any @i{function}.

@subsubheading  Examples::

The following examples illustrate some possible return values, but
are not intended to be exhaustive:

@example
 (function-lambda-expression #'(lambda (x) x))
@result{}  NIL, @i{false}, NIL
@i{OR}@result{} NIL, @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) X), @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) X), @i{false}, NIL

 (function-lambda-expression
    (funcall #'(lambda () #'(lambda (x) x))))
@result{}  NIL, @i{false}, NIL
@i{OR}@result{} NIL, @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) X), @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) X), @i{false}, NIL

 (function-lambda-expression 
    (funcall #'(lambda (x) #'(lambda () x)) nil))
@result{}  NIL, @i{true}, NIL
@i{OR}@result{} (LAMBDA () X), @i{true}, NIL
@i{NOT}@result{} NIL, @i{false}, NIL
@i{NOT}@result{} (LAMBDA () X), @i{false}, NIL

 (flet ((foo (x) x))
   (setf (symbol-function 'bar) #'foo)
   (function-lambda-expression #'bar))
@result{}  NIL, @i{false}, NIL
@i{OR}@result{} NIL, @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) (BLOCK FOO X)), @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) (BLOCK FOO X)), @i{false}, FOO
@i{OR}@result{} (SI::BLOCK-LAMBDA FOO (X) X), @i{false}, FOO

 (defun foo ()
   (flet ((bar (x) x))
     #'bar))
 (function-lambda-expression (foo))
@result{}  NIL, @i{false}, NIL
@i{OR}@result{} NIL, @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) (BLOCK BAR X)), @i{true}, NIL
@i{OR}@result{} (LAMBDA (X) (BLOCK BAR X)), @i{true}, (:INTERNAL FOO 0 BAR)
@i{OR}@result{} (LAMBDA (X) (BLOCK BAR X)), @i{false}, "BAR in FOO"
@end example

@subsubheading  Notes::

Although @i{implementations} are free to return ``@b{nil}, @i{true}, @b{nil}'' in all cases, 
they are encouraged to return a @i{lambda expression} as the @i{primary value}
in the case where the argument was created by a call to @b{compile} 
or @b{eval} (as opposed to being created by @i{loading} a @i{compiled file}).

@node functionp, compiled-function-p, function-lambda-expression, Data and Control Flow Dictionary
@subsection functionp                                                        [Function]

@code{functionp}  @i{object} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values::

@i{object}---an @i{object}.

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

Returns @i{true} if @i{object} is of @i{type} @b{function};
otherwise, returns @i{false}.

@subsubheading  Examples::

@example
 (functionp 'append) @result{}  @i{false}
 (functionp #'append) @result{}  @i{true}
 (functionp (symbol-function 'append)) @result{}  @i{true}
 (flet ((f () 1)) (functionp #'f)) @result{}  @i{true}
 (functionp (compile nil '(lambda () 259))) @result{}  @i{true}
 (functionp nil) @result{}  @i{false}
 (functionp 12) @result{}  @i{false}
 (functionp '(lambda (x) (* x x))) @result{}  @i{false}
 (functionp #'(lambda (x) (* x x))) @result{}  @i{true}
@end example

@subsubheading  Notes::

@example
 (functionp @i{object}) @equiv{} (typep @i{object} 'function)
@end example

@node compiled-function-p, call-arguments-limit, functionp, Data and Control Flow Dictionary
@subsection compiled-function-p                                              [Function]

@code{compiled-function-p}  @i{object} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values::

@i{object}---an @i{object}.

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

Returns @i{true} if @i{object} is of @i{type} @b{compiled-function};
otherwise, returns @i{false}.

@subsubheading  Examples::

@example
 (defun f (x) x) @result{}  F
 (compiled-function-p #'f)
@result{}  @i{false}
@i{OR}@result{} @i{true}
 (compiled-function-p 'f) @result{}  @i{false}
 (compile 'f) @result{}  F
 (compiled-function-p #'f) @result{}  @i{true}
 (compiled-function-p 'f) @result{}  @i{false}
 (compiled-function-p (compile nil '(lambda (x) x)))
@result{}  @i{true}
 (compiled-function-p #'(lambda (x) x))
@result{}  @i{false}
@i{OR}@result{} @i{true}
 (compiled-function-p '(lambda (x) x)) @result{}  @i{false}
@end example

@subsubheading  See Also::

@ref{compile}
,
@ref{compile-file}
,
@ref{compiled-function}

@subsubheading  Notes::

@example
 (compiled-function-p @i{object}) @equiv{} (typep @i{object} 'compiled-function)
@end example

@node call-arguments-limit, lambda-list-keywords, compiled-function-p, Data and Control Flow Dictionary
@subsection call-arguments-limit                                    [Constant Variable]

@subsubheading  Constant Value::

An integer not smaller than @t{50} and at least as great as 
the @i{value} of @b{lambda-parameters-limit}, 
the exact magnitude of which is @i{implementation-dependent}.

@subsubheading  Description::

The upper exclusive bound on the number of @i{arguments} that 
may be passed to a @i{function}.

@subsubheading  See Also::

@ref{lambda-parameters-limit}
, 
@ref{multiple-values-limit}

@node lambda-list-keywords, lambda-parameters-limit, call-arguments-limit, Data and Control Flow Dictionary
@subsection lambda-list-keywords                                    [Constant Variable]

@subsubheading  Constant Value::

a @i{list}, the @i{elements} of which are @i{implementation-dependent}, 
but which must contain at least the @i{symbols} 
 @b{&allow-other-keys},
 @b{&aux},
 @b{&body},
 @b{&environment},
 @b{&key},
 @b{&optional},
 @b{&rest},
and
 @b{&whole}.

@subsubheading  Description::

A @i{list} of all the @i{lambda list keywords} used 
in the @i{implementation}, including the additional ones
used only by @i{macro} definition @i{forms}.

@subsubheading  See Also::

@ref{defun}
,
@ref{flet; labels; macrolet}
,
@ref{defmacro}
,
@b{macrolet},
@ref{The Evaluation Model}

@node lambda-parameters-limit, defconstant, lambda-list-keywords, Data and Control Flow Dictionary
@subsection lambda-parameters-limit                                 [Constant Variable]

@subsubheading  Constant Value::

@i{implementation-dependent}, but not smaller than @t{50}.

@subsubheading  Description::

A positive @i{integer} that is the upper exclusive bound on 
the number of @i{parameter} @i{names} that can appear 
in a single @i{lambda list}.

@subsubheading  See Also::

@ref{call-arguments-limit}

@subsubheading  Notes::

Implementors are encouraged to make the @i{value} of
@b{lambda-parameters-limit} as large as possible.

@node defconstant, defparameter, lambda-parameters-limit, Data and Control Flow Dictionary
@subsection defconstant                                                         [Macro]

@code{defconstant}  @i{name initial-value @r{[}documentation@r{]}} @result{}  @i{name}

@subsubheading  Arguments and Values::

@i{name}---a @i{symbol}; not evaluated.

@i{initial-value}---a @i{form}; evaluated.

@i{documentation}---a @i{string}; not evaluated.

@subsubheading  Description::

@b{defconstant} 
causes the global variable named by @i{name} to be 
given a value that is the result of evaluating @i{initial-value}.

A constant defined by @b{defconstant} can be redefined
with @b{defconstant}.
However, the consequences are undefined if an attempt is made to assign
a @i{value} to the @i{symbol} using another operator, or to
assign it to a @i{different}
@i{value} using a subsequent
@b{defconstant}.

If @i{documentation} is supplied, it is attached to @i{name} as a
@i{documentation string} of kind @b{variable}. 

@b{defconstant} 
normally appears as a @i{top level form}, but it is meaningful
for it to appear as a @i{non-top-level form}.
However, the compile-time side
effects described below
only take place when @b{defconstant} appears as a 
@i{top level form}.

The consequences are undefined if there are any 
@i{bindings}
of the variable named by @i{name} at the time @b{defconstant} 
is executed or if the value is not @b{eql} to the value of
@i{initial-value}.

The consequences are undefined when constant @i{symbols} are rebound
as either lexical or dynamic variables.  In other words, a reference to a
@i{symbol} declared with @b{defconstant} always refers to its global value.

The side effects of the execution of @b{defconstant} must
be equivalent to at least the side effects of the execution of the following
code:

@example
 (setf (symbol-value '@i{name}) @i{initial-value})
 (setf (documentation '@i{name} 'variable) '@i{documentation})
@end example

If a @b{defconstant} @i{form} appears as a @i{top level form},
the @i{compiler} must recognize that @i{name} names
a @i{constant variable}.  An implementation may choose to
evaluate the value-form at compile time, load time, or both.
Therefore, users must ensure that the @i{initial-value}
can be @i{evaluated} at compile time
(regardless of whether or not references to @i{name}
appear in the file) and that it always @i{evaluates}
to the same value.

[Editorial Note by KMP: Does ``same value'' here mean eql or similar?]

[Reviewer Note by Moon: Probably depends on whether load time is compared to compile time,
		or two compiles.]

@subsubheading  Examples::
@example
 (defconstant this-is-a-constant 'never-changing "for a test") @result{}  THIS-IS-A-CONSTANT
this-is-a-constant @result{}  NEVER-CHANGING
 (documentation 'this-is-a-constant 'variable) @result{}  "for a test"
 (constantp 'this-is-a-constant) @result{}  @i{true}
@end example

@subsubheading  See Also::

@ref{declaim}
,
@ref{defparameter; defvar}
, 
@b{defvar},
@ref{documentation; (setf documentation)}
,
@ref{proclaim}
,
@ref{Constant Variables},
@ref{Compilation}

@node defparameter, destructuring-bind, defconstant, Data and Control Flow Dictionary
@subsection defparameter, defvar                                                [Macro]

@code{defparameter}  @i{name         initial-value @r{[}documentation@r{]} } @result{}  @i{name}

@code{defvar}  @i{name @t{[}initial-value @r{[}documentation@r{]}@t{]}} @result{}  @i{name}

@subsubheading  Arguments and Values:: 

@i{name}---a @i{symbol}; not evaluated.

@i{initial-value}---a @i{form}; 
     for @b{defparameter}, it is always @i{evaluated},
 but for @b{defvar} it is @i{evaluated} 
     only if @i{name} is not already @i{bound}.

@i{documentation}---a @i{string}; not evaluated.

@subsubheading  Description::

@b{defparameter} and @b{defvar} @i{establish} @i{name} 
as a @i{dynamic variable}.

@b{defparameter} unconditionally
@i{assigns} the @i{initial-value} to the @i{dynamic variable} named @i{name}.
@b{defvar}, by contrast, @i{assigns} @i{initial-value} (if supplied) 
to the @i{dynamic variable} named @i{name} 
only if @i{name} is not already @i{bound}.

If no @i{initial-value} is supplied,
@b{defvar} leaves the @i{value cell} of 
the @i{dynamic variable} named @i{name} undisturbed;
    if @i{name} was previously @i{bound}, its old @i{value} persists,
and if it was previously @i{unbound}, it remains @i{unbound}.

If @i{documentation} is supplied, it is attached to @i{name} as a
@i{documentation string} of kind @b{variable}. 

@b{defparameter} and @b{defvar} normally appear as a @i{top level form}, 
but it is meaningful for them to appear as @i{non-top-level forms}.  However,
the compile-time side effects described below only take place when
they appear as @i{top level forms}.

@subsubheading  Examples::

@example
 (defparameter *p* 1) @result{}  *P*
 *p* @result{}  1
 (constantp '*p*) @result{}  @i{false}
 (setq *p* 2) @result{}  2
 (defparameter *p* 3) @result{}  *P*
 *p* @result{}  3

 (defvar *v* 1) @result{}  *V*
 *v* @result{}  1
 (constantp '*v*) @result{}  @i{false}
 (setq *v* 2) @result{}  2
 (defvar *v* 3) @result{}  *V*
 *v* @result{}  2

 (defun foo ()
   (let ((*p* 'p) (*v* 'v))
     (bar))) @result{}  FOO
 (defun bar () (list *p* *v*)) @result{}  BAR
 (foo) @result{}  (P V)
@end example

The principal operational distinction between @b{defparameter} and @b{defvar}
is that @b{defparameter} makes an unconditional assignment to @i{name},
while @b{defvar} makes a conditional one.  In practice, this means that
@b{defparameter} is useful in situations where loading or reloading the definition
would want to pick up a new value of the variable, while @b{defvar} is used in
situations where the old value would want to be retained if the file were loaded or reloaded.
For example, one might create a file which contained:

@example
 (defvar *the-interesting-numbers* '())
 (defmacro define-interesting-number (name n)
   `(progn (defvar ,name ,n)
           (pushnew ,name *the-interesting-numbers*)
           ',name))
 (define-interesting-number *my-height* 168) ;cm
 (define-interesting-number *my-weight* 13)  ;stones
@end example

Here the initial value, @t{()}, for the variable @t{*the-interesting-numbers*}
is just a seed that we are never likely to want to reset to something else
once something has been grown from it.  As such, we have used @b{defvar} 
to avoid having the @t{*interesting-numbers*} information reset if the file is
loaded a second time.  It is true that the two calls to
@b{define-interesting-number} here would be reprocessed, but
if there were additional calls in another file, they would not be and that 
information would be lost.  On the other hand, consider the following code:

@example
 (defparameter *default-beep-count* 3)
 (defun beep (&optional (n *default-beep-count*))
   (dotimes (i n) (si:
@end example

Here we could easily imagine editing the code to change the initial value of
@t{*default-beep-count*}, and then reloading the file to pick up the new value.
In order to make value updating easy, we have used @b{defparameter}.

On the other hand, there is potential value to using @b{defvar} in this
situation.  For example, suppose that someone had predefined an alternate
value for @t{*default-beep-count*}, or had loaded the file and then manually
changed the value.  In both cases, if we had used @b{defvar} instead of
@b{defparameter}, those user preferences would not be overridden by
(re)loading the file.

The choice of whether to use @b{defparameter} or @b{defvar} has
visible consequences to programs, but is nevertheless often made for subjective
reasons.

@subsubheading  Side Effects::

If a @b{defvar} or @b{defparameter} @i{form} appears as a @i{top level form},
the @i{compiler} must recognize that the @i{name} has been
proclaimed @b{special}.  However, it must neither @i{evaluate} 
the @i{initial-value} @i{form} nor @i{assign} the 
@i{dynamic variable} named @i{name} at compile time.

There may be additional (@i{implementation-defined}) compile-time or 
run-time side effects, as long as such effects do not interfere with the
correct operation of @i{conforming programs}.

@subsubheading  Affected By::

@b{defvar} is affected by whether @i{name} is already @i{bound}.

@subsubheading  See Also::

@ref{declaim}
, 
@ref{defconstant}
,
@ref{documentation; (setf documentation)}
,
@ref{Compilation}

@subsubheading  Notes::

It is customary to name @i{dynamic variables} with an @i{asterisk}
at the beginning and end of the name.  e.g., @t{*foo*} is a good name for
a @i{dynamic variable}, but not for a @i{lexical variable};
@t{foo} is a good name for a @i{lexical variable}, 
but not for a @i{dynamic variable}.
This naming convention is observed for all @i{defined names} in @r{Common Lisp};
however, neither @i{conforming programs} nor @i{conforming implementations}
are obliged to adhere to this convention.

The intent of the permission for additional side effects is to allow
@i{implementations} to do normal ``bookkeeping'' that accompanies
definitions.  For example, the @i{macro expansion} of a @b{defvar}
or @b{defparameter} @i{form} might include code that arranges to
record the name of the source file in which the definition occurs.

@b{defparameter} and @b{defvar} might be defined as follows:

@example
 (defmacro defparameter (name initial-value 
                         &optional (documentation nil documentation-p))
   `(progn (declaim (special ,name))
           (setf (symbol-value ',name) ,initial-value)
           ,(when documentation-p
              `(setf (documentation ',name 'variable) ',documentation))
           ',name))
 (defmacro defvar (name &optional
                        (initial-value nil initial-value-p)
                        (documentation nil documentation-p))
   `(progn (declaim (special ,name))
           ,(when initial-value-p
              `(unless (boundp ',name)
                 (setf (symbol-value ',name) ,initial-value)))
           ,(when documentation-p
              `(setf (documentation ',name 'variable) ',documentation))
           ',name))
@end example

@node destructuring-bind, let, defparameter, Data and Control Flow Dictionary
@subsection destructuring-bind                                                  [Macro]

@code{destructuring-bind}  @i{lambda-list expression @{@i{declaration}@}{*} @{@i{form}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{lambda-list}---a @i{destructuring lambda list}.

@i{expression}---a @i{form}.

@i{declaration}---a @b{declare} @i{expression}; not evaluated. 

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} returned by the @i{forms}.

@subsubheading  Description::

@b{destructuring-bind} binds the variables specified in @i{lambda-list}
to the corresponding values in the tree structure resulting from the evaluation 
of @i{expression}; then @b{destructuring-bind} evaluates @i{forms}.

The @i{lambda-list} supports destructuring as described in
@ref{Destructuring Lambda Lists}.

@subsubheading  Examples::
@example
 (defun iota (n) (loop for i from 1 to n collect i))       ;helper
 (destructuring-bind ((a &optional (b 'bee)) one two three)
     `((alpha) ,@@(iota 3))
   (list a b three two one)) @result{}  (ALPHA BEE 3 2 1)
@end example

@subsubheading  Exceptional Situations::

If the result of evaluating the @i{expression} does not match the 
destructuring pattern, an error of @i{type} @b{error} should be signaled. 

@subsubheading  See Also::

@b{macrolet}, 
@ref{defmacro}

@node let, progv, destructuring-bind, Data and Control Flow Dictionary
@subsection let, let*                                                [Special Operator]

@code{let}  @i{@r{(}@{@i{var} | @r{(}@i{var} @r{[}@i{init-form}@r{]}@r{)}@}{*}@r{)} @{@i{declaration}@}{*} @{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@code{let*}  @i{@r{(}@{@i{var} | @r{(}@i{var} @r{[}@i{init-form}@r{]}@r{)}@}{*}@r{)} @{@i{declaration}@}{*} @{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{var}---a @i{symbol}.

@i{init-form}---a @i{form}.

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{form}---a @i{form}.

@i{results}---the @i{values} returned by the @i{forms}.

@subsubheading  Description::

@b{let} and @b{let*}
create new variable @i{bindings} and
execute a series of @i{forms} that use these @i{bindings}.
@b{let} performs the @i{bindings} in parallel and 
@b{let*} does them sequentially.

The form

@example
 (let ((@i{var1} @i{init-form-1})
       (@i{var2} @i{init-form-2})
       ...
       (@i{varm} @i{init-form-m}))
   @i{declaration1}
   @i{declaration2}
   ...
   @i{declarationp}
   @i{form1}
   @i{form2}
   ...
   @i{formn})
@end example

first evaluates the expressions @i{init-form-1}, @i{init-form-2}, and so on,

in that order, saving the resulting values.
Then all of the variables @i{varj} are bound to the corresponding
values; each @i{binding} is lexical unless
there is a @b{special} declaration to the contrary.
The expressions @i{formk} are then evaluated
in order; the values of all but the last are discarded
(that is, the body of a @b{let} 
is an @i{implicit progn}).

@b{let*}
is similar to @b{let}, but the @i{bindings} of variables
are performed sequentially rather than in parallel.  
The expression for the @i{init-form} of a 
@i{var} can refer to @i{vars}
previously bound in the @b{let*}.

The form

@example
 (let* ((@i{var1} @i{init-form-1})
        (@i{var2} @i{init-form-2})
        ...
        (@i{varm} @i{init-form-m}))
   @i{declaration1}
   @i{declaration2}
   ...
   @i{declarationp}
   @i{form1}
   @i{form2}
   ...
   @i{formn})
@end example

first evaluates the expression @i{init-form-1}, then binds the variable
@i{var1} to that value; then it evaluates @i{init-form-2} and binds 

@i{var2}, and so on.
The expressions @i{formj} are then evaluated
in order; the values of all but the last are discarded
(that is, the body of @b{let*} is an implicit @b{progn}).

For both @b{let} and @b{let*},
if there is not an @i{init-form} associated with a @i{var},
@i{var} is initialized to @b{nil}.  

The special form @b{let} 
has the property that the @i{scope} 
of the name binding does not include any
initial value form.
For @b{let*}, a variable's @i{scope} also includes the 
     remaining initial value forms for subsequent variable bindings.

@subsubheading  Examples::

@example
 (setq a 'top) @result{}  TOP
 (defun dummy-function () a) @result{}  DUMMY-FUNCTION
 (let ((a 'inside) (b a))
    (format nil "~S ~S ~S" a b (dummy-function))) @result{}  "INSIDE TOP TOP" 
 (let* ((a 'inside) (b a))
    (format nil "~S ~S ~S" a b (dummy-function))) @result{}  "INSIDE INSIDE TOP" 
 (let ((a 'inside) (b a))
    (declare (special a))
    (format nil "~S ~S ~S" a b (dummy-function))) @result{}  "INSIDE TOP INSIDE"
@end example

The code

@example
 (let (x)
   (declare (integer x))
   (setq x (gcd y z))
   ...)
@end example

is incorrect; although @t{x} is indeed set before it is used,
and is set to a value of the declared type @i{integer}, nevertheless
@t{x} initially takes on the value @b{nil} in violation of the type
declaration.

@subsubheading  See Also::

@ref{progv}

@node progv, setq, let, Data and Control Flow Dictionary
@subsection progv                                                    [Special Operator]

@code{progv}  @i{@i{symbols} @i{values} @{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{symbols}---a @i{list} of @i{symbols}; evaluated.

@i{values}---a @i{list} of @i{objects}; evaluated.

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} returned by the @i{forms}.

@subsubheading  Description::

@b{progv} creates new dynamic variable @i{bindings} and
executes each @i{form} using those @i{bindings}.
Each @i{form} is evaluated in  order.

@b{progv} allows @i{binding} one or more dynamic
variables whose names may be determined at run time.  
Each @i{form} is evaluated in order 
with the dynamic variables whose names are in 
@i{symbols} bound to corresponding @i{values}.
If too few @i{values} 
are supplied, the remaining @i{symbols} are bound and then
made to have no value. If too many @i{values} are
supplied, the excess values are ignored.
The @i{bindings} of the dynamic variables are undone on
exit from @b{progv}. 

@subsubheading  Examples::
@example
 (setq *x* 1) @result{}  1
 (progv '(*x*) '(2) *x*) @result{}  2
 *x* @result{}  1

Assuming *x* is not globally special,

 (let ((*x* 3)) 
    (progv '(*x*) '(4) 
      (list *x* (symbol-value '*x*)))) @result{}  (3 4)
@end example

@subsubheading  See Also::

@ref{let; let*}
, @ref{Evaluation}

@subsubheading  Notes::

Among other things, @b{progv} is useful when writing 
interpreters for languages embedded in @r{Lisp}; it provides a handle
on the mechanism for @i{binding} @i{dynamic variables}.

@node setq, psetq, progv, Data and Control Flow Dictionary
@subsection setq                                                         [Special Form]

@code{setq}  @i{@{!@i{pair}@}{*}} @result{}  @i{result}

@w{@i{pair} ::=var form}

@subsubheading  Pronunciation::

pronounced 'set ,ky\"u 

@subsubheading  Arguments and Values::

@i{var}---a @i{symbol} naming a @i{variable} other than a @i{constant variable}.

@i{form}---a @i{form}.

@i{result}---the @i{primary value} of the last @i{form},
		 or @b{nil} if no @i{pairs} were supplied.

@subsubheading  Description::

Assigns values to @i{variables}.

@t{(setq @i{var1} @i{form1} @i{var2} @i{form2} ...)}
is the simple variable assignment statement of @r{Lisp}.
First @i{form1} is evaluated
and the result is stored in the variable @i{var1}, then @i{form2}
is evaluated and the result stored in @i{var2}, and so forth.
@b{setq} may be used for assignment of both lexical
and dynamic variables.

If any @i{var} refers to a @i{binding} 
made by @b{symbol-macrolet},
then that @i{var} is treated as if @b{setf}
(not @b{setq}) had been used.

@subsubheading  Examples::

@example
 ;; A simple use of SETQ to establish values for variables.
 (setq a 1 b 2 c 3) @result{}  3
 a @result{}  1
 b @result{}  2
 c @result{}  3

 ;; Use of SETQ to update values by sequential assignment.
 (setq a (1+ b) b (1+ a) c (+ a b)) @result{}  7
 a @result{}  3
 b @result{}  4
 c @result{}  7

 ;; This illustrates the use of SETQ on a symbol macro.
 (let ((x (list 10 20 30)))
   (symbol-macrolet ((y (car x)) (z (cadr x)))
     (setq y (1+ z) z (1+ y))
     (list x y z)))
@result{}  ((21 22 30) 21 22)
@end example

@subsubheading  Side Effects::

The @i{primary value} of each @i{form} is assigned to the corresponding @i{var}.

@subsubheading  See Also::

@ref{psetq}
,
@ref{set}
,
@ref{setf; psetf}

@node psetq, block, setq, Data and Control Flow Dictionary
@subsection psetq                                                               [Macro]

@code{psetq}  @i{@{!@i{pair}@}{*}} @result{}  @i{@b{nil}}

@w{@i{pair} ::=var form}

@subsubheading  Pronunciation::

@b{psetq}: pronounced {{{\vrule width 1pt height 2pt depth 2pt}\kern -1pt\raise 6pt{\vrule width 1pt height 2pt depth 2pt}}}p\=e'set ,ky\"u 

@subsubheading  Arguments and Values::

@i{var}---a @i{symbol} naming a @i{variable} other than a @i{constant variable}.

@i{form}---a @i{form}.

@subsubheading  Description::

Assigns values to @i{variables}.

This is just like @b{setq}, except that the assignments 
happen ``in parallel.''  That is, first all of the forms are
evaluated, and only then are the variables set to the resulting values.
In this way, the assignment to one variable does not affect the value
computation of another in the way that would occur with @b{setq}'s 
sequential assignment.

If any @i{var} refers to a @i{binding} 
made by @b{symbol-macrolet},
then that @i{var} is treated as if @b{psetf} (not @b{psetq})
had been used.

@subsubheading  Examples::

@example
 ;; A simple use of PSETQ to establish values for variables.
 ;; As a matter of style, many programmers would prefer SETQ 
 ;; in a simple situation like this where parallel assignment
 ;; is not needed, but the two have equivalent effect.
 (psetq a 1 b 2 c 3) @result{}  NIL
 a @result{}  1
 b @result{}  2
 c @result{}  3

 ;; Use of PSETQ to update values by parallel assignment.
 ;; The effect here is very different than if SETQ had been used.
 (psetq a (1+ b) b (1+ a) c (+ a b)) @result{}  NIL
 a @result{}  3
 b @result{}  2
 c @result{}  3

 ;; Use of PSETQ on a symbol macro.
 (let ((x (list 10 20 30)))
   (symbol-macrolet ((y (car x)) (z (cadr x)))
     (psetq y (1+ z) z (1+ y))
     (list x y z)))
@result{}  ((21 11 30) 21 11)

 ;; Use of parallel assignment to swap values of A and B.
 (let ((a 1) (b 2))
   (psetq a b  b a)
   (values a b))
@result{}  2, 1
@end example

@subsubheading  Side Effects::

The values of @i{forms} are assigned to @i{vars}.

@subsubheading  See Also::

@b{psetf},
@ref{setq}

@node block, catch, psetq, Data and Control Flow Dictionary
@subsection block                                                    [Special Operator]

@code{block}  @i{@i{name} @i{form}@r{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{name}---a @i{symbol}.

@i{form}---a @i{form}.

@i{results}---the @i{values} of the @i{forms} if a @i{normal return} occurs,
   or else, if an @i{explicit return} occurs, the @i{values} that were transferred.

@subsubheading  Description::

@b{block} @i{establishes} a @i{block} named @i{name}
and then evaluates @i{forms} as an @i{implicit progn}.

The @i{special operators} @b{block} and @b{return-from} work together to
provide a structured, lexical, non-local exit facility.  At any point lexically
contained within @i{forms}, @b{return-from} can be used with the
given @i{name} to return control and values from the @b{block} 
@i{form}, except when an intervening @i{block} with the same name
has been @i{established}, in which case the outer @i{block} is 
shadowed by the inner one.

The @i{block} named @i{name} has
@i{lexical scope} and @i{dynamic extent}.  

Once established, a @i{block} may only be exited once, 
whether by @i{normal return} or @i{explicit return}.

@subsubheading  Examples::

@example
 (block empty) @result{}  NIL
 (block whocares (values 1 2) (values 3 4)) @result{}  3, 4
 (let ((x 1)) 
   (block stop (setq x 2) (return-from stop) (setq x 3))
   x) @result{}  2
 (block early (return-from early (values 1 2)) (values 3 4)) @result{}  1, 2
 (block outer (block inner (return-from outer 1)) 2) @result{}  1
 (block twin (block twin (return-from twin 1)) 2) @result{}  2
 ;; Contrast behavior of this example with corresponding example of CATCH.
 (block b
   (flet ((b1 () (return-from b 1)))
     (block b (b1) (print 'unreachable))
     2)) @result{}  1
@end example

@subsubheading  See Also::

@ref{return}
, 
@ref{return-from}
, @ref{Evaluation}

@subsubheading  Notes::

@node catch, go, block, Data and Control Flow Dictionary
@subsection catch                                                    [Special Operator]

@code{catch}  @i{@i{tag} @{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{tag}---a @i{catch tag}; evaluated.

@i{forms}---an @i{implicit progn}.

@i{results}---if the @i{forms} exit normally,
	           the @i{values} returned by the @i{forms};
		  if a throw occurs to the @i{tag},
		   the @i{values} that are thrown.

@subsubheading  Description::

@b{catch} is used as the destination of a non-local 
control transfer by @b{throw}.
@i{Tags} are used to find the @b{catch}
to which a @b{throw} is transferring control.
@t{(catch 'foo @i{form})} catches a 
@t{(throw 'foo @i{form})} but not a
@t{(throw 'bar @i{form})}.

The order of execution of @b{catch} follows:
@ITindex{order of evaluation}

@ITindex{evaluation order}

@table @asis

@item 1.  
@i{Tag} is evaluated.
It serves as the name of the
@b{catch}.  

@item 2.  
@i{Forms} are then evaluated as an implicit @b{progn},
and the results of the last @i{form} are returned unless a 
@b{throw} occurs.

@item 3.  
If a @b{throw} occurs 
during the execution of one of the @i{forms}, control
is transferred  to the @b{catch} @i{form} whose @i{tag} 
is @b{eq} to
the tag argument of the @b{throw}
and which is the most recently established @b{catch} with that 
@i{tag}.
No further evaluation of @i{forms} occurs.

@item 4.  
The @i{tag} @i{established} 
by @b{catch} is @i{disestablished}
just before the results are returned.

@end table

If during the execution of one of the @i{forms}, a @b{throw}
is executed whose tag is @b{eq} to the @b{catch} tag, 
then the values specified by the @b{throw} are
returned as the result of the dynamically most recently established
@b{catch} form with that tag.

The mechanism for @b{catch} and @b{throw} works even
if @b{throw} is not within the lexical scope of @b{catch}.
@b{throw} must occur within the @i{dynamic extent} 
of the @i{evaluation} of the body of a @b{catch} with a corresponding @i{tag}.

@subsubheading  Examples::
@example
 (catch 'dummy-tag 1 2 (throw 'dummy-tag 3) 4) @result{}  3
 (catch 'dummy-tag 1 2 3 4) @result{}  4
 (defun throw-back (tag) (throw tag t)) @result{}  THROW-BACK
 (catch 'dummy-tag (throw-back 'dummy-tag) 2) @result{}  T

 ;; Contrast behavior of this example with corresponding example of BLOCK.
 (catch 'c
   (flet ((c1 () (throw 'c 1)))
     (catch 'c (c1) (print 'unreachable))
     2)) @result{}  2
@end example

@subsubheading  Exceptional Situations::
An error of @i{type} @b{control-error} is signaled
if @b{throw} is done
when there is no suitable @b{catch} @i{tag}. 
@subsubheading  See Also::

@ref{throw}
, @ref{Evaluation}

@subsubheading  Notes::

It is customary for @i{symbols} to be used
as @i{tags}, but any @i{object} is permitted.  
However, numbers should not be
used because the comparison is done using @b{eq}.

@b{catch} differs from @b{block} in that 
@b{catch}
tags have dynamic @i{scope} while 
@b{block} names have @i{lexical scope}.

@node go, return-from, catch, Data and Control Flow Dictionary
@subsection go                                                       [Special Operator]

@code{go}  @i{tag} 
        @result{}  #<NoValue>
@subsubheading  Arguments and Values:: 

@i{tag}---a @i{go tag}.

@subsubheading  Description::

@b{go} transfers control to the point in the body 
of an enclosing @b{tagbody} form labeled by a
tag @b{eql} to @i{tag}.  
If there is no such @i{tag}  in the body, the
bodies of lexically containing @b{tagbody} @i{forms}
(if any) are examined as well.
If several tags are @b{eql} 
to @i{tag}, control is transferred to
whichever matching @i{tag} 
is contained in the innermost @b{tagbody} form that
contains the @b{go}.
The consequences are undefined
if there is no matching @i{tag} lexically visible
to the point of the @b{go}.

The transfer of control initiated by @b{go} is performed
as described in @ref{Transfer of Control to an Exit Point}.

@subsubheading  Examples::
@example
 (tagbody
   (setq val 2)
   (go lp)
   (incf val 3)
   lp (incf val 4)) @result{}  NIL
 val @result{}  6 
@end example

The following is in error because there is a normal exit 
of the @b{tagbody} before the 
@b{go} is executed.

@example
 (let ((a nil)) 
   (tagbody t (setq a #'(lambda () (go t))))
   (funcall a))
@end example

The following is in error because the @b{tagbody} is passed over
before the @b{go} @i{form} is executed.

@example
 (funcall (block nil
            (tagbody a (return #'(lambda () (go a))))))
@end example

@subsubheading  See Also::

@ref{tagbody}

@node return-from, return, go, Data and Control Flow Dictionary
@subsection return-from                                              [Special Operator]

@code{return-from}  @i{@i{name} @r{[}@i{result}@r{]}} 
        @result{}  #<NoValue>
@subsubheading  Arguments and Values:: 

@i{name}---a @i{block tag}; not evaluated.

@i{result}---a @i{form}; evaluated.
  The default is @b{nil}.

@subsubheading  Description::

Returns control and @i{multiple values}_2 from a lexically enclosing @i{block}.

A @b{block} @i{form} named @i{name} must lexically enclose
the occurrence of @b{return-from};  any @i{values} @i{yielded}
by the @i{evaluation} of @i{result} are immediately returned from
the innermost such lexically enclosing @i{block}.

The transfer of control initiated by @b{return-from} is performed
as described in @ref{Transfer of Control to an Exit Point}.

@subsubheading  Examples::

@example
 (block alpha (return-from alpha) 1) @result{}  NIL
 (block alpha (return-from alpha 1) 2) @result{}  1
 (block alpha (return-from alpha (values 1 2)) 3) @result{}  1, 2
 (let ((a 0))
    (dotimes (i 10) (incf a) (when (oddp i) (return)))
    a) @result{}  2
 (defun temp (x)
    (if x (return-from temp 'dummy))
    44) @result{}  TEMP
 (temp nil) @result{}  44
 (temp t) @result{}  DUMMY
 (block out
   (flet ((exit (n) (return-from out n)))
     (block out (exit 1)))
   2) @result{}  1
 (block nil   
   (unwind-protect (return-from nil 1)
     (return-from nil 2)))
@result{}  2
 (dolist (flag '(nil t))
   (block nil
     (let ((x 5))
       (declare (special x))
       (unwind-protect (return-from nil)
         (print x))))
   (print 'here))
@t{ |> } 5
@t{ |> } HERE
@t{ |> } 5
@t{ |> } HERE
@result{}  NIL
 (dolist (flag '(nil t))
   (block nil
     (let ((x 5))
       (declare (special x))
       (unwind-protect
           (if flag (return-from nil))
         (print x))))
   (print 'here))
@t{ |> } 5
@t{ |> } HERE
@t{ |> } 5
@t{ |> } HERE
@result{}  NIL
@end example

The following has undefined consequences because the @b{block} @i{form}
exits normally before the @b{return-from} @i{form} is attempted.

@example
 (funcall (block nil #'(lambda () (return-from nil)))) is an error.
@end example

@subsubheading  See Also::

@ref{block}
,
@ref{return}
,
@ref{Evaluation}

@node return, tagbody, return-from, Data and Control Flow Dictionary
@subsection return                                                              [Macro]

@code{return}  @i{@r{[}@i{result}@r{]}} @result{}  #<NoValue>

@subsubheading  Arguments and Values:: 

@i{result}---a @i{form}; evaluated.
  The default is @b{nil}.

@subsubheading  Description::

Returns, as if by @b{return-from}, from the @i{block} named @b{nil}.

@subsubheading  Examples::

@example
 (block nil (return) 1) @result{}  NIL
 (block nil (return 1) 2) @result{}  1
 (block nil (return (values 1 2)) 3) @result{}  1, 2
 (block nil (block alpha (return 1) 2)) @result{}  1
 (block alpha (block nil (return 1)) 2) @result{}  2
 (block nil (block nil (return 1) 2)) @result{}  1
@end example

@subsubheading  See Also::

@ref{block}
,
@ref{return-from}
,
@ref{Evaluation}

@subsubheading  Notes::

@example
 (return) @equiv{} (return-from nil)
 (return @i{form}) @equiv{} (return-from nil @i{form})
@end example

The @i{implicit blocks} @i{established} by @i{macros} such as @b{do}
are often named @b{nil}, so that @b{return} can be used to exit from
such @i{forms}.

@node tagbody, throw, return, Data and Control Flow Dictionary
@subsection tagbody                                                  [Special Operator]

@code{tagbody}  @i{@{@i{tag} | @i{statement}@}{*}} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

@i{tag}---a @i{go tag}; not evaluated.

@i{statement}---a @i{compound form}; evaluated as described below.

@subsubheading  Description::

Executes zero or more @i{statements} in a 
@i{lexical environment}
that provides for control transfers to labels indicated by the @i{tags}.

The @i{statements} in a @b{tagbody} are @i{evaluated} in order
from left to right, and their @i{values} are discarded.  If at any time
there are no remaining @i{statements}, @b{tagbody} returns @b{nil}.
However, if @t{(go @i{tag})} is @i{evaluated}, control jumps to the
part of the body labeled with the @i{tag}.  (Tags are compared with @b{eql}.)

A @i{tag} established by @b{tagbody} has @i{lexical scope}
and has @i{dynamic extent}.  Once @b{tagbody} has been exited,
it is no longer valid to @b{go} to a @i{tag} in its body.
It is permissible for @b{go} to jump to a @b{tagbody} that is 
not the innermost @b{tagbody} containing that @b{go};
the @i{tags} established by a @b{tagbody} only shadow
other @i{tags} of like name.

The determination of which elements of the body are @i{tags} 
and which are @i{statements} is made prior to any @i{macro expansion}
of that element.  If a @i{statement} is a @i{macro form} and
its @i{macro expansion} is an @i{atom}, that @i{atom} is treated
as a @i{statement}, not a @i{tag}.

@subsubheading  Examples::

@example
 (let (val)
    (tagbody
      (setq val 1)
      (go point-a)
      (incf val 16)
     point-c
      (incf val 04)
      (go point-b)
      (incf val 32)
     point-a
      (incf val 02)
      (go point-c)
      (incf val 64)
     point-b
      (incf val 08))
    val)
@result{}  15
 (defun f1 (flag)
   (let ((n 1))
     (tagbody 
       (setq n (f2 flag #'(lambda () (go out))))
      out
       (prin1 n))))
@result{}  F1
 (defun f2 (flag escape)
   (if flag (funcall escape) 2))
@result{}  F2
 (f1 nil)
@t{ |> } 2
@result{}  NIL
 (f1 t)
@t{ |> } 1
@result{}  NIL
@end example

@subsubheading  See Also::

@ref{go}

@subsubheading  Notes::

The @i{macros} in Figure 5--10 have @i{implicit tagbodies}.

@group
@noindent
@w{  do              do-external-symbols  dotimes  }
@w{  do*             do-symbols           prog     }
@w{  do-all-symbols  dolist               prog*    }

@noindent
@w{  Figure 5--10: Macros that have implicit tagbodies.}

@end group

@node throw, unwind-protect, tagbody, Data and Control Flow Dictionary
@subsection throw                                                    [Special Operator]

@code{throw}  @i{tag result-form} 
        @result{}  #<NoValue>
@subsubheading  Arguments and Values:: 

@i{tag}---a @i{catch tag}; evaluated.

@i{result-form}---a @i{form}; evaluated as described below.

@subsubheading  Description::

@b{throw} causes a non-local control transfer
to a @b{catch} whose tag is @b{eq} to @i{tag}. 

@i{Tag} is evaluated first to produce an @i{object}
called the throw tag; then @i{result-form} is evaluated,
and its results are saved. If the @i{result-form} produces
multiple values, then all the values are saved.
The most recent outstanding @b{catch} 
whose @i{tag} is @b{eq} to the throw tag
is exited; the saved results are returned as the value or 
values of @b{catch}.

The transfer of control initiated by @b{throw} is performed
as described in @ref{Transfer of Control to an Exit Point}.

@subsubheading  Examples::

@example
 (catch 'result
    (setq i 0 j 0)
    (loop (incf j 3) (incf i)
          (if (= i 3) (throw 'result (values i j))))) @result{}  3, 9

@end example

@example
 (catch nil 
   (unwind-protect (throw nil 1)
     (throw nil 2))) @result{}  2
@end example

The consequences of the following are undefined 
because the @b{catch} of @t{b} 
is passed over by the first @b{throw}, 
hence portable programs must assume that 
its @i{dynamic extent} is terminated. 
The @i{binding} of the @i{catch tag} is not yet @i{disestablished}
and therefore it is the target of the second @b{throw}.

@example
 (catch 'a
   (catch 'b
     (unwind-protect (throw 'a 1)
       (throw 'b 2))))
@end example

The following prints ``@t{The inner catch returns :SECOND-THROW}''
and then returns @t{:outer-catch}.

@example
 (catch 'foo
         (format t "The inner catch returns ~s.~
                 (catch 'foo
                     (unwind-protect (throw 'foo :first-throw)
                         (throw 'foo :second-throw))))
         :outer-catch)
@t{ |> } The inner catch returns :SECOND-THROW
@result{}  :OUTER-CATCH
@end example

@subsubheading  Exceptional Situations::

If there is no outstanding @i{catch tag} that matches the throw tag,
no unwinding of the stack is performed,
and an error of @i{type} @b{control-error} is signaled.
When the error is signaled, 
the @i{dynamic environment} is that which was
in force at the point of the @b{throw}.

@subsubheading  See Also::

@ref{block}
,
@ref{catch}
,
@ref{return-from}
,
@ref{unwind-protect}
,
@ref{Evaluation}

@subsubheading  Notes::

@b{catch} and @b{throw} are normally used when the @i{exit point}
must have @i{dynamic scope} (@i{e.g.}, the @b{throw} is not lexically enclosed
by the @b{catch}), while @b{block} and @b{return} are used 
when @i{lexical scope} is sufficient.

@node unwind-protect, nil, throw, Data and Control Flow Dictionary
@subsection unwind-protect                                           [Special Operator]

@code{unwind-protect}  @i{@i{protected-form} @{@i{cleanup-form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{protected-form}---a @i{form}.

@i{cleanup-form}---a @i{form}.

@i{results}---the @i{values} of the @i{protected-form}.

@subsubheading  Description::
@b{unwind-protect} evaluates @i{protected-form}
and guarantees that @i{cleanup-forms} are executed
before @b{unwind-protect} exits,
whether it terminates
normally or is aborted by a control transfer of some kind. 
@b{unwind-protect} is intended to be used
to make sure that
certain side effects take place after the evaluation of 
@i{protected-form}.

If a @i{non-local exit} occurs during execution of @i{cleanup-forms},
no special action is taken.  The @i{cleanup-forms} of 
@b{unwind-protect}
are not protected by that @b{unwind-protect}.

@b{unwind-protect} protects against all attempts to exit 
from @i{protected-form}, including
     @b{go},
     @b{handler-case},
     @b{ignore-errors},
     @b{restart-case},
     @b{return-from},
     @b{throw},
 and @b{with-simple-restart}.

Undoing of @i{handler} and @i{restart} @i{bindings} during an exit
happens in parallel with the undoing of the bindings of @i{dynamic variables}
and @b{catch} tags, in the reverse order in which they were established.
The effect of this is that @i{cleanup-form} sees the same @i{handler}
and @i{restart} @i{bindings}, as well as @i{dynamic variable} @i{bindings}
and @b{catch} tags, as were visible when the @b{unwind-protect} was entered.

@subsubheading  Examples::
@example
 (tagbody
   (let ((x 3))
     (unwind-protect
       (if (numberp x) (go out))
       (print x)))
  out
   ...)
@end example

When @b{go} is executed, the call to @b{print} is executed first,
and then the transfer of control to the tag @t{out} is completed.

@example
 (defun dummy-function (x)
    (setq state 'running)
    (unless (numberp x) (throw 'abort 'not-a-number))
    (setq state (1+ x))) @result{}  DUMMY-FUNCTION
 (catch 'abort (dummy-function 1)) @result{}  2
 state @result{}  2
 (catch 'abort (dummy-function 'trash)) @result{}  NOT-A-NUMBER
 state @result{}  RUNNING
 (catch 'abort (unwind-protect (dummy-function 'trash) 
                  (setq state 'aborted))) @result{}  NOT-A-NUMBER
 state @result{}  ABORTED
@end example

The following code
is not correct:

@example
 (unwind-protect
   (progn (incf *access-count*)
          (perform-access))
   (decf *access-count*))
@end example

If an exit occurs before completion of @b{incf},
the @b{decf} @i{form} is executed anyway, resulting in an
incorrect value for @t{*access-count*}.
The correct way to code this is as follows:

@example
 (let ((old-count *access-count*))
   (unwind-protect
     (progn (incf *access-count*)
            (perform-access))
     (setq *access-count* old-count)))
@end example

@example
;;; The following returns 2.
 (block nil   
   (unwind-protect (return 1)
     (return 2)))

;;; The following has undefined consequences.
 (block a    
   (block b
     (unwind-protect (return-from a 1)
       (return-from b 2))))

;;; The following returns 2.
 (catch nil 
   (unwind-protect (throw nil 1)
     (throw nil 2)))

;;; The following has undefined consequences because the catch of B is 
;;; passed over by the first THROW, hence portable programs must assume 
;;; its dynamic extent is terminated.  The binding of the catch tag is not
;;; yet disestablished and therefore it is the target of the second throw.
 (catch 'a
   (catch 'b
     (unwind-protect (throw 'a 1)
       (throw 'b 2))))

;;; The following prints "The inner catch returns :SECOND-THROW"
;;; and then returns :OUTER-CATCH.
 (catch 'foo
         (format t "The inner catch returns ~s.~
                 (catch 'foo
                     (unwind-protect (throw 'foo :first-throw)
                         (throw 'foo :second-throw))))
         :outer-catch)

;;; The following returns 10. The inner CATCH of A is passed over, but 
;;; because that CATCH is disestablished before the THROW to A is executed,
;;; it isn't seen.
 (catch 'a
   (catch 'b
     (unwind-protect (1+ (catch 'a (throw 'b 1)))
       (throw 'a 10))))

;;; The following has undefined consequences because the extent of
;;; the (CATCH 'BAR ...) exit ends when the (THROW 'FOO ...)
;;; commences.
 (catch 'foo
   (catch 'bar
       (unwind-protect (throw 'foo 3)
         (throw 'bar 4)
         (print 'xxx))))

;;; The following returns 4; XXX is not printed.
;;; The (THROW 'FOO ...) has no effect on the scope of the BAR
;;; catch tag or the extent of the (CATCH 'BAR ...) exit.
 (catch 'bar
   (catch 'foo
       (unwind-protect (throw 'foo 3)
         (throw 'bar 4)
         (print 'xxx))))

;;; The following prints 5.
 (block nil
   (let ((x 5))
     (declare (special x))
     (unwind-protect (return)
       (print x))))          
@end example

@subsubheading  See Also::

@ref{catch}
,
@ref{go}
,
@ref{handler-case}
,
@ref{restart-case}
,
@ref{return}
, 
@ref{return-from}
,
@ref{throw}
,
@ref{Evaluation}

@node nil, not, unwind-protect, Data and Control Flow Dictionary
@subsection nil                                                     [Constant Variable]

@subsubheading  Constant Value::

@b{nil}.

@subsubheading  Description::

@b{nil} represents both @i{boolean} (and @i{generalized boolean}) @i{false}
and the @i{empty list}.

@subsubheading  Examples::
@example
 nil @result{}  NIL 
@end example

@subsubheading  See Also::

@ref{t}

@node not, t, nil, Data and Control Flow Dictionary
@subsection not                                                              [Function]

@code{not}  @i{x} @result{}  @i{boolean}

@subsubheading  Arguments and Values:: 

@i{x}---a @i{generalized boolean} (@i{i.e.}, any @i{object}).

@i{boolean}---a @i{boolean}.

@subsubheading  Description::

Returns @b{t} if @i{x} is @i{false};
otherwise, returns @b{nil}.

@subsubheading  Examples::

@example
 (not nil) @result{}  T
 (not '()) @result{}  T
 (not (integerp 'sss)) @result{}  T
 (not (integerp 1)) @result{}  NIL
 (not 3.7) @result{}  NIL
 (not 'apple) @result{}  NIL
@end example

@subsubheading  See Also::

@ref{null}

@subsubheading  Notes::

@b{not} is intended to be used to invert the `truth value' of a @i{boolean}
(or @i{generalized boolean})
whereas @b{null} is intended to be used to test for the @i{empty list}.
Operationally, @b{not} and @b{null} compute the same result;
which to use is a matter of style.

@node t, eq, not, Data and Control Flow Dictionary
@subsection t                                                       [Constant Variable]

@subsubheading  Constant Value::

@b{t}.

@subsubheading  Description::

The @i{boolean} representing true, 
and the canonical @i{generalized boolean} representing true.
Although any @i{object} 
other than @b{nil} is considered @i{true},
@b{t} is generally used when there is no special reason 
to prefer one such @i{object} over another.

The @i{symbol} @b{t} is also sometimes used for other purposes as well.
For example,
    as the @i{name} of a @i{class},
    as a @i{designator} (@i{e.g.}, a @i{stream designator})
 or as a special symbol for some syntactic reason 
      (@i{e.g.}, in @b{case} and @b{typecase} to label the @i{otherwise-clause}).

@subsubheading  Examples::

@example
 t @result{}  T 
 (eq t 't) @result{}  @i{true}
 (find-class 't) @result{}  #<CLASS T 610703333>
 (case 'a (a 1) (t 2)) @result{}  1
 (case 'b (a 1) (t 2)) @result{}  2
 (prin1 'hello t)
@t{ |> } HELLO
@result{}  HELLO
@end example

@subsubheading  See Also::

@ref{NIL}

@node eq, eql, t, Data and Control Flow Dictionary
@subsection eq                                                               [Function]

@code{eq}  @i{x y} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values:: 

@i{x}---an @i{object}.

@i{y}---an @i{object}.

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

Returns @i{true} if its @i{arguments} are the same, identical @i{object};
otherwise, returns @i{false}.

@subsubheading  Examples::
@example
 (eq 'a 'b) @result{}  @i{false}
 (eq 'a 'a) @result{}  @i{true}
 (eq 3 3)
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (eq 3 3.0) @result{}  @i{false}
 (eq 3.0 3.0)
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (eq #c(3 -4) #c(3 -4))
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (eq #c(3 -4.0) #c(3 -4)) @result{}  @i{false}
 (eq (cons 'a 'b) (cons 'a 'c)) @result{}  @i{false}
 (eq (cons 'a 'b) (cons 'a 'b)) @result{}  @i{false}
 (eq '(a . b) '(a . b))
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (progn (setq x (cons 'a 'b)) (eq x x)) @result{}  @i{true}
 (progn (setq x '(a . b)) (eq x x)) @result{}  @i{true}
 (eq #\A #\A)
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (let ((x "Foo")) (eq x x)) @result{}  @i{true}
 (eq "Foo" "Foo")
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (eq "Foo" (copy-seq "Foo")) @result{}  @i{false}
 (eq "FOO" "foo") @result{}  @i{false}
 (eq "string-seq" (copy-seq "string-seq")) @result{}  @i{false}
 (let ((x 5)) (eq x x))
@result{}  @i{true}
@i{OR}@result{} @i{false}
@end example

@subsubheading  See Also::  

@ref{eql}
,
@ref{equal}
,
@ref{equalp}
,
@ref{=; /=; <; >; <=; >=}
,
@ref{Compilation}

@subsubheading  Notes::
@i{Objects} that appear the same when printed are not necessarily
@b{eq} to each other.  @i{Symbols} that print the same 
usually are @b{eq} to each other because of the use of the
@b{intern} function.  However, @i{numbers} with the 
same value need not be @b{eq}, and two similar
@i{lists} are usually not @i{identical}.

An implementation is permitted to make ``copies'' of 
@i{characters} and @i{numbers} at any time.  
The effect is that @r{Common Lisp} makes no guarantee that @b{eq} 
is true even when both its arguments are ``the same thing'' if 
that thing is a @i{character} or @i{number}.

Most @r{Common Lisp} @i{operators} use @b{eql} rather than
@b{eq} to compare objects, or else they default to @b{eql}
and only use @b{eq} if specifically requested to do so.
However, the following @i{operators} are defined to use @b{eq}
rather than @b{eql} in a way that cannot be overridden by the
@i{code} which employs them:

@group
@noindent
@w{  catch           getf     throw  }
@w{  get             remf            }
@w{  get-properties  remprop  }

@noindent
@w{  Figure 5--11: Operators that always prefer EQ over EQL}

@end group

@node eql, equal, eq, Data and Control Flow Dictionary
@subsection eql                                                              [Function]

@code{eql}  @i{x y} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values::

@i{x}---an @i{object}.

@i{y}---an @i{object}. 

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

The value of @b{eql} is @i{true} of two objects, @i{x} and
@i{y}, in the folowing cases:
@table @asis

@item 1.  
If @i{x} and @i{y} are @b{eq}.
@item 2.  
If @i{x} and @i{y} are both @i{numbers} 
of the same @i{type} and the same value.
@item 3.  
If they are both @i{characters} that represent the 
same character.
@end table

Otherwise the value of @b{eql} is @i{false}.

If an implementation supports positive and negative zeros as @i{distinct} values,
then @t{(eql 0.0 -0.0)} returns @i{false}.
Otherwise, when the syntax @t{-0.0} is read it is interpreted as the value @t{0.0},
and so @t{(eql 0.0 -0.0)} returns @i{true}.  

@subsubheading  Examples::

@example
 (eql 'a 'b) @result{}  @i{false}
 (eql 'a 'a) @result{}  @i{true}
 (eql 3 3) @result{}  @i{true}
 (eql 3 3.0) @result{}  @i{false}
 (eql 3.0 3.0) @result{}  @i{true}
 (eql #c(3 -4) #c(3 -4)) @result{}  @i{true}
 (eql #c(3 -4.0) #c(3 -4)) @result{}  @i{false}
 (eql (cons 'a 'b) (cons 'a 'c)) @result{}  @i{false}
 (eql (cons 'a 'b) (cons 'a 'b)) @result{}  @i{false}
 (eql '(a . b) '(a . b))
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (progn (setq x (cons 'a 'b)) (eql x x)) @result{}  @i{true}
 (progn (setq x '(a . b)) (eql x x)) @result{}  @i{true}
 (eql #\A #\A) @result{}  @i{true}
 (eql "Foo" "Foo")
@result{}  @i{true}
@i{OR}@result{} @i{false}
 (eql "Foo" (copy-seq "Foo")) @result{}  @i{false}
 (eql "FOO" "foo") @result{}  @i{false}
@end example

Normally @t{(eql 1.0s0 1.0d0)} is false, under the assumption
that @t{1.0s0} and @t{1.0d0} are of distinct data types.
However, implementations that do not provide four distinct floating-point
formats are permitted to ``collapse'' the four formats into some
smaller number of them; in such an implementation @t{(eql 1.0s0 1.0d0)}
might be true.  

@subsubheading  See Also::

@ref{eq}
,
@ref{equal}
,
@ref{equalp}
,
@ref{=; /=; <; >; <=; >=}
,
@ref{char=; char/=; char<; char>; char<=; char>=; char-equal; char-not-equal; char-lessp; char-greaterp; char-not-greaterp; char-not-lessp}

@subsubheading  Notes::

@b{eql} is the same as @b{eq}, except that if the
arguments are @i{characters} or @i{numbers} 
of the same type then their
values are compared.  Thus @b{eql} tells whether two @i{objects}
are conceptually the same, whereas @b{eq} tells whether two
@i{objects} are implementationally identical.  It is for this reason
that @b{eql}, not @b{eq}, is the default comparison predicate
for @i{operators} that take @i{sequences}
as arguments.

@b{eql} may not be true of two @i{floats}
even when they represent the same
value.  @b{=} is used to compare
mathematical values.

Two @i{complex} numbers are considered to be @b{eql}
if their real parts are @b{eql} 
and their imaginary parts are @b{eql}.
For example, @t{(eql #C(4 5) #C(4 5))} is @i{true} and
@t{(eql #C(4 5) #C(4.0 5.0))} is @i{false}.
Note that while @t{(eql #C(5.0 0.0) 5.0)} is @i{false},
@t{(eql #C(5 0) 5)} is @i{true}.
In the case of @t{(eql #C(5.0 0.0) 5.0)} the
two arguments are of different types,
and so cannot satisfy @b{eql}.
In the case of @t{(eql #C(5 0) 5)}, 
@t{#C(5 0)} is not a @i{complex} number, but
is automatically reduced 
to the @i{integer} @t{5}.

@node equal, equalp, eql, Data and Control Flow Dictionary
@subsection equal                                                            [Function]

@code{equal}  @i{x y} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values:: 

@i{x}---an @i{object}.

@i{y}---an @i{object}.

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

Returns @i{true} if @i{x} and @i{y} are structurally similar
(isomorphic) @i{objects}.  @i{Objects} are treated as follows by
@b{equal}.

@table @asis

@item @i{Symbols}, @i{Numbers}, and @i{Characters}  
@b{equal} is @i{true} of two @i{objects} 
if they are @i{symbols} that are @b{eq},
if they are @i{numbers} that are @b{eql}, or
if they are @i{characters} that are @b{eql}.

@item @i{Conses}  
For @i{conses}, @b{equal} is defined recursively as
the two @i{cars} being @b{equal} 
and the two @i{cdrs} being @b{equal}.

@item @i{Arrays}  
Two @i{arrays} are @b{equal} only if they are @b{eq},
with one exception:
@i{strings} and @i{bit vectors} are compared element-by-element (using @b{eql}).
If either @i{x} or @i{y} has a @i{fill pointer}, the 
@i{fill pointer} limits
the number of elements examined by @b{equal}.
Uppercase and lowercase letters in @i{strings} are considered by
@b{equal} to be different.  

@item @i{Pathnames}  
Two @i{pathnames} are @b{equal} if and only if
all the corresponding components
(host, device, and so on) are 
equivalent.  Whether or not
uppercase and lowercase letters are considered equivalent
in @i{strings} appearing in components is @i{implementation-dependent}.
@i{pathnames}
that are @b{equal} should be functionally equivalent.

@item Other (Structures, hash-tables, instances, ...)  
Two other @i{objects} are @b{equal} only if they are @b{eq}.

@end table

@b{equal} does not descend any @i{objects} other than the
ones explicitly specified above.
Figure 5--12 summarizes the information given in the previous list.
In addition, the figure specifies the priority of the behavior of @b{equal},
with upper
  entries taking priority over lower ones.

@group
@noindent
@w{  Type          Behavior                   }
@w{  @i{number}        uses @b{eql}                   }
@w{  @i{character}     uses @b{eql}                   }
@w{  @i{cons}          descends                   }
@w{  @i{bit vector}    descends                   }
@w{  @i{string}        descends                   }
@w{  @i{pathname}      ``functionally equivalent''  }
@w{  @i{structure}     uses @b{eq}                    }
@w{  Other @i{array}   uses @b{eq}                    }
@w{  @i{hash table}    uses @b{eq}                    }
@w{  Other @i{object}  uses @b{eq}                    }

@noindent
@w{  Figure 5--12: Summary and priorities of behavior of @b{equal}}

@end group

Any two @i{objects} that are @b{eql} are also @b{equal}. 

@b{equal} may fail to terminate if @i{x} or @i{y} is circular.

@subsubheading  Examples::

@example
 (equal 'a 'b) @result{}  @i{false}
 (equal 'a 'a) @result{}  @i{true}
 (equal 3 3) @result{}  @i{true}
 (equal 3 3.0) @result{}  @i{false}
 (equal 3.0 3.0) @result{}  @i{true}
 (equal #c(3 -4) #c(3 -4)) @result{}  @i{true}
 (equal #c(3 -4.0) #c(3 -4)) @result{}  @i{false}
 (equal (cons 'a 'b) (cons 'a 'c)) @result{}  @i{false}
 (equal (cons 'a 'b) (cons 'a 'b)) @result{}  @i{true}
 (equal #\A #\A) @result{}  @i{true}
 (equal #\A #\a) @result{}  @i{false}
 (equal "Foo" "Foo") @result{}  @i{true}
 (equal "Foo" (copy-seq "Foo")) @result{}  @i{true}
 (equal "FOO" "foo") @result{}  @i{false}
 (equal "This-string" "This-string") @result{}  @i{true}
 (equal "This-string" "this-string") @result{}  @i{false}
@end example

@subsubheading  See Also::

@ref{eq}
, 
@ref{eql}
, 
@ref{equalp}
, 
@ref{=; /=; <; >; <=; >=}
, 
@ref{string=; string/=; string<; string>; string<=; string>=; string-equal; string-not-equal; string-lessp; string-greaterp; string-not-greaterp; string-not-lessp}
, @b{string-equal}, 
@ref{char=; char/=; char<; char>; char<=; char>=; char-equal; char-not-equal; char-lessp; char-greaterp; char-not-greaterp; char-not-lessp}
, 
@b{char-equal}, 
@ref{tree-equal}

@subsubheading  Notes::

    @i{Object} equality is not a concept for which there is a uniquely
    determined correct algorithm. The appropriateness of an equality
    predicate can be judged only in the context of the needs of some
    particular program. Although these functions take any type of
    argument and their names sound very generic, 
@b{equal} and @b{equalp} are
    not appropriate for every application. 

A rough rule of thumb is that two @i{objects} are @b{equal} 
if and only if their printed representations are the same.

@node equalp, identity, equal, Data and Control Flow Dictionary
@subsection equalp                                                           [Function]

@code{equalp}  @i{x y} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values::

@i{x}---an @i{object}.

@i{y}---an @i{object}.

@i{generalized-boolean}---a @i{generalized boolean}.

@subsubheading  Description::

Returns @i{true} if @i{x} and @i{y} are @b{equal},
or if they have components that are of the same @i{type} as each other
   and if those components are @b{equalp};
specifically, @b{equalp} returns @i{true} in the following cases:
@table @asis

@item @i{Characters}  
If two @i{characters} are @b{char-equal}.

@item @i{Numbers}  
If two @i{numbers} are the @i{same} under @b{=}. 

@item @i{Conses}  
If the two @i{cars} in the @i{conses} are @b{equalp} 
and the two @i{cdrs} in the @i{conses} are @b{equalp}.

@item @i{Arrays}  
If two @i{arrays} have the same
number of dimensions, the dimensions match,
and the corresponding
@i{active elements} 
are @b{equalp}.
The @i{types} for which the @i{arrays} are @i{specialized} need not match; 
for example, a @i{string} and a general @i{array} that happens to contain the same 
@i{characters} are @b{equalp}.
Because @b{equalp} performs @i{element}-by-@i{element} comparisons
of @i{strings} and ignores the @i{case} of @i{characters},
@i{case} distinctions are ignored when @b{equalp} compares @i{strings}.

@item @i{Structures}  
If two @i{structures} S_1 and S_2 have the same @i{class}
and the value of each @i{slot} in S_1 is the @i{same} under @b{equalp}
as the value of the corresponding @i{slot} in S_2.

@item @i{Hash Tables}  
@b{equalp} descends @i{hash-tables} by first comparing the count of entries
  and the @t{:test} function; if those are the same, it compares the
  keys of the tables using the @t{:test} function and then the values
  of the matching keys using @b{equalp} recursively.

@end table

@b{equalp} does not descend any @i{objects}
  other than the ones explicitly specified above.
Figure 5--13 summarizes the information given in the previous list.
In addition, the figure specifies the priority of the behavior of @b{equalp},
with upper
  entries taking priority over lower ones.

@group
@noindent
@w{  Type          Behavior                      }
@w{  @i{number}        uses @b{=}                        }
@w{  @i{character}     uses @b{char-equal}               }
@w{  @i{cons}          descends                      }
@w{  @i{bit vector}    descends                      }
@w{  @i{string}        descends                      }
@w{  @i{pathname}      same as @b{equal}                 }
@w{  @i{structure}     descends, as described above  }
@w{  Other @i{array}   descends                      }
@w{  @i{hash table}    descends, as described above  }
@w{  Other @i{object}  uses @b{eq}                       }

@noindent
@w{  Figure 5--13: Summary and priorities of behavior of @b{equalp}}

@end group

@subsubheading  Examples::

@example
 (equalp 'a 'b) @result{}  @i{false}
 (equalp 'a 'a) @result{}  @i{true}
 (equalp 3 3) @result{}  @i{true}
 (equalp 3 3.0) @result{}  @i{true}
 (equalp 3.0 3.0) @result{}  @i{true}
 (equalp #c(3 -4) #c(3 -4)) @result{}  @i{true}
 (equalp #c(3 -4.0) #c(3 -4)) @result{}  @i{true}
 (equalp (cons 'a 'b) (cons 'a 'c)) @result{}  @i{false}
 (equalp (cons 'a 'b) (cons 'a 'b)) @result{}  @i{true}
 (equalp #\A #\A) @result{}  @i{true}
 (equalp #\A #\a) @result{}  @i{true}
 (equalp "Foo" "Foo") @result{}  @i{true}
 (equalp "Foo" (copy-seq "Foo")) @result{}  @i{true}
 (equalp "FOO" "foo") @result{}  @i{true}
@end example

@example
 (setq array1 (make-array 6 :element-type 'integer
                            :initial-contents '(1 1 1 3 5 7))) 
@result{}  #(1 1 1 3 5 7)
 (setq array2 (make-array 8 :element-type 'integer
                            :initial-contents '(1 1 1 3 5 7 2 6)
                            :fill-pointer 6))
@result{}  #(1 1 1 3 5 7)
 (equalp array1 array2) @result{}  @i{true}
 (setq vector1 (vector 1 1 1 3 5 7)) @result{}  #(1 1 1 3 5 7)
 (equalp array1 vector1) @result{}  @i{true} 
@end example

@subsubheading  See Also::

@ref{eq}
, 
@ref{eql}
, 
@ref{equal}
, 
@ref{=; /=; <; >; <=; >=}
, 
@ref{string=; string/=; string<; string>; string<=; string>=; string-equal; string-not-equal; string-lessp; string-greaterp; string-not-greaterp; string-not-lessp}
, @b{string-equal}, 
@ref{char=; char/=; char<; char>; char<=; char>=; char-equal; char-not-equal; char-lessp; char-greaterp; char-not-greaterp; char-not-lessp}
, 
@b{char-equal}

@subsubheading  Notes::

    @i{Object} equality is not a concept for which there is a uniquely
    determined correct algorithm. The appropriateness of an equality
    predicate can be judged only in the context of the needs of some
    particular program. Although these functions take any type of
    argument and their names sound very generic, 
@b{equal} and @b{equalp} are
    not appropriate for every application. 

@node identity, complement, equalp, Data and Control Flow Dictionary
@subsection identity                                                         [Function]

@code{identity}  @i{object} @result{}  @i{object}

@subsubheading  Arguments and Values::

@i{object}---an @i{object}.

@subsubheading  Description::

Returns its argument @i{object}.

@subsubheading  Examples::

@example
 (identity 101) @result{}  101
 (mapcan #'identity (list (list 1 2 3) '(4 5 6))) @result{}  (1 2 3 4 5 6)
@end example

@subsubheading  Notes::

@b{identity} is intended for use with functions that require
a @i{function} as an argument.

@t{(eql x (identity x))} returns @i{true} for all possible values of @i{x},
but @t{(eq x (identity x))} might return @i{false} when @i{x} is a @i{number}
or @i{character}.

@b{identity} could be defined by

@example
(defun identity (x) x)
@end example

@node complement, constantly, identity, Data and Control Flow Dictionary
@subsection complement                                                       [Function]

@code{complement}  @i{function} @result{}  @i{complement-function}

@subsubheading  Arguments and Values::

@i{function}---a @i{function}.

@i{complement-function}---a @i{function}.

@subsubheading  Description::

Returns a @i{function} that
  takes the same @i{arguments} as @i{function},
  and has the same side-effect behavior as @i{function},
  but returns only a single value:
   a @i{generalized boolean} with the opposite truth value of that
   which would be returned as the @i{primary value} of @i{function}.
  That is, when the @i{function} would have returned
   @i{true} as its @i{primary value}
   the @i{complement-function} returns @i{false},
   and when the @i{function} would have returned
   @i{false} as its @i{primary value}
   the @i{complement-function} returns @i{true}.

@subsubheading  Examples::

@example
 (funcall (complement #'zerop) 1) @result{}  @i{true}
 (funcall (complement #'characterp) #\A) @result{}  @i{false}
 (funcall (complement #'member) 'a '(a b c)) @result{}  @i{false}
 (funcall (complement #'member) 'd '(a b c)) @result{}  @i{true}
@end example

@subsubheading  See Also::

@ref{not}

@subsubheading  Notes::

@example
 (complement @i{x}) @equiv{} #'(lambda (&rest arguments) (not (apply @i{x} arguments)))
@end example

In @r{Common Lisp}, functions with names like ``@t{@i{xxx}-if-not}''
are related to functions with names like ``@t{@i{xxx}-if}'' 
in that

@example
(@i{xxx}-if-not @i{f} . @i{arguments}) @equiv{} (@i{xxx}-if (complement @i{f}) . @i{arguments})
@end example

For example,

@example
 (find-if-not #'zerop '(0 0 3)) @equiv{}
 (find-if (complement #'zerop) '(0 0 3)) @result{}  3
@end example

Note that since the ``@t{@i{xxx}-if-not}'' @i{functions}
and the @t{:test-not} arguments have been deprecated,
uses of ``@t{@i{xxx}-if}'' @i{functions} or 
@t{:test} arguments with @b{complement} are preferred.

@node constantly, every, complement, Data and Control Flow Dictionary
@subsection constantly                                                       [Function]

@code{constantly}  @i{value} @result{}  @i{function}

@subsubheading  Arguments and Values:: 

@i{value}---an @i{object}.

@i{function}---a @i{function}.

@subsubheading  Description::

@b{constantly} returns a @i{function} that accepts any number of
arguments, that has no side-effects, and that always returns @i{value}.

@subsubheading  Examples::

@example
 (mapcar (constantly 3) '(a b c d)) @result{}  (3 3 3 3)
 (defmacro with-vars (vars &body forms)
   `((lambda ,vars ,@@forms) ,@@(mapcar (constantly nil) vars)))
@result{}  WITH-VARS
 (macroexpand '(with-vars (a b) (setq a 3 b (* a a)) (list a b)))
@result{}  ((LAMBDA (A B) (SETQ A 3 B (* A A)) (LIST A B)) NIL NIL), @i{true}
@end example

@subsubheading  See Also::

@ref{not}

@subsubheading  Notes::

@b{constantly} could be defined by:

@example
 (defun constantly (object)
   #'(lambda (&rest arguments) object))
@end example

@node every, and, constantly, Data and Control Flow Dictionary
@subsection every, some, notevery, notany                                    [Function]

@code{every}  @i{predicate {&rest} sequences^+} @result{}  @i{generalized-boolean}

@code{some}  @i{predicate {&rest} sequences^+} @result{}  @i{result}

@code{notevery}  @i{predicate {&rest} sequences^+} @result{}  @i{generalized-boolean}

@code{notany}  @i{predicate {&rest} sequences^+} @result{}  @i{generalized-boolean}

@subsubheading  Arguments and Values:: 

@i{predicate}---a @i{designator} for a @i{function} of
 as many @i{arguments} as there are @i{sequences}.

@i{sequence}---a @i{sequence}.

@i{result}---an @i{object}.

@i{generalized-boolean}---a @i{generalized boolean}. 

@subsubheading  Description::

@b{every}, @b{some}, @b{notevery}, and @b{notany}
test @i{elements} of @i{sequences} for satisfaction of a given @i{predicate}.
The first argument to @i{predicate} is an @i{element} of the first @i{sequence};
each succeeding argument is an @i{element} of a succeeding @i{sequence}.

@i{Predicate} is first applied to the elements
with index @t{0} in each of the @i{sequences}, and possibly then to
the elements with index @t{1}, and so on, until a termination
criterion is met or the end of the shortest of the @i{sequences} is reached.

@b{every} returns @i{false} as soon 
as any invocation of @i{predicate} returns @i{false}.
If the end of a @i{sequence} is reached,
@b{every} returns @i{true}.
Thus, @b{every} returns @i{true} if and only if
every invocation of @i{predicate} returns @i{true}.

@b{some} returns the first @i{non-nil} value 
which is returned by an invocation of @i{predicate}.
If the end of a @i{sequence} is reached without any invocation of the
@i{predicate} returning @i{true}, @b{some} returns @i{false}.
Thus, @b{some} returns @i{true} if and only if
some invocation of @i{predicate} returns @i{true}.

@b{notany} returns @i{false} 
as soon as any invocation of @i{predicate} returns @i{true}.
If the end of a @i{sequence} is reached,
@b{notany} returns @i{true}.
Thus, @b{notany} returns @i{true} if and only if 
it is not the case that any invocation of @i{predicate} returns @i{true}.

@b{notevery} returns @i{true} as soon as any invocation of
@i{predicate} returns @i{false}.
If the end of a @i{sequence} is reached,
@b{notevery} returns @i{false}.
Thus, @b{notevery} returns @i{true} if and only if 
it is not the case that every invocation of @i{predicate} returns @i{true}.

@subsubheading  Examples::

@example
 (every #'characterp "abc") @result{}  @i{true}
 (some #'= '(1 2 3 4 5) '(5 4 3 2 1)) @result{}  @i{true}
 (notevery #'< '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) @result{}  @i{false}
 (notany #'> '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) @result{}  @i{true} 
@end example

@subsubheading  Exceptional Situations::

Should signal @b{type-error} if its first argument is neither a
@i{symbol} nor a @i{function} or if any subsequent
argument is not a @i{proper sequence}.

Other exceptional situations are possible, depending on the nature
of the @i{predicate}.

@subsubheading  See Also::

@ref{and}
,
@ref{or}
,

@ref{Traversal Rules and Side Effects}

@subsubheading  Notes::

@example
 (notany @i{predicate} @{@i{sequence}@}{*}) @equiv{} (not (some @i{predicate} @{@i{sequence}@}{*}))
 (notevery @i{predicate} @{@i{sequence}@}{*}) @equiv{} (not (every @i{predicate} @{@i{sequence}@}{*}))
@end example

@node and, cond, every, Data and Control Flow Dictionary
@subsection and                                                                 [Macro]

@code{and}  @i{@{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{form}---a @i{form}.

@i{results}---the @i{values} resulting from the evaluation of 
	          the last @i{form}, or the symbols @b{nil} or @b{t}.

@subsubheading  Description::

The macro @b{and} evaluates each @i{form} one at a time from left to right. 
As soon as any @i{form} evaluates to @b{nil}, @b{and} returns
@b{nil} without evaluating the remaining @i{forms}.  If all @i{forms}
but the last evaluate to @i{true} values, @b{and} returns the results
produced by evaluating the last @i{form}.

If no @i{forms} are supplied, @t{(and)} returns @b{t}.

@b{and} passes back multiple values from the last @i{subform}
but not from subforms other than the last.

@subsubheading  Examples::

@example
 (if (and (>= n 0)
          (< n (length a-simple-vector))
          (eq (elt a-simple-vector n) 'foo))
     (princ "Foo!"))
@end example

The above expression prints @t{Foo!} if element @t{n} of @t{a-simple-vector}
is the symbol @t{foo}, provided also that @t{n} is indeed a valid index
for @t{a-simple-vector}.  Because @b{and} guarantees 
left-to-right testing
of its parts, @b{elt} is not called if @t{n} is out of range.

@example
 (setq temp1 1 temp2 1 temp3 1) @result{}  1 
 (and (incf temp1) (incf temp2) (incf temp3)) @result{}  2 
 (and (eql 2 temp1) (eql 2 temp2) (eql 2 temp3)) @result{}  @i{true}
 (decf temp3) @result{}  1 
 (and (decf temp1) (decf temp2) (eq temp3 'nil) (decf temp3)) @result{}  NIL 
 (and (eql temp1 temp2) (eql temp2 temp3)) @result{}  @i{true}
 (and) @result{}  T 
@end example

@subsubheading  See Also::

@ref{cond}
,
@ref{every; some; notevery; notany}
,
@ref{if}
,
@ref{or}
,
@ref{when; unless}

@subsubheading  Notes::

@example
 (and @i{form}) @equiv{} (let () @i{form})
 (and @i{form1} @i{form2} ...) @equiv{} (when @i{form1} (and @i{form2} ...))
@end example

@node cond, if, and, Data and Control Flow Dictionary
@subsection cond                                                                [Macro]

@code{cond}  @i{@{!@i{clause}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@w{@i{clause} ::=@r{(}test-form @{@i{form}@}{*}@r{)}}

@subsubheading  Arguments and Values::

@i{test-form}---a @i{form}.

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} of the @i{forms} 
    in the first @i{clause} whose @i{test-form} @i{yields} @i{true},
 or the @i{primary value} of the @i{test-form}
    if there are no @i{forms} in that @i{clause},
 or else @b{nil} if no @i{test-form} @i{yields} @i{true}.

@subsubheading  Description::

@b{cond} allows the execution of @i{forms} to be dependent
on @i{test-form}.

@i{Test-forms} are evaluated one at a time in the order in which
they are given in the argument list until a @i{test-form} is found that
evaluates to @i{true}.

If there are no @i{forms} in that clause, the @i{primary value} 
of the @i{test-form} is returned by the @b{cond} @i{form}.
Otherwise, the @i{forms} associated with this @i{test-form} are
evaluated in order, left to right, as an @i{implicit progn}, and the
@i{values} returned by the last @i{form} 
are returned by the @b{cond} @i{form}.

Once one @i{test-form} has @i{yielded} @i{true},
no additional @i{test-forms} are @i{evaluated}.
If no @i{test-form} @i{yields} @i{true}, @b{nil} is returned.

@subsubheading  Examples::

@example
 (defun select-options ()
   (cond ((= a 1) (setq a 2))
         ((= a 2) (setq a 3))
         ((and (= a 3) (floor a 2)))
         (t (floor a 3)))) @result{}  SELECT-OPTIONS
 (setq a 1) @result{}  1
 (select-options) @result{}  2
 a @result{}  2
 (select-options) @result{}  3
 a @result{}  3
 (select-options) @result{}  1
 (setq a 5) @result{}  5
 (select-options) @result{}  1, 2
@end example

@subsubheading  See Also::

@ref{if}
, 
@ref{case; ccase; ecase}
.

@node if, or, cond, Data and Control Flow Dictionary
@subsection if                                                       [Special Operator]

@code{if}  @i{@i{test-form} @i{then-form} @r{[}@i{else-form}@r{]}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{Test-form}---a @i{form}.

@i{Then-form}---a @i{form}.

@i{Else-form}---a @i{form}.
  The default is @b{nil}.

@i{results}---if the @i{test-form} @i{yielded} @i{true},
  the @i{values} returned by the @i{then-form}; otherwise,
  the @i{values} returned by the @i{else-form}.

@subsubheading  Description::

@b{if} allows the execution of a @i{form} to be dependent
on a single @i{test-form}.

First @i{test-form} is evaluated.
If the result is @i{true}, then @i{then-form} is selected;
otherwise @i{else-form} is selected.
Whichever form is selected is then evaluated.

@subsubheading  Examples::

@example
 (if t 1) @result{}  1
 (if nil 1 2) @result{}  2 
 (defun test ()
   (dolist (truth-value '(t nil 1 (a b c)))
     (if truth-value (print 'true) (print 'false))
     (prin1 truth-value))) @result{}  TEST
 (test)
@t{ |> } TRUE T
@t{ |> } FALSE NIL
@t{ |> } TRUE 1
@t{ |> } TRUE (A B C)
@result{}  NIL
@end example

@subsubheading  See Also::

@ref{cond}
,
@b{unless},
@ref{when; unless}

@subsubheading  Notes::

@example
 (if @i{test-form} @i{then-form} @i{else-form})
 @equiv{} (cond (@i{test-form} @i{then-form}) (t @i{else-form}))
@end example

@node or, when, if, Data and Control Flow Dictionary
@subsection or                                                                  [Macro]

@code{or}  @i{@{@i{form}@}{*}} @result{}  @i{@{@i{results}@}{*}}

@subsubheading  Arguments and Values:: 

@i{form}---a @i{form}.

@i{results}---the @i{values} or @i{primary value} (see below)
		  resulting from the evaluation of
		  the last @i{form} executed or @b{nil}.

@subsubheading  Description::

@b{or} evaluates each @i{form}, one at a time, from left to right.  
The evaluation of all @i{forms} terminates when a @i{form} evaluates
to @i{true} (@i{i.e.}, something other than @b{nil}).

If the @i{evaluation} of any @i{form} other than the last returns a
@i{primary value} that is @i{true}, @b{or} immediately returns
that @i{value} (but no additional @i{values}) without evaluating the
remaining @i{forms}.
If every @i{form} but the last returns @i{false} as its @i{primary value},
@b{or} returns all @i{values} returned by the last @i{form}.
If no @i{forms} are supplied, @b{or} returns @b{nil}.

@subsubheading  Examples::

@example
 (or) @result{}  NIL 
 (setq temp0 nil temp1 10 temp2 20 temp3 30) @result{}  30
 (or temp0 temp1 (setq temp2 37)) @result{}  10
 temp2 @result{}  20
 (or (incf temp1) (incf temp2) (incf temp3)) @result{}  11
 temp1 @result{}  11
 temp2 @result{}  20
 temp3 @result{}  30
 (or (values) temp1) @result{}  11
 (or (values temp1 temp2) temp3) @result{}  11
 (or temp0 (values temp1 temp2)) @result{}  11, 20
 (or (values temp0 temp1) (values temp2 temp3)) @result{}  20, 30
@end example

@subsubheading  See Also::

@ref{and}
,
@b{some},
@b{unless}

@node when, case, or, Data and Control Flow Dictionary
@subsection when, unless                                                        [Macro]

@code{when}  @i{test-form @{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@code{unless}  @i{test-form @{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{test-form}---a @i{form}.

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} of the @i{forms}
    in a  @b{when}   @i{form} if the @i{test-form} @i{yields} @i{true} 
 or in an @b{unless} @i{form} if the @i{test-form} @i{yields} @i{false};
 otherwise @b{nil}.

@subsubheading  Description::       

@b{when} and @b{unless} allow the execution of @i{forms} 
to be dependent on a single @i{test-form}.

In a @b{when} @i{form},
if the @i{test-form} @i{yields} @i{true},
the @i{forms} are @i{evaluated} in order from left to right
and the @i{values} returned by the @i{forms} 
are returned from the @b{when} @i{form}. 
Otherwise, if the @i{test-form} @i{yields} @i{false},
the @i{forms} are not @i{evaluated},
and the @b{when} @i{form} returns @b{nil}.

In an @b{unless} @i{form},
if the @i{test-form} @i{yields} @i{false},
the @i{forms} are @i{evaluated} in order from left to right
and the @i{values} returned by the @i{forms} 
are returned from the @b{unless} @i{form}. 
Otherwise, if the @i{test-form} @i{yields} @i{false},
the @i{forms} are not @i{evaluated},
and the @b{unless} @i{form} returns @b{nil}.

@subsubheading  Examples::

@example
 (when t 'hello) @result{}  HELLO
 (unless t 'hello) @result{}  NIL
 (when nil 'hello) @result{}  NIL
 (unless nil 'hello) @result{}  HELLO
 (when t) @result{}  NIL
 (unless nil) @result{}  NIL
 (when t (prin1 1) (prin1 2) (prin1 3))
@t{ |> } 123
@result{}  3
 (unless t (prin1 1) (prin1 2) (prin1 3)) @result{}  NIL
 (when nil (prin1 1) (prin1 2) (prin1 3)) @result{}  NIL
 (unless nil (prin1 1) (prin1 2) (prin1 3))
@t{ |> } 123
@result{}  3
 (let ((x 3))
   (list (when (oddp x) (incf x) (list x))
         (when (oddp x) (incf x) (list x))
         (unless (oddp x) (incf x) (list x))
         (unless (oddp x) (incf x) (list x))
         (if (oddp x) (incf x) (list x)) 
         (if (oddp x) (incf x) (list x)) 
         (if (not (oddp x)) (incf x) (list x)) 
         (if (not (oddp x)) (incf x) (list x))))
@result{}  ((4) NIL (5) NIL 6 (6) 7 (7))
@end example

@subsubheading  See Also::

@ref{and}
,
@ref{cond}
,
@ref{if}
,
@ref{or}

@subsubheading  Notes::

@example
 (when @i{test} @{@i{form}@}^+) @equiv{} (and @i{test} (progn @{@i{form}@}^+))
 (when @i{test} @{@i{form}@}^+) @equiv{} (cond (@i{test} @{@i{form}@}^+))
 (when @i{test} @{@i{form}@}^+) @equiv{} (if @i{test} (progn @{@i{form}@}^+) nil)
 (when @i{test} @{@i{form}@}^+) @equiv{} (unless (not @i{test}) @{@i{form}@}^+)
 (unless @i{test} @{@i{form}@}^+) @equiv{} (cond ((not @i{test}) @{@i{form}@}^+))
 (unless @i{test} @{@i{form}@}^+) @equiv{} (if @i{test} nil (progn @{@i{form}@}^+))
 (unless @i{test} @{@i{form}@}^+) @equiv{} (when (not @i{test}) @{@i{form}@}^+)
@end example

@node case, typecase, when, Data and Control Flow Dictionary
@subsection case, ccase, ecase                                                  [Macro]

@code{case}  @i{keyform  @{!@i{normal-clause}@}{*} @r{[}!@i{otherwise-clause}@r{]}} @result{}  @i{@{@i{result}@}{*}}

@code{ccase}  @i{keyplace @{!@i{normal-clause}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@code{ecase}  @i{keyform  @{!@i{normal-clause}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@w{@i{normal-clause} ::=@r{(}keys @{@i{form}@}{*}@r{)}}

@w{@i{otherwise-clause} ::=@r{(}@{otherwise | t@} @{@i{form}@}{*}@r{)}}

@w{@i{clause} ::=normal-clause | otherwise-clause}

@IRindex{otherwise}

@IRindex{t}

@subsubheading  Arguments and Values::

@i{keyform}---a @i{form}; evaluated to produce a @i{test-key}.

@i{keyplace}---a @i{form}; evaluated initially to produce a @i{test-key}.
   Possibly also used later as a @i{place} if no @i{keys} match.

@i{test-key}---an object produced by evaluating @i{keyform} or @i{keyplace}.

@i{keys}---a @i{designator} for a @i{list} of @i{objects}.
 In the case of @b{case}, the @i{symbols} @b{t} and @b{otherwise} may
 not be used as the @i{keys} @i{designator}.  To refer to these @i{symbols}
 by themselves as @i{keys}, the designators @t{(t)} and @t{(otherwise)}, respectively,
 must be used instead.

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} returned by the @i{forms} 
		  in the matching @i{clause}.

@subsubheading  Description::

These @i{macros} allow the conditional execution of a body of @i{forms}
in a @i{clause} that is selected by matching the @i{test-key} on the
basis of its identity.

The @i{keyform} or @i{keyplace} is @i{evaluated} to produce the
@i{test-key}.

Each of the @i{normal-clauses} is then considered in turn.
If the @i{test-key} is the @i{same} as any @i{key} for 
that @i{clause}, the @i{forms} in that @i{clause} are
@i{evaluated} as an @i{implicit progn}, and the @i{values}
it returns are returned as the value of the @b{case},
@b{ccase}, or @b{ecase} @i{form}.

These @i{macros} differ only in their @i{behavior} when 
no @i{normal-clause} matches; specifically:

@table @asis

@item @b{case}  
If no @i{normal-clause} matches, and there is an @i{otherwise-clause},
then that @i{otherwise-clause} automatically matches; the @i{forms} in
that @i{clause} are @i{evaluated} as an @i{implicit progn}, 
and the @i{values} it returns are returned as the value of the @b{case}.

If there is no @i{otherwise-clause}, @b{case} returns @b{nil}.

@item @b{ccase}  
If no @i{normal-clause} matches,
a @i{correctable} @i{error} of @i{type} @b{type-error} is signaled.
The offending datum is the @i{test-key} and
the expected type is @i{type equivalent} to @t{(member @i{key1} @i{key2} ...)}.
The @b{store-value} @i{restart} can be used to correct the error.

If the @b{store-value} @i{restart} is invoked, its @i{argument} becomes the 
new @i{test-key}, and is stored in @i{keyplace} as if by
@t{(setf @i{keyplace} @i{test-key})}.
Then @b{ccase} starts over, considering each @i{clause} anew.

[Reviewer Note by Barmar: Will it prompt for multiple values if keyplace is a VALUES general ref?]

The subforms of @i{keyplace} might be evaluated again if
none of the cases holds.

@item @b{ecase}  
If no @i{normal-clause} matches,
a @i{non-correctable} @i{error} of @i{type} @b{type-error} is signaled.
The offending datum is the @i{test-key} and
the expected type is @i{type equivalent} to @t{(member @i{key1} @i{key2} ...)}.

Note that in contrast with @b{ccase},
the caller of @b{ecase} may rely on the fact that @b{ecase} 
does not return if a @i{normal-clause} does not match.

@end table

@subsubheading  Examples::

@example
 (dolist (k '(1 2 3 :four #\v () t 'other))
    (format t "~S "
       (case k ((1 2) 'clause1)
               (3 'clause2)
               (nil 'no-keys-so-never-seen)
               ((nil) 'nilslot)
               ((:four #\v) 'clause4)
               ((t) 'tslot)
               (otherwise 'others)))) 
@t{ |> } CLAUSE1 CLAUSE1 CLAUSE2 CLAUSE4 CLAUSE4 NILSLOT TSLOT OTHERS 
@result{}  NIL
 (defun add-em (x) (apply #'+ (mapcar #'decode x)))
@result{}  ADD-EM
 (defun decode (x)
   (ccase x
     ((i uno) 1)
     ((ii dos) 2)
     ((iii tres) 3)
     ((iv cuatro) 4)))
@result{}  DECODE
 (add-em '(uno iii)) @result{}  4
 (add-em '(uno iiii))
@t{ |> } Error: The value of X, IIII, is not I, UNO, II, DOS, III,
@t{ |> }        TRES, IV, or CUATRO.
@t{ |> }  1: Supply a value to use instead.
@t{ |> }  2: Return to Lisp Toplevel.
@t{ |> } Debug> @b{|>>}@t{:CONTINUE 1}@b{<<|}
@t{ |> } Value to evaluate and use for X: @b{|>>}@t{'IV}@b{<<|}
@result{}  5
@end example

@subsubheading  Side Effects::

The debugger might be entered.
If the @b{store-value} @i{restart} is invoked,
the @i{value} of @i{keyplace} might be changed.

@subsubheading  Affected By::

@b{ccase} and @b{ecase}, since they might signal an error,
are potentially affected by existing @i{handlers} and @b{*debug-io*}.

@subsubheading  Exceptional Situations::

@b{ccase} and @b{ecase} signal an error of @i{type} @b{type-error}
if no @i{normal-clause} matches.

@subsubheading  See Also::

@ref{cond}
,
@ref{typecase; ctypecase; etypecase}
,
@ref{setf; psetf}
,
@ref{Generalized Reference}

@subsubheading  Notes::

@example
(case @i{test-key}
  @{((@{@i{key}@}{*}) @{@i{form}@}{*})@}{*})
@equiv{}
(let ((#1=#:g0001 @i{test-key}))
  (cond @{((member #1# '(@{@i{key}@}{*})) @{@i{form}@}{*})@}{*}))
@end example

The specific error message used by @b{ecase} and @b{ccase} can vary
between implementations.  In situations where control of the specific wording 
of the error message is important, it is better to use @b{case} with an
@i{otherwise-clause} that explicitly signals an error with an appropriate 
message.

@node typecase, multiple-value-bind, case, Data and Control Flow Dictionary
@subsection typecase, ctypecase, etypecase                                      [Macro]

@code{typecase}  @i{keyform  @{!@i{normal-clause}@}{*} @r{[}!@i{otherwise-clause}@r{]}} @result{}  @i{@{@i{result}@}{*}}

@code{ctypecase}  @i{keyplace @{!@i{normal-clause}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@code{etypecase}  @i{keyform  @{!@i{normal-clause}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@w{@i{normal-clause} ::=@r{(}type @{@i{form}@}{*}@r{)}}

@w{@i{otherwise-clause} ::=@r{(}@{otherwise | t@} @{@i{form}@}{*}@r{)}}

@w{@i{clause} ::=normal-clause | otherwise-clause}

@IRindex{otherwise}

@IRindex{t}

@subsubheading  Arguments and Values::

@i{keyform}---a @i{form}; evaluated to produce a @i{test-key}.

@i{keyplace}---a @i{form}; evaluated initially to produce a @i{test-key}.
   Possibly also used later as a @i{place} if no @i{types} match.

@i{test-key}---an object produced by evaluating @i{keyform} or @i{keyplace}.

@i{type}---a @i{type specifier}.

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} returned by the @i{forms} 
		  in the matching @i{clause}.

@subsubheading  Description::

These @i{macros} allow the conditional execution of a body of @i{forms}
in a @i{clause} that is selected by matching the @i{test-key} on the basis 
of its @i{type}.

The @i{keyform} or @i{keyplace} is @i{evaluated} to produce the
@i{test-key}.

Each of the @i{normal-clauses} is then considered in turn.
If the @i{test-key} is of the @i{type} 
given by the @i{clauses}'s @i{type},
the @i{forms} in that @i{clause} are
@i{evaluated} as an @i{implicit progn}, and the @i{values}
it returns are returned as the value of the @b{typecase},
@b{ctypecase}, or @b{etypecase} @i{form}.

These @i{macros} differ only in their @i{behavior} when 
no @i{normal-clause} matches; specifically:

@table @asis

@item @b{typecase}  
If no @i{normal-clause} matches, and there is an @i{otherwise-clause},
then that @i{otherwise-clause} automatically matches; the @i{forms} in
that @i{clause} are @i{evaluated} as an @i{implicit progn}, 
and the @i{values} it returns are returned as the value of the @b{typecase}.

If there is no @i{otherwise-clause}, @b{typecase} returns @b{nil}.

@item @b{ctypecase}  
If no @i{normal-clause} matches,
a @i{correctable} @i{error} of @i{type} @b{type-error} is signaled.
The offending datum is the @i{test-key} and
the expected type is @i{type equivalent} to @t{(or @i{type1} @i{type2} ...)}.
The @b{store-value} @i{restart} can be used to correct the error.

If the @b{store-value} @i{restart} is invoked, its @i{argument} becomes the 
new @i{test-key}, and is stored in @i{keyplace} as if by
@t{(setf @i{keyplace} @i{test-key})}.
Then @b{ctypecase} starts over, considering each @i{clause} anew.

If the @b{store-value} @i{restart} is invoked interactively, 
the user is prompted for a new @i{test-key} to use.

The subforms of @i{keyplace} might be evaluated again if
none of the cases holds.

@item @b{etypecase}  
If no @i{normal-clause} matches,
a @i{non-correctable} @i{error} of @i{type} @b{type-error} is signaled.
The offending datum is the @i{test-key} and
the expected type is @i{type equivalent} to @t{(or @i{type1} @i{type2} ...)}.

Note that in contrast with @b{ctypecase},
the caller of @b{etypecase} may rely on the fact that @b{etypecase} 
does not return if a @i{normal-clause} does not match.

@end table

In all three cases, is permissible for more than one @i{clause} to specify a
matching @i{type}, particularly if one is a @i{subtype} of another;
the earliest applicable @i{clause} is chosen.

@subsubheading  Examples::

@example
;;; (Note that the parts of this example which use TYPE-OF 
;;;  are implementation-dependent.)
 (defun what-is-it (x)
   (format t "~&~S is ~A.~
           x (typecase x
               (float "a float")
               (null "a symbol, boolean false, or the empty list")
               (list "a list")
               (t (format nil "a(n) ~(~A~)" (type-of x))))))
@result{}  WHAT-IS-IT
 (map 'nil #'what-is-it '(nil (a b) 7.0 7 box))
@t{ |> } NIL is a symbol, boolean false, or the empty list.
@t{ |> } (A B) is a list.
@t{ |> } 7.0 is a float.
@t{ |> } 7 is a(n) integer.
@t{ |> } BOX is a(n) symbol.
@result{}  NIL
 (setq x 1/3)
@result{}  1/3
 (ctypecase x
     (integer (* x 4))
     (symbol  (symbol-value x)))
@t{ |> } Error: The value of X, 1/3, is neither an integer nor a symbol.
@t{ |> } To continue, type :CONTINUE followed by an option number:
@t{ |> }  1: Specify a value to use instead.
@t{ |> }  2: Return to Lisp Toplevel.
@t{ |> } Debug> @b{|>>}@t{:CONTINUE 1}@b{<<|}
@t{ |> } Use value: @b{|>>}@t{3.7}@b{<<|}
@t{ |> } Error: The value of X, 3.7, is neither an integer nor a symbol.
@t{ |> } To continue, type :CONTINUE followed by an option number:
@t{ |> }  1: Specify a value to use instead.
@t{ |> }  2: Return to Lisp Toplevel.
@t{ |> } Debug> @b{|>>}@t{:CONTINUE 1}@b{<<|}
@t{ |> } Use value: @b{|>>}@t{12}@b{<<|}
@result{}  48
 x @result{}  12
@end example

@subsubheading  Affected By::

@b{ctypecase} and @b{etypecase}, since they might signal an error,
are potentially affected by existing @i{handlers} and @b{*debug-io*}.

@subsubheading  Exceptional Situations::

@b{ctypecase} and @b{etypecase} signal an error of @i{type} @b{type-error}
if no @i{normal-clause} matches.

The @i{compiler} may choose to issue a warning of @i{type} @b{style-warning}
if a @i{clause} will never be selected because it is completely 
shadowed by earlier clauses.

@subsubheading  See Also::

@ref{case; ccase; ecase}
,
@ref{cond}
,
@ref{setf; psetf}
,
@ref{Generalized Reference}

@subsubheading  Notes::

@example
(typecase @i{test-key}
  @{(@i{type} @{@i{form}@}{*})@}{*})
@equiv{}
(let ((#1=#:g0001 @i{test-key}))
  (cond @{((typep #1# '@i{type}) @{@i{form}@}{*})@}{*}))
@end example

The specific error message used by @b{etypecase} and @b{ctypecase} can vary
between implementations.  In situations where control of the specific wording 
of the error message is important, it is better to use @b{typecase} with an
@i{otherwise-clause} that explicitly signals an error with an appropriate 
message.

@node multiple-value-bind, multiple-value-call, typecase, Data and Control Flow Dictionary
@subsection multiple-value-bind                                                 [Macro]

@code{multiple-value-bind}  @i{@r{(}@{@i{var}@}{*}@r{)}
 		   @i{values-form}
 		   @{@i{declaration}@}{*}
 		   @{@i{form}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{var}---a @i{symbol} naming a variable; not evaluated.

@i{values-form}---a @i{form}; evaluated.

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} returned by the @i{forms}.

@subsubheading  Description::

Creates new variable @i{bindings} for the @i{vars} and
executes a series of @i{forms} that use these @i{bindings}.

The variable @i{bindings} created are lexical unless
@b{special} declarations are specified.  

@i{Values-form} is evaluated, and each of the @i{vars} is
bound to the respective value returned by that @i{form}.  If there are more
@i{vars} than values returned, extra values of @b{nil} are given to the
remaining @i{vars}. If there are more values than 
@i{vars}, the excess
values are discarded.  The @i{vars} are bound to the values over
the execution of the @i{forms}, which make up an implicit @b{progn}.
The consequences are unspecified if a type @i{declaration} is specified 
for a @i{var}, but the value to which
that @i{var} is bound  is not consistent with 
the type @i{declaration}.

The @i{scopes} of the name binding and @i{declarations}
do not include the @i{values-form}.

@subsubheading  Examples::

@example
 (multiple-value-bind (f r) 
     (floor 130 11)
   (list f r)) @result{}  (11 9)
@end example

@subsubheading  See Also::

@ref{let; let*}
,
@ref{multiple-value-call}

@subsubheading  Notes::

@example
 (multiple-value-bind (@{@i{var}@}{*}) @i{values-form} @{@i{form}@}{*})
 @equiv{} (multiple-value-call #'(lambda (&optional @{@i{var}@}{*} &rest #1=#:ignore)
                             (declare (ignore #1#))
                             @{@i{form}@}{*})
                         @i{values-form})
@end example

@node multiple-value-call, multiple-value-list, multiple-value-bind, Data and Control Flow Dictionary
@subsection multiple-value-call                                      [Special Operator]

@code{multiple-value-call}  @i{@i{function-form} @i{form}@r{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{function-form}---a @i{form}; evaluated to produce @i{function}.

@i{function}---a @i{function designator} 
		   resulting from the evaluation of @i{function-form}.

@i{form}---a @i{form}.

@i{results}---the @i{values} returned by the @i{function}.

@subsubheading  Description::

Applies @i{function} to a @i{list} of the @i{objects} collected from groups of 
@i{multiple values}_2.

@b{multiple-value-call} first evaluates the @i{function-form}
to obtain @i{function}, and then evaluates each @i{form}.
All the values
of each @i{form} are gathered together (not just one value from each)
and given as arguments to the @i{function}.  

@subsubheading  Examples::
@example
 (multiple-value-call #'list 1 '/ (values 2 3) '/ (values) '/ (floor 2.5))
@result{}  (1 / 2 3 / / 2 0.5)
 (+ (floor 5 3) (floor 19 4)) @equiv{} (+ 1 4)
@result{}  5
 (multiple-value-call #'+ (floor 5 3) (floor 19 4)) @equiv{} (+ 1 2 4 3)
@result{}  10
@end example

@subsubheading  See Also::

@ref{multiple-value-list}
, 
@ref{multiple-value-bind}

@node multiple-value-list, multiple-value-prog1, multiple-value-call, Data and Control Flow Dictionary
@subsection multiple-value-list                                                 [Macro]

@code{multiple-value-list}  @i{form} @result{}  @i{list}

@subsubheading  Arguments and Values::

@i{form}---a @i{form}; evaluated as described below.

@i{list}---a @i{list} of the @i{values} returned by @i{form}.

@subsubheading  Description::

@b{multiple-value-list} evaluates @i{form} 
and creates a @i{list} of the @i{multiple values}_2 it returns.

@subsubheading  Examples::

@example
 (multiple-value-list (floor -3 4)) @result{}  (-1 1)
@end example

@subsubheading  See Also::

@ref{values-list}
,
@ref{multiple-value-call}

@subsubheading  Notes::

@b{multiple-value-list} and @b{values-list} are inverses
of each other.

@example
 (multiple-value-list form) @equiv{} (multiple-value-call #'list form)
@end example

@node multiple-value-prog1, multiple-value-setq, multiple-value-list, Data and Control Flow Dictionary
@subsection multiple-value-prog1                                     [Special Operator]

@code{multiple-value-prog}  @i{1} @result{}  @i{first-form @{@i{form}@}{*}}

		   {first-form-results}

@subsubheading  Arguments and Values::

@i{first-form}---a @i{form}; evaluated as described below.

@i{form}---a @i{form}; evaluated as described below.

@i{first-form-results}---the @i{values} resulting from
			     the @i{evaluation} of @i{first-form}.      

@subsubheading  Description::

@b{multiple-value-prog1} evaluates @i{first-form} and saves
all the values produced by that @i{form}. It then evaluates each 
@i{form} from left to right, discarding their values.  

@subsubheading  Examples::

@example
 (setq temp '(1 2 3)) @result{}  (1 2 3)
 (multiple-value-prog1
    (values-list temp)
    (setq temp nil)
    (values-list temp)) @result{}  1, 2, 3
@end example

@subsubheading  See Also::

@ref{prog1; prog2}

@node multiple-value-setq, values, multiple-value-prog1, Data and Control Flow Dictionary
@subsection multiple-value-setq                                                 [Macro]

@code{multiple-value-setq}  @i{vars form} @result{}  @i{result}

@subsubheading  Arguments and Values::

@i{vars}---a @i{list} of @i{symbols}
	       that are either @i{variable} @i{names}
	       or @i{names} of @i{symbol macros}.

@i{form}---a @i{form}.

@i{result}---The @i{primary value} returned by the @i{form}.

@subsubheading  Description::

@b{multiple-value-setq} assigns values to @i{vars}.

The @i{form} is evaluated,
and each @i{var} is @i{assigned} 
to the corresponding @i{value} returned by that @i{form}. 
If there are more @i{vars} than @i{values} returned,
@b{nil} is @i{assigned} to the extra @i{vars}.
If there are more @i{values} than @i{vars},
the extra @i{values} are discarded.

If any @i{var} is the @i{name} of a @i{symbol macro},
then it is @i{assigned} as if by @b{setf}.  Specifically,

@example
 (multiple-value-setq (@i{symbol}_1 ... @i{symbol}_n) @i{value-producing-form})
@end example

is defined to always behave in the same way as

@example
 (values (setf (values @i{symbol}_1 ... @i{symbol}_n) @i{value-producing-form}))
@end example

in order that the rules for order of evaluation and side-effects be consistent
with those used by @b{setf}.
@ITindex{order of evaluation}

@ITindex{evaluation order}

See @ref{VALUES Forms as Places}.

@subsubheading  Examples::

@example
 (multiple-value-setq (quotient remainder) (truncate 3.2 2)) @result{}  1
 quotient @result{}  1
 remainder @result{}  1.2
 (multiple-value-setq (a b c) (values 1 2)) @result{}  1
 a @result{}  1
 b @result{}  2
 c @result{}  NIL
 (multiple-value-setq (a b) (values 4 5 6)) @result{}  4
 a @result{}  4
 b @result{}  5
@end example

@subsubheading  See Also::

@ref{setq}
,
@ref{symbol-macrolet}

@node values, values-list, multiple-value-setq, Data and Control Flow Dictionary
@subsection values                                                           [Accessor]

@code{values}  @i{{&rest} object} @result{}  @i{@{@i{object}@}{*}}

(setf (@code{         values} @i{{&rest} place}) new-values)@*

@subsubheading  Arguments and Values:: 

@i{object}---an @i{object}.

@i{place}---a @i{place}.

@i{new-value}---an @i{object}.

@subsubheading  Description::

@b{values} 
returns the @i{objects} as @i{multiple values}_2.

@b{setf} of @b{values} is used to store the
@i{multiple values}_2 @i{new-values} into the @i{places}.  
See @ref{VALUES Forms as Places}.

@subsubheading  Examples::

@example
 (values) @result{}  <@i{no @i{values}}>
 (values 1) @result{}  1
 (values 1 2) @result{}  1, 2
 (values 1 2 3) @result{}  1, 2, 3
 (values (values 1 2 3) 4 5) @result{}  1, 4, 5
 (defun polar (x y)
   (values (sqrt (+ (* x x) (* y y))) (atan y x))) @result{}  POLAR
 (multiple-value-bind (r theta) (polar 3.0 4.0)
   (vector r theta))
@result{}  #(5.0 0.927295)
@end example

Sometimes it is desirable to indicate explicitly that a function returns
exactly one value.  For example, the function

@example
 (defun foo (x y)
   (floor (+ x y) y)) @result{}  FOO
@end example

returns two values because @b{floor} returns
two values.  It may be that the second value makes no sense,
or that for efficiency reasons it is desired not to compute the
second value.  @b{values} is the standard idiom
for indicating that only one value is to be returned:

@example
 (defun foo (x y)
   (values (floor (+ x y) y))) @result{}  FOO
@end example

This works because @b{values} 
returns exactly one value for each of
@i{args}; as for any function call,
if any of @i{args} produces more than one value, all but the
first are discarded.

@subsubheading  See Also::

@ref{values-list}
,
@ref{multiple-value-bind}
,
@ref{multiple-values-limit}
,
@ref{Evaluation}

@subsubheading  Notes::

Since @b{values} is a @i{function}, not a @i{macro} or @i{special form},
it receives as @i{arguments} only the @i{primary values} of 
its @i{argument} @i{forms}.

@node values-list, multiple-values-limit, values, Data and Control Flow Dictionary
@subsection values-list                                                      [Function]

@code{values-list}  @i{list} @result{}  @i{@{@i{element}@}{*}}

@subsubheading  Arguments and Values::

@i{list}---a @i{list}.

@i{elements}---the @i{elements} of the @i{list}.

@subsubheading  Description::

Returns the @i{elements} of the @i{list} as @i{multiple values}_2.

@subsubheading  Examples::

@example
 (values-list nil) @result{}  <@i{no @i{values}}>
 (values-list '(1)) @result{}  1
 (values-list '(1 2)) @result{}  1, 2
 (values-list '(1 2 3)) @result{}  1, 2, 3
@end example

@subsubheading  Exceptional Situations::

Should signal @b{type-error} if its argument is not a @i{proper list}.

@subsubheading  See Also::

@ref{multiple-value-bind}
,
@ref{multiple-value-list}
,
@ref{multiple-values-limit}
,
@ref{values}

@subsubheading  Notes::

@example
 (values-list @i{list}) @equiv{} (apply #'values @i{list})
@end example

@t{(equal @i{x} (multiple-value-list (values-list @i{x})))}
returns @i{true} for all @i{lists} @i{x}.

@node multiple-values-limit, nth-value, values-list, Data and Control Flow Dictionary
@subsection multiple-values-limit                                   [Constant Variable]

@subsubheading  Constant Value::

An @i{integer} not smaller than @t{20}, 
the exact magnitude of which is @i{implementation-dependent}.

@subsubheading  Description::

The upper exclusive bound on the number of @i{values} that may be
    returned from a @i{function},

    bound or assigned by @b{multiple-value-bind} or @b{multiple-value-setq},
 or passed as a first argument to @b{nth-value}.
(If these individual limits might differ, the minimum value is used.)

@subsubheading  See Also::

@ref{lambda-parameters-limit}
, 
@ref{call-arguments-limit}

@subsubheading  Notes::

Implementors are encouraged to make this limit as large as possible.

@node nth-value, prog, multiple-values-limit, Data and Control Flow Dictionary
@subsection nth-value                                                           [Macro]

@code{nth-value}  @i{n form} @result{}  @i{object}

@subsubheading  Arguments and Values::

@i{n}---a non-negative @i{integer}; evaluated.

@i{form}---a @i{form}; evaluated as described below.

@i{object}---an @i{object}.

@subsubheading  Description::

Evaluates @i{n} and then @i{form},
returning as its only value the @i{n}th value @i{yielded} by @i{form},
or @b{nil} if @i{n} is greater than or equal to the number of @i{values}
returned by @i{form}.  (The first returned value is numbered @t{0}.)

@subsubheading  Examples::

@example
 (nth-value 0 (values 'a 'b)) @result{}  A
 (nth-value 1 (values 'a 'b)) @result{}  B
 (nth-value 2 (values 'a 'b)) @result{}  NIL
 (let* ((x 83927472397238947423879243432432432)
        (y 32423489732)
        (a (nth-value 1 (floor x y)))
        (b (mod x y)))
   (values a b (= a b)))
@result{}  3332987528, 3332987528, @i{true}
@end example

@subsubheading  See Also::

@ref{multiple-value-list}
,
@ref{nth}

@subsubheading  Notes::

Operationally, the following relationship is true, although @b{nth-value} 
might be more efficient in some @i{implementations} 
because, for example, some @i{consing} might be avoided.

@example
 (nth-value @i{n} @i{form}) @equiv{} (nth @i{n} (multiple-value-list @i{form}))
@end example

@node prog, prog1, nth-value, Data and Control Flow Dictionary
@subsection prog, prog*                                                         [Macro]

@code{prog}  @i{@r{(}@{@i{var} | 
			  	       @r{(}@i{var} @r{[}@i{init-form}@r{]}@r{)}@}{*}@r{)}
	      	   @{@i{declaration}@}{*}
	      	   @{@i{tag} | @i{statement}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@code{prog*}  @i{@r{(}@{@i{var} | 
				       @r{(}@i{var} @r{[}@i{init-form}@r{]}@r{)}@}{*}@r{)}
		   @{@i{declaration}@}{*} 
		   @{@i{tag} | @i{statement}@}{*}}@*
   @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values::

@i{var}---variable name.

@i{init-form}---a @i{form}.

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{tag}---a @i{go tag}; not evaluated.

@i{statement}---a @i{compound form}; evaluated as described below.

@i{results}---@b{nil} if a @i{normal return} occurs,
   or else, if an @i{explicit return} occurs, the @i{values} that were transferred.

@subsubheading  Description::

Three distinct operations are performed by @b{prog} and 
@b{prog*}:  
they bind local variables,
they permit use of the @b{return} 
statement, and they permit use of the @b{go}
statement.
A typical @b{prog} looks like this:

@example
 (prog (var1 var2 (var3 init-form-3) var4 (var5 init-form-5))
       @{@i{declaration}@}{*}
       statement1
  tag1
       statement2
       statement3
       statement4
  tag2
       statement5
       ...
       )
@end example

For @b{prog},
@i{init-forms} are evaluated first, in the order in which they are
supplied. The @i{vars} are then bound to the corresponding values in
parallel.  If no @i{init-form} 
is supplied for a given @i{var}, 
that @i{var} is  bound to @b{nil}.

The body of @b{prog} is executed as if it were a @b{tagbody} @i{form};
the @b{go} statement can be used to transfer control
to a @i{tag}.
@i{Tags} label @i{statements}.

@b{prog} implicitly establishes a @b{block} named @b{nil} around
the entire @b{prog} @i{form}, so that @b{return} can be used
at any time to exit from the @b{prog} @i{form}.

The difference between @b{prog*} and @b{prog} is that
in @b{prog*} the @i{binding} and initialization of the @i{vars} 
is done @i{sequentially}, so that the @i{init-form} for each
one can use the values of previous ones.

@subsubheading  Examples::
@example
(prog* ((y z) (x (car y)))
       (return x))
@end example

returns the @i{car} of the value of @t{z}.

@example
 (setq a 1) @result{}  1
 (prog ((a 2) (b a)) (return (if (= a b) '= '/=))) @result{}  /=
 (prog* ((a 2) (b a)) (return (if (= a b) '= '/=))) @result{}  =
 (prog () 'no-return-value) @result{}  NIL
@end example

@example
 (defun king-of-confusion (w)
   "Take a cons of two lists and make a list of conses.
    Think of this function as being like a zipper."
   (prog (x y z)          ;Initialize x, y, z to NIL
        (setq y (car w) z (cdr w))
    loop
        (cond ((null y) (return x))
              ((null z) (go err)))
    rejoin
        (setq x (cons (cons (car y) (car z)) x))
        (setq y (cdr y) z (cdr z))
        (go loop)
    err
        (cerror "Will self-pair extraneous items"
                "Mismatch - gleep!  ~S" y)
        (setq z y)
        (go rejoin))) @result{}  KING-OF-CONFUSION 
@end example

This can be accomplished more perspicuously as follows:

@example
 (defun prince-of-clarity (w)
   "Take a cons of two lists and make a list of conses.
    Think of this function as being like a zipper."
   (do ((y (car w) (cdr y))
        (z (cdr w) (cdr z))
        (x '@t{()} (cons (cons (car y) (car z)) x)))
       ((null y) x)
     (when (null z)
       (cerror "Will self-pair extraneous items"
              "Mismatch - gleep!  ~S" y)
       (setq z y)))) @result{}  PRINCE-OF-CLARITY 
@end example

@subsubheading  See Also::

@ref{block}
, 
@ref{let; let*}
, 
@ref{tagbody}
, 
@ref{go}
, 
@ref{return}
, @ref{Evaluation}

@subsubheading  Notes::
@b{prog} can be explained in terms of 
@b{block}, @b{let}, and @b{tagbody} as
follows:

@example
 (prog @i{variable-list} @i{declaration} . @i{body})
    @equiv{} (block nil (let @i{variable-list} @i{declaration} (tagbody . @i{body})))
@end example

@node prog1, progn, prog, Data and Control Flow Dictionary
@subsection prog1, prog2                                                        [Macro]

@code{prog}  @i{1} @result{}  @i{first-form             @{@i{form}@}{*}}
 {result-1}
@code{prog}  @i{2} @result{}  @i{first-form second-form @{@i{form}@}{*}}
 {result-2}

@subsubheading  Arguments and Values::

@i{first-form}---a @i{form}; evaluated as described below.

@i{second-form}---a @i{form}; evaluated as described below.

@i{forms}---an @i{implicit progn}; evaluated as described below.

@i{result-1}---the @i{primary value} resulting from 
		   the @i{evaluation} of @i{first-form}.

@i{result-2}---the @i{primary value} resulting from 
		   the @i{evaluation} of @i{second-form}.

@subsubheading  Description::

@b{prog1} @i{evaluates} @i{first-form} 
 and then @i{forms},
@i{yielding} as its only @i{value}
the @i{primary value} @i{yielded} by @i{first-form}.

@b{prog2} @i{evaluates} @i{first-form},
     then @i{second-form},
 and then @i{forms},
@i{yielding} as its only @i{value}
the @i{primary value} @i{yielded} by @i{first-form}.

@subsubheading  Examples::

@example
 (setq temp 1) @result{}  1
 (prog1 temp (print temp) (incf temp) (print temp))
@t{ |> } 1
@t{ |> } 2
@result{}  1
 (prog1 temp (setq temp nil)) @result{}  2
 temp @result{}  NIL
 (prog1 (values 1 2 3) 4) @result{}  1 
 (setq temp (list 'a 'b 'c))
 (prog1 (car temp) (setf (car temp) 'alpha)) @result{}  A
 temp @result{}  (ALPHA B C)
 (flet ((swap-symbol-values (x y)
          (setf (symbol-value x) 
                (prog1 (symbol-value y)
                       (setf (symbol-value y) (symbol-value x))))))
   (let ((*foo* 1) (*bar* 2))
     (declare (special *foo* *bar*))
     (swap-symbol-values '*foo* '*bar*)
     (values *foo* *bar*)))
@result{}  2, 1
 (setq temp 1) @result{}  1
 (prog2 (incf temp) (incf temp) (incf temp)) @result{}  3
 temp @result{}  4
 (prog2 1 (values 2 3 4) 5) @result{}  2
@end example

@subsubheading  See Also::

@ref{multiple-value-prog1}
,
@ref{progn}

@subsubheading  Notes::

@b{prog1} and @b{prog2} are typically used to @i{evaluate} 
one or more @i{forms} with side effects and return a @i{value} that
must be computed before some or all of the side effects happen.

@example
 (prog1 @{@i{form}@}{*}) @equiv{} (values (multiple-value-prog1 @{@i{form}@}{*}))
 (prog2 @i{form1} @{@i{form}@}{*}) @equiv{} (let () @i{form1} (prog1 @{@i{form}@}{*}))
@end example

@node progn, define-modify-macro, prog1, Data and Control Flow Dictionary
@subsection progn                                                    [Special Operator]

@code{progn}  @i{@{@i{form}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@subsubheading  Arguments and Values:: 

@i{forms}---an @i{implicit progn}.

@i{results}---the @i{values} of the @i{forms}.

@subsubheading  Description::

@b{progn} evaluates @i{forms},
in the order in which they are given.

The values of each @i{form} but the last are discarded.

If @b{progn} appears as a @i{top level form}, then all @i{forms}
within that @b{progn} are considered by the compiler to be 
@i{top level forms}.

@subsubheading  Examples::
@example
 (progn) @result{}  NIL
 (progn 1 2 3) @result{}  3
 (progn (values 1 2 3)) @result{}  1, 2, 3
 (setq a 1) @result{}  1
 (if a
      (progn (setq a nil) 'here)
      (progn (setq a t) 'there)) @result{}  HERE
 a @result{}  NIL
@end example

@subsubheading  See Also::

@ref{prog1; prog2}
, @b{prog2}, @ref{Evaluation}

@subsubheading  Notes::

Many places in @r{Common Lisp} involve syntax that uses @i{implicit progns}.
That is, part of their syntax allows many @i{forms} to be written
that are to be evaluated sequentially, discarding the results
of all @i{forms} but the last and returning the results of the last @i{form}.
Such places include, but are not limited to, the following:
     the body of a @i{lambda expression};
     the bodies of various control and conditional @i{forms}
    (@i{e.g.}, @b{case}, @b{catch}, @b{progn}, and @b{when}).

@node define-modify-macro, defsetf, progn, Data and Control Flow Dictionary
@subsection define-modify-macro                                                 [Macro]

@code{define-modify-macro}  @i{name lambda-list function @r{[}documentation@r{]}} @result{}  @i{name}

@subsubheading  Arguments and Values:: 

@i{name}---a @i{symbol}.

@i{lambda-list}---a @i{define-modify-macro lambda list} 

@i{function}---a @i{symbol}.

@i{documentation}---a @i{string}; not evaluated.

@subsubheading  Description::

@b{define-modify-macro} defines a @i{macro} named
@i{name} to @i{read} and @i{write} a @i{place}.

The arguments to the new @i{macro} are a @i{place},
followed
by the arguments that are supplied in @i{lambda-list}.

@i{Macros} defined with @b{define-modify-macro} 
correctly pass the @i{environment parameter} to 

@b{get-setf-expansion}.

When the @i{macro} is invoked, @i{function} 
is applied to the old contents of the @i{place}
and the @i{lambda-list} arguments to obtain the new value,
and the @i{place} is updated to contain the result.

Except for the issue of avoiding multiple evaluation (see below), the expansion
of a @b{define-modify-macro} is equivalent to the following:

@example
 (defmacro @i{name} (reference . @i{lambda-list})
   @i{documentation}
   `(setf ,reference
          (@i{function} ,reference ,@i{arg1} ,@i{arg2} ...)))
@end example

where @i{arg1}, @i{arg2}, ..., 
are the parameters appearing in @i{lambda-list};
appropriate provision is made for a @i{rest parameter}.

The @i{subforms} of the macro calls defined by @b{define-modify-macro}
are evaluated as specified in @ref{Evaluation of Subforms to Places}.

@i{Documentation} is attached as a @i{documentation string} 
    to @i{name} (as kind @b{function})
and to the @i{macro function}.

If a @b{define-modify-macro} @i{form} appears as a @i{top level form},
the @i{compiler} must store the @i{macro} definition at compile time,
so that occurrences of the macro later on in the file can be expanded correctly.

@subsubheading  Examples::
@example
 (define-modify-macro appendf (&rest args) 
    append "Append onto list") @result{}  APPENDF
 (setq x '(a b c) y x) @result{}  (A B C)
 (appendf x '(d e f) '(1 2 3)) @result{}  (A B C D E F 1 2 3)
 x @result{}  (A B C D E F 1 2 3)
 y @result{}  (A B C)
 (define-modify-macro new-incf (&optional (delta 1)) +)
 (define-modify-macro unionf (other-set &rest keywords) union)
@end example

@subsubheading  Side Effects::

A macro definition is assigned to @i{name}.

@subsubheading  See Also::

@ref{defsetf}
,

@ref{define-setf-expander}
,

@ref{documentation; (setf documentation)}
,
@ref{Syntactic Interaction of Documentation Strings and Declarations}

@node defsetf, define-setf-expander, define-modify-macro, Data and Control Flow Dictionary
@subsection defsetf                                                             [Macro]

The ``short form'':

@code{defsetf}  @i{access-fn update-fn @r{[}documentation@r{]}}@*
   @result{}  @i{access-fn}

The ``long form'':

@code{defsetf}  @i{access-fn lambda-list @r{(}@{@i{store-variable}@}{*}@r{)}
                          {[[@{@i{declaration}@}{*} | @i{documentation}]]} @{@i{form}@}{*}}@*
   @result{}  @i{access-fn}

@subsubheading  Arguments and Values:: 

@i{access-fn}---a @i{symbol} which names a @i{function} or a @i{macro}.

@i{update-fn}---a @i{symbol} naming a @i{function} or @i{macro}.

@i{lambda-list}---a @i{defsetf lambda list}.

@i{store-variable}---a @i{symbol} (a @i{variable} @i{name}).

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{documentation}---a @i{string}; not evaluated.

@i{form}---a @i{form}.

@subsubheading  Description::

@b{defsetf} defines how to 
@b{setf} a @i{place}
of the form @t{(@i{access-fn} ...)} for relatively simple cases.
(See @b{define-setf-expander} for more general access to this facility.)

It must be the case that the @i{function} or @i{macro} named by @i{access-fn} 
evaluates all of its arguments.

@b{defsetf} may take one of two forms, called the ``short form'' and the ``long form,''
which are distinguished by the @i{type} of the second @i{argument}.

When the short form is used, 
@i{update-fn} must name 
a @i{function} (or @i{macro}) that takes one more argument
than @i{access-fn} takes.  When @b{setf} is given a @i{place}
that is a call on @i{access-fn}, it expands into
a call on @i{update-fn} that is given all the arguments to
@i{access-fn} and also, as its last argument, the new value
(which must be returned by @i{update-fn} as its value).

The long form @b{defsetf} 
resembles @b{defmacro}.
The @i{lambda-list} describes the arguments of @i{access-fn}. 
The @i{store-variables} describe the
value 

or values 

to be stored into the @i{place}.
The @i{body} must
compute the expansion of a @b{setf} of a call on @i{access-fn}.

The expansion function is defined in the same @i{lexical environment}
in which the @b{defsetf} @i{form} appears.

During the evaluation of the
@i{forms}, the variables in the @i{lambda-list} and the
@i{store-variables}
are bound to names of temporary variables,
generated as if by @b{gensym}
or @b{gentemp},
that will be bound by the
expansion of @b{setf} 
to the values of those @i{subforms}.  This binding
permits the
@i{forms} to be written without regard for order-of-evaluation
issues.  @b{defsetf} arranges for the temporary variables to be
optimized out of the final result in cases where that is possible.  

The body code in @b{defsetf} is implicitly enclosed in a 
@i{block} whose name is 
@i{access-fn}

@b{defsetf} 
ensures that @i{subforms} 
of the @i{place} are evaluated exactly once.

@i{Documentation} is attached to @i{access-fn} as a @i{documentation string}
of kind @b{setf}.

If a @b{defsetf} @i{form} appears as a @i{top level form},
the @i{compiler} must make the @i{setf expander} available so that
it may be used to expand calls to @b{setf} later on in the @i{file}.
Users must ensure that the @i{forms}, if any, can be evaluated
at compile time if the @i{access-fn} is used in a @i{place}
later in the same @i{file}.
The @i{compiler} must make these @i{setf expanders} available to 
compile-time calls to @b{get-setf-expansion} when its @i{environment} 
argument is a value received as the @i{environment parameter} of a @i{macro}.

@subsubheading  Examples::
The effect of

@example
 (defsetf symbol-value set)
@end example

is built into the @r{Common Lisp} system.
This causes the form @t{(setf (symbol-value foo) fu)}
to expand into @t{(set foo fu)}.

Note that

@example
 (defsetf car rplaca)
@end example

would be incorrect because @b{rplaca} does not return its last argument.

@example
 (defun middleguy (x) (nth (truncate (1- (list-length x)) 2) x)) @result{}  MIDDLEGUY
 (defun set-middleguy (x v)
    (unless (null x)
      (rplaca (nthcdr (truncate (1- (list-length x)) 2) x) v))
    v) @result{}  SET-MIDDLEGUY
 (defsetf middleguy set-middleguy) @result{}  MIDDLEGUY
 (setq a (list 'a 'b 'c 'd)
       b (list 'x)
       c (list 1 2 3 (list 4 5 6) 7 8 9)) @result{}  (1 2 3 (4 5 6) 7 8 9)
 (setf (middleguy a) 3) @result{}  3
 (setf (middleguy b) 7) @result{}  7
 (setf (middleguy (middleguy c)) 'middleguy-symbol) @result{}  MIDDLEGUY-SYMBOL
 a @result{}  (A 3 C D)
 b @result{}  (7)
 c @result{}  (1 2 3 (4 MIDDLEGUY-SYMBOL 6) 7 8 9)
@end example

An example of the use of the long form of @b{defsetf}:

@example
 (defsetf subseq (sequence start &optional end) (new-sequence)
   `(progn (replace ,sequence ,new-sequence
                    :start1 ,start :end1 ,end)
           ,new-sequence)) @result{}  SUBSEQ
@end example

@example
 (defvar *xy* (make-array '(10 10)))
 (defun xy (&key ((x x) 0) ((y y) 0)) (aref *xy* x y)) @result{}  XY
 (defun set-xy (new-value &key ((x x) 0) ((y y) 0))
   (setf (aref *xy* x y) new-value)) @result{}  SET-XY
 (defsetf xy (&key ((x x) 0) ((y y) 0)) (store)
   `(set-xy ,store 'x ,x 'y ,y)) @result{}  XY
 (get-setf-expansion '(xy a b))
@result{}  (#:t0 #:t1),
   (a b),
   (#:store),
   ((lambda (&key ((x #:x)) ((y #:y))) 
      (set-xy #:store 'x #:x 'y #:y))
    #:t0 #:t1),
   (xy #:t0 #:t1)
 (xy 'x 1) @result{}  NIL
 (setf (xy 'x 1) 1) @result{}  1
 (xy 'x 1) @result{}  1
 (let ((a 'x) (b 'y))
   (setf (xy a 1 b 2) 3)
   (setf (xy b 5 a 9) 14))
@result{}  14
 (xy 'y 0 'x 1) @result{}  1
 (xy 'x 1 'y 2) @result{}  3
@end example

@subsubheading  See Also::

@ref{documentation; (setf documentation)}
,
@ref{setf; psetf}
,

@ref{define-setf-expander}
,
@ref{get-setf-expansion}
,

@ref{Generalized Reference},
@ref{Syntactic Interaction of Documentation Strings and Declarations}

@subsubheading  Notes::

@i{forms} must include provision
for returning the correct value (the value 

or values 

of @i{store-variable}).  
This is
handled by @i{forms} rather than by @b{defsetf} because
in many cases this value can be returned at no extra cost, by calling a
function that simultaneously stores into the @i{place} and 
returns the correct value.

A @b{setf} of a call on @i{access-fn} also evaluates
all of @i{access-fn}'s arguments; it cannot treat any of them specially.
This means that @b{defsetf} 
cannot be used to describe how to store into
a @i{generalized reference} to a byte, such as @t{(ldb field reference)}.

@b{define-setf-expander}

is used to handle situations that 
do not fit the restrictions imposed by @b{defsetf}
and gives the user additional control.

@node define-setf-expander, get-setf-expansion, defsetf, Data and Control Flow Dictionary
@subsection define-setf-expander                                                [Macro]

@code{define-setf-expander}  @i{access-fn lambda-list
			 {[[@{@i{declaration}@}{*} | @i{documentation}]]} @{@i{form}@}{*}}@*
   @result{}  @i{access-fn}

@subsubheading  Arguments and Values::

@i{access-fn}---a @i{symbol} that @i{names} a @i{function} or @i{macro}.

@i{lambda-list} -- @i{macro lambda list}.

@i{declaration}---a @b{declare} @i{expression}; not evaluated.

@i{documentation}---a @i{string}; not evaluated.

@i{forms}---an @i{implicit progn}.

@subsubheading  Description::

@b{define-setf-expander} specifies the means by which @b{setf} 
updates a @i{place} that is referenced by @i{access-fn}.

When @b{setf} is given a @i{place} that is
specified in terms of @i{access-fn} and a new value for the 
@i{place}, it is expanded into a form that performs
the appropriate update. 

The @i{lambda-list} supports destructuring.
See @ref{Macro Lambda Lists}.

@i{Documentation} is attached to @i{access-fn} as a @i{documentation string}
of kind @b{setf}.

@i{Forms} constitute the body of the 

@i{setf expander} 

definition and must compute the @i{setf expansion} for a call on @b{setf} 
that references the @i{place} by means of the given
@i{access-fn}.

The @i{setf expander} function is defined in the same @i{lexical environment}
in which the @b{define-setf-expander} @i{form} appears.

While @i{forms} are being executed,
the variables in @i{lambda-list} are bound to parts of the @i{place} @i{form}.

The body @i{forms} (but not the @i{lambda-list})

in a @b{define-setf-expander} @i{form} are implicitly enclosed in a 
@i{block} whose name is 
@i{access-fn}.

The evaluation of @i{forms} must result in the five values
described in @ref{Setf Expansions}.

If a @b{define-setf-expander} @i{form} appears as a @i{top level form},
the @i{compiler} must make the @i{setf expander} available so that
it may be used to expand calls to @b{setf} later on in the @i{file}.
@i{Programmers} must ensure that the @i{forms} can be evaluated
at compile time if the @i{access-fn} is used in a @i{place}
later in the same @i{file}.
The @i{compiler} must make these @i{setf expanders} available to 
compile-time calls to @b{get-setf-expansion} when its @i{environment} 
argument is a value received as the @i{environment parameter} of a @i{macro}.

@subsubheading  Examples::
@example
 (defun lastguy (x) (car (last x))) @result{}  LASTGUY
 (define-setf-expander lastguy (x &environment env)
   "Set the last element in a list to the given value."
   (multiple-value-bind (dummies vals newval setter getter)
       (get-setf-expansion x env)
     (let ((store (gensym)))
       (values dummies
               vals
               `(,store)
               `(progn (rplaca (last ,getter) ,store) ,store)
               `(lastguy ,getter))))) @result{}  LASTGUY
 (setq a (list 'a 'b 'c 'd)
       b (list 'x)
       c (list 1 2 3 (list 4 5 6))) @result{}  (1 2 3 (4 5 6))
 (setf (lastguy a) 3) @result{}  3
 (setf (lastguy b) 7) @result{}  7
 (setf (lastguy (lastguy c)) 'lastguy-symbol) @result{}  LASTGUY-SYMBOL
 a @result{}  (A B C 3)
 b @result{}  (7)
 c @result{}  (1 2 3 (4 5 LASTGUY-SYMBOL))
@end example

@example
;;; Setf expander for the form (LDB bytespec int).
;;; Recall that the int form must itself be suitable for SETF.
 (define-setf-expander ldb (bytespec int &environment env)
   (multiple-value-bind (temps vals stores
                          store-form access-form)
       (get-setf-expansion int env);Get setf expansion for int.
     (let ((btemp (gensym))     ;Temp var for byte specifier.
           (store (gensym))     ;Temp var for byte to store.
           (stemp (first stores))) ;Temp var for int to store.
       (if (cdr stores) (error "Can't expand this."))
;;; Return the setf expansion for LDB as five values.
       (values (cons btemp temps)       ;Temporary variables.
               (cons bytespec vals)     ;Value forms.
               (list store)             ;Store variables.
               `(let ((,stemp (dpb ,store ,btemp ,access-form)))
                  ,store-form
                  ,store)               ;Storing form.
               `(ldb ,btemp ,access-form) ;Accessing form.
              ))))
@end example

@subsubheading  See Also::

@ref{setf; psetf}
,
@ref{defsetf}
,
@ref{documentation; (setf documentation)}
,
@ref{get-setf-expansion}
,
@ref{Syntactic Interaction of Documentation Strings and Declarations}

@subsubheading  Notes::

@b{define-setf-expander} differs from the long form of @b{defsetf}
in that while the body is being executed the @i{variables}
in @i{lambda-list} are bound to parts of the @i{place} @i{form},
not to temporary variables that will be bound to the values of such parts.
In addition, @b{define-setf-expander} does not have @b{defsetf}'s
restriction that @i{access-fn} must be a @i{function} 
or a function-like @i{macro}; an arbitrary @b{defmacro} destructuring
pattern is permitted in @i{lambda-list}.

@node get-setf-expansion, setf, define-setf-expander, Data and Control Flow Dictionary
@subsection get-setf-expansion                                               [Function]

@code{get-setf-expansion}  @i{place {&optional} environment}@*
   @result{}  @i{vars, vals, store-vars, writer-form, reader-form}

@subsubheading  Arguments and Values:: 

@i{place}---a @i{place}.

@i{environment}---an @i{environment} @i{object}.

@i{vars, vals, store-vars, writer-form, reader-form}---a @i{setf expansion}.

@subsubheading  Description::

Determines
five values constituting the @i{setf expansion} for @i{place}
in @i{environment}; see @ref{Setf Expansions}.

If @i{environment} is not supplied or @b{nil},
the environment is the @i{null lexical environment}. 

@subsubheading  Examples::

@example
 (get-setf-expansion 'x)
@result{}  NIL, NIL, (#:G0001), (SETQ X #:G0001), X 
@end example

@example
;;; This macro is like POP 

 (defmacro xpop (place &environment env)
   (multiple-value-bind (dummies vals new setter getter)
                        (get-setf-expansion place env)
      `(let* (,@@(mapcar #'list dummies vals) (,(car new) ,getter))
         (if (cdr new) (error "Can't expand this."))
         (prog1 (car ,(car new))
                (setq ,(car new) (cdr ,(car new)))
                ,setter))))

 (defsetf frob (x) (value) 
     `(setf (car ,x) ,value)) @result{}  FROB
;;; The following is an error; an error might be signaled at macro expansion time
 (flet ((frob (x) (cdr x)))  ;Invalid
   (xpop (frob z)))

@end example

@subsubheading  See Also::

@ref{defsetf}
,
@ref{define-setf-expander}
,
@ref{setf; psetf}

@subsubheading  Notes::

Any @i{compound form} is a valid @i{place},
since any @i{compound form} whose @i{operator} @i{f} has no @i{setf expander}
are expanded into a call to @t{(setf @i{f})}.

@node setf, shiftf, get-setf-expansion, Data and Control Flow Dictionary
@subsection setf, psetf                                                         [Macro]

@code{setf}  @i{@{!@i{pair}@}{*}} @result{}  @i{@{@i{result}@}{*}}

@code{psetf}  @i{@{!@i{pair}@}{*}} @result{}  @i{@b{nil}}

@w{@i{pair} ::=place newvalue}

@subsubheading  Arguments and Values::

@i{place}---a @i{place}.

@i{newvalue}---a @i{form}.

@i{results}---the @i{multiple values}_2 
                  returned by the storing form for the last @i{place},
                  or @b{nil} if there are no @i{pairs}.

@subsubheading  Description::

@b{setf} changes the @i{value} of @i{place} to be @i{newvalue}.

@t{(setf place newvalue)} 
expands into an update form that stores the 
result 
of evaluating
@i{newvalue} into the location referred to by @i{place}.
   Some @i{place} forms 
involve uses of accessors that take optional arguments. 
   Whether those optional arguments are permitted by 
@b{setf}, or what their use
   is, is up to the 
@b{setf} expander function and is not under the control
   of @b{setf}. 
The documentation for any @i{function} 
that accepts @b{&optional}, @b{&rest},
   or @t{&key} arguments and that 
claims to be usable with @b{setf} must specify
   how those arguments are treated.

If more than one @i{pair} is supplied,
the @i{pairs} are processed sequentially; that is,

@example
 (setf place-1 newvalue-1
       place-2 newvalue-2
       ...
       place-N newvalue-N)
@end example

is precisely equivalent to

@example
 (progn (setf place-1 newvalue-1)
        (setf place-2 newvalue-2)
        ...
        (setf place-N newvalue-N))
@end example

For @b{psetf}, 
if more than one @i{pair} is supplied then the assignments of new values to places are
done in parallel.  More precisely, all @i{subforms} (in both the @i{place}
and @i{newvalue} @i{forms}) that are to be evaluated
are evaluated from left to right; after all evaluations have been performed,
all of the assignments are performed in an unpredictable order.

For detailed treatment of the expansion of @b{setf} and @b{psetf},
see @ref{Kinds of Places}.

@subsubheading  Examples::

@example
 (setq x (cons 'a 'b) y (list 1 2 3)) @result{}  (1 2 3) 
 (setf (car x) 'x (cadr y) (car x) (cdr x) y) @result{}  (1 X 3) 
 x @result{}  (X 1 X 3) 
 y @result{}  (1 X 3) 
 (setq x (cons 'a 'b) y (list 1 2 3)) @result{}  (1 2 3) 
 (psetf (car x) 'x (cadr y) (car x) (cdr x) y) @result{}  NIL 
 x @result{}  (X 1 A 3) 
 y @result{}  (1 A 3) 
@end example

@subsubheading  Affected By::

@b{define-setf-expander},
@b{defsetf},
@b{*macroexpand-hook*}

@subsubheading  See Also::

@ref{define-setf-expander}
,
@ref{defsetf}
,
@b{macroexpand-1},
@ref{rotatef}
,
@ref{shiftf}
,
@ref{Generalized Reference}

@node shiftf, rotatef, setf, Data and Control Flow Dictionary
@subsection shiftf                                                              [Macro]

@code{shiftf}  @i{@{@i{place}@}^+ newvalue} @result{}  @i{old-value-1}

@subsubheading  Arguments and Values::

@i{place}---a @i{place}.

@i{newvalue}---a @i{form}; evaluated.

@i{old-value-1}---an @i{object} (the old @i{value} of the first @i{place}).

@subsubheading  Description::

@b{shiftf} modifies the values of each
@i{place} by storing @i{newvalue}
into the last @i{place}, and shifting the 
values of the second through the last @i{place}
into the remaining @i{places}.

If @i{newvalue} produces more values than there
are store variables, the extra values are ignored. If @i{newvalue}
produces fewer values than there are store variables, the missing values
are set to @b{nil}.

In the form @t{(shiftf @i{place1} @i{place2} ... @i{placen} @i{newvalue})}, 
the values in @i{place1} through @i{placen} are @i{read} and saved,
and @i{newvalue} is evaluated, for a total of @t{n}+1 values in all.
Values 2 through @t{n}+1 are then stored into @i{place1} through @i{placen}, respectively.
It is as if all the @i{places} form a shift register; the @i{newvalue}
is shifted in from the right, all values shift over to the left one place,
and the value shifted out of @i{place1} is returned. 

For information about the @i{evaluation} of @i{subforms} of @i{places},
see @ref{Evaluation of Subforms to Places}.  

@subsubheading  Examples::

@example
 (setq x (list 1 2 3) y 'trash) @result{}  TRASH
 (shiftf y x (cdr x) '(hi there)) @result{}  TRASH
 x @result{}  (2 3)
 y @result{}  (1 HI THERE)

 (setq x (list 'a 'b 'c)) @result{}  (A B C)
 (shiftf (cadr x) 'z) @result{}  B
 x @result{}  (A Z C)
 (shiftf (cadr x) (cddr x) 'q) @result{}  Z
 x @result{}  (A (C) . Q)
 (setq n 0) @result{}  0
 (setq x (list 'a 'b 'c 'd)) @result{}  (A B C D)
 (shiftf (nth (setq n (+ n 1)) x) 'z) @result{}  B
 x @result{}  (A Z C D)
@end example

@subsubheading  Affected By::

@b{define-setf-expander},
@b{defsetf},
@b{*macroexpand-hook*}

@subsubheading  See Also::

@ref{setf; psetf}
, 
@ref{rotatef}
, @ref{Generalized Reference}

@subsubheading  Notes::

The effect of
 @t{(shiftf @i{place1} @i{place2} ... @i{placen} @i{newvalue})}
is roughly equivalent to

@example
 (let ((var1 @i{place1})
       (var2 @i{place2})
       ...
       (varn @i{placen})
       (var0 @i{newvalue}))
   (setf @i{place1} var2)
   (setf @i{place2} var3)
   ...
   (setf @i{placen} var0)
   var1)
@end example

except that the latter would evaluate any @i{subforms} 
of each @t{place} twice, whereas @b{shiftf} evaluates them once.
For example, 

@example
 (setq n 0) @result{}  0
 (setq x (list 'a 'b 'c 'd)) @result{}  (A B C D)
 (prog1 (nth (setq n (+ n 1)) x)
        (setf (nth (setq n (+ n 1)) x) 'z)) @result{}  B
 x @result{}  (A B Z D)
@end example

@node rotatef, control-error, shiftf, Data and Control Flow Dictionary
@subsection rotatef                                                             [Macro]

@code{rotatef}  @i{@{@i{place}@}{*}} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

@i{place}---a @i{place}.

@subsubheading  Description::

@b{rotatef} modifies the values of each @i{place} by
rotating values from one @i{place} into another.

If a @i{place} produces more values than there
are store variables, the extra values are ignored. If a @i{place}
produces fewer values than there are store variables, the missing values
are set to @b{nil}.

In the form @t{(rotatef @i{place1} @i{place2} ... @i{placen})}, 
the values in @i{place1} through @i{placen} are @i{read} and @i{written}.
Values 2 through @i{n} 
and value 1 are then stored into @i{place1} through @i{placen}.
It is as if all the places form an end-around shift register
that is rotated one place to the left, with the value of @i{place1}
being shifted around the end to @i{placen}.

For information about the @i{evaluation} of @i{subforms} of @i{places},
see @ref{Evaluation of Subforms to Places}.  

@subsubheading  Examples::
@example
 (let ((n 0)
        (x (list 'a 'b 'c 'd 'e 'f 'g)))
    (rotatef (nth (incf n) x)
             (nth (incf n) x)
             (nth (incf n) x))
    x) @result{}  (A C D B E F G)
@end example

@subsubheading  See Also::

@ref{define-setf-expander}
,
@ref{defsetf}
,
@ref{setf; psetf}
,
@ref{shiftf}
,
@b{*macroexpand-hook*},
@ref{Generalized Reference}

@subsubheading  Notes::

The effect of
 @t{(rotatef @i{place1} @i{place2} ... @i{placen})}
is roughly equivalent to

@example
 (psetf @i{place1} @i{place2}
        @i{place2} @i{place3}
        ...
        @i{placen} @i{place1})
@end example

except that the latter would evaluate any @i{subforms}
of each @t{place} twice, whereas @b{rotatef} evaluates them once.

@node control-error, program-error, rotatef, Data and Control Flow Dictionary
@subsection control-error                                              [Condition Type]

@subsubheading  Class Precedence List::
@b{control-error},
@b{error},
@b{serious-condition},
@b{condition},
@b{t}

@subsubheading  Description::

The @i{type} @b{control-error} consists of error conditions that result from
invalid dynamic transfers of control in a program.  The errors that
result from giving @b{throw} a tag that is not active or from
giving @b{go} or @b{return-from} a tag that is no longer
dynamically available are of @i{type} @b{control-error}.

@node program-error, undefined-function, control-error, Data and Control Flow Dictionary
@subsection program-error                                              [Condition Type]

@subsubheading  Class Precedence List::
@b{program-error},
@b{error},
@b{serious-condition},
@b{condition},
@b{t}

@subsubheading  Description::

The @i{type} @b{program-error}
consists of error conditions related to incorrect program syntax.  The
errors that result from naming a @i{go tag} or a @i{block tag}
that is not lexically apparent are of @i{type} @b{program-error}.

@node undefined-function,  , program-error, Data and Control Flow Dictionary
@subsection undefined-function                                         [Condition Type]

@subsubheading  Class Precedence List::
@b{undefined-function},
@b{cell-error},
@b{error},
@b{serious-condition},
@b{condition},
@b{t}

@subsubheading  Description::

The @i{type} @b{undefined-function} consists of @i{error} @i{conditions}
that represent attempts to @i{read} the definition of an @i{undefined function}.

The name of the cell (see @b{cell-error}) is the @i{function name}
which was @i{funbound}.

@subsubheading  See Also::

@ref{cell-error-name}

@c end of including dict-flow

@c %**end of chapter