*** empty log message ***
[bpt/guile.git] / doc / maint / guile.texi
CommitLineData
780ee65e
NJ
1@paragraphindent 0
2
3\facons
4@c snarfed from alist.c:60
5@deffn primitive acons key value alist
6Adds a new key-value pair to @var{alist}. A new pair is
7created whose car is @var{key} and whose cdr is @var{value}, and the
8pair is consed onto @var{alist}, and the new list is returned. This
9function is @emph{not} destructive; @var{alist} is not modified.
10@end deffn
11
12\fsloppy-assq
13@c snarfed from alist.c:83
14@deffn primitive sloppy-assq key alist
15Behaves like @code{assq} but does not do any error checking.
16Recommended only for use in Guile internals.
17@end deffn
18
19\fsloppy-assv
20@c snarfed from alist.c:101
21@deffn primitive sloppy-assv key alist
22Behaves like @code{assv} but does not do any error checking.
23Recommended only for use in Guile internals.
24@end deffn
25
26\fsloppy-assoc
27@c snarfed from alist.c:119
28@deffn primitive sloppy-assoc key alist
29Behaves like @code{assoc} but does not do any error checking.
30Recommended only for use in Guile internals.
31@end deffn
32
33\fassq
34@c snarfed from alist.c:146
35@deffn primitive assq key alist
36@deffnx primitive assv key alist
37@deffnx primitive assoc key alist
38Fetches the entry in @var{alist} that is associated with @var{key}. To
39decide whether the argument @var{key} matches a particular entry in
40@var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv}
41uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key}
42cannot be found in @var{alist} (according to whichever equality
43predicate is in use), then @code{#f} is returned. These functions
44return the entire alist entry found (i.e. both the key and the value).
45@end deffn
46
47\fassv
48@c snarfed from alist.c:167
49@deffn primitive assv key alist
50Behaves like @code{assq} but uses @code{eqv?} for key comparison.
51@end deffn
52
53\fassoc
54@c snarfed from alist.c:188
55@deffn primitive assoc key alist
56Behaves like @code{assq} but uses @code{equal?} for key comparison.
57@end deffn
58
59\fassq-ref
60@c snarfed from alist.c:232
61@deffn primitive assq-ref alist key
62@deffnx primitive assv-ref alist key
63@deffnx primitive assoc-ref alist key
64Like @code{assq}, @code{assv} and @code{assoc}, except that only the
65value associated with @var{key} in @var{alist} is returned. These
66functions are equivalent to
67
68@lisp
69(let ((ent (@var{associator} @var{key} @var{alist})))
70 (and ent (cdr ent)))
71@end lisp
72
73where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}.
74@end deffn
75
76\fassv-ref
77@c snarfed from alist.c:249
78@deffn primitive assv-ref alist key
79Behaves like @code{assq-ref} but uses @code{eqv?} for key comparison.
80@end deffn
81
82\fassoc-ref
83@c snarfed from alist.c:266
84@deffn primitive assoc-ref alist key
85Behaves like @code{assq-ref} but uses @code{equal?} for key comparison.
86@end deffn
87
88\fassq-set!
89@c snarfed from alist.c:295
90@deffn primitive assq-set! alist key val
91@deffnx primitive assv-set! alist key value
92@deffnx primitive assoc-set! alist key value
93Reassociate @var{key} in @var{alist} with @var{value}: find any existing
94@var{alist} entry for @var{key} and associate it with the new
95@var{value}. If @var{alist} does not contain an entry for @var{key},
96add a new one. Return the (possibly new) alist.
97
98These functions do not attempt to verify the structure of @var{alist},
99and so may cause unusual results if passed an object that is not an
100association list.
101@end deffn
102
103\fassv-set!
104@c snarfed from alist.c:313
105@deffn primitive assv-set! alist key val
106Behaves like @code{assq-set!} but uses @code{eqv?} for key comparison.
107@end deffn
108
109\fassoc-set!
110@c snarfed from alist.c:331
111@deffn primitive assoc-set! alist key val
112Behaves like @code{assq-set!} but uses @code{equal?} for key comparison.
113@end deffn
114
115\fassq-remove!
116@c snarfed from alist.c:355
117@deffn primitive assq-remove! alist key
118@deffnx primitive assv-remove! alist key
119@deffnx primitive assoc-remove! alist key
120Delete the first entry in @var{alist} associated with @var{key}, and return
121the resulting alist.
122@end deffn
123
124\fassv-remove!
125@c snarfed from alist.c:371
126@deffn primitive assv-remove! alist key
127Behaves like @code{assq-remove!} but uses @code{eqv?} for key comparison.
128@end deffn
129
130\fassoc-remove!
131@c snarfed from alist.c:387
132@deffn primitive assoc-remove! alist key
133Behaves like @code{assq-remove!} but uses @code{equal?} for key comparison.
134@end deffn
135
136\fmake-arbiter
137@c snarfed from arbiters.c:84
138@deffn primitive make-arbiter name
139Return an object of type arbiter and name @var{name}. Its
140state is initially unlocked. Arbiters are a way to achieve
141process synchronization.
142@end deffn
143
144\ftry-arbiter
145@c snarfed from arbiters.c:94
146@deffn primitive try-arbiter arb
147Return @code{#t} and lock the arbiter @var{arb} if the arbiter
148was unlocked. Otherwise, return @code{#f}.
149@end deffn
150
151\frelease-arbiter
152@c snarfed from arbiters.c:115
153@deffn primitive release-arbiter arb
154Return @code{#t} and unlock the arbiter @var{arb} if the
155arbiter was locked. Otherwise, return @code{#f}.
156@end deffn
157
158\fasync
159@c snarfed from async.c:290
160@deffn primitive async thunk
161Create a new async for the procedure @var{thunk}.
162@end deffn
163
164\fsystem-async
165@c snarfed from async.c:300
166@deffn primitive system-async thunk
167Create a new async for the procedure @var{thunk}. Also
168add it to the system's list of active async objects.
169@end deffn
170
171\fasync-mark
89d04205 172@c snarfed from async.c:311
780ee65e
NJ
173@deffn primitive async-mark a
174Mark the async @var{a} for future execution.
175@end deffn
176
177\fsystem-async-mark
89d04205 178@c snarfed from async.c:327
780ee65e
NJ
179@deffn primitive system-async-mark a
180Mark the async @var{a} for future execution.
181@end deffn
182
183\frun-asyncs
89d04205 184@c snarfed from async.c:347
780ee65e
NJ
185@deffn primitive run-asyncs list_of_a
186Execute all thunks from the asyncs of the list @var{list_of_a}.
187@end deffn
188
189\fnoop
89d04205 190@c snarfed from async.c:381
780ee65e
NJ
191@deffn primitive noop . args
192Do nothing. When called without arguments, return @code{#f},
193otherwise return the first argument.
194@end deffn
195
196\funmask-signals
89d04205 197@c snarfed from async.c:433
780ee65e
NJ
198@deffn primitive unmask-signals
199Unmask signals. The returned value is not specified.
200@end deffn
201
202\fmask-signals
89d04205 203@c snarfed from async.c:444
780ee65e
NJ
204@deffn primitive mask-signals
205Mask signals. The returned value is not specified.
206@end deffn
207
208\fdisplay-error
209@c snarfed from backtrace.c:262
210@deffn primitive display-error stack port subr message args rest
211Display an error message to the output port @var{port}.
212@var{stack} is the saved stack for the error, @var{subr} is
213the name of the procedure in which the error occured and
214@var{message} is the actual error message, which may contain
215formatting instructions. These will format the arguments in
216the list @var{args} accordingly. @var{rest} is currently
217ignored.
218@end deffn
219
220\fdisplay-application
221@c snarfed from backtrace.c:399
222@deffn primitive display-application frame [port [indent]]
223Display a procedure application @var{frame} to the output port
224@var{port}. @var{indent} specifies the indentation of the
225output.
226@end deffn
227
228\fdisplay-backtrace
89d04205 229@c snarfed from backtrace.c:619
780ee65e
NJ
230@deffn primitive display-backtrace stack port [first [depth]]
231Display a backtrace to the output port @var{port}. @var{stack}
232is the stack to take the backtrace from, @var{first} specifies
233where in the stack to start and @var{depth} how much frames
234to display. Both @var{first} and @var{depth} can be @code{#f},
235which means that default values will be used.
236@end deffn
237
238\fbacktrace
89d04205 239@c snarfed from backtrace.c:642
780ee65e
NJ
240@deffn primitive backtrace
241Display a backtrace of the stack saved by the last error
242to the current output port.
243@end deffn
244
245\fnot
246@c snarfed from boolean.c:56
247@deffn primitive not x
248Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}.
249@end deffn
250
251\fboolean?
252@c snarfed from boolean.c:66
253@deffn primitive boolean? obj
254Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}.
255@end deffn
256
257\fchar?
258@c snarfed from chars.c:56
259@deffn primitive char? x
260Return @code{#t} iff @var{x} is a character, else @code{#f}.
261@end deffn
262
263\fchar=?
264@c snarfed from chars.c:65
265@deffn primitive char=? x y
266Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}.
267@end deffn
268
269\fchar<?
270@c snarfed from chars.c:78
271@deffn primitive char<? x y
272Return @code{#t} iff @var{x} is less than @var{y} in the ASCII sequence,
273else @code{#f}.
274@end deffn
275
276\fchar<=?
277@c snarfed from chars.c:90
278@deffn primitive char<=? x y
279Return @code{#t} iff @var{x} is less than or equal to @var{y} in the
280ASCII sequence, else @code{#f}.
281@end deffn
282
283\fchar>?
284@c snarfed from chars.c:102
285@deffn primitive char>? x y
286Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII
287sequence, else @code{#f}.
288@end deffn
289
290\fchar>=?
291@c snarfed from chars.c:114
292@deffn primitive char>=? x y
293Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the
294ASCII sequence, else @code{#f}.
295@end deffn
296
297\fchar-ci=?
298@c snarfed from chars.c:126
299@deffn primitive char-ci=? x y
300Return @code{#t} iff @var{x} is the same character as @var{y} ignoring
301case, else @code{#f}.
302@end deffn
303
304\fchar-ci<?
305@c snarfed from chars.c:138
306@deffn primitive char-ci<? x y
307Return @code{#t} iff @var{x} is less than @var{y} in the ASCII sequence
308ignoring case, else @code{#f}.
309@end deffn
310
311\fchar-ci<=?
312@c snarfed from chars.c:150
313@deffn primitive char-ci<=? x y
314Return @code{#t} iff @var{x} is less than or equal to @var{y} in the
315ASCII sequence ignoring case, else @code{#f}.
316@end deffn
317
318\fchar-ci>?
319@c snarfed from chars.c:162
320@deffn primitive char-ci>? x y
321Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII
322sequence ignoring case, else @code{#f}.
323@end deffn
324
325\fchar-ci>=?
326@c snarfed from chars.c:174
327@deffn primitive char-ci>=? x y
328Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the
329ASCII sequence ignoring case, else @code{#f}.
330@end deffn
331
332\fchar-alphabetic?
333@c snarfed from chars.c:187
334@deffn primitive char-alphabetic? chr
335Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}.
336Alphabetic means the same thing as the isalpha C library function.
337@end deffn
338
339\fchar-numeric?
340@c snarfed from chars.c:198
341@deffn primitive char-numeric? chr
342Return @code{#t} iff @var{chr} is numeric, else @code{#f}.
343Numeric means the same thing as the isdigit C library function.
344@end deffn
345
346\fchar-whitespace?
347@c snarfed from chars.c:209
348@deffn primitive char-whitespace? chr
349Return @code{#t} iff @var{chr} is whitespace, else @code{#f}.
350Whitespace means the same thing as the isspace C library function.
351@end deffn
352
353\fchar-upper-case?
354@c snarfed from chars.c:222
355@deffn primitive char-upper-case? chr
356Return @code{#t} iff @var{chr} is uppercase, else @code{#f}.
357Uppercase means the same thing as the isupper C library function.
358@end deffn
359
360\fchar-lower-case?
361@c snarfed from chars.c:234
362@deffn primitive char-lower-case? chr
363Return @code{#t} iff @var{chr} is lowercase, else @code{#f}.
364Lowercase means the same thing as the islower C library function.
365@end deffn
366
367\fchar-is-both?
368@c snarfed from chars.c:248
369@deffn primitive char-is-both? chr
370Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}.
371Uppercase and lowercase are as defined by the isupper and islower
372C library functions.
373@end deffn
374
375\fchar->integer
376@c snarfed from chars.c:262
377@deffn primitive char->integer chr
378Return the number corresponding to ordinal position of @var{chr} in the
379ASCII sequence.
380@end deffn
381
382\finteger->char
383@c snarfed from chars.c:274
384@deffn primitive integer->char n
385Return the character at position @var{n} in the ASCII sequence.
386@end deffn
387
388\fchar-upcase
389@c snarfed from chars.c:285
390@deffn primitive char-upcase chr
391Return the uppercase character version of @var{chr}.
392@end deffn
393
394\fchar-downcase
395@c snarfed from chars.c:296
396@deffn primitive char-downcase chr
397Return the lowercase character version of @var{chr}.
398@end deffn
399
400\fdebug-options-interface
401@c snarfed from debug.c:80
402@deffn primitive debug-options-interface [setting]
403Option interface for the debug options. Instead of using
404this procedure directly, use the procedures @code{debug-enable},
405@code{debug-disable}, @code{debug-set!} and @var{debug-options}.
406@end deffn
407
408\fwith-traps
409@c snarfed from debug.c:128
410@deffn primitive with-traps thunk
411Call @var{thunk} with traps enabled.
412@end deffn
413
414\fmemoized?
415@c snarfed from debug.c:170
416@deffn primitive memoized? obj
417Return @code{#t} if @var{obj} is memoized.
418@end deffn
419
420\funmemoize
421@c snarfed from debug.c:376
422@deffn primitive unmemoize m
423Unmemoize the memoized expression @var{m},
424@end deffn
425
426\fmemoized-environment
427@c snarfed from debug.c:386
428@deffn primitive memoized-environment m
429Return the environment of the memoized expression @var{m}.
430@end deffn
431
432\fprocedure-name
433@c snarfed from debug.c:396
434@deffn primitive procedure-name proc
435Return the name of the procedure @var{proc}
436@end deffn
437
438\fprocedure-source
439@c snarfed from debug.c:422
440@deffn primitive procedure-source proc
441Return the source of the procedure @var{proc}.
442@end deffn
443
444\fprocedure-environment
72ad43dc 445@c snarfed from debug.c:455
780ee65e
NJ
446@deffn primitive procedure-environment proc
447Return the environment of the procedure @var{proc}.
448@end deffn
449
450\flocal-eval
72ad43dc 451@c snarfed from debug.c:487
780ee65e
NJ
452@deffn primitive local-eval exp [env]
453Evaluate @var{exp} in its environment. If @var{env} is supplied,
454it is the environment in which to evaluate @var{exp}. Otherwise,
455@var{exp} must be a memoized code object (in which case, its environment
456is implicit).
457@end deffn
458
459\fdebug-object?
72ad43dc 460@c snarfed from debug.c:574
780ee65e
NJ
461@deffn primitive debug-object? obj
462Return @code{#t} if @var{obj} is a debug object.
463@end deffn
464
465\fc-registered-modules
466@c snarfed from dynl.c:183
467@deffn primitive c-registered-modules
468Return a list of the object code modules that have been imported into
469the current Guile process. Each element of the list is a pair whose
470car is the name of the module, and whose cdr is the function handle
471for that module's initializer function. The name is the string that
472has been passed to scm_register_module_xxx.
473@end deffn
474
475\fc-clear-registered-modules
476@c snarfed from dynl.c:204
477@deffn primitive c-clear-registered-modules
478Destroy the list of modules registered with the current Guile process.
479The return value is unspecified. @strong{Warning:} this function does
480not actually unlink or deallocate these modules, but only destroys the
481records of which modules have been loaded. It should therefore be used
482only by module bookkeeping operations.
483@end deffn
484
485\fdynamic-link
89d04205 486@c snarfed from dynl.c:357
ae9f3a15
MG
487@deffn primitive dynamic-link filename
488Open the dynamic library called @var{filename}. A library
489handle representing the opened library is returned; this handle
490should be used as the @var{dobj} argument to the following
491functions.
780ee65e
NJ
492@end deffn
493
494\fdynamic-object?
89d04205 495@c snarfed from dynl.c:373
780ee65e
NJ
496@deffn primitive dynamic-object? obj
497Return @code{#t} if @var{obj} is a dynamic library handle, or @code{#f}
498otherwise.
499@end deffn
500
501\fdynamic-unlink
89d04205 502@c snarfed from dynl.c:386
780ee65e 503@deffn primitive dynamic-unlink dobj
780ee65e 504Unlink the indicated object file from the application. The
ae9f3a15 505argument @var{dobj} must have been obtained by a call to
780ee65e 506@code{dynamic-link}. After @code{dynamic-unlink} has been
ae9f3a15 507called on @var{dobj}, its content is no longer accessible.
780ee65e
NJ
508@end deffn
509
510\fdynamic-func
89d04205 511@c snarfed from dynl.c:413
780ee65e
NJ
512@deffn primitive dynamic-func name dobj
513Search the dynamic object @var{dobj} for the C function
514indicated by the string @var{name} and return some Scheme
515handle that can later be used with @code{dynamic-call} to
516actually call the function.
517
518Regardless whether your C compiler prepends an underscore @samp{_} to
519the global names in a program, you should @strong{not} include this
520underscore in @var{function}. Guile knows whether the underscore is
521needed or not and will add it when necessary.
522@end deffn
523
524\fdynamic-call
89d04205 525@c snarfed from dynl.c:453
780ee65e 526@deffn primitive dynamic-call func dobj
ae9f3a15
MG
527Call the C function indicated by @var{func} and @var{dobj}.
528The function is passed no arguments and its return value is
529ignored. When @var{function} is something returned by
530@code{dynamic-func}, call that function and ignore @var{dobj}.
531When @var{func} is a string , look it up in @var{dynobj}; this
532is equivalent to
780ee65e 533@smallexample
ae9f3a15 534(dynamic-call (dynamic-func @var{func} @var{dobj} #f))
780ee65e
NJ
535@end smallexample
536
537Interrupts are deferred while the C function is executing (with
538@code{SCM_DEFER_INTS}/@code{SCM_ALLOW_INTS}).
539@end deffn
540
541\fdynamic-args-call
89d04205 542@c snarfed from dynl.c:481
780ee65e 543@deffn primitive dynamic-args-call func dobj args
ae9f3a15
MG
544Call the C function indicated by @var{func} and @var{dobj},
545just like @code{dynamic-call}, but pass it some arguments and
546return its return value. The C function is expected to take
547two arguments and return an @code{int}, just like @code{main}:
780ee65e
NJ
548@smallexample
549int c_func (int argc, char **argv);
550@end smallexample
551
ae9f3a15
MG
552The parameter @var{args} must be a list of strings and is
553converted into an array of @code{char *}. The array is passed
554in @var{argv} and its size in @var{argc}. The return value is
555converted to a Scheme number and returned from the call to
556@code{dynamic-args-call}.
780ee65e
NJ
557@end deffn
558
559\fdynamic-wind
89d04205 560@c snarfed from dynwind.c:121
ae9f3a15 561@deffn primitive dynamic-wind in_guard thunk out_guard
780ee65e 562All three arguments must be 0-argument procedures.
ae9f3a15
MG
563@var{in_guard} is called, then @var{thunk}, then
564@var{out_guard}.
565If, any time during the execution of @var{thunk}, the
566continuation of the @code{dynamic_wind} expression is escaped
567non-locally, @var{out_guard} is called. If the continuation of
568the dynamic-wind is re-entered, @var{in_guard} is called. Thus
569@var{in_guard} and @var{out_guard} may be called any number of
570times.
571@lisp
780ee65e
NJ
572(define x 'normal-binding)
573@result{} x
780ee65e
NJ
574(define a-cont (call-with-current-continuation
575 (lambda (escape)
576 (let ((old-x x))
577 (dynamic-wind
578 ;; in-guard:
579 ;;
580 (lambda () (set! x 'special-binding))
780ee65e
NJ
581 ;; thunk
582 ;;
583 (lambda () (display x) (newline)
584 (call-with-current-continuation escape)
585 (display x) (newline)
586 x)
780ee65e
NJ
587 ;; out-guard:
588 ;;
589 (lambda () (set! x old-x)))))))
780ee65e
NJ
590;; Prints:
591special-binding
592;; Evaluates to:
593@result{} a-cont
780ee65e
NJ
594x
595@result{} normal-binding
780ee65e
NJ
596(a-cont #f)
597;; Prints:
598special-binding
599;; Evaluates to:
600@result{} a-cont ;; the value of the (define a-cont...)
780ee65e
NJ
601x
602@result{} normal-binding
780ee65e
NJ
603a-cont
604@result{} special-binding
ae9f3a15 605@end lisp
780ee65e
NJ
606@end deffn
607
608\fenvironment?
609@c snarfed from environments.c:135
610@deffn primitive environment? obj
611Return @code{#t} if @var{obj} is an environment, or @code{#f}
612otherwise.
613@end deffn
614
615\fenvironment-bound?
616@c snarfed from environments.c:146
617@deffn primitive environment-bound? env sym
618Return @code{#t} if @var{sym} is bound in @var{env}, or
619@code{#f} otherwise.
620@end deffn
621
622\fenvironment-ref
623@c snarfed from environments.c:161
624@deffn primitive environment-ref env sym
625Return the value of the location bound to @var{sym} in
626@var{env}. If @var{sym} is unbound in @var{env}, signal an
627@code{environment:unbound} error.
628@end deffn
629
630\fenvironment-fold
631@c snarfed from environments.c:231
632@deffn primitive environment-fold env proc init
633Iterate over all the bindings in @var{env}, accumulating some
634value.
635For each binding in @var{env}, apply @var{proc} to the symbol
636bound, its value, and the result from the previous application
637of @var{proc}.
638Use @var{init} as @var{proc}'s third argument the first time
639@var{proc} is applied.
640If @var{env} contains no bindings, this function simply returns
641@var{init}.
642If @var{env} binds the symbol sym1 to the value val1, sym2 to
643val2, and so on, then this procedure computes:
ae9f3a15 644@lisp
780ee65e
NJ
645 (proc sym1 val1
646 (proc sym2 val2
647 ...
648 (proc symn valn
649 init)))
ae9f3a15 650@end lisp
780ee65e
NJ
651Each binding in @var{env} will be processed exactly once.
652@code{environment-fold} makes no guarantees about the order in
653which the bindings are processed.
654Here is a function which, given an environment, constructs an
655association list representing that environment's bindings,
656using environment-fold:
ae9f3a15 657@lisp
780ee65e
NJ
658 (define (environment->alist env)
659 (environment-fold env
660 (lambda (sym val tail)
661 (cons (cons sym val) tail))
662 '()))
ae9f3a15 663@end lisp
780ee65e
NJ
664@end deffn
665
666\fenvironment-define
667@c snarfed from environments.c:266
668@deffn primitive environment-define env sym val
669Bind @var{sym} to a new location containing @var{val} in
670@var{env}. If @var{sym} is already bound to another location
671in @var{env} and the binding is mutable, that binding is
672replaced. The new binding and location are both mutable. The
673return value is unspecified.
674If @var{sym} is already bound in @var{env}, and the binding is
675immutable, signal an @code{environment:immutable-binding} error.
676@end deffn
677
678\fenvironment-undefine
679@c snarfed from environments.c:292
680@deffn primitive environment-undefine env sym
681Remove any binding for @var{sym} from @var{env}. If @var{sym}
682is unbound in @var{env}, do nothing. The return value is
683unspecified.
684If @var{sym} is already bound in @var{env}, and the binding is
685immutable, signal an @code{environment:immutable-binding} error.
686@end deffn
687
688\fenvironment-set!
689@c snarfed from environments.c:320
690@deffn primitive environment-set! env sym val
691If @var{env} binds @var{sym} to some location, change that
692location's value to @var{val}. The return value is
693unspecified.
694If @var{sym} is not bound in @var{env}, signal an
695@code{environment:unbound} error. If @var{env} binds @var{sym}
696to an immutable location, signal an
697@code{environment:immutable-location} error.
698@end deffn
699
700\fenvironment-cell
701@c snarfed from environments.c:355
702@deffn primitive environment-cell env sym for_write
703Return the value cell which @var{env} binds to @var{sym}, or
704@code{#f} if the binding does not live in a value cell.
705The argument @var{for-write} indicates whether the caller
706intends to modify the variable's value by mutating the value
707cell. If the variable is immutable, then
708@code{environment-cell} signals an
709@code{environment:immutable-location} error.
710If @var{sym} is unbound in @var{env}, signal an
711@code{environment:unbound} error.
712If you use this function, you should consider using
713@code{environment-observe}, to be notified when @var{sym} gets
714re-bound to a new value cell, or becomes undefined.
715@end deffn
716
717\fenvironment-observe
718@c snarfed from environments.c:407
719@deffn primitive environment-observe env proc
720Whenever @var{env}'s bindings change, apply @var{proc} to
721@var{env}.
722This function returns an object, token, which you can pass to
723@code{environment-unobserve} to remove @var{proc} from the set
724of procedures observing @var{env}. The type and value of
725token is unspecified.
726@end deffn
727
728\fenvironment-observe-weak
729@c snarfed from environments.c:424
730@deffn primitive environment-observe-weak env proc
731This function is the same as environment-observe, except that
732the reference @var{env} retains to @var{proc} is a weak
733reference. This means that, if there are no other live,
734non-weak references to @var{proc}, it will be
735garbage-collected, and dropped from @var{env}'s
736list of observing procedures.
737@end deffn
738
739\fenvironment-unobserve
740@c snarfed from environments.c:460
741@deffn primitive environment-unobserve token
742Cancel the observation request which returned the value
743@var{token}. The return value is unspecified.
744If a call @code{(environment-observe env proc)} returns
745@var{token}, then the call @code{(environment-unobserve token)}
746will cause @var{proc} to no longer be called when @var{env}'s
747bindings change.
748@end deffn
749
750\fmake-leaf-environment
751@c snarfed from environments.c:1040
752@deffn primitive make-leaf-environment
753Create a new leaf environment, containing no bindings.
754All bindings and locations created in the new environment
755will be mutable.
756@end deffn
757
758\fleaf-environment?
759@c snarfed from environments.c:1063
760@deffn primitive leaf-environment? object
761Return @code{#t} if object is a leaf environment, or @code{#f}
762otherwise.
763@end deffn
764
765\fmake-eval-environment
766@c snarfed from environments.c:1429
767@deffn primitive make-eval-environment local imported
768Return a new environment object eval whose bindings are the
769union of the bindings in the environments @var{local} and
770@var{imported}, with bindings from @var{local} taking
771precedence. Definitions made in eval are placed in @var{local}.
772Applying @code{environment-define} or
773@code{environment-undefine} to eval has the same effect as
774applying the procedure to @var{local}.
775Note that eval incorporates @var{local} and @var{imported} by
776reference:
777If, after creating eval, the program changes the bindings of
778@var{local} or @var{imported}, those changes will be visible
779in eval.
780Since most Scheme evaluation takes place in eval environments,
781they transparently cache the bindings received from @var{local}
782and @var{imported}. Thus, the first time the program looks up
783a symbol in eval, eval may make calls to @var{local} or
784@var{imported} to find their bindings, but subsequent
785references to that symbol will be as fast as references to
786bindings in finite environments.
787In typical use, @var{local} will be a finite environment, and
788@var{imported} will be an import environment
789@end deffn
790
791\feval-environment?
792@c snarfed from environments.c:1466
793@deffn primitive eval-environment? object
794Return @code{#t} if object is an eval environment, or @code{#f}
795otherwise.
796@end deffn
797
798\feval-environment-local
799@c snarfed from environments.c:1476
800@deffn primitive eval-environment-local env
801Return the local environment of eval environment @var{env}.
802@end deffn
803
804\feval-environment-set-local!
805@c snarfed from environments.c:1488
806@deffn primitive eval-environment-set-local! env local
807Change @var{env}'s local environment to @var{local}.
808@end deffn
809
810\feval-environment-imported
811@c snarfed from environments.c:1514
812@deffn primitive eval-environment-imported env
813Return the imported environment of eval environment @var{env}.
814@end deffn
815
816\feval-environment-set-imported!
817@c snarfed from environments.c:1526
818@deffn primitive eval-environment-set-imported! env imported
819Change @var{env}'s imported environment to @var{imported}.
820@end deffn
821
822\fmake-import-environment
823@c snarfed from environments.c:1846
824@deffn primitive make-import-environment imports conflict_proc
825Return a new environment @var{imp} whose bindings are the union
826of the bindings from the environments in @var{imports};
827@var{imports} must be a list of environments. That is,
828@var{imp} binds a symbol to a location when some element of
829@var{imports} does.
830If two different elements of @var{imports} have a binding for
831the same symbol, the @var{conflict-proc} is called with the
832following parameters: the import environment, the symbol and
833the list of the imported environments that bind the symbol.
834If the @var{conflict-proc} returns an environment @var{env},
835the conflict is considered as resolved and the binding from
836@var{env} is used. If the @var{conflict-proc} returns some
837non-environment object, the conflict is considered unresolved
838and the symbol is treated as unspecified in the import
839environment.
840The checking for conflicts may be performed lazily, i. e. at
841the moment when a value or binding for a certain symbol is
842requested instead of the moment when the environment is
843created or the bindings of the imports change.
844All bindings in @var{imp} are immutable. If you apply
845@code{environment-define} or @code{environment-undefine} to
846@var{imp}, Guile will signal an
847 @code{environment:immutable-binding} error. However,
848notice that the set of bindings in @var{imp} may still change,
849if one of its imported environments changes.
850@end deffn
851
852\fimport-environment?
853@c snarfed from environments.c:1875
854@deffn primitive import-environment? object
855Return @code{#t} if object is an import environment, or
856@code{#f} otherwise.
857@end deffn
858
859\fimport-environment-imports
860@c snarfed from environments.c:1886
861@deffn primitive import-environment-imports env
862Return the list of environments imported by the import
863environment @var{env}.
864@end deffn
865
866\fimport-environment-set-imports!
867@c snarfed from environments.c:1899
868@deffn primitive import-environment-set-imports! env imports
869Change @var{env}'s list of imported environments to
870@var{imports}, and check for conflicts.
871@end deffn
872
873\fmake-export-environment
874@c snarfed from environments.c:2164
875@deffn primitive make-export-environment private signature
876Return a new environment @var{exp} containing only those
877bindings in private whose symbols are present in
878@var{signature}. The @var{private} argument must be an
879environment.
880
881The environment @var{exp} binds symbol to location when
882@var{env} does, and symbol is exported by @var{signature}.
883
884@var{signature} is a list specifying which of the bindings in
885@var{private} should be visible in @var{exp}. Each element of
886@var{signature} should be a list of the form:
887 (symbol attribute ...)
888where each attribute is one of the following:
889@table @asis
890@item the symbol @code{mutable-location}
891 @var{exp} should treat the
892 location bound to symbol as mutable. That is, @var{exp}
893 will pass calls to @code{environment-set!} or
894 @code{environment-cell} directly through to private.
895@item the symbol @code{immutable-location}
896 @var{exp} should treat
897 the location bound to symbol as immutable. If the program
898 applies @code{environment-set!} to @var{exp} and symbol, or
899 calls @code{environment-cell} to obtain a writable value
900 cell, @code{environment-set!} will signal an
901 @code{environment:immutable-location} error. Note that, even
902 if an export environment treats a location as immutable, the
903 underlying environment may treat it as mutable, so its
904 value may change.
905@end table
906It is an error for an element of signature to specify both
907@code{mutable-location} and @code{immutable-location}. If
908neither is specified, @code{immutable-location} is assumed.
909
910As a special case, if an element of signature is a lone
911symbol @var{sym}, it is equivalent to an element of the form
912@code{(sym)}.
913
914All bindings in @var{exp} are immutable. If you apply
915@code{environment-define} or @code{environment-undefine} to
916@var{exp}, Guile will signal an
917@code{environment:immutable-binding} error. However,
918notice that the set of bindings in @var{exp} may still change,
919if the bindings in private change.
920@end deffn
921
922\fexport-environment?
923@c snarfed from environments.c:2199
924@deffn primitive export-environment? object
925Return @code{#t} if object is an export environment, or
926@code{#f} otherwise.
927@end deffn
928
929\fexport-environment-private
930@c snarfed from environments.c:2209
931@deffn primitive export-environment-private env
932Return the private environment of export environment @var{env}.
933@end deffn
934
935\fexport-environment-set-private!
936@c snarfed from environments.c:2221
937@deffn primitive export-environment-set-private! env private
938Change the private environment of export environment @var{env}.
939@end deffn
940
941\fexport-environment-signature
942@c snarfed from environments.c:2243
943@deffn primitive export-environment-signature env
944Return the signature of export environment @var{env}.
945@end deffn
946
947\fexport-environment-set-signature!
948@c snarfed from environments.c:2317
949@deffn primitive export-environment-set-signature! env signature
950Change the signature of export environment @var{env}.
951@end deffn
952
953\feq?
954@c snarfed from eq.c:64
955@deffn primitive eq? x y
956Return @code{#t} iff @var{x} references the same object as @var{y}.
957@code{eq?} is similar to @code{eqv?} except that in some cases it is
958capable of discerning distinctions finer than those detectable by
959@code{eqv?}.
960@end deffn
961
962\feqv?
963@c snarfed from eq.c:78
964@deffn primitive eqv? x y
965The @code{eqv?} procedure defines a useful equivalence relation on objects.
966Briefly, it returns @code{#t} if @var{x} and @var{y} should normally be
967regarded as the same object. This relation is left slightly open to
968interpretation, but works for comparing immediate integers, characters,
969and inexact numbers.
970@end deffn
971
972\fequal?
973@c snarfed from eq.c:127
974@deffn primitive equal? x y
975Return @code{#t} iff @var{x} and @var{y} are recursively @code{eqv?} equivalent.
976@code{equal?} recursively compares the contents of pairs,
977vectors, and strings, applying @code{eqv?} on other objects such as
978numbers and symbols. A rule of thumb is that objects are generally
979@code{equal?} if they print the same. @code{equal?} may fail to
980terminate if its arguments are circular data structures.
981@end deffn
982
983\fscm-error
89d04205 984@c snarfed from error.c:114
ae9f3a15
MG
985@deffn primitive scm-error key subr message args data
986Raise an error with key @var{key}. @var{subr} can be a string
987naming the procedure associated with the error, or @code{#f}.
988@var{message} is the error message string, possibly containing
989@code{~S} and @code{~A} escapes. When an error is reported,
990these are replaced by formatting the corresponding members of
991@var{args}: @code{~A} (was @code{%s} in older versions of
992Guile) formats using @code{display} and @code{~S} (was
993@code{%S}) formats using @code{write}. @var{data} is a list or
994@code{#f} depending on @var{key}: if @var{key} is
995@code{system-error} then it should be a list containing the
996Unix @code{errno} value; If @var{key} is @code{signal} then it
997should be a list containing the Unix signal number; otherwise
998it will usually be @code{#f}.
780ee65e
NJ
999@end deffn
1000
1001\fstrerror
89d04205 1002@c snarfed from error.c:156
780ee65e 1003@deffn primitive strerror err
ae9f3a15
MG
1004Return the Unix error message corresponding to @var{err}, which
1005must be an integer value.
780ee65e
NJ
1006@end deffn
1007
1008\fapply:nconc2last
89d04205 1009@c snarfed from eval.c:3256
780ee65e
NJ
1010@deffn primitive apply:nconc2last lst
1011Given a list (@var{arg1} @dots{} @var{args}), this function
1012conses the @var{arg1} @dots{} arguments onto the front of
1013@var{args}, and returns the resulting list. Note that
1014@var{args} is a list; thus, the argument to this function is
1015a list whose last element is a list.
1016Note: Rather than do new consing, @code{apply:nconc2last}
1017destroys its argument, so use with care.
1018@end deffn
1019
1020\fforce
89d04205 1021@c snarfed from eval.c:3789
780ee65e
NJ
1022@deffn primitive force x
1023If the promise @var{x} has not been computed yet, compute and
1024return @var{x}, otherwise just return the previously computed
1025value.
1026@end deffn
1027
1028\fpromise?
89d04205 1029@c snarfed from eval.c:3812
780ee65e
NJ
1030@deffn primitive promise? obj
1031Return true if @var{obj} is a promise, i.e. a delayed computation
1032(@pxref{Delayed evaluation,,,r4rs.info,The Revised^4 Report on Scheme}).
1033@end deffn
1034
1035\fcons-source
89d04205 1036@c snarfed from eval.c:3824
780ee65e
NJ
1037@deffn primitive cons-source xorig x y
1038Create and return a new pair whose car and cdr are @var{x} and @var{y}.
1039Any source properties associated with @var{xorig} are also associated
1040with the new pair.
1041@end deffn
1042
1043\fcopy-tree
89d04205 1044@c snarfed from eval.c:3846
780ee65e
NJ
1045@deffn primitive copy-tree obj
1046Recursively copy the data tree that is bound to @var{obj}, and return a
1047pointer to the new data structure. @code{copy-tree} recurses down the
1048contents of both pairs and vectors (since both cons cells and vector
1049cells may point to arbitrary objects), and stops recursing when it hits
1050any other object.
1051@end deffn
1052
1053\fprimitive-eval
89d04205 1054@c snarfed from eval.c:3940
780ee65e
NJ
1055@deffn primitive primitive-eval exp
1056Evaluate @var{exp} in the top-level environment specified by
1057the current module.
1058@end deffn
1059
1060\feval
89d04205 1061@c snarfed from eval.c:4009
780ee65e
NJ
1062@deffn primitive eval exp module
1063Evaluate @var{exp}, a list representing a Scheme expression,
1064in the top-level environment specified by @var{module}.
1065While @var{exp} is evaluated (using @var{primitive-eval}),
1066@var{module} is made the current module. The current module
1067is reset to its previous value when @var{eval} returns.
1068@end deffn
1069
1070\feval2
89d04205 1071@c snarfed from eval.c:4052
780ee65e
NJ
1072@deffn primitive eval2 obj env_thunk
1073Evaluate @var{exp}, a Scheme expression, in the environment
1074designated by @var{lookup}, a symbol-lookup function."
1075Do not use this version of eval, it does not play well
1076with the module system. Use @code{eval} or
1077@code{primitive-eval} instead.
1078@end deffn
1079
1080\feval-options-interface
89d04205 1081@c snarfed from eval.c:1697
780ee65e
NJ
1082@deffn primitive eval-options-interface [setting]
1083Option interface for the evaluation options. Instead of using
1084this procedure directly, use the procedures @code{eval-enable},
1085@code{eval-disable}, @code{eval-set!} and @var{eval-options}.
1086@end deffn
1087
1088\fevaluator-traps-interface
89d04205 1089@c snarfed from eval.c:1714
780ee65e
NJ
1090@deffn primitive evaluator-traps-interface [setting]
1091Option interface for the evaluator trap options.
1092@end deffn
1093
1094\fdefined?
1095@c snarfed from evalext.c:74
1096@deffn primitive defined? sym [env]
1097Return @code{#t} if @var{sym} is defined in the top-level environment.
1098@end deffn
1099
1100\fmap-in-order
1101@c snarfed from evalext.c:146
1102@deffn primitive map-in-order
1103scm_map
1104@end deffn
1105
1106\fprogram-arguments
1107@c snarfed from feature.c:79
1108@deffn primitive program-arguments
1109@deffnx procedure command-line
1110Return the list of command line arguments passed to Guile, as a list of
1111strings. The list includes the invoked program name, which is usually
1112@code{"guile"}, but excludes switches and parameters for command line
1113options like @code{-e} and @code{-l}.
1114@end deffn
1115
1116\fchown
1117@c snarfed from filesys.c:140
1118@deffn primitive chown object owner group
1119Change the ownership and group of the file referred to by @var{object} to
1120the integer values @var{owner} and @var{group}. @var{object} can be
1121a string containing a file name or, if the platform
1122supports fchown, a port or integer file descriptor
1123which is open on the file. The return value
1124is unspecified.
1125
1126If @var{object} is a symbolic link, either the
1127ownership of the link or the ownership of the referenced file will be
1128changed depending on the operating system (lchown is
1129unsupported at present). If @var{owner} or @var{group} is specified
1130as @code{-1}, then that ID is not changed.
1131@end deffn
1132
1133\fchmod
1134@c snarfed from filesys.c:180
1135@deffn primitive chmod object mode
1136Changes the permissions of the file referred to by @var{obj}.
1137@var{obj} can be a string containing a file name or a port or integer file
1138descriptor which is open on a file (in which case @code{fchmod} is used
1139as the underlying system call).
1140@var{mode} specifies
1141the new permissions as a decimal number, e.g., @code{(chmod "foo" #o755)}.
1142The return value is unspecified.
1143@end deffn
1144
1145\fumask
1146@c snarfed from filesys.c:214
1147@deffn primitive umask [mode]
1148If @var{mode} is omitted, retuns a decimal number representing the current
1149file creation mask. Otherwise the file creation mask is set to
1150@var{mode} and the previous value is returned.
1151
1152E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18.
1153@end deffn
1154
1155\fopen-fdes
1156@c snarfed from filesys.c:237
1157@deffn primitive open-fdes path flags [mode]
ae9f3a15
MG
1158Similar to @code{open} but return a file descriptor instead of
1159a port.
780ee65e
NJ
1160@end deffn
1161
1162\fopen
1163@c snarfed from filesys.c:280
1164@deffn primitive open path flags [mode]
1165Open the file named by @var{path} for reading and/or writing.
1166@var{flags} is an integer specifying how the file should be opened.
1167@var{mode} is an integer specifying the permission bits of the file, if
1168it needs to be created, before the umask is applied. The default is 666
1169(Unix itself has no default).
1170
1171@var{flags} can be constructed by combining variables using @code{logior}.
1172Basic flags are:
1173
1174@defvar O_RDONLY
1175Open the file read-only.
1176@end defvar
1177@defvar O_WRONLY
1178Open the file write-only.
1179@end defvar
1180@defvar O_RDWR
1181Open the file read/write.
1182@end defvar
1183@defvar O_APPEND
1184Append to the file instead of truncating.
1185@end defvar
1186@defvar O_CREAT
1187Create the file if it does not already exist.
1188@end defvar
1189
1190See the Unix documentation of the @code{open} system call
1191for additional flags.
1192@end deffn
1193
1194\fclose
1195@c snarfed from filesys.c:318
1196@deffn primitive close fd_or_port
1197Similar to close-port (@pxref{Generic Port Operations, close-port}),
1198but also works on file descriptors. A side
1199effect of closing a file descriptor is that any ports using that file
1200descriptor are moved to a different file descriptor and have
1201their revealed counts set to zero.
1202@end deffn
1203
1204\fclose-fdes
1205@c snarfed from filesys.c:346
1206@deffn primitive close-fdes fd
1207A simple wrapper for the @code{close} system call.
1208Close file descriptor @var{fd}, which must be an integer.
1209Unlike close (@pxref{Ports and File Descriptors, close}),
1210the file descriptor will be closed even if a port is using it.
1211The return value is unspecified.
1212@end deffn
1213
1214\fstat
89d04205 1215@c snarfed from filesys.c:524
780ee65e 1216@deffn primitive stat object
ae9f3a15
MG
1217Return an object containing various information about the file
1218determined by @var{obj}. @var{obj} can be a string containing
1219a file name or a port or integer file descriptor which is open
1220on a file (in which case @code{fstat} is used as the underlying
1221system call).
1222The object returned by @code{stat} can be passed as a single
1223parameter to the following procedures, all of which return
1224integers:
780ee65e
NJ
1225@table @code
1226@item stat:dev
1227The device containing the file.
1228@item stat:ino
ae9f3a15
MG
1229The file serial number, which distinguishes this file from all
1230other files on the same device.
780ee65e 1231@item stat:mode
ae9f3a15
MG
1232The mode of the file. This includes file type information and
1233the file permission bits. See @code{stat:type} and
1234@code{stat:perms} below.
780ee65e
NJ
1235@item stat:nlink
1236The number of hard links to the file.
1237@item stat:uid
1238The user ID of the file's owner.
1239@item stat:gid
1240The group ID of the file.
1241@item stat:rdev
1242Device ID; this entry is defined only for character or block
1243special files.
1244@item stat:size
1245The size of a regular file in bytes.
1246@item stat:atime
1247The last access time for the file.
1248@item stat:mtime
1249The last modification time for the file.
1250@item stat:ctime
1251The last modification time for the attributes of the file.
1252@item stat:blksize
ae9f3a15
MG
1253The optimal block size for reading or writing the file, in
1254bytes.
780ee65e 1255@item stat:blocks
ae9f3a15
MG
1256The amount of disk space that the file occupies measured in
1257units of 512 byte blocks.
780ee65e 1258@end table
780ee65e
NJ
1259In addition, the following procedures return the information
1260from stat:mode in a more convenient form:
780ee65e
NJ
1261@table @code
1262@item stat:type
1263A symbol representing the type of file. Possible values are
ae9f3a15
MG
1264regular, directory, symlink, block-special, char-special, fifo,
1265socket and unknown
780ee65e
NJ
1266@item stat:perms
1267An integer representing the access permission bits.
1268@end table
1269@end deffn
1270
1271\flink
89d04205 1272@c snarfed from filesys.c:570
780ee65e
NJ
1273@deffn primitive link oldpath newpath
1274Creates a new name @var{newpath} in the file system for the
1275file named by @var{oldpath}. If @var{oldpath} is a symbolic
1276link, the link may or may not be followed depending on the
1277system.
1278@end deffn
1279
1280\frename-file
89d04205 1281@c snarfed from filesys.c:592
780ee65e
NJ
1282@deffn primitive rename-file oldname newname
1283Renames the file specified by @var{oldname} to @var{newname}.
1284The return value is unspecified.
1285@end deffn
1286
1287\fdelete-file
89d04205 1288@c snarfed from filesys.c:621
780ee65e
NJ
1289@deffn primitive delete-file str
1290Deletes (or "unlinks") the file specified by @var{path}.
1291@end deffn
1292
1293\fmkdir
89d04205 1294@c snarfed from filesys.c:640
780ee65e
NJ
1295@deffn primitive mkdir path [mode]
1296Create a new directory named by @var{path}. If @var{mode} is omitted
1297then the permissions of the directory file are set using the current
1298umask. Otherwise they are set to the decimal value specified with
1299@var{mode}. The return value is unspecified.
1300@end deffn
1301
1302\frmdir
89d04205 1303@c snarfed from filesys.c:669
780ee65e
NJ
1304@deffn primitive rmdir path
1305Remove the existing directory named by @var{path}. The directory must
1306be empty for this to succeed. The return value is unspecified.
1307@end deffn
1308
1309\fdirectory-stream?
89d04205 1310@c snarfed from filesys.c:695
780ee65e 1311@deffn primitive directory-stream? obj
ae9f3a15
MG
1312Return a boolean indicating whether @var{object} is a directory
1313stream as returned by @code{opendir}.
780ee65e
NJ
1314@end deffn
1315
1316\fopendir
89d04205 1317@c snarfed from filesys.c:706
780ee65e
NJ
1318@deffn primitive opendir dirname
1319Open the directory specified by @var{path} and return a directory
1320stream.
1321@end deffn
1322
1323\freaddir
89d04205 1324@c snarfed from filesys.c:724
780ee65e
NJ
1325@deffn primitive readdir port
1326Return (as a string) the next directory entry from the directory stream
1327@var{stream}. If there is no remaining entry to be read then the
1328end of file object is returned.
1329@end deffn
1330
1331\frewinddir
89d04205 1332@c snarfed from filesys.c:747
780ee65e
NJ
1333@deffn primitive rewinddir port
1334Reset the directory port @var{stream} so that the next call to
1335@code{readdir} will return the first directory entry.
1336@end deffn
1337
1338\fclosedir
89d04205 1339@c snarfed from filesys.c:764
780ee65e
NJ
1340@deffn primitive closedir port
1341Close the directory stream @var{stream}.
1342The return value is unspecified.
1343@end deffn
1344
1345\fchdir
89d04205 1346@c snarfed from filesys.c:814
780ee65e
NJ
1347@deffn primitive chdir str
1348Change the current working directory to @var{path}.
1349The return value is unspecified.
1350@end deffn
1351
1352\fgetcwd
89d04205 1353@c snarfed from filesys.c:831
780ee65e 1354@deffn primitive getcwd
ae9f3a15 1355Return the name of the current working directory.
780ee65e
NJ
1356@end deffn
1357
1358\fselect
89d04205 1359@c snarfed from filesys.c:1028
780ee65e
NJ
1360@deffn primitive select reads writes excepts [secs [usecs]]
1361This procedure has a variety of uses: waiting for the ability
1362to provide input, accept output, or the existance of
1363exceptional conditions on a collection of ports or file
1364descriptors, or waiting for a timeout to occur.
1365It also returns if interrupted by a signal.
1366
1367@var{reads}, @var{writes} and @var{excepts} can be lists or
1368vectors, with each member a port or a file descriptor.
1369The value returned is a list of three corresponding
1370lists or vectors containing only the members which meet the
1371specified requirement. The ability of port buffers to
1372provide input or accept output is taken into account.
1373Ordering of the input lists or vectors is not preserved.
1374
1375The optional arguments @var{secs} and @var{usecs} specify the
1376timeout. Either @var{secs} can be specified alone, as
1377either an integer or a real number, or both @var{secs} and
1378@var{usecs} can be specified as integers, in which case
1379@var{usecs} is an additional timeout expressed in
1380microseconds. If @var{secs} is omitted or is @code{#f} then
1381select will wait for as long as it takes for one of the other
1382conditions to be satisfied.
1383
1384The scsh version of @code{select} differs as follows:
1385Only vectors are accepted for the first three arguments.
1386The @var{usecs} argument is not supported.
1387Multiple values are returned instead of a list.
1388Duplicates in the input vectors appear only once in output.
1389An additional @code{select!} interface is provided.
1390@end deffn
1391
1392\ffcntl
89d04205 1393@c snarfed from filesys.c:1173
780ee65e
NJ
1394@deffn primitive fcntl object cmd [value]
1395Apply @var{command} to the specified file descriptor or the underlying
1396file descriptor of the specified port. @var{value} is an optional
1397integer argument.
1398
1399Values for @var{command} are:
1400
1401@table @code
1402@item F_DUPFD
1403Duplicate a file descriptor
1404@item F_GETFD
1405Get flags associated with the file descriptor.
1406@item F_SETFD
1407Set flags associated with the file descriptor to @var{value}.
1408@item F_GETFL
1409Get flags associated with the open file.
1410@item F_SETFL
1411Set flags associated with the open file to @var{value}
1412@item F_GETOWN
1413Get the process ID of a socket's owner, for @code{SIGIO} signals.
1414@item F_SETOWN
1415Set the process that owns a socket to @var{value}, for @code{SIGIO} signals.
1416@item FD_CLOEXEC
1417The value used to indicate the "close on exec" flag with @code{F_GETFL} or
1418@code{F_SETFL}.
1419@end table
1420@end deffn
1421
1422\ffsync
89d04205 1423@c snarfed from filesys.c:1209
780ee65e
NJ
1424@deffn primitive fsync object
1425Copies any unwritten data for the specified output file descriptor to disk.
1426If @var{port/fd} is a port, its buffer is flushed before the underlying
1427file descriptor is fsync'd.
1428The return value is unspecified.
1429@end deffn
1430
1431\fsymlink
89d04205 1432@c snarfed from filesys.c:1236
780ee65e
NJ
1433@deffn primitive symlink oldpath newpath
1434Create a symbolic link named @var{path-to} with the value (i.e., pointing to)
1435@var{path-from}. The return value is unspecified.
1436@end deffn
1437
1438\freadlink
89d04205 1439@c snarfed from filesys.c:1257
780ee65e 1440@deffn primitive readlink path
ae9f3a15
MG
1441Return the value of the symbolic link named by @var{path} (a
1442string), i.e., the file that the link points to.
780ee65e
NJ
1443@end deffn
1444
1445\flstat
89d04205 1446@c snarfed from filesys.c:1287
780ee65e
NJ
1447@deffn primitive lstat str
1448Similar to @code{stat}, but does not follow symbolic links, i.e.,
1449it will return information about a symbolic link itself, not the
1450file it points to. @var{path} must be a string.
1451@end deffn
1452
1453\fcopy-file
89d04205 1454@c snarfed from filesys.c:1312
780ee65e
NJ
1455@deffn primitive copy-file oldfile newfile
1456Copy the file specified by @var{path-from} to @var{path-to}.
1457The return value is unspecified.
1458@end deffn
1459
1460\fdirname
89d04205 1461@c snarfed from filesys.c:1359
780ee65e
NJ
1462@deffn primitive dirname filename
1463Return the directory name component of the file name
1464@var{filename}. If @var{filename} does not contain a directory
1465component, @code{.} is returned.
1466@end deffn
1467
1468\fbasename
89d04205 1469@c snarfed from filesys.c:1392
780ee65e
NJ
1470@deffn primitive basename filename [suffix]
1471Return the base name of the file name @var{filename}. The
1472base name is the file name without any directory components.
1473If @var{suffix} is privided, and is equal to the end of
1474@var{basename}, it is removed also.
1475@end deffn
1476
1477\fmake-fluid
72ad43dc 1478@c snarfed from fluids.c:124
780ee65e
NJ
1479@deffn primitive make-fluid
1480Return a newly created fluid.
1481Fluids are objects of a certain type (a smob) that can hold one SCM
1482value per dynamic root. That is, modifications to this value are
1483only visible to code that executes within the same dynamic root as
1484the modifying code. When a new dynamic root is constructed, it
1485inherits the values from its parent. Because each thread executes
1486in its own dynamic root, you can use fluids for thread local storage.
1487@end deffn
1488
1489\ffluid?
72ad43dc 1490@c snarfed from fluids.c:137
780ee65e 1491@deffn primitive fluid? obj
ae9f3a15
MG
1492Return @code{#t} iff @var{obj} is a fluid; otherwise, return
1493@code{#f}.
780ee65e
NJ
1494@end deffn
1495
1496\ffluid-ref
72ad43dc 1497@c snarfed from fluids.c:148
780ee65e 1498@deffn primitive fluid-ref fluid
ae9f3a15
MG
1499Return the value associated with @var{fluid} in the current
1500dynamic root. If @var{fluid} has not been set, then return
1501@code{#f}.
780ee65e
NJ
1502@end deffn
1503
1504\ffluid-set!
72ad43dc 1505@c snarfed from fluids.c:165
780ee65e
NJ
1506@deffn primitive fluid-set! fluid value
1507Set the value associated with @var{fluid} in the current dynamic root.
1508@end deffn
1509
1510\fwith-fluids*
72ad43dc 1511@c snarfed from fluids.c:224
780ee65e
NJ
1512@deffn primitive with-fluids* fluids values thunk
1513Set @var{fluids} to @var{values} temporary, and call @var{thunk}.
1514@var{fluids} must be a list of fluids and @var{values} must be the same
1515number of their values to be applied. Each substitution is done
1516one after another. @var{thunk} must be a procedure with no argument.
1517@end deffn
1518
1519\fsetvbuf
1520@c snarfed from fports.c:148
1521@deffn primitive setvbuf port mode [size]
1522Set the buffering mode for @var{port}. @var{mode} can be:
1523@table @code
1524@item _IONBF
1525non-buffered
1526@item _IOLBF
1527line buffered
1528@item _IOFBF
1529block buffered, using a newly allocated buffer of @var{size} bytes.
1530If @var{size} is omitted, a default size will be used.
1531@end table
1532@end deffn
1533
1534\ffile-port?
1535@c snarfed from fports.c:229
1536@deffn primitive file-port? obj
1537Determine whether @var{obj} is a port that is related to a file.
1538@end deffn
1539
1540\fopen-file
89d04205 1541@c snarfed from fports.c:283
ae9f3a15
MG
1542@deffn primitive open-file filename mode
1543Open the file whose name is @var{filename}, and return a port
780ee65e 1544representing that file. The attributes of the port are
ae9f3a15
MG
1545determined by the @var{mode} string. The way in which this is
1546interpreted is similar to C stdio. The first character must be
1547one of the following:
780ee65e
NJ
1548@table @samp
1549@item r
1550Open an existing file for input.
1551@item w
1552Open a file for output, creating it if it doesn't already exist
1553or removing its contents if it does.
1554@item a
ae9f3a15
MG
1555Open a file for output, creating it if it doesn't already
1556exist. All writes to the port will go to the end of the file.
780ee65e
NJ
1557The "append mode" can be turned off while the port is in use
1558@pxref{Ports and File Descriptors, fcntl}
1559@end table
780ee65e 1560The following additional characters can be appended:
780ee65e
NJ
1561@table @samp
1562@item +
1563Open the port for both input and output. E.g., @code{r+}: open
1564an existing file for both input and output.
1565@item 0
ae9f3a15
MG
1566Create an "unbuffered" port. In this case input and output
1567operations are passed directly to the underlying port
1568implementation without additional buffering. This is likely to
1569slow down I/O operations. The buffering mode can be changed
1570while a port is in use @pxref{Ports and File Descriptors,
1571setvbuf}
780ee65e
NJ
1572@item l
1573Add line-buffering to the port. The port output buffer will be
1574automatically flushed whenever a newline character is written.
1575@end table
ae9f3a15
MG
1576In theory we could create read/write ports which were buffered
1577in one direction only. However this isn't included in the
1578current interfaces. If a file cannot be opened with the access
1579requested, @code{open-file} throws an exception.
780ee65e
NJ
1580@end deffn
1581
1582\fgc-stats
89d04205 1583@c snarfed from gc.c:749
780ee65e 1584@deffn primitive gc-stats
ae9f3a15
MG
1585Return an association list of statistics about Guile's current
1586use of storage.
780ee65e
NJ
1587@end deffn
1588
1589\fobject-address
89d04205 1590@c snarfed from gc.c:846
780ee65e
NJ
1591@deffn primitive object-address obj
1592Return an integer that for the lifetime of @var{obj} is uniquely
1593returned by this function for @var{obj}
1594@end deffn
1595
1596\fgc
89d04205 1597@c snarfed from gc.c:857
780ee65e
NJ
1598@deffn primitive gc
1599Scans all of SCM objects and reclaims for further use those that are
1600no longer accessible.
1601@end deffn
1602
1603\funhash-name
72ad43dc 1604@c snarfed from gc.c:2306
780ee65e
NJ
1605@deffn primitive unhash-name name
1606Flushes the glocs for @var{name}, or all glocs if @var{name}
1607is @code{#t}.
1608@end deffn
1609
1610\f%compute-slots
1611@c snarfed from goops.c:290
1612@deffn primitive %compute-slots class
1613Return a list consisting of the names of all slots belonging to
1614class @var{class}, i. e. the slots of @var{class} and of all of
1615its superclasses.
1616@end deffn
1617
1618\fget-keyword
1619@c snarfed from goops.c:375
1620@deffn primitive get-keyword key l default_value
1621Determine an associated value for the keyword @var{key} from
1622the list @var{l}. The list @var{l} has to consist of an even
1623number of elements, where, starting with the first, every
1624second element is a keyword, followed by its associated value.
1625If @var{l} does not hold a value for @var{key}, the value
1626@var{default_value} is returned.
1627@end deffn
1628
1629\f%initialize-object
1630@c snarfed from goops.c:398
1631@deffn primitive %initialize-object obj initargs
1632Initialize the object @var{obj} with the given arguments
1633@var{initargs}.
1634@end deffn
1635
1636\f%prep-layout!
1637@c snarfed from goops.c:479
1638@deffn primitive %prep-layout! class
1639@end deffn
1640
1641\f%inherit-magic!
1642@c snarfed from goops.c:542
1643@deffn primitive %inherit-magic! class dsupers
1644@end deffn
1645
1646\finstance?
1647@c snarfed from goops.c:783
1648@deffn primitive instance? obj
1649Return @code{#t} if @var{obj} is an instance.
1650@end deffn
1651
1652\fclass-name
1653@c snarfed from goops.c:798
1654@deffn primitive class-name obj
1655Return the class name of @var{obj}.
1656@end deffn
1657
1658\fclass-direct-supers
1659@c snarfed from goops.c:808
1660@deffn primitive class-direct-supers obj
1661Return the direct superclasses of the class @var{obj}.
1662@end deffn
1663
1664\fclass-direct-slots
1665@c snarfed from goops.c:818
1666@deffn primitive class-direct-slots obj
1667Return the direct slots of the class @var{obj}.
1668@end deffn
1669
1670\fclass-direct-subclasses
1671@c snarfed from goops.c:828
1672@deffn primitive class-direct-subclasses obj
1673Return the direct subclasses of the class @var{obj}.
1674@end deffn
1675
1676\fclass-direct-methods
1677@c snarfed from goops.c:838
1678@deffn primitive class-direct-methods obj
1679Return the direct methods of the class @var{obj}
1680@end deffn
1681
1682\fclass-precedence-list
1683@c snarfed from goops.c:848
1684@deffn primitive class-precedence-list obj
1685Return the class precedence list of the class @var{obj}.
1686@end deffn
1687
1688\fclass-slots
1689@c snarfed from goops.c:858
1690@deffn primitive class-slots obj
1691Return the slot list of the class @var{obj}.
1692@end deffn
1693
1694\fclass-environment
1695@c snarfed from goops.c:868
1696@deffn primitive class-environment obj
1697Return the environment of the class @var{obj}.
1698@end deffn
1699
1700\fgeneric-function-name
1701@c snarfed from goops.c:879
1702@deffn primitive generic-function-name obj
1703Return the name of the generic function @var{obj}.
1704@end deffn
1705
1706\fgeneric-function-methods
1707@c snarfed from goops.c:889
1708@deffn primitive generic-function-methods obj
1709Return the methods of the generic function @var{obj}.
1710@end deffn
1711
1712\fmethod-generic-function
1713@c snarfed from goops.c:900
1714@deffn primitive method-generic-function obj
1715Return the generic function fot the method @var{obj}.
1716@end deffn
1717
1718\fmethod-specializers
1719@c snarfed from goops.c:910
1720@deffn primitive method-specializers obj
1721Return specializers of the method @var{obj}.
1722@end deffn
1723
1724\fmethod-procedure
1725@c snarfed from goops.c:920
1726@deffn primitive method-procedure obj
1727Return the procedure of the method @var{obj}.
1728@end deffn
1729
1730\faccessor-method-slot-definition
1731@c snarfed from goops.c:930
1732@deffn primitive accessor-method-slot-definition obj
1733Return the slot definition of the accessor @var{obj}.
1734@end deffn
1735
1736\f%tag-body
1737@c snarfed from goops.c:940
1738@deffn primitive %tag-body body
1739Internal GOOPS magic---don't use this function!
1740@end deffn
1741
1742\fmake-unbound
1743@c snarfed from goops.c:955
1744@deffn primitive make-unbound
1745Return the unbound value.
1746@end deffn
1747
1748\funbound?
1749@c snarfed from goops.c:964
1750@deffn primitive unbound? obj
1751Return @code{#t} if @var{obj} is unbound.
1752@end deffn
1753
1754\fassert-bound
1755@c snarfed from goops.c:974
1756@deffn primitive assert-bound value obj
1757Return @var{value} if it is bound, and invoke the
1758@var{slot-unbound} method of @var{obj} if it is not.
1759@end deffn
1760
1761\f@@assert-bound-ref
1762@c snarfed from goops.c:986
1763@deffn primitive @@assert-bound-ref obj index
1764Like @code{assert-bound}, but use @var{index} for accessing
1765the value from @var{obj}.
1766@end deffn
1767
1768\f%fast-slot-ref
1769@c snarfed from goops.c:998
1770@deffn primitive %fast-slot-ref obj index
1771Return the slot value with index @var{index} from @var{obj}.
1772@end deffn
1773
1774\f%fast-slot-set!
1775@c snarfed from goops.c:1015
1776@deffn primitive %fast-slot-set! obj index value
1777Set the slot with index @var{index} in @var{obj} to
1778@var{value}.
1779@end deffn
1780
1781\fslot-ref-using-class
1782@c snarfed from goops.c:1143
1783@deffn primitive slot-ref-using-class class obj slot_name
1784@end deffn
1785
1786\fslot-set-using-class!
1787@c snarfed from goops.c:1162
1788@deffn primitive slot-set-using-class! class obj slot_name value
1789@end deffn
1790
1791\fslot-bound-using-class?
1792@c snarfed from goops.c:1176
1793@deffn primitive slot-bound-using-class? class obj slot_name
1794@end deffn
1795
1796\fslot-exists-using-class?
1797@c snarfed from goops.c:1191
1798@deffn primitive slot-exists-using-class? class obj slot_name
1799@end deffn
1800
1801\fslot-ref
1802@c snarfed from goops.c:1207
1803@deffn primitive slot-ref obj slot_name
1804Return the value from @var{obj}'s slot with the name
1805@var{slot_name}.
1806@end deffn
1807
1808\fslot-set!
1809@c snarfed from goops.c:1224
1810@deffn primitive slot-set! obj slot_name value
1811Set the slot named @var{slot_name} of @var{obj} to @var{value}.
1812@end deffn
1813
1814\fslot-bound?
1815@c snarfed from goops.c:1241
1816@deffn primitive slot-bound? obj slot_name
1817Return @code{#t} if the slot named @var{slot_name} of @var{obj}
1818is bound.
1819@end deffn
1820
1821\fslot-exists?
1822@c snarfed from goops.c:1259
1823@deffn primitive slot-exists? obj slot_name
1824Return @code{#t} if @var{obj} has a slot named @var{slot_name}.
1825@end deffn
1826
1827\f%allocate-instance
1828@c snarfed from goops.c:1302
1829@deffn primitive %allocate-instance class initargs
1830Create a new instance of class @var{class} and initialize it
1831from the arguments @var{initargs}.
1832@end deffn
1833
1834\f%set-object-setter!
1835@c snarfed from goops.c:1375
1836@deffn primitive %set-object-setter! obj setter
1837@end deffn
1838
1839\f%modify-instance
1840@c snarfed from goops.c:1400
1841@deffn primitive %modify-instance old new
1842@end deffn
1843
1844\f%modify-class
1845@c snarfed from goops.c:1426
1846@deffn primitive %modify-class old new
1847@end deffn
1848
1849\f%invalidate-class
1850@c snarfed from goops.c:1450
1851@deffn primitive %invalidate-class class
1852@end deffn
1853
1854\f%invalidate-method-cache!
1855@c snarfed from goops.c:1571
1856@deffn primitive %invalidate-method-cache! gf
1857@end deffn
1858
1859\fgeneric-capability?
1860@c snarfed from goops.c:1597
1861@deffn primitive generic-capability? proc
1862@end deffn
1863
1864\fenable-primitive-generic!
1865@c snarfed from goops.c:1610
1866@deffn primitive enable-primitive-generic! . subrs
1867@end deffn
1868
1869\fprimitive-generic-generic
1870@c snarfed from goops.c:1630
1871@deffn primitive primitive-generic-generic subr
1872@end deffn
1873
1874\fmake
1875@c snarfed from goops.c:1989
1876@deffn primitive make . args
1877Make a new object. @var{args} must contain the class and
1878all necessary initialization information.
1879@end deffn
1880
1881\ffind-method
1882@c snarfed from goops.c:2082
1883@deffn primitive find-method . l
1884@end deffn
1885
1886\f%method-more-specific?
1887@c snarfed from goops.c:2102
1888@deffn primitive %method-more-specific? m1 m2 targs
1889@end deffn
1890
1891\f%goops-loaded
1892@c snarfed from goops.c:2634
1893@deffn primitive %goops-loaded
1894Announce that GOOPS is loaded and perform initialization
1895on the C level which depends on the loaded GOOPS modules.
1896@end deffn
1897
1898\fmake-guardian
1899@c snarfed from guardians.c:336
1900@deffn primitive make-guardian [greedy_p]
1901Create a new guardian.
1902A guardian protects a set of objects from garbage collection,
1903allowing a program to apply cleanup or other actions.
1904
1905@code{make-guardian} returns a procedure representing the guardian.
1906Calling the guardian procedure with an argument adds the
1907argument to the guardian's set of protected objects.
1908Calling the guardian procedure without an argument returns
1909one of the protected objects which are ready for garbage
1910collection, or @code{#f} if no such object is available.
1911Objects which are returned in this way are removed from
1912the guardian.
1913
1914@code{make-guardian} takes one optional argument that says whether the
1915new guardian should be greedy or sharing. If there is any chance
1916that any object protected by the guardian may be resurrected,
1917then you should make the guardian greedy (this is the default).
1918
1919See R. Kent Dybvig, Carl Bruggeman, and David Eby (1993)
1920"Guardians in a Generation-Based Garbage Collector".
1921ACM SIGPLAN Conference on Programming Language Design
1922and Implementation, June 1993.
1923
1924(the semantics are slightly different at this point, but the
1925paper still (mostly) accurately describes the interface).
1926@end deffn
1927
1928\fguardian-destroyed?
1929@c snarfed from guardians.c:364
1930@deffn primitive guardian-destroyed? guardian
1931Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}.
1932@end deffn
1933
1934\fguardian-greedy?
1935@c snarfed from guardians.c:382
1936@deffn primitive guardian-greedy? guardian
1937Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.
1938@end deffn
1939
1940\fdestroy-guardian!
1941@c snarfed from guardians.c:393
1942@deffn primitive destroy-guardian! guardian
1943Destroys @var{guardian}, by making it impossible to put any more
1944objects in it or get any objects from it. It also unguards any
1945objects guarded by @var{guardian}.
1946@end deffn
1947
1948\fhashq
1949@c snarfed from hash.c:202
1950@deffn primitive hashq key size
1951Determine a hash value for @var{key} that is suitable for
1952lookups in a hashtable of size @var{size}, where @code{eq?} is
1953used as the equality predicate. The function returns an
1954integer in the range 0 to @var{size} - 1. Note that
1955@code{hashq} may use internal addresses. Thus two calls to
1956hashq where the keys are @code{eq?} are not guaranteed to
1957deliver the same value if the key object gets garbage collected
1958in between. This can happen, for example with symbols:
1959@code{(hashq 'foo n) (gc) (hashq 'foo n)} may produce two
1960different values, since @code{foo} will be garbage collected.
1961@end deffn
1962
1963\fhashv
1964@c snarfed from hash.c:238
1965@deffn primitive hashv key size
1966Determine a hash value for @var{key} that is suitable for
1967lookups in a hashtable of size @var{size}, where @code{eqv?} is
1968used as the equality predicate. The function returns an
1969integer in the range 0 to @var{size} - 1. Note that
1970@code{(hashv key)} may use internal addresses. Thus two calls
1971to hashv where the keys are @code{eqv?} are not guaranteed to
1972deliver the same value if the key object gets garbage collected
1973in between. This can happen, for example with symbols:
1974@code{(hashv 'foo n) (gc) (hashv 'foo n)} may produce two
1975different values, since @code{foo} will be garbage collected.
1976@end deffn
1977
1978\fhash
1979@c snarfed from hash.c:261
1980@deffn primitive hash key size
1981Determine a hash value for @var{key} that is suitable for
1982lookups in a hashtable of size @var{size}, where @code{equal?}
1983is used as the equality predicate. The function returns an
1984integer in the range 0 to @var{size} - 1.
1985@end deffn
1986
1987\fhashq-get-handle
89d04205 1988@c snarfed from hashtab.c:173
ae9f3a15
MG
1989@deffn primitive hashq-get-handle table key
1990This procedure returns the @code{(key . value)} pair from the
1991hash table @var{table}. If @var{table} does not hold an
1992associated value for @var{key}, @code{#f} is returned.
1993Uses @code{eq?} for equality testing.
780ee65e
NJ
1994@end deffn
1995
1996\fhashq-create-handle!
89d04205 1997@c snarfed from hashtab.c:185
780ee65e
NJ
1998@deffn primitive hashq-create-handle! table key init
1999This function looks up @var{key} in @var{table} and returns its handle.
2000If @var{key} is not already present, a new handle is created which
2001associates @var{key} with @var{init}.
2002@end deffn
2003
2004\fhashq-ref
89d04205 2005@c snarfed from hashtab.c:198
ae9f3a15 2006@deffn primitive hashq-ref table key [dflt]
780ee65e
NJ
2007Look up @var{key} in the hash table @var{table}, and return the
2008value (if any) associated with it. If @var{key} is not found,
2009return @var{default} (or @code{#f} if no @var{default} argument
2010is supplied). Uses @code{eq?} for equality testing.
2011@end deffn
2012
2013\fhashq-set!
89d04205 2014@c snarfed from hashtab.c:212
ae9f3a15 2015@deffn primitive hashq-set! table key val
780ee65e
NJ
2016Find the entry in @var{table} associated with @var{key}, and
2017store @var{value} there. Uses @code{eq?} for equality testing.
2018@end deffn
2019
2020\fhashq-remove!
89d04205 2021@c snarfed from hashtab.c:224
ae9f3a15 2022@deffn primitive hashq-remove! table key
780ee65e
NJ
2023Remove @var{key} (and any value associated with it) from
2024@var{table}. Uses @code{eq?} for equality tests.
2025@end deffn
2026
2027\fhashv-get-handle
89d04205 2028@c snarfed from hashtab.c:240
ae9f3a15
MG
2029@deffn primitive hashv-get-handle table key
2030This procedure returns the @code{(key . value)} pair from the
2031hash table @var{table}. If @var{table} does not hold an
2032associated value for @var{key}, @code{#f} is returned.
2033Uses @code{eqv?} for equality testing.
780ee65e
NJ
2034@end deffn
2035
2036\fhashv-create-handle!
89d04205 2037@c snarfed from hashtab.c:252
780ee65e
NJ
2038@deffn primitive hashv-create-handle! table key init
2039This function looks up @var{key} in @var{table} and returns its handle.
2040If @var{key} is not already present, a new handle is created which
2041associates @var{key} with @var{init}.
2042@end deffn
2043
2044\fhashv-ref
89d04205 2045@c snarfed from hashtab.c:266
ae9f3a15 2046@deffn primitive hashv-ref table key [dflt]
780ee65e
NJ
2047Look up @var{key} in the hash table @var{table}, and return the
2048value (if any) associated with it. If @var{key} is not found,
2049return @var{default} (or @code{#f} if no @var{default} argument
2050is supplied). Uses @code{eqv?} for equality testing.
2051@end deffn
2052
2053\fhashv-set!
89d04205 2054@c snarfed from hashtab.c:280
ae9f3a15 2055@deffn primitive hashv-set! table key val
780ee65e
NJ
2056Find the entry in @var{table} associated with @var{key}, and
2057store @var{value} there. Uses @code{eqv?} for equality testing.
2058@end deffn
2059
2060\fhashv-remove!
89d04205 2061@c snarfed from hashtab.c:291
ae9f3a15 2062@deffn primitive hashv-remove! table key
780ee65e
NJ
2063Remove @var{key} (and any value associated with it) from
2064@var{table}. Uses @code{eqv?} for equality tests.
2065@end deffn
2066
2067\fhash-get-handle
89d04205 2068@c snarfed from hashtab.c:306
ae9f3a15
MG
2069@deffn primitive hash-get-handle table key
2070This procedure returns the @code{(key . value)} pair from the
2071hash table @var{table}. If @var{table} does not hold an
2072associated value for @var{key}, @code{#f} is returned.
2073Uses @code{equal?} for equality testing.
780ee65e
NJ
2074@end deffn
2075
2076\fhash-create-handle!
89d04205 2077@c snarfed from hashtab.c:318
780ee65e
NJ
2078@deffn primitive hash-create-handle! table key init
2079This function looks up @var{key} in @var{table} and returns its handle.
2080If @var{key} is not already present, a new handle is created which
2081associates @var{key} with @var{init}.
2082@end deffn
2083
2084\fhash-ref
89d04205 2085@c snarfed from hashtab.c:331
ae9f3a15 2086@deffn primitive hash-ref table key [dflt]
780ee65e
NJ
2087Look up @var{key} in the hash table @var{table}, and return the
2088value (if any) associated with it. If @var{key} is not found,
2089return @var{default} (or @code{#f} if no @var{default} argument
2090is supplied). Uses @code{equal?} for equality testing.
2091@end deffn
2092
2093\fhash-set!
89d04205 2094@c snarfed from hashtab.c:346
ae9f3a15 2095@deffn primitive hash-set! table key val
780ee65e
NJ
2096Find the entry in @var{table} associated with @var{key}, and
2097store @var{value} there. Uses @code{equal?} for equality
2098testing.
2099@end deffn
2100
2101\fhash-remove!
89d04205 2102@c snarfed from hashtab.c:358
ae9f3a15 2103@deffn primitive hash-remove! table key
780ee65e
NJ
2104Remove @var{key} (and any value associated with it) from
2105@var{table}. Uses @code{equal?} for equality tests.
2106@end deffn
2107
2108\fhashx-get-handle
89d04205 2109@c snarfed from hashtab.c:428
ae9f3a15
MG
2110@deffn primitive hashx-get-handle hash assoc table key
2111This behaves the same way as the corresponding
2112@code{-get-handle} function, but uses @var{hash} as a hash
2113function and @var{assoc} to compare keys. @code{hash} must be
2114a function that takes two arguments, a key to be hashed and a
780ee65e
NJ
2115table size. @code{assoc} must be an associator function, like
2116@code{assoc}, @code{assq} or @code{assv}.
2117@end deffn
2118
2119\fhashx-create-handle!
2120@c snarfed from hashtab.c:447
ae9f3a15
MG
2121@deffn primitive hashx-create-handle! hash assoc table key init
2122This behaves the same way as the corresponding
2123@code{-create-handle} function, but uses @var{hash} as a hash
2124function and @var{assoc} to compare keys. @code{hash} must be
2125a function that takes two arguments, a key to be hashed and a
780ee65e
NJ
2126table size. @code{assoc} must be an associator function, like
2127@code{assoc}, @code{assq} or @code{assv}.
2128@end deffn
2129
2130\fhashx-ref
89d04205 2131@c snarfed from hashtab.c:470
ae9f3a15 2132@deffn primitive hashx-ref hash assoc table key [dflt]
780ee65e 2133This behaves the same way as the corresponding @code{ref}
ae9f3a15
MG
2134function, but uses @var{hash} as a hash function and
2135@var{assoc} to compare keys. @code{hash} must be a function
2136that takes two arguments, a key to be hashed and a table size.
2137@code{assoc} must be an associator function, like @code{assoc},
2138@code{assq} or @code{assv}.
2139By way of illustration, @code{hashq-ref table key} is
2140equivalent to @code{hashx-ref hashq assq table key}.
780ee65e
NJ
2141@end deffn
2142
2143\fhashx-set!
89d04205 2144@c snarfed from hashtab.c:496
ae9f3a15 2145@deffn primitive hashx-set! hash assoc table key val
780ee65e 2146This behaves the same way as the corresponding @code{set!}
ae9f3a15
MG
2147function, but uses @var{hash} as a hash function and
2148@var{assoc} to compare keys. @code{hash} must be a function
2149that takes two arguments, a key to be hashed and a table size.
2150@code{assoc} must be an associator function, like @code{assoc},
2151@code{assq} or @code{assv}.
2152 By way of illustration, @code{hashq-set! table key} is
2153equivalent to @code{hashx-set! hashq assq table key}.
780ee65e
NJ
2154@end deffn
2155
2156\fhash-fold
89d04205 2157@c snarfed from hashtab.c:534
780ee65e
NJ
2158@deffn primitive hash-fold proc init table
2159An iterator over hash-table elements.
2160Accumulates and returns a result by applying PROC successively.
2161The arguments to PROC are "(key value prior-result)" where key
2162and value are successive pairs from the hash table TABLE, and
2163prior-result is either INIT (for the first application of PROC)
2164or the return value of the previous application of PROC.
2165For example, @code{(hash-fold acons () tab)} will convert a hash
2166table into an a-list of key-value pairs.
2167@end deffn
2168
2169\fmake-hook-with-name
89d04205 2170@c snarfed from hooks.c:217
780ee65e
NJ
2171@deffn primitive make-hook-with-name name [n_args]
2172Create a named hook with the name @var{name} for storing
5c4b24e1
MG
2173procedures of arity @var{n_args}. @var{n_args} defaults to
2174zero.
780ee65e
NJ
2175@end deffn
2176
2177\fmake-hook
89d04205 2178@c snarfed from hooks.c:232
780ee65e 2179@deffn primitive make-hook [n_args]
5c4b24e1
MG
2180Create a hook for storing procedure of arity
2181@var{n_args}. @var{n_args} defaults to zero.
780ee65e
NJ
2182@end deffn
2183
2184\fhook?
89d04205 2185@c snarfed from hooks.c:242
780ee65e 2186@deffn primitive hook? x
5c4b24e1 2187Return @code{#t} if @var{x} is a hook, @code{#f} otherwise.
780ee65e
NJ
2188@end deffn
2189
2190\fhook-empty?
89d04205 2191@c snarfed from hooks.c:253
780ee65e 2192@deffn primitive hook-empty? hook
5c4b24e1
MG
2193Return @code{#t} if @var{hook} is an empty hook, @code{#f}
2194otherwise.
780ee65e
NJ
2195@end deffn
2196
2197\fadd-hook!
89d04205 2198@c snarfed from hooks.c:266
780ee65e
NJ
2199@deffn primitive add-hook! hook proc [append_p]
2200Add the procedure @var{proc} to the hook @var{hook}. The
2201procedure is added to the end if @var{append_p} is true,
2202otherwise it is added to the front.
2203@end deffn
2204
2205\fremove-hook!
89d04205 2206@c snarfed from hooks.c:292
780ee65e
NJ
2207@deffn primitive remove-hook! hook proc
2208Remove the procedure @var{proc} from the hook @var{hook}.
2209@end deffn
2210
2211\freset-hook!
89d04205 2212@c snarfed from hooks.c:305
780ee65e
NJ
2213@deffn primitive reset-hook! hook
2214Remove all procedures from the hook @var{hook}.
2215@end deffn
2216
2217\frun-hook
89d04205 2218@c snarfed from hooks.c:319
780ee65e
NJ
2219@deffn primitive run-hook hook . args
2220Apply all procedures from the hook @var{hook} to the arguments
5c4b24e1
MG
2221@var{args}. The order of the procedure application is first to
2222last.
780ee65e
NJ
2223@end deffn
2224
2225\fhook->list
89d04205 2226@c snarfed from hooks.c:346
780ee65e
NJ
2227@deffn primitive hook->list hook
2228Convert the procedure list of @var{hook} to a list.
2229@end deffn
2230
2231\fread-string!/partial
2232@c snarfed from ioext.c:114
2233@deffn primitive read-string!/partial str [port_or_fdes [start [end]]]
2234Read characters from an fport or file descriptor into a
2235string @var{str}. This procedure is scsh-compatible
2236and can efficiently read large strings. It will:
2237
2238@itemize
2239@item
2240attempt to fill the entire string, unless the @var{start}
2241and/or @var{end} arguments are supplied. i.e., @var{start}
2242defaults to 0 and @var{end} defaults to
2243@code{(string-length str)}
2244@item
2245use the current input port if @var{port_or_fdes} is not
2246supplied.
2247@item
2248read any characters that are currently available,
2249without waiting for the rest (short reads are possible).
2250
2251@item
2252wait for as long as it needs to for the first character to
2253become available, unless the port is in non-blocking mode
2254@item
2255return @code{#f} if end-of-file is encountered before reading
2256any characters, otherwise return the number of characters
2257read.
2258@item
2259return 0 if the port is in non-blocking mode and no characters
2260are immediately available.
2261@item
2262return 0 if the request is for 0 bytes, with no
2263end-of-file check
2264@end itemize
2265@end deffn
2266
2267\fftell
89d04205 2268@c snarfed from ioext.c:174
ae9f3a15
MG
2269@deffn primitive ftell fd_port
2270Return an integer representing the current position of
2271@var{fd/port}, measured from the beginning. Equivalent to:
2272@lisp
780ee65e 2273(seek port 0 SEEK_CUR)
ae9f3a15 2274@end lisp
780ee65e
NJ
2275@end deffn
2276
2277\ffseek
89d04205 2278@c snarfed from ioext.c:187
ae9f3a15
MG
2279@deffn primitive fseek fd_port offset whence
2280Obsolete. Almost the same as @code{seek}, but the return value
2281is unspecified.
780ee65e
NJ
2282@end deffn
2283
2284\fredirect-port
89d04205 2285@c snarfed from ioext.c:209
780ee65e
NJ
2286@deffn primitive redirect-port old new
2287This procedure takes two ports and duplicates the underlying file
2288descriptor from @var{old-port} into @var{new-port}. The
2289current file descriptor in @var{new-port} will be closed.
2290After the redirection the two ports will share a file position
2291and file status flags.
2292
2293The return value is unspecified.
2294
2295Unexpected behaviour can result if both ports are subsequently used
2296and the original and/or duplicate ports are buffered.
2297
2298This procedure does not have any side effects on other ports or
2299revealed counts.
2300@end deffn
2301
2302\fdup->fdes
89d04205 2303@c snarfed from ioext.c:248
780ee65e 2304@deffn primitive dup->fdes fd_or_port [fd]
ae9f3a15
MG
2305Return a new integer file descriptor referring to the open file
2306designated by @var{fd_or_port}, which must be either an open
2307file port or a file descriptor.
780ee65e
NJ
2308@end deffn
2309
2310\fdup2
89d04205 2311@c snarfed from ioext.c:295
780ee65e
NJ
2312@deffn primitive dup2 oldfd newfd
2313A simple wrapper for the @code{dup2} system call.
2314Copies the file descriptor @var{oldfd} to descriptor
2315number @var{newfd}, replacing the previous meaning
2316of @var{newfd}. Both @var{oldfd} and @var{newfd} must
2317be integers.
2318Unlike for dup->fdes or primitive-move->fdes, no attempt
2319is made to move away ports which are using @var{newfd}.
2320The return value is unspecified.
2321@end deffn
2322
2323\ffileno
89d04205 2324@c snarfed from ioext.c:314
780ee65e 2325@deffn primitive fileno port
ae9f3a15
MG
2326Return the integer file descriptor underlying @var{port}. Does
2327not change its revealed count.
780ee65e
NJ
2328@end deffn
2329
2330\fisatty?
89d04205 2331@c snarfed from ioext.c:330
780ee65e 2332@deffn primitive isatty? port
ae9f3a15
MG
2333Return @code{#t} if @var{port} is using a serial non--file
2334device, otherwise @code{#f}.
780ee65e
NJ
2335@end deffn
2336
2337\ffdopen
89d04205 2338@c snarfed from ioext.c:352
780ee65e 2339@deffn primitive fdopen fdes modes
ae9f3a15
MG
2340Return a new port based on the file descriptor @var{fdes}.
2341Modes are given by the string @var{modes}. The revealed count
2342of the port is initialized to zero. The modes string is the
2343same as that accepted by @ref{File Ports, open-file}.
780ee65e
NJ
2344@end deffn
2345
2346\fprimitive-move->fdes
89d04205 2347@c snarfed from ioext.c:377
780ee65e
NJ
2348@deffn primitive primitive-move->fdes port fd
2349Moves the underlying file descriptor for @var{port} to the integer
2350value @var{fdes} without changing the revealed count of @var{port}.
2351Any other ports already using this descriptor will be automatically
2352shifted to new descriptors and their revealed counts reset to zero.
2353The return value is @code{#f} if the file descriptor already had the
2354required value or @code{#t} if it was moved.
2355@end deffn
2356
2357\ffdes->ports
89d04205 2358@c snarfed from ioext.c:411
780ee65e 2359@deffn primitive fdes->ports fd
ae9f3a15
MG
2360Return a list of existing ports which have @var{fdes} as an
2361underlying file descriptor, without changing their revealed
2362counts.
780ee65e
NJ
2363@end deffn
2364
2365\fmake-keyword-from-dash-symbol
2366@c snarfed from keywords.c:71
2367@deffn primitive make-keyword-from-dash-symbol symbol
2368Make a keyword object from a @var{symbol} that starts with a dash.
2369@end deffn
2370
2371\fkeyword?
89d04205 2372@c snarfed from keywords.c:113
780ee65e 2373@deffn primitive keyword? obj
ae9f3a15
MG
2374Return @code{#t} if the argument @var{obj} is a keyword, else
2375@code{#f}.
780ee65e
NJ
2376@end deffn
2377
2378\fkeyword-dash-symbol
89d04205 2379@c snarfed from keywords.c:124
780ee65e
NJ
2380@deffn primitive keyword-dash-symbol keyword
2381Return the dash symbol for @var{keyword}.
2382This is the inverse of @code{make-keyword-from-dash-symbol}.
2383@end deffn
2384
2385\fnil-cons
2386@c snarfed from lang.c:71
2387@deffn primitive nil-cons x y
2388Create a new cons cell with @var{x} as the car and @var{y} as
2389the cdr, but convert @var{y} to Scheme's end-of-list if it is
2390a LISP nil.
2391@end deffn
2392
2393\fnil-car
2394@c snarfed from lang.c:86
2395@deffn primitive nil-car x
2396Return the car of @var{x}, but convert it to LISP nil if it
2397is Scheme's end-of-list.
2398@end deffn
2399
2400\fnil-cdr
2401@c snarfed from lang.c:99
2402@deffn primitive nil-cdr x
2403Return the cdr of @var{x}, but convert it to LISP nil if it
2404is Scheme's end-of-list.
2405@end deffn
2406
2407\fnull
2408@c snarfed from lang.c:114
2409@deffn primitive null x
2410Return LISP's @code{t} if @var{x} is nil in the LISP sense,
2411return LISP's nil otherwise.
2412@end deffn
2413
2414\fnil-eq
2415@c snarfed from lang.c:143
2416@deffn primitive nil-eq x y
2417Compare @var{x} and @var{y} and return LISP's t if they are
2418@code{eq?}, return LISP's nil otherwise.
2419@end deffn
2420
2421\flist
2422@c snarfed from list.c:84
2423@deffn primitive list . objs
2424Return a list containing @var{objs}, the arguments to
2425@code{list}.
2426@end deffn
2427
2428\flist*
2429@c snarfed from list.c:94
2430@deffn primitive list*
2431scm_cons_star
2432@end deffn
2433
2434\fcons*
2435@c snarfed from list.c:105
2436@deffn primitive cons* arg . rest
2437Like @code{list}, but the last arg provides the tail of the
2438constructed list, returning @code{(cons @var{arg1} (cons
a6be01a4 2439@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one
780ee65e
NJ
2440argument. If given one argument, that argument is returned as
2441result. This function is called @code{list*} in some other
2442Schemes and in Common LISP.
2443@end deffn
2444
2445\fnull?
2446@c snarfed from list.c:129
2447@deffn primitive null? x
2448Return @code{#t} iff @var{x} is the empty list, else @code{#f}.
2449@end deffn
2450
2451\flist?
2452@c snarfed from list.c:139
2453@deffn primitive list? x
2454Return @code{#t} iff @var{x} is a proper list, else @code{#f}.
2455@end deffn
2456
2457\flength
2458@c snarfed from list.c:180
2459@deffn primitive length lst
2460Return the number of elements in list @var{lst}.
2461@end deffn
2462
2463\fappend
2464@c snarfed from list.c:209
2465@deffn primitive append . args
2466Return a list consisting of the elements the lists passed as
2467arguments.
ae9f3a15 2468@lisp
780ee65e
NJ
2469(append '(x) '(y)) @result{} (x y)
2470(append '(a) '(b c d)) @result{} (a b c d)
2471(append '(a (b)) '((c))) @result{} (a (b) (c))
ae9f3a15 2472@end lisp
780ee65e
NJ
2473The resulting list is always newly allocated, except that it
2474shares structure with the last list argument. The last
2475argument may actually be any object; an improper list results
2476if the last argument is not a proper list.
ae9f3a15 2477@lisp
780ee65e
NJ
2478(append '(a b) '(c . d)) @result{} (a b c . d)
2479(append '() 'a) @result{} a
ae9f3a15 2480@end lisp
780ee65e
NJ
2481@end deffn
2482
2483\fappend!
89d04205 2484@c snarfed from list.c:243
ae9f3a15
MG
2485@deffn primitive append! . lists
2486A destructive version of @code{append} (@pxref{Pairs and
2487Lists,,,r4rs, The Revised^4 Report on Scheme}). The cdr field
2488of each list's final pair is changed to point to the head of
2489the next list, so no consing is performed. Return a pointer to
2490the mutated list.
780ee65e
NJ
2491@end deffn
2492
2493\flast-pair
89d04205 2494@c snarfed from list.c:269
780ee65e
NJ
2495@deffn primitive last-pair lst
2496Return a pointer to the last pair in @var{lst}, signalling an error if
2497@var{lst} is circular.
2498@end deffn
2499
2500\freverse
89d04205 2501@c snarfed from list.c:299
780ee65e
NJ
2502@deffn primitive reverse lst
2503Return a new list that contains the elements of @var{lst} but
2504in reverse order.
2505@end deffn
2506
2507\freverse!
89d04205 2508@c snarfed from list.c:333
780ee65e
NJ
2509@deffn primitive reverse! lst [new_tail]
2510A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r4rs,
2511The Revised^4 Report on Scheme}). The cdr of each cell in @var{lst} is
2512modified to point to the previous list element. Return a pointer to the
2513head of the reversed list.
2514
2515Caveat: because the list is modified in place, the tail of the original
2516list now becomes its head, and the head of the original list now becomes
2517the tail. Therefore, the @var{lst} symbol to which the head of the
2518original list was bound now points to the tail. To ensure that the head
2519of the modified list is not lost, it is wise to save the return value of
2520@code{reverse!}
2521@end deffn
2522
2523\flist-ref
89d04205 2524@c snarfed from list.c:359
780ee65e
NJ
2525@deffn primitive list-ref list k
2526Return the @var{k}th element from @var{list}.
2527@end deffn
2528
2529\flist-set!
89d04205 2530@c snarfed from list.c:383
780ee65e
NJ
2531@deffn primitive list-set! list k val
2532Set the @var{k}th element of @var{list} to @var{val}.
2533@end deffn
2534
2535\flist-cdr-ref
89d04205 2536@c snarfed from list.c:406
780ee65e
NJ
2537@deffn primitive list-cdr-ref
2538scm_list_tail
2539@end deffn
2540
2541\flist-tail
89d04205 2542@c snarfed from list.c:415
780ee65e
NJ
2543@deffn primitive list-tail lst k
2544@deffnx primitive list-cdr-ref lst k
2545Return the "tail" of @var{lst} beginning with its @var{k}th element.
2546The first element of the list is considered to be element 0.
2547
2548@code{list-tail} and @code{list-cdr-ref} are identical. It may help to
2549think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list,
2550or returning the results of cdring @var{k} times down @var{lst}.
2551@end deffn
2552
2553\flist-cdr-set!
89d04205 2554@c snarfed from list.c:431
780ee65e
NJ
2555@deffn primitive list-cdr-set! list k val
2556Set the @var{k}th cdr of @var{list} to @var{val}.
2557@end deffn
2558
2559\flist-head
89d04205 2560@c snarfed from list.c:460
780ee65e
NJ
2561@deffn primitive list-head lst k
2562Copy the first @var{k} elements from @var{lst} into a new list, and
2563return it.
2564@end deffn
2565
2566\flist-copy
89d04205 2567@c snarfed from list.c:484
780ee65e
NJ
2568@deffn primitive list-copy lst
2569Return a (newly-created) copy of @var{lst}.
2570@end deffn
2571
2572\fsloppy-memq
89d04205 2573@c snarfed from list.c:518
780ee65e
NJ
2574@deffn primitive sloppy-memq x lst
2575This procedure behaves like @code{memq}, but does no type or error checking.
2576Its use is recommended only in writing Guile internals,
2577not for high-level Scheme programs.
2578@end deffn
2579
2580\fsloppy-memv
89d04205 2581@c snarfed from list.c:535
780ee65e
NJ
2582@deffn primitive sloppy-memv x lst
2583This procedure behaves like @code{memv}, but does no type or error checking.
2584Its use is recommended only in writing Guile internals,
2585not for high-level Scheme programs.
2586@end deffn
2587
2588\fsloppy-member
89d04205 2589@c snarfed from list.c:552
780ee65e
NJ
2590@deffn primitive sloppy-member x lst
2591This procedure behaves like @code{member}, but does no type or error checking.
2592Its use is recommended only in writing Guile internals,
2593not for high-level Scheme programs.
2594@end deffn
2595
2596\fmemq
89d04205 2597@c snarfed from list.c:592
780ee65e
NJ
2598@deffn primitive memq x lst
2599Return the first sublist of @var{lst} whose car is @code{eq?}
2600to @var{x} where the sublists of @var{lst} are the non-empty
2601lists returned by @code{(list-tail @var{lst} @var{k})} for
2602@var{k} less than the length of @var{lst}. If @var{x} does not
2603occur in @var{lst}, then @code{#f} (not the empty list) is
2604returned.
2605@end deffn
2606
2607\fmemv
89d04205 2608@c snarfed from list.c:609
780ee65e
NJ
2609@deffn primitive memv x lst
2610Return the first sublist of @var{lst} whose car is @code{eqv?}
2611to @var{x} where the sublists of @var{lst} are the non-empty
2612lists returned by @code{(list-tail @var{lst} @var{k})} for
2613@var{k} less than the length of @var{lst}. If @var{x} does not
2614occur in @var{lst}, then @code{#f} (not the empty list) is
2615returned.
2616@end deffn
2617
2618\fmember
89d04205 2619@c snarfed from list.c:630
780ee65e
NJ
2620@deffn primitive member x lst
2621Return the first sublist of @var{lst} whose car is
2622@code{equal?} to @var{x} where the sublists of @var{lst} are
2623the non-empty lists returned by @code{(list-tail @var{lst}
2624@var{k})} for @var{k} less than the length of @var{lst}. If
2625@var{x} does not occur in @var{lst}, then @code{#f} (not the
2626empty list) is returned.
2627@end deffn
2628
2629\fdelq!
89d04205 2630@c snarfed from list.c:656
780ee65e
NJ
2631@deffn primitive delq! item lst
2632@deffnx primitive delv! item lst
2633@deffnx primitive delete! item lst
2634These procedures are destructive versions of @code{delq}, @code{delv}
2635and @code{delete}: they modify the pointers in the existing @var{lst}
2636rather than creating a new list. Caveat evaluator: Like other
2637destructive list functions, these functions cannot modify the binding of
2638@var{lst}, and so cannot be used to delete the first element of
2639@var{lst} destructively.
2640@end deffn
2641
2642\fdelv!
89d04205 2643@c snarfed from list.c:680
780ee65e
NJ
2644@deffn primitive delv! item lst
2645Destructively remove all elements from @var{lst} that are
2646@code{eqv?} to @var{item}.
2647@end deffn
2648
2649\fdelete!
89d04205 2650@c snarfed from list.c:705
780ee65e
NJ
2651@deffn primitive delete! item lst
2652Destructively remove all elements from @var{lst} that are
2653@code{equal?} to @var{item}.
2654@end deffn
2655
2656\fdelq
89d04205 2657@c snarfed from list.c:734
780ee65e
NJ
2658@deffn primitive delq item lst
2659Return a newly-created copy of @var{lst} with elements
2660@code{eq?} to @var{item} removed. This procedure mirrors
2661@code{memq}: @code{delq} compares elements of @var{lst} against
2662@var{item} with @code{eq?}.
2663@end deffn
2664
2665\fdelv
89d04205 2666@c snarfed from list.c:747
780ee65e
NJ
2667@deffn primitive delv item lst
2668Return a newly-created copy of @var{lst} with elements
2669@code{eqv?} to @var{item} removed. This procedure mirrors
2670@code{memv}: @code{delv} compares elements of @var{lst} against
2671@var{item} with @code{eqv?}.
2672@end deffn
2673
2674\fdelete
89d04205 2675@c snarfed from list.c:760
780ee65e
NJ
2676@deffn primitive delete item lst
2677Return a newly-created copy of @var{lst} with elements
2678@code{equal?} to @var{item} removed. This procedure mirrors
2679@code{member}: @code{delete} compares elements of @var{lst}
2680against @var{item} with @code{equal?}.
2681@end deffn
2682
2683\fdelq1!
89d04205 2684@c snarfed from list.c:773
780ee65e
NJ
2685@deffn primitive delq1! item lst
2686Like @code{delq!}, but only deletes the first occurrence of
2687@var{item} from @var{lst}. Tests for equality using
2688@code{eq?}. See also @code{delv1!} and @code{delete1!}.
2689@end deffn
2690
2691\fdelv1!
89d04205 2692@c snarfed from list.c:801
780ee65e
NJ
2693@deffn primitive delv1! item lst
2694Like @code{delv!}, but only deletes the first occurrence of
2695@var{item} from @var{lst}. Tests for equality using
2696@code{eqv?}. See also @code{delq1!} and @code{delete1!}.
2697@end deffn
2698
2699\fdelete1!
89d04205 2700@c snarfed from list.c:829
780ee65e
NJ
2701@deffn primitive delete1! item lst
2702Like @code{delete!}, but only deletes the first occurrence of
2703@var{item} from @var{lst}. Tests for equality using
2704@code{equal?}. See also @code{delq1!} and @code{delv1!}.
2705@end deffn
2706
2707\fprimitive-load
2708@c snarfed from load.c:112
2709@deffn primitive primitive-load filename
2710Load the file named @var{filename} and evaluate its contents in
2711the top-level environment. The load paths are not searched;
2712@var{filename} must either be a full pathname or be a pathname
2713relative to the current directory. If the variable
2714@code{%load-hook} is defined, it should be bound to a procedure
2715that will be called before any code is loaded. See the
2716documentation for @code{%load-hook} later in this section.
2717@end deffn
2718
2719\f%package-data-dir
2720@c snarfed from load.c:147
2721@deffn primitive %package-data-dir
2722Return the name of the directory where Scheme packages, modules and
2723libraries are kept. On most Unix systems, this will be
2724@samp{/usr/local/share/guile}.
2725@end deffn
2726
2727\f%library-dir
2728@c snarfed from load.c:159
2729@deffn primitive %library-dir
2730Return the directory where the Guile Scheme library files are installed.
2731E.g., may return "/usr/share/guile/1.3.5".
2732@end deffn
2733
2734\f%site-dir
2735@c snarfed from load.c:171
2736@deffn primitive %site-dir
2737Return the directory where the Guile site files are installed.
2738E.g., may return "/usr/share/guile/site".
2739@end deffn
2740
2741\fparse-path
2742@c snarfed from load.c:223
2743@deffn primitive parse-path path [tail]
2744Parse @var{path}, which is expected to be a colon-separated
2745string, into a list and return the resulting list with
2746@var{tail} appended. If @var{path} is @code{#f}, @var{tail}
2747is returned.
2748@end deffn
2749
2750\fsearch-path
2751@c snarfed from load.c:273
2752@deffn primitive search-path path filename [extensions]
2753Search @var{path} for a directory containing a file named
2754@var{filename}. The file must be readable, and not a directory.
2755If we find one, return its full filename; otherwise, return
2756@code{#f}. If @var{filename} is absolute, return it unchanged.
2757If given, @var{extensions} is a list of strings; for each
2758directory in @var{path}, we search for @var{filename}
2759concatenated with each @var{extension}.
2760@end deffn
2761
2762\f%search-load-path
2763@c snarfed from load.c:420
2764@deffn primitive %search-load-path filename
2765Search @var{%load-path} for the file named @var{filename},
2766which must be readable by the current user. If @var{filename}
2767is found in the list of paths to search or is an absolute
2768pathname, return its full pathname. Otherwise, return
2769@code{#f}. Filenames may have any of the optional extensions
2770in the @code{%load-extensions} list; @code{%search-load-path}
2771will try each extension automatically.
2772@end deffn
2773
2774\fprimitive-load-path
2775@c snarfed from load.c:441
2776@deffn primitive primitive-load-path filename
2777Search @var{%load-path} for the file named @var{filename} and
2778load it into the top-level environment. If @var{filename} is a
2779relative pathname and is not found in the list of search paths,
2780an error is signalled.
2781@end deffn
2782
2783\fread-and-eval!
2784@c snarfed from load.c:476
2785@deffn primitive read-and-eval! [port]
2786Read a form from @var{port} (standard input by default), and evaluate it
2787(memoizing it in the process) in the top-level environment. If no data
2788is left to be read from @var{port}, an @code{end-of-file} error is
2789signalled.
2790@end deffn
2791
2792\fprocedure->syntax
72ad43dc 2793@c snarfed from macros.c:106
780ee65e 2794@deffn primitive procedure->syntax code
ae9f3a15
MG
2795Return a @dfn{macro} which, when a symbol defined to this value
2796appears as the first symbol in an expression, returns the
2797result of applying @var{code} to the expression and the
2798environment.
780ee65e
NJ
2799@end deffn
2800
2801\fprocedure->macro
72ad43dc 2802@c snarfed from macros.c:129
780ee65e 2803@deffn primitive procedure->macro code
ae9f3a15
MG
2804Return a @dfn{macro} which, when a symbol defined to this value
2805appears as the first symbol in an expression, evaluates the
2806result of applying @var{code} to the expression and the
2807environment. The value returned from @var{code} which has been
2808passed to @code{procedure->memoizing-macro} replaces the form
2809passed to @var{code}. For example:
2810@lisp
780ee65e
NJ
2811(define trace
2812 (procedure->macro
2813 (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x))))))
2814
2815(trace @i{foo}) @equiv{} (set! @i{foo} (tracef @i{foo} '@i{foo})).
ae9f3a15 2816@end lisp
780ee65e
NJ
2817@end deffn
2818
2819\fprocedure->memoizing-macro
72ad43dc 2820@c snarfed from macros.c:152
780ee65e 2821@deffn primitive procedure->memoizing-macro code
ae9f3a15
MG
2822Return a @dfn{macro} which, when a symbol defined to this value
2823appears as the first symbol in an expression, evaluates the
2824result of applying @var{proc} to the expression and the
2825environment. The value returned from @var{proc} which has been
2826passed to @code{procedure->memoizing-macro} replaces the form
2827passed to @var{proc}. For example:
2828@lisp
780ee65e
NJ
2829(define trace
2830 (procedure->macro
2831 (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x))))))
2832
2833(trace @i{foo}) @equiv{} (set! @i{foo} (tracef @i{foo} '@i{foo})).
ae9f3a15 2834@end lisp
780ee65e
NJ
2835@end deffn
2836
2837\fmacro?
72ad43dc 2838@c snarfed from macros.c:164
780ee65e
NJ
2839@deffn primitive macro? obj
2840Return @code{#t} if @var{obj} is a regular macro, a memoizing macro or a
2841syntax transformer.
2842@end deffn
2843
2844\fmacro-type
72ad43dc 2845@c snarfed from macros.c:182
780ee65e 2846@deffn primitive macro-type m
ae9f3a15
MG
2847Return one of the symbols @code{syntax}, @code{macro} or
2848@code{macro!}, depending on whether @var{m} is a syntax
2849tranformer, a regular macro, or a memoizing macro,
2850respectively. If @var{m} is not a macro, @code{#f} is
2851returned.
780ee65e
NJ
2852@end deffn
2853
2854\fmacro-name
72ad43dc 2855@c snarfed from macros.c:200
780ee65e
NJ
2856@deffn primitive macro-name m
2857Return the name of the macro @var{m}.
2858@end deffn
2859
2860\fmacro-transformer
72ad43dc 2861@c snarfed from macros.c:211
780ee65e
NJ
2862@deffn primitive macro-transformer m
2863Return the transformer of the macro @var{m}.
2864@end deffn
2865
2866\finteraction-environment
2867@c snarfed from modules.c:102
2868@deffn primitive interaction-environment
ae9f3a15
MG
2869Return a specifier for the environment that contains
2870implementation--defined bindings, typically a superset of those
2871listed in the report. The intent is that this procedure will
2872return the environment in which the implementation would
2873evaluate expressions dynamically typed by the user.
780ee65e
NJ
2874@end deffn
2875
2876\fstandard-eval-closure
2877@c snarfed from modules.c:271
2878@deffn primitive standard-eval-closure module
2879Return an eval closure for the module @var{module}.
2880@end deffn
2881
2882\finet-aton
2883@c snarfed from net_db.c:96
2884@deffn primitive inet-aton address
ae9f3a15
MG
2885Converts a string containing an Internet host address in the
2886traditional dotted decimal notation into an integer.
2887@lisp
780ee65e 2888(inet-aton "127.0.0.1") @result{} 2130706433
ae9f3a15 2889@end lisp
780ee65e
NJ
2890@end deffn
2891
2892\finet-ntoa
2893@c snarfed from net_db.c:116
2894@deffn primitive inet-ntoa inetid
ae9f3a15
MG
2895Converts an integer Internet host address into a string with
2896the traditional dotted decimal representation.
2897@lisp
780ee65e 2898(inet-ntoa 2130706433) @result{} "127.0.0.1"
ae9f3a15 2899@end lisp
780ee65e
NJ
2900@end deffn
2901
2902\finet-netof
89d04205 2903@c snarfed from net_db.c:136
780ee65e 2904@deffn primitive inet-netof address
ae9f3a15
MG
2905Return the network number part of the given integer Internet
2906address.
2907@lisp
780ee65e 2908(inet-netof 2130706433) @result{} 127
ae9f3a15 2909@end lisp
780ee65e
NJ
2910@end deffn
2911
2912\finet-lnaof
89d04205 2913@c snarfed from net_db.c:153
780ee65e 2914@deffn primitive inet-lnaof address
ae9f3a15
MG
2915Return the local-address-with-network part of the given
2916Internet address.
2917@lisp
780ee65e 2918(inet-lnaof 2130706433) @result{} 1
ae9f3a15 2919@end lisp
780ee65e
NJ
2920@end deffn
2921
2922\finet-makeaddr
89d04205 2923@c snarfed from net_db.c:171
780ee65e 2924@deffn primitive inet-makeaddr net lna
ae9f3a15
MG
2925Makes an Internet host address by combining the network number
2926@var{net} with the local-address-within-network number
2927@var{lna}.
2928@lisp
780ee65e 2929(inet-makeaddr 127 1) @result{} 2130706433
ae9f3a15 2930@end lisp
780ee65e
NJ
2931@end deffn
2932
2933\fgethost
89d04205 2934@c snarfed from net_db.c:256
780ee65e
NJ
2935@deffn primitive gethost [host]
2936@deffnx procedure gethostbyname hostname
2937@deffnx procedure gethostbyaddr address
2938Look up a host by name or address, returning a host object. The
2939@code{gethost} procedure will accept either a string name or an integer
2940address; if given no arguments, it behaves like @code{gethostent} (see
2941below). If a name or address is supplied but the address can not be
2942found, an error will be thrown to one of the keys:
2943@code{host-not-found}, @code{try-again}, @code{no-recovery} or
2944@code{no-data}, corresponding to the equivalent @code{h_error} values.
2945Unusual conditions may result in errors thrown to the
2946@code{system-error} or @code{misc_error} keys.
2947@end deffn
2948
2949\fgetnet
89d04205 2950@c snarfed from net_db.c:337
780ee65e
NJ
2951@deffn primitive getnet [net]
2952@deffnx procedure getnetbyname net-name
2953@deffnx procedure getnetbyaddr net-number
2954Look up a network by name or net number in the network database. The
2955@var{net-name} argument must be a string, and the @var{net-number}
2956argument must be an integer. @code{getnet} will accept either type of
2957argument, behaving like @code{getnetent} (see below) if no arguments are
2958given.
2959@end deffn
2960
2961\fgetproto
89d04205 2962@c snarfed from net_db.c:387
780ee65e
NJ
2963@deffn primitive getproto [protocol]
2964@deffnx procedure getprotobyname name
2965@deffnx procedure getprotobynumber number
2966Look up a network protocol by name or by number. @code{getprotobyname}
2967takes a string argument, and @code{getprotobynumber} takes an integer
2968argument. @code{getproto} will accept either type, behaving like
2969@code{getprotoent} (see below) if no arguments are supplied.
2970@end deffn
2971
2972\fgetserv
89d04205 2973@c snarfed from net_db.c:454
780ee65e
NJ
2974@deffn primitive getserv [name [protocol]]
2975@deffnx procedure getservbyname name protocol
2976@deffnx procedure getservbyport port protocol
2977Look up a network service by name or by service number, and return a
2978network service object. The @var{protocol} argument specifies the name
2979of the desired protocol; if the protocol found in the network service
2980database does not match this name, a system error is signalled.
2981
2982The @code{getserv} procedure will take either a service name or number
2983as its first argument; if given no arguments, it behaves like
2984@code{getservent} (see below).
2985@end deffn
2986
2987\fsethost
89d04205 2988@c snarfed from net_db.c:493
780ee65e
NJ
2989@deffn primitive sethost [stayopen]
2990If @var{stayopen} is omitted, this is equivalent to @code{endhostent}.
2991Otherwise it is equivalent to @code{sethostent stayopen}.
2992@end deffn
2993
2994\fsetnet
89d04205 2995@c snarfed from net_db.c:509
780ee65e
NJ
2996@deffn primitive setnet [stayopen]
2997If @var{stayopen} is omitted, this is equivalent to @code{endnetent}.
2998Otherwise it is equivalent to @code{setnetent stayopen}.
2999@end deffn
3000
3001\fsetproto
89d04205 3002@c snarfed from net_db.c:525
780ee65e
NJ
3003@deffn primitive setproto [stayopen]
3004If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}.
3005Otherwise it is equivalent to @code{setprotoent stayopen}.
3006@end deffn
3007
3008\fsetserv
89d04205 3009@c snarfed from net_db.c:541
780ee65e
NJ
3010@deffn primitive setserv [stayopen]
3011If @var{stayopen} is omitted, this is equivalent to @code{endservent}.
3012Otherwise it is equivalent to @code{setservent stayopen}.
3013@end deffn
3014
3015\fexact?
3016@c snarfed from numbers.c:106
3017@deffn primitive exact? x
3018Return @code{#t} if @var{x} is an exact number, @code{#f}
3019otherwise.
3020@end deffn
3021
3022\fodd?
3023@c snarfed from numbers.c:123
3024@deffn primitive odd? n
3025Return @code{#t} if @var{n} is an odd number, @code{#f}
3026otherwise.
3027@end deffn
3028
3029\feven?
3030@c snarfed from numbers.c:140
3031@deffn primitive even? n
3032Return @code{#t} if @var{n} is an even number, @code{#f}
3033otherwise.
3034@end deffn
3035
3036\flogand
3037@c snarfed from numbers.c:755
3038@deffn primitive logand n1 n2
ae9f3a15 3039Return the integer which is the bit-wise AND of the two integer
780ee65e 3040arguments.
780ee65e
NJ
3041@lisp
3042(number->string (logand #b1100 #b1010) 2)
3043 @result{} "1000"
3044@end lisp
3045@end deffn
3046
3047\flogior
3048@c snarfed from numbers.c:842
3049@deffn primitive logior n1 n2
ae9f3a15 3050Return the integer which is the bit-wise OR of the two integer
780ee65e 3051arguments.
780ee65e
NJ
3052@lisp
3053(number->string (logior #b1100 #b1010) 2)
3054 @result{} "1110"
3055@end lisp
3056@end deffn
3057
3058\flogxor
3059@c snarfed from numbers.c:928
3060@deffn primitive logxor n1 n2
ae9f3a15 3061Return the integer which is the bit-wise XOR of the two integer
780ee65e 3062arguments.
780ee65e
NJ
3063@lisp
3064(number->string (logxor #b1100 #b1010) 2)
3065 @result{} "110"
3066@end lisp
3067@end deffn
3068
3069\flogtest
3070@c snarfed from numbers.c:997
ae9f3a15
MG
3071@deffn primitive logtest j k
3072@lisp
780ee65e
NJ
3073(logtest j k) @equiv{} (not (zero? (logand j k)))
3074
3075(logtest #b0100 #b1011) @result{} #f
3076(logtest #b0100 #b0111) @result{} #t
ae9f3a15 3077@end lisp
780ee65e
NJ
3078@end deffn
3079
3080\flogbit?
3081@c snarfed from numbers.c:1054
3082@deffn primitive logbit? index j
ae9f3a15 3083@lisp
780ee65e
NJ
3084(logbit? index j) @equiv{} (logtest (integer-expt 2 index) j)
3085
3086(logbit? 0 #b1101) @result{} #t
3087(logbit? 1 #b1101) @result{} #f
3088(logbit? 2 #b1101) @result{} #t
3089(logbit? 3 #b1101) @result{} #t
3090(logbit? 4 #b1101) @result{} #f
ae9f3a15 3091@end lisp
780ee65e
NJ
3092@end deffn
3093
3094\flognot
89d04205 3095@c snarfed from numbers.c:1103
780ee65e 3096@deffn primitive lognot n
ae9f3a15
MG
3097Return the integer which is the 2s-complement of the integer
3098argument.
780ee65e
NJ
3099@lisp
3100(number->string (lognot #b10000000) 2)
3101 @result{} "-10000001"
3102(number->string (lognot #b0) 2)
3103 @result{} "-1"
3104@end lisp
3105@end deffn
3106
3107\finteger-expt
89d04205 3108@c snarfed from numbers.c:1120
780ee65e 3109@deffn primitive integer-expt n k
ae9f3a15
MG
3110Return @var{n} raised to the non-negative integer exponent
3111@var{k}.
780ee65e
NJ
3112@lisp
3113(integer-expt 2 5)
3114 @result{} 32
3115(integer-expt -3 3)
3116 @result{} -27
3117@end lisp
3118@end deffn
3119
3120\fash
89d04205 3121@c snarfed from numbers.c:1167
780ee65e 3122@deffn primitive ash n cnt
ae9f3a15
MG
3123The function ash performs an arithmetic shift left by @var{cnt}
3124bits (or shift right, if @var{cnt} is negative). 'Arithmetic'
3125means, that the function does not guarantee to keep the bit
3126structure of @var{n}, but rather guarantees that the result
3127will always be rounded towards minus infinity. Therefore, the
3128results of ash and a corresponding bitwise shift will differ if
3129@var{n} is negative.
780ee65e
NJ
3130Formally, the function returns an integer equivalent to
3131@code{(inexact->exact (floor (* @var{n} (expt 2 @var{cnt}))))}.
780ee65e 3132@lisp
ae9f3a15
MG
3133(number->string (ash #b1 3) 2) @result{} "1000"
3134(number->string (ash #b1010 -1) 2) @result{} "101"
780ee65e
NJ
3135@end lisp
3136@end deffn
3137
3138\fbit-extract
89d04205 3139@c snarfed from numbers.c:1220
780ee65e 3140@deffn primitive bit-extract n start end
ae9f3a15
MG
3141Return the integer composed of the @var{start} (inclusive)
3142through @var{end} (exclusive) bits of @var{n}. The
3143@var{start}th bit becomes the 0-th bit in the result.
780ee65e
NJ
3144@lisp
3145(number->string (bit-extract #b1101101010 0 4) 2)
3146 @result{} "1010"
3147(number->string (bit-extract #b1101101010 4 9) 2)
3148 @result{} "10110"
3149@end lisp
3150@end deffn
3151
3152\flogcount
89d04205 3153@c snarfed from numbers.c:1292
780ee65e 3154@deffn primitive logcount n
ae9f3a15
MG
3155Return the number of bits in integer @var{n}. If integer is
3156positive, the 1-bits in its binary representation are counted.
3157If negative, the 0-bits in its two's-complement binary
3158representation are counted. If 0, 0 is returned.
780ee65e
NJ
3159@lisp
3160(logcount #b10101010)
3161 @result{} 4
3162(logcount 0)
3163 @result{} 0
3164(logcount -2)
3165 @result{} 1
3166@end lisp
3167@end deffn
3168
3169\finteger-length
89d04205 3170@c snarfed from numbers.c:1343
780ee65e 3171@deffn primitive integer-length n
ae9f3a15 3172Return the number of bits neccessary to represent @var{n}.
780ee65e
NJ
3173@lisp
3174(integer-length #b10101010)
3175 @result{} 8
3176(integer-length 0)
3177 @result{} 0
3178(integer-length #b1111)
3179 @result{} 4
3180@end lisp
3181@end deffn
3182
3183\fnumber->string
89d04205 3184@c snarfed from numbers.c:2289
780ee65e
NJ
3185@deffn primitive number->string n [radix]
3186Return a string holding the external representation of the
3187number @var{n} in the given @var{radix}. If @var{n} is
3188inexact, a radix of 10 will be used.
3189@end deffn
3190
3191\fstring->number
89d04205 3192@c snarfed from numbers.c:2874
780ee65e 3193@deffn primitive string->number string [radix]
ae9f3a15 3194Return a number of the maximally precise representation
780ee65e
NJ
3195expressed by the given @var{string}. @var{radix} must be an
3196exact integer, either 2, 8, 10, or 16. If supplied, @var{radix}
3197is a default radix that may be overridden by an explicit radix
3198prefix in @var{string} (e.g. "#o177"). If @var{radix} is not
3199supplied, then the default radix is 10. If string is not a
3200syntactically valid notation for a number, then
3201@code{string->number} returns @code{#f}.
3202@end deffn
3203
3204\fnumber?
89d04205 3205@c snarfed from numbers.c:2941
780ee65e
NJ
3206@deffn primitive number?
3207scm_number_p
3208@end deffn
3209
3210\fcomplex?
89d04205 3211@c snarfed from numbers.c:2953
780ee65e
NJ
3212@deffn primitive complex? x
3213Return @code{#t} if @var{x} is a complex number, @code{#f}
3214else. Note that the sets of real, rational and integer
3215values form subsets of the set of complex numbers, i. e. the
3216predicate will also be fulfilled if @var{x} is a real,
3217rational or integer number.
3218@end deffn
3219
3220\freal?
89d04205 3221@c snarfed from numbers.c:2961
780ee65e
NJ
3222@deffn primitive real?
3223scm_real_p
3224@end deffn
3225
3226\frational?
89d04205 3227@c snarfed from numbers.c:2974
780ee65e
NJ
3228@deffn primitive rational? x
3229Return @code{#t} if @var{x} is a rational number, @code{#f}
3230else. Note that the set of integer values forms a subset of
3231the set of rational numbers, i. e. the predicate will also be
3232fulfilled if @var{x} is an integer number. Real numbers
3233will also satisfy this predicate, because of their limited
3234precision.
3235@end deffn
3236
3237\finteger?
89d04205 3238@c snarfed from numbers.c:2995
780ee65e
NJ
3239@deffn primitive integer? x
3240Return @code{#t} if @var{x} is an integer number, @code{#f}
3241else.
3242@end deffn
3243
3244\finexact?
89d04205 3245@c snarfed from numbers.c:3020
780ee65e
NJ
3246@deffn primitive inexact? x
3247Return @code{#t} if @var{x} is an inexact number, @code{#f}
3248else.
3249@end deffn
3250
3251\f$expt
89d04205 3252@c snarfed from numbers.c:4072
780ee65e
NJ
3253@deffn primitive $expt x y
3254Return @var{x} raised to the power of @var{y}. This
3255procedure does not accept complex arguments.
3256@end deffn
3257
3258\f$atan2
89d04205 3259@c snarfed from numbers.c:4088
780ee65e
NJ
3260@deffn primitive $atan2 x y
3261Return the arc tangent of the two arguments @var{x} and
3262@var{y}. This is similar to calculating the arc tangent of
3263@var{x} / @var{y}, except that the signs of both arguments
3264are used to determine the quadrant of the result. This
3265procedure does not accept complex arguments.
3266@end deffn
3267
3268\fmake-rectangular
89d04205 3269@c snarfed from numbers.c:4101
780ee65e
NJ
3270@deffn primitive make-rectangular real imaginary
3271Return a complex number constructed of the given @var{real} and
3272@var{imaginary} parts.
3273@end deffn
3274
3275\fmake-polar
89d04205 3276@c snarfed from numbers.c:4114
780ee65e
NJ
3277@deffn primitive make-polar x y
3278Return the complex number @var{x} * e^(i * @var{y}).
3279@end deffn
3280
3281\finexact->exact
89d04205 3282@c snarfed from numbers.c:4232
780ee65e 3283@deffn primitive inexact->exact z
ae9f3a15 3284Return an exact number that is numerically closest to @var{z}.
780ee65e
NJ
3285@end deffn
3286
3287\fclass-of
3288@c snarfed from objects.c:88
3289@deffn primitive class-of x
3290Return the class of @var{x}.
3291@end deffn
3292
3293\fentity?
3294@c snarfed from objects.c:359
3295@deffn primitive entity? obj
3296Return @code{#t} if @var{obj} is an entity.
3297@end deffn
3298
3299\foperator?
3300@c snarfed from objects.c:368
3301@deffn primitive operator? obj
3302Return @code{#t} if @var{obj} is an operator.
3303@end deffn
3304
3305\fset-object-procedure!
3306@c snarfed from objects.c:380
3307@deffn primitive set-object-procedure! obj proc
3308Return the object procedure of @var{obj} to @var{proc}.
3309@var{obj} must be either an entity or an operator.
3310@end deffn
3311
3312\fmake-class-object
3313@c snarfed from objects.c:440
3314@deffn primitive make-class-object metaclass layout
3315Create a new class object of class @var{metaclass}, with the
3316slot layout specified by @var{layout}.
3317@end deffn
3318
3319\fmake-subclass-object
3320@c snarfed from objects.c:455
3321@deffn primitive make-subclass-object class layout
3322Create a subclass object of @var{class}, with the slot layout
3323specified by @var{layout}.
3324@end deffn
3325
3326\fobject-properties
3327@c snarfed from objprop.c:62
3328@deffn primitive object-properties obj
3329@deffnx primitive procedure-properties obj
3330Return @var{obj}'s property list.
3331@end deffn
3332
3333\fset-object-properties!
3334@c snarfed from objprop.c:73
ae9f3a15 3335@deffn primitive set-object-properties! obj alist
780ee65e
NJ
3336@deffnx primitive set-procedure-properties! obj alist
3337Set @var{obj}'s property list to @var{alist}.
3338@end deffn
3339
3340\fobject-property
3341@c snarfed from objprop.c:85
3342@deffn primitive object-property obj key
3343@deffnx primitive procedure-property obj key
3344Return the property of @var{obj} with name @var{key}.
3345@end deffn
3346
3347\fset-object-property!
3348@c snarfed from objprop.c:98
ae9f3a15 3349@deffn primitive set-object-property! obj key value
780ee65e 3350@deffnx primitive set-procedure-property! obj key value
ae9f3a15
MG
3351In @var{obj}'s property list, set the property named @var{key}
3352to @var{value}.
780ee65e
NJ
3353@end deffn
3354
3355\fcons
3356@c snarfed from pairs.c:61
3357@deffn primitive cons x y
ae9f3a15
MG
3358Return a newly allocated pair whose car is @var{x} and whose
3359cdr is @var{y}. The pair is guaranteed to be different (in the
3360sense of @code{eq?}) from every previously existing object.
780ee65e
NJ
3361@end deffn
3362
3363\fpair?
89d04205 3364@c snarfed from pairs.c:94
780ee65e 3365@deffn primitive pair? x
ae9f3a15
MG
3366Return @code{#t} if @var{x} is a pair; otherwise return
3367@code{#f}.
780ee65e
NJ
3368@end deffn
3369
3370\fset-car!
89d04205 3371@c snarfed from pairs.c:105
780ee65e
NJ
3372@deffn primitive set-car! pair value
3373Stores @var{value} in the car field of @var{pair}. The value returned
3374by @code{set-car!} is unspecified.
3375@end deffn
3376
3377\fset-cdr!
89d04205 3378@c snarfed from pairs.c:118
780ee65e
NJ
3379@deffn primitive set-cdr! pair value
3380Stores @var{value} in the cdr field of @var{pair}. The value returned
3381by @code{set-cdr!} is unspecified.
3382@end deffn
3383
3384\fchar-ready?
3385@c snarfed from ports.c:246
3386@deffn primitive char-ready? [port]
ae9f3a15
MG
3387Return @code{#t} if a character is ready on input @var{port}
3388and return @code{#f} otherwise. If @code{char-ready?} returns
3389@code{#t} then the next @code{read-char} operation on
3390@var{port} is guaranteed not to hang. If @var{port} is a file
3391port at end of file then @code{char-ready?} returns @code{#t}.
780ee65e 3392@footnote{@code{char-ready?} exists to make it possible for a
ae9f3a15
MG
3393program to accept characters from interactive ports without
3394getting stuck waiting for input. Any input editors associated
3395with such ports must make sure that characters whose existence
3396has been asserted by @code{char-ready?} cannot be rubbed out.
3397If @code{char-ready?} were to return @code{#f} at end of file,
3398a port at end of file would be indistinguishable from an
3399interactive port that has no ready characters.}
780ee65e
NJ
3400@end deffn
3401
3402\fdrain-input
3403@c snarfed from ports.c:312
3404@deffn primitive drain-input port
3405Drain @var{port}'s read buffers (including any pushed-back
ae9f3a15 3406characters) and return the content as a single string.
780ee65e
NJ
3407@end deffn
3408
3409\fcurrent-input-port
3410@c snarfed from ports.c:339
3411@deffn primitive current-input-port
3412Return the current input port. This is the default port used
3413by many input procedures. Initially, @code{current-input-port}
3414returns the @dfn{standard input} in Unix and C terminology.
3415@end deffn
3416
3417\fcurrent-output-port
3418@c snarfed from ports.c:351
3419@deffn primitive current-output-port
3420Return the current output port. This is the default port used
3421by many output procedures. Initially,
3422@code{current-output-port} returns the @dfn{standard output} in
3423Unix and C terminology.
3424@end deffn
3425
3426\fcurrent-error-port
3427@c snarfed from ports.c:361
3428@deffn primitive current-error-port
3429Return the port to which errors and warnings should be sent (the
3430@dfn{standard error} in Unix and C terminology).
3431@end deffn
3432
3433\fcurrent-load-port
3434@c snarfed from ports.c:371
3435@deffn primitive current-load-port
3436Return the current-load-port.
3437The load port is used internally by @code{primitive-load}.
3438@end deffn
3439
3440\fset-current-input-port
3441@c snarfed from ports.c:384
3442@deffn primitive set-current-input-port port
3443@deffnx primitive set-current-output-port port
3444@deffnx primitive set-current-error-port port
3445Change the ports returned by @code{current-input-port},
3446@code{current-output-port} and @code{current-error-port}, respectively,
3447so that they use the supplied @var{port} for input or output.
3448@end deffn
3449
3450\fset-current-output-port
3451@c snarfed from ports.c:397
3452@deffn primitive set-current-output-port port
3453Set the current default output port to @var{port}.
3454@end deffn
3455
3456\fset-current-error-port
3457@c snarfed from ports.c:411
3458@deffn primitive set-current-error-port port
3459Set the current default error port to @var{port}.
3460@end deffn
3461
3462\fport-revealed
3463@c snarfed from ports.c:556
3464@deffn primitive port-revealed port
ae9f3a15 3465Return the revealed count for @var{port}.
780ee65e
NJ
3466@end deffn
3467
3468\fset-port-revealed!
3469@c snarfed from ports.c:569
3470@deffn primitive set-port-revealed! port rcount
3471Sets the revealed count for a port to a given value.
3472The return value is unspecified.
3473@end deffn
3474
3475\fport-mode
3476@c snarfed from ports.c:612
3477@deffn primitive port-mode port
ae9f3a15
MG
3478Return the port modes associated with the open port @var{port}.
3479These will not necessarily be identical to the modes used when
3480the port was opened, since modes such as "append" which are
3481used only during port creation are not retained.
780ee65e
NJ
3482@end deffn
3483
3484\fclose-port
3485@c snarfed from ports.c:649
3486@deffn primitive close-port port
ae9f3a15
MG
3487Close the specified port object. Return @code{#t} if it
3488successfully closes a port or @code{#f} if it was already
3489closed. An exception may be raised if an error occurs, for
3490example when flushing buffered output. See also @ref{Ports and
3491File Descriptors, close}, for a procedure which can close file
3492descriptors.
780ee65e
NJ
3493@end deffn
3494
3495\fclose-input-port
3496@c snarfed from ports.c:677
3497@deffn primitive close-input-port port
3498Close the specified input port object. The routine has no effect if
3499the file has already been closed. An exception may be raised if an
3500error occurs. The value returned is unspecified.
3501
3502See also @ref{Ports and File Descriptors, close}, for a procedure
3503which can close file descriptors.
3504@end deffn
3505
3506\fclose-output-port
3507@c snarfed from ports.c:692
3508@deffn primitive close-output-port port
3509Close the specified output port object. The routine has no effect if
3510the file has already been closed. An exception may be raised if an
3511error occurs. The value returned is unspecified.
3512
3513See also @ref{Ports and File Descriptors, close}, for a procedure
3514which can close file descriptors.
3515@end deffn
3516
3517\fport-for-each
3518@c snarfed from ports.c:709
3519@deffn primitive port-for-each proc
3520Apply @var{proc} to each port in the Guile port table
3521in turn. The return value is unspecified. More specifically,
3522@var{proc} is applied exactly once to every port that exists
3523in the system at the time @var{port-for-each} is invoked.
3524Changes to the port table while @var{port-for-each} is running
3525have no effect as far as @var{port-for-each} is concerned.
3526@end deffn
3527
3528\fclose-all-ports-except
3529@c snarfed from ports.c:752
3530@deffn primitive close-all-ports-except . ports
3531[DEPRECATED] Close all open file ports used by the interpreter
3532except for those supplied as arguments. This procedure
3533was intended to be used before an exec call to close file descriptors
3534which are not needed in the new process. However it has the
3535undesirable side-effect of flushing buffes, so it's deprecated.
3536Use port-for-each instead.
3537@end deffn
3538
3539\finput-port?
3540@c snarfed from ports.c:791
3541@deffn primitive input-port? x
ae9f3a15 3542Return @code{#t} if @var{x} is an input port, otherwise return
780ee65e
NJ
3543@code{#f}. Any object satisfying this predicate also satisfies
3544@code{port?}.
3545@end deffn
3546
3547\foutput-port?
3548@c snarfed from ports.c:804
3549@deffn primitive output-port? x
ae9f3a15 3550Return @code{#t} if @var{x} is an output port, otherwise return
780ee65e
NJ
3551@code{#f}. Any object satisfying this predicate also satisfies
3552@code{port?}.
3553@end deffn
3554
3555\fport?
3556@c snarfed from ports.c:819
3557@deffn primitive port? x
ae9f3a15 3558Return a boolean indicating whether @var{x} is a port.
780ee65e
NJ
3559Equivalent to @code{(or (input-port? @var{x}) (output-port?
3560@var{x}))}.
3561@end deffn
3562
3563\fport-closed?
89d04205 3564@c snarfed from ports.c:829
780ee65e 3565@deffn primitive port-closed? port
ae9f3a15
MG
3566Return @code{#t} if @var{port} is closed or @code{#f} if it is
3567open.
780ee65e
NJ
3568@end deffn
3569
3570\feof-object?
89d04205 3571@c snarfed from ports.c:840
780ee65e 3572@deffn primitive eof-object? x
ae9f3a15
MG
3573Return @code{#t} if @var{x} is an end-of-file object; otherwise
3574return @code{#f}.
780ee65e
NJ
3575@end deffn
3576
3577\fforce-output
89d04205 3578@c snarfed from ports.c:854
780ee65e
NJ
3579@deffn primitive force-output [port]
3580Flush the specified output port, or the current output port if @var{port}
3581is omitted. The current output buffer contents are passed to the
3582underlying port implementation (e.g., in the case of fports, the
3583data will be written to the file and the output buffer will be cleared.)
3584It has no effect on an unbuffered port.
3585
3586The return value is unspecified.
3587@end deffn
3588
3589\fflush-all-ports
89d04205 3590@c snarfed from ports.c:872
780ee65e
NJ
3591@deffn primitive flush-all-ports
3592Equivalent to calling @code{force-output} on
3593all open output ports. The return value is unspecified.
3594@end deffn
3595
3596\fread-char
89d04205 3597@c snarfed from ports.c:890
780ee65e 3598@deffn primitive read-char [port]
ae9f3a15 3599Return the next character available from @var{port}, updating
780ee65e 3600@var{port} to point to the following character. If no more
ae9f3a15 3601characters are available, the end-of-file object is returned.
780ee65e
NJ
3602@end deffn
3603
3604\fpeek-char
89d04205 3605@c snarfed from ports.c:1207
780ee65e 3606@deffn primitive peek-char [port]
ae9f3a15 3607Return the next character available from @var{port},
780ee65e 3608@emph{without} updating @var{port} to point to the following
ae9f3a15
MG
3609character. If no more characters are available, the
3610end-of-file object is returned.@footnote{The value returned by
3611a call to @code{peek-char} is the same as the value that would
3612have been returned by a call to @code{read-char} on the same
3613port. The only difference is that the very next call to
3614@code{read-char} or @code{peek-char} on that @var{port} will
3615return the value returned by the preceding call to
3616@code{peek-char}. In particular, a call to @code{peek-char} on
3617an interactive port will hang waiting for input whenever a call
3618to @code{read-char} would have hung.}
780ee65e
NJ
3619@end deffn
3620
3621\funread-char
89d04205 3622@c snarfed from ports.c:1228
780ee65e
NJ
3623@deffn primitive unread-char cobj [port]
3624Place @var{char} in @var{port} so that it will be read by the
3625next read operation. If called multiple times, the unread characters
3626will be read again in last-in first-out order. If @var{port} is
3627not supplied, the current input port is used.
3628@end deffn
3629
3630\funread-string
89d04205 3631@c snarfed from ports.c:1251
780ee65e
NJ
3632@deffn primitive unread-string str port
3633Place the string @var{str} in @var{port} so that its characters will be
3634read in subsequent read operations. If called multiple times, the
3635unread characters will be read again in last-in first-out order. If
3636@var{port} is not supplied, the current-input-port is used.
3637@end deffn
3638
3639\fseek
89d04205 3640@c snarfed from ports.c:1290
ae9f3a15
MG
3641@deffn primitive seek fd_port offset whence
3642Sets the current position of @var{fd/port} to the integer
3643@var{offset}, which is interpreted according to the value of
3644@var{whence}.
3645One of the following variables should be supplied for
3646@var{whence}:
780ee65e
NJ
3647@defvar SEEK_SET
3648Seek from the beginning of the file.
3649@end defvar
3650@defvar SEEK_CUR
3651Seek from the current position.
3652@end defvar
3653@defvar SEEK_END
3654Seek from the end of the file.
3655@end defvar
ae9f3a15
MG
3656If @var{fd/port} is a file descriptor, the underlying system
3657call is @code{lseek}. @var{port} may be a string port.
3658The value returned is the new position in the file. This means
3659that the current position of a port can be obtained using:
3660@lisp
780ee65e 3661(seek port 0 SEEK_CUR)
ae9f3a15 3662@end lisp
780ee65e
NJ
3663@end deffn
3664
3665\ftruncate-file
89d04205 3666@c snarfed from ports.c:1331
780ee65e 3667@deffn primitive truncate-file object [length]
ae9f3a15
MG
3668Truncates the object referred to by @var{object} to at most
3669@var{length} bytes. @var{object} can be a string containing a
3670file name or an integer file descriptor or a port.
3671@var{length} may be omitted if @var{object} is not a file name,
3672in which case the truncation occurs at the current port.
3673position. The return value is unspecified.
780ee65e
NJ
3674@end deffn
3675
3676\fport-line
89d04205 3677@c snarfed from ports.c:1385
780ee65e
NJ
3678@deffn primitive port-line port
3679Return the current line number for @var{port}.
3680@end deffn
3681
3682\fset-port-line!
89d04205 3683@c snarfed from ports.c:1396
780ee65e
NJ
3684@deffn primitive set-port-line! port line
3685Set the current line number for @var{port} to @var{line}.
3686@end deffn
3687
3688\fport-column
89d04205 3689@c snarfed from ports.c:1417
780ee65e
NJ
3690@deffn primitive port-column port
3691@deffnx primitive port-line port
3692Return the current column number or line number of @var{port},
3693using the current input port if none is specified. If the number is
3694unknown, the result is #f. Otherwise, the result is a 0-origin integer
3695- i.e. the first character of the first line is line 0, column 0.
3696(However, when you display a file position, for example in an error
3697message, we recommend you add 1 to get 1-origin integers. This is
3698because lines and column numbers traditionally start with 1, and that is
3699what non-programmers will find most natural.)
3700@end deffn
3701
3702\fset-port-column!
89d04205 3703@c snarfed from ports.c:1430
780ee65e
NJ
3704@deffn primitive set-port-column! port column
3705@deffnx primitive set-port-line! port line
3706Set the current column or line number of @var{port}, using the
3707current input port if none is specified.
3708@end deffn
3709
3710\fport-filename
89d04205 3711@c snarfed from ports.c:1445
780ee65e
NJ
3712@deffn primitive port-filename port
3713Return the filename associated with @var{port}. This function returns
3714the strings "standard input", "standard output" and "standard error"
3715when called on the current input, output and error ports respectively.
3716@end deffn
3717
3718\fset-port-filename!
89d04205 3719@c snarfed from ports.c:1459
780ee65e
NJ
3720@deffn primitive set-port-filename! port filename
3721Change the filename associated with @var{port}, using the current input
3722port if none is specified. Note that this does not change the port's
3723source of data, but only the value that is returned by
3724@code{port-filename} and reported in diagnostic output.
3725@end deffn
3726
3727\f%make-void-port
89d04205 3728@c snarfed from ports.c:1551
780ee65e
NJ
3729@deffn primitive %make-void-port mode
3730Create and return a new void port. A void port acts like
3731/dev/null. The @var{mode} argument
3732specifies the input/output modes for this port: see the
3733documentation for @code{open-file} in @ref{File Ports}.
3734@end deffn
3735
3736\fpipe
3737@c snarfed from posix.c:201
3738@deffn primitive pipe
ae9f3a15
MG
3739Return a newly created pipe: a pair of ports which are linked
3740together on the local machine. The @emph{car} is the input
3741port and the @emph{cdr} is the output port. Data written (and
3742flushed) to the output port can be read from the input port.
3743Pipes are commonly used for communication with a newly forked
3744child process. The need to flush the output port can be
3745avoided by making it unbuffered using @code{setvbuf}.
3746Writes occur atomically provided the size of the data in bytes
3747is not greater than the value of @code{PIPE_BUF}. Note that
3748the output port is likely to block if too much data (typically
3749equal to @code{PIPE_BUF}) has been written but not yet read
3750from the input port.
780ee65e
NJ
3751@end deffn
3752
3753\fgetgroups
89d04205 3754@c snarfed from posix.c:222
780ee65e 3755@deffn primitive getgroups
ae9f3a15
MG
3756Return a vector of integers representing the current
3757supplimentary group IDs.
780ee65e
NJ
3758@end deffn
3759
3760\fgetpw
89d04205 3761@c snarfed from posix.c:255
780ee65e
NJ
3762@deffn primitive getpw [user]
3763Look up an entry in the user database. @var{obj} can be an integer,
3764a string, or omitted, giving the behaviour of getpwuid, getpwnam
3765or getpwent respectively.
3766@end deffn
3767
3768\fsetpw
89d04205 3769@c snarfed from posix.c:308
780ee65e
NJ
3770@deffn primitive setpw [arg]
3771If called with a true argument, initialize or reset the password data
3772stream. Otherwise, close the stream. The @code{setpwent} and
3773@code{endpwent} procedures are implemented on top of this.
3774@end deffn
3775
3776\fgetgr
89d04205 3777@c snarfed from posix.c:327
780ee65e
NJ
3778@deffn primitive getgr [name]
3779Look up an entry in the group database. @var{obj} can be an integer,
3780a string, or omitted, giving the behaviour of getgrgid, getgrnam
3781or getgrent respectively.
3782@end deffn
3783
3784\fsetgr
89d04205 3785@c snarfed from posix.c:368
780ee65e
NJ
3786@deffn primitive setgr [arg]
3787If called with a true argument, initialize or reset the group data
3788stream. Otherwise, close the stream. The @code{setgrent} and
3789@code{endgrent} procedures are implemented on top of this.
3790@end deffn
3791
3792\fkill
89d04205 3793@c snarfed from posix.c:404
780ee65e
NJ
3794@deffn primitive kill pid sig
3795Sends a signal to the specified process or group of processes.
3796
3797@var{pid} specifies the processes to which the signal is sent:
3798
3799@table @r
3800@item @var{pid} greater than 0
3801The process whose identifier is @var{pid}.
3802@item @var{pid} equal to 0
3803All processes in the current process group.
3804@item @var{pid} less than -1
3805The process group whose identifier is -@var{pid}
3806@item @var{pid} equal to -1
3807If the process is privileged, all processes except for some special
3808system processes. Otherwise, all processes with the current effective
3809user ID.
3810@end table
3811
3812@var{sig} should be specified using a variable corresponding to
3813the Unix symbolic name, e.g.,
3814
3815@defvar SIGHUP
3816Hang-up signal.
3817@end defvar
3818
3819@defvar SIGINT
3820Interrupt signal.
3821@end defvar
3822@end deffn
3823
3824\fwaitpid
89d04205 3825@c snarfed from posix.c:452
780ee65e
NJ
3826@deffn primitive waitpid pid [options]
3827This procedure collects status information from a child process which
3828has terminated or (optionally) stopped. Normally it will
3829suspend the calling process until this can be done. If more than one
3830child process is eligible then one will be chosen by the operating system.
3831
3832The value of @var{pid} determines the behaviour:
3833
3834@table @r
3835@item @var{pid} greater than 0
3836Request status information from the specified child process.
3837@item @var{pid} equal to -1 or WAIT_ANY
3838Request status information for any child process.
3839@item @var{pid} equal to 0 or WAIT_MYPGRP
3840Request status information for any child process in the current process
3841group.
3842@item @var{pid} less than -1
3843Request status information for any child process whose process group ID
3844is -@var{PID}.
3845@end table
3846
3847The @var{options} argument, if supplied, should be the bitwise OR of the
3848values of zero or more of the following variables:
3849
3850@defvar WNOHANG
3851Return immediately even if there are no child processes to be collected.
3852@end defvar
3853
3854@defvar WUNTRACED
3855Report status information for stopped processes as well as terminated
3856processes.
3857@end defvar
3858
3859The return value is a pair containing:
3860
3861@enumerate
3862@item
3863The process ID of the child process, or 0 if @code{WNOHANG} was
3864specified and no process was collected.
3865@item
3866The integer status value.
3867@end enumerate
3868@end deffn
3869
3870\fstatus:exit-val
89d04205 3871@c snarfed from posix.c:479
780ee65e 3872@deffn primitive status:exit-val status
ae9f3a15
MG
3873Return the exit status value, as would be set if a process
3874ended normally through a call to @code{exit} or @code{_exit},
3875if any, otherwise @code{#f}.
780ee65e
NJ
3876@end deffn
3877
3878\fstatus:term-sig
89d04205 3879@c snarfed from posix.c:499
780ee65e 3880@deffn primitive status:term-sig status
ae9f3a15
MG
3881Return the signal number which terminated the process, if any,
3882otherwise @code{#f}.
780ee65e
NJ
3883@end deffn
3884
3885\fstatus:stop-sig
89d04205 3886@c snarfed from posix.c:517
780ee65e 3887@deffn primitive status:stop-sig status
ae9f3a15
MG
3888Return the signal number which stopped the process, if any,
3889otherwise @code{#f}.
780ee65e
NJ
3890@end deffn
3891
3892\fgetppid
89d04205 3893@c snarfed from posix.c:535
780ee65e 3894@deffn primitive getppid
ae9f3a15
MG
3895Return an integer representing the process ID of the parent
3896process.
780ee65e
NJ
3897@end deffn
3898
3899\fgetuid
89d04205 3900@c snarfed from posix.c:546
780ee65e 3901@deffn primitive getuid
ae9f3a15 3902Return an integer representing the current real user ID.
780ee65e
NJ
3903@end deffn
3904
3905\fgetgid
89d04205 3906@c snarfed from posix.c:557
780ee65e 3907@deffn primitive getgid
ae9f3a15 3908Return an integer representing the current real group ID.
780ee65e
NJ
3909@end deffn
3910
3911\fgeteuid
89d04205 3912@c snarfed from posix.c:571
780ee65e 3913@deffn primitive geteuid
ae9f3a15 3914Return an integer representing the current effective user ID.
780ee65e 3915If the system does not support effective IDs, then the real ID
ae9f3a15
MG
3916is returned. @code{(feature? 'EIDs)} reports whether the
3917system supports effective IDs.
780ee65e
NJ
3918@end deffn
3919
3920\fgetegid
89d04205 3921@c snarfed from posix.c:589
780ee65e 3922@deffn primitive getegid
ae9f3a15 3923Return an integer representing the current effective group ID.
780ee65e 3924If the system does not support effective IDs, then the real ID
ae9f3a15
MG
3925is returned. @code{(feature? 'EIDs)} reports whether the
3926system supports effective IDs.
780ee65e
NJ
3927@end deffn
3928
3929\fsetuid
89d04205 3930@c snarfed from posix.c:605
780ee65e
NJ
3931@deffn primitive setuid id
3932Sets both the real and effective user IDs to the integer @var{id}, provided
3933the process has appropriate privileges.
3934The return value is unspecified.
3935@end deffn
3936
3937\fsetgid
89d04205 3938@c snarfed from posix.c:619
780ee65e
NJ
3939@deffn primitive setgid id
3940Sets both the real and effective group IDs to the integer @var{id}, provided
3941the process has appropriate privileges.
3942The return value is unspecified.
3943@end deffn
3944
3945\fseteuid
89d04205 3946@c snarfed from posix.c:635
780ee65e
NJ
3947@deffn primitive seteuid id
3948Sets the effective user ID to the integer @var{id}, provided the process
3949has appropriate privileges. If effective IDs are not supported, the
3950real ID is set instead -- @code{(feature? 'EIDs)} reports whether the
3951system supports effective IDs.
3952The return value is unspecified.
3953@end deffn
3954
3955\fsetegid
89d04205 3956@c snarfed from posix.c:659
780ee65e
NJ
3957@deffn primitive setegid id
3958Sets the effective group ID to the integer @var{id}, provided the process
3959has appropriate privileges. If effective IDs are not supported, the
3960real ID is set instead -- @code{(feature? 'EIDs)} reports whether the
3961system supports effective IDs.
3962The return value is unspecified.
3963@end deffn
3964
3965\fgetpgrp
89d04205 3966@c snarfed from posix.c:681
780ee65e 3967@deffn primitive getpgrp
ae9f3a15 3968Return an integer representing the current process group ID.
780ee65e
NJ
3969This is the POSIX definition, not BSD.
3970@end deffn
3971
3972\fsetpgid
89d04205 3973@c snarfed from posix.c:697
780ee65e
NJ
3974@deffn primitive setpgid pid pgid
3975Move the process @var{pid} into the process group @var{pgid}. @var{pid} or
3976@var{pgid} must be integers: they can be zero to indicate the ID of the
3977current process.
3978Fails on systems that do not support job control.
3979The return value is unspecified.
3980@end deffn
3981
3982\fsetsid
89d04205 3983@c snarfed from posix.c:716
780ee65e
NJ
3984@deffn primitive setsid
3985Creates a new session. The current process becomes the session leader
3986and is put in a new process group. The process will be detached
3987from its controlling terminal if it has one.
3988The return value is an integer representing the new process group ID.
3989@end deffn
3990
3991\fttyname
89d04205 3992@c snarfed from posix.c:730
780ee65e 3993@deffn primitive ttyname port
ae9f3a15
MG
3994Return a string with the name of the serial terminal device
3995underlying @var{port}.
780ee65e
NJ
3996@end deffn
3997
3998\fctermid
89d04205 3999@c snarfed from posix.c:753
780ee65e 4000@deffn primitive ctermid
ae9f3a15
MG
4001Return a string containing the file name of the controlling
4002terminal for the current process.
780ee65e
NJ
4003@end deffn
4004
4005\ftcgetpgrp
89d04205 4006@c snarfed from posix.c:776
780ee65e 4007@deffn primitive tcgetpgrp port
ae9f3a15
MG
4008Return the process group ID of the foreground process group
4009associated with the terminal open on the file descriptor
780ee65e 4010underlying @var{port}.
780ee65e
NJ
4011If there is no foreground process group, the return value is a
4012number greater than 1 that does not match the process group ID
4013of any existing process group. This can happen if all of the
4014processes in the job that was formerly the foreground job have
4015terminated, and no other job has yet been moved into the
4016foreground.
4017@end deffn
4018
4019\ftcsetpgrp
89d04205 4020@c snarfed from posix.c:800
780ee65e
NJ
4021@deffn primitive tcsetpgrp port pgid
4022Set the foreground process group ID for the terminal used by the file
4023descriptor underlying @var{port} to the integer @var{pgid}.
4024The calling process
4025must be a member of the same session as @var{pgid} and must have the same
4026controlling terminal. The return value is unspecified.
4027@end deffn
4028
4029\fexecl
89d04205 4030@c snarfed from posix.c:860
780ee65e
NJ
4031@deffn primitive execl filename . args
4032Executes the file named by @var{path} as a new process image.
4033The remaining arguments are supplied to the process; from a C program
4034they are accessable as the @code{argv} argument to @code{main}.
4035Conventionally the first @var{arg} is the same as @var{path}.
4036All arguments must be strings.
4037
4038If @var{arg} is missing, @var{path} is executed with a null
4039argument list, which may have system-dependent side-effects.
4040
4041This procedure is currently implemented using the @code{execv} system
4042call, but we call it @code{execl} because of its Scheme calling interface.
4043@end deffn
4044
4045\fexeclp
89d04205 4046@c snarfed from posix.c:881
780ee65e
NJ
4047@deffn primitive execlp filename . args
4048Similar to @code{execl}, however if
4049@var{filename} does not contain a slash
4050then the file to execute will be located by searching the
4051directories listed in the @code{PATH} environment variable.
4052
4053This procedure is currently implemented using the @code{execvp} system
4054call, but we call it @code{execlp} because of its Scheme calling interface.
4055@end deffn
4056
4057\fexecle
89d04205 4058@c snarfed from posix.c:932
780ee65e
NJ
4059@deffn primitive execle filename env . args
4060Similar to @code{execl}, but the environment of the new process is
4061specified by @var{env}, which must be a list of strings as returned by the
4062@code{environ} procedure.
4063
4064This procedure is currently implemented using the @code{execve} system
4065call, but we call it @code{execle} because of its Scheme calling interface.
4066@end deffn
4067
4068\fprimitive-fork
89d04205 4069@c snarfed from posix.c:956
780ee65e
NJ
4070@deffn primitive primitive-fork
4071Creates a new "child" process by duplicating the current "parent" process.
4072In the child the return value is 0. In the parent the return value is
4073the integer process ID of the child.
4074
4075This procedure has been renamed from @code{fork} to avoid a naming conflict
4076with the scsh fork.
4077@end deffn
4078
4079\funame
89d04205 4080@c snarfed from posix.c:971
780ee65e 4081@deffn primitive uname
ae9f3a15
MG
4082Return an object with some information about the computer
4083system the program is running on.
780ee65e
NJ
4084@end deffn
4085
4086\fenviron
89d04205 4087@c snarfed from posix.c:1001
780ee65e 4088@deffn primitive environ [env]
ae9f3a15
MG
4089If @var{env} is omitted, return the current environment (in the
4090Unix sense) as a list of strings. Otherwise set the current
4091environment, which is also the default environment for child
4092processes, to the supplied list of strings. Each member of
4093@var{env} should be of the form @code{NAME=VALUE} and values of
4094@code{NAME} should not be duplicated. If @var{env} is supplied
4095then the return value is unspecified.
780ee65e
NJ
4096@end deffn
4097
4098\ftmpnam
89d04205 4099@c snarfed from posix.c:1039
780ee65e 4100@deffn primitive tmpnam
ae9f3a15
MG
4101Return a name in the file system that does not match any
4102existing file. However there is no guarantee that another
4103process will not create the file after @code{tmpnam} is called.
4104Care should be taken if opening the file, e.g., use the
4105@code{O_EXCL} open flag or use @code{mkstemp!} instead.
780ee65e
NJ
4106@end deffn
4107
4108\fmkstemp!
89d04205 4109@c snarfed from posix.c:1061
780ee65e 4110@deffn primitive mkstemp! tmpl
ae9f3a15
MG
4111Create a new unique file in the file system and returns a new
4112buffered port open for reading and writing to the file.
4113@var{tmpl} is a string specifying where the file should be
4114created: it must end with @code{XXXXXX} and will be changed in
4115place to return the name of the temporary file.
780ee65e
NJ
4116@end deffn
4117
4118\futime
89d04205 4119@c snarfed from posix.c:1087
780ee65e 4120@deffn primitive utime pathname [actime [modtime]]
ae9f3a15
MG
4121@code{utime} sets the access and modification times for the
4122file named by @var{path}. If @var{actime} or @var{modtime} is
4123not supplied, then the current time is used. @var{actime} and
4124@var{modtime} must be integer time values as returned by the
4125@code{current-time} procedure.
4126@lisp
780ee65e 4127(utime "foo" (- (current-time) 3600))
ae9f3a15
MG
4128@end lisp
4129will set the access time to one hour in the past and the
4130modification time to the current time.
780ee65e
NJ
4131@end deffn
4132
4133\faccess?
89d04205 4134@c snarfed from posix.c:1136
780ee65e 4135@deffn primitive access? path how
ae9f3a15
MG
4136Return @code{#t} if @var{path} corresponds to an existing file
4137and the current process has the type of access specified by
4138@var{how}, otherwise @code{#f}. @var{how} should be specified
4139using the values of the variables listed below. Multiple
4140values can be combined using a bitwise or, in which case
4141@code{#t} will only be returned if all accesses are granted.
4142Permissions are checked using the real id of the current
4143process, not the effective id, although it's the effective id
4144which determines whether the access would actually be granted.
780ee65e
NJ
4145@defvar R_OK
4146test for read permission.
4147@end defvar
4148@defvar W_OK
4149test for write permission.
4150@end defvar
4151@defvar X_OK
4152test for execute permission.
4153@end defvar
4154@defvar F_OK
4155test for existence of the file.
4156@end defvar
4157@end deffn
4158
4159\fgetpid
89d04205 4160@c snarfed from posix.c:1151
780ee65e 4161@deffn primitive getpid
ae9f3a15 4162Return an integer representing the current process ID.
780ee65e
NJ
4163@end deffn
4164
4165\fputenv
89d04205 4166@c snarfed from posix.c:1168
780ee65e
NJ
4167@deffn primitive putenv str
4168Modifies the environment of the current process, which is
4169also the default environment inherited by child processes.
4170
4171If @var{string} is of the form @code{NAME=VALUE} then it will be written
4172directly into the environment, replacing any existing environment string
4173with
4174name matching @code{NAME}. If @var{string} does not contain an equal
4175sign, then any existing string with name matching @var{string} will
4176be removed.
4177
4178The return value is unspecified.
4179@end deffn
4180
4181\fsetlocale
89d04205 4182@c snarfed from posix.c:1199
780ee65e 4183@deffn primitive setlocale category [locale]
ae9f3a15
MG
4184If @var{locale} is omitted, return the current value of the
4185specified locale category as a system-dependent string.
4186@var{category} should be specified using the values
4187@code{LC_COLLATE}, @code{LC_ALL} etc.
4188Otherwise the specified locale category is set to the string
4189@var{locale} and the new value is returned as a
4190system-dependent string. If @var{locale} is an empty string,
4191the locale will be set using envirionment variables.
780ee65e
NJ
4192@end deffn
4193
4194\fmknod
89d04205 4195@c snarfed from posix.c:1240
780ee65e
NJ
4196@deffn primitive mknod path type perms dev
4197Creates a new special file, such as a file corresponding to a device.
4198@var{path} specifies the name of the file. @var{type} should
4199be one of the following symbols:
4200regular, directory, symlink, block-special, char-special,
4201fifo, or socket. @var{perms} (an integer) specifies the file permissions.
4202@var{dev} (an integer) specifies which device the special file refers
4203to. Its exact interpretation depends on the kind of special file
4204being created.
4205
4206E.g.,
ae9f3a15 4207@lisp
780ee65e 4208(mknod "/dev/fd0" 'block-special #o660 (+ (* 2 256) 2))
ae9f3a15 4209@end lisp
780ee65e
NJ
4210
4211The return value is unspecified.
4212@end deffn
4213
4214\fnice
89d04205 4215@c snarfed from posix.c:1287
780ee65e
NJ
4216@deffn primitive nice incr
4217Increment the priority of the current process by @var{incr}. A higher
4218priority value means that the process runs less often.
4219The return value is unspecified.
4220@end deffn
4221
4222\fsync
89d04205 4223@c snarfed from posix.c:1302
780ee65e
NJ
4224@deffn primitive sync
4225Flush the operating system disk buffers.
4226The return value is unspecified.
4227@end deffn
4228
4229\fcrypt
89d04205 4230@c snarfed from posix.c:1315
780ee65e
NJ
4231@deffn primitive crypt key salt
4232Encrypt @var{key} using @var{salt} as the salt value to the
4233crypt(3) library call
4234@end deffn
4235
4236\fchroot
89d04205 4237@c snarfed from posix.c:1338
780ee65e
NJ
4238@deffn primitive chroot path
4239Change the root directory to that specified in @var{path}.
4240This directory will be used for path names beginning with
4241@file{/}. The root directory is inherited by all children
4242of the current process. Only the superuser may change the
4243root directory.
4244@end deffn
4245
4246\fgetlogin
89d04205 4247@c snarfed from posix.c:1356
780ee65e
NJ
4248@deffn primitive getlogin
4249Return a string containing the name of the user logged in on
4250the controlling terminal of the process, or @code{#f} if this
4251information cannot be obtained.
4252@end deffn
4253
4254\fcuserid
89d04205 4255@c snarfed from posix.c:1374
780ee65e
NJ
4256@deffn primitive cuserid
4257Return a string containing a user name associated with the
4258effective user id of the process. Return @code{#f} if this
4259information cannot be obtained.
4260@end deffn
4261
4262\fgetpriority
89d04205 4263@c snarfed from posix.c:1399
780ee65e
NJ
4264@deffn primitive getpriority which who
4265Return the scheduling priority of the process, process group
4266or user, as indicated by @var{which} and @var{who}. @var{which}
4267is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP}
4268or @code{PRIO_USER}, and @var{who} is interpreted relative to
4269@var{which} (a process identifier for @code{PRIO_PROCESS},
4270process group identifier for @code{PRIO_PGRP}, and a user
4271identifier for @code{PRIO_USER}. A zero value of @var{who}
4272denotes the current process, process group, or user. Return
4273the highest priority (lowest numerical value) of any of the
4274specified processes.
4275@end deffn
4276
4277\fsetpriority
89d04205 4278@c snarfed from posix.c:1433
780ee65e
NJ
4279@deffn primitive setpriority which who prio
4280Set the scheduling priority of the process, process group
4281or user, as indicated by @var{which} and @var{who}. @var{which}
4282is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP}
4283or @code{PRIO_USER}, and @var{who} is interpreted relative to
4284@var{which} (a process identifier for @code{PRIO_PROCESS},
4285process group identifier for @code{PRIO_PGRP}, and a user
4286identifier for @code{PRIO_USER}. A zero value of @var{who}
4287denotes the current process, process group, or user.
4288@var{prio} is a value in the range -20 and 20, the default
4289priority is 0; lower priorities cause more favorable
4290scheduling. Sets the priority of all of the specified
4291processes. Only the super-user may lower priorities.
4292The return value is not specified.
4293@end deffn
4294
4295\fgetpass
89d04205 4296@c snarfed from posix.c:1458
780ee65e
NJ
4297@deffn primitive getpass prompt
4298Display @var{prompt} to the standard error output and read
4299a password from @file{/dev/tty}. If this file is not
4300accessible, it reads from standard input. The password may be
4301up to 127 characters in length. Additional characters and the
4302terminating newline character are discarded. While reading
4303the password, echoing and the generation of signals by special
4304characters is disabled.
4305@end deffn
4306
4307\fflock
89d04205 4308@c snarfed from posix.c:1497
780ee65e
NJ
4309@deffn primitive flock file operation
4310Apply or remove an advisory lock on an open file.
4311@var{operation} specifies the action to be done:
4312@table @code
4313@item LOCK_SH
4314Shared lock. More than one process may hold a shared lock
4315for a given file at a given time.
4316@item LOCK_EX
4317Exclusive lock. Only one process may hold an exclusive lock
4318for a given file at a given time.
4319@item LOCK_UN
4320Unlock the file.
4321@item LOCK_NB
4322Don't block when locking. May be specified by bitwise OR'ing
4323it to one of the other operations.
4324@end table
4325The return value is not specified. @var{file} may be an open
4326file descriptor or an open file descriptior port.
4327@end deffn
4328
4329\fsethostname
89d04205 4330@c snarfed from posix.c:1523
780ee65e
NJ
4331@deffn primitive sethostname name
4332Set the host name of the current processor to @var{name}. May
4333only be used by the superuser. The return value is not
4334specified.
4335@end deffn
4336
4337\fgethostname
89d04205 4338@c snarfed from posix.c:1539
780ee65e
NJ
4339@deffn primitive gethostname
4340Return the host name of the current processor.
4341@end deffn
4342
4343\fprint-options-interface
4344@c snarfed from print.c:142
4345@deffn primitive print-options-interface [setting]
4346Option interface for the print options. Instead of using
4347this procedure directly, use the procedures
4348@code{print-enable}, @code{print-disable}, @code{print-set!}
4349and @code{print-options}.
4350@end deffn
4351
4352\fsimple-format
72ad43dc 4353@c snarfed from print.c:909
780ee65e
NJ
4354@deffn primitive simple-format destination message . args
4355Write @var{message} to @var{destination}, defaulting to
4356the current output port.
4357@var{message} can contain @code{~A} (was @code{%s}) and
4358@code{~S} (was @code{%S}) escapes. When printed,
4359the escapes are replaced with corresponding members of
4360@var{ARGS}:
4361@code{~A} formats using @code{display} and @code{~S} formats
4362using @code{write}.
4363If @var{destination} is @code{#t}, then use the current output
4364port, if @var{destination} is @code{#f}, then return a string
4365containing the formatted text. Does not add a trailing newline.
4366@end deffn
4367
4368\fnewline
72ad43dc 4369@c snarfed from print.c:974
780ee65e
NJ
4370@deffn primitive newline [port]
4371Send a newline to @var{port}.
4372@end deffn
4373
4374\fwrite-char
72ad43dc 4375@c snarfed from print.c:989
780ee65e
NJ
4376@deffn primitive write-char chr [port]
4377Send character @var{chr} to @var{port}.
4378@end deffn
4379
4380\fport-with-print-state
72ad43dc 4381@c snarfed from print.c:1043
780ee65e
NJ
4382@deffn primitive port-with-print-state port pstate
4383Create a new port which behaves like @var{port}, but with an
4384included print state @var{pstate}.
4385@end deffn
4386
4387\fget-print-state
72ad43dc 4388@c snarfed from print.c:1058
780ee65e
NJ
4389@deffn primitive get-print-state port
4390Return the print state of the port @var{port}. If @var{port}
4391has no associated print state, @code{#f} is returned.
4392@end deffn
4393
4394\fprocedure-properties
4395@c snarfed from procprop.c:180
4396@deffn primitive procedure-properties proc
4397Return @var{obj}'s property list.
4398@end deffn
4399
4400\fset-procedure-properties!
4401@c snarfed from procprop.c:193
4402@deffn primitive set-procedure-properties! proc new_val
4403Set @var{obj}'s property list to @var{alist}.
4404@end deffn
4405
4406\fprocedure-property
4407@c snarfed from procprop.c:206
4408@deffn primitive procedure-property p k
4409Return the property of @var{obj} with name @var{key}.
4410@end deffn
4411
4412\fset-procedure-property!
4413@c snarfed from procprop.c:229
4414@deffn primitive set-procedure-property! p k v
4415In @var{obj}'s property list, set the property named @var{key} to
4416@var{value}.
4417@end deffn
4418
4419\fprocedure?
4420@c snarfed from procs.c:196
4421@deffn primitive procedure? obj
4422Return @code{#t} if @var{obj} is a procedure.
4423@end deffn
4424
4425\fclosure?
4426@c snarfed from procs.c:223
4427@deffn primitive closure? obj
4428Return @code{#t} if @var{obj} is a closure.
4429@end deffn
4430
4431\fthunk?
4432@c snarfed from procs.c:232
4433@deffn primitive thunk? obj
4434Return @code{#t} if @var{obj} is a thunk.
4435@end deffn
4436
4437\fprocedure-documentation
72ad43dc 4438@c snarfed from procs.c:282
780ee65e
NJ
4439@deffn primitive procedure-documentation proc
4440Return the documentation string associated with @code{proc}. By
4441convention, if a procedure contains more than one expression and the
4442first expression is a string constant, that string is assumed to contain
4443documentation for that procedure.
4444@end deffn
4445
4446\fprocedure-with-setter?
72ad43dc 4447@c snarfed from procs.c:318
780ee65e
NJ
4448@deffn primitive procedure-with-setter? obj
4449Return @code{#t} if @var{obj} is a procedure with an
4450associated setter procedure.
4451@end deffn
4452
4453\fmake-procedure-with-setter
72ad43dc 4454@c snarfed from procs.c:328
780ee65e
NJ
4455@deffn primitive make-procedure-with-setter procedure setter
4456Create a new procedure which behaves like @var{procedure}, but
4457with the associated setter @var{setter}.
4458@end deffn
4459
4460\fprocedure
72ad43dc 4461@c snarfed from procs.c:347
780ee65e
NJ
4462@deffn primitive procedure proc
4463Return the procedure of @var{proc}, which must be either a
4464procedure with setter, or an operator struct.
4465@end deffn
4466
4467\fprimitive-make-property
4468@c snarfed from properties.c:66
4469@deffn primitive primitive-make-property not_found_proc
4470Create a @dfn{property token} that can be used with
4471@code{primitive-property-ref} and @code{primitive-property-set!}.
4472See @code{primitive-property-ref} for the significance of
4473@var{not_found_proc}.
4474@end deffn
4475
4476\fprimitive-property-ref
89d04205 4477@c snarfed from properties.c:84
780ee65e
NJ
4478@deffn primitive primitive-property-ref prop obj
4479Return the property @var{prop} of @var{obj}. When no value
4480has yet been associated with @var{prop} and @var{obj}, call
4481@var{not-found-proc} instead (see @code{primitive-make-property})
4482and use its return value. That value is also associated with
4483@var{obj} via @code{primitive-property-set!}. When
4484@var{not-found-proc} is @code{#f}, use @code{#f} as the
4485default value of @var{prop}.
4486@end deffn
4487
4488\fprimitive-property-set!
89d04205 4489@c snarfed from properties.c:115
780ee65e
NJ
4490@deffn primitive primitive-property-set! prop obj val
4491Associate @var{code} with @var{prop} and @var{obj}.
4492@end deffn
4493
4494\fprimitive-property-del!
89d04205 4495@c snarfed from properties.c:136
780ee65e
NJ
4496@deffn primitive primitive-property-del! prop obj
4497Remove any value associated with @var{prop} and @var{obj}.
4498@end deffn
4499
4500\farray-fill!
4501@c snarfed from ramap.c:467
4502@deffn primitive array-fill! ra fill
4503Stores @var{fill} in every element of @var{array}. The value returned
4504is unspecified.
4505@end deffn
4506
4507\farray-copy-in-order!
4508@c snarfed from ramap.c:832
4509@deffn primitive array-copy-in-order!
4510scm_array_copy_x
4511@end deffn
4512
4513\farray-copy!
4514@c snarfed from ramap.c:841
4515@deffn primitive array-copy! src dst
4516@deffnx primitive array-copy-in-order! src dst
4517Copies every element from vector or array @var{source} to the
4518corresponding element of @var{destination}. @var{destination} must have
4519the same rank as @var{source}, and be at least as large in each
4520dimension. The order is unspecified.
4521@end deffn
4522
4523\farray-map-in-order!
4524@c snarfed from ramap.c:1515
4525@deffn primitive array-map-in-order!
4526scm_array_map_x
4527@end deffn
4528
4529\farray-map!
4530@c snarfed from ramap.c:1526
4531@deffn primitive array-map! ra0 proc . lra
4532@deffnx primitive array-map-in-order! ra0 proc . lra
4533@var{array1}, @dots{} must have the same number of dimensions as
4534@var{array0} and have a range for each index which includes the range
4535for the corresponding index in @var{array0}. @var{proc} is applied to
4536each tuple of elements of @var{array1} @dots{} and the result is stored
4537as the corresponding element in @var{array0}. The value returned is
4538unspecified. The order of application is unspecified.
4539@end deffn
4540
4541\farray-for-each
4542@c snarfed from ramap.c:1673
4543@deffn primitive array-for-each proc ra0 . lra
4544@var{proc} is applied to each tuple of elements of @var{array0} @dots{}
4545in row-major order. The value returned is unspecified.
4546@end deffn
4547
4548\farray-index-map!
4549@c snarfed from ramap.c:1701
4550@deffn primitive array-index-map! ra proc
4551applies @var{proc} to the indices of each element of @var{array} in
4552turn, storing the result in the corresponding element. The value
4553returned and the order of application are unspecified.
4554
4555One can implement @var{array-indexes} as
ae9f3a15 4556@lisp
780ee65e
NJ
4557(define (array-indexes array)
4558 (let ((ra (apply make-array #f (array-shape array))))
4559 (array-index-map! ra (lambda x x))
4560 ra))
ae9f3a15 4561@end lisp
780ee65e 4562Another example:
ae9f3a15 4563@lisp
780ee65e
NJ
4564(define (apl:index-generator n)
4565 (let ((v (make-uniform-vector n 1)))
4566 (array-index-map! v (lambda (i) i))
4567 v))
ae9f3a15 4568@end lisp
780ee65e
NJ
4569@end deffn
4570
4571\frandom
4572@c snarfed from random.c:370
4573@deffn primitive random n [state]
4574Return a number in [0,N).
4575Accepts a positive integer or real n and returns a
4576number of the same type between zero (inclusive) and
4577N (exclusive). The values returned have a uniform
4578distribution.
4579The optional argument @var{state} must be of the type produced
4580by @code{seed->random-state}. It defaults to the value of the
4581variable @var{*random-state*}. This object is used to maintain
4582the state of the pseudo-random-number generator and is altered
4583as a side effect of the random operation.
4584@end deffn
4585
4586\fcopy-random-state
4587@c snarfed from random.c:393
4588@deffn primitive copy-random-state [state]
4589Return a copy of the random state @var{state}.
4590@end deffn
4591
4592\fseed->random-state
4593@c snarfed from random.c:405
4594@deffn primitive seed->random-state seed
4595Return a new random state using @var{seed}.
4596@end deffn
4597
4598\frandom:uniform
89d04205 4599@c snarfed from random.c:419
780ee65e 4600@deffn primitive random:uniform [state]
ae9f3a15
MG
4601Return a uniformly distributed inexact real random number in
4602[0,1).
780ee65e
NJ
4603@end deffn
4604
4605\frandom:normal
89d04205 4606@c snarfed from random.c:434
780ee65e 4607@deffn primitive random:normal [state]
ae9f3a15
MG
4608Return an inexact real in a normal distribution. The
4609distribution used has mean 0 and standard deviation 1. For a
4610normal distribution with mean m and standard deviation d use
4611@code{(+ m (* d (random:normal)))}.
780ee65e
NJ
4612@end deffn
4613
4614\frandom:solid-sphere!
89d04205 4615@c snarfed from random.c:490
780ee65e
NJ
4616@deffn primitive random:solid-sphere! v [state]
4617Fills vect with inexact real random numbers
4618the sum of whose squares is less than 1.0.
4619Thinking of vect as coordinates in space of
4620dimension n = (vector-length vect), the coordinates
4621are uniformly distributed within the unit n-shere.
4622The sum of the squares of the numbers is returned.
4623@end deffn
4624
4625\frandom:hollow-sphere!
89d04205 4626@c snarfed from random.c:513
780ee65e
NJ
4627@deffn primitive random:hollow-sphere! v [state]
4628Fills vect with inexact real random numbers
4629the sum of whose squares is equal to 1.0.
4630Thinking of vect as coordinates in space of
4631dimension n = (vector-length vect), the coordinates
4632are uniformly distributed over the surface of the
4633unit n-shere.
4634@end deffn
4635
4636\frandom:normal-vector!
89d04205 4637@c snarfed from random.c:531
780ee65e
NJ
4638@deffn primitive random:normal-vector! v [state]
4639Fills vect with inexact real random numbers that are
4640independent and standard normally distributed
4641(i.e., with mean 0 and variance 1).
4642@end deffn
4643
4644\frandom:exp
89d04205 4645@c snarfed from random.c:556
780ee65e 4646@deffn primitive random:exp [state]
ae9f3a15
MG
4647Return an inexact real in an exponential distribution with mean
46481. For an exponential distribution with mean u use (* u
4649(random:exp)).
780ee65e
NJ
4650@end deffn
4651
4652\f%read-delimited!
4653@c snarfed from rdelim.c:78
4654@deffn primitive %read-delimited! delims str gobble [port [start [end]]]
4655Read characters from @var{port} into @var{str} until one of the
4656characters in the @var{delims} string is encountered. If
4657@var{gobble} is true, discard the delimiter character;
4658otherwise, leave it in the input stream for the next read. If
4659@var{port} is not specified, use the value of
4660@code{(current-input-port)}. If @var{start} or @var{end} are
4661specified, store data only into the substring of @var{str}
4662bounded by @var{start} and @var{end} (which default to the
4663beginning and end of the string, respectively).
4664 Return a pair consisting of the delimiter that terminated the
4665string and the number of characters read. If reading stopped
4666at the end of file, the delimiter returned is the
4667@var{eof-object}; if the string was filled without encountering
4668a delimiter, this value is @code{#f}.
4669@end deffn
4670
4671\f%read-line
4672@c snarfed from rdelim.c:223
4673@deffn primitive %read-line [port]
4674Read a newline-terminated line from @var{port}, allocating storage as
4675necessary. The newline terminator (if any) is removed from the string,
4676and a pair consisting of the line and its delimiter is returned. The
4677delimiter may be either a newline or the @var{eof-object}; if
4678@code{%read-line} is called at the end of file, it returns the pair
4679@code{(#<eof> . #<eof>)}.
4680@end deffn
4681
4682\fwrite-line
4683@c snarfed from rdelim.c:277
4684@deffn primitive write-line obj [port]
ae9f3a15
MG
4685Display @var{obj} and a newline character to @var{port}. If
4686@var{port} is not specified, @code{(current-output-port)} is
4687used. This function is equivalent to:
4688@lisp
780ee65e
NJ
4689(display obj [port])
4690(newline [port])
ae9f3a15 4691@end lisp
780ee65e
NJ
4692@end deffn
4693
4694\fread-options-interface
4695@c snarfed from read.c:84
4696@deffn primitive read-options-interface [setting]
4697Option interface for the read options. Instead of using
4698this procedure directly, use the procedures @code{read-enable},
4699@code{read-disable}, @code{read-set!} and @var{read-options}.
4700@end deffn
4701
4702\fread
4703@c snarfed from read.c:104
4704@deffn primitive read [port]
4705Read an s-expression from the input port @var{port}, or from
4706the current input port if @var{port} is not specified.
4707Any whitespace before the next token is discarded.
4708@end deffn
4709
4710\fread-hash-extend
4711@c snarfed from read.c:746
4712@deffn primitive read-hash-extend chr proc
4713Install the procedure @var{proc} for reading expressions
4714starting with the character sequence @code{#} and @var{chr}.
4715@var{proc} will be called with two arguments: the character
4716@var{chr} and the port to read further data from. The object
4717returned will be the return value of @code{read}.
4718@end deffn
4719
4720\fregexp?
4721@c snarfed from regex-posix.c:139
ae9f3a15
MG
4722@deffn primitive regexp? obj
4723Return @code{#t} if @var{obj} is a compiled regular expression,
4724or @code{#f} otherwise.
780ee65e
NJ
4725@end deffn
4726
4727\fmake-regexp
89d04205 4728@c snarfed from regex-posix.c:184
780ee65e 4729@deffn primitive make-regexp pat . flags
ae9f3a15
MG
4730Compile the regular expression described by @var{pat}, and
4731return the compiled regexp structure. If @var{pat} does not
4732describe a legal regular expression, @code{make-regexp} throws
4733a @code{regular-expression-syntax} error.
4734The @var{flags} arguments change the behavior of the compiled
4735regular expression. The following flags may be supplied:
780ee65e
NJ
4736@table @code
4737@item regexp/icase
ae9f3a15
MG
4738Consider uppercase and lowercase letters to be the same when
4739matching.
780ee65e 4740@item regexp/newline
ae9f3a15
MG
4741If a newline appears in the target string, then permit the
4742@samp{^} and @samp{$} operators to match immediately after or
4743immediately before the newline, respectively. Also, the
4744@samp{.} and @samp{[^...]} operators will never match a newline
4745character. The intent of this flag is to treat the target
4746string as a buffer containing many lines of text, and the
4747regular expression as a pattern that may match a single one of
4748those lines.
780ee65e
NJ
4749@item regexp/basic
4750Compile a basic (``obsolete'') regexp instead of the extended
ae9f3a15
MG
4751(``modern'') regexps that are the default. Basic regexps do
4752not consider @samp{|}, @samp{+} or @samp{?} to be special
4753characters, and require the @samp{@{...@}} and @samp{(...)}
4754metacharacters to be backslash-escaped (@pxref{Backslash
4755Escapes}). There are several other differences between basic
4756and extended regular expressions, but these are the most
4757significant.
780ee65e 4758@item regexp/extended
ae9f3a15
MG
4759Compile an extended regular expression rather than a basic
4760regexp. This is the default behavior; this flag will not
4761usually be needed. If a call to @code{make-regexp} includes
4762both @code{regexp/basic} and @code{regexp/extended} flags, the
4763one which comes last will override the earlier one.
780ee65e
NJ
4764@end table
4765@end deffn
4766
4767\fregexp-exec
89d04205 4768@c snarfed from regex-posix.c:232
780ee65e 4769@deffn primitive regexp-exec rx str [start [flags]]
ae9f3a15
MG
4770Match the compiled regular expression @var{rx} against
4771@code{str}. If the optional integer @var{start} argument is
4772provided, begin matching from that position in the string.
4773Return a match structure describing the results of the match,
4774or @code{#f} if no match could be found.
780ee65e
NJ
4775@end deffn
4776
4777\fcall-with-dynamic-root
4778@c snarfed from root.c:358
4779@deffn primitive call-with-dynamic-root thunk handler
4780Evaluate @code{(thunk)} in a new dynamic context, returning its value.
4781
4782If an error occurs during evaluation, apply @var{handler} to the
4783arguments to the throw, just as @code{throw} would. If this happens,
4784@var{handler} is called outside the scope of the new root -- it is
4785called in the same dynamic context in which
4786@code{call-with-dynamic-root} was evaluated.
4787
4788If @var{thunk} captures a continuation, the continuation is rooted at
4789the call to @var{thunk}. In particular, the call to
4790@code{call-with-dynamic-root} is not captured. Therefore,
4791@code{call-with-dynamic-root} always returns at most one time.
4792
4793Before calling @var{thunk}, the dynamic-wind chain is un-wound back to
4794the root and a new chain started for @var{thunk}. Therefore, this call
4795may not do what you expect:
4796
ae9f3a15 4797@lisp
780ee65e
NJ
4798;; Almost certainly a bug:
4799(with-output-to-port
4800 some-port
4801
4802 (lambda ()
4803 (call-with-dynamic-root
4804 (lambda ()
4805 (display 'fnord)
4806 (newline))
4807 (lambda (errcode) errcode))))
ae9f3a15 4808@end lisp
780ee65e
NJ
4809
4810The problem is, on what port will @samp{fnord} be displayed? You
4811might expect that because of the @code{with-output-to-port} that
4812it will be displayed on the port bound to @code{some-port}. But it
4813probably won't -- before evaluating the thunk, dynamic winds are
4814unwound, including those created by @code{with-output-to-port}.
4815So, the standard output port will have been re-set to its default value
4816before @code{display} is evaluated.
4817
4818(This function was added to Guile mostly to help calls to functions in C
4819libraries that can not tolerate non-local exits or calls that return
4820multiple times. If such functions call back to the interpreter, it should
4821be under a new dynamic root.)
4822@end deffn
4823
4824\fdynamic-root
4825@c snarfed from root.c:371
4826@deffn primitive dynamic-root
4827Return an object representing the current dynamic root.
4828
4829These objects are only useful for comparison using @code{eq?}.
4830They are currently represented as numbers, but your code should
4831in no way depend on this.
4832@end deffn
4833
4834\fsigaction
4835@c snarfed from scmsigs.c:201
4836@deffn primitive sigaction signum [handler [flags]]
4837Install or report the signal handler for a specified signal.
4838
4839@var{signum} is the signal number, which can be specified using the value
4840of variables such as @code{SIGINT}.
4841
4842If @var{action} is omitted, @code{sigaction} returns a pair: the
4843CAR is the current
4844signal hander, which will be either an integer with the value @code{SIG_DFL}
4845(default action) or @code{SIG_IGN} (ignore), or the Scheme procedure which
4846handles the signal, or @code{#f} if a non-Scheme procedure handles the
4847signal. The CDR contains the current @code{sigaction} flags for the handler.
4848
4849If @var{action} is provided, it is installed as the new handler for
4850@var{signum}. @var{action} can be a Scheme procedure taking one
4851argument, or the value of @code{SIG_DFL} (default action) or
4852@code{SIG_IGN} (ignore), or @code{#f} to restore whatever signal handler
4853was installed before @code{sigaction} was first used. Flags can
4854optionally be specified for the new handler (@code{SA_RESTART} will
4855always be added if it's available and the system is using restartable
4856system calls.) The return value is a pair with information about the
4857old handler as described above.
4858
4859This interface does not provide access to the "signal blocking"
4860facility. Maybe this is not needed, since the thread support may
4861provide solutions to the problem of consistent access to data
4862structures.
4863@end deffn
4864
4865\frestore-signals
4866@c snarfed from scmsigs.c:360
4867@deffn primitive restore-signals
4868Return all signal handlers to the values they had before any call to
4869@code{sigaction} was made. The return value is unspecified.
4870@end deffn
4871
4872\falarm
4873@c snarfed from scmsigs.c:399
4874@deffn primitive alarm i
4875Set a timer to raise a @code{SIGALRM} signal after the specified
4876number of seconds (an integer). It's advisable to install a signal
4877handler for
4878@code{SIGALRM} beforehand, since the default action is to terminate
4879the process.
4880
4881The return value indicates the time remaining for the previous alarm,
4882if any. The new value replaces the previous alarm. If there was
4883no previous alarm, the return value is zero.
4884@end deffn
4885
4886\fpause
4887@c snarfed from scmsigs.c:414
4888@deffn primitive pause
4889Pause the current process (thread?) until a signal arrives whose
4890action is to either terminate the current process or invoke a
4891handler procedure. The return value is unspecified.
4892@end deffn
4893
4894\fsleep
4895@c snarfed from scmsigs.c:427
4896@deffn primitive sleep i
4897Wait for the given number of seconds (an integer) or until a signal
4898arrives. The return value is zero if the time elapses or the number
4899of seconds remaining otherwise.
4900@end deffn
4901
4902\fusleep
4903@c snarfed from scmsigs.c:445
4904@deffn primitive usleep i
4905Sleep for I microseconds. @code{usleep} is not available on
4906all platforms.
4907@end deffn
4908
4909\fraise
4910@c snarfed from scmsigs.c:475
4911@deffn primitive raise sig
4912Sends a specified signal @var{sig} to the current process, where
4913@var{sig} is as described for the kill procedure.
4914@end deffn
4915
4916\fsystem
89d04205 4917@c snarfed from simpos.c:78
780ee65e 4918@deffn primitive system [cmd]
ae9f3a15
MG
4919Execute @var{cmd} using the operating system's "command
4920processor". Under Unix this is usually the default shell
4921@code{sh}. The value returned is @var{cmd}'s exit status as
4922returned by @code{waitpid}, which can be interpreted using the
4923functions above.
4924If @code{system} is called without arguments, return a boolean
780ee65e
NJ
4925indicating whether the command processor is available.
4926@end deffn
4927
4928\fgetenv
89d04205 4929@c snarfed from simpos.c:106
780ee65e
NJ
4930@deffn primitive getenv nam
4931Looks up the string @var{name} in the current environment. The return
4932value is @code{#f} unless a string of the form @code{NAME=VALUE} is
4933found, in which case the string @code{VALUE} is returned.
4934@end deffn
4935
4936\fprimitive-exit
89d04205 4937@c snarfed from simpos.c:122
780ee65e
NJ
4938@deffn primitive primitive-exit [status]
4939Terminate the current process without unwinding the Scheme stack.
4940This is would typically be useful after a fork. The exit status
4941is @var{status} if supplied, otherwise zero.
4942@end deffn
4943
4944\fhtons
4945@c snarfed from socket.c:89
4946@deffn primitive htons in
ae9f3a15
MG
4947Return a new integer from @var{value} by converting from host
4948to network order. @var{value} must be within the range of a C
4949unsigned short integer.
780ee65e
NJ
4950@end deffn
4951
4952\fntohs
4953@c snarfed from socket.c:106
4954@deffn primitive ntohs in
ae9f3a15
MG
4955Return a new integer from @var{value} by converting from
4956network to host order. @var{value} must be within the range of
4957a C unsigned short integer.
780ee65e
NJ
4958@end deffn
4959
4960\fhtonl
4961@c snarfed from socket.c:123
4962@deffn primitive htonl in
ae9f3a15
MG
4963Return a new integer from @var{value} by converting from host
4964to network order. @var{value} must be within the range of a C
4965unsigned long integer.
780ee65e
NJ
4966@end deffn
4967
4968\fntohl
4969@c snarfed from socket.c:135
4970@deffn primitive ntohl in
ae9f3a15
MG
4971Return a new integer from @var{value} by converting from
4972network to host order. @var{value} must be within the range of
4973a C unsigned long integer.
780ee65e
NJ
4974@end deffn
4975
4976\fsocket
89d04205 4977@c snarfed from socket.c:161
780ee65e 4978@deffn primitive socket family style proto
ae9f3a15
MG
4979Return a new socket port of the type specified by @var{family},
4980@var{style} and @var{protocol}. All three parameters are
72ad43dc
NJ
4981integers. Supported values for @var{family} are
4982@code{AF_UNIX}, @code{AF_INET} and @code{AF_INET6}.
4983Typical values for @var{style} are @code{SOCK_STREAM},
ae9f3a15 4984@code{SOCK_DGRAM} and @code{SOCK_RAW}.
780ee65e 4985@var{protocol} can be obtained from a protocol name using
ae9f3a15
MG
4986@code{getprotobyname}. A value of zero specifies the default
4987protocol, which is usually right.
4988A single socket port cannot by used for communication until it
4989has been connected to another socket.
780ee65e
NJ
4990@end deffn
4991
4992\fsocketpair
89d04205 4993@c snarfed from socket.c:183
780ee65e 4994@deffn primitive socketpair family style proto
ae9f3a15
MG
4995Return a pair of connected (but unnamed) socket ports of the
4996type specified by @var{family}, @var{style} and @var{protocol}.
4997Many systems support only socket pairs of the @code{AF_UNIX}
4998family. Zero is likely to be the only meaningful value for
4999@var{protocol}.
780ee65e
NJ
5000@end deffn
5001
5002\fgetsockopt
89d04205 5003@c snarfed from socket.c:213
780ee65e 5004@deffn primitive getsockopt sock level optname
ae9f3a15
MG
5005Return the value of a particular socket option for the socket
5006port @var{socket}. @var{level} is an integer code for type of
5007option being requested, e.g., @code{SOL_SOCKET} for
5008socket-level options. @var{optname} is an integer code for the
5009option required and should be specified using one of the
5010symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc.
5011The returned value is typically an integer but @code{SO_LINGER}
5012returns a pair of integers.
780ee65e
NJ
5013@end deffn
5014
5015\fsetsockopt
89d04205 5016@c snarfed from socket.c:281
780ee65e
NJ
5017@deffn primitive setsockopt sock level optname value
5018Sets the value of a particular socket option for the socket
5019port @var{socket}. @var{level} is an integer code for type of option
5020being set, e.g., @code{SOL_SOCKET} for socket-level options.
5021@var{optname} is an
5022integer code for the option to set and should be specified using one of
5023the symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc.
5024@var{value} is the value to which the option should be set. For
5025most options this must be an integer, but for @code{SO_LINGER} it must
5026be a pair.
5027
5028The return value is unspecified.
5029@end deffn
5030
5031\fshutdown
72ad43dc 5032@c snarfed from socket.c:403
780ee65e
NJ
5033@deffn primitive shutdown sock how
5034Sockets can be closed simply by using @code{close-port}. The
5035@code{shutdown} procedure allows reception or tranmission on a
5036connection to be shut down individually, according to the parameter
5037@var{how}:
5038
5039@table @asis
5040@item 0
5041Stop receiving data for this socket. If further data arrives, reject it.
5042@item 1
5043Stop trying to transmit data from this socket. Discard any
5044data waiting to be sent. Stop looking for acknowledgement of
5045data already sent; don't retransmit it if it is lost.
5046@item 2
5047Stop both reception and transmission.
5048@end table
5049
5050The return value is unspecified.
5051@end deffn
5052
5053\fconnect
72ad43dc 5054@c snarfed from socket.c:569
780ee65e 5055@deffn primitive connect sock fam address . args
72ad43dc
NJ
5056Initiates a connection from a socket using a specified address
5057family to the address
5058specified by @var{address} and possibly @var{args}.
5059The format required for @var{address}
5060and @var{args} depends on the family of the socket.
780ee65e
NJ
5061
5062For a socket of family @code{AF_UNIX},
72ad43dc 5063only @var{address} is specified and must be a string with the
780ee65e
NJ
5064filename where the socket is to be created.
5065
5066For a socket of family @code{AF_INET},
72ad43dc
NJ
5067@var{address} must be an integer IPv4 host address and
5068@var{args} must be a single integer port number.
5069
5070For a socket of family @code{AF_INET6},
5071@var{address} must be an integer IPv6 host address and
5072@var{args} may be up to three integers:
5073port [flowinfo] [scope_id],
5074where flowinfo and scope_id default to zero.
780ee65e
NJ
5075
5076The return value is unspecified.
5077@end deffn
5078
5079\fbind
72ad43dc 5080@c snarfed from socket.c:623
780ee65e
NJ
5081@deffn primitive bind sock fam address . args
5082Assigns an address to the socket port @var{socket}.
5083Generally this only needs to be done for server sockets,
5084so they know where to look for incoming connections. A socket
5085without an address will be assigned one automatically when it
5086starts communicating.
5087
5088The format of @var{address} and @var{ARG} @dots{} depends on the family
5089of the socket.
5090
5091For a socket of family @code{AF_UNIX}, only @var{address}
5092is specified and must
5093be a string with the filename where the socket is to be created.
5094
5095For a socket of family @code{AF_INET}, @var{address} must be an integer
5096Internet host address and @var{arg} @dots{} must be a single integer
5097port number.
5098
5099The values of the following variables can also be used for @var{address}:
5100
5101@defvar INADDR_ANY
5102Allow connections from any address.
5103@end defvar
5104
5105@defvar INADDR_LOOPBACK
5106The address of the local host using the loopback device.
5107@end defvar
5108
5109@defvar INADDR_BROADCAST
5110The broadcast address on the local network.
5111@end defvar
5112
5113@defvar INADDR_NONE
5114No address.
5115@end defvar
5116
5117The return value is unspecified.
5118@end deffn
5119
5120\flisten
72ad43dc 5121@c snarfed from socket.c:656
780ee65e
NJ
5122@deffn primitive listen sock backlog
5123This procedure enables @var{socket} to accept connection
5124requests. @var{backlog} is an integer specifying
5125the maximum length of the queue for pending connections.
5126If the queue fills, new clients will fail to connect until the
5127server calls @code{accept} to accept a connection from the queue.
5128
5129The return value is unspecified.
5130@end deffn
5131
5132\faccept
72ad43dc 5133@c snarfed from socket.c:793
780ee65e
NJ
5134@deffn primitive accept sock
5135Accepts a connection on a bound, listening socket @var{socket}. If there
5136are no pending connections in the queue, it waits until
5137one is available unless the non-blocking option has been set on the
5138socket.
5139
5140The return value is a
5141pair in which the CAR is a new socket port for the connection and
5142the CDR is an object with address information about the client which
5143initiated the connection.
5144
5145If the address is not available then the CDR will be an empty vector.
5146
5147@var{socket} does not become part of the
5148connection and will continue to accept new requests.
5149@end deffn
5150
5151\fgetsockname
72ad43dc 5152@c snarfed from socket.c:824
780ee65e 5153@deffn primitive getsockname sock
ae9f3a15
MG
5154Return the address of @var{socket}, in the same form as the
5155object returned by @code{accept}. On many systems the address
5156of a socket in the @code{AF_FILE} namespace cannot be read.
780ee65e
NJ
5157@end deffn
5158
5159\fgetpeername
72ad43dc 5160@c snarfed from socket.c:851
780ee65e 5161@deffn primitive getpeername sock
ae9f3a15
MG
5162Return the address of the socket that the socket @var{socket}
5163is connected to, in the same form as the object returned by
5164@code{accept}. On many systems the address of a socket in the
5165@code{AF_FILE} namespace cannot be read.
780ee65e
NJ
5166@end deffn
5167
5168\frecv!
72ad43dc 5169@c snarfed from socket.c:886
780ee65e
NJ
5170@deffn primitive recv! sock buf [flags]
5171Receives data from the socket port @var{socket}. @var{socket} must already
5172be bound to the address from which data is to be received.
5173@var{buf} is a string into which
5174the data will be written. The size of @var{buf} limits the amount of
5175data which can be received: in the case of packet
5176protocols, if a packet larger than this limit is encountered then some data
5177will be irrevocably lost.
5178
5179The optional @var{flags} argument is a value or
5180bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
5181
5182The value returned is the number of bytes read from the socket.
5183
5184Note that the data is read directly from the socket file descriptor:
5185any unread buffered port data is ignored.
5186@end deffn
5187
5188\fsend
72ad43dc 5189@c snarfed from socket.c:915
780ee65e
NJ
5190@deffn primitive send sock message [flags]
5191Transmits the string @var{message} on the socket port @var{socket}.
5192@var{socket} must already be bound to a destination address. The
5193value returned is the number of bytes transmitted -- it's possible for
5194this to be less than the length of @var{message} if the socket is
5195set to be non-blocking. The optional @var{flags} argument is a value or
5196bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
5197
5198Note that the data is written directly to the socket file descriptor:
5199any unflushed buffered port data is ignored.
5200@end deffn
5201
5202\frecvfrom!
72ad43dc 5203@c snarfed from socket.c:957
780ee65e 5204@deffn primitive recvfrom! sock str [flags [start [end]]]
ae9f3a15
MG
5205Return data from the socket port @var{socket} and also
5206information about where the data was received from.
5207@var{socket} must already be bound to the address from which
5208data is to be received. @code{str}, is a string into which the
5209data will be written. The size of @var{str} limits the amount
5210of data which can be received: in the case of packet protocols,
5211if a packet larger than this limit is encountered then some
5212data will be irrevocably lost.
5213The optional @var{flags} argument is a value or bitwise OR of
5214@code{MSG_OOB}, @code{MSG_PEEK}, @code{MSG_DONTROUTE} etc.
5215The value returned is a pair: the @emph{car} is the number of
5216bytes read from the socket and the @emph{cdr} an address object
5217in the same form as returned by @code{accept}.
5218The @var{start} and @var{end} arguments specify a substring of
5219@var{str} to which the data should be written.
5220Note that the data is read directly from the socket file
5221descriptor: any unread buffered port data is ignored.
780ee65e
NJ
5222@end deffn
5223
5224\fsendto
72ad43dc 5225@c snarfed from socket.c:1008
780ee65e
NJ
5226@deffn primitive sendto sock message fam address . args_and_flags
5227Transmits the string @var{message} on the socket port @var{socket}. The
5228destination address is specified using the @var{family}, @var{address} and
5229@var{arg} arguments, in a similar way to the @code{connect}
5230procedure. The
5231value returned is the number of bytes transmitted -- it's possible for
5232this to be less than the length of @var{message} if the socket is
5233set to be non-blocking. The optional @var{flags} argument is a value or
5234bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
5235
5236Note that the data is written directly to the socket file descriptor:
5237any unflushed buffered port data is ignored.
5238@end deffn
5239
5240\frestricted-vector-sort!
5241@c snarfed from sort.c:425
5242@deffn primitive restricted-vector-sort! vec less startpos endpos
5243Sort the vector @var{vec}, using @var{less} for comparing
5244the vector elements. @var{startpos} and @var{endpos} delimit
5245the range of the vector which gets sorted. The return value
5246is not specified.
5247@end deffn
5248
5249\fsorted?
5250@c snarfed from sort.c:456
5251@deffn primitive sorted? items less
5252Return @code{#t} iff @var{items} is a list or a vector such that
5253for all 1 <= i <= m, the predicate @var{less} returns true when
5254applied to all elements i - 1 and i
5255@end deffn
5256
5257\fmerge
5258@c snarfed from sort.c:528
5259@deffn primitive merge alist blist less
5260Takes two lists @var{alist} and @var{blist} such that
5261@code{(sorted? alist less?)} and @code{(sorted? blist less?)} and
5262returns a new list in which the elements of @var{alist} and
5263@var{blist} have been stably interleaved so that
5264@code{(sorted? (merge alist blist less?) less?)}.
5265Note: this does _not_ accept vectors.
5266@end deffn
5267
5268\fmerge!
5269@c snarfed from sort.c:641
5270@deffn primitive merge! alist blist less
5271Takes two lists @var{alist} and @var{blist} such that
5272@code{(sorted? alist less?)} and @code{(sorted? blist less?)} and
5273returns a new list in which the elements of @var{alist} and
5274@var{blist} have been stably interleaved so that
5275 @code{(sorted? (merge alist blist less?) less?)}.
5276This is the destructive variant of @code{merge}
5277Note: this does _not_ accept vectors.
5278@end deffn
5279
5280\fsort!
5281@c snarfed from sort.c:717
5282@deffn primitive sort! items less
5283Sort the sequence @var{items}, which may be a list or a
5284vector. @var{less} is used for comparing the sequence
5285elements. The sorting is destructive, that means that the
5286input sequence is modified to produce the sorted result.
5287This is not a stable sort.
5288@end deffn
5289
5290\fsort
5291@c snarfed from sort.c:751
5292@deffn primitive sort items less
5293Sort the sequence @var{items}, which may be a list or a
5294vector. @var{less} is used for comparing the sequence
5295elements. This is not a stable sort.
5296@end deffn
5297
5298\fstable-sort!
5299@c snarfed from sort.c:847
5300@deffn primitive stable-sort! items less
5301Sort the sequence @var{items}, which may be a list or a
5302vector. @var{less} is used for comparing the sequence elements.
5303The sorting is destructive, that means that the input sequence
5304is modified to produce the sorted result.
5305This is a stable sort.
5306@end deffn
5307
5308\fstable-sort
5309@c snarfed from sort.c:887
5310@deffn primitive stable-sort items less
5311Sort the sequence @var{items}, which may be a list or a
5312vector. @var{less} is used for comparing the sequence elements.
5313This is a stable sort.
5314@end deffn
5315
5316\fsort-list!
5317@c snarfed from sort.c:933
5318@deffn primitive sort-list! items less
5319Sort the list @var{items}, using @var{less} for comparing the
5320list elements. The sorting is destructive, that means that the
5321input list is modified to produce the sorted result.
5322This is a stable sort.
5323@end deffn
5324
5325\fsort-list
5326@c snarfed from sort.c:947
5327@deffn primitive sort-list items less
5328Sort the list @var{items}, using @var{less} for comparing the
5329list elements. This is a stable sort.
5330@end deffn
5331
5332\fsource-properties
72ad43dc 5333@c snarfed from srcprop.c:172
780ee65e
NJ
5334@deffn primitive source-properties obj
5335Return the source property association list of @var{obj}.
5336@end deffn
5337
5338\fset-source-properties!
72ad43dc 5339@c snarfed from srcprop.c:195
780ee65e
NJ
5340@deffn primitive set-source-properties! obj plist
5341Install the association list @var{plist} as the source property
5342list for @var{obj}.
5343@end deffn
5344
5345\fsource-property
72ad43dc 5346@c snarfed from srcprop.c:215
780ee65e
NJ
5347@deffn primitive source-property obj key
5348Return the source property specified by @var{key} from
5349@var{obj}'s source property list.
5350@end deffn
5351
5352\fset-source-property!
72ad43dc 5353@c snarfed from srcprop.c:248
780ee65e
NJ
5354@deffn primitive set-source-property! obj key datum
5355Set the source property of object @var{obj}, which is specified by
5356@var{key} to @var{datum}. Normally, the key will be a symbol.
5357@end deffn
5358
5359\fstack?
5360@c snarfed from stacks.c:407
5361@deffn primitive stack? obj
5362Return @code{#t} if @var{obj} is a calling stack.
5363@end deffn
5364
5365\fmake-stack
5366@c snarfed from stacks.c:421
5367@deffn primitive make-stack obj . args
5368Create a new stack. If @var{obj} is @code{#t}, the current
5369evaluation stack is used for creating the stack frames,
5370otherwise the frames are taken from @var{obj} (which must be
5371either a debug object or a continuation).
5372@var{args} must be a list if integers and specifies how the
5373resulting stack will be narrowed.
5374@end deffn
5375
5376\fstack-id
5377@c snarfed from stacks.c:512
5378@deffn primitive stack-id stack
5379Return the identifier given to @var{stack} by @code{start-stack}.
5380@end deffn
5381
5382\fstack-ref
5383@c snarfed from stacks.c:548
5384@deffn primitive stack-ref stack i
5385Return the @var{i}'th frame from @var{stack}.
5386@end deffn
5387
5388\fstack-length
5389@c snarfed from stacks.c:562
5390@deffn primitive stack-length stack
5391Return the length of @var{stack}.
5392@end deffn
5393
5394\fframe?
5395@c snarfed from stacks.c:575
5396@deffn primitive frame? obj
5397Return @code{#t} if @var{obj} is a stack frame.
5398@end deffn
5399
5400\flast-stack-frame
5401@c snarfed from stacks.c:586
5402@deffn primitive last-stack-frame obj
5403Return a stack which consists of a single frame, which is the
5404last stack frame for @var{obj}. @var{obj} must be either a
5405debug object or a continuation.
5406@end deffn
5407
5408\fframe-number
5409@c snarfed from stacks.c:627
5410@deffn primitive frame-number frame
5411Return the frame number of @var{frame}.
5412@end deffn
5413
5414\fframe-source
5415@c snarfed from stacks.c:637
5416@deffn primitive frame-source frame
5417Return the source of @var{frame}.
5418@end deffn
5419
5420\fframe-procedure
5421@c snarfed from stacks.c:648
5422@deffn primitive frame-procedure frame
5423Return the procedure for @var{frame}, or @code{#f} if no
5424procedure is associated with @var{frame}.
5425@end deffn
5426
5427\fframe-arguments
5428@c snarfed from stacks.c:660
5429@deffn primitive frame-arguments frame
5430Return the arguments of @var{frame}.
5431@end deffn
5432
5433\fframe-previous
5434@c snarfed from stacks.c:671
5435@deffn primitive frame-previous frame
5436Return the previous frame of @var{frame}, or @code{#f} if
5437@var{frame} is the first frame in its stack.
5438@end deffn
5439
5440\fframe-next
5441@c snarfed from stacks.c:687
5442@deffn primitive frame-next frame
5443Return the next frame of @var{frame}, or @code{#f} if
5444@var{frame} is the last frame in its stack.
5445@end deffn
5446
5447\fframe-real?
5448@c snarfed from stacks.c:702
5449@deffn primitive frame-real? frame
5450Return @code{#t} if @var{frame} is a real frame.
5451@end deffn
5452
5453\fframe-procedure?
5454@c snarfed from stacks.c:712
5455@deffn primitive frame-procedure? frame
5456Return @code{#t} if a procedure is associated with @var{frame}.
5457@end deffn
5458
5459\fframe-evaluating-args?
5460@c snarfed from stacks.c:722
5461@deffn primitive frame-evaluating-args? frame
5462Return @code{#t} if @var{frame} contains evaluated arguments.
5463@end deffn
5464
5465\fframe-overflow?
5466@c snarfed from stacks.c:732
5467@deffn primitive frame-overflow? frame
5468Return @code{#t} if @var{frame} is an overflow frame.
5469@end deffn
5470
5471\fget-internal-real-time
89d04205 5472@c snarfed from stime.c:142
780ee65e 5473@deffn primitive get-internal-real-time
ae9f3a15
MG
5474Return the number of time units since the interpreter was
5475started.
780ee65e
NJ
5476@end deffn
5477
5478\ftimes
89d04205 5479@c snarfed from stime.c:187
780ee65e 5480@deffn primitive times
ae9f3a15
MG
5481Return an object with information about real and processor
5482time. The following procedures accept such an object as an
5483argument and return a selected component:
780ee65e
NJ
5484@table @code
5485@item tms:clock
5486The current real time, expressed as time units relative to an
5487arbitrary base.
5488@item tms:utime
5489The CPU time units used by the calling process.
5490@item tms:stime
ae9f3a15
MG
5491The CPU time units used by the system on behalf of the calling
5492process.
780ee65e 5493@item tms:cutime
ae9f3a15
MG
5494The CPU time units used by terminated child processes of the
5495calling process, whose status has been collected (e.g., using
5496@code{waitpid}).
780ee65e
NJ
5497@item tms:cstime
5498Similarly, the CPU times units used by the system on behalf of
5499terminated child processes.
5500@end table
5501@end deffn
5502
5503\fget-internal-run-time
89d04205 5504@c snarfed from stime.c:219
780ee65e 5505@deffn primitive get-internal-run-time
ae9f3a15
MG
5506Return the number of time units of processor time used by the
5507interpreter. Both @emph{system} and @emph{user} time are
5508included but subprocesses are not.
780ee65e
NJ
5509@end deffn
5510
5511\fcurrent-time
89d04205 5512@c snarfed from stime.c:229
780ee65e 5513@deffn primitive current-time
ae9f3a15
MG
5514Return the number of seconds since 1970-01-01 00:00:00 UTC,
5515excluding leap seconds.
780ee65e
NJ
5516@end deffn
5517
5518\fgettimeofday
89d04205 5519@c snarfed from stime.c:247
780ee65e 5520@deffn primitive gettimeofday
ae9f3a15
MG
5521Return a pair containing the number of seconds and microseconds
5522since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note:
5523whether true microsecond resolution is available depends on the
5524operating system.
780ee65e
NJ
5525@end deffn
5526
5527\flocaltime
89d04205 5528@c snarfed from stime.c:347
780ee65e 5529@deffn primitive localtime time [zone]
ae9f3a15
MG
5530Return an object representing the broken down components of
5531@var{time}, an integer like the one returned by
5532@code{current-time}. The time zone for the calculation is
5533optionally specified by @var{zone} (a string), otherwise the
5534@code{TZ} environment variable or the system default is used.
780ee65e
NJ
5535@end deffn
5536
5537\fgmtime
89d04205 5538@c snarfed from stime.c:419
780ee65e 5539@deffn primitive gmtime time
ae9f3a15
MG
5540Return an object representing the broken down components of
5541@var{time}, an integer like the one returned by
5542@code{current-time}. The values are calculated for UTC.
780ee65e
NJ
5543@end deffn
5544
5545\fmktime
89d04205 5546@c snarfed from stime.c:481
780ee65e
NJ
5547@deffn primitive mktime sbd_time [zone]
5548@var{bd-time} is an object representing broken down time and @code{zone}
5549is an optional time zone specifier (otherwise the TZ environment variable
5550or the system default is used).
5551
5552Returns a pair: the car is a corresponding
5553integer time value like that returned
5554by @code{current-time}; the cdr is a broken down time object, similar to
5555as @var{bd-time} but with normalized values.
5556@end deffn
5557
5558\ftzset
89d04205 5559@c snarfed from stime.c:554
780ee65e
NJ
5560@deffn primitive tzset
5561Initialize the timezone from the TZ environment variable
5562or the system default. It's not usually necessary to call this procedure
5563since it's done automatically by other procedures that depend on the
5564timezone.
5565@end deffn
5566
5567\fstrftime
89d04205 5568@c snarfed from stime.c:571
780ee65e
NJ
5569@deffn primitive strftime format stime
5570Formats a time specification @var{time} using @var{template}. @var{time}
5571is an object with time components in the form returned by @code{localtime}
5572or @code{gmtime}. @var{template} is a string which can include formatting
5573specifications introduced by a @code{%} character. The formatting of
5574month and day names is dependent on the current locale. The value returned
5575is the formatted string.
5576@xref{Formatting Date and Time, , , libc, The GNU C Library Reference Manual}.)
5577@end deffn
5578
5579\fstrptime
89d04205 5580@c snarfed from stime.c:669
780ee65e
NJ
5581@deffn primitive strptime format string
5582Performs the reverse action to @code{strftime}, parsing
5583@var{string} according to the specification supplied in
5584@var{template}. The interpretation of month and day names is
5585dependent on the current locale. The value returned is a pair.
5586The car has an object with time components
5587in the form returned by @code{localtime} or @code{gmtime},
5588but the time zone components
5589are not usefully set.
5590The cdr reports the number of characters from @var{string}
5591which were used for the conversion.
5592@end deffn
5593
5594\fstring?
5595@c snarfed from strings.c:62
5596@deffn primitive string? obj
ae9f3a15 5597Return @code{#t} iff @var{obj} is a string, else returns
780ee65e
NJ
5598@code{#f}.
5599@end deffn
5600
5601\fread-only-string?
89d04205 5602@c snarfed from strings.c:78
780ee65e 5603@deffn primitive read-only-string? obj
89d04205
NJ
5604Return @code{#t} if @var{obj} is either a string or a symbol,
5605otherwise return @code{#f}.
780ee65e
NJ
5606@end deffn
5607
5608\flist->string
89d04205 5609@c snarfed from strings.c:87
780ee65e
NJ
5610@deffn primitive list->string
5611scm_string
5612@end deffn
5613
5614\fstring
89d04205 5615@c snarfed from strings.c:93
780ee65e
NJ
5616@deffn primitive string . chrs
5617@deffnx primitive list->string chrs
ae9f3a15 5618Return a newly allocated string composed of the arguments,
780ee65e
NJ
5619@var{chrs}.
5620@end deffn
5621
5622\fmake-string
89d04205 5623@c snarfed from strings.c:246
780ee65e
NJ
5624@deffn primitive make-string k [chr]
5625Return a newly allocated string of
5626length @var{k}. If @var{chr} is given, then all elements of
5627the string are initialized to @var{chr}, otherwise the contents
5628of the @var{string} are unspecified.
5629@end deffn
5630
5631\fstring-length
89d04205 5632@c snarfed from strings.c:279
780ee65e
NJ
5633@deffn primitive string-length string
5634Return the number of characters in @var{string}.
5635@end deffn
5636
5637\fstring-ref
89d04205 5638@c snarfed from strings.c:290
780ee65e
NJ
5639@deffn primitive string-ref str k
5640Return character @var{k} of @var{str} using zero-origin
5641indexing. @var{k} must be a valid index of @var{str}.
5642@end deffn
5643
5644\fstring-set!
89d04205 5645@c snarfed from strings.c:307
780ee65e
NJ
5646@deffn primitive string-set! str k chr
5647Store @var{chr} in element @var{k} of @var{str} and return
5648an unspecified value. @var{k} must be a valid index of
5649@var{str}.
5650@end deffn
5651
5652\fsubstring
89d04205 5653@c snarfed from strings.c:330
780ee65e
NJ
5654@deffn primitive substring str start [end]
5655Return a newly allocated string formed from the characters
5656of @var{str} beginning with index @var{start} (inclusive) and
5657ending with index @var{end} (exclusive).
5658@var{str} must be a string, @var{start} and @var{end} must be
5659exact integers satisfying:
5660
56610 <= @var{start} <= @var{end} <= (string-length @var{str}).
5662@end deffn
5663
5664\fstring-append
89d04205 5665@c snarfed from strings.c:353
780ee65e
NJ
5666@deffn primitive string-append . args
5667Return a newly allocated string whose characters form the
5668concatenation of the given strings, @var{args}.
5669@end deffn
5670
5671\fmake-shared-substring
89d04205 5672@c snarfed from strings.c:393
ae9f3a15 5673@deffn primitive make-shared-substring str [start [end]]
72ad43dc 5674Return a shared substring of @var{str}. The arguments are the
ae9f3a15
MG
5675same as for the @code{substring} function: the shared substring
5676returned includes all of the text from @var{str} between
5677indexes @var{start} (inclusive) and @var{end} (exclusive). If
5678@var{end} is omitted, it defaults to the end of @var{str}. The
5679shared substring returned by @code{make-shared-substring}
5680occupies the same storage space as @var{str}.
780ee65e
NJ
5681@end deffn
5682
5683\fstring-index
89d04205 5684@c snarfed from strop.c:116
780ee65e
NJ
5685@deffn primitive string-index str chr [frm [to]]
5686Return the index of the first occurrence of @var{chr} in
5687@var{str}. The optional integer arguments @var{frm} and
5688@var{to} limit the search to a portion of the string. This
5689procedure essentially implements the @code{index} or
a6be01a4 5690@code{strchr} functions from the C library.
ae9f3a15 5691@lisp
a6be01a4 5692(string-index "weiner" #\e)
780ee65e
NJ
5693@result{} 1
5694
a6be01a4 5695(string-index "weiner" #\e 2)
780ee65e
NJ
5696@result{} 4
5697
a6be01a4 5698(string-index "weiner" #\e 2 4)
780ee65e 5699@result{} #f
ae9f3a15 5700@end lisp
780ee65e
NJ
5701@end deffn
5702
5703\fstring-rindex
89d04205 5704@c snarfed from strop.c:146
780ee65e 5705@deffn primitive string-rindex str chr [frm [to]]
ae9f3a15
MG
5706Like @code{string-index}, but search from the right of the
5707string rather than from the left. This procedure essentially
5708implements the @code{rindex} or @code{strrchr} functions from
5709the C library.
5710@lisp
a6be01a4 5711(string-rindex "weiner" #\e)
780ee65e
NJ
5712@result{} 4
5713
a6be01a4 5714(string-rindex "weiner" #\e 2 4)
780ee65e
NJ
5715@result{} #f
5716
a6be01a4 5717(string-rindex "weiner" #\e 2 5)
780ee65e 5718@result{} 4
ae9f3a15 5719@end lisp
780ee65e
NJ
5720@end deffn
5721
5722\fsubstring-move-left!
89d04205 5723@c snarfed from strop.c:163
780ee65e
NJ
5724@deffn primitive substring-move-left!
5725scm_substring_move_x
5726@end deffn
5727
5728\fsubstring-move-right!
89d04205 5729@c snarfed from strop.c:164
780ee65e
NJ
5730@deffn primitive substring-move-right!
5731scm_substring_move_x
5732@end deffn
5733
5734\fsubstring-move!
89d04205 5735@c snarfed from strop.c:238
780ee65e
NJ
5736@deffn primitive substring-move! str1 start1 end1 str2 start2
5737@deffnx primitive substring-move-left! str1 start1 end1 str2 start2
5738@deffnx primitive substring-move-right! str1 start1 end1 str2 start2
5739Copy the substring of @var{str1} bounded by @var{start1} and @var{end1}
5740into @var{str2} beginning at position @var{end2}.
5741@code{substring-move-right!} begins copying from the rightmost character
5742and moves left, and @code{substring-move-left!} copies from the leftmost
5743character moving right.
5744
5745It is useful to have two functions that copy in different directions so
5746that substrings can be copied back and forth within a single string. If
5747you wish to copy text from the left-hand side of a string to the
5748right-hand side of the same string, and the source and destination
5749overlap, you must be careful to copy the rightmost characters of the
5750text first, to avoid clobbering your data. Hence, when @var{str1} and
5751@var{str2} are the same string, you should use
5752@code{substring-move-right!} when moving text from left to right, and
5753@code{substring-move-left!} otherwise. If @code{str1} and @samp{str2}
5754are different strings, it does not matter which function you use.
5755@end deffn
5756
5757\fsubstring-fill!
89d04205 5758@c snarfed from strop.c:274
780ee65e 5759@deffn primitive substring-fill! str start end fill
ae9f3a15
MG
5760Change every character in @var{str} between @var{start} and
5761@var{end} to @var{fill}.
5762@lisp
780ee65e 5763(define y "abcdefg")
a6be01a4 5764(substring-fill! y 1 3 #\r)
780ee65e
NJ
5765y
5766@result{} "arrdefg"
ae9f3a15 5767@end lisp
780ee65e
NJ
5768@end deffn
5769
5770\fstring-null?
89d04205 5771@c snarfed from strop.c:299
780ee65e 5772@deffn primitive string-null? str
ae9f3a15
MG
5773Return @code{#t} if @var{str}'s length is nonzero, and
5774@code{#f} otherwise.
5775@lisp
5776(string-null? "") @result{} #t
5777y @result{} "foo"
5778(string-null? y) @result{} #f
5779@end lisp
780ee65e
NJ
5780@end deffn
5781
5782\fstring->list
89d04205 5783@c snarfed from strop.c:313
780ee65e 5784@deffn primitive string->list str
ae9f3a15
MG
5785Return a newly allocated list of the characters that make up
5786the given string @var{str}. @code{string->list} and
5787@code{list->string} are inverses as far as @samp{equal?} is
5788concerned.
780ee65e
NJ
5789@end deffn
5790
5791\fstring-copy
89d04205 5792@c snarfed from strop.c:338
780ee65e 5793@deffn primitive string-copy str
ae9f3a15 5794Return a newly allocated copy of the given @var{string}.
780ee65e
NJ
5795@end deffn
5796
5797\fstring-fill!
89d04205 5798@c snarfed from strop.c:351
780ee65e 5799@deffn primitive string-fill! str chr
ae9f3a15
MG
5800Store @var{char} in every element of the given @var{string} and
5801return an unspecified value.
780ee65e
NJ
5802@end deffn
5803
5804\fstring-upcase!
89d04205 5805@c snarfed from strop.c:386
780ee65e 5806@deffn primitive string-upcase! str
ae9f3a15
MG
5807Destructively upcase every character in @var{str} and return
5808@var{str}.
5809@lisp
5810y @result{} "arrdefg"
5811(string-upcase! y) @result{} "ARRDEFG"
5812y @result{} "ARRDEFG"
5813@end lisp
780ee65e
NJ
5814@end deffn
5815
5816\fstring-upcase
89d04205 5817@c snarfed from strop.c:399
780ee65e 5818@deffn primitive string-upcase str
ae9f3a15
MG
5819Return a freshly allocated string containing the characters of
5820@var{str} in upper case.
780ee65e
NJ
5821@end deffn
5822
5823\fstring-downcase!
89d04205 5824@c snarfed from strop.c:431
780ee65e 5825@deffn primitive string-downcase! str
ae9f3a15
MG
5826Destructively downcase every character in @var{str} and return
5827@var{str}.
5828@lisp
5829y @result{} "ARRDEFG"
5830(string-downcase! y) @result{} "arrdefg"
5831y @result{} "arrdefg"
5832@end lisp
780ee65e
NJ
5833@end deffn
5834
5835\fstring-downcase
89d04205 5836@c snarfed from strop.c:444
780ee65e 5837@deffn primitive string-downcase str
ae9f3a15
MG
5838Return a freshly allocation string containing the characters in
5839@var{str} in lower case.
780ee65e
NJ
5840@end deffn
5841
5842\fstring-capitalize!
89d04205 5843@c snarfed from strop.c:488
780ee65e 5844@deffn primitive string-capitalize! str
ae9f3a15
MG
5845Upcase the first character of every word in @var{str}
5846destructively and return @var{str}.
5847@lisp
5848y @result{} "hello world"
5849(string-capitalize! y) @result{} "Hello World"
5850y @result{} "Hello World"
5851@end lisp
780ee65e
NJ
5852@end deffn
5853
5854\fstring-capitalize
89d04205 5855@c snarfed from strop.c:502
780ee65e 5856@deffn primitive string-capitalize str
ae9f3a15
MG
5857Return a freshly allocated string with the characters in
5858@var{str}, where the first character of every word is
5859capitalized.
780ee65e
NJ
5860@end deffn
5861
5862\fstring-ci->symbol
89d04205 5863@c snarfed from strop.c:516
780ee65e 5864@deffn primitive string-ci->symbol str
ae9f3a15
MG
5865Return the symbol whose name is @var{str}. @var{str} is
5866converted to lowercase before the conversion is done, if Guile
5867is currently reading symbols case--insensitively.
780ee65e
NJ
5868@end deffn
5869
5870\fstring=?
5871@c snarfed from strorder.c:64
5872@deffn primitive string=? s1 s2
ae9f3a15
MG
5873Lexicographic equality predicate; return @code{#t} if the two
5874strings are the same length and contain the same characters in
5875the same positions, otherwise return @code{#f}.
780ee65e
NJ
5876The procedure @code{string-ci=?} treats upper and lower case
5877letters as though they were the same character, but
5878@code{string=?} treats upper and lower case as distinct
5879characters.
5880@end deffn
5881
5882\fstring-ci=?
5883@c snarfed from strorder.c:99
5884@deffn primitive string-ci=? s1 s2
ae9f3a15
MG
5885Case-insensitive string equality predicate; return @code{#t} if
5886the two strings are the same length and their component
780ee65e 5887characters match (ignoring case) at each position; otherwise
ae9f3a15 5888return @code{#f}.
780ee65e
NJ
5889@end deffn
5890
5891\fstring<?
5892@c snarfed from strorder.c:156
5893@deffn primitive string<? s1 s2
ae9f3a15
MG
5894Lexicographic ordering predicate; return @code{#t} if @var{s1}
5895is lexicographically less than @var{s2}.
780ee65e
NJ
5896@end deffn
5897
5898\fstring<=?
89d04205 5899@c snarfed from strorder.c:170
780ee65e 5900@deffn primitive string<=? s1 s2
ae9f3a15
MG
5901Lexicographic ordering predicate; return @code{#t} if @var{s1}
5902is lexicographically less than or equal to @var{s2}.
780ee65e
NJ
5903@end deffn
5904
5905\fstring>?
89d04205 5906@c snarfed from strorder.c:184
780ee65e 5907@deffn primitive string>? s1 s2
ae9f3a15
MG
5908Lexicographic ordering predicate; return @code{#t} if @var{s1}
5909is lexicographically greater than @var{s2}.
780ee65e
NJ
5910@end deffn
5911
5912\fstring>=?
89d04205 5913@c snarfed from strorder.c:198
780ee65e 5914@deffn primitive string>=? s1 s2
ae9f3a15
MG
5915Lexicographic ordering predicate; return @code{#t} if @var{s1}
5916is lexicographically greater than or equal to @var{s2}.
780ee65e
NJ
5917@end deffn
5918
5919\fstring-ci<?
89d04205 5920@c snarfed from strorder.c:237
780ee65e 5921@deffn primitive string-ci<? s1 s2
ae9f3a15
MG
5922Case insensitive lexicographic ordering predicate; return
5923@code{#t} if @var{s1} is lexicographically less than @var{s2}
5924regardless of case.
780ee65e
NJ
5925@end deffn
5926
5927\fstring-ci<=?
89d04205 5928@c snarfed from strorder.c:252
780ee65e 5929@deffn primitive string-ci<=? s1 s2
ae9f3a15
MG
5930Case insensitive lexicographic ordering predicate; return
5931@code{#t} if @var{s1} is lexicographically less than or equal
5932to @var{s2} regardless of case.
780ee65e
NJ
5933@end deffn
5934
5935\fstring-ci>?
89d04205 5936@c snarfed from strorder.c:267
780ee65e 5937@deffn primitive string-ci>? s1 s2
ae9f3a15
MG
5938Case insensitive lexicographic ordering predicate; return
5939@code{#t} if @var{s1} is lexicographically greater than
5940@var{s2} regardless of case.
780ee65e
NJ
5941@end deffn
5942
5943\fstring-ci>=?
89d04205 5944@c snarfed from strorder.c:282
780ee65e 5945@deffn primitive string-ci>=? s1 s2
ae9f3a15
MG
5946Case insensitive lexicographic ordering predicate; return
5947@code{#t} if @var{s1} is lexicographically greater than or
5948equal to @var{s2} regardless of case.
780ee65e
NJ
5949@end deffn
5950
5951\fobject->string
5952@c snarfed from strports.c:318
5953@deffn primitive object->string obj [printer]
5954Return a Scheme string obtained by printing @var{obj}.
5955Printing function can be specified by the optional second
5956argument @var{printer} (default: @code{write}).
5957@end deffn
5958
5959\fcall-with-output-string
5960@c snarfed from strports.c:352
5961@deffn primitive call-with-output-string proc
5962Calls the one-argument procedure @var{proc} with a newly created output
5963port. When the function returns, the string composed of the characters
5964written into the port is returned.
5965@end deffn
5966
5967\fcall-with-input-string
5968@c snarfed from strports.c:371
ae9f3a15
MG
5969@deffn primitive call-with-input-string string proc
5970Calls the one-argument procedure @var{proc} with a newly
5971created input port from which @var{string}'s contents may be
5972read. The value yielded by the @var{proc} is returned.
780ee65e
NJ
5973@end deffn
5974
5975\fopen-input-string
5976@c snarfed from strports.c:384
5977@deffn primitive open-input-string str
ae9f3a15
MG
5978Take a string and return an input port that delivers characters
5979from the string. The port can be closed by
780ee65e
NJ
5980@code{close-input-port}, though its storage will be reclaimed
5981by the garbage collector if it becomes inaccessible.
5982@end deffn
5983
5984\fopen-output-string
5985@c snarfed from strports.c:398
5986@deffn primitive open-output-string
ae9f3a15 5987Return an output port that will accumulate characters for
780ee65e
NJ
5988retrieval by @code{get-output-string}. The port can be closed
5989by the procedure @code{close-output-port}, though its storage
5990will be reclaimed by the garbage collector if it becomes
5991inaccessible.
5992@end deffn
5993
5994\fget-output-string
5995@c snarfed from strports.c:415
5996@deffn primitive get-output-string port
5997Given an output port created by @code{open-output-string},
ae9f3a15 5998return a string consisting of the characters that have been
780ee65e
NJ
5999output to the port so far.
6000@end deffn
6001
6002\feval-string
6003@c snarfed from strports.c:456
6004@deffn primitive eval-string string
6005Evaluate @var{string} as the text representation of a Scheme
6006form or forms, and return whatever value they produce.
6007Evaluation takes place in the environment returned by the
6008procedure @code{interaction-environment}.
6009@end deffn
6010
6011\fmake-struct-layout
6012@c snarfed from struct.c:79
6013@deffn primitive make-struct-layout fields
6014Return a new structure layout object.
6015
6016@var{fields} must be a string made up of pairs of characters
6017strung together. The first character of each pair describes a field
6018type, the second a field protection. Allowed types are 'p' for
6019GC-protected Scheme data, 'u' for unprotected binary data, and 's' for
6020a field that points to the structure itself. Allowed protections
6021are 'w' for mutable fields, 'r' for read-only fields, and 'o' for opaque
6022fields. The last field protection specification may be capitalized to
6023indicate that the field is a tail-array.
6024@end deffn
6025
6026\fstruct?
6027@c snarfed from struct.c:246
6028@deffn primitive struct? x
6029Return @code{#t} iff @var{obj} is a structure object, else
6030@code{#f}.
6031@end deffn
6032
6033\fstruct-vtable?
6034@c snarfed from struct.c:255
6035@deffn primitive struct-vtable? x
6036Return @code{#t} iff obj is a vtable structure.
6037@end deffn
6038
6039\fmake-struct
6040@c snarfed from struct.c:437
6041@deffn primitive make-struct vtable tail_array_size . init
6042Create a new structure.
6043
6044@var{type} must be a vtable structure (@pxref{Vtables}).
6045
6046@var{tail-elts} must be a non-negative integer. If the layout
6047specification indicated by @var{type} includes a tail-array,
6048this is the number of elements allocated to that array.
6049
6050The @var{init1}, @dots{} are optional arguments describing how
6051successive fields of the structure should be initialized. Only fields
6052with protection 'r' or 'w' can be initialized, except for fields of
6053type 's', which are automatically initialized to point to the new
6054structure itself; fields with protection 'o' can not be initialized by
6055Scheme programs.
6056
6057If fewer optional arguments than initializable fields are supplied,
6058fields of type 'p' get default value #f while fields of type 'u' are
6059initialized to 0.
6060
6061Structs are currently the basic representation for record-like data
6062structures in Guile. The plan is to eventually replace them with a
6063new representation which will at the same time be easier to use and
6064more powerful.
6065
6066For more information, see the documentation for @code{make-vtable-vtable}.
6067@end deffn
6068
6069\fmake-vtable-vtable
6070@c snarfed from struct.c:523
6071@deffn primitive make-vtable-vtable user_fields tail_array_size . init
6072Return a new, self-describing vtable structure.
6073
6074@var{user-fields} is a string describing user defined fields of the
6075vtable beginning at index @code{vtable-offset-user}
6076(see @code{make-struct-layout}).
6077
6078@var{tail-size} specifies the size of the tail-array (if any) of
6079this vtable.
6080
6081@var{init1}, @dots{} are the optional initializers for the fields of
6082the vtable.
6083
6084Vtables have one initializable system field---the struct printer.
6085This field comes before the user fields in the initializers passed
6086to @code{make-vtable-vtable} and @code{make-struct}, and thus works as
6087a third optional argument to @code{make-vtable-vtable} and a fourth to
6088@code{make-struct} when creating vtables:
6089
6090If the value is a procedure, it will be called instead of the standard
6091printer whenever a struct described by this vtable is printed.
6092The procedure will be called with arguments STRUCT and PORT.
6093
6094The structure of a struct is described by a vtable, so the vtable is
6095in essence the type of the struct. The vtable is itself a struct with
6096a vtable. This could go on forever if it weren't for the
6097vtable-vtables which are self-describing vtables, and thus terminate
6098the chain.
6099
6100There are several potential ways of using structs, but the standard
6101one is to use three kinds of structs, together building up a type
6102sub-system: one vtable-vtable working as the root and one or several
6103"types", each with a set of "instances". (The vtable-vtable should be
6104compared to the class <class> which is the class of itself.)
6105
ae9f3a15 6106@lisp
780ee65e
NJ
6107(define ball-root (make-vtable-vtable "pr" 0))
6108
6109(define (make-ball-type ball-color)
6110 (make-struct ball-root 0
6111 (make-struct-layout "pw")
6112 (lambda (ball port)
6113 (format port "#<a ~A ball owned by ~A>"
6114 (color ball)
6115 (owner ball)))
6116 ball-color))
6117(define (color ball) (struct-ref (struct-vtable ball) vtable-offset-user))
6118(define (owner ball) (struct-ref ball 0))
6119
6120(define red (make-ball-type 'red))
6121(define green (make-ball-type 'green))
6122
6123(define (make-ball type owner) (make-struct type 0 owner))
6124
6125(define ball (make-ball green 'Nisse))
6126ball @result{} #<a green ball owned by Nisse>
ae9f3a15 6127@end lisp
780ee65e
NJ
6128@end deffn
6129
6130\fstruct-ref
6131@c snarfed from struct.c:565
6132@deffn primitive struct-ref handle pos
6133@deffnx primitive struct-set! struct n value
6134Access (or modify) the @var{n}th field of @var{struct}.
6135
6136If the field is of type 'p', then it can be set to an arbitrary value.
6137
6138If the field is of type 'u', then it can only be set to a non-negative
6139integer value small enough to fit in one machine word.
6140@end deffn
6141
6142\fstruct-set!
6143@c snarfed from struct.c:643
6144@deffn primitive struct-set! handle pos val
6145Set the slot of the structure @var{handle} with index @var{pos}
6146to @var{val}. Signal an error if the slot can not be written
6147to.
6148@end deffn
6149
6150\fstruct-vtable
6151@c snarfed from struct.c:713
6152@deffn primitive struct-vtable handle
6153Return the vtable structure that describes the type of @var{struct}.
6154@end deffn
6155
6156\fstruct-vtable-tag
6157@c snarfed from struct.c:724
6158@deffn primitive struct-vtable-tag handle
6159Return the vtable tag of the structure @var{handle}.
6160@end deffn
6161
6162\fstruct-vtable-name
6163@c snarfed from struct.c:763
6164@deffn primitive struct-vtable-name vtable
6165Return the name of the vtable @var{vtable}.
6166@end deffn
6167
6168\fset-struct-vtable-name!
6169@c snarfed from struct.c:773
6170@deffn primitive set-struct-vtable-name! vtable name
6171Set the name of the vtable @var{vtable} to @var{name}.
6172@end deffn
6173
6174\fsymbol?
6175@c snarfed from symbols.c:422
6176@deffn primitive symbol? obj
ae9f3a15
MG
6177Return @code{#t} if @var{obj} is a symbol, otherwise return
6178@code{#f}.
780ee65e
NJ
6179@end deffn
6180
6181\fsymbol->string
89d04205 6182@c snarfed from symbols.c:453
780ee65e 6183@deffn primitive symbol->string s
ae9f3a15
MG
6184Return the name of @var{symbol} as a string. If the symbol was
6185part of an object returned as the value of a literal expression
6186(section @pxref{Literal expressions,,,r4rs, The Revised^4
6187Report on Scheme}) or by a call to the @code{read} procedure,
6188and its name contains alphabetic characters, then the string
6189returned will contain characters in the implementation's
6190preferred standard case---some implementations will prefer
6191upper case, others lower case. If the symbol was returned by
6192@code{string->symbol}, the case of characters in the string
6193returned will be the same as the case in the string that was
6194passed to @code{string->symbol}. It is an error to apply
6195mutation procedures like @code{string-set!} to strings returned
6196by this procedure.
780ee65e
NJ
6197The following examples assume that the implementation's
6198standard case is lower case:
780ee65e 6199@lisp
ae9f3a15
MG
6200(symbol->string 'flying-fish) @result{} "flying-fish"
6201(symbol->string 'Martin) @result{} "martin"
780ee65e
NJ
6202(symbol->string
6203 (string->symbol "Malvina")) @result{} "Malvina"
6204@end lisp
6205@end deffn
6206
6207\fstring->symbol
89d04205 6208@c snarfed from symbols.c:483
ae9f3a15
MG
6209@deffn primitive string->symbol string
6210Return the symbol whose name is @var{string}. This procedure
780ee65e
NJ
6211can create symbols with names containing special characters or
6212letters in the non-standard case, but it is usually a bad idea
ae9f3a15
MG
6213to create such symbols because in some implementations of
6214Scheme they cannot be read as themselves. See
6215@code{symbol->string}.
780ee65e
NJ
6216The following examples assume that the implementation's
6217standard case is lower case:
780ee65e
NJ
6218@lisp
6219(eq? 'mISSISSIppi 'mississippi) @result{} #t
6220(string->symbol "mISSISSIppi") @result{} @r{the symbol with name "mISSISSIppi"}
6221(eq? 'bitBlt (string->symbol "bitBlt")) @result{} #f
6222(eq? 'JollyWog
6223 (string->symbol (symbol->string 'JollyWog))) @result{} #t
6224(string=? "K. Harper, M.D."
6225 (symbol->string
6226 (string->symbol "K. Harper, M.D."))) @result{}#t
6227@end lisp
6228@end deffn
6229
6230\fstring->obarray-symbol
89d04205 6231@c snarfed from symbols.c:505
780ee65e
NJ
6232@deffn primitive string->obarray-symbol o s [softp]
6233Intern a new symbol in @var{obarray}, a symbol table, with name
6234@var{string}.
6235
6236If @var{obarray} is @code{#f}, use the default system symbol table. If
6237@var{obarray} is @code{#t}, the symbol should not be interned in any
6238symbol table; merely return the pair (@var{symbol}
6239. @var{#<undefined>}).
6240
6241The @var{soft?} argument determines whether new symbol table entries
6242should be created when the specified symbol is not already present in
6243@var{obarray}. If @var{soft?} is specified and is a true value, then
6244new entries should not be added for symbols not already present in the
6245table; instead, simply return @code{#f}.
6246@end deffn
6247
6248\fintern-symbol
89d04205 6249@c snarfed from symbols.c:537
780ee65e
NJ
6250@deffn primitive intern-symbol o s
6251Add a new symbol to @var{obarray} with name @var{string}, bound to an
6252unspecified initial value. The symbol table is not modified if a symbol
6253with this name is already present.
6254@end deffn
6255
6256\funintern-symbol
89d04205 6257@c snarfed from symbols.c:574
780ee65e
NJ
6258@deffn primitive unintern-symbol o s
6259Remove the symbol with name @var{string} from @var{obarray}. This
6260function returns @code{#t} if the symbol was present and @code{#f}
6261otherwise.
6262@end deffn
6263
6264\fsymbol-binding
89d04205 6265@c snarfed from symbols.c:615
780ee65e
NJ
6266@deffn primitive symbol-binding o s
6267Look up in @var{obarray} the symbol whose name is @var{string}, and
6268return the value to which it is bound. If @var{obarray} is @code{#f},
6269use the global symbol table. If @var{string} is not interned in
6270@var{obarray}, an error is signalled.
6271@end deffn
6272
6273\fsymbol-interned?
89d04205 6274@c snarfed from symbols.c:632
780ee65e
NJ
6275@deffn primitive symbol-interned? o s
6276Return @code{#t} if @var{obarray} contains a symbol with name
6277@var{string}, and @code{#f} otherwise.
6278@end deffn
6279
6280\fsymbol-bound?
89d04205 6281@c snarfed from symbols.c:655
780ee65e
NJ
6282@deffn primitive symbol-bound? o s
6283Return @code{#t} if @var{obarray} contains a symbol with name
6284@var{string} bound to a defined value. This differs from
6285@var{symbol-interned?} in that the mere mention of a symbol
6286usually causes it to be interned; @code{symbol-bound?}
6287determines whether a symbol has been given any meaningful
6288value.
6289@end deffn
6290
6291\fsymbol-set!
89d04205 6292@c snarfed from symbols.c:673
780ee65e
NJ
6293@deffn primitive symbol-set! o s v
6294Find the symbol in @var{obarray} whose name is @var{string}, and rebind
6295it to @var{value}. An error is signalled if @var{string} is not present
6296in @var{obarray}.
6297@end deffn
6298
6299\fsymbol-fref
89d04205 6300@c snarfed from symbols.c:690
780ee65e
NJ
6301@deffn primitive symbol-fref s
6302Return the contents of @var{symbol}'s @dfn{function slot}.
6303@end deffn
6304
6305\fsymbol-pref
89d04205 6306@c snarfed from symbols.c:701
780ee65e
NJ
6307@deffn primitive symbol-pref s
6308Return the @dfn{property list} currently associated with @var{symbol}.
6309@end deffn
6310
6311\fsymbol-fset!
89d04205 6312@c snarfed from symbols.c:712
780ee65e
NJ
6313@deffn primitive symbol-fset! s val
6314Change the binding of @var{symbol}'s function slot.
6315@end deffn
6316
6317\fsymbol-pset!
89d04205 6318@c snarfed from symbols.c:724
780ee65e
NJ
6319@deffn primitive symbol-pset! s val
6320Change the binding of @var{symbol}'s property slot.
6321@end deffn
6322
6323\fsymbol-hash
89d04205 6324@c snarfed from symbols.c:738
780ee65e
NJ
6325@deffn primitive symbol-hash symbol
6326Return a hash value for @var{symbol}.
6327@end deffn
6328
6329\fbuiltin-bindings
89d04205 6330@c snarfed from symbols.c:775
780ee65e
NJ
6331@deffn primitive builtin-bindings
6332Create and return a copy of the global symbol table, removing all
6333unbound symbols.
6334@end deffn
6335
6336\fgensym
89d04205 6337@c snarfed from symbols.c:796
780ee65e
NJ
6338@deffn primitive gensym [prefix]
6339Create a new symbol with a name constructed from a prefix and
6340a counter value. The string @var{prefix} can be specified as
6341an optional argument. Default prefix is @code{g}. The counter
6342is increased by 1 at each call. There is no provision for
6343resetting the counter.
6344@end deffn
6345
6346\fgentemp
89d04205 6347@c snarfed from symbols.c:835
780ee65e
NJ
6348@deffn primitive gentemp [prefix [obarray]]
6349Create a new symbol with a name unique in an obarray.
6350The name is constructed from an optional string @var{prefix}
6351and a counter value. The default prefix is @code{t}. The
6352@var{obarray} is specified as a second optional argument.
6353Default is the system obarray where all normal symbols are
6354interned. The counter is increased by 1 at each
6355call. There is no provision for resetting the counter.
6356@end deffn
6357
6358\ftag
6359@c snarfed from tag.c:98
6360@deffn primitive tag x
6361Return an integer corresponding to the type of X. Deprecated.
6362@end deffn
6363
6364\fcatch
89d04205 6365@c snarfed from throw.c:535
ae9f3a15 6366@deffn primitive catch key thunk handler
780ee65e 6367Invoke @var{thunk} in the dynamic context of @var{handler} for
ae9f3a15
MG
6368exceptions matching @var{key}. If thunk throws to the symbol
6369@var{key}, then @var{handler} is invoked this way:
6370@lisp
780ee65e 6371(handler key args ...)
ae9f3a15
MG
6372@end lisp
6373@var{key} is a symbol or @code{#t}.
6374@var{thunk} takes no arguments. If @var{thunk} returns
6375normally, that is the return value of @code{catch}.
6376Handler is invoked outside the scope of its own @code{catch}.
6377If @var{handler} again throws to the same key, a new handler
6378from further up the call chain is invoked.
6379If the key is @code{#t}, then a throw to @emph{any} symbol will
6380match this call to @code{catch}.
780ee65e
NJ
6381@end deffn
6382
6383\flazy-catch
89d04205 6384@c snarfed from throw.c:562
ae9f3a15 6385@deffn primitive lazy-catch key thunk handler
780ee65e
NJ
6386This behaves exactly like @code{catch}, except that it does
6387not unwind the stack (this is the major difference), and if
6388handler returns, its value is returned from the throw.
6389@end deffn
6390
6391\fthrow
89d04205 6392@c snarfed from throw.c:595
780ee65e
NJ
6393@deffn primitive throw key . args
6394Invoke the catch form matching @var{key}, passing @var{args} to the
6395@var{handler}.
6396
6397@var{key} is a symbol. It will match catches of the same symbol or of
6398#t.
6399
6400If there is no handler at all, an error is signaled.
6401@end deffn
6402
6403\funiform-vector-length
6404@c snarfed from unif.c:255
6405@deffn primitive uniform-vector-length v
ae9f3a15 6406Return the number of elements in @var{uve}.
780ee65e
NJ
6407@end deffn
6408
6409\farray?
6410@c snarfed from unif.c:289
6411@deffn primitive array? v [prot]
ae9f3a15
MG
6412Return @code{#t} if the @var{obj} is an array, and @code{#f} if
6413not. The @var{prototype} argument is used with uniform arrays
6414and is described elsewhere.
780ee65e
NJ
6415@end deffn
6416
6417\farray-rank
6418@c snarfed from unif.c:360
6419@deffn primitive array-rank ra
ae9f3a15
MG
6420Return the number of dimensions of @var{obj}. If @var{obj} is
6421not an array, @code{0} is returned.
780ee65e
NJ
6422@end deffn
6423
6424\farray-dimensions
6425@c snarfed from unif.c:398
6426@deffn primitive array-dimensions ra
6427@code{Array-dimensions} is similar to @code{array-shape} but replaces
6428elements with a @code{0} minimum with one greater than the maximum. So:
ae9f3a15 6429@lisp
780ee65e 6430(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5)
ae9f3a15 6431@end lisp
780ee65e
NJ
6432@end deffn
6433
6434\fshared-array-root
6435@c snarfed from unif.c:445
6436@deffn primitive shared-array-root ra
6437Return the root vector of a shared array.
6438@end deffn
6439
6440\fshared-array-offset
6441@c snarfed from unif.c:456
6442@deffn primitive shared-array-offset ra
6443Return the root vector index of the first element in the array.
6444@end deffn
6445
6446\fshared-array-increments
6447@c snarfed from unif.c:467
6448@deffn primitive shared-array-increments ra
6449For each dimension, return the distance between elements in the root vector.
6450@end deffn
6451
6452\fdimensions->uniform-array
6453@c snarfed from unif.c:586
6454@deffn primitive dimensions->uniform-array dims prot [fill]
6455@deffnx primitive make-uniform-vector length prototype [fill]
ae9f3a15
MG
6456Create and return a uniform array or vector of type
6457corresponding to @var{prototype} with dimensions @var{dims} or
6458length @var{length}. If @var{fill} is supplied, it's used to
6459fill the array, otherwise @var{prototype} is used.
780ee65e
NJ
6460@end deffn
6461
6462\fmake-shared-array
6463@c snarfed from unif.c:672
6464@deffn primitive make-shared-array oldra mapfunc . dims
6465@code{make-shared-array} can be used to create shared subarrays of other
6466arrays. The @var{mapper} is a function that translates coordinates in
6467the new array into coordinates in the old array. A @var{mapper} must be
6468linear, and its range must stay within the bounds of the old array, but
6469it can be otherwise arbitrary. A simple example:
ae9f3a15 6470@lisp
780ee65e
NJ
6471(define fred (make-array #f 8 8))
6472(define freds-diagonal
6473 (make-shared-array fred (lambda (i) (list i i)) 8))
6474(array-set! freds-diagonal 'foo 3)
6475(array-ref fred 3 3) @result{} foo
6476(define freds-center
6477 (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2))
6478(array-ref freds-center 0 0) @result{} foo
ae9f3a15 6479@end lisp
780ee65e
NJ
6480@end deffn
6481
6482\ftranspose-array
89d04205 6483@c snarfed from unif.c:804
780ee65e 6484@deffn primitive transpose-array ra . args
ae9f3a15
MG
6485Return an array sharing contents with @var{array}, but with
6486dimensions arranged in a different order. There must be one
6487@var{dim} argument for each dimension of @var{array}.
6488@var{dim0}, @var{dim1}, @dots{} should be integers between 0
6489and the rank of the array to be returned. Each integer in that
6490range must appear at least once in the argument list.
6491The values of @var{dim0}, @var{dim1}, @dots{} correspond to
6492dimensions in the array to be returned, their positions in the
6493argument list to dimensions of @var{array}. Several @var{dim}s
6494may have the same value, in which case the returned array will
6495have smaller rank than @var{array}.
6496@lisp
780ee65e
NJ
6497(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d))
6498(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d)
6499(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{}
6500 #2((a 4) (b 5) (c 6))
ae9f3a15 6501@end lisp
780ee65e
NJ
6502@end deffn
6503
6504\fenclose-array
89d04205 6505@c snarfed from unif.c:913
780ee65e
NJ
6506@deffn primitive enclose-array ra . axes
6507@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than
6508the rank of @var{array}. @var{enclose-array} returns an array
6509resembling an array of shared arrays. The dimensions of each shared
6510array are the same as the @var{dim}th dimensions of the original array,
6511the dimensions of the outer array are the same as those of the original
6512array that did not match a @var{dim}.
6513
6514An enclosed array is not a general Scheme array. Its elements may not
6515be set using @code{array-set!}. Two references to the same element of
6516an enclosed array will be @code{equal?} but will not in general be
6517@code{eq?}. The value returned by @var{array-prototype} when given an
6518enclosed array is unspecified.
6519
6520examples:
ae9f3a15 6521@lisp
780ee65e
NJ
6522(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{}
6523 #<enclosed-array (#1(a d) #1(b e) #1(c f)) (#1(1 4) #1(2 5) #1(3 6))>
6524
6525(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{}
6526 #<enclosed-array #2((a 1) (d 4)) #2((b 2) (e 5)) #2((c 3) (f 6))>
ae9f3a15 6527@end lisp
780ee65e
NJ
6528@end deffn
6529
6530\farray-in-bounds?
89d04205 6531@c snarfed from unif.c:997
780ee65e 6532@deffn primitive array-in-bounds? v . args
ae9f3a15
MG
6533Return @code{#t} if its arguments would be acceptable to
6534@code{array-ref}.
780ee65e
NJ
6535@end deffn
6536
6537\farray-ref
89d04205 6538@c snarfed from unif.c:1076
780ee65e
NJ
6539@deffn primitive array-ref
6540scm_uniform_vector_ref
6541@end deffn
6542
6543\funiform-vector-ref
89d04205 6544@c snarfed from unif.c:1083
780ee65e
NJ
6545@deffn primitive uniform-vector-ref v args
6546@deffnx primitive array-ref v . args
ae9f3a15
MG
6547Return the element at the @code{(index1, index2)} element in
6548@var{array}.
780ee65e
NJ
6549@end deffn
6550
6551\funiform-array-set1!
89d04205 6552@c snarfed from unif.c:1252
780ee65e
NJ
6553@deffn primitive uniform-array-set1!
6554scm_array_set_x
6555@end deffn
6556
6557\farray-set!
89d04205 6558@c snarfed from unif.c:1261
780ee65e
NJ
6559@deffn primitive array-set! v obj . args
6560@deffnx primitive uniform-array-set1! v obj args
6561Sets the element at the @code{(index1, index2)} element in @var{array} to
6562@var{new-value}. The value returned by array-set! is unspecified.
6563@end deffn
6564
6565\farray-contents
89d04205 6566@c snarfed from unif.c:1376
780ee65e
NJ
6567@deffn primitive array-contents ra [strict]
6568@deffnx primitive array-contents array strict
6569If @var{array} may be @dfn{unrolled} into a one dimensional shared array
6570without changing their order (last subscript changing fastest), then
6571@code{array-contents} returns that shared array, otherwise it returns
6572@code{#f}. All arrays made by @var{make-array} and
6573@var{make-uniform-array} may be unrolled, some arrays made by
6574@var{make-shared-array} may not be.
6575
6576If the optional argument @var{strict} is provided, a shared array will
6577be returned only if its elements are stored internally contiguous in
6578memory.
6579@end deffn
6580
6581\funiform-array-read!
89d04205 6582@c snarfed from unif.c:1490
780ee65e
NJ
6583@deffn primitive uniform-array-read! ra [port_or_fd [start [end]]]
6584@deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end]
6585Attempts to read all elements of @var{ura}, in lexicographic order, as
6586binary objects from @var{port-or-fdes}.
6587If an end of file is encountered during
6588uniform-array-read! the objects up to that point only are put into @var{ura}
6589(starting at the beginning) and the remainder of the array is
6590unchanged.
6591
6592The optional arguments @var{start} and @var{end} allow
6593a specified region of a vector (or linearized array) to be read,
6594leaving the remainder of the vector unchanged.
6595
6596@code{uniform-array-read!} returns the number of objects read.
6597@var{port-or-fdes} may be omitted, in which case it defaults to the value
6598returned by @code{(current-input-port)}.
6599@end deffn
6600
6601\funiform-array-write
89d04205 6602@c snarfed from unif.c:1653
780ee65e
NJ
6603@deffn primitive uniform-array-write v [port_or_fd [start [end]]]
6604@deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end]
6605Writes all elements of @var{ura} as binary objects to
6606@var{port-or-fdes}.
6607
6608The optional arguments @var{start}
6609and @var{end} allow
6610a specified region of a vector (or linearized array) to be written.
6611
6612The number of objects actually written is returned.
6613@var{port-or-fdes} may be
6614omitted, in which case it defaults to the value returned by
6615@code{(current-output-port)}.
6616@end deffn
6617
6618\fbit-count
89d04205 6619@c snarfed from unif.c:1778
780ee65e 6620@deffn primitive bit-count b bitvector
ae9f3a15 6621Return the number of occurrences of the boolean @var{b} in
780ee65e
NJ
6622@var{bitvector}.
6623@end deffn
6624
6625\fbit-position
89d04205 6626@c snarfed from unif.c:1817
780ee65e 6627@deffn primitive bit-position item v k
ae9f3a15
MG
6628Return the minimum index of an occurrence of @var{bool} in
6629@var{bv} which is at least @var{k}. If no @var{bool} occurs
6630within the specified range @code{#f} is returned.
780ee65e
NJ
6631@end deffn
6632
6633\fbit-set*!
89d04205 6634@c snarfed from unif.c:1885
780ee65e
NJ
6635@deffn primitive bit-set*! v kv obj
6636If uve is a bit-vector @var{bv} and uve must be of the same
6637length. If @var{bool} is @code{#t}, uve is OR'ed into
6638@var{bv}; If @var{bool} is @code{#f}, the inversion of uve is
6639AND'ed into @var{bv}.
6640
6641If uve is a unsigned integer vector all the elements of uve
6642must be between 0 and the @code{length} of @var{bv}. The bits
6643of @var{bv} corresponding to the indexes in uve are set to
6644@var{bool}. The return value is unspecified.
6645@end deffn
6646
6647\fbit-count*
89d04205 6648@c snarfed from unif.c:1939
780ee65e 6649@deffn primitive bit-count* v kv obj
ae9f3a15
MG
6650Return
6651@lisp
780ee65e 6652(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t).
ae9f3a15 6653@end lisp
780ee65e
NJ
6654@var{bv} is not modified.
6655@end deffn
6656
6657\fbit-invert!
89d04205 6658@c snarfed from unif.c:2003
780ee65e
NJ
6659@deffn primitive bit-invert! v
6660Modifies @var{bv} by replacing each element with its negation.
6661@end deffn
6662
6663\farray->list
89d04205 6664@c snarfed from unif.c:2082
780ee65e 6665@deffn primitive array->list v
ae9f3a15
MG
6666Return a list consisting of all the elements, in order, of
6667@var{array}.
780ee65e
NJ
6668@end deffn
6669
6670\flist->uniform-array
72ad43dc 6671@c snarfed from unif.c:2183
780ee65e
NJ
6672@deffn primitive list->uniform-array ndim prot lst
6673@deffnx procedure list->uniform-vector prot lst
ae9f3a15
MG
6674Return a uniform array of the type indicated by prototype
6675@var{prot} with elements the same as those of @var{lst}.
6676Elements must be of the appropriate type, no coercions are
6677done.
780ee65e
NJ
6678@end deffn
6679
6680\farray-prototype
72ad43dc 6681@c snarfed from unif.c:2534
780ee65e 6682@deffn primitive array-prototype ra
ae9f3a15
MG
6683Return an object that would produce an array of the same type
6684as @var{array}, if used as the @var{prototype} for
780ee65e
NJ
6685@code{make-uniform-array}.
6686@end deffn
6687
6688\fvalues
89d04205 6689@c snarfed from values.c:80
780ee65e
NJ
6690@deffn primitive values . args
6691Delivers all of its arguments to its continuation. Except for
6692continuations created by the @code{call-with-values} procedure,
6693all continuations take exactly one value. The effect of
6694passing no value or more than one value to continuations that
6695were not created by @code{call-with-values} is unspecified.
6696@end deffn
6697
780ee65e 6698\fmake-variable
89d04205 6699@c snarfed from variable.c:99
780ee65e
NJ
6700@deffn primitive make-variable init [name_hint]
6701Return a variable object initialized to value @var{init}.
6702If given, uses @var{name-hint} as its internal (debugging)
6703name, otherwise just treat it as an anonymous variable.
6704Remember, of course, that multiple bindings to the same
6705variable may exist, so @var{name-hint} is just that---a hint.
6706@end deffn
6707
6708\fmake-undefined-variable
89d04205 6709@c snarfed from variable.c:119
780ee65e
NJ
6710@deffn primitive make-undefined-variable [name_hint]
6711Return a variable object initialized to an undefined value.
6712If given, uses @var{name-hint} as its internal (debugging)
6713name, otherwise just treat it as an anonymous variable.
6714Remember, of course, that multiple bindings to the same
6715variable may exist, so @var{name-hint} is just that---a hint.
6716@end deffn
6717
6718\fvariable?
89d04205 6719@c snarfed from variable.c:136
780ee65e
NJ
6720@deffn primitive variable? obj
6721Return @code{#t} iff @var{obj} is a variable object, else
6722return @code{#f}
6723@end deffn
6724
6725\fvariable-ref
89d04205 6726@c snarfed from variable.c:148
780ee65e
NJ
6727@deffn primitive variable-ref var
6728Dereference @var{var} and return its value.
6729@var{var} must be a variable object; see @code{make-variable}
6730and @code{make-undefined-variable}.
6731@end deffn
6732
6733\fvariable-set!
89d04205 6734@c snarfed from variable.c:162
780ee65e
NJ
6735@deffn primitive variable-set! var val
6736Set the value of the variable @var{var} to @var{val}.
6737@var{var} must be a variable object, @var{val} can be any
6738value. Return an unspecified value.
6739@end deffn
6740
6741\fbuiltin-variable
89d04205 6742@c snarfed from variable.c:176
780ee65e
NJ
6743@deffn primitive builtin-variable name
6744Return the built-in variable with the name @var{name}.
6745@var{name} must be a symbol (not a string).
6746Then use @code{variable-ref} to access its value.
6747@end deffn
6748
6749\fvariable-bound?
89d04205 6750@c snarfed from variable.c:204
780ee65e
NJ
6751@deffn primitive variable-bound? var
6752Return @code{#t} iff @var{var} is bound to a value.
6753Throws an error if @var{var} is not a variable object.
6754@end deffn
6755
6756\fvector?
6757@c snarfed from vectors.c:142
6758@deffn primitive vector? obj
ae9f3a15
MG
6759Return @code{#t} if @var{obj} is a vector, otherwise return
6760@code{#f}.
780ee65e
NJ
6761@end deffn
6762
6763\flist->vector
6764@c snarfed from vectors.c:161
6765@deffn primitive list->vector
6766scm_vector
6767@end deffn
6768
6769\fvector
89d04205 6770@c snarfed from vectors.c:178
780ee65e
NJ
6771@deffn primitive vector . l
6772@deffnx primitive list->vector l
ae9f3a15
MG
6773Return a newly allocated vector whose elements contain the
6774given arguments. Analogous to @code{list}.
780ee65e 6775@lisp
ae9f3a15 6776(vector 'a 'b 'c) @result{} #(a b c)
780ee65e
NJ
6777@end lisp
6778@end deffn
6779
6780\fmake-vector
89d04205 6781@c snarfed from vectors.c:264
780ee65e 6782@deffn primitive make-vector k [fill]
ae9f3a15
MG
6783Return a newly allocated vector of @var{k} elements. If a
6784second argument is given, then each element is initialized to
6785@var{fill}. Otherwise the initial contents of each element is
6786unspecified.
780ee65e
NJ
6787@end deffn
6788
6789\fvector->list
89d04205 6790@c snarfed from vectors.c:321
780ee65e 6791@deffn primitive vector->list v
ae9f3a15
MG
6792Return a newly allocated list of the objects contained in the
6793elements of @var{vector}.
780ee65e
NJ
6794@lisp
6795(vector->list '#(dah dah didah)) @result{} (dah dah didah)
6796(list->vector '(dididit dah)) @result{} #(dididit dah)
6797@end lisp
6798@end deffn
6799
6800\fvector-fill!
89d04205 6801@c snarfed from vectors.c:338
ae9f3a15
MG
6802@deffn primitive vector-fill! v fill
6803Store @var{fill} in every element of @var{vector}. The value
6804returned by @code{vector-fill!} is unspecified.
780ee65e
NJ
6805@end deffn
6806
6807\fvector-move-left!
89d04205 6808@c snarfed from vectors.c:365
780ee65e
NJ
6809@deffn primitive vector-move-left! vec1 start1 end1 vec2 start2
6810Vector version of @code{substring-move-left!}.
6811@end deffn
6812
6813\fvector-move-right!
89d04205 6814@c snarfed from vectors.c:388
780ee65e
NJ
6815@deffn primitive vector-move-right! vec1 start1 end1 vec2 start2
6816Vector version of @code{substring-move-right!}.
6817@end deffn
6818
6819\fmajor-version
6820@c snarfed from version.c:59
6821@deffn primitive major-version
6822Return a string containing Guile's major version number.
6823E.g., "1".
6824@end deffn
6825
6826\fminor-version
6827@c snarfed from version.c:71
6828@deffn primitive minor-version
6829Return a string containing Guile's minor version number.
6830E.g., "3.5".
6831@end deffn
6832
6833\fversion
6834@c snarfed from version.c:90
6835@deffn primitive version
6836@deffnx primitive major-version
6837@deffnx primitive minor-version
6838Return a string describing Guile's version number, or its major or minor
6839version numbers, respectively.
6840
ae9f3a15 6841@lisp
780ee65e
NJ
6842(version) @result{} "1.3a"
6843(major-version) @result{} "1"
6844(minor-version) @result{} "3a"
ae9f3a15 6845@end lisp
780ee65e
NJ
6846@end deffn
6847
6848\fmake-soft-port
89d04205 6849@c snarfed from vports.c:190
780ee65e 6850@deffn primitive make-soft-port pv modes
ae9f3a15 6851Return a port capable of receiving or delivering characters as
780ee65e 6852specified by the @var{modes} string (@pxref{File Ports,
ae9f3a15
MG
6853open-file}). @var{pv} must be a vector of length 5. Its
6854components are as follows:
780ee65e
NJ
6855@enumerate 0
6856@item
6857procedure accepting one character for output
6858@item
6859procedure accepting a string for output
6860@item
6861thunk for flushing output
6862@item
6863thunk for getting one character
6864@item
6865thunk for closing port (not by garbage collection)
6866@end enumerate
780ee65e 6867For an output-only port only elements 0, 1, 2, and 4 need be
ae9f3a15
MG
6868procedures. For an input-only port only elements 3 and 4 need
6869be procedures. Thunks 2 and 4 can instead be @code{#f} if
6870there is no useful operation for them to perform.
6871If thunk 3 returns @code{#f} or an @code{eof-object}
6872(@pxref{Input, eof-object?, ,r4rs, The Revised^4 Report on
6873Scheme}) it indicates that the port has reached end-of-file.
6874For example:
6875@lisp
780ee65e
NJ
6876(define stdout (current-output-port))
6877(define p (make-soft-port
6878 (vector
6879 (lambda (c) (write c stdout))
6880 (lambda (s) (display s stdout))
6881 (lambda () (display "." stdout))
6882 (lambda () (char-upcase (read-char)))
6883 (lambda () (display "@@" stdout)))
6884 "rw"))
780ee65e 6885(write p p) @result{} #<input-output: soft 8081e20>
ae9f3a15 6886@end lisp
780ee65e
NJ
6887@end deffn
6888
6889\fmake-weak-vector
89d04205 6890@c snarfed from weaks.c:63
ae9f3a15 6891@deffn primitive make-weak-vector size [fill]
780ee65e 6892Return a weak vector with @var{size} elements. If the optional
ae9f3a15
MG
6893argument @var{fill} is given, all entries in the vector will be
6894set to @var{fill}. The default value for @var{fill} is the
6895empty list.
780ee65e
NJ
6896@end deffn
6897
6898\flist->weak-vector
89d04205 6899@c snarfed from weaks.c:80
780ee65e
NJ
6900@deffn primitive list->weak-vector
6901scm_weak_vector
6902@end deffn
6903
6904\fweak-vector
89d04205 6905@c snarfed from weaks.c:88
780ee65e
NJ
6906@deffn primitive weak-vector . l
6907@deffnx primitive list->weak-vector l
ae9f3a15
MG
6908Construct a weak vector from a list: @code{weak-vector} uses
6909the list of its arguments while @code{list->weak-vector} uses
6910its only argument @var{l} (a list) to construct a weak vector
6911the same way @code{list->vector} would.
780ee65e
NJ
6912@end deffn
6913
6914\fweak-vector?
89d04205 6915@c snarfed from weaks.c:116
ae9f3a15 6916@deffn primitive weak-vector? obj
780ee65e
NJ
6917Return @code{#t} if @var{obj} is a weak vector. Note that all
6918weak hashes are also weak vectors.
6919@end deffn
6920
6921\fmake-weak-key-hash-table
89d04205 6922@c snarfed from weaks.c:138
ae9f3a15 6923@deffn primitive make-weak-key-hash-table size
780ee65e
NJ
6924@deffnx primitive make-weak-value-hash-table size
6925@deffnx primitive make-doubly-weak-hash-table size
ae9f3a15
MG
6926Return a weak hash table with @var{size} buckets. As with any
6927hash table, choosing a good size for the table requires some
6928caution.
6929You can modify weak hash tables in exactly the same way you
6930would modify regular hash tables. (@pxref{Hash Tables})
780ee65e
NJ
6931@end deffn
6932
6933\fmake-weak-value-hash-table
89d04205
NJ
6934@c snarfed from weaks.c:155
6935@deffn primitive make-weak-value-hash-table size
780ee65e
NJ
6936Return a hash table with weak values with @var{size} buckets.
6937(@pxref{Hash Tables})
6938@end deffn
6939
6940\fmake-doubly-weak-hash-table
89d04205
NJ
6941@c snarfed from weaks.c:173
6942@deffn primitive make-doubly-weak-hash-table size
780ee65e
NJ
6943Return a hash table with weak keys and values with @var{size}
6944buckets. (@pxref{Hash Tables})
6945@end deffn
6946
6947\fweak-key-hash-table?
89d04205 6948@c snarfed from weaks.c:192
ae9f3a15 6949@deffn primitive weak-key-hash-table? obj
780ee65e
NJ
6950@deffnx primitive weak-value-hash-table? obj
6951@deffnx primitive doubly-weak-hash-table? obj
6952Return @code{#t} if @var{obj} is the specified weak hash
6953table. Note that a doubly weak hash table is neither a weak key
6954nor a weak value hash table.
6955@end deffn
6956
6957\fweak-value-hash-table?
89d04205
NJ
6958@c snarfed from weaks.c:202
6959@deffn primitive weak-value-hash-table? obj
6960Return @code{#t} if @var{obj} is a weak value hash table.
780ee65e
NJ
6961@end deffn
6962
6963\fdoubly-weak-hash-table?
89d04205
NJ
6964@c snarfed from weaks.c:212
6965@deffn primitive doubly-weak-hash-table? obj
6966Return @code{#t} if @var{obj} is a doubly weak hash table.
780ee65e 6967@end deffn