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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html40/loose.dtd">
<HTML>
<!-- Created on January, 10 2005 by texi2html 1.66 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<HEAD>
<TITLE>SLIB: The Library System</TITLE>
<META NAME="description" CONTENT="SLIB: The Library System">
<META NAME="keywords" CONTENT="SLIB: The Library System">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.66">
</HEAD>
<BODY LANG="en" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC1"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC2"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<A NAME="The Library System"></A>
<H1> 1. The Library System </H1>
<!--docid::SEC1::-->
<P>
<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC2">1.1 Feature</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">SLIB names.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC3">1.2 Require</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC4">1.3 Library Catalogs</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC5">1.4 Catalog Creation</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC6">1.5 Catalog Vicinities</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC7">1.6 Compiling Scheme</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>
<A NAME="Feature"></A>
<HR SIZE="6">
<A NAME="SEC2"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC3"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 1.1 Feature </H2>
<!--docid::SEC2::-->
<P>
<A NAME="IDX1"></A>
SLIB denotes <EM>features</EM> by symbols. SLIB maintains a list of
features supported by a Scheme <EM>session</EM>. The set of features
<A NAME="IDX2"></A>
provided by a session may change during that session. Some features
are properties of the Scheme implementation being used. The following
<A NAME="IDX3"></A>
<EM>intrinsic feature</EM>s detail what sort of numbers are available
from an implementation:
</P>
<P>
<UL>
<LI>
'inexact
<LI>
'rational
<LI>
'real
<LI>
'complex
<LI>
'bignum
</UL>
<P>
SLIB initialization (in `<TT>require.scm</TT>') tests and <EM>provide</EM>s
any of these numeric features which are appropriate.
</P>
<P>
Other features correspond to the presence of packages of Scheme
procedures or syntax (macros).
</P>
<P>
<A NAME="IDX4"></A>
</P>
<DL>
<DT><U>Function:</U> <B>provided?</B> <I>feature</I>
<DD>Returns <CODE>#t</CODE> if <VAR>feature</VAR> is present in the current Scheme
session; otherwise <CODE>#f</CODE>. More specifically, <CODE>provided?</CODE>
returns <CODE>#t</CODE> if the symbol <VAR>feature</VAR> is the
<CODE>software-type</CODE> or if <VAR>feature</VAR> has been provided by a module
already loaded; and <CODE>#f</CODE> otherwise.
<P>
In some implementations <CODE>provided?</CODE> tests whether a module has
been <CODE>require</CODE>d by any module or in any thread; other
implementations will have <CODE>provided?</CODE> reflect only the modules
<CODE>require</CODE>d by that particular session or thread.
</P>
<P>
To work portably in both scenarios, use <CODE>provided?</CODE> only to test
whether intrinsic properties (like those above) are present.
</P>
<P>
The <VAR>feature</VAR> argument can also be an expression calling
<CODE>and</CODE>, <CODE>or</CODE>, and <CODE>not</CODE> of features. The boolean result
of the logical question asked by <VAR>feature</VAR> is returned.
</P>
</DL>
<P>
The generalization of <CODE>provided?</CODE> for arbitrary features and catalog
is <CODE>feature-eval</CODE>:
</P>
<P>
<A NAME="IDX5"></A>
</P>
<DL>
<DT><U>Function:</U> <B>feature-eval</B> <I>expression provided?</I>
<DD>Evaluates <CODE>and</CODE>, <CODE>or</CODE>, and <CODE>not</CODE> forms in
<VAR>expression</VAR>, using the values returned by calling <VAR>provided?</VAR>
on the leaf symbols. <CODE>feature-eval</CODE> returns the boolean result
of the logical combinations.
</DL>
<P>
<A NAME="IDX6"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>provide</B> <I>feature</I>
<DD>Informs SLIB that <VAR>feature</VAR> is supported in this session.
</DL>
<P>
<TABLE><tr><td> </td><td class=example><pre>(provided? 'foo) => #f
(provide 'foo)
(provided? 'foo) => #t
</pre></td></tr></table><P>
<A NAME="Require"></A>
<HR SIZE="6">
<A NAME="SEC3"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC2"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC4"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 1.2 Require </H2>
<!--docid::SEC3::-->
<P>
<A NAME="IDX7"></A>
SLIB creates and maintains a <EM>catalog</EM> mapping features to locations
of files introducing procedures and syntax denoted by those features.
</P>
<P>
<A NAME="IDX8"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*catalog*</B>
<DD>Is an association list of features (symbols) and pathnames which will
supply those features. The pathname can be either a string or a pair.
If pathname is a pair then the first element should be a macro feature
symbol, <CODE>source</CODE>, <CODE>compiled</CODE>, or one of the other cases
described in <A HREF="slib_1.html#SEC4">1.3 Library Catalogs</A>. The cdr of the pathname should
be either a string or a list.
</DL>
<P>
At the beginning of each section of this manual, there is a line like
<CODE>(require '<VAR>feature</VAR>)</CODE>.
<A NAME="IDX9"></A>
The Scheme files comprising SLIB are cataloged so that these feature
names map to the corresponding files.
</P>
<P>
SLIB provides a form, <CODE>require</CODE>, which loads the files providing
the requested feature.
</P>
<P>
<A NAME="IDX10"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>require</B> <I>feature</I>
<DD><UL>
<LI>
If <CODE>(provided? <VAR>feature</VAR>)</CODE> is true,
then <CODE>require</CODE> just returns.
<LI>
Otherwise, if <VAR>feature</VAR> is found in the catalog, then the
corresponding files will be loaded and <CODE>(provided?
<VAR>feature</VAR>)</CODE> will henceforth return <CODE>#t</CODE>. That <VAR>feature</VAR>
is thereafter <CODE>provided</CODE>.
<LI>
Otherwise (<VAR>feature</VAR> not found in the catalog), an error is
signaled.
</UL>
</DL>
<P>
There is a related form <CODE>require-if</CODE>, used primarily for enabling
compilers to statically include modules which would be dynamically
loaded by interpreters.
</P>
<P>
<A NAME="IDX11"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>require-if</B> <I>condition feature</I>
<DD><P>
Requires <VAR>feature</VAR> if <VAR>condition</VAR> is true.
</P>
</DL>
<P>
The <CODE>random</CODE> module uses <CODE>require-if</CODE> to flag
<CODE>object->string</CODE> as a (dynamic) required module.
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(require 'byte)
(require 'logical)
(require-if 'compiling 'object->string)
</pre></td></tr></table><P>
The <CODE>batch</CODE> module uses <CODE>require-if</CODE> to flag
<CODE>posix-time</CODE> as a module to load if the implementation supports
large precision exact integers.
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(require-if '(and bignum compiling) 'posix-time)
</pre></td></tr></table><P>
The <CODE>commutative-ring</CODE> module uses <CODE>require-if</CODE> to ensure
that it has an exponentiation routine, regardless of whether the
implementation supports inexact numbers:
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(require-if '(not inexact) 'logical) ;for integer-expt
(define number^ (if (provided? 'inexact) expt integer-expt))
</pre></td></tr></table><P>
The catalog can also be queried using <CODE>slib:in-catalog?</CODE>.
</P>
<P>
<A NAME="IDX12"></A>
</P>
<DL>
<DT><U>Function:</U> <B>slib:in-catalog?</B> <I>feature</I>
<DD>Returns a <CODE>CDR</CODE> of the catalog entry if one was found for the
symbol <VAR>feature</VAR> in the alist <CODE>*catalog*</CODE> (and transitively
through any symbol aliases encountered). Otherwise, returns
<CODE>#f</CODE>. The format of catalog entries is explained in <A HREF="slib_1.html#SEC4">1.3 Library Catalogs</A>.
</DL>
<P>
<A NAME="Library Catalogs"></A>
<HR SIZE="6">
<A NAME="SEC4"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC3"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC5"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 1.3 Library Catalogs </H2>
<!--docid::SEC4::-->
<P>
Catalog files consist of one or more <EM>association list</EM>s.
<A NAME="IDX13"></A>
In the circumstance where a feature symbol appears in more than one
list, the latter list's association is retrieved. Here are the
supported formats for elements of catalog lists:
</P>
<P>
</P>
<DL COMPACT>
<DT><CODE>(<VAR>feature</VAR> . <I><symbol></I>)</CODE>
<DD>Redirects to the feature named <I><symbol></I>.
<DT><CODE>(<VAR>feature</VAR> . "<I><path></I>")</CODE>
<DD>Loads file <I><path></I>.
<DT><CODE>(<VAR>feature</VAR> source "<I><path>"</I>)</CODE>
<DD><A NAME="IDX14"></A>
<CODE>slib:load</CODE>s the Scheme source file <I><path></I>.
<DT><CODE>(<VAR>feature</VAR> compiled "<I><path>"</I> <small>...</small>)</CODE>
<DD><A NAME="IDX15"></A>
<CODE>slib:load-compiled</CODE>s the files <I><path></I> <small>...</small>.
<DT><CODE>(<VAR>feature</VAR> aggregate <I><symbol></I> <small>...</small>)</CODE>
<DD><A NAME="IDX16"></A>
<CODE>slib:require</CODE>s the features <I><symbol></I> <small>...</small>.
</DL>
<P>
The various macro styles first <CODE>require</CODE> the named macro package,
then just load <I><path></I> or load-and-macro-expand <I><path></I> as
appropriate for the implementation.
</P>
<P>
</P>
<DL COMPACT>
<DT><CODE>(<VAR>feature</VAR> defmacro "<I><path>"</I>)</CODE>
<DD><A NAME="IDX17"></A>
<CODE>defmacro:load</CODE>s the Scheme source file <I><path></I>.
<DT><CODE>(<VAR>feature</VAR> macro-by-example "<I><path>"</I>)</CODE>
<DD><A NAME="IDX18"></A>
<CODE>defmacro:load</CODE>s the Scheme source file <I><path></I>.
</DL>
<P>
</P>
<DL COMPACT>
<DT><CODE>(<VAR>feature</VAR> macro "<I><path>"</I>)</CODE>
<DD><A NAME="IDX19"></A>
<CODE>macro:load</CODE>s the Scheme source file <I><path></I>.
<DT><CODE>(<VAR>feature</VAR> macros-that-work "<I><path>"</I>)</CODE>
<DD><A NAME="IDX20"></A>
<CODE>macro:load</CODE>s the Scheme source file <I><path></I>.
<DT><CODE>(<VAR>feature</VAR> syntax-case "<I><path>"</I>)</CODE>
<DD><A NAME="IDX21"></A>
<CODE>macro:load</CODE>s the Scheme source file <I><path></I>.
<DT><CODE>(<VAR>feature</VAR> syntactic-closures "<I><path>"</I>)</CODE>
<DD><A NAME="IDX22"></A>
<CODE>macro:load</CODE>s the Scheme source file <I><path></I>.
</DL>
<P>
<A NAME="Catalog Creation"></A>
<HR SIZE="6">
<A NAME="SEC5"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC4"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC6"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 1.4 Catalog Creation </H2>
<!--docid::SEC5::-->
<P>
At the start of an interactive session no catalog is present, but is
created with the first catalog inquiry (such as <CODE>(require
'random)</CODE>). Several sources of catalog information are combined to
produce the catalog:
</P>
<P>
<UL>
<LI>
standard SLIB packages.
<LI>
additional packages of interest to this site.
<LI>
packages specifically for the variety of Scheme which this
session is running.
<LI>
packages this user wants to always have available. This catalog is the
file `<TT>homecat</TT>' in the user's <EM>HOME</EM> directory.
<A NAME="IDX23"></A>
<LI>
packages germane to working in this (current working) directory. This
catalog is the file `<TT>usercat</TT>' in the directory to which it applies.
One would typically <CODE>cd</CODE> to this directory before starting the
Scheme session.
<LI>
packages which are part of an application program.
</UL>
<P>
SLIB combines the catalog information which doesn't vary per user into
the file `<TT>slibcat</TT>' in the implementation-vicinity. Therefore
`<TT>slibcat</TT>' needs change only when new software is installed or
compiled. Because the actual pathnames of files can differ from
installation to installation, SLIB builds a separate catalog for each
implementation it is used with.
</P>
<P>
The definition of <CODE>*SLIB-VERSION*</CODE> in SLIB file
`<TT>require.scm</TT>' is checked against the catalog association of
<CODE>*SLIB-VERSION*</CODE> to ascertain when versions have changed. It is
a reasonable practice to change the definition of
<CODE>*SLIB-VERSION*</CODE> whenever the library is changed. If multiple
implementations of Scheme use SLIB, remember that recompiling one
`<TT>slibcat</TT>' will update only that implementation's catalog.
</P>
<P>
The compilation scripts of Scheme implementations which work with SLIB
can automatically trigger catalog compilation by deleting
`<TT>slibcat</TT>' or by invoking <CODE>require</CODE> of a special feature:
</P>
<P>
<A NAME="IDX24"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>require</B> <I>'new-catalog</I>
<DD><A NAME="IDX25"></A>
This will load `<TT>mklibcat</TT>', which compiles and writes a new
`<TT>slibcat</TT>'.
</DL>
<P>
Another special feature of <CODE>require</CODE> erases SLIB's catalog,
forcing it to be reloaded the next time the catalog is queried.
</P>
<P>
<A NAME="IDX26"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>require</B> <I>#f</I>
<DD>Removes SLIB's catalog information. This should be done before saving
an executable image so that, when restored, its catalog will be loaded
afresh.
</DL>
<P>
<A NAME="Catalog Vicinities"></A>
<HR SIZE="6">
<A NAME="SEC6"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC5"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 1.5 Catalog Vicinities </H2>
<!--docid::SEC6::-->
<P>
Each file in the table below is descibed in terms of its
file-system independent <EM>vicinity</EM> (see section <A HREF="slib_2.html#SEC14">2.1 Vicinity</A>). The entries
of a catalog in the table override those of catalogs above it in the
table.
</P>
<P>
</P>
<DL COMPACT>
<DT><CODE>implementation-vicinity</CODE> `<TT>slibcat</TT>'
<DD><A NAME="IDX27"></A>
This file contains the associations for the packages comprising SLIB,
the `<TT>implcat</TT>' and the `<TT>sitecat</TT>'s. The associations in the
other catalogs override those of the standard catalog.
<P>
</P>
<DT><CODE>library-vicinity</CODE> `<TT>mklibcat.scm</TT>'
<DD><A NAME="IDX28"></A>
creates `<TT>slibcat</TT>'.
<P>
</P>
<DT><CODE>library-vicinity</CODE> `<TT>sitecat</TT>'
<DD><A NAME="IDX29"></A>
This file contains the associations specific to an SLIB installation.
<P>
</P>
<DT><CODE>implementation-vicinity</CODE> `<TT>implcat</TT>'
<DD><A NAME="IDX30"></A>
This file contains the associations specific to an implementation of
Scheme. Different implementations of Scheme should have different
<CODE>implementation-vicinity</CODE>.
<P>
</P>
<DT><CODE>implementation-vicinity</CODE> `<TT>mkimpcat.scm</TT>'
<DD><A NAME="IDX31"></A>
if present, creates `<TT>implcat</TT>'.
<P>
</P>
<DT><CODE>implementation-vicinity</CODE> `<TT>sitecat</TT>'
<DD><A NAME="IDX32"></A>
This file contains the associations specific to a Scheme implementation
installation.
<P>
</P>
<DT><CODE>home-vicinity</CODE> `<TT>homecat</TT>'
<DD><A NAME="IDX33"></A>
This file contains the associations specific to an SLIB user.
<P>
</P>
<DT><CODE>user-vicinity</CODE> `<TT>usercat</TT>'
<DD><A NAME="IDX34"></A>
This file contains associations affecting only those sessions whose
<EM>working directory</EM> is <CODE>user-vicinity</CODE>.
<P>
</DL>
<P>
Here is an example of a `<TT>usercat</TT>' catalog. A program in this
directory can invoke the `<SAMP>run</SAMP>' feature with <CODE>(require 'run)</CODE>.
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>;;; "usercat": SLIB catalog additions for SIMSYNCH. -*-scheme-*-
(
(simsynch . "../synch/simsynch.scm")
(run . "../synch/run.scm")
(schlep . "schlep.scm")
)
</pre></td></tr></table><P>
Copying `<TT>usercat</TT>' to many directories is inconvenient.
Application programs which aren't always run in specially prepared
directories can nonetheless register their features during
initialization.
</P>
<P>
<A NAME="IDX35"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>catalog:read</B> <I>vicinity catalog</I>
<DD>Reads file named by string <VAR>catalog</VAR> in <VAR>vicinity</VAR>, resolving
all paths relative to <VAR>vicinity</VAR>, and adds those feature
associations to <VAR>*catalog*</VAR>.
<P>
<CODE>catalog:read</CODE> would typically be used by an application program
having dynamically loadable modules. For instance, to register
factoring and other modules in <VAR>*catalog*</VAR>, JACAL does:
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(catalog:read (program-vicinity) "jacalcat")
</pre></td></tr></table><P>
</P>
</DL>
<P>
For an application program there are three appropriate venues for
registering its catalog associations:
</P>
<P>
<UL>
<LI>
in a `<TT>usercat</TT>' file in the directory where the program runs; or
<LI>
in an `<TT>implcat</TT>' file in the <CODE>implementation-vicinity</CODE>; or
<LI>
in an application program directory; loaded by calling
<CODE>catalog:read</CODE>.
</UL>
<P>
<A NAME="Compiling Scheme"></A>
<HR SIZE="6">
<A NAME="SEC7"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC6"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC8"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 1.6 Compiling Scheme </H2>
<!--docid::SEC7::-->
<P>
To use Scheme compilers effectively with SLIB the compiler needs to
know which SLIB modules are to be compiled and which symbols are
exported from those modules.
</P>
<P>
The procedures in this section automate the extraction of this
information from SLIB modules. They are guaranteed to work on SLIB
modules; to use them on other sources, those sources should follow
SLIB conventions.
</P>
<P>
<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC8">1.6.1 Module Conventions</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC9">1.6.2 Module Manifests</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC10">1.6.3 Module Semantics</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC11">1.6.4 Top-level Variable References</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_1.html#SEC12">1.6.5 Module Analysis</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>
<A NAME="Module Conventions"></A>
<HR SIZE="6">
<A NAME="SEC8"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC9"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 1.6.1 Module Conventions </H3>
<!--docid::SEC8::-->
<P>
<UL>
<LI>
All the top-level <CODE>require</CODE> commands have one quoted argument and
are positioned before other Scheme definitions and expressions in the
file.
<LI>
Any conditionally <CODE>require</CODE>d SLIB modules
<A NAME="DOCF1" HREF="slib_fot.html#FOOT1">(1)</A>
also appear at the beginning of their files conditioned on the feature
<A NAME="IDX36"></A>
<CODE>compiling</CODE> using <CODE>require-if</CODE>
(see section <A HREF="slib_1.html#SEC3">require-if</A>).
<P>
<TABLE><tr><td> </td><td class=example><pre>(require 'logical)
(require 'multiarg/and-)
(require-if 'compiling 'sort)
(require-if 'compiling 'ciexyz)
</pre></td></tr></table><P>
</P>
<LI>
Schmooz-style comments preceding a definition, identify that
definition as an exported identifier (see section <A HREF="slib_4.html#SEC87">4.14 Schmooz</A>). For
non-schmooz files, putting `<SAMP>;@</SAMP>' at the beginning of the line
immediately preceding the definition (<CODE>define</CODE>,
<CODE>define-syntax</CODE>, or <CODE>defmacro</CODE>) suffices.
<P>
<TABLE><tr><td> </td><td class=example><pre>;@
(define (make-vicinity <pathname>) <pathname>)
</pre></td></tr></table><P>
</P>
<LI>
Syntax (macro) definitions are grouped at the end of a module file.
<P>
</P>
<LI>
Modules defining macros do not invoke those macros. SLIB macro
implementations are exempt from this rule.
<P>
An example of how to expand macro invocations is:
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(require 'macros-that-work)
(require 'yasos)
(require 'pprint-file)
(pprint-filter-file "collect.scm" macwork:expand)
</pre></td></tr></table><P>
</UL>
<P>
<A NAME="Module Manifests"></A>
<HR SIZE="6">
<A NAME="SEC9"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC8"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC10"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 1.6.2 Module Manifests </H3>
<!--docid::SEC9::-->
<P>
<CODE>(require 'manifest)</CODE>
<A NAME="IDX37"></A>
</P>
<P>
In some of these examples, <VAR>slib:catalog</VAR> is the SLIB part of
the catalog; it is free of compiled and implementation-specific
entries. It would be defined by:
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(define slib:catalog (cdr (member (assq 'null *catalog*) *catalog*)))
</pre></td></tr></table><P>
<A NAME="IDX38"></A>
</P>
<DL>
<DT><U>Function:</U> <B>file->requires</B> <I>file provided? catalog</I>
<DD><P>
Returns a list of the features <CODE>require</CODE>d by <VAR>file</VAR> assuming the
predicate <VAR>provided?</VAR> and association-list <VAR>catalog</VAR>.
</P>
</DL>
<TABLE><tr><td> </td><td class=example><pre>(define (provided+? . features)
(lambda (feature)
(or (memq feature features) (provided? feature))))
(file->requires "obj2str.scm" (provided+? 'compiling) '())
=> (string-port generic-write)
(file->requires "obj2str.scm" provided? '())
=> (string-port)
</pre></td></tr></table><P>
<A NAME="IDX39"></A>
</P>
<DL>
<DT><U>Function:</U> <B>feature->requires</B> <I>feature provided? catalog</I>
<DD><P>
Returns a list of the features <CODE>require</CODE>d by <VAR>feature</VAR> assuming the
predicate <VAR>provided?</VAR> and association-list <VAR>catalog</VAR>.
</P>
</DL>
<TABLE><tr><td> </td><td class=example><pre>(feature->requires 'batch (provided+? 'compiling) *catalog*)
=> (tree line-i/o databases parameters string-port
pretty-print common-list-functions posix-time)
(feature->requires 'batch provided? *catalog*)
=> (tree line-i/o databases parameters string-port
pretty-print common-list-functions)
(feature->requires 'batch provided? '((batch . "batch")))
=> (tree line-i/o databases parameters string-port
pretty-print common-list-functions)
</pre></td></tr></table><P>
<A NAME="IDX40"></A>
</P>
<DL>
<DT><U>Function:</U> <B>file->loads</B> <I>file</I>
<DD><P>
Returns a list of strings naming existing files loaded (load
slib:load slib:load-source macro:load defmacro:load syncase:load
synclo:load macwork:load) by <VAR>file</VAR> or any of the files it loads.
</P>
</DL>
<TABLE><tr><td> </td><td class=example><pre>(file->loads (in-vicinity (library-vicinity) "scainit.scm"))
=> ("/usr/local/lib/slib/scaexpp.scm"
"/usr/local/lib/slib/scaglob.scm"
"/usr/local/lib/slib/scaoutp.scm")
</pre></td></tr></table><P>
<A NAME="IDX41"></A>
</P>
<DL>
<DT><U>Function:</U> <B>load->path</B> <I>exp</I>
<DD><P>
Given a <CODE>(load '<expr>)</CODE>, where <expr> is a string or vicinity
stuff), <CODE>(load->path <expr>)</CODE> figures a path to the file.
<CODE>load->path</CODE> returns that path if it names an existing file; otherwise #f.
</P>
</DL>
<TABLE><tr><td> </td><td class=example><pre>(load->path '(in-vicinity (library-vicinity) "mklibcat"))
=> "/usr/local/lib/slib/mklibcat.scm"
</pre></td></tr></table><P>
<A NAME="IDX42"></A>
</P>
<DL>
<DT><U>Function:</U> <B>file->definitions</B> <I>file</I>
<DD><P>
Returns a list of the identifier symbols defined by SLIB (or
SLIB-style) file <VAR>file</VAR>.
</P>
</DL>
<TABLE><tr><td> </td><td class=example><pre>(file->definitions "random.scm")
=> (*random-state* make-random-state
seed->random-state copy-random-state random
random:chunk)
</pre></td></tr></table><P>
<A NAME="IDX43"></A>
</P>
<DL>
<DT><U>Function:</U> <B>file->exports</B> <I>file</I>
<DD><P>
Returns a list of the identifier symbols exported (advertised) by
SLIB (or SLIB-style) file <VAR>file</VAR>.
</P>
</DL>
<TABLE><tr><td> </td><td class=example><pre>(file->exports "random.scm")
=> (make-random-state seed->random-state
copy-random-state random)
(file->exports "randinex.scm")
=> (random:solid-sphere! random:hollow-sphere!
random:normal-vector! random:normal
random:exp random:uniform)
</pre></td></tr></table><P>
<A NAME="IDX44"></A>
</P>
<DL>
<DT><U>Function:</U> <B>feature->export-alist</B> <I>feature catalog</I>
<DD><P>
Returns a list of lists; each sublist holding the name of the file
implementing <VAR>feature</VAR>, and the identifier symbols exported (advertised) by
SLIB (or SLIB-style) feature <VAR>feature</VAR>, in <VAR>catalog</VAR>.
</P>
</DL>
<P>
<A NAME="IDX45"></A>
</P>
<DL>
<DT><U>Function:</U> <B>feature->exports</B> <I>feature catalog</I>
<DD><P>
Returns a list of all exports of <VAR>feature</VAR>.
</P>
</DL>
In the case of <CODE>aggregate</CODE> features, more than one file may
have export lists to report:
<P>
<TABLE><tr><td> </td><td class=example><pre>(feature->export-alist 'r5rs slib:catalog))
=> (("/usr/local/lib/slib/values.scm"
call-with-values values)
("/usr/local/lib/slib/mbe.scm"
define-syntax macro:expand
macro:load macro:eval)
("/usr/local/lib/slib/eval.scm"
eval scheme-report-environment
null-environment interaction-environment))
(feature->export-alist 'stdio *catalog*)
=> (("/usr/local/lib/slib/scanf.scm"
fscanf sscanf scanf scanf-read-list)
("/usr/local/lib/slib/printf.scm"
sprintf printf fprintf)
("/usr/local/lib/slib/stdio.scm"
stderr stdout stdin))
(feature->exports 'stdio slib:catalog)
=> (fscanf sscanf scanf scanf-read-list
sprintf printf fprintf stderr stdout stdin)
</pre></td></tr></table><P>
<A NAME="Module Semantics"></A>
<HR SIZE="6">
<A NAME="SEC10"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC9"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC11"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 1.6.3 Module Semantics </H3>
<!--docid::SEC10::-->
<P>
For the purpose of compiling Scheme code, each top-level
<CODE>require</CODE> makes the identifiers exported by its feature's module
<CODE>defined</CODE> (or defmacroed or defined-syntaxed) within the file
(being compiled) headed with those requires.
</P>
<P>
Top-level occurrences of <CODE>require-if</CODE> make defined the exports
from the module named by the second argument <EM>if</EM> the
<VAR>feature-expression</VAR> first argument is true in the target
environment. The target feature <CODE>compiling</CODE> should be provided
during this phase of compilation.
</P>
<P>
Non-top-level SLIB occurences of <CODE>require</CODE> and <CODE>require-if</CODE>
of quoted features can be ignored by compilers. The SLIB modules will
all have top-level constructs for those features.
</P>
<P>
<A NAME="IDX46"></A>
Note that aggregate catalog entries import more than one module.
Implementations of <CODE>require</CODE> may or may <EM>not</EM> be transitive;
code which uses module exports without requiring the providing module
is in error.
</P>
<P>
In the SLIB modules <CODE>modular</CODE>, <CODE>batch</CODE>, <CODE>hash</CODE>,
<CODE>common-lisp-time</CODE>, <CODE>commutative-ring</CODE>, <CODE>charplot</CODE>,
<CODE>logical</CODE>, <CODE>common-list-functions</CODE>, <CODE>coerce</CODE> and
<CODE>break</CODE> there is code conditional on features being
<CODE>provided?</CODE>. Most are testing for the presence of features which
are intrinsic to implementations (inexacts, bignums, ...).
</P>
<P>
In all cases these <CODE>provided?</CODE> tests can be evaluated at
compile-time using <CODE>feature-eval</CODE>
(see section <A HREF="slib_1.html#SEC2">feature-eval</A>). The simplest way to compile these
constructs may be to treat <CODE>provided?</CODE> as a macro.
</P>
<P>
<A NAME="Top-level Variable References"></A>
<HR SIZE="6">
<A NAME="SEC11"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC10"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC12"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 1.6.4 Top-level Variable References </H3>
<!--docid::SEC11::-->
<P>
<CODE>(require 'top-refs)</CODE>
<A NAME="IDX47"></A>
<A NAME="IDX48"></A>
<A NAME="IDX49"></A>
</P>
<P>
These procedures complement those in <A HREF="slib_1.html#SEC9">1.6.2 Module Manifests</A> by
finding the top-level variable references in Scheme source code.
They work by traversing expressions and definitions, keeping track
of bindings encountered. It is certainly possible to foil these
functions, but they return useful information about SLIB source
code.
</P>
<P>
<A NAME="IDX50"></A>
</P>
<DL>
<DT><U>Function:</U> <B>top-refs</B> <I>obj</I>
<DD><P>
Returns a list of the top-level variables referenced by the Scheme
expression <VAR>obj</VAR>.
</P>
</DL>
<P>
<A NAME="IDX51"></A>
</P>
<DL>
<DT><U>Function:</U> <B>top-refs<-file</B> <I>filename</I>
<DD><P>
<VAR>filename</VAR> should be a string naming an existing file containing Scheme
source code. <CODE>top-refs<-file</CODE> returns a list of the top-level variable references
made by expressions in the file named by <VAR>filename</VAR>.
</P>
<P>
Code in modules which <VAR>filename</VAR> <CODE>require</CODE>s is not traversed. Code in
files loaded from top-level <EM>is</EM> traversed if the expression
argument to <CODE>load</CODE>, <CODE>slib:load</CODE>, <CODE>slib:load-source</CODE>,
<CODE>macro:load</CODE>, <CODE>defmacro:load</CODE>, <CODE>synclo:load</CODE>,
<CODE>syncase:load</CODE>, or <CODE>macwork:load</CODE> is a literal string
constant or composed of combinations of vicinity functions and
string literal constants; and the resulting file exists (possibly
with ".scm" appended).
</P>
</DL>
The following function parses an <EM>Info</EM> Index.
<A NAME="IDX52"></A>
<A NAME="DOCF2" HREF="slib_fot.html#FOOT2">(2)</A>
<P>
<A NAME="IDX53"></A>
</P>
<DL>
<DT><U>Function:</U> <B>exports<-info-index</B> <I>file n <small>...</small></I>
<DD><P>
<VAR>n</VAR> <small>...</small> must be an increasing series of positive integers.
<CODE>exports<-info-index</CODE> returns a list of all the identifiers appearing in the <VAR>n</VAR>th
<small>...</small> (info) indexes of <VAR>file</VAR>. The identifiers have the case that
the implementation's <CODE>read</CODE> uses for symbols. Identifiers
containing spaces (eg. <CODE>close-base on base-table</CODE>) are
<EM>not</EM> included.
</P>
<P>
Each info index is headed by a `<SAMP>* Menu:</SAMP>' line. To list the
symbols in the first and third info indexes do:
</P>
<P>
<TABLE><tr><td> </td><td class=example><pre>(exports<-info-index "slib.info" 1 3)
</pre></td></tr></table></DL>
<P>
<A NAME="Module Analysis"></A>
<HR SIZE="6">
<A NAME="SEC12"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC11"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 1.6.5 Module Analysis </H3>
<!--docid::SEC12::-->
<P>
<CODE>(require 'vet)</CODE>
<A NAME="IDX54"></A>
</P>
<P>
<A NAME="IDX55"></A>
</P>
<DL>
<DT><U>Function:</U> <B>vet-slib</B>
<DD><P>
Using the procedures in the <CODE>top-refs</CODE> and <CODE>manifest</CODE>
modules, <CODE>vet-slib</CODE> analyzes each SLIB module, reporting about any
procedure or macro defined whether it is:
</P>
<P>
</P>
<DL COMPACT>
<DT>orphaned
<DD>defined, not called, not exported;
<DT>missing
<DD>called, not defined, and not exported by its <CODE>require</CODE>d modules;
<DT>undocumented-export
<DD>Exported by module, but no index entry in `<TT>slib.info</TT>';
<P>
</DL>
<P>
And for the library as a whole:
</P>
<P>
</P>
<DL COMPACT>
<DT>documented-unexport
<DD>Index entry in `<TT>slib.info</TT>', but no module exports it.
<P>
</DL>
<P>
This straightforward analysis caught three full days worth of
never-executed branches, transitive require assumptions, spelling
errors, undocumented procedures, missing procedures, and cyclic
dependencies in SLIB.
</P>
</DL>
<P>
<A NAME="Universal SLIB Procedures"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_1.html#SEC1"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_2.html#SEC13"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Steve Langasek</I> on <I>January, 10 2005</I>
using <A HREF="http://texi2html.cvshome.org"><I>texi2html</I></A>
</FONT>
</BODY>
</HTML>
|