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