File: chap-22.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 (5285 lines) | stat: -rw-r--r-- 194,654 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


@node Printer, Reader, Streams, Top
@chapter Printer

@menu
* The Lisp Printer::		
* The Lisp Pretty Printer::	
* Formatted Output::		
* Printer Dictionary::		
@end menu

@node The Lisp Printer, The Lisp Pretty Printer, Printer, Printer
@section The Lisp Printer

@c including concept-print

@menu
* Overview of The Lisp Printer::  
* Printer Dispatching::		
* Default Print-Object Methods::  
* Examples of Printer Behavior::  
@end menu

@node Overview of The Lisp Printer, Printer Dispatching, The Lisp Printer, The Lisp Printer
@subsection Overview of The Lisp Printer

@r{Common Lisp} provides a representation of most @i{objects} in the form 
of printed text called the printed representation.
Functions such as @b{print} take an @i{object} 
and send the characters of its printed representation to a @i{stream}. 
The collection of routines that does this is known as the (@r{Common Lisp}) printer.  

Reading a printed representation 
typically
produces an @i{object} that is @b{equal} to the
originally printed @i{object}.

@menu
* Multiple Possible Textual Representations::  
* Printer Escaping::		
@end menu

@node Multiple Possible Textual Representations, Printer Escaping, Overview of The Lisp Printer, Overview of The Lisp Printer
@subsubsection Multiple Possible Textual Representations

Most @i{objects} have more than one possible textual representation.
For example, the positive @i{integer} with a magnitude of twenty-seven
can be textually expressed in any of these ways:

@example
 27    27.    #o33    #x1B    #b11011    #.(* 3 3 3)    81/3
@end example

A list containing the two symbols @t{A} and @t{B} can also be textually
expressed in a variety of ways:

@example
 (A B)    (a b)    (  a  b )    (\A |B|) 
(|\A|
  B
)
@end example

In general,

from the point of view of the @i{Lisp reader},

wherever @i{whitespace} is permissible in a textual representation,
any number of @i{spaces} and @i{newlines} can appear in @i{standard syntax}.

When a function such as @b{print} produces a printed representation,
it must choose 
from among many possible textual representations.
In most cases, it chooses a 
program readable representation,
but in certain cases it might use a more compact notation that is not 
program-readable.

A number of option variables, called
@i{printer control variables}
@IGindex{printer control variable}
,
are provided to permit control of individual aspects of the 
printed representation of @i{objects}.
Figure 22--1 shows the @i{standardized} @i{printer control variables};
there might also be @i{implementation-defined} @i{printer control variables}.

@group
@noindent
@w{  *print-array*   *print-gensym*       *print-pprint-dispatch*  }
@w{  *print-base*    *print-length*       *print-pretty*           }
@w{  *print-case*    *print-level*        *print-radix*            }
@w{  *print-circle*  *print-lines*        *print-readably*         }
@w{  *print-escape*  *print-miser-width*  *print-right-margin*     }

@noindent
@w{       Figure 22--1: Standardized Printer Control Variables     }

@end group

In addition to the @i{printer control variables}, 
the following additional @i{defined names} 
relate to or affect the behavior of the @i{Lisp printer}:

@group
@noindent
@w{  *package*                    *read-eval*  readtable-case  }
@w{  *read-default-float-format*  *readtable*                  }

@noindent
@w{   Figure 22--2: Additional Influences on the Lisp printer. }

@end group

@node Printer Escaping,  , Multiple Possible Textual Representations, Overview of The Lisp Printer
@subsubsection Printer Escaping

The @i{variable} @b{*print-escape*} controls whether the @i{Lisp printer}
tries to produce notations such as escape characters and package prefixes.

The @i{variable} @b{*print-readably*} can be used to override
many of the individual aspects controlled by the other 
@i{printer control variables} when program-readable output
is especially important.

One of the many effects of making the @i{value} of @b{*print-readably*} be @i{true}
is that the @i{Lisp printer} behaves as if @b{*print-escape*} were also @i{true}.
For notational convenience, we say that 
if the value of either @b{*print-readably*} or @b{*print-escape*} is @i{true}, 
then @i{printer escaping}
@IGindex{printer escaping}
 is ``enabled'';
and we say that
if the values of both @b{*print-readably*} and @b{*print-escape*} are @i{false}, 
then @i{printer escaping} is ``disabled''.

@node Printer Dispatching, Default Print-Object Methods, Overview of The Lisp Printer, The Lisp Printer
@subsection Printer Dispatching

The @i{Lisp printer} makes its determination of how to print an
@i{object} as follows:

If the @i{value} of @b{*print-pretty*} is @i{true}, 
printing is controlled by the @i{current pprint dispatch table};
see @ref{Pretty Print Dispatch Tables}.

Otherwise (if the @i{value} of @b{*print-pretty*} is @i{false}),
the object's @b{print-object} method is used;
see @ref{Default Print-Object Methods}.

@node Default Print-Object Methods, Examples of Printer Behavior, Printer Dispatching, The Lisp Printer
@subsection Default Print-Object Methods

This section describes the default behavior of 
@b{print-object} methods for the @i{standardized} @i{types}.

@menu
* Printing Numbers::		
* Printing Integers::		
* Printing Ratios::		
* Printing Floats::		
* Printing Complexes::		
* Note about Printing Numbers::	 
* Printing Characters::		
* Printing Symbols::		
* Package Prefixes for Symbols::  
* Effect of Readtable Case on the Lisp Printer::  
* Examples of Effect of Readtable Case on the Lisp Printer::  
* Printing Strings::		
* Printing Lists and Conses::	
* Printing Bit Vectors::	
* Printing Other Vectors::	
* Printing Other Arrays::	
* Examples of Printing Arrays::	 
* Printing Random States::	
* Printing Pathnames::		
* Printing Structures::		
* Printing Other Objects::	
@end menu

@node Printing Numbers, Printing Integers, Default Print-Object Methods, Default Print-Object Methods
@subsubsection Printing Numbers

@node Printing Integers, Printing Ratios, Printing Numbers, Default Print-Object Methods
@subsubsection Printing Integers

@i{Integers} are printed in the radix specified by the @i{current output base}
in positional notation, most significant digit first.
If appropriate, a radix specifier can be printed; see @b{*print-radix*}.
If an @i{integer} is negative, a minus sign is printed and then the
absolute value of the @i{integer} is printed.
The @i{integer} zero is represented
by the single digit @t{0} and never has a sign.
A decimal point might be printed, 
depending on the @i{value} of @b{*print-radix*}.

For related information about the syntax of an @i{integer},
see @ref{Syntax of an Integer}.

@node Printing Ratios, Printing Floats, Printing Integers, Default Print-Object Methods
@subsubsection Printing Ratios

@IRindex{ratio}

@i{Ratios} are printed as follows:
the absolute value of the numerator is printed, as for an @i{integer};
then a @t{/}; then the denominator.  The numerator and denominator are
both printed in the radix specified by the @i{current output base}; 
they are obtained as if by
@b{numerator} and @b{denominator}, and so @i{ratios}
are printed in reduced form (lowest terms).
If appropriate, a radix specifier can be printed; see 
@b{*print-radix*}.
If the ratio is negative, a minus sign is printed before the numerator.

For related information about the syntax of a @i{ratio},
see @ref{Syntax of a Ratio}.

@node Printing Floats, Printing Complexes, Printing Ratios, Default Print-Object Methods
@subsubsection Printing Floats

@IRindex{float}

If the magnitude of the @i{float} is either zero or between 10^{-3} (inclusive)
and 10^7 (exclusive), it is printed as the integer part of the number,
then a decimal point,
followed by the fractional part of the number;
there is always at least one
digit on each side of the decimal point.    
If the sign of the number
(as determined by @b{float-sign})
is negative, then a minus sign is printed before the number.
If the format of the number
does not match that specified by
@b{*read-default-float-format*}, then the @i{exponent marker} for
that format and the digit @t{0} are also printed.
For example, the base of the natural logarithms as a @i{short float}
might be printed as @t{2.71828S0}.

For non-zero magnitudes outside of the range 10^{-3} to 10^7,
a @i{float} is printed in computerized scientific notation.
The representation of the number is scaled to be between
1 (inclusive) and 10 (exclusive) and then printed, with one digit
before the decimal point and at least one digit after the decimal point.
Next the @i{exponent marker} for the format is printed,
except that
if the format of the number matches that specified by 
@b{*read-default-float-format*}, then the @i{exponent marker} @t{E}
is used.
Finally, the power of ten by which the fraction must be multiplied
to equal the original number is printed as a decimal integer.
For example, Avogadro's number as a @i{short float} 
is printed as @t{6.02S23}.

For related information about the syntax of a @i{float},
see @ref{Syntax of a Float}.

@node Printing Complexes, Note about Printing Numbers, Printing Floats, Default Print-Object Methods
@subsubsection Printing Complexes

@IRindex{complex}

A @i{complex} is printed as @t{#C}, an open parenthesis,
the printed representation of its real part, a space,
the printed representation of its imaginary part, and finally
a close parenthesis.

For related information about the syntax of a @i{complex},
see @ref{Syntax of a Complex} and @ref{Sharpsign C}.

@node Note about Printing Numbers, Printing Characters, Printing Complexes, Default Print-Object Methods
@subsubsection Note about Printing Numbers

The printed representation of a number must not contain @i{escape} @i{characters};
see @ref{Escape Characters and Potential Numbers}.

@node Printing Characters, Printing Symbols, Note about Printing Numbers, Default Print-Object Methods
@subsubsection Printing Characters

When @i{printer escaping} is disabled,

a @i{character} prints as itself;
it is sent directly to the output @i{stream}.

When @i{printer escaping} is enabled,

then @t{#\} syntax is used.

When the printer types out the name of a @i{character},
it uses the same table as the @t{#\} @i{reader macro} would use;
therefore any @i{character} name that is typed out
is acceptable as input (in that @i{implementation}).
If a @i{non-graphic} @i{character} has a @i{standardized} @i{name}_5,
that @i{name} is preferred over non-standard @i{names}
for printing in @t{#\} notation.
For the @i{graphic} @i{standard characters},
the @i{character} itself is always used
for printing in @t{#\} notation---even if 
the @i{character} also has a @i{name}_5.

For details about the @t{#\} @i{reader macro}, see @ref{Sharpsign Backslash}.

@node Printing Symbols, Package Prefixes for Symbols, Printing Characters, Default Print-Object Methods
@subsubsection Printing Symbols

When @i{printer escaping} is disabled,

only the characters of the @i{symbol}'s @i{name} are output 

(but the case in which to print characters in the @i{name} is
controlled by @b{*print-case*};
see @ref{Effect of Readtable Case on the Lisp Printer}).

The remainder of this section applies only 

when @i{printer escaping} is enabled.

When printing a @i{symbol}, the printer inserts enough 
@i{single escape} and/or @i{multiple escape}
characters (@i{backslashes} and/or @i{vertical-bars}) so that if
@b{read} were called with the same @b{*readtable*} and
with @b{*read-base*} bound to the @i{current output base}, it
would return the same @i{symbol} (if it is not 
@i{apparently uninterned}) or an @i{uninterned} @i{symbol}
with the same @i{print name} (otherwise).

For example, if the @i{value} of @b{*print-base*} were @t{16} 
when printing the symbol @t{face}, it would have to be printed as
@t{\FACE} or @t{\Face} or @t{|FACE|}, 
because the token @t{face} would be read as a hexadecimal
number (decimal value 64206) if the @i{value} of @b{*read-base*} were @t{16}.

For additional restrictions concerning characters with  nonstandard
@i{syntax types} in the @i{current readtable}, see the @i{variable} @b{*print-readably*} 

For information about how the @i{Lisp reader} parses @i{symbols},
see @ref{Symbols as Tokens} and @ref{Sharpsign Colon}.

@b{nil} might be printed as @t{()} 

when @b{*print-pretty*} is @i{true}
and @i{printer escaping} is enabled.

@node Package Prefixes for Symbols, Effect of Readtable Case on the Lisp Printer, Printing Symbols, Default Print-Object Methods
@subsubsection Package Prefixes for Symbols

@i{Package prefixes} are printed if necessary.
The rules for @i{package prefixes} are as follows.
When the @i{symbol} is printed, if it is in the @t{KEYWORD} @i{package}, 
then it is printed with a preceding @i{colon}; otherwise, if
it is @i{accessible} in the @i{current package}, it is printed without any
@i{package prefix}; otherwise, it is printed with a @i{package prefix}.

A @i{symbol} that is @i{apparently uninterned} is printed
preceded by ``@t{#:}'' 

if @b{*print-gensym*} is @i{true} and @i{printer escaping} is enabled;
if @b{*print-gensym*} is @i{false} or @i{printer escaping} is disabled,

then the @i{symbol} is printed without a prefix,
as if it were in the @i{current package}.

Because the @t{#:} syntax does not intern the
following symbol, it is necessary to use circular-list syntax
if @b{*print-circle*} is @i{true} and
the same uninterned symbol appears several times in an expression
to be printed.  For example, the result of

@example
 (let ((x (make-symbol "FOO"))) (list x x))
@end example

would be printed as @t{(#:foo #:foo)} if @b{*print-circle*}
were @i{false}, but as @t{(#1=#:foo #1#)} if @b{*print-circle*}
were @i{true}.

A summary of the preceding package prefix rules follows:

@table @asis

@item @t{foo:bar}  
@t{foo:bar} is printed when @i{symbol} @t{bar} 
is external in its @i{home package} @t{foo} 
and is not @i{accessible} in the @i{current package}.

@item @t{foo::bar}  
@t{foo::bar} is printed when @t{bar} is internal in its @i{home package}
@t{foo} and is not @i{accessible} in the @i{current package}.

@item @t{:bar}  
@t{:bar} is printed when the home package of @t{bar} is the @t{KEYWORD} @i{package}.

@item #:bar  
@t{#:bar} is printed when @t{bar} is @i{apparently uninterned},
even in the pathological case that @t{bar} 
has no @i{home package} but is nevertheless somehow @i{accessible} 
in the @i{current package}.
@end table

@node Effect of Readtable Case on the Lisp Printer, Examples of Effect of Readtable Case on the Lisp Printer, Package Prefixes for Symbols, Default Print-Object Methods
@subsubsection Effect of Readtable Case on the Lisp Printer

When 
@i{printer escaping} is disabled,
or the characters under consideration are not already 
quoted specifically by @i{single escape} or @i{multiple escape}
syntax,

the @i{readtable case} of the @i{current readtable} 
affects the way the @i{Lisp printer} writes @i{symbols}
in the following ways:

@table @asis

@item @t{:upcase}  
When the @i{readtable case} is @t{:upcase},
 @i{uppercase} @i{characters}
 are printed in the case specified by @b{*print-case*}, and
 @i{lowercase} @i{characters} are printed in their own case.

@item @t{:downcase}  
When the @i{readtable case} is @t{:downcase},
 @i{uppercase} @i{characters} are printed in their own case, and
 @i{lowercase} @i{characters}
 are printed in the case specified by @b{*print-case*}.

@item @t{:preserve}  
When the @i{readtable case} is @t{:preserve},
 all @i{alphabetic} @i{characters} are printed in their own case.

@item @t{:invert}  
When the @i{readtable case} is @t{:invert},
 the case of all @i{alphabetic} @i{characters} 
 in single case symbol names is inverted.
 Mixed-case symbol names are printed as is.
@end table

The rules for escaping @i{alphabetic} @i{characters} in symbol names are affected by
the @b{readtable-case} 

if @i{printer escaping} is enabled.

@i{Alphabetic} @i{characters} are escaped as follows:                
@table @asis

@item @t{:upcase}  
When the @i{readtable case} is @t{:upcase},
all @i{lowercase} @i{characters} must be escaped.

@item @t{:downcase}  
When the @i{readtable case} is @t{:downcase},
all @i{uppercase} @i{characters} must be escaped.

@item @t{:preserve}  
When the @i{readtable case} is @t{:preserve}, 
no @i{alphabetic} @i{characters} need be escaped.

@item @t{:invert}  
When the @i{readtable case} is @t{:invert},
no @i{alphabetic} @i{characters} need be escaped.

@end table

@node Examples of Effect of Readtable Case on the Lisp Printer, Printing Strings, Effect of Readtable Case on the Lisp Printer, Default Print-Object Methods
@subsubsection Examples of Effect of Readtable Case on the Lisp Printer

@example
 (defun test-readtable-case-printing ()
   (let ((*readtable* (copy-readtable nil))
         (*print-case* *print-case*))
     (format t "READTABLE-CASE *PRINT-CASE*  Symbol-name  Output~
              ~
              ~
     (dolist (readtable-case '(:upcase :downcase :preserve :invert))
       (setf (readtable-case *readtable*) readtable-case)
       (dolist (print-case '(:upcase :downcase :capitalize))
         (dolist (symbol '(|ZEBRA| |Zebra| |zebra|))
           (setq *print-case* print-case)
           (format t "~&:~A~15T:~A~29T~A~42T~A"
                   (string-upcase readtable-case)
                   (string-upcase print-case)
                   (symbol-name symbol)
                   (prin1-to-string symbol)))))))
@end example

  The output from @t{(test-readtable-case-printing)} should be as follows:

@example
    READTABLE-CASE *PRINT-CASE*  Symbol-name  Output
    --------------------------------------------------
    :UPCASE        :UPCASE       ZEBRA        ZEBRA
    :UPCASE        :UPCASE       Zebra        |Zebra|
    :UPCASE        :UPCASE       zebra        |zebra|
    :UPCASE        :DOWNCASE     ZEBRA        zebra
    :UPCASE        :DOWNCASE     Zebra        |Zebra|
    :UPCASE        :DOWNCASE     zebra        |zebra|
    :UPCASE        :CAPITALIZE   ZEBRA        Zebra
    :UPCASE        :CAPITALIZE   Zebra        |Zebra|
    :UPCASE        :CAPITALIZE   zebra        |zebra|
    :DOWNCASE      :UPCASE       ZEBRA        |ZEBRA|
    :DOWNCASE      :UPCASE       Zebra        |Zebra|
    :DOWNCASE      :UPCASE       zebra        ZEBRA
    :DOWNCASE      :DOWNCASE     ZEBRA        |ZEBRA|
    :DOWNCASE      :DOWNCASE     Zebra        |Zebra|
    :DOWNCASE      :DOWNCASE     zebra        zebra
    :DOWNCASE      :CAPITALIZE   ZEBRA        |ZEBRA|
    :DOWNCASE      :CAPITALIZE   Zebra        |Zebra|
    :DOWNCASE      :CAPITALIZE   zebra        Zebra
    :PRESERVE      :UPCASE       ZEBRA        ZEBRA
    :PRESERVE      :UPCASE       Zebra        Zebra
    :PRESERVE      :UPCASE       zebra        zebra
    :PRESERVE      :DOWNCASE     ZEBRA        ZEBRA
    :PRESERVE      :DOWNCASE     Zebra        Zebra
    :PRESERVE      :DOWNCASE     zebra        zebra
    :PRESERVE      :CAPITALIZE   ZEBRA        ZEBRA
    :PRESERVE      :CAPITALIZE   Zebra        Zebra
    :PRESERVE      :CAPITALIZE   zebra        zebra
    :INVERT        :UPCASE       ZEBRA        zebra
    :INVERT        :UPCASE       Zebra        Zebra
    :INVERT        :UPCASE       zebra        ZEBRA
    :INVERT        :DOWNCASE     ZEBRA        zebra
    :INVERT        :DOWNCASE     Zebra        Zebra
    :INVERT        :DOWNCASE     zebra        ZEBRA
    :INVERT        :CAPITALIZE   ZEBRA        zebra
    :INVERT        :CAPITALIZE   Zebra        Zebra
    :INVERT        :CAPITALIZE   zebra        ZEBRA
@end example

@node Printing Strings, Printing Lists and Conses, Examples of Effect of Readtable Case on the Lisp Printer, Default Print-Object Methods
@subsubsection Printing Strings

The characters of the @i{string} are output in order.

If @i{printer escaping} is enabled,

a @i{double-quote} is output before and after, and all
@i{double-quotes} and @i{single escapes} are preceded by @i{backslash}.
The printing of @i{strings} is not affected by @b{*print-array*}.
Only the @i{active} @i{elements} of the @i{string} are printed.

For information on how the @i{Lisp reader} parses @i{strings},
see @ref{Double-Quote}.

@node Printing Lists and Conses, Printing Bit Vectors, Printing Strings, Default Print-Object Methods
@subsubsection Printing Lists and Conses

Wherever possible, list notation is preferred over dot notation.  
Therefore the following algorithm is used to print a @i{cons} x:

@table @asis

@item 1.  
A @i{left-parenthesis} is printed.

@item 2.  
The @i{car} of x is printed. 

@item 3.  
If the @i{cdr} of x is itself a @i{cons},
          it is made to be the current @i{cons} 
	  (@i{i.e.}, x becomes that @i{cons}), 

	  a @i{space}

	  is printed,
          and step 2 is re-entered.

@item 4.  
If the @i{cdr} of x is not @i{null}, 

	  a @i{space},

          a @i{dot},

	  a @i{space},

          and the @i{cdr} of x are printed.

@item 5.  
A @i{right-parenthesis} is printed.
@end table

Actually, the above algorithm is only used when @b{*print-pretty*}
is @i{false}.  When @b{*print-pretty*} is @i{true} (or 
when @b{pprint} is used),
additional @i{whitespace}_1 
may replace the use of a single @i{space},
and a more elaborate algorithm with similar goals but more presentational 
flexibility is used; see @ref{Printer Dispatching}.

Although the two expressions below are equivalent,
and the reader accepts
either one and 
produces
the same @i{cons}, the printer
always prints such a @i{cons} in the second form.

@example
 (a . (b . ((c . (d . nil)) . (e . nil))))
 (a b (c d) e)
@end example

The printing of @i{conses} is affected by @b{*print-level*},
@b{*print-length*}, and @b{*print-circle*}.

Following are examples of printed representations of @i{lists}:

@example
 (a . b)     ;A dotted pair of a and b
 (a.b)       ;A list of one element, the symbol named a.b
 (a. b)      ;A list of two elements a. and b
 (a .b)      ;A list of two elements a and .b
 (a b . c)   ;A dotted list of a and b with c at the end; two conses
 .iot        ;The symbol whose name is .iot
 (. b)       ;Invalid -- an error is signaled if an attempt is made to read 
             ;this syntax.
 (a .)       ;Invalid -- an error is signaled.
 (a .. b)    ;Invalid -- an error is signaled.
 (a . . b)   ;Invalid -- an error is signaled.
 (a b c ...) ;Invalid -- an error is signaled.
 (a \. b)    ;A list of three elements a, ., and b
 (a |.| b)   ;A list of three elements a, ., and b
 (a \... b)  ;A list of three elements a, ..., and b
 (a |...| b) ;A list of three elements a, ..., and b
@end example

For information on how the @i{Lisp reader} parses @i{lists} and @i{conses},
see @ref{Left-Parenthesis}. 

@node Printing Bit Vectors, Printing Other Vectors, Printing Lists and Conses, Default Print-Object Methods
@subsubsection Printing Bit Vectors

A @i{bit vector} is printed as @t{#*} followed by the bits of the @i{bit vector}
in order.  If @b{*print-array*} is @i{false}, then the @i{bit vector} is
printed in a format (using @t{#<}) that is concise but not readable.
Only the @i{active} @i{elements} of the @i{bit vector} are printed.

[Reviewer Note by Barrett: Need to provide for @t{#5*0} as an alternate 
  	  notation for @t{#*00000}.]

For information on @i{Lisp reader} parsing of @i{bit vectors},
see @ref{Sharpsign Asterisk}.

@node Printing Other Vectors, Printing Other Arrays, Printing Bit Vectors, Default Print-Object Methods
@subsubsection Printing Other Vectors

If @b{*print-array*} is @i{true} 
and @b{*print-readably*} is @i{false},
any

@i{vector} 
other than a @i{string} or @i{bit vector} is printed using
general-vector syntax; this means that information
about specialized vector representations does not appear.
The printed representation of a zero-length @i{vector} is @t{#()}.
The printed representation of a non-zero-length @i{vector} begins with @t{#(}.
Following that, the first element of the @i{vector} is printed.  

If there are any other elements, they are printed in turn, with 
each such additional element preceded by
a @i{space} if @b{*print-pretty*} is @i{false},
or @i{whitespace}_1 if @b{*print-pretty*} is @i{true}.

A @i{right-parenthesis} after the last element
terminates the printed representation of the @i{vector}. 
The printing of @i{vectors} 
is affected by @b{*print-level*} and @b{*print-length*}.
If the @i{vector} has a @i{fill pointer}, 
then only those elements below
the @i{fill pointer} are printed.

If both @b{*print-array*} and @b{*print-readably*} are @i{false},

the @i{vector} is not printed as described above,
but in a format (using @t{#<}) that is concise but not readable.

If @b{*print-readably*} is @i{true},
the @i{vector} prints in an @i{implementation-defined} manner;
see the @i{variable} @b{*print-readably*}.

For information on how the @i{Lisp reader} parses these ``other @i{vectors},''
see @ref{Sharpsign Left-Parenthesis}.

@node Printing Other Arrays, Examples of Printing Arrays, Printing Other Vectors, Default Print-Object Methods
@subsubsection Printing Other Arrays

If  @b{*print-array*} is @i{true} 
and @b{*print-readably*} is @i{false},
any

@i{array} other than a @i{vector} is printed
using @t{#}@t{n}@t{A} format.
Let @t{n} be the @i{rank} of the @i{array}.
Then @t{#} is printed, then @t{n} as a decimal integer,
then @t{A}, then @t{n} open parentheses.  
Next the @i{elements} are scanned in row-major order,
using @b{write} on each @i{element}, 
and separating @i{elements} from each other with @i{whitespace}_1.
The array's dimensions are numbered 0 to @t{n}-1 from left to right,
and are enumerated with the rightmost index changing fastest.
Every time the index for dimension @t{j} is incremented,
the following actions are taken:

@table @asis

@item @t{*}  
If @t{j} < @t{n}-1, then a close parenthesis is printed.

@item @t{*}  
If incrementing the index for dimension @t{j} caused it to equal
dimension @t{j}, that index is reset to zero and the
index for dimension @t{j}-1 is incremented (thereby performing these three steps recursively),
unless @t{j}=0, in which case the entire algorithm is terminated.
If incrementing the index for dimension @t{j} did not cause it to
equal dimension @t{j}, then a space is printed.

@item @t{*}  
If @t{j} < @t{n}-1, then an open parenthesis is printed.
@end table

This causes the contents to be printed in a format suitable for
@t{:initial-contents} to @b{make-array}.
The lists effectively printed by this procedure are subject to
truncation by @b{*print-level*} and @b{*print-length*}.

If the @i{array} 
is of a specialized @i{type}, containing bits or characters,
then the innermost lists generated by the algorithm given above can instead
be printed using bit-vector or string syntax, provided that these innermost
lists would not be subject to truncation by @b{*print-length*}.  

If both @b{*print-array*} and @b{*print-readably*} are @i{false},

then the @i{array} is printed
in a format (using @t{#<}) that is concise but not readable.

If @b{*print-readably*} is @i{true},
the @i{array} prints in an @i{implementation-defined} manner; 
see the @i{variable} @b{*print-readably*}.

In particular,
this may be important for arrays having some dimension @t{0}.

For information on how the @i{Lisp reader} parses these ``other @i{arrays},''
see @ref{Sharpsign A}.

@node Examples of Printing Arrays, Printing Random States, Printing Other Arrays, Default Print-Object Methods
@subsubsection Examples of Printing Arrays

@example
 (let ((a (make-array '(3 3)))
       (*print-pretty* t)
       (*print-array* t))
   (dotimes (i 3) (dotimes (j 3) (setf (aref a i j) (format nil "<~D,~D>" i j))))
   (print a)
   (print (make-array 9 :displaced-to a)))
@t{ |> } #2A(("<0,0>" "<0,1>" "<0,2>") 
@t{ |> }     ("<1,0>" "<1,1>" "<1,2>") 
@t{ |> }     ("<2,0>" "<2,1>" "<2,2>")) 
@t{ |> } #("<0,0>" "<0,1>" "<0,2>" "<1,0>" "<1,1>" "<1,2>" "<2,0>" "<2,1>" "<2,2>") 
@result{}  #<ARRAY 9 indirect 36363476>
@end example

@node Printing Random States, Printing Pathnames, Examples of Printing Arrays, Default Print-Object Methods
@subsubsection Printing Random States

A specific syntax for printing @i{objects} of @i{type} @b{random-state} is
not specified. However, every @i{implementation}
must arrange to print a @i{random state} @i{object} in such a way that,
within the same implementation, @b{read}
can construct from the printed representation a copy of the 
@i{random state}
object as if the copy had been made by @b{make-random-state}.

If the type @i{random state} is effectively implemented 
by using the machinery for @b{defstruct},
the usual structure syntax can then be used for printing 
@i{random state}
objects; one might look something like

@example
 #S(RANDOM-STATE :DATA #(14 49 98436589 786345 8734658324 ... ))
@end example

where the components are @i{implementation-dependent}.

@node Printing Pathnames, Printing Structures, Printing Random States, Default Print-Object Methods
@subsubsection Printing Pathnames

When @i{printer escaping} is enabled,

the syntax @t{#P"..."} is how a
@i{pathname} is printed by @b{write} and the other functions herein described.
The @t{"..."} is the namestring representation of the pathname.

When @i{printer escaping} is disabled,

@b{write} writes a @i{pathname} @i{P}
by writing @t{(namestring @i{P})} instead.

For information on how the @i{Lisp reader} parses @i{pathnames},
see @ref{Sharpsign P}.

@node Printing Structures, Printing Other Objects, Printing Pathnames, Default Print-Object Methods
@subsubsection Printing Structures

By default, a @i{structure} of type S is printed using @t{#S} syntax.
This behavior can be customized by specifying a @t{:print-function} 
or @t{:print-object} option to the @b{defstruct} @i{form} that defines S,
or by writing a @b{print-object} @i{method} 
that is @i{specialized} for @i{objects} of type S.

Different structures might print out in different ways;
the default notation for structures is:

@example
 #S(@i{structure-name} @{@i{slot-key} @i{slot-value}@}{*})
@end example

where @t{#S} indicates structure syntax,
@i{structure-name} is a @i{structure name},
each @i{slot-key} is an initialization argument @i{name}
for a @i{slot} in the @i{structure},
and each corresponding @i{slot-value} is a representation
of the @i{object} in that @i{slot}.

For information on how the @i{Lisp reader} parses @i{structures},
see @ref{Sharpsign S}.

@node Printing Other Objects,  , Printing Structures, Default Print-Object Methods
@subsubsection Printing Other Objects

Other @i{objects} are printed in an @i{implementation-dependent} manner.
It is not required that an @i{implementation} print those @i{objects}
@i{readably}.

For example, @i{hash tables}, 
	     @i{readtables},
             @i{packages},
             @i{streams},
         and @i{functions}
might not print @i{readably}.

A common notation to use in this circumstance is @t{#<...>}.
Since @t{#<} is not readable by the @i{Lisp reader},
the precise format of the text which follows is not important,
but a common format to use is that provided by the @b{print-unreadable-object} @i{macro}.

For information on how the @i{Lisp reader} treats this notation,
see @ref{Sharpsign Less-Than-Sign}.
For information on how to notate @i{objects} that cannot be printed @i{readably},
see @ref{Sharpsign Dot}.

@node Examples of Printer Behavior,  , Default Print-Object Methods, The Lisp Printer
@subsection Examples of Printer Behavior

@example
 (let ((*print-escape* t)) (fresh-line) (write #\a))
@t{ |> } #\a
@result{}  #\a
 (let ((*print-escape* nil) (*print-readably* nil))
   (fresh-line)
   (write #\a))
@t{ |> } a
@result{}  #\a
 (progn (fresh-line) (prin1 #\a))
@t{ |> } #\a
@result{}  #\a
 (progn (fresh-line) (print #\a))
@t{ |> } 
@t{ |> } #\a
@result{}  #\a
 (progn (fresh-line) (princ #\a))
@t{ |> } a
@result{}  #\a

 (dolist (val '(t nil))
   (let ((*print-escape* val) (*print-readably* val))
     (print '#\a) 
     (prin1 #\a) (write-char #\Space)
     (princ #\a) (write-char #\Space)
     (write #\a)))
@t{ |> } #\a #\a a #\a
@t{ |> } #\a #\a a a
@result{}  NIL

 (progn (fresh-line) (write '(let ((a 1) (b 2)) (+ a b))))
@t{ |> } (LET ((A 1) (B 2)) (+ A B))
@result{}  (LET ((A 1) (B 2)) (+ A B))

 (progn (fresh-line) (pprint '(let ((a 1) (b 2)) (+ a b))))
@t{ |> } (LET ((A 1)
@t{ |> }       (B 2))               
@t{ |> }   (+ A B))
@result{}  (LET ((A 1) (B 2)) (+ A B))

 (progn (fresh-line) 
        (write '(let ((a 1) (b 2)) (+ a b)) :pretty t))
@t{ |> } (LET ((A 1)
@t{ |> }       (B 2))
@t{ |> }   (+ A B))                 
@result{}  (LET ((A 1) (B 2)) (+ A B))

 (with-output-to-string (s)  
    (write 'write :stream s)
    (prin1 'prin1 s))
@result{}  "WRITEPRIN1"
@end example

@c end of including concept-print

@node The Lisp Pretty Printer, Formatted Output, The Lisp Printer, Printer
@section The Lisp Pretty Printer

@c including concept-pprint

@menu
* Pretty Printer Concepts::	
* Examples of using the Pretty Printer::  
* Notes about the Pretty Printer's Background::	 
@end menu

@node Pretty Printer Concepts, Examples of using the Pretty Printer, The Lisp Pretty Printer, The Lisp Pretty Printer
@subsection Pretty Printer Concepts

The facilities provided by the @i{pretty printer}
@IGindex{pretty printer}
 permit
@i{programs} to redefine the way in which @i{code} is displayed, 
and allow the full power of @i{pretty printing} to be applied 
to complex combinations of data structures.

Whether any given style of output is in fact ``pretty'' is inherently a
somewhat subjective issue.  However, since the effect of the 
@i{pretty printer} can be customized by @i{conforming programs},
the necessary flexibility is provided for individual @i{programs}
to achieve an arbitrary degree of aesthetic control.

By providing direct access to the mechanisms within the pretty printer
that make dynamic decisions about layout, the macros and functions
@b{pprint-logical-block}, @b{pprint-newline}, and
@b{pprint-indent} make it possible to specify pretty printing
layout rules as a part of any function that produces output.  They also
make it very easy for the detection of circularity and sharing, and
abbreviation based on length and nesting depth to be supported by the
function.

The @i{pretty printer} is driven entirely by dispatch based on
the @i{value} of @b{*print-pprint-dispatch*}.
The @i{function} @b{set-pprint-dispatch} makes it possible
for @i{conforming programs} to associate new pretty printing 
functions with a @i{type}.

@menu
* Dynamic Control of the Arrangement of Output::  
* Format Directive Interface::	
* Compiling Format Strings::	
* Pretty Print Dispatch Tables::  
* Pretty Printer Margins::	
@end menu

@node Dynamic Control of the Arrangement of Output, Format Directive Interface, Pretty Printer Concepts, Pretty Printer Concepts
@subsubsection Dynamic Control of the Arrangement of Output

The actions of the @i{pretty printer} when a piece of output is too
large to fit in the space available can be precisely controlled.
Three concepts underlie 
the way these operations work---@i{logical blocks}
@IGindex{logical blocks}
,
			        @i{conditional newlines}
@IGindex{conditional newlines}
,
			    and @i{sections}
@IGindex{sections}
.
Before proceeding further, it is important to define these terms.

The first line of Figure 22--3 shows a schematic piece of output.  Each of
the characters in the output is represented by ``@t{-}''.  The positions of
conditional newlines are indicated by digits.  The beginnings and ends of
logical blocks are indicated by ``@t{<}'' and ``@t{>}'' respectively.

The output as a whole is a logical block and the outermost section.  This
section is indicated by the @t{0}'s on the second line of Figure 1.  Logical
blocks nested within the output are specified by the macro
@b{pprint-logical-block}.  Conditional newline positions are specified 
by calls to @b{pprint-newline}.  Each conditional newline defines 
two sections (one before it and one after it) and is associated with a 
third (the section immediately containing it).

The section after a conditional newline consists of: all the output up to,
but not including, (a) the next conditional newline immediately contained
in the same logical block; or if (a) is not applicable, (b) the next
newline that is at a lesser level of nesting in logical blocks; or if (b)
is not applicable, (c) the end of the output.

The section before a conditional newline consists of: all the output back
to, but not including, (a) the previous conditional newline that is
immediately contained in the same logical block; or if (a) is not
applicable, (b) the beginning of the immediately containing logical block.
The last four lines in Figure 1 indicate the sections before and after the
four conditional newlines.

The section immediately containing a conditional newline is the shortest
section that contains the conditional newline in question.  In Figure 22--3,
the first conditional newline is immediately contained in the section
marked with @t{0}'s, the second and third conditional newlines are immediately
contained in the section before the fourth conditional newline, and the
fourth conditional newline is immediately contained in the section after
the first conditional newline.

@example
 <-1---<--<--2---3->--4-->->
 000000000000000000000000000
 11 111111111111111111111111
           22 222
              333 3333
        44444444444444 44444
@end example

@w{  Figure 22--2: Example of Logical Blocks, Conditional Newlines, and Sections}

Whenever possible, the pretty printer displays the entire contents of a
section on a single line.  However, if the section is too long to fit in
the space available, line breaks are inserted at conditional newline
positions within the section.

@node Format Directive Interface, Compiling Format Strings, Dynamic Control of the Arrangement of Output, Pretty Printer Concepts
@subsubsection Format Directive Interface

The primary interface to operations for dynamically determining the
arrangement of output is provided through the functions and macros of the
pretty printer.  Figure 22--3 shows the defined names related to @i{pretty printing}.

@group
@noindent
@w{  *print-lines*            pprint-dispatch                pprint-pop           }
@w{  *print-miser-width*      pprint-exit-if-list-exhausted  pprint-tab           }
@w{  *print-pprint-dispatch*  pprint-fill                    pprint-tabular       }
@w{  *print-right-margin*     pprint-indent                  set-pprint-dispatch  }
@w{  copy-pprint-dispatch     pprint-linear                  write                }
@w{  format                   pprint-logical-block                                }
@w{  formatter                pprint-newline                                      }

@noindent
@w{             Figure 22--3: Defined names related to pretty printing.           }

@end group

Figure 22--4 identifies a set of @i{format directives} which serve
as an alternate interface to the same pretty printing operations in a 
more textually compact form.

@group
@noindent
@w{  @t{~I}   @t{~W}      @t{~<...~:>}  }
@w{  @t{~:T}  @t{~/.../}  @t{~_}        }

@noindent
@w{  Figure 22--4: Format directives related to Pretty Printing}

@end group

@node Compiling Format Strings, Pretty Print Dispatch Tables, Format Directive Interface, Pretty Printer Concepts
@subsubsection Compiling Format Strings

A @i{format string} is essentially a program in a special-purpose language
that performs printing, and that is interpreted by the @i{function} @b{format}.
The @b{formatter} @i{macro} provides the efficiency of using a @i{compiled function} 
to do that same printing but without losing the textual compactness of @i{format strings}.

A @i{format control}
@IGindex{format control}
 is either a @i{format string} or a @i{function}
that was returned by the the @b{formatter} @i{macro}.

@node Pretty Print Dispatch Tables, Pretty Printer Margins, Compiling Format Strings, Pretty Printer Concepts
@subsubsection Pretty Print Dispatch Tables

A @i{pprint dispatch table}
@IGindex{pprint dispatch table}
 is a mapping from keys to pairs of values.  
Each key is a @i{type specifier}.  
The values associated with a key are
     a ``function'' (specifically, a @i{function designator} or @b{nil})
 and a ``numerical priority'' (specifically, a @i{real}).
Basic insertion and retrieval is done based on the keys with the equality
of keys being tested by @b{equal}.

When @b{*print-pretty*} is @i{true}, 
the @i{current pprint dispatch table}
@IGindex{current pprint dispatch table}
 (in @b{*print-pprint-dispatch*})
controls how @i{objects} are printed.
The information in this table takes precedence over
all other mechanisms for specifying how to print @i{objects}.
In particular, it 
has priority over
user-defined @b{print-object} @i{methods} 

because the @i{current pprint dispatch table} is consulted first.

The function is chosen from the @i{current pprint dispatch table}
by finding the highest priority function 
that is associated with a @i{type specifier} that matches the @i{object};
if there is more than one such function, 
it is @i{implementation-dependent} which is used.

However, if there is no 
information in the table
about how to @i{pretty print} a particular kind of @i{object}, 
a @i{function} is invoked which uses @b{print-object} to print the @i{object}.
The value of @b{*print-pretty*} is still @i{true} 
when this function is @i{called},
and individual methods for @b{print-object} might still elect to
produce output in a special format conditional on the @i{value} of @b{*print-pretty*}.

@node Pretty Printer Margins,  , Pretty Print Dispatch Tables, Pretty Printer Concepts
@subsubsection Pretty Printer Margins

A primary goal of pretty printing is to keep the output between a pair of
margins. 
The column where the output begins is taken as the left margin.
If the current column cannot be determined at the time output begins,
the left margin is assumed to be zero.
The right margin is controlled by @b{*print-right-margin*}.

@node Examples of using the Pretty Printer, Notes about the Pretty Printer's Background, Pretty Printer Concepts, The Lisp Pretty Printer
@subsection Examples of using the Pretty Printer

As an example of the interaction of logical blocks, conditional newlines,
and indentation, consider the function @t{simple-pprint-defun} below.  This
function prints out lists whose @i{cars} are @b{defun} in the 
standard way assuming that the list has exactly length @t{4}.

@example
(defun simple-pprint-defun (*standard-output* list)
  (pprint-logical-block (*standard-output* list :prefix "(" :suffix ")")
    (write (first list))
    (write-char #\Space)
    (pprint-newline :miser)
    (pprint-indent :current 0)
    (write (second list))
    (write-char #\Space)
    (pprint-newline :fill)
    (write (third list))
    (pprint-indent :block 1)
    (write-char #\Space)
    (pprint-newline :linear)
    (write (fourth list))))
@end example

Suppose that one evaluates the following:

@example
(simple-pprint-defun *standard-output* '(defun prod (x y) (* x y)))
@end example

If the line width available is greater than or equal to @t{26}, then all of the
output appears on one line.  If the line width available is reduced to @t{25},
a line break is inserted at the 
linear-style conditional newline
@ITindex{linear-style conditional newline}

before the
@i{expression} @t{(* x y)}, producing the output shown.  The
@t{(pprint-indent :block 1)} causes @t{(* x y)} to be printed at a relative
indentation of @t{1} in the logical block.

@example
 (DEFUN PROD (X Y) 
   (* X Y))
@end example

If the line width available is @t{15}, a line break is also inserted at the
fill style conditional newline before the argument list.  The call on
@t{(pprint-indent :current 0)} causes the argument list to line up under the
function name.

@example
(DEFUN PROD
       (X Y)
  (* X Y))
@end example

If @b{*print-miser-width*} were greater than or equal to 14, the example 
output above would have been as follows, because all indentation changes 
are ignored in miser mode and line breaks are inserted at 
miser-style conditional newlines.
@ITindex{miser-style conditional newline}

@example
 (DEFUN
  PROD
  (X Y)
  (* X Y))
@end example

As an example of a per-line prefix, consider that evaluating the following
produces the output shown with a line width of @t{20} and
@b{*print-miser-width*} of @b{nil}.

@example
 (pprint-logical-block (*standard-output* nil :per-line-prefix ";;; ")
   (simple-pprint-defun *standard-output* '(defun prod (x y) (* x y))))

 ;;; (DEFUN PROD
 ;;;        (X Y)
 ;;;   (* X Y))
@end example

As a more complex (and realistic) example, consider the function @t{pprint-let}
below.  This specifies how to print a @b{let} @i{form} in the traditional
style.  It is more complex than the example above, because it has to deal with
nested structure.  Also, unlike the example above it contains complete code to 
readably print any possible list that begins with the @i{symbol} @b{let}.
The outermost @b{pprint-logical-block} @i{form} handles the printing of
the input list as a whole and specifies that parentheses should be printed in the
output.  The second @b{pprint-logical-block} @i{form} handles the list 
of binding pairs.  Each pair in the list is itself printed by the innermost
@b{pprint-logical-block}.  (A @b{loop} @i{form} is used instead of
merely decomposing the pair into two @i{objects} so that readable output will
be produced no matter whether the list corresponding to the pair has one element,
two elements, or (being malformed) has more than two elements.)   
A space and a 
fill-style conditional newline
@ITindex{fill-style conditional newline}

are placed after
each pair except the last.  The loop at the end of the topmost
@b{pprint-logical-block} @i{form} prints out the forms in the body
of the @b{let} @i{form} separated by spaces and 
linear-style conditional newlines.

@example
 (defun pprint-let (*standard-output* list)
   (pprint-logical-block (nil list :prefix "(" :suffix ")")
     (write (pprint-pop))
     (pprint-exit-if-list-exhausted)
     (write-char #\Space)
     (pprint-logical-block (nil (pprint-pop) :prefix "(" :suffix ")")
       (pprint-exit-if-list-exhausted)
       (loop (pprint-logical-block (nil (pprint-pop) :prefix "(" :suffix ")")
               (pprint-exit-if-list-exhausted)
               (loop (write (pprint-pop))
                     (pprint-exit-if-list-exhausted)
                     (write-char #\Space)
                     (pprint-newline :linear)))
             (pprint-exit-if-list-exhausted)
             (write-char #\Space)
             (pprint-newline :fill)))
     (pprint-indent :block 1)
     (loop (pprint-exit-if-list-exhausted)
           (write-char #\Space)
           (pprint-newline :linear)
           (write (pprint-pop)))))
@end example

Suppose that one evaluates the following with @b{*print-level*} being 4, 
and @b{*print-circle*} being @i{true}.

@example
 (pprint-let *standard-output*
             '#1=(let (x (*print-length* (f (g 3))) 
                       (z . 2) (k (car y)))
                   (setq x (sqrt z)) #1#))
@end example

If the line length is greater than or equal to @t{77}, the output produced
appears on one line.  However, if the line length is @t{76}, line breaks are
inserted at the linear-style conditional newlines separating the forms in
the body and the output below is produced.  Note that, the degenerate
binding pair @t{x} is printed readably even though it fails to be a list; a
depth abbreviation marker is printed in place of @t{(g 3)}; the binding pair
@t{(z . 2)} is printed readably even though it is not a proper list; and
appropriate circularity markers are printed.

@example
 #1=(LET (X (*PRINT-LENGTH* (F #)) (Z . 2) (K (CAR Y))) 
      (SETQ X (SQRT Z))
      #1#)
@end example

If the line length is reduced to @t{35}, a line break is inserted at one of the
fill-style conditional newlines separating the binding pairs.

@example
 #1=(LET (X (*PRINT-PRETTY* (F #))
          (Z . 2) (K (CAR Y)))
      (SETQ X (SQRT Z))
      #1#)
@end example

Suppose that the line length is further reduced to @t{22} and @b{*print-length*} is
set to @t{3}. In this situation, line breaks are inserted after both the first
and second binding pairs.  In addition, the second binding pair is itself
broken across two lines.  Clause (b) of the description of fill-style
conditional newlines (see the @i{function} @b{pprint-newline}) 
prevents the binding pair @t{(z . 2)} from being printed
at the end of the third line.  Note that the length abbreviation hides the
circularity from view and therefore the printing of circularity markers
disappears.

@example
 (LET (X
       (*PRINT-LENGTH*
        (F #))
       (Z . 2) ...)
   (SETQ X (SQRT Z))
   ...)
@end example

The next function prints a vector using ``@t{#(...)}'' notation.

@example
(defun pprint-vector (*standard-output* v)
  (pprint-logical-block (nil nil :prefix "#(" :suffix ")")
    (let ((end (length v)) (i 0))
      (when (plusp end)
        (loop (pprint-pop)
              (write (aref v i))
              (if (= (incf i) end) (return nil))
              (write-char #\Space)
              (pprint-newline :fill))))))
@end example

Evaluating the following with a line length of 15 produces the output shown.

@example
 (pprint-vector *standard-output* '#(12 34 567 8 9012 34 567 89 0 1 23))

 #(12 34 567 8 
   9012 34 567 
   89 0 1 23)
@end example

As examples of the convenience of specifying pretty printing with 
@i{format strings}, consider that the functions @t{simple-pprint-defun}
and @t{pprint-let} used as examples above can be compactly defined as follows.
(The function @t{pprint-vector} cannot be defined using @b{format}
because the data structure it traverses is not a list.)

@example
(defun simple-pprint-defun (*standard-output* list)
  (format T "~:<~W ~@@_~:I~W ~:_~W~1I ~_~W~:>" list))

(defun pprint-let (*standard-output* list)
  (format T "~:<~W~{@t{^}}~:<~@@@{~:<~@@@{~W~{@t{^}}~_~@}~:>~{@t{^}}~:_~@}~:>~1I~@@@{~{@t{^}}~_~W~@}~:>" list)) 
@end example

In the following example, the first @i{form} restores
@b{*print-pprint-dispatch*} to the equivalent of its initial value.
The next two forms then set up a special way to pretty print ratios.
Note that the more specific @i{type specifier} has to be associated
with a higher priority.

@example
 (setq *print-pprint-dispatch* (copy-pprint-dispatch nil))

 (set-pprint-dispatch 'ratio
   #'(lambda (s obj)
       (format s "#.(/ ~W ~W)" 
                 (numerator obj) (denominator obj))))

 (set-pprint-dispatch '(and ratio (satisfies minusp))
   #'(lambda (s obj)
       (format s "#.(- (/ ~W ~W))" 
               (- (numerator obj)) (denominator obj)))
   5)

 (pprint '(1/3 -2/3))
 (#.(/ 1 3) #.(- (/ 2 3)))
@end example

The following two @i{forms} illustrate the definition of 
pretty printing functions for types of @i{code}.  The first
@i{form} illustrates how to specify the traditional method 
for printing quoted objects using @i{single-quote}.  Note
the care taken to ensure that data lists that happen to begin
with @b{quote} will be printed readably.  The second form 
specifies that lists beginning with the symbol @t{my-let}
should print the same way that lists beginning with @b{let}
print when the initial @i{pprint dispatch table} is in effect.

@example
 (set-pprint-dispatch '(cons (member quote)) () 
   #'(lambda (s list)
       (if (and (consp (cdr list)) (null (cddr list)))
          (funcall (formatter "'~W") s (cadr list))
          (pprint-fill s list))))

 (set-pprint-dispatch '(cons (member my-let)) 
                      (pprint-dispatch '(let) nil))
@end example

The next example specifies a default method for printing lists that do not
correspond to function calls.  Note that the functions @b{pprint-linear},
@b{pprint-fill}, and @b{pprint-tabular} are all defined with
optional @i{colon-p} and @i{at-sign-p} arguments so that they can 
be used as @b{pprint dispatch functions} as well as @t{~/.../} 
functions.

@example
 (set-pprint-dispatch '(cons (not (and symbol (satisfies fboundp))))
                      #'pprint-fill -5)

 ;; Assume a line length of 9
 (pprint '(0 b c d e f g h i j k))
 (0 b c d
  e f g h
  i j k)
@end example

This final example shows how to define a pretty printing function for a
user defined data structure.

@example
 (defstruct family mom kids)

 (set-pprint-dispatch 'family
   #'(lambda (s f)
       (funcall (formatter "~@@<#<~;~W and ~2I~_~/pprint-fill/~;>~:>")
               s (family-mom f) (family-kids f))))
@end example

The pretty printing function for the structure @t{family} specifies how to
adjust the layout of the output so that it can fit aesthetically into
a variety of line widths.  In addition, it obeys 
the printer control variables @b{*print-level*},
@b{*print-length*}, @b{*print-lines*},
@b{*print-circle*}
and @b{*print-escape*},
and can tolerate several different kinds of malformity in the data structure.
The output below shows what is printed out with a right margin of @t{25},
@b{*print-pretty*} being @i{true}, @b{*print-escape*} being @i{false},
and a malformed @t{kids} list.

@example
 (write (list 'principal-family
              (make-family :mom "Lucy"
                           :kids '("Mark" "Bob" . "Dan")))
        :right-margin 25 :pretty T :escape nil :miser-width nil)
 (PRINCIPAL-FAMILY
  #<Lucy and
      Mark Bob . Dan>)
@end example

Note that a pretty printing function for a structure is different from
the structure's @b{print-object} @i{method}.
While
@b{print-object} @i{methods}
are permanently associated with a structure,
pretty printing functions are stored in 
@i{pprint dispatch tables} and can be rapidly changed to reflect 
different printing needs.  If there is no pretty printing function for 
a structure in the current @i{pprint dispatch table},
its @b{print-object} @i{method}
is used instead.

@node Notes about the Pretty Printer's Background,  , Examples of using the Pretty Printer, The Lisp Pretty Printer
@subsection Notes about the Pretty Printer's Background

For a background reference to the abstract concepts detailed in this
section, see @i{XP: A Common Lisp Pretty Printing System}.  The details of that paper are not binding on
this document, but may be helpful in establishing a conceptual basis for
understanding this material.

@c end of including concept-pprint

@node Formatted Output, Printer Dictionary, The Lisp Pretty Printer, Printer
@section Formatted Output

@c including concept-format

[Editorial Note by KMP: This is transplanted from FORMAT and will need a bit of work before
 it looks good standing alone. Bear with me.]

@b{format} is useful for producing nicely formatted text, producing
good-looking messages, and so on.  @b{format} can generate and return
a @i{string} or output to @i{destination}.

The @i{control-string} argument to @b{format} is actually a @i{format control}.
That is, it can be either a @i{format string} or a @i{function},
for example a @i{function} returned
by the @b{formatter} @i{macro}.

If it is a @i{function}, the @i{function} is called with the appropriate
output stream as its first argument and the data arguments to @b{format}
as its remaining arguments.  The function should perform whatever output is 
necessary and return the unused tail of the arguments (if any).

The compilation process performed by @b{formatter} produces a @i{function}
that would do with its @i{arguments} as the @b{format} interpreter
would do with those @i{arguments}.

The remainder of this section describes what happens if the @i{control-string}
is a @i{format string}.  

@i{Control-string} is composed of simple text (@i{characters}) 
and embedded directives.

@b{format} writes the simple text as is;
each embedded directive specifies further text output 
that is to appear at the corresponding point within the simple text.  
Most directives use one or more elements of @i{args} to
create their output.

A directive consists of a @i{tilde},
optional prefix parameters
separated by commas, optional @i{colon} and @i{at-sign} modifiers,
and a single character indicating what kind of directive this is.

There is no required ordering between the @i{at-sign} and @i{colon} modifier.

The @i{case} of the directive character is ignored.
Prefix parameters are notated as signed (sign is optional) decimal numbers,
or as a @i{single-quote} followed by a character.
For example, @t{~5,'0d} can be used
to print an @i{integer} 
in decimal radix in five columns with leading zeros,
or @t{~5,'*d} to get leading asterisks.

In place of a prefix parameter to a directive, @t{V} (or @t{v}) can be used. 
In this case, @b{format} takes an argument from @i{args} as a parameter to
the directive.  The argument should be an @i{integer} or @i{character}.
If the @i{arg} used by a @t{V} parameter is @b{nil},
the effect is as if the parameter had been omitted.
@t{#} can be used in place of a prefix parameter; it
represents the number of @i{args} remaining to be processed.
When used within a recursive format, in the context of @t{~?} or @t{~@{},
the @t{#} prefix parameter represents the number of @i{format arguments}
remaining within the recursive call.

Examples of @i{format strings}:

@group
@noindent
@w{  @t{"~S"}        ;This is an S directive with no parameters or modifiers.  }
@w{  @t{"~3,-4:@@s"}  ;This is an S directive with two parameters, @t{3} and @t{-4},    }
@w{              ; and both the @i{colon} and @i{at-sign} flags.                   }
@w{  @t{"~,+4S"}     ;Here the first prefix parameter is omitted and takes     }
@w{              ; on its default value, while the second parameter is @t{4}.  }

@noindent
@w{             Figure 22--5: Examples of format control strings           }

@end group

@b{format} sends the output to @i{destination}.
If @i{destination} is @b{nil},
@b{format} creates and returns a @i{string} 
containing the output from @i{control-string}.
If @i{destination} is @i{non-nil}, 
it must be a @i{string} with a @i{fill pointer}, 
a @i{stream}, or the symbol @b{t}.
If @i{destination} is a @i{string} with a @i{fill pointer}, 
the output is added to the end of the @i{string}. 
If @i{destination} is a @i{stream}, 
the output is sent to that @i{stream}. 
If @i{destination} is @b{t},
the output is sent to @i{standard output}.

In the description of the directives that follows,
the term @i{arg} in general
refers to the next item of the set of @i{args} to be processed.
The word or phrase at the beginning of each description is a mnemonic
for the directive.

@b{format} directives do not bind any of the printer control
variables (@b{*print-...*}) except as specified in the following
descriptions.
   Implementations may specify the binding of new, implementation-specific 
printer control variables for each @b{format} directive, but they
    may neither bind any standard printer control variables not
    specified in description of a @b{format} 
directive nor fail to bind
    any standard printer control variables as specified in the
    description.

@menu
* FORMAT Basic Output::		
* FORMAT Radix Control::	
* FORMAT Floating-Point Printers::  
* FORMAT Printer Operations::	
* FORMAT Pretty Printer Operations::  
* FORMAT Layout Control::	
* FORMAT Control-Flow Operations::  
* FORMAT Miscellaneous Operations::  
* FORMAT Miscellaneous Pseudo-Operations::  
* Additional Information about FORMAT Operations::  
* Examples of FORMAT::		
* Notes about FORMAT::		
@end menu

@node FORMAT Basic Output, FORMAT Radix Control, Formatted Output, Formatted Output
@subsection FORMAT Basic Output

@menu
* Tilde C-> Character::		
* Tilde Percent-> Newline::	
* Tilde Ampersand-> Fresh-Line::  
* Tilde Vertical-Bar-> Page::	
* Tilde Tilde-> Tilde::		
@end menu

@node Tilde C-> Character, Tilde Percent-> Newline, FORMAT Basic Output, FORMAT Basic Output
@subsubsection Tilde C: Character

The next @i{arg} should be a @i{character}; 
it is printed
according to the modifier flags.

@t{~C} prints the @i{character} 
as if by using @b{write-char} if it is a @i{simple character}.
@i{Characters} that are not @i{simple}
are not necessarily printed as if by @b{write-char},
but are displayed in an @i{implementation-defined}, abbreviated format.
For example,

@example
 (format nil "~C" #\A) @result{}  "A"
 (format nil "~C" #\Space) @result{}  " "
@end example

@t{~:C} is the same as @t{~C} for @i{printing} @i{characters},
but other @i{characters} are ``spelled out.''  The intent is that this
is a ``pretty'' format for printing characters.
For @i{simple} @i{characters} that are not @i{printing},
what is spelled out is the @i{name} of the @i{character} (see @b{char-name}).
For @i{characters} that are not @i{simple} and not @i{printing},
what is spelled out is @i{implementation-defined}.
For example, 

@example
 (format nil "~:C" #\A) @result{}  "A"
 (format nil "~:C" #\Space) @result{}  "Space"
;; This next example assumes an implementation-defined "Control" attribute.
 (format nil "~:C" #\Control-Space)
@result{}  "Control-Space"
@i{OR}@result{} "c-Space"
@end example

@t{~:@@C} prints what @t{~:C} would, and then
if the @i{character} requires unusual shift keys on the keyboard to type it,
this fact is mentioned.  For example,

@example
 (format nil "~:@@C" #\Control-Partial) @result{}  "Control-{\partial} (Top-F)"  
@end example

This is the format used for telling the user about a key he is expected to type,
in prompts, for instance.  The precise output may depend not only
on the implementation, but on the particular I/O devices in use.

@t{~@@C} 
prints the @i{character} in a way that the @i{Lisp reader} can understand,
using @t{#\} syntax.

@t{~@@C}  binds @b{*print-escape*} to @b{t}.

@node Tilde Percent-> Newline, Tilde Ampersand-> Fresh-Line, Tilde C-> Character, FORMAT Basic Output
@subsubsection Tilde Percent: Newline

This outputs a @t{#\Newline} character, thereby terminating the current
output line and beginning a new one.
@t{~@i{n}%} outputs @i{n} newlines.
No @i{arg} is used.  

@node Tilde Ampersand-> Fresh-Line, Tilde Vertical-Bar-> Page, Tilde Percent-> Newline, FORMAT Basic Output
@subsubsection Tilde Ampersand: Fresh-Line

Unless it can be determined that the output stream
is already at the beginning of a line,
this outputs a newline.
@t{~@i{n}&} calls @b{fresh-line}
and then outputs @i{n}- 1 newlines.
@t{~0&} does nothing.

@node Tilde Vertical-Bar-> Page, Tilde Tilde-> Tilde, Tilde Ampersand-> Fresh-Line, FORMAT Basic Output
@subsubsection Tilde Vertical-Bar: Page

This outputs a page separator character, if possible.
@t{~@i{n}|} does this @i{n} times.

@node Tilde Tilde-> Tilde,  , Tilde Vertical-Bar-> Page, FORMAT Basic Output
@subsubsection Tilde Tilde: Tilde

This outputs a @i{tilde}.  @t{~@i{n}~} outputs @i{n} tildes.

@node FORMAT Radix Control, FORMAT Floating-Point Printers, FORMAT Basic Output, Formatted Output
@subsection FORMAT Radix Control

@menu
* Tilde R-> Radix::		
* Tilde D-> Decimal::		
* Tilde B-> Binary::		
* Tilde O-> Octal::		
* Tilde X-> Hexadecimal::	
@end menu

@node Tilde R-> Radix, Tilde D-> Decimal, FORMAT Radix Control, FORMAT Radix Control
@subsubsection Tilde R: Radix

@t{~@i{n}R} prints @i{arg} in radix @i{n}.
The modifier flags and any remaining parameters are used as for
the @t{~D} directive.
@t{~D} is the same as @t{~10R}.  
The full form is 
@t{~@i{radix},@i{mincol},@i{padchar},@i{commachar},@i{comma-interval}R}.

If no prefix parameters are given to @t{~R}, then a different
interpretation is given.  The argument should be an @i{integer}.
For example, if @i{arg} is 4:

@table @asis

@item @t{*}  
@t{~R} prints @i{arg} as a cardinal English number: @t{four}.

@item @t{*}  
@t{~:R} prints @i{arg} as an ordinal English number: @t{fourth}.

@item @t{*}  
@t{~@@R} prints @i{arg} as a Roman numeral: @t{IV}.

@item @t{*}  
@t{~:@@R} prints @i{arg} as an old Roman numeral: @t{IIII}.
@end table

For example:

@example
 (format nil "~,,' ,4:B" 13) @result{}  "1101"
 (format nil "~,,' ,4:B" 17) @result{}  "1 0001"
 (format nil "~19,0,' ,4:B" 3333) @result{}  "0000 1101 0000 0101"
 (format nil "~3,,,' ,2:R" 17) @result{}  "1 22"
 (format nil "~,,'|,2:D" #xFFFF) @result{}   "6|55|35"
@end example

If and only if the first parameter, @i{n}, is supplied,
@t{~R} binds
     @b{*print-escape*} to @i{false},
     @b{*print-radix*} to @i{false}, 
     @b{*print-base*} to @i{n},

 and @b{*print-readably*} to @i{false}.

If and only if no parameters are supplied,
@t{~R} binds @b{*print-base*} to @t{10}.

@node Tilde D-> Decimal, Tilde B-> Binary, Tilde R-> Radix, FORMAT Radix Control
@subsubsection Tilde D: Decimal

An @i{arg}, which should be an @i{integer}, 
is printed in decimal radix.
@t{~D} will never put a decimal point after the number.

@t{~@i{mincol}D} uses 
a column width of @i{mincol}; spaces are inserted on
the left if the number requires fewer than @i{mincol} columns for its digits
and sign.  If the number doesn't fit in @i{mincol} columns, additional columns
are used as needed.

@t{~@i{mincol},@i{padchar}D} uses @i{padchar} as the pad character
instead of space.

If @i{arg} is not an @i{integer}, it is printed in @t{~A} format and decimal base.

The @t{@@} modifier causes the number's sign to be printed always; the default
is to print it only if the number is negative.

The @t{:} modifier causes commas to be printed between groups of digits;
@i{commachar} may be used to change the character used as the comma.
@i{comma-interval} 
must be an @i{integer} and defaults to 3.  When the @t{:} 
modifier is given to any of
these directives, the @i{commachar} 
is printed between groups of @i{comma-interval}
digits.

Thus the most general form of @t{~D} is
@t{~@i{mincol},@i{padchar},@i{commachar},@i{comma-interval}D}.

@t{~D} binds
     @b{*print-escape*} to @i{false},
     @b{*print-radix*} to @i{false},
     @b{*print-base*} to @t{10},

 and @b{*print-readably*} to @i{false}.

@node Tilde B-> Binary, Tilde O-> Octal, Tilde D-> Decimal, FORMAT Radix Control
@subsubsection Tilde B: Binary

This is just like @t{~D} but prints in binary radix (radix 2)
instead of decimal.  The full form is therefore
@t{~@i{mincol},@i{padchar},@i{commachar},@i{comma-interval}B}.

@t{~B} binds
     @b{*print-escape*} to @i{false},
     @b{*print-radix*} to @i{false},
     @b{*print-base*} to @t{2},

 and @b{*print-readably*} to @i{false}.

@node Tilde O-> Octal, Tilde X-> Hexadecimal, Tilde B-> Binary, FORMAT Radix Control
@subsubsection Tilde O: Octal

This is just like @t{~D} but prints in octal radix (radix 8)
instead of decimal.  The full form is therefore
@t{~@i{mincol},@i{padchar},@i{commachar},@i{comma-interval}O}.

@t{~O} binds
     @b{*print-escape*} to @i{false},
     @b{*print-radix*} to @i{false},
     @b{*print-base*} to @t{8},

 and @b{*print-readably*} to @i{false}.

@node Tilde X-> Hexadecimal,  , Tilde O-> Octal, FORMAT Radix Control
@subsubsection Tilde X: Hexadecimal

This is just like @t{~D} but prints in hexadecimal radix
(radix 16) instead of decimal.  The full form is therefore
@t{~@i{mincol},@i{padchar},@i{commachar},@i{comma-interval}X}.

@t{~X} binds
     @b{*print-escape*} to @i{false},
     @b{*print-radix*} to @i{false},
     @b{*print-base*} to @t{16},

 and @b{*print-readably*} to @i{false}.

@node FORMAT Floating-Point Printers, FORMAT Printer Operations, FORMAT Radix Control, Formatted Output
@subsection FORMAT Floating-Point Printers

@menu
* Tilde F-> Fixed-Format Floating-Point::  
* Tilde E-> Exponential Floating-Point::  
* Tilde G-> General Floating-Point::  
* Tilde Dollarsign-> Monetary Floating-Point::	
@end menu

@node Tilde F-> Fixed-Format Floating-Point, Tilde E-> Exponential Floating-Point, FORMAT Floating-Point Printers, FORMAT Floating-Point Printers
@subsubsection Tilde F: Fixed-Format Floating-Point

The next @i{arg} is printed as a @i{float}.

The full form is @t{~@i{w},@i{d},@i{k},@i{overflowchar},@i{padchar}F}.
The parameter @i{w}
is the width of the field to be printed; @i{d} is the number
of digits to print after the decimal point; @i{k} is a scale factor
that defaults to zero.

Exactly @i{w} characters will
be output.  First, leading copies of the character @i{padchar}
(which defaults to a space) are printed, if necessary, to pad the
field on the left.
If the @i{arg} is negative, then a minus sign is printed;
if the @i{arg} is not negative, then a plus sign is printed
if and only if the @t{@@}
modifier was supplied.  Then a sequence
of digits, containing a single embedded decimal point, is printed;
this represents the magnitude of the value of @i{arg} times 10^@i{k},
rounded to @i{d} fractional digits.                         
When rounding up and rounding down would produce printed values
equidistant from the scaled value of @i{arg}, then the implementation
is free to use either one.  For example, printing the argument
@t{6.375} using the format @t{~4,2F} may correctly produce
either @t{6.37} or @t{6.38}.
Leading zeros are not permitted, except that a single
zero digit is output before the decimal point if the printed value
is less than one, and this single zero digit is not output
at all if @i{w}=@i{d}+1.

If it is impossible to print the value in the required format in a field
of width @i{w}, then one of two actions is taken.  If the
parameter @i{overflowchar} is supplied, then @i{w} copies of that
parameter are printed instead of the scaled value of @i{arg}.
If the @i{overflowchar} parameter is omitted, then the scaled value
is printed using more than @i{w} characters, as many more as may be
needed.

If the @i{w} parameter is omitted, then the field is of variable width.
In effect, a value is chosen
for @i{w} in such a way that no leading pad characters need to be printed
and exactly @i{d} characters will follow the decimal point.
For example, the directive @t{~,2F} will print exactly
two digits after the decimal point and as many as necessary before the
decimal point.

If the parameter @i{d} is omitted, then there is no constraint
on the number of digits to appear after the decimal point.
A value is chosen for @i{d} in such a way that as many digits
as possible may be printed subject to the width constraint
imposed by the parameter @i{w} and the constraint that no trailing
zero digits may appear in the fraction, except that if the
fraction to be printed is zero, then a single zero digit should
appear after the decimal point if permitted by the width constraint.

If both @i{w} and @i{d} are omitted, then the effect is to print
the value using ordinary free-format output; @b{prin1} uses this format
for any number whose magnitude is either zero or between
10^{-3} (inclusive) and 10^7 (exclusive).

If @i{w} is omitted, then if the magnitude of @i{arg} is so large (or, if
@i{d} is also omitted, so small) that more than 100 digits would have to
be printed, then an implementation is free, at its discretion, to print
the number using exponential notation instead, as if by the directive
@t{~E} (with all parameters to @t{~E} defaulted, not
taking their values from the @t{~F} directive).

If @i{arg} is a @i{rational} 
number, then it is coerced to be a @i{single float}
and then printed.  Alternatively, an implementation is permitted to
process a @i{rational} 
number by any other method that has essentially the
same behavior but avoids loss of precision or overflow
because of the coercion.  If @i{w} and @i{d} are
not supplied and the number has no exact decimal representation,
for example @t{1/3}, some precision cutoff must be chosen
by the implementation since only a finite number of digits may be printed.

If @i{arg} is a @i{complex} number or some non-numeric
@i{object}, 
then it is printed using the format directive @t{~@i{w}D},
thereby printing it in decimal radix and a minimum field width of @i{w}.

@t{~F} binds
    @b{*print-escape*} to @i{false}

 and @b{*print-readably*} to @i{false}.

@node Tilde E-> Exponential Floating-Point, Tilde G-> General Floating-Point, Tilde F-> Fixed-Format Floating-Point, FORMAT Floating-Point Printers
@subsubsection Tilde E: Exponential Floating-Point

The next @i{arg} is printed as a @i{float} in exponential notation.

The full form is
@t{~@i{w},@i{d},@i{e},@i{k},@i{overflowchar},@i{padchar},@i{exponentchar}E}.
The parameter @i{w}
is the width of the field to be printed; @i{d} is the number
of digits to print after the decimal point; @i{e} is the number
of digits to use when printing the exponent;
@i{k} is a scale factor that defaults to one (not zero).

Exactly @i{w} characters will
be output.  First, leading copies of the character @i{padchar}
(which defaults to a space) are printed, if necessary, to pad the
field on the left.
If the @i{arg} is negative, then a minus sign is printed;
if the @i{arg} is not negative, then a plus sign is printed
if and only if the @t{@@}
modifier was supplied.  Then a sequence
of digits containing a single embedded decimal point is printed.
The form of this sequence of digits depends on the scale factor @i{k}.
If @i{k} is zero, then @i{d} digits are printed after the decimal
point, and a single zero digit appears before the decimal point if
the total field width will permit it.  If @i{k} is positive,
then it must be strictly less than @i{d}+2;  @i{k} significant digits
are printed before the decimal point, and @i{d}- @i{k}+1
digits are printed after the decimal point.  If @i{k} is negative,
then it must be strictly greater than - @i{d};
a single zero digit appears before the decimal point if
the total field width will permit it, and after the decimal point
are printed first
- @i{k} zeros and then @i{d}+@i{k} significant digits.
The printed fraction must be properly rounded.         
When rounding up and rounding down would produce printed values
equidistant from the scaled value of @i{arg}, then the implementation
is free to use either one.  For example, printing the argument
@t{637.5} using the format @t{~8,2E} may correctly produce
either @t{6.37E+2} or @t{6.38E+2}.

Following the digit sequence, the exponent is printed.
First the character parameter @i{exponentchar} is printed; if this
parameter is omitted, then the @i{exponent marker} that
@b{prin1} would use is printed, as determined from the
type of the @i{float} and the current value of
@b{*read-default-float-format*}.
Next, either a plus sign or a minus sign
is printed, followed by @i{e} digits representing the power of
ten by which the printed fraction must be multiplied
to properly represent the rounded value of @i{arg}.

If it is impossible to print the value in the required format in a field
of width @i{w}, possibly because @i{k} is too large or too small
or because the exponent cannot be printed in @i{e} character positions,
then one of two actions is taken.  If the
parameter @i{overflowchar} is supplied, then @i{w} copies of that
parameter are printed instead of the scaled value of @i{arg}.
If the @i{overflowchar} parameter is omitted, then the scaled value
is printed using more than @i{w} characters, as many more as may be
needed; if the problem is that @i{d} is too small for the supplied @i{k}
or that @i{e} is too small, then a larger value is used for @i{d} or @i{e}
as may be needed.

If the @i{w} parameter is omitted, then the field is of variable width.
In effect a value is chosen
for @i{w} in such a way that no leading pad characters need to be printed.

If the parameter @i{d} is omitted, then there is no constraint
on the number of digits to appear.
A value is chosen for @i{d} in such a way that as many digits
as possible may be printed subject to the width constraint
imposed by the parameter @i{w}, the constraint of the scale factor @i{k},
and the constraint that no trailing
zero digits may appear in the fraction, except that if the
fraction to be printed is zero then a single zero digit should
appear after the decimal point.

If the parameter @i{e} is omitted, then the exponent is printed
using the smallest number of digits necessary to represent its value.

If all of @i{w}, @i{d}, and @i{e} are omitted, then the effect is to print
the value using ordinary free-format exponential-notation output;
@b{prin1} uses 

a similar

format for any non-zero number whose magnitude
is less than 10^{-3} or greater than or equal to 10^7.

The only difference is that the @t{~E} 
directive always prints a plus or minus sign in front of the
    exponent, while @b{prin1} omits the plus sign if the exponent is
    non-negative.

If @i{arg} is a @i{rational} 
number, then it is coerced to be a @i{single float}
and then printed.  Alternatively, an implementation is permitted to
process a @i{rational} 
number by any other method that has essentially the
same behavior but avoids loss of precision or overflow
because of the coercion.  If @i{w} and @i{d} are
unsupplied and the number has no exact decimal representation,
for example @t{1/3}, some precision cutoff must be chosen
by the implementation since only a finite number of digits may be printed.

If @i{arg} is a @i{complex} number or some non-numeric
@i{object}, 
then it is printed using the format directive @t{~@i{w}D},
thereby printing it in decimal radix and a minimum field width of @i{w}.

@t{~E} binds
     @b{*print-escape*} to @i{false}

 and @b{*print-readably*} to @i{false}.

@node Tilde G-> General Floating-Point, Tilde Dollarsign-> Monetary Floating-Point, Tilde E-> Exponential Floating-Point, FORMAT Floating-Point Printers
@subsubsection Tilde G: General Floating-Point

The next @i{arg} is printed as a @i{float} 
in either fixed-format or exponential notation as appropriate.

The full form is @t{~@i{w},@i{d},@i{e},@i{k},@i{overflowchar},@i{padchar},@i{exponentchar}G}.
The format in which to print @i{arg} depends on the magnitude (absolute
value) of the @i{arg}.  Let @i{n} be an integer such that
10^{{n}-1} \le |@i{arg}| < 10^@i{n}.
Let @i{ee} equal @i{e}+2, or 4 if @i{e} is omitted.
Let @i{ww} equal @i{w}- @i{ee},
or @b{nil} if @i{w} is omitted.  If @i{d} is omitted, first let @i{q}
be the number of digits needed to print @i{arg} with no loss
of information and without leading or trailing zeros;
then let @i{d} equal @t{(max @i{q} (min @i{n} 7))}.
Let @i{dd} equal @i{d}- @i{n}.

If 0 \le @i{dd} \le @i{d}, then @i{arg} is printed
as if by the format directives

@t{~@i{ww},@i{dd},,@i{overflowchar},@i{padchar}F~@i{ee}@@T}

Note that the scale factor @i{k} is not passed to the @t{~F}
directive.  For all other values of @i{dd}, @i{arg} is printed as if
by the format directive

@t{~@i{w},@i{d},@i{e},@i{k},@i{overflowchar},@i{padchar},@i{exponentchar}E}

In either case, an @t{@@}
modifier is supplied to the @t{~F}
or @t{~E} directive if and only if one was supplied to the
@t{~G} directive.

@t{~G} binds
     @b{*print-escape*} to @i{false}

 and @b{*print-readably*} to @i{false}.

@node Tilde Dollarsign-> Monetary Floating-Point,  , Tilde G-> General Floating-Point, FORMAT Floating-Point Printers
@subsubsection Tilde Dollarsign: Monetary Floating-Point

The next @i{arg} is printed as a @i{float} in fixed-format notation.  

The full form is @t{~@i{d},@i{n},@i{w},@i{padchar}$}.
The parameter @i{d} is the number
of digits to print after the decimal point (default value 2);
@i{n} is the minimum number of digits to print before the decimal
point (default value 1);
@i{w} is the minimum total width of the field to be printed (default
value 0).

First padding and the sign are output.
If the @i{arg} is negative, then a minus sign is printed;
if the @i{arg} is not negative, then a plus sign is printed
if and only if the @t{@@} modifier was supplied.  
If the @t{:} modifier is used, the sign appears before any padding,
and otherwise after the padding.
If @i{w} is supplied and the number of other characters to be output
is less than @i{w}, then copies of @i{padchar} (which defaults
to a space) are output to
make the total field width equal @i{w}.
Then @i{n} digits are printed for the integer part of @i{arg},
with leading zeros if necessary; then a decimal point;
then @i{d} digits of fraction, properly rounded.

If the magnitude of @i{arg} is so large that more than @i{m} digits would
have to be printed, where @i{m} is the larger of @i{w} and 100, then an
implementation is free, at its discretion, to print the number using
exponential notation instead, as if by the directive
@t{~@i{w},@i{q},,,,@i{padchar}E}, where @i{w} and @i{padchar} are
present or omitted according to whether they were present or omitted in
the @t{~$} directive, and where @i{q}=@i{d}+@i{n}- 1,
where @i{d} and @i{n} are the (possibly default) values given to the
@t{~$} directive.

If @i{arg} is a @i{rational} 
number, then it is coerced to be a @i{single float}
and then printed.  Alternatively, an implementation is permitted to
process a @i{rational} number by any 
other method that has essentially the
same behavior but avoids loss of precision or overflow
because of the coercion.

If @i{arg} is a @i{complex} number or some non-numeric
@i{object},
then it is printed using the format directive @t{~@i{w}D},
thereby printing it in decimal radix and a minimum field width of @i{w}.

@t{~$} binds @b{*print-escape*} to @i{false}

 and @b{*print-readably*} to @i{false}.

@node FORMAT Printer Operations, FORMAT Pretty Printer Operations, FORMAT Floating-Point Printers, Formatted Output
@subsection FORMAT Printer Operations

@menu
* Tilde A-> Aesthetic::		
* Tilde S-> Standard::		
* Tilde W-> Write::		
@end menu

@node Tilde A-> Aesthetic, Tilde S-> Standard, FORMAT Printer Operations, FORMAT Printer Operations
@subsubsection Tilde A: Aesthetic

An @i{arg}, any @i{object}, 
is printed without escape characters
(as by @b{princ}).  If @i{arg} is a @i{string}, 
its @i{characters}
will be output verbatim.
If @i{arg} is @b{nil} it will be printed as @b{nil};
the @i{colon} modifier (@t{~:A}) will cause an @i{arg} of @b{nil} to be printed as @t{()},
but if @i{arg} is a composite structure, such as a @i{list} or @i{vector},
any contained occurrences of @b{nil} will still be printed as @b{nil}.

@t{~@i{mincol}A} inserts spaces on the right, if necessary, to make the
width at least @i{mincol} columns.  The @t{@@}
modifier causes the spaces
to be inserted on the left rather than the right.

@t{~@i{mincol},@i{colinc},@i{minpad},@i{padchar}A} 
is the full form of @t{~A},
which allows control of the padding.
The @i{string} is padded on the right (or on the left if the
@t{@@} modifier is used) with at least @i{minpad} copies
of @i{padchar}; padding characters are then inserted @i{colinc} characters
at a time until the total width is at least @i{mincol}.
The defaults are @t{0} for @i{mincol} and @i{minpad}, @t{1} for @i{colinc},
and the space character for @i{padchar}.

@t{~A} binds @b{*print-escape*} to @i{false},

and @b{*print-readably*} to @i{false}.

@node Tilde S-> Standard, Tilde W-> Write, Tilde A-> Aesthetic, FORMAT Printer Operations
@subsubsection Tilde S: Standard

This is just like @t{~A}, but @i{arg} is printed with escape
characters (as by @b{prin1} rather than @t{princ}).  The output is
therefore suitable for input to @b{read}.  @t{~S} accepts
all the arguments and modifiers that @t{~A} does.

@t{~S} binds @b{*print-escape*} to @b{t}.

@node Tilde W-> Write,  , Tilde S-> Standard, FORMAT Printer Operations
@subsubsection Tilde W: Write

An argument, any @i{object}, is printed obeying every printer control
variable (as by @b{write}).  In addition, @t{~W} interacts correctly with depth
abbreviation, by not resetting the depth counter to zero.  @t{~W} does not
accept parameters.  If given the @i{colon} modifier, @t{~W} binds @b{*print-pretty*}
to @i{true}.  If given the @i{at-sign} modifier, @t{~W} binds @b{*print-level*}
and @b{*print-length*} to @b{nil}.

@t{~W} provides automatic support for the detection of circularity and
sharing.  If the @i{value} of @b{*print-circle*} is not @b{nil} and @t{~W} is applied
to an argument that is a circular (or shared) reference, an appropriate 
@t{#@i{n}#} marker is inserted in the output instead of printing the argument.

@node FORMAT Pretty Printer Operations, FORMAT Layout Control, FORMAT Printer Operations, Formatted Output
@subsection FORMAT Pretty Printer Operations

The following constructs provide access to the @i{pretty printer}:

@menu
* Tilde Underscore-> Conditional Newline::  
* Tilde Less-Than-Sign-> Logical Block::  
* Tilde I-> Indent::		
* Tilde Slash-> Call Function::	 
@end menu

@node Tilde Underscore-> Conditional Newline, Tilde Less-Than-Sign-> Logical Block, FORMAT Pretty Printer Operations, FORMAT Pretty Printer Operations
@subsubsection Tilde Underscore: Conditional Newline

Without any modifiers, @t{~_} is the same as @t{(pprint-newline :linear)}.
@t{~@@_}  is the same as @t{(pprint-newline :miser)}.
@t{~:_}  is the same as @t{(pprint-newline :fill)}.
@t{~:@@_} is the same as @t{(pprint-newline :mandatory)}.

@node Tilde Less-Than-Sign-> Logical Block, Tilde I-> Indent, Tilde Underscore-> Conditional Newline, FORMAT Pretty Printer Operations
@subsubsection Tilde Less-Than-Sign: Logical Block

@t{~<...~:>}

If @t{~:>} is used to terminate a @t{~<...~>},
the directive is equivalent to a call to @b{pprint-logical-block}.
The argument corresponding to the @t{~<...~:>} directive is treated in
the same way as the @i{list} argument to @b{pprint-logical-block},
thereby providing automatic support for non-@i{list} arguments and
the detection of circularity, sharing, and depth abbreviation.  
The portion of the @i{control-string} nested within the @t{~<...~:>}
specifies the @t{:prefix} (or @t{:per-line-prefix}), @t{:suffix},
and body of the @b{pprint-logical-block}.

The @i{control-string} portion enclosed by @t{~<...~:>} can be divided
into segments @t{~<@i{prefix}~;@i{body}~;@i{suffix}~:>}
by @t{~;} directives.  If the first section is terminated by @t{~@@;}, 
it specifies a per-line prefix rather than a simple prefix.  
The @i{prefix} and @i{suffix} cannot contain format directives.  
An error is signaled if either the prefix or suffix fails to be a
constant string or if the enclosed portion is divided into more than three segments.

If the enclosed portion is divided into only two segments, the @i{suffix}
defaults to the null string.  If the enclosed portion consists of only
a single segment, both the @i{prefix} and the @i{suffix} default to 
the null string.  If the @i{colon} modifier is used (@i{i.e.}, @t{~:<...~:>}),
the @i{prefix} and @i{suffix} default to @t{"("} and @t{")"}
(respectively) instead of the null string.

The body segment can be any arbitrary @i{format string}.
This @i{format string} is applied to the elements of the list
corresponding to the @t{~<...~:>} directive as a whole.
Elements are extracted from this list using @b{pprint-pop},
thereby providing automatic support for malformed lists, and the detection
of circularity, sharing, and length abbreviation.
Within the body segment, @t{~{@t{^}}} acts like @b{pprint-exit-if-list-exhausted}.

@t{~<...~:>} supports a feature not supported by @b{pprint-logical-block}.
If @t{~:@@>} is used to terminate the directive (@i{i.e.}, @t{~<...~:@@>}), 
then a fill-style conditional newline is automatically inserted after each
group of blanks immediately contained in the body (except for blanks
after a ~<@i{Newline}> directive).  This makes it easy to achieve the
equivalent of paragraph filling.

If the @i{at-sign} modifier is used with @t{~<...~:>}, the entire remaining argument
list is passed to the directive as its argument.  All of the remaining
arguments are always consumed by @t{~@@<...~:>}, even if they are not all used
by the @i{format string} nested in the directive.  Other than the difference in
its argument, @t{~@@<...~:>} is exactly the same as @t{~<...~:>} except that
circularity detection is not applied if @t{~@@<...~:>} is encountered at top
level in a @i{format string}.  This ensures that circularity detection is
applied only to data lists, not to @i{format argument} @i{lists}.

@t{" . #@i{n}#"} is printed if circularity or sharing has to be indicated
for its argument as a whole.

To a considerable extent, the basic form of the directive @t{~<...~>} is
incompatible with the dynamic control of the arrangement of output by
@t{~W}, @t{~_}, @t{~<...~:>}, @t{~I}, and @t{~:T}.  As a result, an error 
is signaled if any of these directives is nested within @t{~<...~>}.  
Beyond this, an error is also signaled if the @t{~<...~:;...~>} form of
@t{~<...~>} is used in the same @i{format string} with 
@t{~W}, @t{~_}, @t{~<...~:>}, @t{~I}, or @t{~:T}.

See also @ref{Tilde Less-Than-Sign-> Justification}.

@node Tilde I-> Indent, Tilde Slash-> Call Function, Tilde Less-Than-Sign-> Logical Block, FORMAT Pretty Printer Operations
@subsubsection Tilde I: Indent

@t{~@i{n}I}  is the same as @t{(pprint-indent :block n)}.

@t{~@i{n}:I} is the same as @t{(pprint-indent :current n)}.
In both cases, @i{n} defaults to zero, if it is omitted.

@node Tilde Slash-> Call Function,  , Tilde I-> Indent, FORMAT Pretty Printer Operations
@subsubsection Tilde Slash: Call Function

@t{~/@i{name}/}

User defined functions can be called from within a format
string by using the directive @t{~/@i{name}/}.
The @i{colon} modifier, the @i{at-sign} modifier, and arbitrarily many parameters 
can be specified with the @t{~/@i{name}/} directive.
@i{name} can be any arbitrary string that does not contain a "/".
All of the characters in @i{name} are treated as if they were upper case.
If @i{name} contains a single @i{colon} (@t{:}) or double @i{colon} (@t{::}),
then everything up to but not including the first @t{":"} or @t{"::"}
is taken to be a @i{string} that names a @i{package}.
Everything after the first @t{":"} or @t{"::"} (if any) is taken to be a 
@i{string} that names a @t{symbol}.  The function corresponding to a 
@t{~/name/} directive is obtained by looking up the @i{symbol}
that has the indicated name in the indicated @i{package}.
If @i{name} does not contain a @t{":"} or @t{"::"},
then the whole @i{name} string is looked up in the @t{COMMON-LISP-USER} @i{package}. 

When a @t{~/name/} directive is encountered,
the indicated function is called with four or more arguments.
The first four arguments are:
     the output stream,
     the @i{format argument} corresponding to the directive,
     a @i{generalized boolean} that is @i{true} if the @i{colon} modifier was used,
 and a @i{generalized boolean} that is @i{true} if the @i{at-sign} modifier was used.
The remaining arguments consist of any parameters specified with the directive.
The function should print the argument appropriately.
Any values returned by the function are ignored.

The three @i{functions} 
      @b{pprint-linear},
      @b{pprint-fill},
  and @b{pprint-tabular}
are specifically designed so that they can be called by @t{~/.../}
(@i{i.e.}, @t{~/pprint-linear/}, @t{~/pprint-fill/}, and @t{~/pprint-tabular/}).
In particular they take @i{colon} and @i{at-sign} arguments.

@node FORMAT Layout Control, FORMAT Control-Flow Operations, FORMAT Pretty Printer Operations, Formatted Output
@subsection FORMAT Layout Control

@menu
* Tilde T-> Tabulate::		
* Tilde Less-Than-Sign-> Justification::  
* Tilde Greater-Than-Sign-> End of Justification::  
@end menu

@node Tilde T-> Tabulate, Tilde Less-Than-Sign-> Justification, FORMAT Layout Control, FORMAT Layout Control
@subsubsection Tilde T: Tabulate

This spaces over to a given column.
@t{~@i{colnum},@i{colinc}T} will output
sufficient spaces to move the cursor to column @i{colnum}.  If the cursor
is already at or beyond column @i{colnum}, it will output spaces to move it to
column @i{colnum}+@i{k}*@i{colinc} for the smallest positive integer
@i{k} possible, unless @i{colinc} is zero, in which case no spaces
are output if the cursor is already at or beyond column @i{colnum}.
@i{colnum} and @i{colinc} default to @t{1}.

If for some reason the current absolute column position cannot be determined
by direct inquiry,
@b{format} 
may be able to deduce the current column position by noting         
that certain directives (such as @t{~%}, or @t{~&},
or @t{~A} 
with the argument being a string containing a newline) cause
the column position to be reset to zero, and counting the number of characters
emitted since that point.  If that fails, @b{format} 
may attempt a
similar deduction on the riskier assumption that the destination was
at column zero when @b{format} 
was invoked.  If even this heuristic fails
or is implementationally inconvenient, at worst
the @t{~T} operation will simply output two spaces.

@t{~@@T} performs relative tabulation.
@t{~@i{colrel},@i{colinc}@@T} outputs @i{colrel} spaces
and then outputs the smallest non-negative
number of additional spaces necessary to move the cursor
to a column that is a multiple                                       
of @i{colinc}.  For example, the directive 
@t{~3,8@@T} outputs
three spaces and then moves the cursor to a ``standard multiple-of-eight
tab stop'' if not at one already.
If the current output column cannot be determined, however,
then @i{colinc} is ignored, and exactly @i{colrel} spaces are output.

If the @i{colon} modifier is used with the @t{~T} directive,
the tabbing computation is done relative to the horizontal position where the
section immediately containing the directive begins, rather than with
respect to a horizontal position of zero.  The numerical parameters are
both interpreted as being in units of @i{ems} and both default to @t{1}.
@t{~@i{n},@i{m}:T} is the same as 
  @t{(pprint-tab :section @i{n} @i{m})}.
@t{~@i{n},@i{m}:@@T} is the same as
  @t{(pprint-tab :section-relative @i{n} @i{m})}.

@node Tilde Less-Than-Sign-> Justification, Tilde Greater-Than-Sign-> End of Justification, Tilde T-> Tabulate, FORMAT Layout Control
@subsubsection Tilde Less-Than-Sign: Justification

@t{~@i{mincol},@i{colinc},@i{minpad},@i{padchar}<@i{str}~>}

This justifies the text produced by processing @i{str}
within a field at least @i{mincol} columns wide.  @i{str}
may be divided up into segments with @t{~;}, in which case the
spacing is evenly divided between the text segments.

With no modifiers, the leftmost text segment is left justified in the
field, and the rightmost text segment is right justified.  If there is
only one text element, as a special case, it is right justified.
The @t{:} modifier causes                                            
spacing to be introduced before the first text segment;  the 
@t{@@} modifier causes spacing to be added after the last.
The @i{minpad} parameter (default @t{0}) is the minimum number of
padding characters to be output between each segment.
The padding character is supplied by @i{padchar},
which defaults to the space character.
If the total width needed to satisfy these constraints is greater
than @i{mincol}, then the width used is @i{mincol}+@i{k}*@i{colinc}
for the smallest possible non-negative integer value @i{k}.
@i{colinc} defaults to @t{1}, and @i{mincol} defaults to @t{0}.

Note that @i{str} may include @b{format} directives.
All the clauses in @i{str} are processed in order;
it is the resulting pieces of text that are justified.

The @t{~@t{^} } directive may be used to terminate processing of the
clauses prematurely, in which case only the completely processed clauses
are justified.

If the first clause of a @t{~<} 
is terminated with @t{~:;} instead of
@t{~;}, then it is used in a special way.  All of the clauses are
processed (subject to @t{~@t{^} }, of course), but the 
first one is not used
in performing the spacing and padding.  When the padded result has been
determined, then if it will fit on the current line of output, it is
output, and the text for the first clause is discarded.  If, however, the
padded text will not fit on the current line, then the text segment for
the first clause is output before the padded text.  The first clause
ought to contain a newline (such as a @t{~%} directive).  The first
clause is always processed, and so any arguments it refers to will be
used; the decision is whether to use the resulting segment of text, not
whether to process the first clause.  If the @t{~:;} has a prefix
parameter @i{n}, then the padded text must fit on the current line with
@i{n} character positions to spare to avoid outputting the first clause's
text.  For example, the control string

@example
 "~
@end example

can be used to print a list of items separated by commas without
breaking items over line boundaries, beginning each line with
@t{;; }.  The prefix parameter 
@t{1} in @t{~1:;} accounts for the width of the
comma that will follow the justified item if it is not the last
element in the list, or the period 
if it is.  If @t{~:;} has a second
prefix parameter, then it is used as the width of the line,
thus overriding the natural line width of the output stream.  To make
the preceding example use a line width of 50, one would write

@example
 "~
@end example

If the second argument is not supplied, then @b{format} uses the
line width of the @i{destination} output stream.
If this cannot be determined (for example, when producing a 
@i{string} result), then @b{format} uses @t{72} as the line length.

See also @ref{Tilde Less-Than-Sign-> Logical Block}.

@node Tilde Greater-Than-Sign-> End of Justification,  , Tilde Less-Than-Sign-> Justification, FORMAT Layout Control
@subsubsection Tilde Greater-Than-Sign: End of Justification

@t{~>} terminates a @t{~<}.
The consequences of using it elsewhere are undefined.

@node FORMAT Control-Flow Operations, FORMAT Miscellaneous Operations, FORMAT Layout Control, Formatted Output
@subsection FORMAT Control-Flow Operations

@menu
* Tilde Asterisk-> Go-To::	
* Tilde Left-Bracket-> Conditional Expression::	 
* Tilde Right-Bracket-> End of Conditional Expression::	 
* Tilde Left-Brace-> Iteration::  
* Tilde Right-Brace-> End of Iteration::  
* Tilde Question-Mark-> Recursive Processing::	
@end menu

@node Tilde Asterisk-> Go-To, Tilde Left-Bracket-> Conditional Expression, FORMAT Control-Flow Operations, FORMAT Control-Flow Operations
@subsubsection Tilde Asterisk: Go-To

The next @i{arg} is ignored.
@t{~@i{n}*} ignores the next @i{n} arguments.

@t{~:*} backs up in the list of
arguments so that the argument last processed will be processed again.
@t{~@i{n}:*} backs up @i{n} arguments.

When within a @t{~@{} construct
(see below), the ignoring (in either direction) is relative to the list
of arguments being processed by the iteration.

@t{~@i{n}@@*} 
goes to the @i{n}th @i{arg}, where 0 means the first one;
@i{n} defaults to 0, so @t{~@@*} goes back to the first @i{arg}.      
Directives after a @t{~@i{n}@@*}
will take arguments in sequence beginning with the one gone to.
When within a @t{~@{} construct, the ``goto''
is relative to the list of arguments being processed by the iteration.

@node Tilde Left-Bracket-> Conditional Expression, Tilde Right-Bracket-> End of Conditional Expression, Tilde Asterisk-> Go-To, FORMAT Control-Flow Operations
@subsubsection Tilde Left-Bracket: Conditional Expression

@t{~[@i{str0}~;@i{str1}~;@i{...}~;@i{strn}~]}

This is a set of control strings, called @i{clauses}, one of which is
chosen and used.  The clauses are separated by @t{~;}
and the construct is terminated by @t{~]}.  For example,

@t{"~[Siamese~;Manx~;Persian~] Cat"}

The @i{arg}th
clause is selected, where the first clause is number 0.
If a prefix parameter is given (as @t{~@i{n}[}),
then the parameter is used instead of an argument.    
If @i{arg} is out of range then no clause is selected
and no error is signaled.
After the selected alternative has been processed, the control string
continues after the @t{~]}.

@t{~[@i{str0}~;@i{str1}~;@i{...}~;@i{strn}~:;@i{default}~]}
has a default case.
If the @i{last} @t{~;} used to separate clauses
is @t{~:;} instead, then the last clause is an else clause
that is performed if no other clause is selected.
For example:

@t{"~[Siamese~;Manx~;Persian~:;Alley~] Cat"}

@t{~:[@i{alternative}~;@i{consequent}~]} 
selects the @i{alternative} control string if @i{arg} is @i{false},
and selects the @i{consequent} control string otherwise.

@t{~@@[@i{consequent}~]} 
tests the argument.  If it is @i{true},           
then the argument is not used up by the @t{~[} command
but remains as the next one to be processed,
and the one clause @i{consequent} is processed.
If the @i{arg} is @i{false}, then the argument is used up,
and the clause is not processed.
The clause therefore should normally use exactly one argument,
and may expect it to be @i{non-nil}.
For example:

@example
 (setq *print-level* nil *print-length* 5)
 (format nil
        "~@@[ print level = ~D~]~@@[ print length = ~D~]"
        *print-level* *print-length*)
@result{}   " print length = 5"
@end example

Note also that

@example
 (format @i{stream} "...~@@[@i{str}~]..." ...)
@equiv{} (format @i{stream} "...~:[~;~:*@i{str}~]..." ...)
@end example

The combination of @t{~[} and @t{#} is useful, for
example, for dealing with English conventions for printing lists:

@example
 (setq foo "Items:~#[ none~; ~S~; ~S and ~S~
           ~:;~@@@{~#[~; and~] ~S~@t{^} ,~@}~].")
 (format nil foo) @result{}   "Items: none."
 (format nil foo 'foo) @result{}   "Items: FOO."
 (format nil foo 'foo 'bar) @result{}   "Items: FOO and BAR."
 (format nil foo 'foo 'bar 'baz) @result{}   "Items: FOO, BAR, and BAZ."
 (format nil foo 'foo 'bar 'baz 'quux) @result{}   "Items: FOO, BAR, BAZ, and QUUX."
@end example

@node Tilde Right-Bracket-> End of Conditional Expression, Tilde Left-Brace-> Iteration, Tilde Left-Bracket-> Conditional Expression, FORMAT Control-Flow Operations
@subsubsection Tilde Right-Bracket: End of Conditional Expression

@t{~]} terminates a @t{~[}.
The consequences of using it elsewhere are undefined.

@node Tilde Left-Brace-> Iteration, Tilde Right-Brace-> End of Iteration, Tilde Right-Bracket-> End of Conditional Expression, FORMAT Control-Flow Operations
@subsubsection Tilde Left-Brace: Iteration

@t{~@{{@i{str}}~@}}

This is an iteration construct.  The argument should be a @i{list},
which is used as a set of arguments 
as if for a recursive call to @b{format}.
The @i{string} @i{str} is used repeatedly as the control string.
Each iteration can absorb as many elements of the @i{list} as it likes
as arguments;
if @i{str} uses up two arguments by itself, then two elements of the
@i{list} will get used up each time around the loop.
If before any iteration step the @i{list} 
is empty, then the iteration is terminated.
Also, if a prefix parameter @i{n} is given, then there will be at most @i{n}
repetitions of processing of @i{str}.  
Finally, the @t{~@t{^} } directive can be
used to terminate the iteration prematurely.

For example:

@example
 (format nil "The winners are:~@{ ~S~@}." 
         '(fred harry jill)) 
@result{}  "The winners are: FRED HARRY JILL."                           
 (format nil "Pairs:~@{ <~S,~S>~@}." 
         '(a 1 b 2 c 3))
@result{}  "Pairs: <A,1> <B,2> <C,3>."
@end example

@t{~:@{ @i{str}~@}  } is similar, 
but the argument should be a @i{list} of sublists.
At each repetition step, one sublist 
is used as the set of arguments for
processing @i{str}; on the next repetition, a new sublist 
is used, whether
or not all of the last sublist had been processed.  
For example:

@example
 (format nil "Pairs:~:@{ <~S,~S>~@} ." 
                 '((a 1) (b 2) (c 3)))
@result{}  "Pairs: <A,1> <B,2> <C,3>."
@end example

@t{~@@@{ @i{str}~@} }
is similar to @t{~@{ @i{str}~@}  }, but instead of
using one argument that is a list, all the remaining arguments
are used as the list of arguments for the iteration.
Example:

@example
 (format nil "Pairs:~@@@{ <~S,~S>~@} ." 'a 1 'b 2 'c 3)
@result{}  "Pairs: <A,1> <B,2> <C,3>."
@end example

If the iteration is terminated before all the remaining arguments are
consumed, then any arguments not processed by the iteration remain to be
processed by any directives following the iteration construct.

@t{~:@@@{ @i{str}~@}  } 
combines the features                              
of @t{~:@{ @i{str}~@}  }
and @t{~@@@{ @i{str}~@}  }.
All the remaining arguments
are used, and each one must be a @i{list}.
On each iteration, the next argument is 
used as a @i{list} of arguments to @i{str}.
Example:

@example
 (format nil "Pairs:~:@@@{ <~S,~S>~@} ." 
              '(a 1) '(b 2) '(c 3)) 
@result{}  "Pairs: <A,1> <B,2> <C,3>."
@end example

Terminating the repetition construct with @t{~:@} } 
instead of @t{~@}  }
forces @i{str} to be processed at least once, even if the initial
list of arguments is null. However, this will not override an explicit
prefix parameter of zero.

If @i{str} is empty, then an argument is used as @i{str}.  
It must be a @i{format control}
and precede any arguments processed by the iteration.  As an example,
the following are equivalent:

@example
    (apply #'format stream string arguments)
 @equiv{} (format stream "~1@{~:@}" string arguments)
@end example

This will use @t{string} as a formatting string.  
The @t{~1@{ } says it will                 
be processed at most once, and the @t{~:@} } 
says it will be processed at least once.
Therefore it is processed exactly once, using @t{arguments} as the arguments.
This case may be handled more clearly by the @t{~?} directive,
but this general feature of @t{~@{  }
is more powerful than @t{~?}.

@node Tilde Right-Brace-> End of Iteration, Tilde Question-Mark-> Recursive Processing, Tilde Left-Brace-> Iteration, FORMAT Control-Flow Operations
@subsubsection Tilde Right-Brace: End of Iteration

@t{~@}} terminates a @t{~@{}.
The consequences of using it elsewhere are undefined.

@node Tilde Question-Mark-> Recursive Processing,  , Tilde Right-Brace-> End of Iteration, FORMAT Control-Flow Operations
@subsubsection Tilde Question-Mark: Recursive Processing

The next @i{arg} must be a @i{format control}, and the one after it a @i{list};
both are consumed by the @t{~?} directive.
The two are processed as a @i{control-string}, with the elements of the @i{list} 
as the arguments.  Once the recursive processing
has been finished, the processing of the control
string containing the @t{~?} directive is resumed.
Example:

@example
 (format nil "~? ~D" "<~A ~D>" '("Foo" 5) 7) @result{}  "<Foo 5> 7"
 (format nil "~? ~D" "<~A ~D>" '("Foo" 5 14) 7) @result{}  "<Foo 5> 7"
@end example

Note that in the second example three arguments are supplied
to the @i{format string} @t{"<~A ~D>"}, but only two are processed
and the third is therefore ignored.

With the @t{@@}
modifier, only one @i{arg} is directly consumed.
The @i{arg} must be a @i{string}; 
it is processed as part of the control
string as if it had appeared in place of the @t{~@@?} construct,
and any directives in the recursively processed control string may      
consume arguments of the control string containing the @t{~@@?}
directive.
Example:

@example
 (format nil "~@@? ~D" "<~A ~D>" "Foo" 5 7) @result{}  "<Foo 5> 7"
 (format nil "~@@? ~D" "<~A ~D>" "Foo" 5 14 7) @result{}  "<Foo 5> 14"
@end example

@node FORMAT Miscellaneous Operations, FORMAT Miscellaneous Pseudo-Operations, FORMAT Control-Flow Operations, Formatted Output
@subsection FORMAT Miscellaneous Operations

@menu
* Tilde Left-Paren-> Case Conversion::	
* Tilde Right-Paren-> End of Case Conversion::	
* Tilde P-> Plural::		
@end menu

@node Tilde Left-Paren-> Case Conversion, Tilde Right-Paren-> End of Case Conversion, FORMAT Miscellaneous Operations, FORMAT Miscellaneous Operations
@subsubsection Tilde Left-Paren: Case Conversion

@t{~(@i{str}~)}

The contained control string @i{str} is processed, and what it produces
is subject to case conversion.

With no flags, every @i{uppercase} @i{character}
is converted to the corresponding @i{lowercase} @i{character}.

@t{~:(} capitalizes all words, as if by @b{string-capitalize}.

@t{~@@(} 
capitalizes just the first word and forces the rest to lower
case.

@t{~:@@(} converts every lowercase character
to the corresponding uppercase character.

In this example @t{~@@(} is used to cause the first word
produced by @t{~@@R} to be capitalized:

@example
 (format nil "~@@R ~(~@@R~)" 14 14) 
@result{}  "XIV xiv"
 (defun f (n) (format nil "~@@(~R~) error~:P detected." n)) @result{}  F
 (f 0) @result{}  "Zero errors detected."
 (f 1) @result{}  "One error detected."
 (f 23) @result{}  "Twenty-three errors detected."
@end example

When case conversions appear nested, the outer conversion dominates,
as illustrated in the following example:

@example
 (format nil "~@@(how is ~:(BOB SMITH~)?~)")
 @result{}  "How is bob smith?"
 @i{NOT}@result{} "How is Bob Smith?"
@end example

@node Tilde Right-Paren-> End of Case Conversion, Tilde P-> Plural, Tilde Left-Paren-> Case Conversion, FORMAT Miscellaneous Operations
@subsubsection Tilde Right-Paren: End of Case Conversion

@t{~)} terminates a @t{~(}.
The consequences of using it elsewhere are undefined.

@node Tilde P-> Plural,  , Tilde Right-Paren-> End of Case Conversion, FORMAT Miscellaneous Operations
@subsubsection Tilde P: Plural

If @i{arg} is not @b{eql} 
to the integer @t{1}, a lowercase @t{s} is
printed; if @i{arg} is @b{eql} to @t{1}, nothing is printed.  
If @i{arg} is a floating-point @t{1.0}, the @t{s} is
printed.

@t{~:P} does the same thing, 
after doing a @t{~:*} to back up one argument;
that is, it prints a lowercase @t{s} if the previous argument was not
@t{1}.  

@t{~@@P} 
prints @t{y} if the argument is @t{1}, or @t{ies} if it is
not.  @t{~:@@P} does the same thing, but backs up first.

@example
 (format nil "~D tr~:@@P/~D win~:P" 7 1) @result{}  "7 tries/1 win"
 (format nil "~D tr~:@@P/~D win~:P" 1 0) @result{}  "1 try/0 wins"
 (format nil "~D tr~:@@P/~D win~:P" 1 3) @result{}  "1 try/3 wins"
@end example

@node FORMAT Miscellaneous Pseudo-Operations, Additional Information about FORMAT Operations, FORMAT Miscellaneous Operations, Formatted Output
@subsection FORMAT Miscellaneous Pseudo-Operations

@menu
* Tilde Semicolon-> Clause Separator::	
* Tilde Circumflex-> Escape Upward::  
* Tilde Newline-> Ignored Newline::  
@end menu

@node Tilde Semicolon-> Clause Separator, Tilde Circumflex-> Escape Upward, FORMAT Miscellaneous Pseudo-Operations, FORMAT Miscellaneous Pseudo-Operations
@subsubsection Tilde Semicolon: Clause Separator

This separates clauses in @t{~[} and @t{~<} constructs.
The consequences of using it elsewhere are undefined.

@node Tilde Circumflex-> Escape Upward, Tilde Newline-> Ignored Newline, Tilde Semicolon-> Clause Separator, FORMAT Miscellaneous Pseudo-Operations
@subsubsection Tilde Circumflex: Escape Upward

{@t{~@t{^} }}

This is an escape construct.  If there are no more arguments remaining to
be processed, then the immediately           
enclosing @t{~@{  } or @t{~<} construct
is terminated.  If there is no such enclosing construct, then the entire
formatting operation is terminated.  
In the @t{~<} case, the formatting
is performed, but no more segments are processed before doing the
justification.     
@t{~@t{^} } may appear anywhere in a @t{~@{  }
construct.

@example
 (setq donestr "Done.~{@t{^}} ~D warning~:P.~{@t{^}} ~D error~:P.")
@result{}  "Done.~{@t{^}} ~D warning~:P.~{@t{^}} ~D error~:P."
 (format nil donestr) @result{}  "Done."
 (format nil donestr 3) @result{}  "Done. 3 warnings."
 (format nil donestr 1 5) @result{}  "Done. 1 warning. 5 errors."
@end example

If a prefix parameter is given, then termination occurs if the parameter
is zero.  (Hence @t{~{@t{^}}} is equivalent to 
@t{~#{@t{^}}}.)  If two
parameters are given, termination occurs if they are equal.

[Reviewer Note by Barmar: Which equality predicate?]  If three
parameters are given, termination occurs if the first is less than or
equal to the second and the second is less than or equal to the third.
Of course, this is useless if all the prefix parameters are constants; at
least one of them should be a @t{#} or a @t{V} parameter.

If @t{~{@t{^}}} is used within a @t{~:@{  } 
construct, then it terminates
the current iteration step because in the standard case it tests for
remaining arguments of the current step only; the next iteration step
commences immediately.  @t{~:{@t{^}}} is used to terminate
the iteration process.

@t{~:{@t{^}}} 
may be used only if the command it would terminate is 
@t{~:@{  } or @t{~:@@@{  }.
The entire iteration process is terminated if and only if the sublist that is
supplying the arguments for the current iteration step is the last sublist in
the case of @t{~:@{ }, 
or the last @b{format}        
argument in the case of @t{~:@@@{  }. 
@t{~:{@t{^}}} is not
equivalent to @t{~#:{@t{^}}}; 
the latter terminates the entire iteration if and only if no
arguments remain for the current iteration step.
For example:

@example
 (format nil "~:@{ ~@@?~:@t{^} ...~@} " '(("a") ("b"))) @result{}  "a...b"
@end example

If @t{~{@t{^}}} appears within a control string being processed
under the control of a @t{~?} directive, but not within
any @t{~@{  } or @t{~<} construct within that string,
then the string being
processed will be terminated, thereby ending processing
of the @t{~?} directive.  Processing then
continues within the string   
containing the @t{~?} directive at the point following that directive.

If @t{~{@t{^}}}                                          
appears within a @t{~[} or @t{~(} construct,
then all the commands up to the @t{~{@t{^}}} are properly selected
or case-converted,                   
the @t{~[} or @t{~(} processing is terminated,
and the outward search continues         
for a @t{~@{  } or @t{~<} construct
to be terminated.  For example:

@example
 (setq tellstr "~@@(~@@[~R~]~{@t{^}} ~A!~)")
@result{}  "~@@(~@@[~R~]~{@t{^}} ~A!~)"
 (format nil tellstr 23) @result{}  "Twenty-three!"
 (format nil tellstr nil "losers") @result{}  " Losers!"
 (format nil tellstr 23 "losers") @result{}  "Twenty-three losers!"
@end example

Following are examples of the use of @t{~{@t{^}}} 
within a @t{~<} construct.

@example
 (format nil "~15<~S~;~{@t{^}}~S~;~{@t{^}}~S~>" 'foo)
@result{}   "            FOO"
 (format nil "~15<~S~;~{@t{^}}~S~;~{@t{^}}~S~>" 'foo 'bar)
@result{}   "FOO         BAR"
 (format nil "~15<~S~;~{@t{^}}~S~;~{@t{^}}~S~>" 'foo 'bar 'baz)
@result{}   "FOO   BAR   BAZ"
@end example

@node Tilde Newline-> Ignored Newline,  , Tilde Circumflex-> Escape Upward, FORMAT Miscellaneous Pseudo-Operations
@subsubsection Tilde Newline: Ignored Newline

@i{Tilde} immediately followed by a @i{newline} ignores the @i{newline}
and any following non-newline @i{whitespace}_1 characters.
With a @t{:},
 the @i{newline} is ignored, 
 but any following @i{whitespace}_1 is left in place.
With an @t{@@},
 the @i{newline} is left in place,
 but any following @i{whitespace}_1 is ignored.
For example:

@example
 (defun type-clash-error (fn nargs argnum right-type wrong-type)
   (format *error-output*
           "~&~S requires its ~:[~:R~;~*~]~ 
           argument to be of type ~S,~
           with an argument of type ~S.~
           fn (eql nargs 1) argnum right-type wrong-type))
 (type-clash-error 'aref nil 2 'integer 'vector)  prints:
AREF requires its second argument to be of type INTEGER,
but it was called with an argument of type VECTOR.
NIL
 (type-clash-error 'car 1 1 'list 'short-float)  prints:
CAR requires its argument to be of type LIST,
but it was called with an argument of type SHORT-FLOAT.
NIL
@end example

Note that in this example newlines appear in the output only as specified
by the @t{~&} and @t{~%} directives; the 
actual newline characters
in the control string are suppressed because each is preceded by a tilde.

@node Additional Information about FORMAT Operations, Examples of FORMAT, FORMAT Miscellaneous Pseudo-Operations, Formatted Output
@subsection Additional Information about FORMAT Operations

@menu
* Nesting of FORMAT Operations::  
* Missing and Additional FORMAT Arguments::  
* Additional FORMAT Parameters::  
* Undefined FORMAT Modifier Combinations::  
@end menu

@node Nesting of FORMAT Operations, Missing and Additional FORMAT Arguments, Additional Information about FORMAT Operations, Additional Information about FORMAT Operations
@subsubsection Nesting of FORMAT Operations

The case-conversion, conditional, iteration, and justification
constructs can contain other formatting constructs by bracketing them.
These constructs must nest properly with respect to each other.
For example, it is not legitimate to put the start of a case-conversion
construct in each arm of a conditional and the
end of the case-conversion construct outside the conditional:

@example
 (format nil "~:[abc~:@@(def~;ghi~
:@@(jkl~]mno~)" x) ;Invalid!
@end example

This notation is invalid because the @t{~[...~;...~]}
and @t{~(...~)} constructs are not properly nested.

The processing indirection caused by the @t{~?} directive
is also a kind of nesting for the purposes of this rule of proper nesting.
It is not permitted to
start a bracketing construct within a string processed
under control of a @t{~?}                                      
directive and end the construct at some point after the @t{~?} construct
in the string containing that construct, or vice versa.
For example, this situation is invalid:

@example
 (format nil "~@@?ghi~)" "abc~@@(def") ;Invalid!
@end example

This notation
is invalid because the @t{~?}
and @t{~(...~)} constructs are not properly nested.

@node Missing and Additional FORMAT Arguments, Additional FORMAT Parameters, Nesting of FORMAT Operations, Additional Information about FORMAT Operations
@subsubsection Missing and Additional FORMAT Arguments

The consequences are undefined if no @i{arg} remains for a directive 
requiring an argument.  However, it is permissible for one or more @i{args} 
to remain unprocessed by a directive; such @i{args} are ignored.

@node Additional FORMAT Parameters, Undefined FORMAT Modifier Combinations, Missing and Additional FORMAT Arguments, Additional Information about FORMAT Operations
@subsubsection Additional FORMAT Parameters

The consequences are undefined if a format directive is given more parameters 
than it is described here as accepting.

@node Undefined FORMAT Modifier Combinations,  , Additional FORMAT Parameters, Additional Information about FORMAT Operations
@subsubsection Undefined FORMAT Modifier Combinations

The consequences are undefined if @i{colon} or @i{at-sign} modifiers
are given to a directive in a combination not specifically described
here as being meaningful.

@node Examples of FORMAT, Notes about FORMAT, Additional Information about FORMAT Operations, Formatted Output
@subsection Examples of FORMAT

@example
 (format nil "foo") @result{}  "foo"
 (setq x 5) @result{}  5
 (format nil "The answer is ~D." x) @result{}  "The answer is 5."
 (format nil "The answer is ~3D." x) @result{}  "The answer is   5."
 (format nil "The answer is ~3,'0D." x) @result{}  "The answer is 005."
 (format nil "The answer is ~:D." (expt 47 x))
@result{}  "The answer is 229,345,007."
 (setq y "elephant") @result{}  "elephant"
 (format nil "Look at the ~A!" y) @result{}  "Look at the elephant!"
 (setq n 3) @result{}  3
 (format nil "~D item~:P found." n) @result{}  "3 items found."
 (format nil "~R dog~:[s are~; is~] here." n (= n 1))
@result{}  "three dogs are here."
 (format nil "~R dog~:*~[s are~; is~:;s are~] here." n)
@result{}  "three dogs are here."
 (format nil "Here ~[are~;is~:;are~] ~:*~R pupp~:@@P." n)
@result{}  "Here are three puppies."
@end example

@example
 (defun foo (x)
   (format nil "~6,2F|~6,2,1,'*F|~6,2,,'?F|~6F|~,2F|~F"
           x x x x x x)) @result{}  FOO
 (foo 3.14159)  @result{}  "  3.14| 31.42|  3.14|3.1416|3.14|3.14159"
 (foo -3.14159) @result{}  " -3.14|-31.42| -3.14|-3.142|-3.14|-3.14159"
 (foo 100.0)    @result{}  "100.00|******|100.00| 100.0|100.00|100.0"
 (foo 1234.0)   @result{}  "1234.00|******|??????|1234.0|1234.00|1234.0"
 (foo 0.006)    @result{}  "  0.01|  0.06|  0.01| 0.006|0.01|0.006"
@end example

@example
 (defun foo (x)  
    (format nil
           "~9,2,1,,'*E|~10,3,2,2,'?,,'$E|~
            ~9,3,2,-2,'
           x x x x))
 (foo 3.14159)  @result{}  "  3.14E+0| 31.42$-01|+.003E+03|  3.14E+0"
 (foo -3.14159) @result{}  " -3.14E+0|-31.42$-01|-.003E+03| -3.14E+0"
 (foo 1100.0)   @result{}  "  1.10E+3| 11.00$+02|+.001E+06|  1.10E+3"
 (foo 1100.0L0) @result{}  "  1.10L+3| 11.00$+02|+.001L+06|  1.10L+3"
 (foo 1.1E13)   @result{}  "*********| 11.00$+12|+.001E+16| 1.10E+13"
 (foo 1.1L120)  @result{}  "*********|??????????|
 (foo 1.1L1200) @result{}  "*********|??????????|
@end example

As an example of the effects of varying the scale factor, the code

@example
 (dotimes (k 13)
   (format t "~
           (- k 5) (- k 5) 3.14159))
@end example

produces the following output:

@example
Scale factor -5: | 0.000003E+06|
Scale factor -4: | 0.000031E+05|
Scale factor -3: | 0.000314E+04|
Scale factor -2: | 0.003142E+03|
Scale factor -1: | 0.031416E+02|
Scale factor  0: | 0.314159E+01|
Scale factor  1: | 3.141590E+00|
Scale factor  2: | 31.41590E-01|
Scale factor  3: | 314.1590E-02|
Scale factor  4: | 3141.590E-03|
Scale factor  5: | 31415.90E-04|
Scale factor  6: | 314159.0E-05|
Scale factor  7: | 3141590.E-06|
@end example

@example
 (defun foo (x)
   (format nil "~9,2,1,,'*G|~9,3,2,3,'?,,'$G|~9,3,2,0,'
          x x x x))                                     
 (foo 0.0314159) @result{}  "  3.14E-2|314.2$-04|0.314E-01|  3.14E-2"
 (foo 0.314159)  @result{}  "  0.31   |0.314    |0.314    | 0.31    "
 (foo 3.14159)   @result{}  "   3.1   | 3.14    | 3.14    |  3.1    "
 (foo 31.4159)   @result{}  "   31.   | 31.4    | 31.4    |  31.    "
 (foo 314.159)   @result{}  "  3.14E+2| 314.    | 314.    |  3.14E+2"
 (foo 3141.59)   @result{}  "  3.14E+3|314.2$+01|0.314E+04|  3.14E+3"
 (foo 3141.59L0) @result{}  "  3.14L+3|314.2$+01|0.314L+04|  3.14L+3"
 (foo 3.14E12)   @result{}  "*********|314.0$+10|0.314E+13| 3.14E+12"
 (foo 3.14L120)  @result{}  "*********|?????????|
 (foo 3.14L1200) @result{}  "*********|?????????|
@end example

@example
 (format nil "~10<foo~;bar~>")   @result{}  "foo    bar"
 (format nil "~10:<foo~;bar~>")  @result{}  "  foo  bar"
 (format nil "~10<foobar~>")     @result{}  "    foobar"
 (format nil "~10:<foobar~>")    @result{}  "    foobar"
 (format nil "~10:@@<foo~;bar~>") @result{}  "  foo bar "
 (format nil "~10@@<foobar~>")    @result{}  "foobar    "
 (format nil "~10:@@<foobar~>")   @result{}  "  foobar  "
@end example

@example
  (FORMAT NIL "Written to ~A." #P"foo.bin")
  @result{}  "Written to foo.bin."
@end example

@node Notes about FORMAT,  , Examples of FORMAT, Formatted Output
@subsection Notes about FORMAT

Formatted output is performed not only by @b{format},
but by certain other functions that accept a @i{format control}
the way @b{format} does.  For example, error-signaling functions
such as @b{cerror} accept @i{format controls}.

Note that the meaning of @b{nil} and @b{t} as destinations to @b{format} 
are different than those of @b{nil} and @b{t} as @i{stream designators}.

The @t{~{@t{^}}} should appear only at the beginning of a @t{~<} clause,
because it aborts the entire clause in which it appears (as well as
all following clauses).                                     

@c end of including concept-format

@node Printer Dictionary,  , Formatted Output, Printer
@section Printer Dictionary

@c including dict-printer

@menu
* copy-pprint-dispatch::	
* formatter::			
* pprint-dispatch::		
* pprint-exit-if-list-exhausted::  
* pprint-fill::			
* pprint-indent::		
* pprint-logical-block::	
* pprint-newline::		
* pprint-pop::			
* pprint-tab::			
* print-object::		
* print-unreadable-object::	
* set-pprint-dispatch::		
* write::			
* write-to-string::		
* *print-array*::		
* *print-base*::		
* *print-case*::		
* *print-circle*::		
* *print-escape*::		
* *print-gensym*::		
* *print-level*::		
* *print-lines*::		
* *print-miser-width*::		
* *print-pprint-dispatch*::	
* *print-pretty*::		
* *print-readably*::		
* *print-right-margin*::	
* print-not-readable::		
* print-not-readable-object::	
* format::			
@end menu

@node copy-pprint-dispatch, formatter, Printer Dictionary, Printer Dictionary
@subsection copy-pprint-dispatch                                             [Function]

@code{copy-pprint-dispatch}  @i{{&optional} table} @result{}  @i{new-table}

@subsubheading  Arguments and Values::

@i{table}---a @i{pprint dispatch table}, or @b{nil}.

@i{new-table}---a @i{fresh} @i{pprint dispatch table}.

@subsubheading  Description::

Creates and returns a copy of the specified @i{table}, 
or of the @i{value} of @b{*print-pprint-dispatch*} if no @i{table} is specified,
or of the initial @i{value} of @b{*print-pprint-dispatch*} if @b{nil} is specified.

@subsubheading  Exceptional Situations::

Should signal an error of @i{type} @b{type-error} if @i{table} 
is not a @i{pprint dispatch table}.

@node formatter, pprint-dispatch, copy-pprint-dispatch, Printer Dictionary
@subsection formatter                                                           [Macro]

@code{formatter}  @i{control-string} @result{}  @i{function}

@subsubheading  Arguments and Values::

@i{control-string}---a @i{format string}; not evaluated.

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

@subsubheading  Description::

Returns a @i{function} which has behavior equivalent to:

@example
  #'(lambda (*standard-output* &rest arguments)
      (apply #'format t @i{control-string} arguments)
      @i{arguments-tail})
@end example

where @i{arguments-tail} is either the tail of @i{arguments} 
which has as its @i{car} the argument that would be processed next 
if there were more format directives in the @i{control-string}, 
or else @b{nil} if no more @i{arguments} follow the most recently
processed argument.

@subsubheading  Examples::

@example
(funcall (formatter "~&~A~A") *standard-output* 'a 'b 'c)
@t{ |> } AB
@result{}  (C)

(format t (formatter "~&~A~A") 'a 'b 'c)
@t{ |> } AB
@result{}  NIL
@end example

@subsubheading  Exceptional Situations::

Might signal an error (at macro expansion time or at run time) if the argument
is not a valid @i{format string}.

@subsubheading  See Also::

@ref{format}

@node pprint-dispatch, pprint-exit-if-list-exhausted, formatter, Printer Dictionary
@subsection pprint-dispatch                                                  [Function]

@code{pprint-dispatch}  @i{object {&optional} table} @result{}  @i{function, found-p}

@subsubheading  Arguments and Values::

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

@i{table}---a @i{pprint dispatch table}, or @b{nil}.
 The default is the @i{value} of @b{*print-pprint-dispatch*}.

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

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

@subsubheading  Description::

Retrieves the highest priority function in @i{table} that is
associated with a @i{type specifier} that matches @i{object}.
The function is chosen by finding all of the @i{type specifiers} in @i{table}
that match the @i{object} and 
selecting the highest priority function associated with any of these
@i{type specifiers}.  If there is more than one highest priority function,
an arbitrary choice is made.  If no @i{type specifiers} match the 
@i{object}, a function is returned that prints @i{object} 

using @b{print-object}.

The @i{secondary value}, @i{found-p}, is @i{true} if a matching
@i{type specifier} was found in @i{table}, or @i{false} otherwise.

If @i{table} is @b{nil},
retrieval is done in the
@i{initial pprint dispatch table}.

@subsubheading  Affected By::

The state of the @i{table}.

@subsubheading  Exceptional Situations::

Should signal an error of @i{type} @b{type-error} if @i{table} is neither a
@i{pprint-dispatch-table} nor @b{nil}.

@subsubheading  Notes::

@example
(let ((*print-pretty* t))
  (write object :stream s))
@equiv{} (funcall (pprint-dispatch object) s object)
@end example

@node pprint-exit-if-list-exhausted, pprint-fill, pprint-dispatch, Printer Dictionary
@subsection pprint-exit-if-list-exhausted                                 [Local Macro]

@subsubheading  Syntax::

@code{pprint-exit-if-list-exhausted}  @i{<@i{no @i{arguments}}>} @result{}  @i{@b{nil}}

@subsubheading  Description::

Tests whether or not the @i{list} passed to 
the @i{lexically current logical block}
has been exhausted; see @ref{Dynamic Control of the Arrangement of Output}.
If this @i{list} has been
reduced to @b{nil}, @b{pprint-exit-if-list-exhausted} terminates the execution
of the @i{lexically current logical block} except for the printing
of the suffix.  Otherwise @b{pprint-exit-if-list-exhausted} returns @b{nil}. 

Whether or not @b{pprint-exit-if-list-exhausted} is @i{fbound} in the
@i{global environment} is @i{implementation-dependent};
however, the restrictions on redefinition and @i{shadowing} of
@b{pprint-exit-if-list-exhausted} are the same as for @i{symbols} in the @t{COMMON-LISP} @i{package}
which are @i{fbound} in the @i{global environment}.
The consequences of attempting to use @b{pprint-exit-if-list-exhausted} outside
of @b{pprint-logical-block} are undefined.

@subsubheading  Exceptional Situations::

An error is signaled (at macro expansion time or at run time) if
@b{pprint-exit-if-list-exhausted} is used anywhere other than
lexically within a call on @b{pprint-logical-block}.  
Also, the consequences of executing @b{pprint-if-list-exhausted} outside
of the dynamic extent of the @b{pprint-logical-block} which lexically
contains it are undefined.

@subsubheading  See Also::

@ref{pprint-logical-block}
, 
@ref{pprint-pop}
.

@node pprint-fill, pprint-indent, pprint-exit-if-list-exhausted, Printer Dictionary
@subsection pprint-fill, pprint-linear, pprint-tabular                       [Function]

@code{pprint-fill}  @i{stream object {&optional} colon-p at-sign-p} @result{}  @i{@b{nil}}

@code{pprint-linear}  @i{stream object {&optional} colon-p at-sign-p} @result{}  @i{@b{nil}}

@code{pprint-tabular}  @i{stream object {&optional} colon-p at-sign-p tabsize} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

@i{stream}---an @i{output} @i{stream designator}.

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

@i{colon-p}---a @i{generalized boolean}.
  The default is @i{true}.

@i{at-sign-p}---a @i{generalized boolean}.
  The default is @i{implementation-dependent}.

@i{tabsize}---a non-negative @i{integer}.
  The default is @t{16}.

@subsubheading  Description::

The functions @b{pprint-fill}, @b{pprint-linear}, and
@b{pprint-tabular} specify particular ways of @i{pretty printing}
a @i{list} to @i{stream}. 
Each function prints parentheses around the output if and only
if @i{colon-p} is @i{true}.
Each function ignores its @i{at-sign-p} argument.
(Both arguments are included even though only one is needed
so that these functions can be used via @t{~/.../}
and as @b{set-pprint-dispatch} functions, as well as directly.)
Each function handles abbreviation and the detection of circularity
and sharing correctly, and uses @b{write} to print @i{object}
when it is a @i{non-list}.

If @i{object} is a @i{list} and 
if the @i{value} of @b{*print-pretty*} is @i{false},
each of these functions prints @i{object}
using a minimum of @i{whitespace},
as described in @ref{Printing Lists and Conses}.
Otherwise (if @i{object} is a @i{list} and 
	   if the @i{value} of @b{*print-pretty*} is @i{true}):

@table @asis

@item @t{*}  
The @i{function} @b{pprint-linear} prints a @i{list} either all on one line, 
or with each @i{element} on a separate line.  

@item @t{*}  
The @i{function} @b{pprint-fill} prints a @i{list} with as many @i{elements}
as possible on each line.

@item @t{*}  
The @i{function} @b{pprint-tabular} is the same as @b{pprint-fill}
except that it prints the @i{elements} so that they line up in columns.
The @i{tabsize} specifies the column spacing in @i{ems},
which is the total spacing from the leading edge of one column to
the leading edge of the next.
@end table

@subsubheading  Examples::

Evaluating the following with a line length of @t{25} produces the output shown.

@example
(progn (princ "Roads ") 
       (pprint-tabular *standard-output* '(elm main maple center) nil nil 8))
Roads ELM     MAIN
      MAPLE   CENTER
@end example

@subsubheading  Side Effects::

Performs output to the indicated @i{stream}.

@subsubheading  Affected By::

The cursor position on the indicated @i{stream}, if it can be determined.

@subsubheading  Notes::

The @i{function} @b{pprint-tabular} could be defined as follows:

@example
(defun pprint-tabular (s list &optional (colon-p t) at-sign-p (tabsize nil))
  (declare (ignore at-sign-p))
  (when (null tabsize) (setq tabsize 16))
  (pprint-logical-block (s list :prefix (if colon-p "(" "")
                                :suffix (if colon-p ")" ""))
    (pprint-exit-if-list-exhausted)
    (loop (write (pprint-pop) :stream s)
          (pprint-exit-if-list-exhausted)
          (write-char #\Space s)
          (pprint-tab :section-relative 0 tabsize s)
          (pprint-newline :fill s))))
@end example

Note that it would have been inconvenient to specify this function
using @b{format}, because of the need to pass its @i{tabsize} argument
through to a @t{~:T} format directive nested within an iteration over a list.

@node pprint-indent, pprint-logical-block, pprint-fill, Printer Dictionary
@subsection pprint-indent                                                    [Function]

@code{pprint-indent}  @i{relative-to n {&optional} stream} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

@i{relative-to}---either @t{:block} or @t{:current}.

@i{n}---a @i{real}.

@i{stream}---an @i{output} @i{stream designator}.
  The default is @i{standard output}.

@subsubheading  Description::

@b{pprint-indent} specifies the indentation to use in a logical block on @i{stream}.

If @i{stream} is a @i{pretty printing stream}
   and the @i{value} of @b{*print-pretty*} is @i{true},
@b{pprint-indent} sets the indentation in the innermost 
dynamically enclosing logical block;
otherwise, @b{pprint-indent} has no effect.

@i{N} specifies the indentation in
@i{ems}.  If @i{relative-to} is @t{:block}, the indentation is set
to the horizontal position of the first character in the @i{dynamically current logical block} plus @i{n} 
@i{ems}. If @i{relative-to} is @t{:current}, the indentation is set
to the current output position plus @i{n} @i{ems}. (For robustness
in the face of variable-width fonts, it is advisable to use @t{:current}
with an @i{n} of zero whenever possible.)

@i{N} can be negative;
however, the total indentation cannot be moved 
left of the beginning of the line 
or left of the end of the rightmost per-line prefix---an attempt to move beyond
one of these limits is treated
the same as an attempt to move to that limit.
Changes in indentation caused by @i{pprint-indent}
do not take effect until after the next line break.  In addition, in 
miser mode all calls to @b{pprint-indent} are ignored, forcing the lines 
corresponding to the logical block to line up under the first character in
the block.

@subsubheading  Exceptional Situations::

An error is signaled if @i{relative-to} is any @i{object} other
than @t{:block} or @t{:current}.

@subsubheading  See Also::

@ref{Tilde I-> Indent}

@node pprint-logical-block, pprint-newline, pprint-indent, Printer Dictionary
@subsection pprint-logical-block                                                [Macro]

@code{pprint-logical-block}  @i{@r{(}stream-symbol object 
					     {&key} prefix per-line-prefix suffix@r{)}
				@{@i{declaration}@}{*} @{@i{form}@}{*}}@*
   @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values:: 

@i{stream-symbol}---a @i{stream variable designator}.

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

@t{:prefix}---a @i{string}; evaluated.
	       Complicated defaulting behavior; see below.

@t{:per-line-prefix}---a @i{string}; evaluated.
		        Complicated defaulting behavior; see below.

@t{:suffix}---a @i{string}; evaluated.
	       The default is the @i{null} @i{string}.

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

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

@subsubheading  Description::

Causes printing to be grouped into a logical block.

The logical block is printed to the @i{stream} that is the @i{value}
of the @i{variable} denoted by @i{stream-symbol}.
During the execution of the @i{forms},
that @i{variable} is @i{bound} to a @i{pretty printing stream}
that supports decisions about the arrangement of output
and then forwards the output to the destination stream.

All the standard printing functions 
  (@i{e.g.}, @b{write},
       @b{princ},
   and @b{terpri})
can be used to print output to the @i{pretty printing stream}.
All and only the output sent to this @i{pretty printing stream}
is treated as being in the logical block.

The @i{prefix} specifies a prefix to be printed before the beginning of
the logical block.
The @i{per-line-prefix} specifies a prefix that is printed before the block
and at the beginning of each new line in the block.
The @t{:prefix} and @t{:pre-line-prefix} @i{arguments} are mutually exclusive.
If neither @t{:prefix} nor @t{:per-line-prefix} is specified,
a @i{prefix} of the @i{null} @i{string} is assumed.

The @i{suffix} specifies a suffix that is printed just after the logical block.

The @i{object} is 
normally 
a @i{list} that the body @i{forms} are responsible for printing.
If @i{object} is not a @i{list},
it is printed using @b{write}.
(This makes it easier to write printing functions that are robust
 in the face of malformed arguments.)
If @b{*print-circle*}
is @i{non-nil} and @i{object} is a circular (or shared) reference to a @i{cons},
then an appropriate ``@t{#@i{n}#}'' marker is printed.  (This
makes it easy to write printing functions that provide full support
for circularity and sharing abbreviation.)  If @b{*print-level*} is not
@b{nil} and the logical block is at a dynamic nesting depth of greater
than @b{*print-level*} in logical blocks, ``@t{#}'' is printed.
(This makes easy to write printing functions that provide full support for depth
abbreviation.)

If either of the three conditions above occurs, the indicated output is
printed on @i{stream-symbol} and the body @i{forms} are skipped 
along with the printing of the @t{:prefix} and @t{:suffix}.
(If the body @i{forms} are not to be responsible for printing a list,
then the first two tests above can be turned off by supplying @b{nil} for
the @i{object} argument.)

In addition to the @i{object} argument of @b{pprint-logical-block},
the arguments of the standard printing functions (such as @b{write}, 
@b{print}, @b{prin1}, and @b{pprint}, as well as the arguments
of the standard @i{format directives} such as @t{~A}, @t{~S},
(and @t{~W}) are all checked (when necessary) for circularity and sharing.
However, such checking is not applied to the arguments of the
functions @b{write-line}, @b{write-string}, and @b{write-char}
or to the literal text output by @b{format}.  A consequence of this is
that you must use one of the latter functions if you want to print some 
literal text in the output that is not supposed to be checked for circularity
or sharing.

The body @i{forms} of a @b{pprint-logical-block} @i{form}
must not perform any side-effects on the surrounding environment; for 
example, no @i{variables} must be assigned which have not been
@i{bound} within its scope.  

The @b{pprint-logical-block} @i{macro} may be used regardless of the @i{value} of @b{*print-pretty*}.

@subsubheading  Affected By::

@b{*print-circle*}, @b{*print-level*}.

@subsubheading  Exceptional Situations::

An error of @i{type} @b{type-error} is signaled if any of the @t{:suffix}, 
@t{:prefix}, or @t{:per-line-prefix} is supplied but does not evaluate 
to a @i{string}.

An error is signaled if @t{:prefix} and @t{:pre-line-prefix} are both used.

@b{pprint-logical-block} and the @i{pretty printing stream} it creates 
have @i{dynamic extent}.  The consequences are undefined if, outside
of this extent, output is attempted to the @i{pretty printing stream} it creates.

It is also unspecified what happens if, within this extent, any output is 
sent directly to the underlying destination stream.

@subsubheading  See Also::

@ref{pprint-pop}
,
@ref{pprint-exit-if-list-exhausted}
,
@ref{Tilde Less-Than-Sign-> Logical Block}

@subsubheading  Notes::

One reason for using the @b{pprint-logical-block} @i{macro} when the @i{value} of @b{*print-pretty*}
is @b{nil} would be to allow it to perform checking for @i{dotted lists}, 
as well as (in conjunction with @b{pprint-pop}) 
checking for @b{*print-level*} or @b{*print-length*} being exceeded.

Detection of circularity and sharing is supported by the @i{pretty printer}
by in essence performing requested output twice.  On the first pass,
circularities and sharing are detected and the actual outputting of characters
is suppressed.  On the second pass, the appropriate ``@t{#@i{n}=}'' 
and ``@t{#@i{n}#}'' markers are inserted and characters are output.
This is why the restriction on side-effects is necessary.
Obeying this restriction is facilitated by using @b{pprint-pop},
instead of an ordinary @b{pop} when traversing a list being printed by 
the body @i{forms} of the @b{pprint-logical-block} @i{form}.)

@node pprint-newline, pprint-pop, pprint-logical-block, Printer Dictionary
@subsection pprint-newline                                                   [Function]

@code{pprint-newline}  @i{kind {&optional} stream} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

@i{kind}---one of @t{:linear}, @t{:fill}, @t{:miser}, or @t{:mandatory}.

@i{stream}---a @i{stream designator}.
 The default is @i{standard output}.

@subsubheading  Description::

If @i{stream} is a @i{pretty printing stream}
   and the @i{value} of @b{*print-pretty*} is @i{true},
a line break is inserted in the output 
when the appropriate condition below is satisfied;
otherwise, @b{pprint-newline} has no effect.

@i{Kind} specifies the style of conditional newline.
This @i{parameter} is treated as follows:

@table @asis

@item @t{:linear}  
This specifies a
``linear-style'' @i{conditional newline}.
@ITindex{linear-style conditional newline}

A line break is inserted 
if and only if the immediately containing @i{section}
cannot be printed on one line.
The effect of this is that line breaks are
either inserted at every linear-style conditional newline in a logical block
or at none of them.

@item @t{:miser}  
This specifies a 
``miser-style'' @i{conditional newline}.
@ITindex{miser-style conditional newline}

A line break is inserted
if and only if the immediately containing @i{section}
cannot be printed on one line
and miser style is in effect in the immediately containing logical block.
The effect of this is that miser-style conditional newlines
act like linear-style conditional newlines,
but only when miser style is in effect.
Miser style is in effect for a logical block if and only if 
the starting position of the logical block
is less than or equal to
@b{*print-miser-width*} @i{ems} from the right margin.

@item @t{:fill}  
This specifies a
``fill-style'' @i{conditional newline}.
@ITindex{fill-style conditional newline}

A line break is inserted if and only if
either (a) the following @i{section} cannot be printed 
	   on the end of the current line,
       (b) the preceding @i{section} was not printed on a single line,
    or (c) the immediately containing @i{section} cannot
	   be printed on one line and miser style is in effect
	   in the immediately containing logical block.
If a logical block is broken up into a number of subsections
by fill-style conditional newlines,
the basic effect is that the logical block
is printed with as many subsections as possible on each line.
However, if miser style is in effect,
fill-style conditional newlines act like linear-style conditional newlines.

@item @t{:mandatory}  
This specifies a
``mandatory-style'' @i{conditional newline}.
@ITindex{mandatory-style conditional newline}

A line break is always inserted.
This implies that  none of the containing @i{sections}
can be printed on a single line and 
will therefore trigger the insertion of line breaks 
at linear-style conditional newlines in these @i{sections}.

@end table

When a line break is inserted by any type of conditional newline, 
any blanks that immediately precede the conditional newline are omitted 
from the output and indentation is introduced at the beginning of the next line.
By default, the indentation causes the following line to begin 
in the same horizontal position 
as the first character in the immediately containing logical block.
(The indentation can be changed via @b{pprint-indent}.)

There are a variety of ways unconditional newlines can be introduced into
the output (@i{i.e.}, via @b{terpri} or by printing a string containing a newline
character).  As with mandatory conditional newlines, this prevents any of
the containing @i{sections} from being printed on one line.  In general, when
an unconditional newline is encountered, it is printed out without
suppression of the preceding blanks and without any indentation following
it.  However, if a per-line prefix has been specified (see
@b{pprint-logical-block}), this prefix will always be printed no matter 
how a newline originates.

@subsubheading  Examples::

See @ref{Examples of using the Pretty Printer}.

@subsubheading  Side Effects::

Output to @i{stream}.

@subsubheading  Affected By::

@b{*print-pretty*}, @b{*print-miser*}.
The presence of containing logical blocks.
The placement of newlines and conditional newlines.

@subsubheading  Exceptional Situations::

An error of @i{type} @b{type-error} is signaled if @i{kind} 
is not one of @t{:linear}, @t{:fill}, @t{:miser}, or @t{:mandatory}.

@subsubheading  See Also::

@ref{Tilde Underscore-> Conditional Newline},
@ref{Examples of using the Pretty Printer}

@node pprint-pop, pprint-tab, pprint-newline, Printer Dictionary
@subsection pprint-pop                                                    [Local Macro]

@subsubheading  Syntax::

@code{pprint-pop}  @i{<@i{no @i{arguments}}>} @result{}  @i{object}

@subsubheading  Arguments and Values::

@i{object}---an @i{element} of the @i{list} 
		 being printed in the @i{lexically current logical block},
		 or @b{nil}.

@subsubheading  Description::

Pops one @i{element} from the @i{list} being printed
in the @i{lexically current logical block}, obeying @b{*print-length*}
and @b{*print-circle*} as described below.

Each time @b{pprint-pop} is called, it pops the next value off the
@i{list} passed to the @i{lexically current logical block} and returns it.
However, before doing this, it performs three tests:

@table @asis

@item @t{*}  
If the remaining `list' is not a @i{list}, 
    ``@t{. }'' is printed followed by the remaining `list.' 
    (This makes it easier to write printing functions that 
    are robust in the face of malformed arguments.)

@item @t{*}  
If @b{*print-length*} is @i{non-nil},
    and @b{pprint-pop} has already been called @b{*print-length*} times 
    within the immediately containing logical block,
    ``@t{...}'' is printed.
    (This makes it easy to write printing functions that properly handle
    @b{*print-length*}.)

@item @t{*}  
If @b{*print-circle*} is
    @i{non-nil}, and the remaining list is a circular (or shared) reference,
    then ``@t{. }'' is printed followed by an appropriate
    ``@t{#@i{n}#}'' marker.
    (This catches instances of @i{cdr} circularity and sharing in lists.)
@end table

If either of the three conditions above occurs, the indicated output is
printed on the @i{pretty printing stream} created by the immediately containing
@b{pprint-logical-block} and the execution of the immediately containing
@b{pprint-logical-block} is terminated except for the printing of the suffix.

If @b{pprint-logical-block} is given a `list' argument of @b{nil}---because
it is not processing a list---@b{pprint-pop} can still be used to obtain 
support for @b{*print-length*}.  
In this situation, the first and third tests above are disabled and
@b{pprint-pop} always returns @b{nil}.
See @ref{Examples of using the Pretty Printer}---specifically, the @b{pprint-vector} example.

Whether or not @b{pprint-pop} is @i{fbound} in the
@i{global environment} is @i{implementation-dependent};
however, the restrictions on redefinition and @i{shadowing} of
@b{pprint-pop} are the same as for @i{symbols} in the @t{COMMON-LISP} @i{package}
which are @i{fbound} in the @i{global environment}.
The consequences of attempting to use @b{pprint-pop} outside
of @b{pprint-logical-block} are undefined.

@subsubheading  Side Effects::

Might cause output
to the @i{pretty printing stream} associated with the lexically current logical block.

@subsubheading  Affected By::

@b{*print-length*}, @b{*print-circle*}.

@subsubheading  Exceptional Situations::

An error is signaled (either at macro expansion time or at run time)
if a usage of @b{pprint-pop} occurs where there is no lexically
containing @b{pprint-logical-block} @i{form}.

The consequences are undefined if @b{pprint-pop} is executed outside
of the @i{dynamic extent} of this @b{pprint-logical-block}.

@subsubheading  See Also::

@ref{pprint-exit-if-list-exhausted}
, 
@ref{pprint-logical-block}
.

@subsubheading  Notes::

It is frequently a good idea to call @b{pprint-exit-if-list-exhausted} 
before calling @b{pprint-pop}.

@node pprint-tab, print-object, pprint-pop, Printer Dictionary
@subsection pprint-tab                                                       [Function]

@code{pprint-tab}  @i{kind colnum colinc {&optional} stream} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

@i{kind}---one of @t{:line}, @t{:section}, @t{:line-relative},
	       or @t{:section-relative}.

@i{colnum}---a non-negative @i{integer}.

@i{colinc}---a non-negative @i{integer}.

@i{stream}---an @i{output} @i{stream designator}.

@subsubheading  Description::

Specifies tabbing to @i{stream} as performed by the standard @t{~T} format directive.

If @i{stream} is a @i{pretty printing stream} and
   the @i{value} of @b{*print-pretty*} is @i{true},

tabbing is performed;
otherwise, @b{pprint-tab} has no effect.

The arguments @i{colnum} and @i{colinc} correspond to the two 
@i{parameters} to @t{~T} and are in terms of @i{ems}.
The @i{kind} argument specifies the style of tabbing.  It must be one of
  @t{:line} (tab as by @t{~T}),
  @t{:section} (tab as by @t{~:T}, 
		 but measuring horizontal positions relative to 
		 the start of the dynamically enclosing section),
  @t{:line-relative} (tab as by @t{~@@T}), or
  @t{:section-relative} (tab as by @t{~:@@T}, 
			  but measuring horizontal positions relative to
			  the start of the dynamically enclosing section).

@subsubheading  Exceptional Situations::

An error is signaled if @i{kind} is not one of @t{:line},
@t{:section}, @t{:line-relative}, or @t{:section-relative}.

@subsubheading  See Also::

@ref{pprint-logical-block}

@node print-object, print-unreadable-object, pprint-tab, Printer Dictionary
@subsection print-object                                    [Standard Generic Function]

@subsubheading  Syntax::

@code{print-object}  @i{object stream} @result{}  @i{object}

@subsubheading  Method Signatures::

@code{print-object}  @i{@r{(}@i{object} standard-object@r{)} @i{stream}}

@code{print-object}  @i{@r{(}@i{object} structure-object@r{)} @i{stream}}

@subsubheading  Arguments and Values::

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

@i{stream}---a @i{stream}.

@subsubheading  Description::

The @i{generic function} @b{print-object} writes the printed representation of @i{object}
to @i{stream}.
The @i{function} @b{print-object} is called by the @i{Lisp printer}; 
it should not be called by the user.

Each implementation is required to provide a @i{method} on
the @i{class} @b{standard-object} and on the @i{class} @b{structure-object}.
In addition, each @i{implementation} must provide 
@i{methods} on enough other @i{classes} 
so as to ensure that there is always an applicable @i{method}.
Implementations are free to add @i{methods} for other @i{classes}.
Users may write @i{methods} for @b{print-object} for their own
@i{classes} if they do not wish to inherit an 
@i{implementation-dependent} @i{method}.

The @i{method} on the @i{class} @b{structure-object} prints the object in the
default @t{#S} notation; see @ref{Printing Structures}.

@i{Methods} on @b{print-object} are responsible for implementing
their part of the semantics of the @i{printer control variables}, as follows:

@table @asis

@item @b{*print-readably*}  
All methods for @b{print-object} must obey @b{*print-readably*}.
This includes both user-defined methods and @i{implementation-defined} methods.
Readable printing of @i{structures} and @i{standard objects} 
is controlled by their @b{print-object} method, 
not by their @b{make-load-form} @i{method}.
@i{Similarity} for these @i{objects} is application dependent
and hence is defined to be whatever these @i{methods} do; 
see @ref{Similarity of Literal Objects}.

@item @b{*print-escape*}  
Each @i{method} must implement @b{*print-escape*}. 

@item @b{*print-pretty*}  

The @i{method} may wish to perform specialized line breaking
or other output conditional on the @i{value} of @b{*print-pretty*}.
For further information,
see (for example) the @i{macro} @b{pprint-fill}.
See also @ref{Pretty Print Dispatch Tables} and @ref{Examples of using the Pretty Printer}.

@item @b{*print-length*}  
@i{Methods} that produce output of indefinite length must obey
@b{*print-length*}.

For further information,
see (for example) the @i{macros} @b{pprint-logical-block}
and @b{pprint-pop}.
See also @ref{Pretty Print Dispatch Tables} and @ref{Examples of using the Pretty Printer}.

@item @b{*print-level*}  
The printer takes care of @b{*print-level*} automatically,
provided that each @i{method} handles exactly one level of structure and
calls @b{write} (or an equivalent @i{function}) recursively if
there are more structural levels.  The printer's decision of whether an
@i{object} has components (and therefore should not be printed when the
printing depth is not less than @b{*print-level*}) is
@i{implementation-dependent}.  In some implementations its 
@b{print-object} @i{method} is not called; 
in others the @i{method} is called, 
and the determination that the @i{object} has components is based on what
it tries to write to the @i{stream}.

@item @b{*print-circle*}  

When the @i{value} of @b{*print-circle*} is @i{true},
a user-defined 

@b{print-object} @i{method}

can print @i{objects} to the supplied @i{stream} 
using @b{write},
      @b{prin1},
      @b{princ},
   or @b{format}
and expect circularities to be detected 
and printed using the @t{#@i{n}#} syntax.
If a user-defined

@b{print-object} @i{method}

prints to a @i{stream} other than the one
that was supplied, then circularity detection starts over for that
@i{stream}.  See @b{*print-circle*}.

@item @b{*print-base*},
      @b{*print-radix*},
      @b{*print-case*}, 
      @b{*print-gensym*},
  and @b{*print-array*}  
These @i{printer control variables} apply to specific types of @i{objects}
and are handled by the @i{methods} for those @i{objects}.

@end table

If these rules are not obeyed, the results are undefined.

In general, the printer and the @b{print-object} methods should not
rebind the print control variables as they operate recursively through the
structure, but this is @i{implementation-dependent}.

In some implementations the @i{stream} argument passed to a 
@b{print-object} @i{method} is not the original @i{stream}, 
but is an intermediate @i{stream} that implements part of the printer.
@i{methods} should therefore not depend on the identity of this @i{stream}.

@subsubheading  See Also::

@ref{pprint-fill; pprint-linear; pprint-tabular}
,
@ref{pprint-logical-block}
,
@ref{pprint-pop}
,
@ref{write; prin1; print; pprint; princ}
,
@b{*print-readably*},
@b{*print-escape*},
@b{*print-pretty*},
@b{*print-length*},
@ref{Default Print-Object Methods},

@ref{Printing Structures},

@ref{Pretty Print Dispatch Tables},
@ref{Examples of using the Pretty Printer}

@node print-unreadable-object, set-pprint-dispatch, print-object, Printer Dictionary
@subsection print-unreadable-object                                             [Macro]

@code{print-unreadable-object}  @i{@r{(}object stream {&key} type identity@r{)} @{@i{form}@}{*}} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values::

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

@i{stream}---
a @i{stream designator}; evaluated.

@i{type}---a @i{generalized boolean}; evaluated.

@i{identity}---a @i{generalized boolean}; evaluated.

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

@subsubheading  Description::

Outputs a printed representation of @i{object} on @i{stream},
beginning with ``@t{#<}'' and ending with ``@t{>}''.  
Everything output to @i{stream} by the body @i{forms}
is enclosed in the the angle brackets.
If @i{type} is @i{true}, the output from @i{forms}
is preceded by a brief description of the @i{object}'s
@i{type} and a space character.
If @i{identity} is @i{true},
the output from @i{forms} is followed by a space character
and a representation of the @i{object}'s identity, 
typically a storage address.

If either @i{type} or @i{identity} is not supplied, 
its value is @i{false}.  It is valid to omit the body @i{forms}.  
If @i{type} and @i{identity} are both true and there are no
body @i{forms}, only one space character separates the type 
and the identity.

@subsubheading  Examples::

;; Note that in this example, the precise form of the output
;; is @i{implementation-dependent}.

@example
 (defmethod print-object ((obj airplane) stream)
   (print-unreadable-object (obj stream :type t :identity t)
     (princ (tail-number obj) stream)))

 (prin1-to-string my-airplane)
@result{}  "#<Airplane NW0773 36000123135>"
@i{OR}@result{} "#<FAA:AIRPLANE NW0773 17>"
@end example

@subsubheading  Exceptional Situations::

If @b{*print-readably*} is @i{true}, @b{print-unreadable-object}
signals an error of @i{type} @b{print-not-readable} without printing anything.

@node set-pprint-dispatch, write, print-unreadable-object, Printer Dictionary
@subsection set-pprint-dispatch                                              [Function]

@code{set-pprint-dispatch}  @i{type-specifier function {&optional} priority table} @result{}  @i{@b{nil}}

@subsubheading  Arguments and Values:: 

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

@i{function}---a @i{function}, a @i{function name}, or @b{nil}.

@i{priority}---a @i{real}.
 The default is @t{0}.

@i{table}---a @i{pprint dispatch table}.
 The default is the @i{value} of @b{*print-pprint-dispatch*}.

@subsubheading  Description::

Installs an entry into the @i{pprint dispatch table} which is @i{table}.

@i{Type-specifier} 
is the @i{key}
of the entry.  The first action of @b{set-pprint-dispatch} is to remove any
pre-existing entry associated with @i{type-specifier}.  This guarantees that
there will never be two entries associated with the same @i{type specifier} 
in a given @i{pprint dispatch table}.  Equality of @i{type specifiers} is
tested by @b{equal}.

Two values are associated with each @i{type specifier} in a 
@i{pprint dispatch table}: a @i{function} and a @i{priority}.
The @i{function} must accept two arguments: the @i{stream} to which output
is sent and the @i{object} to be printed.  The @i{function} should
@i{pretty print} the @i{object} to the @i{stream}.  The @i{function}
can assume that object satisfies the @i{type} given by @i{type-specifier}.
The @i{function} must obey @b{*print-readably*}.
Any values returned by the @i{function} are ignored.

@i{Priority} is a priority to resolve conflicts
when an object matches more than one entry.

It is permissible for @i{function} to be @b{nil}.  In this situation, 
there will be no @i{type-specifier} entry in @i{table} after
@b{set-pprint-dispatch} returns.

@subsubheading  Exceptional Situations::

An error is signaled if @i{priority} is not a @i{real}.

@subsubheading  Notes::

Since @i{pprint dispatch tables} are often used to control the pretty
printing of Lisp code, it is common for the @i{type-specifier} to be
an @i{expression} of the form 

@example
 (cons @i{car-type} @i{cdr-type})
@end example

This signifies that the corresponding object must be a cons cell 
whose @i{car} matches the @i{type specifier} @i{car-type} 
and whose @i{cdr} matches the @i{type specifier} @i{cdr-type}.
The @i{cdr-type} can be omitted in which case it defaults to @b{t}.

@node write, write-to-string, set-pprint-dispatch, Printer Dictionary
@subsection write, prin1, print, pprint, princ                               [Function]

@code{write}  @i{@i{object} {&key} \writekeys{stream}}@*
   @result{}  @i{object}

@code{prin}  @i{1} @result{}  @i{object {&optional} output-stream}
 {object}
@code{princ}  @i{object {&optional} output-stream} @result{}  @i{object}

@code{print}  @i{object {&optional} output-stream} @result{}  @i{object}

@code{pprint}  @i{object {&optional} output-stream} @result{}  @i{<@i{no @i{values}}>}

@subsubheading  Arguments and Values::

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

@i{output-stream}---an @i{output} @i{stream designator}.
		        The default is @i{standard output}.

\writekeydescriptions{@i{stream}---an @i{output} @i{stream designator}.
The default is @i{standard output}.}

@subsubheading  Description::

@b{write}, @b{prin1}, @b{princ}, @b{print}, and @b{pprint}
write the printed representation of @i{object} to @i{output-stream}.

@b{write} is the general entry point to the @i{Lisp printer}.
For each explicitly supplied @i{keyword parameter} named in Figure 22--6,
the corresponding @i{printer control variable} is dynamically bound to its @i{value}
while printing goes on;
for each @i{keyword parameter} in Figure 22--6 that is not explicitly supplied,
the value of the corresponding @i{printer control variable} is the same as it was
at the time @b{write} was invoked.
Once the appropriate @i{bindings} are @i{established},
the @i{object} is output by the @i{Lisp printer}.

@group
@noindent
@w{  Parameter        Corresponding Dynamic Variable  }
@w{  @i{array}            @b{*print-array*}                   }
@w{  @i{base}             @b{*print-base*}                    }
@w{  @i{case}             @b{*print-case*}                    }
@w{  @i{circle}           @b{*print-circle*}                  }
@w{  @i{escape}           @b{*print-escape*}                  }
@w{  @i{gensym}           @b{*print-gensym*}                  }
@w{  @i{length}           @b{*print-length*}                  }
@w{  @i{level}            @b{*print-level*}                   }
@w{  @i{lines}            @b{*print-lines*}                   }
@w{  @i{miser-width}      @b{*print-miser-width*}             }
@w{  @i{pprint-dispatch}  @b{*print-pprint-dispatch*}         }
@w{  @i{pretty}           @b{*print-pretty*}                  }
@w{  @i{radix}            @b{*print-radix*}                   }
@w{  @i{readably}         @b{*print-readably*}                }
@w{  @i{right-margin}     @b{*print-right-margin*}            }

@noindent
@w{  Figure 22--6: Argument correspondences for the WRITE function.}

@end group

@b{prin1}, @b{princ}, @b{print}, and @b{pprint} implicitly 
@i{bind} certain print parameters to particular values.  The remaining parameter
values are taken from 
     @b{*print-array*},
     @b{*print-base*},
     @b{*print-case*}, 
     @b{*print-circle*},
     @b{*print-escape*},
     @b{*print-gensym*},
     @b{*print-length*},
     @b{*print-level*},
     @b{*print-lines*},
     @b{*print-miser-width*},
     @b{*print-pprint-dispatch*},
     @b{*print-pretty*}, 
     @b{*print-radix*}, 
 and @b{*print-right-margin*}.

@b{prin1} produces output suitable for input to @b{read}.  
It binds @b{*print-escape*} to @i{true}.

@b{princ} is just like @b{prin1} except that the
output has no @i{escape} @i{characters}.
It binds @b{*print-escape*}   to @i{false}

     and @b{*print-readably*} to @i{false}.

The general rule is that output from @b{princ} is intended to look
good to people, while output from @b{prin1} is intended to
be acceptable to @b{read}.

@b{print} is just like @b{prin1} 
except that the printed representation
of @i{object} is preceded by a newline 
and followed by a space.

@b{pprint} is just like @b{print} except that the trailing
space is omitted and 
@i{object} is printed with the @b{*print-pretty*} flag @i{non-nil} 
to produce pretty output.

@i{Output-stream} specifies the @i{stream} to which 
output is to be sent.  

@subsubheading  Affected By::

@b{*standard-output*},
@b{*terminal-io*},
@b{*print-escape*},
@b{*print-radix*},
@b{*print-base*},
@b{*print-circle*},
@b{*print-pretty*},
@b{*print-level*},
@b{*print-length*},
@b{*print-case*},
@b{*print-gensym*},
@b{*print-array*},
@b{*read-default-float-format*}.

@subsubheading  See Also::

@ref{readtable-case}
,
@ref{FORMAT Printer Operations}

@subsubheading  Notes::

The @i{functions} @b{prin1} and @b{print} do not bind @b{*print-readably*}.

@example
 (prin1 object output-stream)
@equiv{} (write object :stream output-stream :escape t)
@end example

@example
 (princ object output-stream)
@equiv{} (write object stream output-stream :escape nil :readably nil)
@end example

@example
 (print object output-stream)
@equiv{} (progn (terpri output-stream)
           (write object :stream output-stream
                         :escape t)
           (write-char #\space output-stream))
@end example

@example
 (pprint object output-stream)
@equiv{} (write object :stream output-stream :escape t :pretty t)
@end example

@node write-to-string, *print-array*, write, Printer Dictionary
@subsection write-to-string, prin1-to-string, princ-to-string                [Function]

@code{write-to-string}  @i{object {&key} \writekeys{}}@*
   @result{}  @i{string}

@code{prin}  @i{1} @result{}  @i{-to-string}
 {object} {string}

@code{princ-to-string}  @i{object} @result{}  @i{string}

@subsubheading  Arguments and Values:: 

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

\writekeydescriptions{}

@i{string}---a @i{string}.

@subsubheading  Description::

@b{write-to-string}, @b{prin1-to-string}, and @b{princ-to-string}
are used to create a @i{string} consisting of the printed representation 
of @i{object}.
@i{Object} is effectively printed as if by @b{write},
@b{prin1}, or @b{princ}, respectively,
and the @i{characters} that would be output are made 
into a @i{string}.

@b{write-to-string} is the general output function.
It has the ability to specify all the parameters applicable 
to the printing of @i{object}.

@b{prin1-to-string} acts like @b{write-to-string} with 
@t{:escape t}, that is, escape characters are written where appropriate.

@b{princ-to-string} acts like @b{write-to-string} with 

@t{:escape nil :readably nil}.  

Thus no @i{escape} @i{characters} are written.

All other keywords that would be specified to @b{write-to-string} 
are default values when @b{prin1-to-string}
or @b{princ-to-string} is invoked.

The meanings and defaults for the keyword arguments to @b{write-to-string}
are the same as those for @b{write}.

@subsubheading  Examples::

@example
 (prin1-to-string "abc") @result{}  "\"abc\""
 (princ-to-string "abc") @result{}  "abc"
@end example

@subsubheading  Affected By::

@b{*print-escape*},
@b{*print-radix*},
@b{*print-base*},
@b{*print-circle*},
@b{*print-pretty*},
@b{*print-level*},
@b{*print-length*},
@b{*print-case*},
@b{*print-gensym*},
@b{*print-array*},
@b{*read-default-float-format*}.

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}

@subsubheading  Notes::       

@example
 (write-to-string @i{object} @{@i{key} @i{argument}@}{*})
@equiv{} (with-output-to-string (#1=#:string-stream) 
     (write object :stream #1# @{@i{key} @i{argument}@}{*}))

 (princ-to-string @i{object})
@equiv{} (with-output-to-string (string-stream)
     (princ @i{object} string-stream))

 (prin1-to-string @i{object})
@equiv{} (with-output-to-string (string-stream)
     (prin1 @i{object} string-stream))
@end example

@node *print-array*, *print-base*, write-to-string, Printer Dictionary
@subsection *print-array*                                                    [Variable]

@subsubheading  Value Type::

a @i{generalized boolean}.

@subsubheading  Initial Value::

@i{implementation-dependent}.

@subsubheading  Description::

Controls the format in which @i{arrays} are printed.  
If it is @i{false}, the contents of @i{arrays} other than @i{strings}
are never printed.  Instead, @i{arrays} are printed in a concise form using
@t{#<} that gives enough information for the user to be able to identify the
@i{array}, but does not include the entire @i{array} contents.
If it is @i{true}, non-@i{string} @i{arrays} are printed using
@t{#(...)}, @t{#*}, or @t{#nA} syntax.

@subsubheading  Affected By::

The @i{implementation}.

@subsubheading  See Also::

@ref{Sharpsign Left-Parenthesis},
@ref{Sharpsign Less-Than-Sign}

@node *print-base*, *print-case*, *print-array*, Printer Dictionary
@subsection *print-base*, *print-radix*                                      [Variable]

@subsubheading  Value Type::

@b{*print-base*}---a @i{radix}.
@b{*print-radix*}---a @i{generalized boolean}.

@subsubheading  Initial Value::

The initial @i{value} of @b{*print-base*} is @t{10}.
The initial @i{value} of @b{*print-radix*} is @i{false}.

@subsubheading  Description::

@b{*print-base*} and @b{*print-radix*} control the printing
of @i{rationals}.
The @i{value} of @b{*print-base*} is called the @i{current output base}
@IGindex{current output base}
.

The @i{value} of @b{*print-base*} is the @i{radix} in which the printer 
will print @i{rationals}.   For radices above @t{10}, letters of
the alphabet are used to represent digits above @t{9}.

If the @i{value} of @b{*print-radix*} is @i{true},
the printer will print a radix specifier to indicate the @i{radix}
in which it is printing a @i{rational} number.  The radix specifier
is always printed using lowercase letters.  If @b{*print-base*}
is @t{2}, @t{8}, or @t{16}, then the radix specifier used is @t{#b},
@t{#o}, or @t{#x}, respectively.  For @i{integers}, base ten is
indicated by a trailing decimal point instead of a leading radix
specifier; for @i{ratios}, @t{#10r} is used.  

@subsubheading  Examples::

@example
 (let ((*print-base* 24.) (*print-radix* t)) 
   (print 23.))
@t{ |> } #24rN
@result{}  23
 (setq *print-base* 10) @result{}  10
 (setq *print-radix* nil) @result{}  NIL                                          
 (dotimes (i 35)
    (let ((*print-base* (+ i 2)))           ;print the decimal number 40 
      (write 40)                            ;in each base from 2 to 36
      (if (zerop (mod i 10)) (terpri) (format t " "))))
@t{ |> } 101000
@t{ |> } 1111 220 130 104 55 50 44 40 37 34
@t{ |> } 31 2C 2A 28 26 24 22 20 1J 1I
@t{ |> } 1H 1G 1F 1E 1D 1C 1B 1A 19 18
@t{ |> } 17 16 15 14 
@result{}  NIL
 (dolist (pb '(2 3 8 10 16))               
    (let ((*print-radix* t)                 ;print the integer 10 and 
          (*print-base* pb))                ;the ratio 1/10 in bases 2, 
     (format t "~&~S  ~S~
@t{ |> } #b1010  #b1/1010
@t{ |> } #3r101  #3r1/101
@t{ |> } #o12  #o1/12
@t{ |> } 10.  #10r1/10
@t{ |> } #xA  #x1/A
@result{}  NIL
@end example

@subsubheading  Affected By::

Might be @i{bound} by @b{format}, and @b{write}, @b{write-to-string}.

@subsubheading  See Also::

@ref{format}
,
@ref{write; prin1; print; pprint; princ}
,
@ref{write-to-string; prin1-to-string; princ-to-string}

@node *print-case*, *print-circle*, *print-base*, Printer Dictionary
@subsection *print-case*                                                     [Variable]

@subsubheading  Value Type::

One of the @i{symbols} @t{:upcase}, @t{:downcase}, or @t{:capitalize}.

@subsubheading  Initial Value::

The @i{symbol} @t{:upcase}.

@subsubheading  Description::

The @i{value} of @b{*print-case*} controls the case (upper, lower, or mixed) in 
which to print any uppercase characters in the names of @i{symbols}
when vertical-bar syntax is not used.

@b{*print-case*} has an effect at all times when the @i{value} of @b{*print-escape*}
is @i{false}. @b{*print-case*} also has an effect when
the @i{value} of @b{*print-escape*} is @i{true} unless inside an escape context
(@i{i.e.}, unless between @i{vertical-bars} or after a @i{slash}).

@subsubheading  Examples::

@example
 (defun test-print-case ()
   (dolist (*print-case* '(:upcase :downcase :capitalize))
     (format t "~&~S ~S~
@result{}  TEST-PC
;; Although the choice of which characters to escape is specified by
;; *PRINT-CASE*, the choice of how to escape those characters 
;; (i.e., whether single escapes or multiple escapes are used)
;; is implementation-dependent.  The examples here show two of the
;; many valid ways in which escaping might appear.
 (test-print-case) ;Implementation A
@t{ |> } THIS-AND-THAT |And-something-elSE|
@t{ |> } this-and-that a\n\d-\s\o\m\e\t\h\i\n\g-\e\lse
@t{ |> } This-And-That A\n\d-\s\o\m\e\t\h\i\n\g-\e\lse
@result{}  NIL
 (test-print-case) ;Implementation B
@t{ |> } THIS-AND-THAT |And-something-elSE|
@t{ |> } this-and-that a|nd-something-el|se
@t{ |> } This-And-That A|nd-something-el|se
@result{}  NIL
@end example

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}

@subsubheading  Notes::

@b{read} normally converts lowercase characters appearing 
in @i{symbols} to corresponding uppercase characters,
so that internally print names normally contain only uppercase characters.

If @b{*print-escape*} is @i{true},
lowercase characters in the @i{name} of a @i{symbol}
are always printed in lowercase, and
are preceded by a single escape character 
or enclosed by multiple escape characters;
uppercase characters in the @i{name} of a @i{symbol}
are printed in upper case, in lower case, or in mixed case
so as to capitalize words, according to the value of
@b{*print-case*}.  The convention for what constitutes
a ``word'' is the same as for @b{string-capitalize}.

@node *print-circle*, *print-escape*, *print-case*, Printer Dictionary
@subsection *print-circle*                                                   [Variable]

@subsubheading  Value Type::

a @i{generalized boolean}.

@subsubheading  Initial Value::

@i{false}.

@subsubheading  Description::

Controls the attempt to detect circularity and sharing in an @i{object} 
being printed.

If @i{false},
the printing process merely proceeds by recursive descent without attempting 
to detect circularity and sharing.

If @i{true},
the printer will endeavor to detect cycles and sharing
in the structure to be printed, 
and to use @t{#@i{n}=} and @t{#@i{n}#}
syntax to indicate the circularities or shared components.

If @i{true}, a user-defined 

@b{print-object} @i{method}

can print
@i{objects} to the supplied @i{stream} using @b{write}, @b{prin1}, 
@b{princ}, or @b{format} and expect circularities and sharing
to be detected and printed using the @t{#@i{n}#} syntax.

If a user-defined 

@b{print-object} @i{method}

prints to a @i{stream} other than the one
that was supplied, then circularity detection starts over for that @i{stream}. 

Note that implementations should not use @t{#@i{n}#} notation 
when the @i{Lisp reader} would automatically assure sharing without it
(@i{e.g.}, as happens with @i{interned} @i{symbols}).

@subsubheading  Examples::

@example
 (let ((a (list 1 2 3)))
   (setf (cdddr a) a)
   (let ((*print-circle* t))
     (write a)
     :done))
@t{ |> } #1=(1 2 3 . #1#)
@result{}  :DONE
@end example

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}

@subsubheading  Notes::

An attempt to print a circular structure with @b{*print-circle*} 
set to @b{nil} may lead to looping behavior and failure to terminate.

@node *print-escape*, *print-gensym*, *print-circle*, Printer Dictionary
@subsection *print-escape*                                                   [Variable]

@subsubheading  Value Type::

a @i{generalized boolean}.

@subsubheading  Initial Value::

@i{true}.

@subsubheading  Description::

If @i{false},
escape characters and @i{package prefixes} are not output
when an expression is printed.

If @i{true}, an attempt is made to print an @i{expression}
in such a way that it can be read again to produce an @b{equal} @i{expression}.
(This is only a guideline; not a requirement.  See @b{*print-readably*}.)

For more specific details of how the @i{value} of @b{*print-escape*}
affects the printing of certain @i{types},
see @ref{Default Print-Object Methods}.

@subsubheading  Examples::
@example
 (let ((*print-escape* t)) (write #\a))
@t{ |> } #\a
@result{}  #\a
 (let ((*print-escape* nil)) (write #\a))
@t{ |> } a
@result{}  #\a
@end example

@subsubheading  Affected By::

@b{princ}, @b{prin1}, @b{format}

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}
, 
@ref{readtable-case}

@subsubheading  Notes::

@b{princ} effectively binds @b{*print-escape*} to @i{false}.
@b{prin1} effectively binds @b{*print-escape*} to @i{true}.

@node *print-gensym*, *print-level*, *print-escape*, Printer Dictionary
@subsection *print-gensym*                                                   [Variable]

@subsubheading  Value Type::

a @i{generalized boolean}.

@subsubheading  Initial Value::

@i{true}.

@subsubheading  Description::

Controls whether the prefix ``@t{#:}'' is printed before 
@i{apparently uninterned} @i{symbols}.  
The prefix is printed before such @i{symbols} 
if and only if the @i{value} of @b{*print-gensym*} is @i{true}.

@subsubheading  Examples::

@example
 (let ((*print-gensym* nil))
   (print (gensym)))
@t{ |> } G6040 
@result{}  #:G6040
@end example

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}
, @b{*print-escape*}

@node *print-level*, *print-lines*, *print-gensym*, Printer Dictionary
@subsection *print-level*, *print-length*                                    [Variable]

@subsubheading  Value Type::

a non-negative @i{integer}, or @b{nil}.

@subsubheading  Initial Value::

@b{nil}.

@subsubheading  Description::

@b{*print-level*} controls how many levels deep a nested @i{object} will print.
If it is @i{false}, then no control is exercised.
Otherwise, it is an @i{integer} indicating the maximum level to be printed.
An @i{object} to be printed is at level @t{0};
its components (as of a @i{list} or @i{vector}) are at level @t{1};
and so on.
If an @i{object} to be recursively printed has components 
and is at a level equal to or greater than the @i{value} of @b{*print-level*}, 
then the @i{object} is printed as ``@t{#}''.

@b{*print-length*} controls how many elements at a given level are printed.
If it is @i{false}, there is no limit to the number of components printed.
Otherwise, it is an @i{integer} indicating the maximum number of @i{elements} 
of an @i{object} to be printed.  If exceeded, the printer will print 
``@t{...}'' in place of the other @i{elements}.  In the case of a @i{dotted list},
if the @i{list} contains exactly as many @i{elements} as the @i{value} of @b{*print-length*},
the terminating @i{atom} is printed rather than printing ``@t{...}''

@b{*print-level*} and @b{*print-length*} affect the printing 
of an any @i{object} printed with a list-like syntax.  They do not affect
the printing of @i{symbols}, @i{strings}, and @i{bit vectors}.

@subsubheading  Examples::

@example
 (setq a '(1 (2 (3 (4 (5 (6))))))) @result{}  (1 (2 (3 (4 (5 (6))))))
 (dotimes (i 8) 
   (let ((*print-level* i)) 
     (format t "~&~D -- ~S~
@t{ |> } 0 -- #
@t{ |> } 1 -- (1 #)
@t{ |> } 2 -- (1 (2 #))
@t{ |> } 3 -- (1 (2 (3 #)))
@t{ |> } 4 -- (1 (2 (3 (4 #))))
@t{ |> } 5 -- (1 (2 (3 (4 (5 #)))))
@t{ |> } 6 -- (1 (2 (3 (4 (5 (6))))))
@t{ |> } 7 -- (1 (2 (3 (4 (5 (6))))))
@result{}  NIL

 (setq a '(1 2 3 4 5 6)) @result{}  (1 2 3 4 5 6)
 (dotimes (i 7) 
   (let ((*print-length* i)) 
     (format t "~&~D -- ~S~
@t{ |> } 0 -- (...)
@t{ |> } 1 -- (1 ...)
@t{ |> } 2 -- (1 2 ...)
@t{ |> } 3 -- (1 2 3 ...)
@t{ |> } 4 -- (1 2 3 4 ...)
@t{ |> } 5 -- (1 2 3 4 5 6)
@t{ |> } 6 -- (1 2 3 4 5 6)
@result{}  NIL

(dolist (level-length '((0 1) (1 1) (1 2) (1 3) (1 4) 
                        (2 1) (2 2) (2 3) (3 2) (3 3) (3 4)))
 (let ((*print-level*  (first  level-length))
       (*print-length* (second level-length)))
   (format t "~&~D ~D -- ~S~
           *print-level* *print-length* 
           '(if (member x y) (+ (car x) 3) '(foo . #(a b c d "Baz"))))))
@t{ |> } 0 1 -- #
@t{ |> } 1 1 -- (IF ...)
@t{ |> } 1 2 -- (IF # ...)
@t{ |> } 1 3 -- (IF # # ...)
@t{ |> } 1 4 -- (IF # # #)
@t{ |> } 2 1 -- (IF ...)
@t{ |> } 2 2 -- (IF (MEMBER X ...) ...)
@t{ |> } 2 3 -- (IF (MEMBER X Y) (+ # 3) ...)
@t{ |> } 3 2 -- (IF (MEMBER X ...) ...)
@t{ |> } 3 3 -- (IF (MEMBER X Y) (+ (CAR X) 3) ...)
@t{ |> } 3 4 -- (IF (MEMBER X Y) (+ (CAR X) 3) '(FOO . #(A B C D ...)))
@result{}  NIL
@end example

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}

@node *print-lines*, *print-miser-width*, *print-level*, Printer Dictionary
@subsection *print-lines*                                                    [Variable]

@subsubheading  Value Type::

a non-negative @i{integer}, or @b{nil}.

@subsubheading  Initial Value::

@b{nil}.

@subsubheading  Description::

When the @i{value} of @b{*print-lines*} is other than @b{nil},
it is a limit on the number of output lines produced when something is pretty
printed.  If an attempt is made to go beyond that many lines,
``@t{..}'' is printed at the end of the last line followed by all of the
suffixes (closing delimiters) that are pending to be printed.

@subsubheading  Examples::

@example
 (let ((*print-right-margin* 25) (*print-lines* 3))
   (pprint '(progn (setq a 1 b 2 c 3 d 4))))
@t{ |> } (PROGN (SETQ A 1
@t{ |> }              B 2
@t{ |> }              C 3 ..))
@result{}  <@i{no @i{values}}>
@end example

@subsubheading  Notes::

The ``@t{..}'' notation is intentionally different than
the ``@t{...}'' notation used for level abbreviation, so that the two
different situations can be visually distinguished.

This notation is used to increase the likelihood that the @i{Lisp reader}
will signal an error if an attempt is later made to read the abbreviated output.
Note however that if the truncation occurs in a @i{string}, 
as in @t{"This string has been trunc.."}, the problem situation cannot be
detected later and no such error will be signaled.

@node *print-miser-width*, *print-pprint-dispatch*, *print-lines*, Printer Dictionary
@subsection *print-miser-width*                                              [Variable]

@subsubheading  Value Type::

a non-negative @i{integer}, or @b{nil}.

@subsubheading  Initial Value::

@i{implementation-dependent}

@subsubheading  Description::

If it is not @b{nil}, the @i{pretty printer} switches to a compact
style of output (called miser style) whenever the width available for
printing a substructure is less than or equal to this many @i{ems}.

@node *print-pprint-dispatch*, *print-pretty*, *print-miser-width*, Printer Dictionary
@subsection *print-pprint-dispatch*                                          [Variable]

@subsubheading  Value Type::

a @i{pprint dispatch table}.

@subsubheading  Initial Value::

@i{implementation-dependent}, but the initial entries all use a 
special class of priorities that have the property that they are less
than every priority that can be specified using @b{set-pprint-dispatch},
so that the initial contents of any entry can be overridden.

@subsubheading  Description::

The @i{pprint dispatch table} which currently controls the @i{pretty printer}.

@subsubheading  See Also::

@b{*print-pretty*},
@ref{Pretty Print Dispatch Tables}

@subsubheading  Notes::

The intent is that the initial @i{value} of this @i{variable} should
cause `traditional' @i{pretty printing} of @i{code}.
In general, however, you can put a value in @b{*print-pprint-dispatch*}
that makes pretty-printed output look exactly like non-pretty-printed output.

Setting @b{*print-pretty*} to @i{true} 
just causes the functions contained in the @i{current pprint dispatch table} 
to have priority over normal @b{print-object} methods;
it has no magic way of enforcing that those functions actually produce pretty
output.  For details, see @ref{Pretty Print Dispatch Tables}.

@node *print-pretty*, *print-readably*, *print-pprint-dispatch*, Printer Dictionary
@subsection *print-pretty*                                                   [Variable]

@subsubheading  Value Type::

a @i{generalized boolean}.

@subsubheading  Initial Value::

@i{implementation-dependent}.

@subsubheading  Description::

Controls whether the @i{Lisp printer} calls the @i{pretty printer}.

If it is @i{false},
the @i{pretty printer} is not used and 

a minimum

of @i{whitespace}_1
is output when printing an expression.

If it is @i{true},
the @i{pretty printer} is used, and the @i{Lisp printer} will endeavor
to insert extra @i{whitespace}_1 where appropriate to make @i{expressions} 
more readable.

@b{*print-pretty*} has an effect even when the @i{value} of @b{*print-escape*}
is @i{false}.

@subsubheading  Examples::

@example
 (setq *print-pretty* 'nil) @result{}  NIL
 (progn (write '(let ((a 1) (b 2) (c 3)) (+ a b c))) nil)
@t{ |> } (LET ((A 1) (B 2) (C 3)) (+ A B C))
@result{}  NIL
 (let ((*print-pretty* t))
   (progn (write '(let ((a 1) (b 2) (c 3)) (+ a b c))) nil))
@t{ |> } (LET ((A 1)
@t{ |> }       (B 2)
@t{ |> }       (C 3))
@t{ |> }   (+ A B C))
@result{}  NIL
;; Note that the first two expressions printed by this next form
;; differ from the second two only in whether escape characters are printed.
;; In all four cases, extra whitespace is inserted by the pretty printer.
 (flet ((test (x)
          (let ((*print-pretty* t))
            (print x)
            (format t "~
            (terpri) (princ x) (princ " ")
            (format t "~
  (test '#'(lambda () (list "a" #@b{'c} #'d))))
@t{ |> } #'(LAMBDA ()
@t{ |> }     (LIST "a" #@b{'C} #'D))
@t{ |> } #'(LAMBDA ()
@t{ |> }     (LIST "a" #@b{'C} #'D))
@t{ |> } #'(LAMBDA ()
@t{ |> }     (LIST a b 'C #'D)) 
@t{ |> } #'(LAMBDA ()
@t{ |> }     (LIST a b 'C #'D))
@result{}  NIL
@end example

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}

@node *print-readably*, *print-right-margin*, *print-pretty*, Printer Dictionary
@subsection *print-readably*                                                 [Variable]

@subsubheading  Value Type::

a @i{generalized boolean}.

@subsubheading  Initial Value::

@i{false}.

@subsubheading  Description::

If @b{*print-readably*} is @i{true},
some special rules for printing @i{objects} go into effect.
Specifically, printing any @i{object} O_1 produces a printed 
representation that, when seen by the @i{Lisp reader} 
while the @i{standard readtable} is in effect,
will produce 
an @i{object} O_2 that is @i{similar} to O_1.
The printed representation produced might or might not be the same as
the printed representation produced when @b{*print-readably*} is @i{false}.
If printing an @i{object} @i{readably} is not possible,
an error of @i{type} @b{print-not-readable} is signaled rather than 
using a syntax (@i{e.g.}, the ``@t{#<}'' syntax) that would not be readable by
the same @i{implementation}.
If the @i{value} of some other @i{printer control variable} is such
that these requirements would be violated, the @i{value} of that other
@i{variable} is ignored.

Specifically, if @b{*print-readably*} is @i{true},
printing proceeds as if
      @b{*print-escape*},
      @b{*print-array*},
  and @b{*print-gensym*} were also @i{true},
and as if 
      @b{*print-length*},
      @b{*print-level*},
  and @b{*print-lines*} were @i{false}.

If @b{*print-readably*} is @i{false},
the normal rules for printing and the normal interpretations
of other @i{printer control variables} are in effect.

Individual @i{methods} for @b{print-object}, including user-defined
@i{methods}, are responsible for implementing these requirements.

If @b{*read-eval*} is @i{false} and @b{*print-readably*} is @i{true},
any such method that would output a reference to the ``@t{#.}'' @i{reader macro}
will either output something else or will signal an error (as described above).

@subsubheading  Examples::

@example
 (let ((x (list "a" '\a (gensym) '((a (b (c))) d e f g)))
       (*print-escape* nil)
       (*print-gensym* nil)
       (*print-level* 3)
       (*print-length* 3))
   (write x)
   (let ((*print-readably* t))
     (terpri)
     (write x)
     :done))
@t{ |> } (a a G4581 ((A #) D E ...))
@t{ |> } ("a" |a| #:G4581 ((A (B (C))) D E F G))
@result{}  :DONE

;; This is setup code is shared between the examples
;; of three hypothetical implementations which follow.
 (setq table (make-hash-table)) @result{}  #<HASH-TABLE EQL 0/120 32005763> 
 (setf (gethash table 1) 'one) @result{}  ONE
 (setf (gethash table 2) 'two) @result{}  TWO

;; Implementation A
 (let ((*print-readably* t)) (print table))
 Error: Can't print #<HASH-TABLE EQL 0/120 32005763> readably.

;; Implementation B
;; No standardized #S notation for hash tables is defined, 
;; but there might be an implementation-defined notation.
 (let ((*print-readably* t)) (print table))
@t{ |> } #S(HASH-TABLE :TEST EQL :SIZE 120 :CONTENTS (1 ONE 2 TWO))
@result{}  #<HASH-TABLE EQL 0/120 32005763>

;; Implementation C
;; Note that #. notation can only be used if *READ-EVAL* is true.
;; If *READ-EVAL* were false, this same implementation might have to
;; signal an error unless it had yet another printing strategy to fall
;; back on.
 (let ((*print-readably* t)) (print table))
@t{ |> } #.(LET ((HASH-TABLE (MAKE-HASH-TABLE)))
@t{ |> }     (SETF (GETHASH 1 HASH-TABLE) ONE)
@t{ |> }     (SETF (GETHASH 2 HASH-TABLE) TWO)
@t{ |> }     HASH-TABLE)
@result{}  #<HASH-TABLE EQL 0/120 32005763>
@end example

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}
, 
@ref{print-unreadable-object}

@subsubheading  Notes::

The rules for ``@i{similarity}'' imply that 
@t{#A} or @t{#(} 
syntax cannot be used for @i{arrays} of @i{element type}
other than @b{t}.  
An implementation will have to use another syntax 
or signal an error of @i{type} @b{print-not-readable}.  

@node *print-right-margin*, print-not-readable, *print-readably*, Printer Dictionary
@subsection *print-right-margin*                                             [Variable]

@subsubheading  Value Type::

a non-negative @i{integer}, or @b{nil}.

@subsubheading  Initial Value::

@b{nil}.

@subsubheading  Description::

If it is @i{non-nil}, it specifies the right margin (as @i{integer}
number of @i{ems}) to use when the @i{pretty printer} is making
layout decisions.

If it is @b{nil}, the right margin is taken to be the maximum line length 
such that output can be displayed without wraparound or truncation.
If this cannot be determined, an @i{implementation-dependent} value is used.

@subsubheading  Notes::

This measure is in units of @i{ems} in order to be compatible with
@i{implementation-defined} variable-width fonts while still not 
requiring the language to provide support for fonts.

@node print-not-readable, print-not-readable-object, *print-right-margin*, Printer Dictionary
@subsection print-not-readable                                         [Condition Type]

@subsubheading  Class Precedence List::
@b{print-not-readable},
@b{error},
@b{serious-condition},
@b{condition},
@b{t}

@subsubheading  Description::

The @i{type} @b{print-not-readable} consists of error conditions that occur during
output while @b{*print-readably*} is @i{true}, as a result of attempting
to write a printed representation with the @i{Lisp printer}
that would not be correctly read back with the @i{Lisp reader}.
The object which could not be printed is initialized by 
the @t{:object} initialization argument to @b{make-condition}, and is @i{accessed} by 
the @i{function} @b{print-not-readable-object}.

@subsubheading  See Also::

@ref{print-not-readable-object}

@node print-not-readable-object, format, print-not-readable, Printer Dictionary
@subsection print-not-readable-object                                        [Function]

@code{print-not-readable-object}  @i{condition} @result{}  @i{object}

@subsubheading  Arguments and Values::

@i{condition}---a @i{condition} of @i{type} @b{print-not-readable}.

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

@subsubheading  Description::

Returns the @i{object} that could not be printed readably 
in the situation represented by @i{condition}.

@subsubheading  See Also::

@b{print-not-readable},
@ref{Conditions}

@node format,  , print-not-readable-object, Printer Dictionary
@subsection format                                                           [Function]

@code{format}  @i{destination control-string {&rest} args} @result{}  @i{result}

@subsubheading  Arguments and Values:: 

@i{destination}---@b{nil},
		      @b{t},
		      a @i{stream},
		   or a @i{string} with a @i{fill pointer}.

@i{control-string}---a @i{format control}.

@i{args}---@i{format arguments} for @i{control-string}.

@i{result}---if @i{destination} is @i{non-nil}, then @b{nil};
		 otherwise, a @i{string}.

@subsubheading  Description::

@b{format} produces formatted output by outputting the characters
of @i{control-string} and observing that a @i{tilde}
introduces a directive.  The character after the tilde, possibly preceded 
by prefix parameters and modifiers, specifies what kind of formatting 
is desired.  Most directives use one or more elements of @i{args} to
create their output.

If @i{destination} is a @i{string}, a @i{stream}, or @b{t}, 
then the @i{result} is @b{nil}.  Otherwise, the @i{result} is
a @i{string} containing the `output.'

@b{format} is useful for producing nicely formatted text, producing
good-looking messages, and so on.  @b{format} can generate and return
a @i{string} or output to @i{destination}.

For details on how the @i{control-string} is interpreted,
see @ref{Formatted Output}.

@subsubheading  Affected By::

@b{*standard-output*},
@b{*print-escape*},
@b{*print-radix*},
@b{*print-base*},
@b{*print-circle*},
@b{*print-pretty*},
@b{*print-level*},
@b{*print-length*},
@b{*print-case*},
@b{*print-gensym*},
@b{*print-array*}.

@subsubheading  Exceptional Situations::

If @i{destination} is a @i{string} with a @i{fill pointer},
the consequences are undefined if destructive modifications are performed
directly on the @i{string} during the @i{dynamic extent} of the call.

@subsubheading  See Also::

@ref{write; prin1; print; pprint; princ}
,
@ref{Documentation of Implementation-Defined Scripts}

@c end of including dict-printer

@c %**end of chapter