Commit | Line | Data |
---|---|---|
f7b47737 | 1 | Guile NEWS --- history of user-visible changes. -*- text -*- |
d21ffe26 | 2 | Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
5c54da76 JB |
3 | See the end for copying conditions. |
4 | ||
e1b6c710 | 5 | Please send Guile bug reports to bug-guile@gnu.org. |
5c54da76 | 6 | \f |
cc36e791 JB |
7 | Changes since Guile 1.3.4: |
8 | ||
52cfc69b GH |
9 | configure has new options to remove support for certain features: |
10 | ||
11 | --disable-posix omit posix interfaces | |
12 | --disable-net omit networking interfaces | |
13 | --disable-regex omit regular expression interfaces | |
14 | ||
15 | These are likely to become separate modules some day. | |
16 | ||
cc36e791 | 17 | \f |
43fa9a05 JB |
18 | Changes since Guile 1.3.2: |
19 | ||
0fdcbcaa MD |
20 | * Changes to the stand-alone interpreter |
21 | ||
22 | ** Debugger | |
23 | ||
24 | An initial version of the Guile debugger written by Chris Hanson has | |
25 | been added. The debugger is still under development but is included | |
26 | in the distribution anyway since it is already quite useful. | |
27 | ||
28 | Type | |
29 | ||
30 | (debug) | |
31 | ||
32 | after an error to enter the debugger. Type `help' inside the debugger | |
33 | for a description of available commands. | |
34 | ||
35 | If you prefer to have stack frames numbered and printed in | |
36 | anti-chronological order and prefer up in the stack to be down on the | |
37 | screen as is the case in gdb, you can put | |
38 | ||
39 | (debug-enable 'backwards) | |
40 | ||
41 | in your .guile startup file. (However, this means that Guile can't | |
42 | use indentation to indicate stack level.) | |
43 | ||
44 | The debugger is autoloaded into Guile at the first use. | |
45 | ||
46 | ** Further enhancements to backtraces | |
47 | ||
48 | There is a new debug option `width' which controls the maximum width | |
49 | on the screen of printed stack frames. Fancy printing parameters | |
50 | ("level" and "length" as in Common LISP) are adaptively adjusted for | |
51 | each stack frame to give maximum information while still fitting | |
52 | within the bounds. If the stack frame can't be made to fit by | |
53 | adjusting parameters, it is simply cut off at the end. This is marked | |
54 | with a `$'. | |
55 | ||
56 | ** Some modules are now only loaded when the repl is started | |
57 | ||
58 | The modules (ice-9 debug), (ice-9 session), (ice-9 threads) and (ice-9 | |
59 | regex) are now loaded into (guile-user) only if the repl has been | |
60 | started. The effect is that the startup time for scripts has been | |
61 | reduced to 30% of what it was previously. | |
62 | ||
63 | Correctly written scripts load the modules they require at the top of | |
64 | the file and should not be affected by this change. | |
65 | ||
ece41168 MD |
66 | ** Hooks are now represented as smobs |
67 | ||
6822fe53 MD |
68 | * Changes to Scheme functions and syntax |
69 | ||
0ce204b0 MV |
70 | ** Readline support has changed again. |
71 | ||
72 | The old (readline-activator) module is gone. Use (ice-9 readline) | |
73 | instead, which now contains all readline functionality. So the code | |
74 | to activate readline is now | |
75 | ||
76 | (use-modules (ice-9 readline)) | |
77 | (activate-readline) | |
78 | ||
79 | This should work at any time, including from the guile prompt. | |
80 | ||
5d195868 JB |
81 | To avoid confusion about the terms of Guile's license, please only |
82 | enable readline for your personal use; please don't make it the | |
83 | default for others. Here is why we make this rather odd-sounding | |
84 | request: | |
85 | ||
86 | Guile is normally licensed under a weakened form of the GNU General | |
87 | Public License, which allows you to link code with Guile without | |
88 | placing that code under the GPL. This exception is important to some | |
89 | people. | |
90 | ||
91 | However, since readline is distributed under the GNU General Public | |
92 | License, when you link Guile with readline, either statically or | |
93 | dynamically, you effectively change Guile's license to the strict GPL. | |
94 | Whenever you link any strictly GPL'd code into Guile, uses of Guile | |
95 | which are normally permitted become forbidden. This is a rather | |
96 | non-obvious consequence of the licensing terms. | |
97 | ||
98 | So, to make sure things remain clear, please let people choose for | |
99 | themselves whether to link GPL'd libraries like readline with Guile. | |
100 | ||
25b0654e JB |
101 | ** regexp-substitute/global has changed slightly, but incompatibly. |
102 | ||
103 | If you include a function in the item list, the string of the match | |
104 | object it receives is the same string passed to | |
105 | regexp-substitute/global, not some suffix of that string. | |
106 | Correspondingly, the match's positions are relative to the entire | |
107 | string, not the suffix. | |
108 | ||
109 | If the regexp can match the empty string, the way matches are chosen | |
110 | from the string has changed. regexp-substitute/global recognizes the | |
111 | same set of matches that list-matches does; see below. | |
112 | ||
113 | ** New function: list-matches REGEXP STRING [FLAGS] | |
114 | ||
115 | Return a list of match objects, one for every non-overlapping, maximal | |
116 | match of REGEXP in STRING. The matches appear in left-to-right order. | |
117 | list-matches only reports matches of the empty string if there are no | |
118 | other matches which begin on, end at, or include the empty match's | |
119 | position. | |
120 | ||
121 | If present, FLAGS is passed as the FLAGS argument to regexp-exec. | |
122 | ||
123 | ** New function: fold-matches REGEXP STRING INIT PROC [FLAGS] | |
124 | ||
125 | For each match of REGEXP in STRING, apply PROC to the match object, | |
126 | and the last value PROC returned, or INIT for the first call. Return | |
127 | the last value returned by PROC. We apply PROC to the matches as they | |
128 | appear from left to right. | |
129 | ||
130 | This function recognizes matches according to the same criteria as | |
131 | list-matches. | |
132 | ||
133 | Thus, you could define list-matches like this: | |
134 | ||
135 | (define (list-matches regexp string . flags) | |
136 | (reverse! (apply fold-matches regexp string '() cons flags))) | |
137 | ||
138 | If present, FLAGS is passed as the FLAGS argument to regexp-exec. | |
139 | ||
bc848f7f MD |
140 | ** Hooks |
141 | ||
142 | *** New function: hook? OBJ | |
143 | ||
144 | Return #t if OBJ is a hook, otherwise #f. | |
145 | ||
ece41168 MD |
146 | *** New function: make-hook-with-name NAME [ARITY] |
147 | ||
148 | Return a hook with name NAME and arity ARITY. The default value for | |
149 | ARITY is 0. The only effect of NAME is that it will appear when the | |
150 | hook object is printed to ease debugging. | |
151 | ||
bc848f7f MD |
152 | *** New function: hook-empty? HOOK |
153 | ||
154 | Return #t if HOOK doesn't contain any procedures, otherwise #f. | |
155 | ||
156 | *** New function: hook->list HOOK | |
157 | ||
158 | Return a list of the procedures that are called when run-hook is | |
159 | applied to HOOK. | |
160 | ||
b074884f JB |
161 | ** `map' signals an error if its argument lists are not all the same length. |
162 | ||
163 | This is the behavior required by R5RS, so this change is really a bug | |
164 | fix. But it seems to affect a lot of people's code, so we're | |
165 | mentioning it here anyway. | |
166 | ||
6822fe53 MD |
167 | ** Print-state handling has been made more transparent |
168 | ||
169 | Under certain circumstances, ports are represented as a port with an | |
170 | associated print state. Earlier, this pair was represented as a pair | |
171 | (see "Some magic has been added to the printer" below). It is now | |
172 | indistinguishable (almost; see `get-print-state') from a port on the | |
173 | user level. | |
174 | ||
175 | *** New function: port-with-print-state OUTPUT-PORT PRINT-STATE | |
176 | ||
177 | Return a new port with the associated print state PRINT-STATE. | |
178 | ||
179 | *** New function: get-print-state OUTPUT-PORT | |
180 | ||
181 | Return the print state associated with this port if it exists, | |
182 | otherwise return #f. | |
183 | ||
340a8770 | 184 | *** New function: directory-stream? OBJECT |
77242ff9 | 185 | |
340a8770 | 186 | Returns true iff OBJECT is a directory stream --- the sort of object |
77242ff9 GH |
187 | returned by `opendir'. |
188 | ||
0fdcbcaa MD |
189 | ** New function: using-readline? |
190 | ||
191 | Return #t if readline is in use in the current repl. | |
192 | ||
26405bc1 MD |
193 | ** structs will be removed in 1.4 |
194 | ||
195 | Structs will be replaced in Guile 1.4. We will merge GOOPS into Guile | |
196 | and use GOOPS objects as the fundamental record type. | |
197 | ||
49199eaa MD |
198 | * Changes to the scm_ interface |
199 | ||
26405bc1 MD |
200 | ** structs will be removed in 1.4 |
201 | ||
202 | The entire current struct interface (struct.c, struct.h) will be | |
203 | replaced in Guile 1.4. We will merge GOOPS into libguile and use | |
204 | GOOPS objects as the fundamental record type. | |
205 | ||
49199eaa MD |
206 | ** The internal representation of subr's has changed |
207 | ||
208 | Instead of giving a hint to the subr name, the CAR field of the subr | |
209 | now contains an index to a subr entry in scm_subr_table. | |
210 | ||
211 | *** New variable: scm_subr_table | |
212 | ||
213 | An array of subr entries. A subr entry contains the name, properties | |
214 | and documentation associated with the subr. The properties and | |
215 | documentation slots are not yet used. | |
216 | ||
217 | ** A new scheme for "forwarding" calls to a builtin to a generic function | |
218 | ||
219 | It is now possible to extend the functionality of some Guile | |
220 | primitives by letting them defer a call to a GOOPS generic function on | |
240ed66f | 221 | argument mismatch. This means that there is no loss of efficiency in |
daf516d6 | 222 | normal evaluation. |
49199eaa MD |
223 | |
224 | Example: | |
225 | ||
daf516d6 | 226 | (use-modules (oop goops)) ; Must be GOOPS version 0.2. |
49199eaa MD |
227 | (define-method + ((x <string>) (y <string>)) |
228 | (string-append x y)) | |
229 | ||
86a4d62e MD |
230 | + will still be as efficient as usual in numerical calculations, but |
231 | can also be used for concatenating strings. | |
49199eaa | 232 | |
86a4d62e | 233 | Who will be the first one to extend Guile's numerical tower to |
daf516d6 MD |
234 | rationals? :) [OK, there a few other things to fix before this can |
235 | be made in a clean way.] | |
49199eaa MD |
236 | |
237 | *** New snarf macros for defining primitives: SCM_GPROC, SCM_GPROC1 | |
238 | ||
239 | New macro: SCM_GPROC (CNAME, SNAME, REQ, OPT, VAR, CFUNC, GENERIC) | |
240 | ||
241 | New macro: SCM_GPROC1 (CNAME, SNAME, TYPE, CFUNC, GENERIC) | |
242 | ||
d02cafe7 | 243 | These do the same job as SCM_PROC and SCM_PROC1, but they also define |
49199eaa MD |
244 | a variable GENERIC which can be used by the dispatch macros below. |
245 | ||
246 | [This is experimental code which may change soon.] | |
247 | ||
248 | *** New macros for forwarding control to a generic on arg type error | |
249 | ||
250 | New macro: SCM_WTA_DISPATCH_1 (GENERIC, ARG1, POS, SUBR) | |
251 | ||
252 | New macro: SCM_WTA_DISPATCH_2 (GENERIC, ARG1, ARG2, POS, SUBR) | |
253 | ||
254 | These correspond to the scm_wta function call, and have the same | |
255 | behaviour until the user has called the GOOPS primitive | |
256 | `enable-primitive-generic!'. After that, these macros will apply the | |
257 | generic function GENERIC to the argument(s) instead of calling | |
258 | scm_wta. | |
259 | ||
260 | [This is experimental code which may change soon.] | |
261 | ||
262 | *** New macros for argument testing with generic dispatch | |
263 | ||
264 | New macro: SCM_GASSERT1 (COND, GENERIC, ARG1, POS, SUBR) | |
265 | ||
266 | New macro: SCM_GASSERT2 (COND, GENERIC, ARG1, ARG2, POS, SUBR) | |
267 | ||
268 | These correspond to the SCM_ASSERT macro, but will defer control to | |
269 | GENERIC on error after `enable-primitive-generic!' has been called. | |
270 | ||
271 | [This is experimental code which may change soon.] | |
272 | ||
273 | ** New function: SCM scm_eval_body (SCM body, SCM env) | |
274 | ||
275 | Evaluates the body of a special form. | |
276 | ||
277 | ** The internal representation of struct's has changed | |
278 | ||
279 | Previously, four slots were allocated for the procedure(s) of entities | |
280 | and operators. The motivation for this representation had to do with | |
281 | the structure of the evaluator, the wish to support tail-recursive | |
282 | generic functions, and efficiency. Since the generic function | |
283 | dispatch mechanism has changed, there is no longer a need for such an | |
284 | expensive representation, and the representation has been simplified. | |
285 | ||
286 | This should not make any difference for most users. | |
287 | ||
288 | ** GOOPS support has been cleaned up. | |
289 | ||
290 | Some code has been moved from eval.c to objects.c and code in both of | |
291 | these compilation units has been cleaned up and better structured. | |
292 | ||
293 | *** New functions for applying generic functions | |
294 | ||
295 | New function: SCM scm_apply_generic (GENERIC, ARGS) | |
296 | New function: SCM scm_call_generic_0 (GENERIC) | |
297 | New function: SCM scm_call_generic_1 (GENERIC, ARG1) | |
298 | New function: SCM scm_call_generic_2 (GENERIC, ARG1, ARG2) | |
299 | New function: SCM scm_call_generic_3 (GENERIC, ARG1, ARG2, ARG3) | |
300 | ||
ece41168 MD |
301 | ** Deprecated function: scm_make_named_hook |
302 | ||
303 | It is now replaced by: | |
304 | ||
305 | ** New function: SCM scm_create_hook (const char *name, int arity) | |
306 | ||
307 | Creates a hook in the same way as make-hook above but also | |
308 | binds a variable named NAME to it. | |
309 | ||
310 | This is the typical way of creating a hook from C code. | |
311 | ||
312 | Currently, the variable is created in the "current" module. | |
313 | This might change when we get the new module system. | |
314 | ||
315 | [The behaviour is identical to scm_make_named_hook.] | |
316 | ||
317 | ||
43fa9a05 | 318 | \f |
f3227c7a JB |
319 | Changes since Guile 1.3: |
320 | ||
6ca345f3 JB |
321 | * Changes to mailing lists |
322 | ||
323 | ** Some of the Guile mailing lists have moved to sourceware.cygnus.com. | |
324 | ||
325 | See the README file to find current addresses for all the Guile | |
326 | mailing lists. | |
327 | ||
d77fb593 JB |
328 | * Changes to the distribution |
329 | ||
1d335863 JB |
330 | ** Readline support is no longer included with Guile by default. |
331 | ||
332 | Based on the different license terms of Guile and Readline, we | |
333 | concluded that Guile should not *by default* cause the linking of | |
334 | Readline into an application program. Readline support is now offered | |
335 | as a separate module, which is linked into an application only when | |
336 | you explicitly specify it. | |
337 | ||
338 | Although Guile is GNU software, its distribution terms add a special | |
339 | exception to the usual GNU General Public License (GPL). Guile's | |
340 | license includes a clause that allows you to link Guile with non-free | |
341 | programs. We add this exception so as not to put Guile at a | |
342 | disadvantage vis-a-vis other extensibility packages that support other | |
343 | languages. | |
344 | ||
345 | In contrast, the GNU Readline library is distributed under the GNU | |
346 | General Public License pure and simple. This means that you may not | |
347 | link Readline, even dynamically, into an application unless it is | |
348 | distributed under a free software license that is compatible the GPL. | |
349 | ||
350 | Because of this difference in distribution terms, an application that | |
351 | can use Guile may not be able to use Readline. Now users will be | |
352 | explicitly offered two independent decisions about the use of these | |
353 | two packages. | |
d77fb593 | 354 | |
0e8a8468 MV |
355 | You can activate the readline support by issuing |
356 | ||
357 | (use-modules (readline-activator)) | |
358 | (activate-readline) | |
359 | ||
360 | from your ".guile" file, for example. | |
361 | ||
e4eae9b1 MD |
362 | * Changes to the stand-alone interpreter |
363 | ||
67ad463a MD |
364 | ** All builtins now print as primitives. |
365 | Previously builtin procedures not belonging to the fundamental subr | |
366 | types printed as #<compiled closure #<primitive-procedure gsubr-apply>>. | |
367 | Now, they print as #<primitive-procedure NAME>. | |
368 | ||
369 | ** Backtraces slightly more intelligible. | |
370 | gsubr-apply and macro transformer application frames no longer appear | |
371 | in backtraces. | |
372 | ||
69c6acbb JB |
373 | * Changes to Scheme functions and syntax |
374 | ||
2a52b429 MD |
375 | ** Guile now correctly handles internal defines by rewriting them into |
376 | their equivalent letrec. Previously, internal defines would | |
377 | incrementally add to the innermost environment, without checking | |
378 | whether the restrictions specified in RnRS were met. This lead to the | |
379 | correct behaviour when these restriction actually were met, but didn't | |
380 | catch all illegal uses. Such an illegal use could lead to crashes of | |
381 | the Guile interpreter or or other unwanted results. An example of | |
382 | incorrect internal defines that made Guile behave erratically: | |
383 | ||
384 | (let () | |
385 | (define a 1) | |
386 | (define (b) a) | |
387 | (define c (1+ (b))) | |
388 | (define d 3) | |
389 | ||
390 | (b)) | |
391 | ||
392 | => 2 | |
393 | ||
394 | The problem with this example is that the definition of `c' uses the | |
395 | value of `b' directly. This confuses the meoization machine of Guile | |
396 | so that the second call of `b' (this time in a larger environment that | |
397 | also contains bindings for `c' and `d') refers to the binding of `c' | |
398 | instead of `a'. You could also make Guile crash with a variation on | |
399 | this theme: | |
400 | ||
401 | (define (foo flag) | |
402 | (define a 1) | |
403 | (define (b flag) (if flag a 1)) | |
404 | (define c (1+ (b flag))) | |
405 | (define d 3) | |
406 | ||
407 | (b #t)) | |
408 | ||
409 | (foo #f) | |
410 | (foo #t) | |
411 | ||
412 | From now on, Guile will issue an `Unbound variable: b' error message | |
413 | for both examples. | |
414 | ||
36d3d540 MD |
415 | ** Hooks |
416 | ||
417 | A hook contains a list of functions which should be called on | |
418 | particular occasions in an existing program. Hooks are used for | |
419 | customization. | |
420 | ||
421 | A window manager might have a hook before-window-map-hook. The window | |
422 | manager uses the function run-hooks to call all functions stored in | |
423 | before-window-map-hook each time a window is mapped. The user can | |
424 | store functions in the hook using add-hook!. | |
425 | ||
426 | In Guile, hooks are first class objects. | |
427 | ||
428 | *** New function: make-hook [N_ARGS] | |
429 | ||
430 | Return a hook for hook functions which can take N_ARGS arguments. | |
431 | The default value for N_ARGS is 0. | |
432 | ||
ad91d6c3 MD |
433 | (See also scm_make_named_hook below.) |
434 | ||
36d3d540 MD |
435 | *** New function: add-hook! HOOK PROC [APPEND_P] |
436 | ||
437 | Put PROC at the beginning of the list of functions stored in HOOK. | |
438 | If APPEND_P is supplied, and non-false, put PROC at the end instead. | |
439 | ||
440 | PROC must be able to take the number of arguments specified when the | |
441 | hook was created. | |
442 | ||
443 | If PROC already exists in HOOK, then remove it first. | |
444 | ||
445 | *** New function: remove-hook! HOOK PROC | |
446 | ||
447 | Remove PROC from the list of functions in HOOK. | |
448 | ||
449 | *** New function: reset-hook! HOOK | |
450 | ||
451 | Clear the list of hook functions stored in HOOK. | |
452 | ||
453 | *** New function: run-hook HOOK ARG1 ... | |
454 | ||
455 | Run all hook functions stored in HOOK with arguments ARG1 ... . | |
456 | The number of arguments supplied must correspond to the number given | |
457 | when the hook was created. | |
458 | ||
56a19408 MV |
459 | ** The function `dynamic-link' now takes optional keyword arguments. |
460 | The only keyword argument that is currently defined is `:global | |
461 | BOOL'. With it, you can control whether the shared library will be | |
462 | linked in global mode or not. In global mode, the symbols from the | |
463 | linked library can be used to resolve references from other | |
464 | dynamically linked libraries. In non-global mode, the linked | |
465 | library is essentially invisible and can only be accessed via | |
466 | `dynamic-func', etc. The default is now to link in global mode. | |
467 | Previously, the default has been non-global mode. | |
468 | ||
469 | The `#:global' keyword is only effective on platforms that support | |
470 | the dlopen family of functions. | |
471 | ||
ad226f25 | 472 | ** New function `provided?' |
b7e13f65 JB |
473 | |
474 | - Function: provided? FEATURE | |
475 | Return true iff FEATURE is supported by this installation of | |
476 | Guile. FEATURE must be a symbol naming a feature; the global | |
477 | variable `*features*' is a list of available features. | |
478 | ||
ad226f25 JB |
479 | ** Changes to the module (ice-9 expect): |
480 | ||
481 | *** The expect-strings macro now matches `$' in a regular expression | |
482 | only at a line-break or end-of-file by default. Previously it would | |
ab711359 JB |
483 | match the end of the string accumulated so far. The old behaviour |
484 | can be obtained by setting the variable `expect-strings-exec-flags' | |
485 | to 0. | |
ad226f25 JB |
486 | |
487 | *** The expect-strings macro now uses a variable `expect-strings-exec-flags' | |
488 | for the regexp-exec flags. If `regexp/noteol' is included, then `$' | |
489 | in a regular expression will still match before a line-break or | |
490 | end-of-file. The default is `regexp/noteol'. | |
491 | ||
492 | *** The expect-strings macro now uses a variable | |
493 | `expect-strings-compile-flags' for the flags to be supplied to | |
494 | `make-regexp'. The default is `regexp/newline', which was previously | |
495 | hard-coded. | |
496 | ||
497 | *** The expect macro now supplies two arguments to a match procedure: | |
ab711359 JB |
498 | the current accumulated string and a flag to indicate whether |
499 | end-of-file has been reached. Previously only the string was supplied. | |
500 | If end-of-file is reached, the match procedure will be called an | |
501 | additional time with the same accumulated string as the previous call | |
502 | but with the flag set. | |
ad226f25 | 503 | |
b7e13f65 JB |
504 | ** New module (ice-9 format), implementing the Common Lisp `format' function. |
505 | ||
506 | This code, and the documentation for it that appears here, was | |
507 | borrowed from SLIB, with minor adaptations for Guile. | |
508 | ||
509 | - Function: format DESTINATION FORMAT-STRING . ARGUMENTS | |
510 | An almost complete implementation of Common LISP format description | |
511 | according to the CL reference book `Common LISP' from Guy L. | |
512 | Steele, Digital Press. Backward compatible to most of the | |
513 | available Scheme format implementations. | |
514 | ||
515 | Returns `#t', `#f' or a string; has side effect of printing | |
516 | according to FORMAT-STRING. If DESTINATION is `#t', the output is | |
517 | to the current output port and `#t' is returned. If DESTINATION | |
518 | is `#f', a formatted string is returned as the result of the call. | |
519 | NEW: If DESTINATION is a string, DESTINATION is regarded as the | |
520 | format string; FORMAT-STRING is then the first argument and the | |
521 | output is returned as a string. If DESTINATION is a number, the | |
522 | output is to the current error port if available by the | |
523 | implementation. Otherwise DESTINATION must be an output port and | |
524 | `#t' is returned. | |
525 | ||
526 | FORMAT-STRING must be a string. In case of a formatting error | |
527 | format returns `#f' and prints a message on the current output or | |
528 | error port. Characters are output as if the string were output by | |
529 | the `display' function with the exception of those prefixed by a | |
530 | tilde (~). For a detailed description of the FORMAT-STRING syntax | |
531 | please consult a Common LISP format reference manual. For a test | |
532 | suite to verify this format implementation load `formatst.scm'. | |
533 | Please send bug reports to `lutzeb@cs.tu-berlin.de'. | |
534 | ||
535 | Note: `format' is not reentrant, i.e. only one `format'-call may | |
536 | be executed at a time. | |
537 | ||
538 | ||
539 | *** Format Specification (Format version 3.0) | |
540 | ||
541 | Please consult a Common LISP format reference manual for a detailed | |
542 | description of the format string syntax. For a demonstration of the | |
543 | implemented directives see `formatst.scm'. | |
544 | ||
545 | This implementation supports directive parameters and modifiers (`:' | |
546 | and `@' characters). Multiple parameters must be separated by a comma | |
547 | (`,'). Parameters can be numerical parameters (positive or negative), | |
548 | character parameters (prefixed by a quote character (`''), variable | |
549 | parameters (`v'), number of rest arguments parameter (`#'), empty and | |
550 | default parameters. Directive characters are case independent. The | |
551 | general form of a directive is: | |
552 | ||
553 | DIRECTIVE ::= ~{DIRECTIVE-PARAMETER,}[:][@]DIRECTIVE-CHARACTER | |
554 | ||
555 | DIRECTIVE-PARAMETER ::= [ [-|+]{0-9}+ | 'CHARACTER | v | # ] | |
556 | ||
557 | *** Implemented CL Format Control Directives | |
558 | ||
559 | Documentation syntax: Uppercase characters represent the | |
560 | corresponding control directive characters. Lowercase characters | |
561 | represent control directive parameter descriptions. | |
562 | ||
563 | `~A' | |
564 | Any (print as `display' does). | |
565 | `~@A' | |
566 | left pad. | |
567 | ||
568 | `~MINCOL,COLINC,MINPAD,PADCHARA' | |
569 | full padding. | |
570 | ||
571 | `~S' | |
572 | S-expression (print as `write' does). | |
573 | `~@S' | |
574 | left pad. | |
575 | ||
576 | `~MINCOL,COLINC,MINPAD,PADCHARS' | |
577 | full padding. | |
578 | ||
579 | `~D' | |
580 | Decimal. | |
581 | `~@D' | |
582 | print number sign always. | |
583 | ||
584 | `~:D' | |
585 | print comma separated. | |
586 | ||
587 | `~MINCOL,PADCHAR,COMMACHARD' | |
588 | padding. | |
589 | ||
590 | `~X' | |
591 | Hexadecimal. | |
592 | `~@X' | |
593 | print number sign always. | |
594 | ||
595 | `~:X' | |
596 | print comma separated. | |
597 | ||
598 | `~MINCOL,PADCHAR,COMMACHARX' | |
599 | padding. | |
600 | ||
601 | `~O' | |
602 | Octal. | |
603 | `~@O' | |
604 | print number sign always. | |
605 | ||
606 | `~:O' | |
607 | print comma separated. | |
608 | ||
609 | `~MINCOL,PADCHAR,COMMACHARO' | |
610 | padding. | |
611 | ||
612 | `~B' | |
613 | Binary. | |
614 | `~@B' | |
615 | print number sign always. | |
616 | ||
617 | `~:B' | |
618 | print comma separated. | |
619 | ||
620 | `~MINCOL,PADCHAR,COMMACHARB' | |
621 | padding. | |
622 | ||
623 | `~NR' | |
624 | Radix N. | |
625 | `~N,MINCOL,PADCHAR,COMMACHARR' | |
626 | padding. | |
627 | ||
628 | `~@R' | |
629 | print a number as a Roman numeral. | |
630 | ||
631 | `~:@R' | |
632 | print a number as an "old fashioned" Roman numeral. | |
633 | ||
634 | `~:R' | |
635 | print a number as an ordinal English number. | |
636 | ||
637 | `~:@R' | |
638 | print a number as a cardinal English number. | |
639 | ||
640 | `~P' | |
641 | Plural. | |
642 | `~@P' | |
643 | prints `y' and `ies'. | |
644 | ||
645 | `~:P' | |
646 | as `~P but jumps 1 argument backward.' | |
647 | ||
648 | `~:@P' | |
649 | as `~@P but jumps 1 argument backward.' | |
650 | ||
651 | `~C' | |
652 | Character. | |
653 | `~@C' | |
654 | prints a character as the reader can understand it (i.e. `#\' | |
655 | prefixing). | |
656 | ||
657 | `~:C' | |
658 | prints a character as emacs does (eg. `^C' for ASCII 03). | |
659 | ||
660 | `~F' | |
661 | Fixed-format floating-point (prints a flonum like MMM.NNN). | |
662 | `~WIDTH,DIGITS,SCALE,OVERFLOWCHAR,PADCHARF' | |
663 | `~@F' | |
664 | If the number is positive a plus sign is printed. | |
665 | ||
666 | `~E' | |
667 | Exponential floating-point (prints a flonum like MMM.NNN`E'EE). | |
668 | `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARE' | |
669 | `~@E' | |
670 | If the number is positive a plus sign is printed. | |
671 | ||
672 | `~G' | |
673 | General floating-point (prints a flonum either fixed or | |
674 | exponential). | |
675 | `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARG' | |
676 | `~@G' | |
677 | If the number is positive a plus sign is printed. | |
678 | ||
679 | `~$' | |
680 | Dollars floating-point (prints a flonum in fixed with signs | |
681 | separated). | |
682 | `~DIGITS,SCALE,WIDTH,PADCHAR$' | |
683 | `~@$' | |
684 | If the number is positive a plus sign is printed. | |
685 | ||
686 | `~:@$' | |
687 | A sign is always printed and appears before the padding. | |
688 | ||
689 | `~:$' | |
690 | The sign appears before the padding. | |
691 | ||
692 | `~%' | |
693 | Newline. | |
694 | `~N%' | |
695 | print N newlines. | |
696 | ||
697 | `~&' | |
698 | print newline if not at the beginning of the output line. | |
699 | `~N&' | |
700 | prints `~&' and then N-1 newlines. | |
701 | ||
702 | `~|' | |
703 | Page Separator. | |
704 | `~N|' | |
705 | print N page separators. | |
706 | ||
707 | `~~' | |
708 | Tilde. | |
709 | `~N~' | |
710 | print N tildes. | |
711 | ||
712 | `~'<newline> | |
713 | Continuation Line. | |
714 | `~:'<newline> | |
715 | newline is ignored, white space left. | |
716 | ||
717 | `~@'<newline> | |
718 | newline is left, white space ignored. | |
719 | ||
720 | `~T' | |
721 | Tabulation. | |
722 | `~@T' | |
723 | relative tabulation. | |
724 | ||
725 | `~COLNUM,COLINCT' | |
726 | full tabulation. | |
727 | ||
728 | `~?' | |
729 | Indirection (expects indirect arguments as a list). | |
730 | `~@?' | |
731 | extracts indirect arguments from format arguments. | |
732 | ||
733 | `~(STR~)' | |
734 | Case conversion (converts by `string-downcase'). | |
735 | `~:(STR~)' | |
736 | converts by `string-capitalize'. | |
737 | ||
738 | `~@(STR~)' | |
739 | converts by `string-capitalize-first'. | |
740 | ||
741 | `~:@(STR~)' | |
742 | converts by `string-upcase'. | |
743 | ||
744 | `~*' | |
745 | Argument Jumping (jumps 1 argument forward). | |
746 | `~N*' | |
747 | jumps N arguments forward. | |
748 | ||
749 | `~:*' | |
750 | jumps 1 argument backward. | |
751 | ||
752 | `~N:*' | |
753 | jumps N arguments backward. | |
754 | ||
755 | `~@*' | |
756 | jumps to the 0th argument. | |
757 | ||
758 | `~N@*' | |
759 | jumps to the Nth argument (beginning from 0) | |
760 | ||
761 | `~[STR0~;STR1~;...~;STRN~]' | |
762 | Conditional Expression (numerical clause conditional). | |
763 | `~N[' | |
764 | take argument from N. | |
765 | ||
766 | `~@[' | |
767 | true test conditional. | |
768 | ||
769 | `~:[' | |
770 | if-else-then conditional. | |
771 | ||
772 | `~;' | |
773 | clause separator. | |
774 | ||
775 | `~:;' | |
776 | default clause follows. | |
777 | ||
778 | `~{STR~}' | |
779 | Iteration (args come from the next argument (a list)). | |
780 | `~N{' | |
781 | at most N iterations. | |
782 | ||
783 | `~:{' | |
784 | args from next arg (a list of lists). | |
785 | ||
786 | `~@{' | |
787 | args from the rest of arguments. | |
788 | ||
789 | `~:@{' | |
790 | args from the rest args (lists). | |
791 | ||
792 | `~^' | |
793 | Up and out. | |
794 | `~N^' | |
795 | aborts if N = 0 | |
796 | ||
797 | `~N,M^' | |
798 | aborts if N = M | |
799 | ||
800 | `~N,M,K^' | |
801 | aborts if N <= M <= K | |
802 | ||
803 | *** Not Implemented CL Format Control Directives | |
804 | ||
805 | `~:A' | |
806 | print `#f' as an empty list (see below). | |
807 | ||
808 | `~:S' | |
809 | print `#f' as an empty list (see below). | |
810 | ||
811 | `~<~>' | |
812 | Justification. | |
813 | ||
814 | `~:^' | |
815 | (sorry I don't understand its semantics completely) | |
816 | ||
817 | *** Extended, Replaced and Additional Control Directives | |
818 | ||
819 | `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHD' | |
820 | `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHX' | |
821 | `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHO' | |
822 | `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHB' | |
823 | `~N,MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHR' | |
824 | COMMAWIDTH is the number of characters between two comma | |
825 | characters. | |
826 | ||
827 | `~I' | |
828 | print a R4RS complex number as `~F~@Fi' with passed parameters for | |
829 | `~F'. | |
830 | ||
831 | `~Y' | |
832 | Pretty print formatting of an argument for scheme code lists. | |
833 | ||
834 | `~K' | |
835 | Same as `~?.' | |
836 | ||
837 | `~!' | |
838 | Flushes the output if format DESTINATION is a port. | |
839 | ||
840 | `~_' | |
841 | Print a `#\space' character | |
842 | `~N_' | |
843 | print N `#\space' characters. | |
844 | ||
845 | `~/' | |
846 | Print a `#\tab' character | |
847 | `~N/' | |
848 | print N `#\tab' characters. | |
849 | ||
850 | `~NC' | |
851 | Takes N as an integer representation for a character. No arguments | |
852 | are consumed. N is converted to a character by `integer->char'. N | |
853 | must be a positive decimal number. | |
854 | ||
855 | `~:S' | |
856 | Print out readproof. Prints out internal objects represented as | |
857 | `#<...>' as strings `"#<...>"' so that the format output can always | |
858 | be processed by `read'. | |
859 | ||
860 | `~:A' | |
861 | Print out readproof. Prints out internal objects represented as | |
862 | `#<...>' as strings `"#<...>"' so that the format output can always | |
863 | be processed by `read'. | |
864 | ||
865 | `~Q' | |
866 | Prints information and a copyright notice on the format | |
867 | implementation. | |
868 | `~:Q' | |
869 | prints format version. | |
870 | ||
871 | `~F, ~E, ~G, ~$' | |
872 | may also print number strings, i.e. passing a number as a string | |
873 | and format it accordingly. | |
874 | ||
875 | *** Configuration Variables | |
876 | ||
877 | The format module exports some configuration variables to suit the | |
878 | systems and users needs. There should be no modification necessary for | |
879 | the configuration that comes with Guile. Format detects automatically | |
880 | if the running scheme system implements floating point numbers and | |
881 | complex numbers. | |
882 | ||
883 | format:symbol-case-conv | |
884 | Symbols are converted by `symbol->string' so the case type of the | |
885 | printed symbols is implementation dependent. | |
886 | `format:symbol-case-conv' is a one arg closure which is either | |
887 | `#f' (no conversion), `string-upcase', `string-downcase' or | |
888 | `string-capitalize'. (default `#f') | |
889 | ||
890 | format:iobj-case-conv | |
891 | As FORMAT:SYMBOL-CASE-CONV but applies for the representation of | |
892 | implementation internal objects. (default `#f') | |
893 | ||
894 | format:expch | |
895 | The character prefixing the exponent value in `~E' printing. | |
896 | (default `#\E') | |
897 | ||
898 | *** Compatibility With Other Format Implementations | |
899 | ||
900 | SLIB format 2.x: | |
901 | See `format.doc'. | |
902 | ||
903 | SLIB format 1.4: | |
904 | Downward compatible except for padding support and `~A', `~S', | |
905 | `~P', `~X' uppercase printing. SLIB format 1.4 uses C-style | |
906 | `printf' padding support which is completely replaced by the CL | |
907 | `format' padding style. | |
908 | ||
909 | MIT C-Scheme 7.1: | |
910 | Downward compatible except for `~', which is not documented | |
911 | (ignores all characters inside the format string up to a newline | |
912 | character). (7.1 implements `~a', `~s', ~NEWLINE, `~~', `~%', | |
913 | numerical and variable parameters and `:/@' modifiers in the CL | |
914 | sense). | |
915 | ||
916 | Elk 1.5/2.0: | |
917 | Downward compatible except for `~A' and `~S' which print in | |
918 | uppercase. (Elk implements `~a', `~s', `~~', and `~%' (no | |
919 | directive parameters or modifiers)). | |
920 | ||
921 | Scheme->C 01nov91: | |
922 | Downward compatible except for an optional destination parameter: | |
923 | S2C accepts a format call without a destination which returns a | |
924 | formatted string. This is equivalent to a #f destination in S2C. | |
925 | (S2C implements `~a', `~s', `~c', `~%', and `~~' (no directive | |
926 | parameters or modifiers)). | |
927 | ||
928 | ||
e7d37b0a | 929 | ** Changes to string-handling functions. |
b7e13f65 | 930 | |
e7d37b0a | 931 | These functions were added to support the (ice-9 format) module, above. |
b7e13f65 | 932 | |
e7d37b0a JB |
933 | *** New function: string-upcase STRING |
934 | *** New function: string-downcase STRING | |
b7e13f65 | 935 | |
e7d37b0a JB |
936 | These are non-destructive versions of the existing string-upcase! and |
937 | string-downcase! functions. | |
b7e13f65 | 938 | |
e7d37b0a JB |
939 | *** New function: string-capitalize! STRING |
940 | *** New function: string-capitalize STRING | |
941 | ||
942 | These functions convert the first letter of each word in the string to | |
943 | upper case. Thus: | |
944 | ||
945 | (string-capitalize "howdy there") | |
946 | => "Howdy There" | |
947 | ||
948 | As with the other functions, string-capitalize! modifies the string in | |
949 | place, while string-capitalize returns a modified copy of its argument. | |
950 | ||
951 | *** New function: string-ci->symbol STRING | |
952 | ||
953 | Return a symbol whose name is STRING, but having the same case as if | |
954 | the symbol had be read by `read'. | |
955 | ||
956 | Guile can be configured to be sensitive or insensitive to case | |
957 | differences in Scheme identifiers. If Guile is case-insensitive, all | |
958 | symbols are converted to lower case on input. The `string-ci->symbol' | |
959 | function returns a symbol whose name in STRING, transformed as Guile | |
960 | would if STRING were input. | |
961 | ||
962 | *** New function: substring-move! STRING1 START END STRING2 START | |
963 | ||
964 | Copy the substring of STRING1 from START (inclusive) to END | |
965 | (exclusive) to STRING2 at START. STRING1 and STRING2 may be the same | |
966 | string, and the source and destination areas may overlap; in all | |
967 | cases, the function behaves as if all the characters were copied | |
968 | simultanously. | |
969 | ||
970 | *** Extended functions: substring-move-left! substring-move-right! | |
971 | ||
972 | These functions now correctly copy arbitrarily overlapping substrings; | |
973 | they are both synonyms for substring-move!. | |
b7e13f65 | 974 | |
b7e13f65 | 975 | |
deaceb4e JB |
976 | ** New module (ice-9 getopt-long), with the function `getopt-long'. |
977 | ||
978 | getopt-long is a function for parsing command-line arguments in a | |
979 | manner consistent with other GNU programs. | |
980 | ||
981 | (getopt-long ARGS GRAMMAR) | |
982 | Parse the arguments ARGS according to the argument list grammar GRAMMAR. | |
983 | ||
984 | ARGS should be a list of strings. Its first element should be the | |
985 | name of the program; subsequent elements should be the arguments | |
986 | that were passed to the program on the command line. The | |
987 | `program-arguments' procedure returns a list of this form. | |
988 | ||
989 | GRAMMAR is a list of the form: | |
990 | ((OPTION (PROPERTY VALUE) ...) ...) | |
991 | ||
992 | Each OPTION should be a symbol. `getopt-long' will accept a | |
993 | command-line option named `--OPTION'. | |
994 | Each option can have the following (PROPERTY VALUE) pairs: | |
995 | ||
996 | (single-char CHAR) --- Accept `-CHAR' as a single-character | |
997 | equivalent to `--OPTION'. This is how to specify traditional | |
998 | Unix-style flags. | |
999 | (required? BOOL) --- If BOOL is true, the option is required. | |
1000 | getopt-long will raise an error if it is not found in ARGS. | |
1001 | (value BOOL) --- If BOOL is #t, the option accepts a value; if | |
1002 | it is #f, it does not; and if it is the symbol | |
1003 | `optional', the option may appear in ARGS with or | |
1004 | without a value. | |
1005 | (predicate FUNC) --- If the option accepts a value (i.e. you | |
1006 | specified `(value #t)' for this option), then getopt | |
1007 | will apply FUNC to the value, and throw an exception | |
1008 | if it returns #f. FUNC should be a procedure which | |
1009 | accepts a string and returns a boolean value; you may | |
1010 | need to use quasiquotes to get it into GRAMMAR. | |
1011 | ||
1012 | The (PROPERTY VALUE) pairs may occur in any order, but each | |
1013 | property may occur only once. By default, options do not have | |
1014 | single-character equivalents, are not required, and do not take | |
1015 | values. | |
1016 | ||
1017 | In ARGS, single-character options may be combined, in the usual | |
1018 | Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option | |
1019 | accepts values, then it must be the last option in the | |
1020 | combination; the value is the next argument. So, for example, using | |
1021 | the following grammar: | |
1022 | ((apples (single-char #\a)) | |
1023 | (blimps (single-char #\b) (value #t)) | |
1024 | (catalexis (single-char #\c) (value #t))) | |
1025 | the following argument lists would be acceptable: | |
1026 | ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values | |
1027 | for "blimps" and "catalexis") | |
1028 | ("-ab" "bang" "-c" "couth") (same) | |
1029 | ("-ac" "couth" "-b" "bang") (same) | |
1030 | ("-abc" "couth" "bang") (an error, since `-b' is not the | |
1031 | last option in its combination) | |
1032 | ||
1033 | If an option's value is optional, then `getopt-long' decides | |
1034 | whether it has a value by looking at what follows it in ARGS. If | |
1035 | the next element is a string, and it does not appear to be an | |
1036 | option itself, then that string is the option's value. | |
1037 | ||
1038 | The value of a long option can appear as the next element in ARGS, | |
1039 | or it can follow the option name, separated by an `=' character. | |
1040 | Thus, using the same grammar as above, the following argument lists | |
1041 | are equivalent: | |
1042 | ("--apples" "Braeburn" "--blimps" "Goodyear") | |
1043 | ("--apples=Braeburn" "--blimps" "Goodyear") | |
1044 | ("--blimps" "Goodyear" "--apples=Braeburn") | |
1045 | ||
1046 | If the option "--" appears in ARGS, argument parsing stops there; | |
1047 | subsequent arguments are returned as ordinary arguments, even if | |
1048 | they resemble options. So, in the argument list: | |
1049 | ("--apples" "Granny Smith" "--" "--blimp" "Goodyear") | |
1050 | `getopt-long' will recognize the `apples' option as having the | |
1051 | value "Granny Smith", but it will not recognize the `blimp' | |
1052 | option; it will return the strings "--blimp" and "Goodyear" as | |
1053 | ordinary argument strings. | |
1054 | ||
1055 | The `getopt-long' function returns the parsed argument list as an | |
1056 | assocation list, mapping option names --- the symbols from GRAMMAR | |
1057 | --- onto their values, or #t if the option does not accept a value. | |
1058 | Unused options do not appear in the alist. | |
1059 | ||
1060 | All arguments that are not the value of any option are returned | |
1061 | as a list, associated with the empty list. | |
1062 | ||
1063 | `getopt-long' throws an exception if: | |
1064 | - it finds an unrecognized option in ARGS | |
1065 | - a required option is omitted | |
1066 | - an option that requires an argument doesn't get one | |
1067 | - an option that doesn't accept an argument does get one (this can | |
1068 | only happen using the long option `--opt=value' syntax) | |
1069 | - an option predicate fails | |
1070 | ||
1071 | So, for example: | |
1072 | ||
1073 | (define grammar | |
1074 | `((lockfile-dir (required? #t) | |
1075 | (value #t) | |
1076 | (single-char #\k) | |
1077 | (predicate ,file-is-directory?)) | |
1078 | (verbose (required? #f) | |
1079 | (single-char #\v) | |
1080 | (value #f)) | |
1081 | (x-includes (single-char #\x)) | |
1082 | (rnet-server (single-char #\y) | |
1083 | (predicate ,string?)))) | |
1084 | ||
1085 | (getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include" | |
1086 | "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3") | |
1087 | grammar) | |
1088 | => ((() "foo1" "-fred" "foo2" "foo3") | |
1089 | (rnet-server . "lamprod") | |
1090 | (x-includes . "/usr/include") | |
1091 | (lockfile-dir . "/tmp") | |
1092 | (verbose . #t)) | |
1093 | ||
1094 | ** The (ice-9 getopt-gnu-style) module is obsolete; use (ice-9 getopt-long). | |
1095 | ||
1096 | It will be removed in a few releases. | |
1097 | ||
08394899 MS |
1098 | ** New syntax: lambda* |
1099 | ** New syntax: define* | |
1100 | ** New syntax: define*-public | |
1101 | ** New syntax: defmacro* | |
1102 | ** New syntax: defmacro*-public | |
1103 | Guile now supports optional arguments. | |
1104 | ||
1105 | `lambda*', `define*', `define*-public', `defmacro*' and | |
1106 | `defmacro*-public' are identical to the non-* versions except that | |
1107 | they use an extended type of parameter list that has the following BNF | |
1108 | syntax (parentheses are literal, square brackets indicate grouping, | |
1109 | and `*', `+' and `?' have the usual meaning): | |
1110 | ||
1111 | ext-param-list ::= ( [identifier]* [#&optional [ext-var-decl]+]? | |
1112 | [#&key [ext-var-decl]+ [#&allow-other-keys]?]? | |
1113 | [[#&rest identifier]|[. identifier]]? ) | [identifier] | |
1114 | ||
1115 | ext-var-decl ::= identifier | ( identifier expression ) | |
1116 | ||
1117 | The semantics are best illustrated with the following documentation | |
1118 | and examples for `lambda*': | |
1119 | ||
1120 | lambda* args . body | |
1121 | lambda extended for optional and keyword arguments | |
1122 | ||
1123 | lambda* creates a procedure that takes optional arguments. These | |
1124 | are specified by putting them inside brackets at the end of the | |
1125 | paramater list, but before any dotted rest argument. For example, | |
1126 | (lambda* (a b #&optional c d . e) '()) | |
1127 | creates a procedure with fixed arguments a and b, optional arguments c | |
1128 | and d, and rest argument e. If the optional arguments are omitted | |
1129 | in a call, the variables for them are unbound in the procedure. This | |
1130 | can be checked with the bound? macro. | |
1131 | ||
1132 | lambda* can also take keyword arguments. For example, a procedure | |
1133 | defined like this: | |
1134 | (lambda* (#&key xyzzy larch) '()) | |
1135 | can be called with any of the argument lists (#:xyzzy 11) | |
1136 | (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments | |
1137 | are given as keywords are bound to values. | |
1138 | ||
1139 | Optional and keyword arguments can also be given default values | |
1140 | which they take on when they are not present in a call, by giving a | |
1141 | two-item list in place of an optional argument, for example in: | |
1142 | (lambda* (foo #&optional (bar 42) #&key (baz 73)) (list foo bar baz)) | |
1143 | foo is a fixed argument, bar is an optional argument with default | |
1144 | value 42, and baz is a keyword argument with default value 73. | |
1145 | Default value expressions are not evaluated unless they are needed | |
1146 | and until the procedure is called. | |
1147 | ||
1148 | lambda* now supports two more special parameter list keywords. | |
1149 | ||
1150 | lambda*-defined procedures now throw an error by default if a | |
1151 | keyword other than one of those specified is found in the actual | |
1152 | passed arguments. However, specifying #&allow-other-keys | |
1153 | immediately after the kyword argument declarations restores the | |
1154 | previous behavior of ignoring unknown keywords. lambda* also now | |
1155 | guarantees that if the same keyword is passed more than once, the | |
1156 | last one passed is the one that takes effect. For example, | |
1157 | ((lambda* (#&key (heads 0) (tails 0)) (display (list heads tails))) | |
1158 | #:heads 37 #:tails 42 #:heads 99) | |
1159 | would result in (99 47) being displayed. | |
1160 | ||
1161 | #&rest is also now provided as a synonym for the dotted syntax rest | |
1162 | argument. The argument lists (a . b) and (a #&rest b) are equivalent in | |
1163 | all respects to lambda*. This is provided for more similarity to DSSSL, | |
1164 | MIT-Scheme and Kawa among others, as well as for refugees from other | |
1165 | Lisp dialects. | |
1166 | ||
1167 | Further documentation may be found in the optargs.scm file itself. | |
1168 | ||
1169 | The optional argument module also exports the macros `let-optional', | |
1170 | `let-optional*', `let-keywords', `let-keywords*' and `bound?'. These | |
1171 | are not documented here because they may be removed in the future, but | |
1172 | full documentation is still available in optargs.scm. | |
1173 | ||
2e132553 JB |
1174 | ** New syntax: and-let* |
1175 | Guile now supports the `and-let*' form, described in the draft SRFI-2. | |
1176 | ||
1177 | Syntax: (land* (<clause> ...) <body> ...) | |
1178 | Each <clause> should have one of the following forms: | |
1179 | (<variable> <expression>) | |
1180 | (<expression>) | |
1181 | <bound-variable> | |
1182 | Each <variable> or <bound-variable> should be an identifier. Each | |
1183 | <expression> should be a valid expression. The <body> should be a | |
1184 | possibly empty sequence of expressions, like the <body> of a | |
1185 | lambda form. | |
1186 | ||
1187 | Semantics: A LAND* expression is evaluated by evaluating the | |
1188 | <expression> or <bound-variable> of each of the <clause>s from | |
1189 | left to right. The value of the first <expression> or | |
1190 | <bound-variable> that evaluates to a false value is returned; the | |
1191 | remaining <expression>s and <bound-variable>s are not evaluated. | |
1192 | The <body> forms are evaluated iff all the <expression>s and | |
1193 | <bound-variable>s evaluate to true values. | |
1194 | ||
1195 | The <expression>s and the <body> are evaluated in an environment | |
1196 | binding each <variable> of the preceding (<variable> <expression>) | |
1197 | clauses to the value of the <expression>. Later bindings | |
1198 | shadow earlier bindings. | |
1199 | ||
1200 | Guile's and-let* macro was contributed by Michael Livshin. | |
1201 | ||
36d3d540 MD |
1202 | ** New sorting functions |
1203 | ||
1204 | *** New function: sorted? SEQUENCE LESS? | |
ed8c8636 MD |
1205 | Returns `#t' when the sequence argument is in non-decreasing order |
1206 | according to LESS? (that is, there is no adjacent pair `... x y | |
1207 | ...' for which `(less? y x)'). | |
1208 | ||
1209 | Returns `#f' when the sequence contains at least one out-of-order | |
1210 | pair. It is an error if the sequence is neither a list nor a | |
1211 | vector. | |
1212 | ||
36d3d540 | 1213 | *** New function: merge LIST1 LIST2 LESS? |
ed8c8636 MD |
1214 | LIST1 and LIST2 are sorted lists. |
1215 | Returns the sorted list of all elements in LIST1 and LIST2. | |
1216 | ||
1217 | Assume that the elements a and b1 in LIST1 and b2 in LIST2 are "equal" | |
1218 | in the sense that (LESS? x y) --> #f for x, y in {a, b1, b2}, | |
1219 | and that a < b1 in LIST1. Then a < b1 < b2 in the result. | |
1220 | (Here "<" should read "comes before".) | |
1221 | ||
36d3d540 | 1222 | *** New procedure: merge! LIST1 LIST2 LESS? |
ed8c8636 MD |
1223 | Merges two lists, re-using the pairs of LIST1 and LIST2 to build |
1224 | the result. If the code is compiled, and LESS? constructs no new | |
1225 | pairs, no pairs at all will be allocated. The first pair of the | |
1226 | result will be either the first pair of LIST1 or the first pair of | |
1227 | LIST2. | |
1228 | ||
36d3d540 | 1229 | *** New function: sort SEQUENCE LESS? |
ed8c8636 MD |
1230 | Accepts either a list or a vector, and returns a new sequence |
1231 | which is sorted. The new sequence is the same type as the input. | |
1232 | Always `(sorted? (sort sequence less?) less?)'. The original | |
1233 | sequence is not altered in any way. The new sequence shares its | |
1234 | elements with the old one; no elements are copied. | |
1235 | ||
36d3d540 | 1236 | *** New procedure: sort! SEQUENCE LESS |
ed8c8636 MD |
1237 | Returns its sorted result in the original boxes. No new storage is |
1238 | allocated at all. Proper usage: (set! slist (sort! slist <)) | |
1239 | ||
36d3d540 | 1240 | *** New function: stable-sort SEQUENCE LESS? |
ed8c8636 MD |
1241 | Similar to `sort' but stable. That is, if "equal" elements are |
1242 | ordered a < b in the original sequence, they will have the same order | |
1243 | in the result. | |
1244 | ||
36d3d540 | 1245 | *** New function: stable-sort! SEQUENCE LESS? |
ed8c8636 MD |
1246 | Similar to `sort!' but stable. |
1247 | Uses temporary storage when sorting vectors. | |
1248 | ||
36d3d540 | 1249 | *** New functions: sort-list, sort-list! |
ed8c8636 MD |
1250 | Added for compatibility with scsh. |
1251 | ||
36d3d540 MD |
1252 | ** New built-in random number support |
1253 | ||
1254 | *** New function: random N [STATE] | |
3e8370c3 MD |
1255 | Accepts a positive integer or real N and returns a number of the |
1256 | same type between zero (inclusive) and N (exclusive). The values | |
1257 | returned have a uniform distribution. | |
1258 | ||
1259 | The optional argument STATE must be of the type produced by | |
416075f1 MD |
1260 | `copy-random-state' or `seed->random-state'. It defaults to the value |
1261 | of the variable `*random-state*'. This object is used to maintain the | |
1262 | state of the pseudo-random-number generator and is altered as a side | |
1263 | effect of the `random' operation. | |
3e8370c3 | 1264 | |
36d3d540 | 1265 | *** New variable: *random-state* |
3e8370c3 MD |
1266 | Holds a data structure that encodes the internal state of the |
1267 | random-number generator that `random' uses by default. The nature | |
1268 | of this data structure is implementation-dependent. It may be | |
1269 | printed out and successfully read back in, but may or may not | |
1270 | function correctly as a random-number state object in another | |
1271 | implementation. | |
1272 | ||
36d3d540 | 1273 | *** New function: copy-random-state [STATE] |
3e8370c3 MD |
1274 | Returns a new object of type suitable for use as the value of the |
1275 | variable `*random-state*' and as a second argument to `random'. | |
1276 | If argument STATE is given, a copy of it is returned. Otherwise a | |
1277 | copy of `*random-state*' is returned. | |
416075f1 | 1278 | |
36d3d540 | 1279 | *** New function: seed->random-state SEED |
416075f1 MD |
1280 | Returns a new object of type suitable for use as the value of the |
1281 | variable `*random-state*' and as a second argument to `random'. | |
1282 | SEED is a string or a number. A new state is generated and | |
1283 | initialized using SEED. | |
3e8370c3 | 1284 | |
36d3d540 | 1285 | *** New function: random:uniform [STATE] |
3e8370c3 MD |
1286 | Returns an uniformly distributed inexact real random number in the |
1287 | range between 0 and 1. | |
1288 | ||
36d3d540 | 1289 | *** New procedure: random:solid-sphere! VECT [STATE] |
3e8370c3 MD |
1290 | Fills VECT with inexact real random numbers the sum of whose |
1291 | squares is less than 1.0. Thinking of VECT as coordinates in | |
1292 | space of dimension N = `(vector-length VECT)', the coordinates are | |
1293 | uniformly distributed within the unit N-shere. The sum of the | |
1294 | squares of the numbers is returned. VECT can be either a vector | |
1295 | or a uniform vector of doubles. | |
1296 | ||
36d3d540 | 1297 | *** New procedure: random:hollow-sphere! VECT [STATE] |
3e8370c3 MD |
1298 | Fills VECT with inexact real random numbers the sum of whose squares |
1299 | is equal to 1.0. Thinking of VECT as coordinates in space of | |
1300 | dimension n = `(vector-length VECT)', the coordinates are uniformly | |
1301 | distributed over the surface of the unit n-shere. VECT can be either | |
1302 | a vector or a uniform vector of doubles. | |
1303 | ||
36d3d540 | 1304 | *** New function: random:normal [STATE] |
3e8370c3 MD |
1305 | Returns an inexact real in a normal distribution with mean 0 and |
1306 | standard deviation 1. For a normal distribution with mean M and | |
1307 | standard deviation D use `(+ M (* D (random:normal)))'. | |
1308 | ||
36d3d540 | 1309 | *** New procedure: random:normal-vector! VECT [STATE] |
3e8370c3 MD |
1310 | Fills VECT with inexact real random numbers which are independent and |
1311 | standard normally distributed (i.e., with mean 0 and variance 1). | |
1312 | VECT can be either a vector or a uniform vector of doubles. | |
1313 | ||
36d3d540 | 1314 | *** New function: random:exp STATE |
3e8370c3 MD |
1315 | Returns an inexact real in an exponential distribution with mean 1. |
1316 | For an exponential distribution with mean U use (* U (random:exp)). | |
1317 | ||
69c6acbb JB |
1318 | ** The range of logand, logior, logxor, logtest, and logbit? have changed. |
1319 | ||
1320 | These functions now operate on numbers in the range of a C unsigned | |
1321 | long. | |
1322 | ||
1323 | These functions used to operate on numbers in the range of a C signed | |
1324 | long; however, this seems inappropriate, because Guile integers don't | |
1325 | overflow. | |
1326 | ||
ba4ee0d6 MD |
1327 | ** New function: make-guardian |
1328 | This is an implementation of guardians as described in | |
1329 | R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a | |
1330 | Generation-Based Garbage Collector" ACM SIGPLAN Conference on | |
1331 | Programming Language Design and Implementation, June 1993 | |
1332 | ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz | |
1333 | ||
88ceea5c MD |
1334 | ** New functions: delq1!, delv1!, delete1! |
1335 | These procedures behave similar to delq! and friends but delete only | |
1336 | one object if at all. | |
1337 | ||
55254a6a MD |
1338 | ** New function: unread-string STRING PORT |
1339 | Unread STRING to PORT, that is, push it back onto the port so that | |
1340 | next read operation will work on the pushed back characters. | |
1341 | ||
1342 | ** unread-char can now be called multiple times | |
1343 | If unread-char is called multiple times, the unread characters will be | |
1344 | read again in last-in first-out order. | |
1345 | ||
9e97c52d GH |
1346 | ** the procedures uniform-array-read! and uniform-array-write! now |
1347 | work on any kind of port, not just ports which are open on a file. | |
1348 | ||
b074884f | 1349 | ** Now 'l' in a port mode requests line buffering. |
9e97c52d | 1350 | |
69bc9ff3 GH |
1351 | ** The procedure truncate-file now works on string ports as well |
1352 | as file ports. If the size argument is omitted, the current | |
1b9c3dae | 1353 | file position is used. |
9e97c52d | 1354 | |
c94577b4 | 1355 | ** new procedure: seek PORT/FDES OFFSET WHENCE |
9e97c52d GH |
1356 | The arguments are the same as for the old fseek procedure, but it |
1357 | works on string ports as well as random-access file ports. | |
1358 | ||
1359 | ** the fseek procedure now works on string ports, since it has been | |
c94577b4 | 1360 | redefined using seek. |
9e97c52d GH |
1361 | |
1362 | ** the setvbuf procedure now uses a default size if mode is _IOFBF and | |
1363 | size is not supplied. | |
1364 | ||
1365 | ** the newline procedure no longer flushes the port if it's not | |
1366 | line-buffered: previously it did if it was the current output port. | |
1367 | ||
1368 | ** open-pipe and close-pipe are no longer primitive procedures, but | |
1369 | an emulation can be obtained using `(use-modules (ice-9 popen))'. | |
1370 | ||
1371 | ** the freopen procedure has been removed. | |
1372 | ||
1373 | ** new procedure: drain-input PORT | |
1374 | Drains PORT's read buffers (including any pushed-back characters) | |
1375 | and returns the contents as a single string. | |
1376 | ||
67ad463a | 1377 | ** New function: map-in-order PROC LIST1 LIST2 ... |
d41b3904 MD |
1378 | Version of `map' which guarantees that the procedure is applied to the |
1379 | lists in serial order. | |
1380 | ||
67ad463a MD |
1381 | ** Renamed `serial-array-copy!' and `serial-array-map!' to |
1382 | `array-copy-in-order!' and `array-map-in-order!'. The old names are | |
1383 | now obsolete and will go away in release 1.5. | |
1384 | ||
cf7132b3 | 1385 | ** New syntax: collect BODY1 ... |
d41b3904 MD |
1386 | Version of `begin' which returns a list of the results of the body |
1387 | forms instead of the result of the last body form. In contrast to | |
cf7132b3 | 1388 | `begin', `collect' allows an empty body. |
d41b3904 | 1389 | |
e4eae9b1 MD |
1390 | ** New functions: read-history FILENAME, write-history FILENAME |
1391 | Read/write command line history from/to file. Returns #t on success | |
1392 | and #f if an error occured. | |
1393 | ||
d21ffe26 JB |
1394 | ** `ls' and `lls' in module (ice-9 ls) now handle no arguments. |
1395 | ||
1396 | These procedures return a list of definitions available in the specified | |
1397 | argument, a relative module reference. In the case of no argument, | |
1398 | `(current-module)' is now consulted for definitions to return, instead | |
1399 | of simply returning #f, the former behavior. | |
1400 | ||
f8c9d497 JB |
1401 | ** The #/ syntax for lists is no longer supported. |
1402 | ||
1403 | Earlier versions of Scheme accepted this syntax, but printed a | |
1404 | warning. | |
1405 | ||
1406 | ** Guile no longer consults the SCHEME_LOAD_PATH environment variable. | |
1407 | ||
1408 | Instead, you should set GUILE_LOAD_PATH to tell Guile where to find | |
1409 | modules. | |
1410 | ||
3ffc7a36 MD |
1411 | * Changes to the gh_ interface |
1412 | ||
1413 | ** gh_scm2doubles | |
1414 | ||
1415 | Now takes a second argument which is the result array. If this | |
1416 | pointer is NULL, a new array is malloced (the old behaviour). | |
1417 | ||
1418 | ** gh_chars2byvect, gh_shorts2svect, gh_floats2fvect, gh_scm2chars, | |
1419 | gh_scm2shorts, gh_scm2longs, gh_scm2floats | |
1420 | ||
1421 | New functions. | |
1422 | ||
3e8370c3 MD |
1423 | * Changes to the scm_ interface |
1424 | ||
ad91d6c3 MD |
1425 | ** Function: scm_make_named_hook (char* name, int n_args) |
1426 | ||
1427 | Creates a hook in the same way as make-hook above but also | |
1428 | binds a variable named NAME to it. | |
1429 | ||
1430 | This is the typical way of creating a hook from C code. | |
1431 | ||
ece41168 MD |
1432 | Currently, the variable is created in the "current" module. This |
1433 | might change when we get the new module system. | |
ad91d6c3 | 1434 | |
16a5a9a4 MD |
1435 | ** The smob interface |
1436 | ||
1437 | The interface for creating smobs has changed. For documentation, see | |
1438 | data-rep.info (made from guile-core/doc/data-rep.texi). | |
1439 | ||
1440 | *** Deprecated function: SCM scm_newsmob (scm_smobfuns *) | |
1441 | ||
1442 | >>> This function will be removed in 1.3.4. <<< | |
1443 | ||
1444 | It is replaced by: | |
1445 | ||
1446 | *** Function: SCM scm_make_smob_type (const char *name, scm_sizet size) | |
1447 | This function adds a new smob type, named NAME, with instance size | |
1448 | SIZE to the system. The return value is a tag that is used in | |
1449 | creating instances of the type. If SIZE is 0, then no memory will | |
1450 | be allocated when instances of the smob are created, and nothing | |
1451 | will be freed by the default free function. | |
1452 | ||
1453 | *** Function: void scm_set_smob_mark (long tc, SCM (*mark) (SCM)) | |
1454 | This function sets the smob marking procedure for the smob type | |
1455 | specified by the tag TC. TC is the tag returned by | |
1456 | `scm_make_smob_type'. | |
1457 | ||
1458 | *** Function: void scm_set_smob_free (long tc, SCM (*mark) (SCM)) | |
1459 | This function sets the smob freeing procedure for the smob type | |
1460 | specified by the tag TC. TC is the tag returned by | |
1461 | `scm_make_smob_type'. | |
1462 | ||
1463 | *** Function: void scm_set_smob_print (tc, print) | |
1464 | ||
1465 | - Function: void scm_set_smob_print (long tc, | |
1466 | scm_sizet (*print) (SCM, | |
1467 | SCM, | |
1468 | scm_print_state *)) | |
1469 | ||
1470 | This function sets the smob printing procedure for the smob type | |
1471 | specified by the tag TC. TC is the tag returned by | |
1472 | `scm_make_smob_type'. | |
1473 | ||
1474 | *** Function: void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM)) | |
1475 | This function sets the smob equality-testing predicate for the | |
1476 | smob type specified by the tag TC. TC is the tag returned by | |
1477 | `scm_make_smob_type'. | |
1478 | ||
1479 | *** Macro: void SCM_NEWSMOB (SCM var, long tc, void *data) | |
1480 | Make VALUE contain a smob instance of the type with type code TC and | |
1481 | smob data DATA. VALUE must be previously declared as C type `SCM'. | |
1482 | ||
1483 | *** Macro: fn_returns SCM_RETURN_NEWSMOB (long tc, void *data) | |
1484 | This macro expands to a block of code that creates a smob instance | |
1485 | of the type with type code TC and smob data DATA, and returns that | |
1486 | `SCM' value. It should be the last piece of code in a block. | |
1487 | ||
9e97c52d GH |
1488 | ** The interfaces for using I/O ports and implementing port types |
1489 | (ptobs) have changed significantly. The new interface is based on | |
1490 | shared access to buffers and a new set of ptob procedures. | |
1491 | ||
16a5a9a4 MD |
1492 | *** scm_newptob has been removed |
1493 | ||
1494 | It is replaced by: | |
1495 | ||
1496 | *** Function: SCM scm_make_port_type (type_name, fill_buffer, write_flush) | |
1497 | ||
1498 | - Function: SCM scm_make_port_type (char *type_name, | |
1499 | int (*fill_buffer) (SCM port), | |
1500 | void (*write_flush) (SCM port)); | |
1501 | ||
1502 | Similarly to the new smob interface, there is a set of function | |
1503 | setters by which the user can customize the behaviour of his port | |
544e9093 | 1504 | type. See ports.h (scm_set_port_XXX). |
16a5a9a4 | 1505 | |
9e97c52d GH |
1506 | ** scm_strport_to_string: New function: creates a new string from |
1507 | a string port's buffer. | |
1508 | ||
3e8370c3 MD |
1509 | ** Plug in interface for random number generators |
1510 | The variable `scm_the_rng' in random.c contains a value and three | |
1511 | function pointers which together define the current random number | |
1512 | generator being used by the Scheme level interface and the random | |
1513 | number library functions. | |
1514 | ||
1515 | The user is free to replace the default generator with the generator | |
1516 | of his own choice. | |
1517 | ||
1518 | *** Variable: size_t scm_the_rng.rstate_size | |
1519 | The size of the random state type used by the current RNG | |
1520 | measured in chars. | |
1521 | ||
1522 | *** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE) | |
1523 | Given the random STATE, return 32 random bits. | |
1524 | ||
1525 | *** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N) | |
1526 | Seed random state STATE using string S of length N. | |
1527 | ||
1528 | *** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE) | |
1529 | Given random state STATE, return a malloced copy. | |
1530 | ||
1531 | ** Default RNG | |
1532 | The default RNG is the MWC (Multiply With Carry) random number | |
1533 | generator described by George Marsaglia at the Department of | |
1534 | Statistics and Supercomputer Computations Research Institute, The | |
1535 | Florida State University (http://stat.fsu.edu/~geo). | |
1536 | ||
1537 | It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and | |
1538 | passes all tests in the DIEHARD test suite | |
1539 | (http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits | |
1540 | costs one multiply and one add on platforms which either supports long | |
1541 | longs (gcc does this on most systems) or have 64 bit longs. The cost | |
1542 | is four multiply on other systems but this can be optimized by writing | |
1543 | scm_i_uniform32 in assembler. | |
1544 | ||
1545 | These functions are provided through the scm_the_rng interface for use | |
1546 | by libguile and the application. | |
1547 | ||
1548 | *** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE) | |
1549 | Given the random STATE, return 32 random bits. | |
1550 | Don't use this function directly. Instead go through the plugin | |
1551 | interface (see "Plug in interface" above). | |
1552 | ||
1553 | *** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N) | |
1554 | Initialize STATE using SEED of length N. | |
1555 | ||
1556 | *** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE) | |
1557 | Return a malloc:ed copy of STATE. This function can easily be re-used | |
1558 | in the interfaces to other RNGs. | |
1559 | ||
1560 | ** Random number library functions | |
1561 | These functions use the current RNG through the scm_the_rng interface. | |
1562 | It might be a good idea to use these functions from your C code so | |
1563 | that only one random generator is used by all code in your program. | |
1564 | ||
259529f2 | 1565 | The default random state is stored in: |
3e8370c3 MD |
1566 | |
1567 | *** Variable: SCM scm_var_random_state | |
1568 | Contains the vcell of the Scheme variable "*random-state*" which is | |
1569 | used as default state by all random number functions in the Scheme | |
1570 | level interface. | |
1571 | ||
1572 | Example: | |
1573 | ||
259529f2 | 1574 | double x = scm_c_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state))); |
3e8370c3 | 1575 | |
259529f2 MD |
1576 | *** Function: scm_rstate *scm_c_default_rstate (void) |
1577 | This is a convenience function which returns the value of | |
1578 | scm_var_random_state. An error message is generated if this value | |
1579 | isn't a random state. | |
1580 | ||
1581 | *** Function: scm_rstate *scm_c_make_rstate (char *SEED, int LENGTH) | |
1582 | Make a new random state from the string SEED of length LENGTH. | |
1583 | ||
1584 | It is generally not a good idea to use multiple random states in a | |
1585 | program. While subsequent random numbers generated from one random | |
1586 | state are guaranteed to be reasonably independent, there is no such | |
1587 | guarantee for numbers generated from different random states. | |
1588 | ||
1589 | *** Macro: unsigned long scm_c_uniform32 (scm_rstate *STATE) | |
1590 | Return 32 random bits. | |
1591 | ||
1592 | *** Function: double scm_c_uniform01 (scm_rstate *STATE) | |
3e8370c3 MD |
1593 | Return a sample from the uniform(0,1) distribution. |
1594 | ||
259529f2 | 1595 | *** Function: double scm_c_normal01 (scm_rstate *STATE) |
3e8370c3 MD |
1596 | Return a sample from the normal(0,1) distribution. |
1597 | ||
259529f2 | 1598 | *** Function: double scm_c_exp1 (scm_rstate *STATE) |
3e8370c3 MD |
1599 | Return a sample from the exp(1) distribution. |
1600 | ||
259529f2 MD |
1601 | *** Function: unsigned long scm_c_random (scm_rstate *STATE, unsigned long M) |
1602 | Return a sample from the discrete uniform(0,M) distribution. | |
1603 | ||
1604 | *** Function: SCM scm_c_random_bignum (scm_rstate *STATE, SCM M) | |
3e8370c3 | 1605 | Return a sample from the discrete uniform(0,M) distribution. |
259529f2 | 1606 | M must be a bignum object. The returned value may be an INUM. |
3e8370c3 | 1607 | |
9e97c52d | 1608 | |
f3227c7a | 1609 | \f |
d23bbf3e | 1610 | Changes in Guile 1.3 (released Monday, October 19, 1998): |
c484bf7f JB |
1611 | |
1612 | * Changes to the distribution | |
1613 | ||
e2d6569c JB |
1614 | ** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH. |
1615 | To avoid conflicts, programs should name environment variables after | |
1616 | themselves, except when there's a common practice establishing some | |
1617 | other convention. | |
1618 | ||
1619 | For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH, | |
1620 | giving the former precedence, and printing a warning message if the | |
1621 | latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all. | |
1622 | ||
1623 | ** The header files related to multi-byte characters have been removed. | |
1624 | They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code | |
1625 | which referred to these explicitly will probably need to be rewritten, | |
1626 | since the support for the variant string types has been removed; see | |
1627 | below. | |
1628 | ||
1629 | ** The header files append.h and sequences.h have been removed. These | |
1630 | files implemented non-R4RS operations which would encourage | |
1631 | non-portable programming style and less easy-to-read code. | |
3a97e020 | 1632 | |
c484bf7f JB |
1633 | * Changes to the stand-alone interpreter |
1634 | ||
2e368582 | 1635 | ** New procedures have been added to implement a "batch mode": |
ec4ab4fd | 1636 | |
2e368582 | 1637 | *** Function: batch-mode? |
ec4ab4fd GH |
1638 | |
1639 | Returns a boolean indicating whether the interpreter is in batch | |
1640 | mode. | |
1641 | ||
2e368582 | 1642 | *** Function: set-batch-mode?! ARG |
ec4ab4fd GH |
1643 | |
1644 | If ARG is true, switches the interpreter to batch mode. The `#f' | |
1645 | case has not been implemented. | |
1646 | ||
2e368582 JB |
1647 | ** Guile now provides full command-line editing, when run interactively. |
1648 | To use this feature, you must have the readline library installed. | |
1649 | The Guile build process will notice it, and automatically include | |
1650 | support for it. | |
1651 | ||
1652 | The readline library is available via anonymous FTP from any GNU | |
1653 | mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu". | |
1654 | ||
a5d6d578 MD |
1655 | ** the-last-stack is now a fluid. |
1656 | ||
c484bf7f JB |
1657 | * Changes to the procedure for linking libguile with your programs |
1658 | ||
71f20534 | 1659 | ** You can now use the `guile-config' utility to build programs that use Guile. |
2e368582 | 1660 | |
2adfe1c0 | 1661 | Guile now includes a command-line utility called `guile-config', which |
71f20534 JB |
1662 | can provide information about how to compile and link programs that |
1663 | use Guile. | |
1664 | ||
1665 | *** `guile-config compile' prints any C compiler flags needed to use Guile. | |
1666 | You should include this command's output on the command line you use | |
1667 | to compile C or C++ code that #includes the Guile header files. It's | |
1668 | usually just a `-I' flag to help the compiler find the Guile headers. | |
1669 | ||
1670 | ||
1671 | *** `guile-config link' prints any linker flags necessary to link with Guile. | |
8aa5c148 | 1672 | |
71f20534 | 1673 | This command writes to its standard output a list of flags which you |
8aa5c148 JB |
1674 | must pass to the linker to link your code against the Guile library. |
1675 | The flags include '-lguile' itself, any other libraries the Guile | |
1676 | library depends upon, and any `-L' flags needed to help the linker | |
1677 | find those libraries. | |
2e368582 JB |
1678 | |
1679 | For example, here is a Makefile rule that builds a program named 'foo' | |
1680 | from the object files ${FOO_OBJECTS}, and links them against Guile: | |
1681 | ||
1682 | foo: ${FOO_OBJECTS} | |
2adfe1c0 | 1683 | ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo |
2e368582 | 1684 | |
e2d6569c JB |
1685 | Previous Guile releases recommended that you use autoconf to detect |
1686 | which of a predefined set of libraries were present on your system. | |
2adfe1c0 | 1687 | It is more robust to use `guile-config', since it records exactly which |
e2d6569c JB |
1688 | libraries the installed Guile library requires. |
1689 | ||
2adfe1c0 JB |
1690 | This was originally called `build-guile', but was renamed to |
1691 | `guile-config' before Guile 1.3 was released, to be consistent with | |
1692 | the analogous script for the GTK+ GUI toolkit, which is called | |
1693 | `gtk-config'. | |
1694 | ||
2e368582 | 1695 | |
8aa5c148 JB |
1696 | ** Use the GUILE_FLAGS macro in your configure.in file to find Guile. |
1697 | ||
1698 | If you are using the GNU autoconf package to configure your program, | |
1699 | you can use the GUILE_FLAGS autoconf macro to call `guile-config' | |
1700 | (described above) and gather the necessary values for use in your | |
1701 | Makefiles. | |
1702 | ||
1703 | The GUILE_FLAGS macro expands to configure script code which runs the | |
1704 | `guile-config' script, to find out where Guile's header files and | |
1705 | libraries are installed. It sets two variables, marked for | |
1706 | substitution, as by AC_SUBST. | |
1707 | ||
1708 | GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build | |
1709 | code that uses Guile header files. This is almost always just a | |
1710 | -I flag. | |
1711 | ||
1712 | GUILE_LDFLAGS --- flags to pass to the linker to link a | |
1713 | program against Guile. This includes `-lguile' for the Guile | |
1714 | library itself, any libraries that Guile itself requires (like | |
1715 | -lqthreads), and so on. It may also include a -L flag to tell the | |
1716 | compiler where to find the libraries. | |
1717 | ||
1718 | GUILE_FLAGS is defined in the file guile.m4, in the top-level | |
1719 | directory of the Guile distribution. You can copy it into your | |
1720 | package's aclocal.m4 file, and then use it in your configure.in file. | |
1721 | ||
1722 | If you are using the `aclocal' program, distributed with GNU automake, | |
1723 | to maintain your aclocal.m4 file, the Guile installation process | |
1724 | installs guile.m4 where aclocal will find it. All you need to do is | |
1725 | use GUILE_FLAGS in your configure.in file, and then run `aclocal'; | |
1726 | this will copy the definition of GUILE_FLAGS into your aclocal.m4 | |
1727 | file. | |
1728 | ||
1729 | ||
c484bf7f | 1730 | * Changes to Scheme functions and syntax |
7ad3c1e7 | 1731 | |
02755d59 | 1732 | ** Multi-byte strings have been removed, as have multi-byte and wide |
e2d6569c JB |
1733 | ports. We felt that these were the wrong approach to |
1734 | internationalization support. | |
02755d59 | 1735 | |
2e368582 JB |
1736 | ** New function: readline [PROMPT] |
1737 | Read a line from the terminal, and allow the user to edit it, | |
1738 | prompting with PROMPT. READLINE provides a large set of Emacs-like | |
1739 | editing commands, lets the user recall previously typed lines, and | |
1740 | works on almost every kind of terminal, including dumb terminals. | |
1741 | ||
1742 | READLINE assumes that the cursor is at the beginning of the line when | |
1743 | it is invoked. Thus, you can't print a prompt yourself, and then call | |
1744 | READLINE; you need to package up your prompt as a string, pass it to | |
1745 | the function, and let READLINE print the prompt itself. This is | |
1746 | because READLINE needs to know the prompt's screen width. | |
1747 | ||
8cd57bd0 JB |
1748 | For Guile to provide this function, you must have the readline |
1749 | library, version 2.1 or later, installed on your system. Readline is | |
1750 | available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from | |
1751 | any GNU mirror site. | |
2e368582 JB |
1752 | |
1753 | See also ADD-HISTORY function. | |
1754 | ||
1755 | ** New function: add-history STRING | |
1756 | Add STRING as the most recent line in the history used by the READLINE | |
1757 | command. READLINE does not add lines to the history itself; you must | |
1758 | call ADD-HISTORY to make previous input available to the user. | |
1759 | ||
8cd57bd0 JB |
1760 | ** The behavior of the read-line function has changed. |
1761 | ||
1762 | This function now uses standard C library functions to read the line, | |
1763 | for speed. This means that it doesn not respect the value of | |
1764 | scm-line-incrementors; it assumes that lines are delimited with | |
1765 | #\newline. | |
1766 | ||
1767 | (Note that this is read-line, the function that reads a line of text | |
1768 | from a port, not readline, the function that reads a line from a | |
1769 | terminal, providing full editing capabilities.) | |
1770 | ||
1a0106ef JB |
1771 | ** New module (ice-9 getopt-gnu-style): Parse command-line arguments. |
1772 | ||
1773 | This module provides some simple argument parsing. It exports one | |
1774 | function: | |
1775 | ||
1776 | Function: getopt-gnu-style ARG-LS | |
1777 | Parse a list of program arguments into an alist of option | |
1778 | descriptions. | |
1779 | ||
1780 | Each item in the list of program arguments is examined to see if | |
1781 | it meets the syntax of a GNU long-named option. An argument like | |
1782 | `--MUMBLE' produces an element of the form (MUMBLE . #t) in the | |
1783 | returned alist, where MUMBLE is a keyword object with the same | |
1784 | name as the argument. An argument like `--MUMBLE=FROB' produces | |
1785 | an element of the form (MUMBLE . FROB), where FROB is a string. | |
1786 | ||
1787 | As a special case, the returned alist also contains a pair whose | |
1788 | car is the symbol `rest'. The cdr of this pair is a list | |
1789 | containing all the items in the argument list that are not options | |
1790 | of the form mentioned above. | |
1791 | ||
1792 | The argument `--' is treated specially: all items in the argument | |
1793 | list appearing after such an argument are not examined, and are | |
1794 | returned in the special `rest' list. | |
1795 | ||
1796 | This function does not parse normal single-character switches. | |
1797 | You will need to parse them out of the `rest' list yourself. | |
1798 | ||
8cd57bd0 JB |
1799 | ** The read syntax for byte vectors and short vectors has changed. |
1800 | ||
1801 | Instead of #bytes(...), write #y(...). | |
1802 | ||
1803 | Instead of #short(...), write #h(...). | |
1804 | ||
1805 | This may seem nutty, but, like the other uniform vectors, byte vectors | |
1806 | and short vectors want to have the same print and read syntax (and, | |
1807 | more basic, want to have read syntax!). Changing the read syntax to | |
1808 | use multiple characters after the hash sign breaks with the | |
1809 | conventions used in R5RS and the conventions used for the other | |
1810 | uniform vectors. It also introduces complexity in the current reader, | |
1811 | both on the C and Scheme levels. (The Right solution is probably to | |
1812 | change the syntax and prototypes for uniform vectors entirely.) | |
1813 | ||
1814 | ||
1815 | ** The new module (ice-9 session) provides useful interactive functions. | |
1816 | ||
1817 | *** New procedure: (apropos REGEXP OPTION ...) | |
1818 | ||
1819 | Display a list of top-level variables whose names match REGEXP, and | |
1820 | the modules they are imported from. Each OPTION should be one of the | |
1821 | following symbols: | |
1822 | ||
1823 | value --- Show the value of each matching variable. | |
1824 | shadow --- Show bindings shadowed by subsequently imported modules. | |
1825 | full --- Same as both `shadow' and `value'. | |
1826 | ||
1827 | For example: | |
1828 | ||
1829 | guile> (apropos "trace" 'full) | |
1830 | debug: trace #<procedure trace args> | |
1831 | debug: untrace #<procedure untrace args> | |
1832 | the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>> | |
1833 | the-scm-module: before-backtrace-hook () | |
1834 | the-scm-module: backtrace #<primitive-procedure backtrace> | |
1835 | the-scm-module: after-backtrace-hook () | |
1836 | the-scm-module: has-shown-backtrace-hint? #f | |
1837 | guile> | |
1838 | ||
1839 | ** There are new functions and syntax for working with macros. | |
1840 | ||
1841 | Guile implements macros as a special object type. Any variable whose | |
1842 | top-level binding is a macro object acts as a macro. The macro object | |
1843 | specifies how the expression should be transformed before evaluation. | |
1844 | ||
1845 | *** Macro objects now print in a reasonable way, resembling procedures. | |
1846 | ||
1847 | *** New function: (macro? OBJ) | |
1848 | True iff OBJ is a macro object. | |
1849 | ||
1850 | *** New function: (primitive-macro? OBJ) | |
1851 | Like (macro? OBJ), but true only if OBJ is one of the Guile primitive | |
1852 | macro transformers, implemented in eval.c rather than Scheme code. | |
1853 | ||
dbdd0c16 JB |
1854 | Why do we have this function? |
1855 | - For symmetry with procedure? and primitive-procedure?, | |
1856 | - to allow custom print procedures to tell whether a macro is | |
1857 | primitive, and display it differently, and | |
1858 | - to allow compilers and user-written evaluators to distinguish | |
1859 | builtin special forms from user-defined ones, which could be | |
1860 | compiled. | |
1861 | ||
8cd57bd0 JB |
1862 | *** New function: (macro-type OBJ) |
1863 | Return a value indicating what kind of macro OBJ is. Possible return | |
1864 | values are: | |
1865 | ||
1866 | The symbol `syntax' --- a macro created by procedure->syntax. | |
1867 | The symbol `macro' --- a macro created by procedure->macro. | |
1868 | The symbol `macro!' --- a macro created by procedure->memoizing-macro. | |
1869 | The boolean #f --- if OBJ is not a macro object. | |
1870 | ||
1871 | *** New function: (macro-name MACRO) | |
1872 | Return the name of the macro object MACRO's procedure, as returned by | |
1873 | procedure-name. | |
1874 | ||
1875 | *** New function: (macro-transformer MACRO) | |
1876 | Return the transformer procedure for MACRO. | |
1877 | ||
1878 | *** New syntax: (use-syntax MODULE ... TRANSFORMER) | |
1879 | ||
1880 | Specify a new macro expander to use in the current module. Each | |
1881 | MODULE is a module name, with the same meaning as in the `use-modules' | |
1882 | form; each named module's exported bindings are added to the current | |
1883 | top-level environment. TRANSFORMER is an expression evaluated in the | |
1884 | resulting environment which must yield a procedure to use as the | |
1885 | module's eval transformer: every expression evaluated in this module | |
1886 | is passed to this function, and the result passed to the Guile | |
1887 | interpreter. | |
1888 | ||
1889 | *** macro-eval! is removed. Use local-eval instead. | |
29521173 | 1890 | |
8d9dcb3c MV |
1891 | ** Some magic has been added to the printer to better handle user |
1892 | written printing routines (like record printers, closure printers). | |
1893 | ||
1894 | The problem is that these user written routines must have access to | |
7fbd77df | 1895 | the current `print-state' to be able to handle fancy things like |
8d9dcb3c MV |
1896 | detection of circular references. These print-states have to be |
1897 | passed to the builtin printing routines (display, write, etc) to | |
1898 | properly continue the print chain. | |
1899 | ||
1900 | We didn't want to change all existing print code so that it | |
8cd57bd0 | 1901 | explicitly passes thru a print state in addition to a port. Instead, |
8d9dcb3c MV |
1902 | we extented the possible values that the builtin printing routines |
1903 | accept as a `port'. In addition to a normal port, they now also take | |
1904 | a pair of a normal port and a print-state. Printing will go to the | |
1905 | port and the print-state will be used to control the detection of | |
1906 | circular references, etc. If the builtin function does not care for a | |
1907 | print-state, it is simply ignored. | |
1908 | ||
1909 | User written callbacks are now called with such a pair as their | |
1910 | `port', but because every function now accepts this pair as a PORT | |
1911 | argument, you don't have to worry about that. In fact, it is probably | |
1912 | safest to not check for these pairs. | |
1913 | ||
1914 | However, it is sometimes necessary to continue a print chain on a | |
1915 | different port, for example to get a intermediate string | |
1916 | representation of the printed value, mangle that string somehow, and | |
1917 | then to finally print the mangled string. Use the new function | |
1918 | ||
1919 | inherit-print-state OLD-PORT NEW-PORT | |
1920 | ||
1921 | for this. It constructs a new `port' that prints to NEW-PORT but | |
1922 | inherits the print-state of OLD-PORT. | |
1923 | ||
ef1ea498 MD |
1924 | ** struct-vtable-offset renamed to vtable-offset-user |
1925 | ||
1926 | ** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer | |
1927 | ||
1928 | ** There is now a fourth (optional) argument to make-vtable-vtable and | |
1929 | make-struct when constructing new types (vtables). This argument | |
1930 | initializes field vtable-index-printer of the vtable. | |
1931 | ||
4851dc57 MV |
1932 | ** The detection of circular references has been extended to structs. |
1933 | That is, a structure that -- in the process of being printed -- prints | |
1934 | itself does not lead to infinite recursion. | |
1935 | ||
1936 | ** There is now some basic support for fluids. Please read | |
1937 | "libguile/fluid.h" to find out more. It is accessible from Scheme with | |
1938 | the following functions and macros: | |
1939 | ||
9c3fb66f MV |
1940 | Function: make-fluid |
1941 | ||
1942 | Create a new fluid object. Fluids are not special variables or | |
1943 | some other extension to the semantics of Scheme, but rather | |
1944 | ordinary Scheme objects. You can store them into variables (that | |
1945 | are still lexically scoped, of course) or into any other place you | |
1946 | like. Every fluid has a initial value of `#f'. | |
04c76b58 | 1947 | |
9c3fb66f | 1948 | Function: fluid? OBJ |
04c76b58 | 1949 | |
9c3fb66f | 1950 | Test whether OBJ is a fluid. |
04c76b58 | 1951 | |
9c3fb66f MV |
1952 | Function: fluid-ref FLUID |
1953 | Function: fluid-set! FLUID VAL | |
04c76b58 MV |
1954 | |
1955 | Access/modify the fluid FLUID. Modifications are only visible | |
1956 | within the current dynamic root (that includes threads). | |
1957 | ||
9c3fb66f MV |
1958 | Function: with-fluids* FLUIDS VALUES THUNK |
1959 | ||
1960 | FLUIDS is a list of fluids and VALUES a corresponding list of | |
1961 | values for these fluids. Before THUNK gets called the values are | |
1962 | installed in the fluids and the old values of the fluids are | |
1963 | saved in the VALUES list. When the flow of control leaves THUNK | |
1964 | or reenters it, the values get swapped again. You might think of | |
1965 | this as a `safe-fluid-excursion'. Note that the VALUES list is | |
1966 | modified by `with-fluids*'. | |
1967 | ||
1968 | Macro: with-fluids ((FLUID VALUE) ...) FORM ... | |
1969 | ||
1970 | The same as `with-fluids*' but with a different syntax. It looks | |
1971 | just like `let', but both FLUID and VALUE are evaluated. Remember, | |
1972 | fluids are not special variables but ordinary objects. FLUID | |
1973 | should evaluate to a fluid. | |
04c76b58 | 1974 | |
e2d6569c | 1975 | ** Changes to system call interfaces: |
64d01d13 | 1976 | |
e2d6569c | 1977 | *** close-port, close-input-port and close-output-port now return a |
64d01d13 GH |
1978 | boolean instead of an `unspecified' object. #t means that the port |
1979 | was successfully closed, while #f means it was already closed. It is | |
1980 | also now possible for these procedures to raise an exception if an | |
1981 | error occurs (some errors from write can be delayed until close.) | |
1982 | ||
e2d6569c | 1983 | *** the first argument to chmod, fcntl, ftell and fseek can now be a |
6afcd3b2 GH |
1984 | file descriptor. |
1985 | ||
e2d6569c | 1986 | *** the third argument to fcntl is now optional. |
6afcd3b2 | 1987 | |
e2d6569c | 1988 | *** the first argument to chown can now be a file descriptor or a port. |
6afcd3b2 | 1989 | |
e2d6569c | 1990 | *** the argument to stat can now be a port. |
6afcd3b2 | 1991 | |
e2d6569c | 1992 | *** The following new procedures have been added (most use scsh |
64d01d13 GH |
1993 | interfaces): |
1994 | ||
e2d6569c | 1995 | *** procedure: close PORT/FD |
ec4ab4fd GH |
1996 | Similar to close-port (*note close-port: Closing Ports.), but also |
1997 | works on file descriptors. A side effect of closing a file | |
1998 | descriptor is that any ports using that file descriptor are moved | |
1999 | to a different file descriptor and have their revealed counts set | |
2000 | to zero. | |
2001 | ||
e2d6569c | 2002 | *** procedure: port->fdes PORT |
ec4ab4fd GH |
2003 | Returns the integer file descriptor underlying PORT. As a side |
2004 | effect the revealed count of PORT is incremented. | |
2005 | ||
e2d6569c | 2006 | *** procedure: fdes->ports FDES |
ec4ab4fd GH |
2007 | Returns a list of existing ports which have FDES as an underlying |
2008 | file descriptor, without changing their revealed counts. | |
2009 | ||
e2d6569c | 2010 | *** procedure: fdes->inport FDES |
ec4ab4fd GH |
2011 | Returns an existing input port which has FDES as its underlying |
2012 | file descriptor, if one exists, and increments its revealed count. | |
2013 | Otherwise, returns a new input port with a revealed count of 1. | |
2014 | ||
e2d6569c | 2015 | *** procedure: fdes->outport FDES |
ec4ab4fd GH |
2016 | Returns an existing output port which has FDES as its underlying |
2017 | file descriptor, if one exists, and increments its revealed count. | |
2018 | Otherwise, returns a new output port with a revealed count of 1. | |
2019 | ||
2020 | The next group of procedures perform a `dup2' system call, if NEWFD | |
2021 | (an integer) is supplied, otherwise a `dup'. The file descriptor to be | |
2022 | duplicated can be supplied as an integer or contained in a port. The | |
64d01d13 GH |
2023 | type of value returned varies depending on which procedure is used. |
2024 | ||
ec4ab4fd GH |
2025 | All procedures also have the side effect when performing `dup2' that |
2026 | any ports using NEWFD are moved to a different file descriptor and have | |
64d01d13 GH |
2027 | their revealed counts set to zero. |
2028 | ||
e2d6569c | 2029 | *** procedure: dup->fdes PORT/FD [NEWFD] |
ec4ab4fd | 2030 | Returns an integer file descriptor. |
64d01d13 | 2031 | |
e2d6569c | 2032 | *** procedure: dup->inport PORT/FD [NEWFD] |
ec4ab4fd | 2033 | Returns a new input port using the new file descriptor. |
64d01d13 | 2034 | |
e2d6569c | 2035 | *** procedure: dup->outport PORT/FD [NEWFD] |
ec4ab4fd | 2036 | Returns a new output port using the new file descriptor. |
64d01d13 | 2037 | |
e2d6569c | 2038 | *** procedure: dup PORT/FD [NEWFD] |
ec4ab4fd GH |
2039 | Returns a new port if PORT/FD is a port, with the same mode as the |
2040 | supplied port, otherwise returns an integer file descriptor. | |
64d01d13 | 2041 | |
e2d6569c | 2042 | *** procedure: dup->port PORT/FD MODE [NEWFD] |
ec4ab4fd GH |
2043 | Returns a new port using the new file descriptor. MODE supplies a |
2044 | mode string for the port (*note open-file: File Ports.). | |
64d01d13 | 2045 | |
e2d6569c | 2046 | *** procedure: setenv NAME VALUE |
ec4ab4fd GH |
2047 | Modifies the environment of the current process, which is also the |
2048 | default environment inherited by child processes. | |
64d01d13 | 2049 | |
ec4ab4fd GH |
2050 | If VALUE is `#f', then NAME is removed from the environment. |
2051 | Otherwise, the string NAME=VALUE is added to the environment, | |
2052 | replacing any existing string with name matching NAME. | |
64d01d13 | 2053 | |
ec4ab4fd | 2054 | The return value is unspecified. |
956055a9 | 2055 | |
e2d6569c | 2056 | *** procedure: truncate-file OBJ SIZE |
6afcd3b2 GH |
2057 | Truncates the file referred to by OBJ to at most SIZE bytes. OBJ |
2058 | can be a string containing a file name or an integer file | |
2059 | descriptor or port open for output on the file. The underlying | |
2060 | system calls are `truncate' and `ftruncate'. | |
2061 | ||
2062 | The return value is unspecified. | |
2063 | ||
e2d6569c | 2064 | *** procedure: setvbuf PORT MODE [SIZE] |
7a6f1ffa GH |
2065 | Set the buffering mode for PORT. MODE can be: |
2066 | `_IONBF' | |
2067 | non-buffered | |
2068 | ||
2069 | `_IOLBF' | |
2070 | line buffered | |
2071 | ||
2072 | `_IOFBF' | |
2073 | block buffered, using a newly allocated buffer of SIZE bytes. | |
2074 | However if SIZE is zero or unspecified, the port will be made | |
2075 | non-buffered. | |
2076 | ||
2077 | This procedure should not be used after I/O has been performed with | |
2078 | the port. | |
2079 | ||
2080 | Ports are usually block buffered by default, with a default buffer | |
2081 | size. Procedures e.g., *Note open-file: File Ports, which accept a | |
2082 | mode string allow `0' to be added to request an unbuffered port. | |
2083 | ||
e2d6569c | 2084 | *** procedure: fsync PORT/FD |
6afcd3b2 GH |
2085 | Copies any unwritten data for the specified output file descriptor |
2086 | to disk. If PORT/FD is a port, its buffer is flushed before the | |
2087 | underlying file descriptor is fsync'd. The return value is | |
2088 | unspecified. | |
2089 | ||
e2d6569c | 2090 | *** procedure: open-fdes PATH FLAGS [MODES] |
6afcd3b2 GH |
2091 | Similar to `open' but returns a file descriptor instead of a port. |
2092 | ||
e2d6569c | 2093 | *** procedure: execle PATH ENV [ARG] ... |
6afcd3b2 GH |
2094 | Similar to `execl', but the environment of the new process is |
2095 | specified by ENV, which must be a list of strings as returned by | |
2096 | the `environ' procedure. | |
2097 | ||
2098 | This procedure is currently implemented using the `execve' system | |
2099 | call, but we call it `execle' because of its Scheme calling | |
2100 | interface. | |
2101 | ||
e2d6569c | 2102 | *** procedure: strerror ERRNO |
ec4ab4fd GH |
2103 | Returns the Unix error message corresponding to ERRNO, an integer. |
2104 | ||
e2d6569c | 2105 | *** procedure: primitive-exit [STATUS] |
6afcd3b2 GH |
2106 | Terminate the current process without unwinding the Scheme stack. |
2107 | This is would typically be useful after a fork. The exit status | |
2108 | is STATUS if supplied, otherwise zero. | |
2109 | ||
e2d6569c | 2110 | *** procedure: times |
6afcd3b2 GH |
2111 | Returns an object with information about real and processor time. |
2112 | The following procedures accept such an object as an argument and | |
2113 | return a selected component: | |
2114 | ||
2115 | `tms:clock' | |
2116 | The current real time, expressed as time units relative to an | |
2117 | arbitrary base. | |
2118 | ||
2119 | `tms:utime' | |
2120 | The CPU time units used by the calling process. | |
2121 | ||
2122 | `tms:stime' | |
2123 | The CPU time units used by the system on behalf of the | |
2124 | calling process. | |
2125 | ||
2126 | `tms:cutime' | |
2127 | The CPU time units used by terminated child processes of the | |
2128 | calling process, whose status has been collected (e.g., using | |
2129 | `waitpid'). | |
2130 | ||
2131 | `tms:cstime' | |
2132 | Similarly, the CPU times units used by the system on behalf of | |
2133 | terminated child processes. | |
7ad3c1e7 | 2134 | |
e2d6569c JB |
2135 | ** Removed: list-length |
2136 | ** Removed: list-append, list-append! | |
2137 | ** Removed: list-reverse, list-reverse! | |
2138 | ||
2139 | ** array-map renamed to array-map! | |
2140 | ||
2141 | ** serial-array-map renamed to serial-array-map! | |
2142 | ||
660f41fa MD |
2143 | ** catch doesn't take #f as first argument any longer |
2144 | ||
2145 | Previously, it was possible to pass #f instead of a key to `catch'. | |
2146 | That would cause `catch' to pass a jump buffer object to the procedure | |
2147 | passed as second argument. The procedure could then use this jump | |
2148 | buffer objekt as an argument to throw. | |
2149 | ||
2150 | This mechanism has been removed since its utility doesn't motivate the | |
2151 | extra complexity it introduces. | |
2152 | ||
332d00f6 JB |
2153 | ** The `#/' notation for lists now provokes a warning message from Guile. |
2154 | This syntax will be removed from Guile in the near future. | |
2155 | ||
2156 | To disable the warning message, set the GUILE_HUSH environment | |
2157 | variable to any non-empty value. | |
2158 | ||
8cd57bd0 JB |
2159 | ** The newline character now prints as `#\newline', following the |
2160 | normal Scheme notation, not `#\nl'. | |
2161 | ||
c484bf7f JB |
2162 | * Changes to the gh_ interface |
2163 | ||
8986901b JB |
2164 | ** The gh_enter function now takes care of loading the Guile startup files. |
2165 | gh_enter works by calling scm_boot_guile; see the remarks below. | |
2166 | ||
5424b4f7 MD |
2167 | ** Function: void gh_write (SCM x) |
2168 | ||
2169 | Write the printed representation of the scheme object x to the current | |
2170 | output port. Corresponds to the scheme level `write'. | |
2171 | ||
3a97e020 MD |
2172 | ** gh_list_length renamed to gh_length. |
2173 | ||
8d6787b6 MG |
2174 | ** vector handling routines |
2175 | ||
2176 | Several major changes. In particular, gh_vector() now resembles | |
2177 | (vector ...) (with a caveat -- see manual), and gh_make_vector() now | |
956328d2 MG |
2178 | exists and behaves like (make-vector ...). gh_vset() and gh_vref() |
2179 | have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing | |
8d6787b6 MG |
2180 | vector-related gh_ functions have been implemented. |
2181 | ||
7fee59bd MG |
2182 | ** pair and list routines |
2183 | ||
2184 | Implemented several of the R4RS pair and list functions that were | |
2185 | missing. | |
2186 | ||
171422a9 MD |
2187 | ** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect |
2188 | ||
2189 | New function. Converts double arrays back and forth between Scheme | |
2190 | and C. | |
2191 | ||
c484bf7f JB |
2192 | * Changes to the scm_ interface |
2193 | ||
8986901b JB |
2194 | ** The function scm_boot_guile now takes care of loading the startup files. |
2195 | ||
2196 | Guile's primary initialization function, scm_boot_guile, now takes | |
2197 | care of loading `boot-9.scm', in the `ice-9' module, to initialize | |
2198 | Guile, define the module system, and put together some standard | |
2199 | bindings. It also loads `init.scm', which is intended to hold | |
2200 | site-specific initialization code. | |
2201 | ||
2202 | Since Guile cannot operate properly until boot-9.scm is loaded, there | |
2203 | is no reason to separate loading boot-9.scm from Guile's other | |
2204 | initialization processes. | |
2205 | ||
2206 | This job used to be done by scm_compile_shell_switches, which didn't | |
2207 | make much sense; in particular, it meant that people using Guile for | |
2208 | non-shell-like applications had to jump through hoops to get Guile | |
2209 | initialized properly. | |
2210 | ||
2211 | ** The function scm_compile_shell_switches no longer loads the startup files. | |
2212 | Now, Guile always loads the startup files, whenever it is initialized; | |
2213 | see the notes above for scm_boot_guile and scm_load_startup_files. | |
2214 | ||
2215 | ** Function: scm_load_startup_files | |
2216 | This new function takes care of loading Guile's initialization file | |
2217 | (`boot-9.scm'), and the site initialization file, `init.scm'. Since | |
2218 | this is always called by the Guile initialization process, it's | |
2219 | probably not too useful to call this yourself, but it's there anyway. | |
2220 | ||
87148d9e JB |
2221 | ** The semantics of smob marking have changed slightly. |
2222 | ||
2223 | The smob marking function (the `mark' member of the scm_smobfuns | |
2224 | structure) is no longer responsible for setting the mark bit on the | |
2225 | smob. The generic smob handling code in the garbage collector will | |
2226 | set this bit. The mark function need only ensure that any other | |
2227 | objects the smob refers to get marked. | |
2228 | ||
2229 | Note that this change means that the smob's GC8MARK bit is typically | |
2230 | already set upon entry to the mark function. Thus, marking functions | |
2231 | which look like this: | |
2232 | ||
2233 | { | |
2234 | if (SCM_GC8MARKP (ptr)) | |
2235 | return SCM_BOOL_F; | |
2236 | SCM_SETGC8MARK (ptr); | |
2237 | ... mark objects to which the smob refers ... | |
2238 | } | |
2239 | ||
2240 | are now incorrect, since they will return early, and fail to mark any | |
2241 | other objects the smob refers to. Some code in the Guile library used | |
2242 | to work this way. | |
2243 | ||
1cf84ea5 JB |
2244 | ** The semantics of the I/O port functions in scm_ptobfuns have changed. |
2245 | ||
2246 | If you have implemented your own I/O port type, by writing the | |
2247 | functions required by the scm_ptobfuns and then calling scm_newptob, | |
2248 | you will need to change your functions slightly. | |
2249 | ||
2250 | The functions in a scm_ptobfuns structure now expect the port itself | |
2251 | as their argument; they used to expect the `stream' member of the | |
2252 | port's scm_port_table structure. This allows functions in an | |
2253 | scm_ptobfuns structure to easily access the port's cell (and any flags | |
2254 | it its CAR), and the port's scm_port_table structure. | |
2255 | ||
2256 | Guile now passes the I/O port itself as the `port' argument in the | |
2257 | following scm_ptobfuns functions: | |
2258 | ||
2259 | int (*free) (SCM port); | |
2260 | int (*fputc) (int, SCM port); | |
2261 | int (*fputs) (char *, SCM port); | |
2262 | scm_sizet (*fwrite) SCM_P ((char *ptr, | |
2263 | scm_sizet size, | |
2264 | scm_sizet nitems, | |
2265 | SCM port)); | |
2266 | int (*fflush) (SCM port); | |
2267 | int (*fgetc) (SCM port); | |
2268 | int (*fclose) (SCM port); | |
2269 | ||
2270 | The interfaces to the `mark', `print', `equalp', and `fgets' methods | |
2271 | are unchanged. | |
2272 | ||
2273 | If you have existing code which defines its own port types, it is easy | |
2274 | to convert your code to the new interface; simply apply SCM_STREAM to | |
2275 | the port argument to yield the value you code used to expect. | |
2276 | ||
2277 | Note that since both the port and the stream have the same type in the | |
2278 | C code --- they are both SCM values --- the C compiler will not remind | |
2279 | you if you forget to update your scm_ptobfuns functions. | |
2280 | ||
2281 | ||
933a7411 MD |
2282 | ** Function: int scm_internal_select (int fds, |
2283 | SELECT_TYPE *rfds, | |
2284 | SELECT_TYPE *wfds, | |
2285 | SELECT_TYPE *efds, | |
2286 | struct timeval *timeout); | |
2287 | ||
2288 | This is a replacement for the `select' function provided by the OS. | |
2289 | It enables I/O blocking and sleeping to happen for one cooperative | |
2290 | thread without blocking other threads. It also avoids busy-loops in | |
2291 | these situations. It is intended that all I/O blocking and sleeping | |
2292 | will finally go through this function. Currently, this function is | |
2293 | only available on systems providing `gettimeofday' and `select'. | |
2294 | ||
5424b4f7 MD |
2295 | ** Function: SCM scm_internal_stack_catch (SCM tag, |
2296 | scm_catch_body_t body, | |
2297 | void *body_data, | |
2298 | scm_catch_handler_t handler, | |
2299 | void *handler_data) | |
2300 | ||
2301 | A new sibling to the other two C level `catch' functions | |
2302 | scm_internal_catch and scm_internal_lazy_catch. Use it if you want | |
2303 | the stack to be saved automatically into the variable `the-last-stack' | |
2304 | (scm_the_last_stack_var) on error. This is necessary if you want to | |
2305 | use advanced error reporting, such as calling scm_display_error and | |
2306 | scm_display_backtrace. (They both take a stack object as argument.) | |
2307 | ||
df366c26 MD |
2308 | ** Function: SCM scm_spawn_thread (scm_catch_body_t body, |
2309 | void *body_data, | |
2310 | scm_catch_handler_t handler, | |
2311 | void *handler_data) | |
2312 | ||
2313 | Spawns a new thread. It does a job similar to | |
2314 | scm_call_with_new_thread but takes arguments more suitable when | |
2315 | spawning threads from application C code. | |
2316 | ||
88482b31 MD |
2317 | ** The hook scm_error_callback has been removed. It was originally |
2318 | intended as a way for the user to install his own error handler. But | |
2319 | that method works badly since it intervenes between throw and catch, | |
2320 | thereby changing the semantics of expressions like (catch #t ...). | |
2321 | The correct way to do it is to use one of the C level catch functions | |
2322 | in throw.c: scm_internal_catch/lazy_catch/stack_catch. | |
2323 | ||
3a97e020 MD |
2324 | ** Removed functions: |
2325 | ||
2326 | scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x, | |
2327 | scm_list_reverse, scm_list_reverse_x | |
2328 | ||
2329 | ** New macros: SCM_LISTn where n is one of the integers 0-9. | |
2330 | ||
2331 | These can be used for pretty list creation from C. The idea is taken | |
2332 | from Erick Gallesio's STk. | |
2333 | ||
298aa6e3 MD |
2334 | ** scm_array_map renamed to scm_array_map_x |
2335 | ||
527da704 MD |
2336 | ** mbstrings are now removed |
2337 | ||
2338 | This means that the type codes scm_tc7_mb_string and | |
2339 | scm_tc7_mb_substring has been removed. | |
2340 | ||
8cd57bd0 JB |
2341 | ** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed. |
2342 | ||
2343 | Since we no longer support multi-byte strings, these I/O functions | |
2344 | have been simplified, and renamed. Here are their old names, and | |
2345 | their new names and arguments: | |
2346 | ||
2347 | scm_gen_putc -> void scm_putc (int c, SCM port); | |
2348 | scm_gen_puts -> void scm_puts (char *s, SCM port); | |
2349 | scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port); | |
2350 | scm_gen_getc -> void scm_getc (SCM port); | |
2351 | ||
2352 | ||
527da704 MD |
2353 | ** The macros SCM_TYP7D and SCM_TYP7SD has been removed. |
2354 | ||
2355 | ** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D | |
2356 | ||
2357 | SCM_TYP7S now masks away the bit which distinguishes substrings from | |
2358 | strings. | |
2359 | ||
660f41fa MD |
2360 | ** scm_catch_body_t: Backward incompatible change! |
2361 | ||
2362 | Body functions to scm_internal_catch and friends do not any longer | |
2363 | take a second argument. This is because it is no longer possible to | |
2364 | pass a #f arg to catch. | |
2365 | ||
a8e05009 JB |
2366 | ** Calls to scm_protect_object and scm_unprotect now nest properly. |
2367 | ||
2368 | The function scm_protect_object protects its argument from being freed | |
2369 | by the garbage collector. scm_unprotect_object removes that | |
2370 | protection. | |
2371 | ||
2372 | These functions now nest properly. That is, for every object O, there | |
2373 | is a counter which scm_protect_object(O) increments and | |
2374 | scm_unprotect_object(O) decrements, if the counter is greater than | |
2375 | zero. Every object's counter is zero when it is first created. If an | |
2376 | object's counter is greater than zero, the garbage collector will not | |
2377 | reclaim its storage. | |
2378 | ||
2379 | This allows you to use scm_protect_object in your code without | |
2380 | worrying that some other function you call will call | |
2381 | scm_unprotect_object, and allow it to be freed. Assuming that the | |
2382 | functions you call are well-behaved, and unprotect only those objects | |
2383 | they protect, you can follow the same rule and have confidence that | |
2384 | objects will be freed only at appropriate times. | |
2385 | ||
c484bf7f JB |
2386 | \f |
2387 | Changes in Guile 1.2 (released Tuesday, June 24 1997): | |
cf78e9e8 | 2388 | |
737c9113 JB |
2389 | * Changes to the distribution |
2390 | ||
832b09ed JB |
2391 | ** Nightly snapshots are now available from ftp.red-bean.com. |
2392 | The old server, ftp.cyclic.com, has been relinquished to its rightful | |
2393 | owner. | |
2394 | ||
2395 | Nightly snapshots of the Guile development sources are now available via | |
2396 | anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz. | |
2397 | ||
2398 | Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz | |
2399 | For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz | |
2400 | ||
0fcab5ed JB |
2401 | ** To run Guile without installing it, the procedure has changed a bit. |
2402 | ||
2403 | If you used a separate build directory to compile Guile, you'll need | |
2404 | to include the build directory in SCHEME_LOAD_PATH, as well as the | |
2405 | source directory. See the `INSTALL' file for examples. | |
2406 | ||
737c9113 JB |
2407 | * Changes to the procedure for linking libguile with your programs |
2408 | ||
94982a4e JB |
2409 | ** The standard Guile load path for Scheme code now includes |
2410 | $(datadir)/guile (usually /usr/local/share/guile). This means that | |
2411 | you can install your own Scheme files there, and Guile will find them. | |
2412 | (Previous versions of Guile only checked a directory whose name | |
2413 | contained the Guile version number, so you had to re-install or move | |
2414 | your Scheme sources each time you installed a fresh version of Guile.) | |
2415 | ||
2416 | The load path also includes $(datadir)/guile/site; we recommend | |
2417 | putting individual Scheme files there. If you want to install a | |
2418 | package with multiple source files, create a directory for them under | |
2419 | $(datadir)/guile. | |
2420 | ||
2421 | ** Guile 1.2 will now use the Rx regular expression library, if it is | |
2422 | installed on your system. When you are linking libguile into your own | |
2423 | programs, this means you will have to link against -lguile, -lqt (if | |
2424 | you configured Guile with thread support), and -lrx. | |
27590f82 JB |
2425 | |
2426 | If you are using autoconf to generate configuration scripts for your | |
2427 | application, the following lines should suffice to add the appropriate | |
2428 | libraries to your link command: | |
2429 | ||
2430 | ### Find Rx, quickthreads and libguile. | |
2431 | AC_CHECK_LIB(rx, main) | |
2432 | AC_CHECK_LIB(qt, main) | |
2433 | AC_CHECK_LIB(guile, scm_shell) | |
2434 | ||
94982a4e JB |
2435 | The Guile 1.2 distribution does not contain sources for the Rx |
2436 | library, as Guile 1.0 did. If you want to use Rx, you'll need to | |
2437 | retrieve it from a GNU FTP site and install it separately. | |
2438 | ||
b83b8bee JB |
2439 | * Changes to Scheme functions and syntax |
2440 | ||
e035e7e6 MV |
2441 | ** The dynamic linking features of Guile are now enabled by default. |
2442 | You can disable them by giving the `--disable-dynamic-linking' option | |
2443 | to configure. | |
2444 | ||
e035e7e6 MV |
2445 | (dynamic-link FILENAME) |
2446 | ||
2447 | Find the object file denoted by FILENAME (a string) and link it | |
2448 | into the running Guile application. When everything works out, | |
2449 | return a Scheme object suitable for representing the linked object | |
2450 | file. Otherwise an error is thrown. How object files are | |
2451 | searched is system dependent. | |
2452 | ||
2453 | (dynamic-object? VAL) | |
2454 | ||
2455 | Determine whether VAL represents a dynamically linked object file. | |
2456 | ||
2457 | (dynamic-unlink DYNOBJ) | |
2458 | ||
2459 | Unlink the indicated object file from the application. DYNOBJ | |
2460 | should be one of the values returned by `dynamic-link'. | |
2461 | ||
2462 | (dynamic-func FUNCTION DYNOBJ) | |
2463 | ||
2464 | Search the C function indicated by FUNCTION (a string or symbol) | |
2465 | in DYNOBJ and return some Scheme object that can later be used | |
2466 | with `dynamic-call' to actually call this function. Right now, | |
2467 | these Scheme objects are formed by casting the address of the | |
2468 | function to `long' and converting this number to its Scheme | |
2469 | representation. | |
2470 | ||
2471 | (dynamic-call FUNCTION DYNOBJ) | |
2472 | ||
2473 | Call the C function indicated by FUNCTION and DYNOBJ. The | |
2474 | function is passed no arguments and its return value is ignored. | |
2475 | When FUNCTION is something returned by `dynamic-func', call that | |
2476 | function and ignore DYNOBJ. When FUNCTION is a string (or symbol, | |
2477 | etc.), look it up in DYNOBJ; this is equivalent to | |
2478 | ||
2479 | (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f) | |
2480 | ||
2481 | Interrupts are deferred while the C function is executing (with | |
2482 | SCM_DEFER_INTS/SCM_ALLOW_INTS). | |
2483 | ||
2484 | (dynamic-args-call FUNCTION DYNOBJ ARGS) | |
2485 | ||
2486 | Call the C function indicated by FUNCTION and DYNOBJ, but pass it | |
2487 | some arguments and return its return value. The C function is | |
2488 | expected to take two arguments and return an `int', just like | |
2489 | `main': | |
2490 | ||
2491 | int c_func (int argc, char **argv); | |
2492 | ||
2493 | ARGS must be a list of strings and is converted into an array of | |
2494 | `char *'. The array is passed in ARGV and its size in ARGC. The | |
2495 | return value is converted to a Scheme number and returned from the | |
2496 | call to `dynamic-args-call'. | |
2497 | ||
0fcab5ed JB |
2498 | When dynamic linking is disabled or not supported on your system, |
2499 | the above functions throw errors, but they are still available. | |
2500 | ||
e035e7e6 MV |
2501 | Here is a small example that works on GNU/Linux: |
2502 | ||
2503 | (define libc-obj (dynamic-link "libc.so")) | |
2504 | (dynamic-args-call 'rand libc-obj '()) | |
2505 | ||
2506 | See the file `libguile/DYNAMIC-LINKING' for additional comments. | |
2507 | ||
27590f82 JB |
2508 | ** The #/ syntax for module names is depreciated, and will be removed |
2509 | in a future version of Guile. Instead of | |
2510 | ||
2511 | #/foo/bar/baz | |
2512 | ||
2513 | instead write | |
2514 | ||
2515 | (foo bar baz) | |
2516 | ||
2517 | The latter syntax is more consistent with existing Lisp practice. | |
2518 | ||
5dade857 MV |
2519 | ** Guile now does fancier printing of structures. Structures are the |
2520 | underlying implementation for records, which in turn are used to | |
2521 | implement modules, so all of these object now print differently and in | |
2522 | a more informative way. | |
2523 | ||
161029df JB |
2524 | The Scheme printer will examine the builtin variable *struct-printer* |
2525 | whenever it needs to print a structure object. When this variable is | |
2526 | not `#f' it is deemed to be a procedure and will be applied to the | |
2527 | structure object and the output port. When *struct-printer* is `#f' | |
2528 | or the procedure return `#f' the structure object will be printed in | |
2529 | the boring #<struct 80458270> form. | |
5dade857 MV |
2530 | |
2531 | This hook is used by some routines in ice-9/boot-9.scm to implement | |
2532 | type specific printing routines. Please read the comments there about | |
2533 | "printing structs". | |
2534 | ||
2535 | One of the more specific uses of structs are records. The printing | |
2536 | procedure that could be passed to MAKE-RECORD-TYPE is now actually | |
2537 | called. It should behave like a *struct-printer* procedure (described | |
2538 | above). | |
2539 | ||
b83b8bee JB |
2540 | ** Guile now supports a new R4RS-compliant syntax for keywords. A |
2541 | token of the form #:NAME, where NAME has the same syntax as a Scheme | |
2542 | symbol, is the external representation of the keyword named NAME. | |
2543 | Keyword objects print using this syntax as well, so values containing | |
1e5afba0 JB |
2544 | keyword objects can be read back into Guile. When used in an |
2545 | expression, keywords are self-quoting objects. | |
b83b8bee JB |
2546 | |
2547 | Guile suports this read syntax, and uses this print syntax, regardless | |
2548 | of the current setting of the `keyword' read option. The `keyword' | |
2549 | read option only controls whether Guile recognizes the `:NAME' syntax, | |
2550 | which is incompatible with R4RS. (R4RS says such token represent | |
2551 | symbols.) | |
737c9113 JB |
2552 | |
2553 | ** Guile has regular expression support again. Guile 1.0 included | |
2554 | functions for matching regular expressions, based on the Rx library. | |
2555 | In Guile 1.1, the Guile/Rx interface was removed to simplify the | |
2556 | distribution, and thus Guile had no regular expression support. Guile | |
94982a4e JB |
2557 | 1.2 again supports the most commonly used functions, and supports all |
2558 | of SCSH's regular expression functions. | |
2409cdfa | 2559 | |
94982a4e JB |
2560 | If your system does not include a POSIX regular expression library, |
2561 | and you have not linked Guile with a third-party regexp library such as | |
2562 | Rx, these functions will not be available. You can tell whether your | |
2563 | Guile installation includes regular expression support by checking | |
2564 | whether the `*features*' list includes the `regex' symbol. | |
737c9113 | 2565 | |
94982a4e | 2566 | *** regexp functions |
161029df | 2567 | |
94982a4e JB |
2568 | By default, Guile supports POSIX extended regular expressions. That |
2569 | means that the characters `(', `)', `+' and `?' are special, and must | |
2570 | be escaped if you wish to match the literal characters. | |
e1a191a8 | 2571 | |
94982a4e JB |
2572 | This regular expression interface was modeled after that implemented |
2573 | by SCSH, the Scheme Shell. It is intended to be upwardly compatible | |
2574 | with SCSH regular expressions. | |
2575 | ||
2576 | **** Function: string-match PATTERN STR [START] | |
2577 | Compile the string PATTERN into a regular expression and compare | |
2578 | it with STR. The optional numeric argument START specifies the | |
2579 | position of STR at which to begin matching. | |
2580 | ||
2581 | `string-match' returns a "match structure" which describes what, | |
2582 | if anything, was matched by the regular expression. *Note Match | |
2583 | Structures::. If STR does not match PATTERN at all, | |
2584 | `string-match' returns `#f'. | |
2585 | ||
2586 | Each time `string-match' is called, it must compile its PATTERN | |
2587 | argument into a regular expression structure. This operation is | |
2588 | expensive, which makes `string-match' inefficient if the same regular | |
2589 | expression is used several times (for example, in a loop). For better | |
2590 | performance, you can compile a regular expression in advance and then | |
2591 | match strings against the compiled regexp. | |
2592 | ||
2593 | **** Function: make-regexp STR [FLAGS] | |
2594 | Compile the regular expression described by STR, and return the | |
2595 | compiled regexp structure. If STR does not describe a legal | |
2596 | regular expression, `make-regexp' throws a | |
2597 | `regular-expression-syntax' error. | |
2598 | ||
2599 | FLAGS may be the bitwise-or of one or more of the following: | |
2600 | ||
2601 | **** Constant: regexp/extended | |
2602 | Use POSIX Extended Regular Expression syntax when interpreting | |
2603 | STR. If not set, POSIX Basic Regular Expression syntax is used. | |
2604 | If the FLAGS argument is omitted, we assume regexp/extended. | |
2605 | ||
2606 | **** Constant: regexp/icase | |
2607 | Do not differentiate case. Subsequent searches using the | |
2608 | returned regular expression will be case insensitive. | |
2609 | ||
2610 | **** Constant: regexp/newline | |
2611 | Match-any-character operators don't match a newline. | |
2612 | ||
2613 | A non-matching list ([^...]) not containing a newline matches a | |
2614 | newline. | |
2615 | ||
2616 | Match-beginning-of-line operator (^) matches the empty string | |
2617 | immediately after a newline, regardless of whether the FLAGS | |
2618 | passed to regexp-exec contain regexp/notbol. | |
2619 | ||
2620 | Match-end-of-line operator ($) matches the empty string | |
2621 | immediately before a newline, regardless of whether the FLAGS | |
2622 | passed to regexp-exec contain regexp/noteol. | |
2623 | ||
2624 | **** Function: regexp-exec REGEXP STR [START [FLAGS]] | |
2625 | Match the compiled regular expression REGEXP against `str'. If | |
2626 | the optional integer START argument is provided, begin matching | |
2627 | from that position in the string. Return a match structure | |
2628 | describing the results of the match, or `#f' if no match could be | |
2629 | found. | |
2630 | ||
2631 | FLAGS may be the bitwise-or of one or more of the following: | |
2632 | ||
2633 | **** Constant: regexp/notbol | |
2634 | The match-beginning-of-line operator always fails to match (but | |
2635 | see the compilation flag regexp/newline above) This flag may be | |
2636 | used when different portions of a string are passed to | |
2637 | regexp-exec and the beginning of the string should not be | |
2638 | interpreted as the beginning of the line. | |
2639 | ||
2640 | **** Constant: regexp/noteol | |
2641 | The match-end-of-line operator always fails to match (but see the | |
2642 | compilation flag regexp/newline above) | |
2643 | ||
2644 | **** Function: regexp? OBJ | |
2645 | Return `#t' if OBJ is a compiled regular expression, or `#f' | |
2646 | otherwise. | |
2647 | ||
2648 | Regular expressions are commonly used to find patterns in one string | |
2649 | and replace them with the contents of another string. | |
2650 | ||
2651 | **** Function: regexp-substitute PORT MATCH [ITEM...] | |
2652 | Write to the output port PORT selected contents of the match | |
2653 | structure MATCH. Each ITEM specifies what should be written, and | |
2654 | may be one of the following arguments: | |
2655 | ||
2656 | * A string. String arguments are written out verbatim. | |
2657 | ||
2658 | * An integer. The submatch with that number is written. | |
2659 | ||
2660 | * The symbol `pre'. The portion of the matched string preceding | |
2661 | the regexp match is written. | |
2662 | ||
2663 | * The symbol `post'. The portion of the matched string | |
2664 | following the regexp match is written. | |
2665 | ||
2666 | PORT may be `#f', in which case nothing is written; instead, | |
2667 | `regexp-substitute' constructs a string from the specified ITEMs | |
2668 | and returns that. | |
2669 | ||
2670 | **** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...] | |
2671 | Similar to `regexp-substitute', but can be used to perform global | |
2672 | substitutions on STR. Instead of taking a match structure as an | |
2673 | argument, `regexp-substitute/global' takes two string arguments: a | |
2674 | REGEXP string describing a regular expression, and a TARGET string | |
2675 | which should be matched against this regular expression. | |
2676 | ||
2677 | Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following | |
2678 | exceptions: | |
2679 | ||
2680 | * A function may be supplied. When this function is called, it | |
2681 | will be passed one argument: a match structure for a given | |
2682 | regular expression match. It should return a string to be | |
2683 | written out to PORT. | |
2684 | ||
2685 | * The `post' symbol causes `regexp-substitute/global' to recurse | |
2686 | on the unmatched portion of STR. This *must* be supplied in | |
2687 | order to perform global search-and-replace on STR; if it is | |
2688 | not present among the ITEMs, then `regexp-substitute/global' | |
2689 | will return after processing a single match. | |
2690 | ||
2691 | *** Match Structures | |
2692 | ||
2693 | A "match structure" is the object returned by `string-match' and | |
2694 | `regexp-exec'. It describes which portion of a string, if any, matched | |
2695 | the given regular expression. Match structures include: a reference to | |
2696 | the string that was checked for matches; the starting and ending | |
2697 | positions of the regexp match; and, if the regexp included any | |
2698 | parenthesized subexpressions, the starting and ending positions of each | |
2699 | submatch. | |
2700 | ||
2701 | In each of the regexp match functions described below, the `match' | |
2702 | argument must be a match structure returned by a previous call to | |
2703 | `string-match' or `regexp-exec'. Most of these functions return some | |
2704 | information about the original target string that was matched against a | |
2705 | regular expression; we will call that string TARGET for easy reference. | |
2706 | ||
2707 | **** Function: regexp-match? OBJ | |
2708 | Return `#t' if OBJ is a match structure returned by a previous | |
2709 | call to `regexp-exec', or `#f' otherwise. | |
2710 | ||
2711 | **** Function: match:substring MATCH [N] | |
2712 | Return the portion of TARGET matched by subexpression number N. | |
2713 | Submatch 0 (the default) represents the entire regexp match. If | |
2714 | the regular expression as a whole matched, but the subexpression | |
2715 | number N did not match, return `#f'. | |
2716 | ||
2717 | **** Function: match:start MATCH [N] | |
2718 | Return the starting position of submatch number N. | |
2719 | ||
2720 | **** Function: match:end MATCH [N] | |
2721 | Return the ending position of submatch number N. | |
2722 | ||
2723 | **** Function: match:prefix MATCH | |
2724 | Return the unmatched portion of TARGET preceding the regexp match. | |
2725 | ||
2726 | **** Function: match:suffix MATCH | |
2727 | Return the unmatched portion of TARGET following the regexp match. | |
2728 | ||
2729 | **** Function: match:count MATCH | |
2730 | Return the number of parenthesized subexpressions from MATCH. | |
2731 | Note that the entire regular expression match itself counts as a | |
2732 | subexpression, and failed submatches are included in the count. | |
2733 | ||
2734 | **** Function: match:string MATCH | |
2735 | Return the original TARGET string. | |
2736 | ||
2737 | *** Backslash Escapes | |
2738 | ||
2739 | Sometimes you will want a regexp to match characters like `*' or `$' | |
2740 | exactly. For example, to check whether a particular string represents | |
2741 | a menu entry from an Info node, it would be useful to match it against | |
2742 | a regexp like `^* [^:]*::'. However, this won't work; because the | |
2743 | asterisk is a metacharacter, it won't match the `*' at the beginning of | |
2744 | the string. In this case, we want to make the first asterisk un-magic. | |
2745 | ||
2746 | You can do this by preceding the metacharacter with a backslash | |
2747 | character `\'. (This is also called "quoting" the metacharacter, and | |
2748 | is known as a "backslash escape".) When Guile sees a backslash in a | |
2749 | regular expression, it considers the following glyph to be an ordinary | |
2750 | character, no matter what special meaning it would ordinarily have. | |
2751 | Therefore, we can make the above example work by changing the regexp to | |
2752 | `^\* [^:]*::'. The `\*' sequence tells the regular expression engine | |
2753 | to match only a single asterisk in the target string. | |
2754 | ||
2755 | Since the backslash is itself a metacharacter, you may force a | |
2756 | regexp to match a backslash in the target string by preceding the | |
2757 | backslash with itself. For example, to find variable references in a | |
2758 | TeX program, you might want to find occurrences of the string `\let\' | |
2759 | followed by any number of alphabetic characters. The regular expression | |
2760 | `\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp | |
2761 | each match a single backslash in the target string. | |
2762 | ||
2763 | **** Function: regexp-quote STR | |
2764 | Quote each special character found in STR with a backslash, and | |
2765 | return the resulting string. | |
2766 | ||
2767 | *Very important:* Using backslash escapes in Guile source code (as | |
2768 | in Emacs Lisp or C) can be tricky, because the backslash character has | |
2769 | special meaning for the Guile reader. For example, if Guile encounters | |
2770 | the character sequence `\n' in the middle of a string while processing | |
2771 | Scheme code, it replaces those characters with a newline character. | |
2772 | Similarly, the character sequence `\t' is replaced by a horizontal tab. | |
2773 | Several of these "escape sequences" are processed by the Guile reader | |
2774 | before your code is executed. Unrecognized escape sequences are | |
2775 | ignored: if the characters `\*' appear in a string, they will be | |
2776 | translated to the single character `*'. | |
2777 | ||
2778 | This translation is obviously undesirable for regular expressions, | |
2779 | since we want to be able to include backslashes in a string in order to | |
2780 | escape regexp metacharacters. Therefore, to make sure that a backslash | |
2781 | is preserved in a string in your Guile program, you must use *two* | |
2782 | consecutive backslashes: | |
2783 | ||
2784 | (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*")) | |
2785 | ||
2786 | The string in this example is preprocessed by the Guile reader before | |
2787 | any code is executed. The resulting argument to `make-regexp' is the | |
2788 | string `^\* [^:]*', which is what we really want. | |
2789 | ||
2790 | This also means that in order to write a regular expression that | |
2791 | matches a single backslash character, the regular expression string in | |
2792 | the source code must include *four* backslashes. Each consecutive pair | |
2793 | of backslashes gets translated by the Guile reader to a single | |
2794 | backslash, and the resulting double-backslash is interpreted by the | |
2795 | regexp engine as matching a single backslash character. Hence: | |
2796 | ||
2797 | (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*")) | |
2798 | ||
2799 | The reason for the unwieldiness of this syntax is historical. Both | |
2800 | regular expression pattern matchers and Unix string processing systems | |
2801 | have traditionally used backslashes with the special meanings described | |
2802 | above. The POSIX regular expression specification and ANSI C standard | |
2803 | both require these semantics. Attempting to abandon either convention | |
2804 | would cause other kinds of compatibility problems, possibly more severe | |
2805 | ones. Therefore, without extending the Scheme reader to support | |
2806 | strings with different quoting conventions (an ungainly and confusing | |
2807 | extension when implemented in other languages), we must adhere to this | |
2808 | cumbersome escape syntax. | |
2809 | ||
7ad3c1e7 GH |
2810 | * Changes to the gh_ interface |
2811 | ||
2812 | * Changes to the scm_ interface | |
2813 | ||
2814 | * Changes to system call interfaces: | |
94982a4e | 2815 | |
7ad3c1e7 | 2816 | ** The value returned by `raise' is now unspecified. It throws an exception |
e1a191a8 GH |
2817 | if an error occurs. |
2818 | ||
94982a4e | 2819 | *** A new procedure `sigaction' can be used to install signal handlers |
115b09a5 GH |
2820 | |
2821 | (sigaction signum [action] [flags]) | |
2822 | ||
2823 | signum is the signal number, which can be specified using the value | |
2824 | of SIGINT etc. | |
2825 | ||
2826 | If action is omitted, sigaction returns a pair: the CAR is the current | |
2827 | signal hander, which will be either an integer with the value SIG_DFL | |
2828 | (default action) or SIG_IGN (ignore), or the Scheme procedure which | |
2829 | handles the signal, or #f if a non-Scheme procedure handles the | |
2830 | signal. The CDR contains the current sigaction flags for the handler. | |
2831 | ||
2832 | If action is provided, it is installed as the new handler for signum. | |
2833 | action can be a Scheme procedure taking one argument, or the value of | |
2834 | SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore | |
2835 | whatever signal handler was installed before sigaction was first used. | |
2836 | Flags can optionally be specified for the new handler (SA_RESTART is | |
2837 | always used if the system provides it, so need not be specified.) The | |
2838 | return value is a pair with information about the old handler as | |
2839 | described above. | |
2840 | ||
2841 | This interface does not provide access to the "signal blocking" | |
2842 | facility. Maybe this is not needed, since the thread support may | |
2843 | provide solutions to the problem of consistent access to data | |
2844 | structures. | |
e1a191a8 | 2845 | |
94982a4e | 2846 | *** A new procedure `flush-all-ports' is equivalent to running |
89ea5b7c GH |
2847 | `force-output' on every port open for output. |
2848 | ||
94982a4e JB |
2849 | ** Guile now provides information on how it was built, via the new |
2850 | global variable, %guile-build-info. This variable records the values | |
2851 | of the standard GNU makefile directory variables as an assocation | |
2852 | list, mapping variable names (symbols) onto directory paths (strings). | |
2853 | For example, to find out where the Guile link libraries were | |
2854 | installed, you can say: | |
2855 | ||
2856 | guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)" | |
2857 | ||
2858 | ||
2859 | * Changes to the scm_ interface | |
2860 | ||
2861 | ** The new function scm_handle_by_message_noexit is just like the | |
2862 | existing scm_handle_by_message function, except that it doesn't call | |
2863 | exit to terminate the process. Instead, it prints a message and just | |
2864 | returns #f. This might be a more appropriate catch-all handler for | |
2865 | new dynamic roots and threads. | |
2866 | ||
cf78e9e8 | 2867 | \f |
c484bf7f | 2868 | Changes in Guile 1.1 (released Friday, May 16 1997): |
f3b1485f JB |
2869 | |
2870 | * Changes to the distribution. | |
2871 | ||
2872 | The Guile 1.0 distribution has been split up into several smaller | |
2873 | pieces: | |
2874 | guile-core --- the Guile interpreter itself. | |
2875 | guile-tcltk --- the interface between the Guile interpreter and | |
2876 | Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk | |
2877 | is a toolkit for building graphical user interfaces. | |
2878 | guile-rgx-ctax --- the interface between Guile and the Rx regular | |
2879 | expression matcher, and the translator for the Ctax | |
2880 | programming language. These are packaged together because the | |
2881 | Ctax translator uses Rx to parse Ctax source code. | |
2882 | ||
095936d2 JB |
2883 | This NEWS file describes the changes made to guile-core since the 1.0 |
2884 | release. | |
2885 | ||
48d224d7 JB |
2886 | We no longer distribute the documentation, since it was either out of |
2887 | date, or incomplete. As soon as we have current documentation, we | |
2888 | will distribute it. | |
2889 | ||
0fcab5ed JB |
2890 | |
2891 | ||
f3b1485f JB |
2892 | * Changes to the stand-alone interpreter |
2893 | ||
48d224d7 JB |
2894 | ** guile now accepts command-line arguments compatible with SCSH, Olin |
2895 | Shivers' Scheme Shell. | |
2896 | ||
2897 | In general, arguments are evaluated from left to right, but there are | |
2898 | exceptions. The following switches stop argument processing, and | |
2899 | stash all remaining command-line arguments as the value returned by | |
2900 | the (command-line) function. | |
2901 | -s SCRIPT load Scheme source code from FILE, and exit | |
2902 | -c EXPR evalute Scheme expression EXPR, and exit | |
2903 | -- stop scanning arguments; run interactively | |
2904 | ||
2905 | The switches below are processed as they are encountered. | |
2906 | -l FILE load Scheme source code from FILE | |
2907 | -e FUNCTION after reading script, apply FUNCTION to | |
2908 | command line arguments | |
2909 | -ds do -s script at this point | |
2910 | --emacs enable Emacs protocol (experimental) | |
2911 | -h, --help display this help and exit | |
2912 | -v, --version display version information and exit | |
2913 | \ read arguments from following script lines | |
2914 | ||
2915 | So, for example, here is a Guile script named `ekko' (thanks, Olin) | |
2916 | which re-implements the traditional "echo" command: | |
2917 | ||
2918 | #!/usr/local/bin/guile -s | |
2919 | !# | |
2920 | (define (main args) | |
2921 | (map (lambda (arg) (display arg) (display " ")) | |
2922 | (cdr args)) | |
2923 | (newline)) | |
2924 | ||
2925 | (main (command-line)) | |
2926 | ||
2927 | Suppose we invoke this script as follows: | |
2928 | ||
2929 | ekko a speckled gecko | |
2930 | ||
2931 | Through the magic of Unix script processing (triggered by the `#!' | |
2932 | token at the top of the file), /usr/local/bin/guile receives the | |
2933 | following list of command-line arguments: | |
2934 | ||
2935 | ("-s" "./ekko" "a" "speckled" "gecko") | |
2936 | ||
2937 | Unix inserts the name of the script after the argument specified on | |
2938 | the first line of the file (in this case, "-s"), and then follows that | |
2939 | with the arguments given to the script. Guile loads the script, which | |
2940 | defines the `main' function, and then applies it to the list of | |
2941 | remaining command-line arguments, ("a" "speckled" "gecko"). | |
2942 | ||
095936d2 JB |
2943 | In Unix, the first line of a script file must take the following form: |
2944 | ||
2945 | #!INTERPRETER ARGUMENT | |
2946 | ||
2947 | where INTERPRETER is the absolute filename of the interpreter | |
2948 | executable, and ARGUMENT is a single command-line argument to pass to | |
2949 | the interpreter. | |
2950 | ||
2951 | You may only pass one argument to the interpreter, and its length is | |
2952 | limited. These restrictions can be annoying to work around, so Guile | |
2953 | provides a general mechanism (borrowed from, and compatible with, | |
2954 | SCSH) for circumventing them. | |
2955 | ||
2956 | If the ARGUMENT in a Guile script is a single backslash character, | |
2957 | `\', Guile will open the script file, parse arguments from its second | |
2958 | and subsequent lines, and replace the `\' with them. So, for example, | |
2959 | here is another implementation of the `ekko' script: | |
2960 | ||
2961 | #!/usr/local/bin/guile \ | |
2962 | -e main -s | |
2963 | !# | |
2964 | (define (main args) | |
2965 | (for-each (lambda (arg) (display arg) (display " ")) | |
2966 | (cdr args)) | |
2967 | (newline)) | |
2968 | ||
2969 | If the user invokes this script as follows: | |
2970 | ||
2971 | ekko a speckled gecko | |
2972 | ||
2973 | Unix expands this into | |
2974 | ||
2975 | /usr/local/bin/guile \ ekko a speckled gecko | |
2976 | ||
2977 | When Guile sees the `\' argument, it replaces it with the arguments | |
2978 | read from the second line of the script, producing: | |
2979 | ||
2980 | /usr/local/bin/guile -e main -s ekko a speckled gecko | |
2981 | ||
2982 | This tells Guile to load the `ekko' script, and apply the function | |
2983 | `main' to the argument list ("a" "speckled" "gecko"). | |
2984 | ||
2985 | Here is how Guile parses the command-line arguments: | |
2986 | - Each space character terminates an argument. This means that two | |
2987 | spaces in a row introduce an empty-string argument. | |
2988 | - The tab character is not permitted (unless you quote it with the | |
2989 | backslash character, as described below), to avoid confusion. | |
2990 | - The newline character terminates the sequence of arguments, and will | |
2991 | also terminate a final non-empty argument. (However, a newline | |
2992 | following a space will not introduce a final empty-string argument; | |
2993 | it only terminates the argument list.) | |
2994 | - The backslash character is the escape character. It escapes | |
2995 | backslash, space, tab, and newline. The ANSI C escape sequences | |
2996 | like \n and \t are also supported. These produce argument | |
2997 | constituents; the two-character combination \n doesn't act like a | |
2998 | terminating newline. The escape sequence \NNN for exactly three | |
2999 | octal digits reads as the character whose ASCII code is NNN. As | |
3000 | above, characters produced this way are argument constituents. | |
3001 | Backslash followed by other characters is not allowed. | |
3002 | ||
48d224d7 JB |
3003 | * Changes to the procedure for linking libguile with your programs |
3004 | ||
3005 | ** Guile now builds and installs a shared guile library, if your | |
3006 | system support shared libraries. (It still builds a static library on | |
3007 | all systems.) Guile automatically detects whether your system | |
3008 | supports shared libraries. To prevent Guile from buildisg shared | |
3009 | libraries, pass the `--disable-shared' flag to the configure script. | |
3010 | ||
3011 | Guile takes longer to compile when it builds shared libraries, because | |
3012 | it must compile every file twice --- once to produce position- | |
3013 | independent object code, and once to produce normal object code. | |
3014 | ||
3015 | ** The libthreads library has been merged into libguile. | |
3016 | ||
3017 | To link a program against Guile, you now need only link against | |
3018 | -lguile and -lqt; -lthreads is no longer needed. If you are using | |
3019 | autoconf to generate configuration scripts for your application, the | |
3020 | following lines should suffice to add the appropriate libraries to | |
3021 | your link command: | |
3022 | ||
3023 | ### Find quickthreads and libguile. | |
3024 | AC_CHECK_LIB(qt, main) | |
3025 | AC_CHECK_LIB(guile, scm_shell) | |
f3b1485f JB |
3026 | |
3027 | * Changes to Scheme functions | |
3028 | ||
095936d2 JB |
3029 | ** Guile Scheme's special syntax for keyword objects is now optional, |
3030 | and disabled by default. | |
3031 | ||
3032 | The syntax variation from R4RS made it difficult to port some | |
3033 | interesting packages to Guile. The routines which accepted keyword | |
3034 | arguments (mostly in the module system) have been modified to also | |
3035 | accept symbols whose names begin with `:'. | |
3036 | ||
3037 | To change the keyword syntax, you must first import the (ice-9 debug) | |
3038 | module: | |
3039 | (use-modules (ice-9 debug)) | |
3040 | ||
3041 | Then you can enable the keyword syntax as follows: | |
3042 | (read-set! keywords 'prefix) | |
3043 | ||
3044 | To disable keyword syntax, do this: | |
3045 | (read-set! keywords #f) | |
3046 | ||
3047 | ** Many more primitive functions accept shared substrings as | |
3048 | arguments. In the past, these functions required normal, mutable | |
3049 | strings as arguments, although they never made use of this | |
3050 | restriction. | |
3051 | ||
3052 | ** The uniform array functions now operate on byte vectors. These | |
3053 | functions are `array-fill!', `serial-array-copy!', `array-copy!', | |
3054 | `serial-array-map', `array-map', `array-for-each', and | |
3055 | `array-index-map!'. | |
3056 | ||
3057 | ** The new functions `trace' and `untrace' implement simple debugging | |
3058 | support for Scheme functions. | |
3059 | ||
3060 | The `trace' function accepts any number of procedures as arguments, | |
3061 | and tells the Guile interpreter to display each procedure's name and | |
3062 | arguments each time the procedure is invoked. When invoked with no | |
3063 | arguments, `trace' returns the list of procedures currently being | |
3064 | traced. | |
3065 | ||
3066 | The `untrace' function accepts any number of procedures as arguments, | |
3067 | and tells the Guile interpreter not to trace them any more. When | |
3068 | invoked with no arguments, `untrace' untraces all curretly traced | |
3069 | procedures. | |
3070 | ||
3071 | The tracing in Guile has an advantage over most other systems: we | |
3072 | don't create new procedure objects, but mark the procedure objects | |
3073 | themselves. This means that anonymous and internal procedures can be | |
3074 | traced. | |
3075 | ||
3076 | ** The function `assert-repl-prompt' has been renamed to | |
3077 | `set-repl-prompt!'. It takes one argument, PROMPT. | |
3078 | - If PROMPT is #f, the Guile read-eval-print loop will not prompt. | |
3079 | - If PROMPT is a string, we use it as a prompt. | |
3080 | - If PROMPT is a procedure accepting no arguments, we call it, and | |
3081 | display the result as a prompt. | |
3082 | - Otherwise, we display "> ". | |
3083 | ||
3084 | ** The new function `eval-string' reads Scheme expressions from a | |
3085 | string and evaluates them, returning the value of the last expression | |
3086 | in the string. If the string contains no expressions, it returns an | |
3087 | unspecified value. | |
3088 | ||
3089 | ** The new function `thunk?' returns true iff its argument is a | |
3090 | procedure of zero arguments. | |
3091 | ||
3092 | ** `defined?' is now a builtin function, instead of syntax. This | |
3093 | means that its argument should be quoted. It returns #t iff its | |
3094 | argument is bound in the current module. | |
3095 | ||
3096 | ** The new syntax `use-modules' allows you to add new modules to your | |
3097 | environment without re-typing a complete `define-module' form. It | |
3098 | accepts any number of module names as arguments, and imports their | |
3099 | public bindings into the current module. | |
3100 | ||
3101 | ** The new function (module-defined? NAME MODULE) returns true iff | |
3102 | NAME, a symbol, is defined in MODULE, a module object. | |
3103 | ||
3104 | ** The new function `builtin-bindings' creates and returns a hash | |
3105 | table containing copies of all the root module's bindings. | |
3106 | ||
3107 | ** The new function `builtin-weak-bindings' does the same as | |
3108 | `builtin-bindings', but creates a doubly-weak hash table. | |
3109 | ||
3110 | ** The `equal?' function now considers variable objects to be | |
3111 | equivalent if they have the same name and the same value. | |
3112 | ||
3113 | ** The new function `command-line' returns the command-line arguments | |
3114 | given to Guile, as a list of strings. | |
3115 | ||
3116 | When using guile as a script interpreter, `command-line' returns the | |
3117 | script's arguments; those processed by the interpreter (like `-s' or | |
3118 | `-c') are omitted. (In other words, you get the normal, expected | |
3119 | behavior.) Any application that uses scm_shell to process its | |
3120 | command-line arguments gets this behavior as well. | |
3121 | ||
3122 | ** The new function `load-user-init' looks for a file called `.guile' | |
3123 | in the user's home directory, and loads it if it exists. This is | |
3124 | mostly for use by the code generated by scm_compile_shell_switches, | |
3125 | but we thought it might also be useful in other circumstances. | |
3126 | ||
3127 | ** The new function `log10' returns the base-10 logarithm of its | |
3128 | argument. | |
3129 | ||
3130 | ** Changes to I/O functions | |
3131 | ||
3132 | *** The functions `read', `primitive-load', `read-and-eval!', and | |
3133 | `primitive-load-path' no longer take optional arguments controlling | |
3134 | case insensitivity and a `#' parser. | |
3135 | ||
3136 | Case sensitivity is now controlled by a read option called | |
3137 | `case-insensitive'. The user can add new `#' syntaxes with the | |
3138 | `read-hash-extend' function (see below). | |
3139 | ||
3140 | *** The new function `read-hash-extend' allows the user to change the | |
3141 | syntax of Guile Scheme in a somewhat controlled way. | |
3142 | ||
3143 | (read-hash-extend CHAR PROC) | |
3144 | When parsing S-expressions, if we read a `#' character followed by | |
3145 | the character CHAR, use PROC to parse an object from the stream. | |
3146 | If PROC is #f, remove any parsing procedure registered for CHAR. | |
3147 | ||
3148 | The reader applies PROC to two arguments: CHAR and an input port. | |
3149 | ||
3150 | *** The new functions read-delimited and read-delimited! provide a | |
3151 | general mechanism for doing delimited input on streams. | |
3152 | ||
3153 | (read-delimited DELIMS [PORT HANDLE-DELIM]) | |
3154 | Read until we encounter one of the characters in DELIMS (a string), | |
3155 | or end-of-file. PORT is the input port to read from; it defaults to | |
3156 | the current input port. The HANDLE-DELIM parameter determines how | |
3157 | the terminating character is handled; it should be one of the | |
3158 | following symbols: | |
3159 | ||
3160 | 'trim omit delimiter from result | |
3161 | 'peek leave delimiter character in input stream | |
3162 | 'concat append delimiter character to returned value | |
3163 | 'split return a pair: (RESULT . TERMINATOR) | |
3164 | ||
3165 | HANDLE-DELIM defaults to 'peek. | |
3166 | ||
3167 | (read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END]) | |
3168 | A side-effecting variant of `read-delimited'. | |
3169 | ||
3170 | The data is written into the string BUF at the indices in the | |
3171 | half-open interval [START, END); the default interval is the whole | |
3172 | string: START = 0 and END = (string-length BUF). The values of | |
3173 | START and END must specify a well-defined interval in BUF, i.e. | |
3174 | 0 <= START <= END <= (string-length BUF). | |
3175 | ||
3176 | It returns NBYTES, the number of bytes read. If the buffer filled | |
3177 | up without a delimiter character being found, it returns #f. If the | |
3178 | port is at EOF when the read starts, it returns the EOF object. | |
3179 | ||
3180 | If an integer is returned (i.e., the read is successfully terminated | |
3181 | by reading a delimiter character), then the HANDLE-DELIM parameter | |
3182 | determines how to handle the terminating character. It is described | |
3183 | above, and defaults to 'peek. | |
3184 | ||
3185 | (The descriptions of these functions were borrowed from the SCSH | |
3186 | manual, by Olin Shivers and Brian Carlstrom.) | |
3187 | ||
3188 | *** The `%read-delimited!' function is the primitive used to implement | |
3189 | `read-delimited' and `read-delimited!'. | |
3190 | ||
3191 | (%read-delimited! DELIMS BUF GOBBLE? [PORT START END]) | |
3192 | ||
3193 | This returns a pair of values: (TERMINATOR . NUM-READ). | |
3194 | - TERMINATOR describes why the read was terminated. If it is a | |
3195 | character or the eof object, then that is the value that terminated | |
3196 | the read. If it is #f, the function filled the buffer without finding | |
3197 | a delimiting character. | |
3198 | - NUM-READ is the number of characters read into BUF. | |
3199 | ||
3200 | If the read is successfully terminated by reading a delimiter | |
3201 | character, then the gobble? parameter determines what to do with the | |
3202 | terminating character. If true, the character is removed from the | |
3203 | input stream; if false, the character is left in the input stream | |
3204 | where a subsequent read operation will retrieve it. In either case, | |
3205 | the character is also the first value returned by the procedure call. | |
3206 | ||
3207 | (The descriptions of this function was borrowed from the SCSH manual, | |
3208 | by Olin Shivers and Brian Carlstrom.) | |
3209 | ||
3210 | *** The `read-line' and `read-line!' functions have changed; they now | |
3211 | trim the terminator by default; previously they appended it to the | |
3212 | returned string. For the old behavior, use (read-line PORT 'concat). | |
3213 | ||
3214 | *** The functions `uniform-array-read!' and `uniform-array-write!' now | |
3215 | take new optional START and END arguments, specifying the region of | |
3216 | the array to read and write. | |
3217 | ||
f348c807 JB |
3218 | *** The `ungetc-char-ready?' function has been removed. We feel it's |
3219 | inappropriate for an interface to expose implementation details this | |
3220 | way. | |
095936d2 JB |
3221 | |
3222 | ** Changes to the Unix library and system call interface | |
3223 | ||
3224 | *** The new fcntl function provides access to the Unix `fcntl' system | |
3225 | call. | |
3226 | ||
3227 | (fcntl PORT COMMAND VALUE) | |
3228 | Apply COMMAND to PORT's file descriptor, with VALUE as an argument. | |
3229 | Values for COMMAND are: | |
3230 | ||
3231 | F_DUPFD duplicate a file descriptor | |
3232 | F_GETFD read the descriptor's close-on-exec flag | |
3233 | F_SETFD set the descriptor's close-on-exec flag to VALUE | |
3234 | F_GETFL read the descriptor's flags, as set on open | |
3235 | F_SETFL set the descriptor's flags, as set on open to VALUE | |
3236 | F_GETOWN return the process ID of a socket's owner, for SIGIO | |
3237 | F_SETOWN set the process that owns a socket to VALUE, for SIGIO | |
3238 | FD_CLOEXEC not sure what this is | |
3239 | ||
3240 | For details, see the documentation for the fcntl system call. | |
3241 | ||
3242 | *** The arguments to `select' have changed, for compatibility with | |
3243 | SCSH. The TIMEOUT parameter may now be non-integral, yielding the | |
3244 | expected behavior. The MILLISECONDS parameter has been changed to | |
3245 | MICROSECONDS, to more closely resemble the underlying system call. | |
3246 | The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the | |
3247 | corresponding return set will be the same. | |
3248 | ||
3249 | *** The arguments to the `mknod' system call have changed. They are | |
3250 | now: | |
3251 | ||
3252 | (mknod PATH TYPE PERMS DEV) | |
3253 | Create a new file (`node') in the file system. PATH is the name of | |
3254 | the file to create. TYPE is the kind of file to create; it should | |
3255 | be 'fifo, 'block-special, or 'char-special. PERMS specifies the | |
3256 | permission bits to give the newly created file. If TYPE is | |
3257 | 'block-special or 'char-special, DEV specifies which device the | |
3258 | special file refers to; its interpretation depends on the kind of | |
3259 | special file being created. | |
3260 | ||
3261 | *** The `fork' function has been renamed to `primitive-fork', to avoid | |
3262 | clashing with various SCSH forks. | |
3263 | ||
3264 | *** The `recv' and `recvfrom' functions have been renamed to `recv!' | |
3265 | and `recvfrom!'. They no longer accept a size for a second argument; | |
3266 | you must pass a string to hold the received value. They no longer | |
3267 | return the buffer. Instead, `recv' returns the length of the message | |
3268 | received, and `recvfrom' returns a pair containing the packet's length | |
3269 | and originating address. | |
3270 | ||
3271 | *** The file descriptor datatype has been removed, as have the | |
3272 | `read-fd', `write-fd', `close', `lseek', and `dup' functions. | |
3273 | We plan to replace these functions with a SCSH-compatible interface. | |
3274 | ||
3275 | *** The `create' function has been removed; it's just a special case | |
3276 | of `open'. | |
3277 | ||
3278 | *** There are new functions to break down process termination status | |
3279 | values. In the descriptions below, STATUS is a value returned by | |
3280 | `waitpid'. | |
3281 | ||
3282 | (status:exit-val STATUS) | |
3283 | If the child process exited normally, this function returns the exit | |
3284 | code for the child process (i.e., the value passed to exit, or | |
3285 | returned from main). If the child process did not exit normally, | |
3286 | this function returns #f. | |
3287 | ||
3288 | (status:stop-sig STATUS) | |
3289 | If the child process was suspended by a signal, this function | |
3290 | returns the signal that suspended the child. Otherwise, it returns | |
3291 | #f. | |
3292 | ||
3293 | (status:term-sig STATUS) | |
3294 | If the child process terminated abnormally, this function returns | |
3295 | the signal that terminated the child. Otherwise, this function | |
3296 | returns false. | |
3297 | ||
3298 | POSIX promises that exactly one of these functions will return true on | |
3299 | a valid STATUS value. | |
3300 | ||
3301 | These functions are compatible with SCSH. | |
3302 | ||
3303 | *** There are new accessors and setters for the broken-out time vectors | |
48d224d7 JB |
3304 | returned by `localtime', `gmtime', and that ilk. They are: |
3305 | ||
3306 | Component Accessor Setter | |
3307 | ========================= ============ ============ | |
3308 | seconds tm:sec set-tm:sec | |
3309 | minutes tm:min set-tm:min | |
3310 | hours tm:hour set-tm:hour | |
3311 | day of the month tm:mday set-tm:mday | |
3312 | month tm:mon set-tm:mon | |
3313 | year tm:year set-tm:year | |
3314 | day of the week tm:wday set-tm:wday | |
3315 | day in the year tm:yday set-tm:yday | |
3316 | daylight saving time tm:isdst set-tm:isdst | |
3317 | GMT offset, seconds tm:gmtoff set-tm:gmtoff | |
3318 | name of time zone tm:zone set-tm:zone | |
3319 | ||
095936d2 JB |
3320 | *** There are new accessors for the vectors returned by `uname', |
3321 | describing the host system: | |
48d224d7 JB |
3322 | |
3323 | Component Accessor | |
3324 | ============================================== ================ | |
3325 | name of the operating system implementation utsname:sysname | |
3326 | network name of this machine utsname:nodename | |
3327 | release level of the operating system utsname:release | |
3328 | version level of the operating system utsname:version | |
3329 | machine hardware platform utsname:machine | |
3330 | ||
095936d2 JB |
3331 | *** There are new accessors for the vectors returned by `getpw', |
3332 | `getpwnam', `getpwuid', and `getpwent', describing entries from the | |
3333 | system's user database: | |
3334 | ||
3335 | Component Accessor | |
3336 | ====================== ================= | |
3337 | user name passwd:name | |
3338 | user password passwd:passwd | |
3339 | user id passwd:uid | |
3340 | group id passwd:gid | |
3341 | real name passwd:gecos | |
3342 | home directory passwd:dir | |
3343 | shell program passwd:shell | |
3344 | ||
3345 | *** There are new accessors for the vectors returned by `getgr', | |
3346 | `getgrnam', `getgrgid', and `getgrent', describing entries from the | |
3347 | system's group database: | |
3348 | ||
3349 | Component Accessor | |
3350 | ======================= ============ | |
3351 | group name group:name | |
3352 | group password group:passwd | |
3353 | group id group:gid | |
3354 | group members group:mem | |
3355 | ||
3356 | *** There are new accessors for the vectors returned by `gethost', | |
3357 | `gethostbyaddr', `gethostbyname', and `gethostent', describing | |
3358 | internet hosts: | |
3359 | ||
3360 | Component Accessor | |
3361 | ========================= =============== | |
3362 | official name of host hostent:name | |
3363 | alias list hostent:aliases | |
3364 | host address type hostent:addrtype | |
3365 | length of address hostent:length | |
3366 | list of addresses hostent:addr-list | |
3367 | ||
3368 | *** There are new accessors for the vectors returned by `getnet', | |
3369 | `getnetbyaddr', `getnetbyname', and `getnetent', describing internet | |
3370 | networks: | |
3371 | ||
3372 | Component Accessor | |
3373 | ========================= =============== | |
3374 | official name of net netent:name | |
3375 | alias list netent:aliases | |
3376 | net number type netent:addrtype | |
3377 | net number netent:net | |
3378 | ||
3379 | *** There are new accessors for the vectors returned by `getproto', | |
3380 | `getprotobyname', `getprotobynumber', and `getprotoent', describing | |
3381 | internet protocols: | |
3382 | ||
3383 | Component Accessor | |
3384 | ========================= =============== | |
3385 | official protocol name protoent:name | |
3386 | alias list protoent:aliases | |
3387 | protocol number protoent:proto | |
3388 | ||
3389 | *** There are new accessors for the vectors returned by `getserv', | |
3390 | `getservbyname', `getservbyport', and `getservent', describing | |
3391 | internet protocols: | |
3392 | ||
3393 | Component Accessor | |
3394 | ========================= =============== | |
3395 | official service name servent:name | |
3396 | alias list servent:aliases | |
3397 | port number servent:port | |
3398 | protocol to use servent:proto | |
3399 | ||
3400 | *** There are new accessors for the sockaddr structures returned by | |
3401 | `accept', `getsockname', `getpeername', `recvfrom!': | |
3402 | ||
3403 | Component Accessor | |
3404 | ======================================== =============== | |
3405 | address format (`family') sockaddr:fam | |
3406 | path, for file domain addresses sockaddr:path | |
3407 | address, for internet domain addresses sockaddr:addr | |
3408 | TCP or UDP port, for internet sockaddr:port | |
3409 | ||
3410 | *** The `getpwent', `getgrent', `gethostent', `getnetent', | |
3411 | `getprotoent', and `getservent' functions now return #f at the end of | |
3412 | the user database. (They used to throw an exception.) | |
3413 | ||
3414 | Note that calling MUMBLEent function is equivalent to calling the | |
3415 | corresponding MUMBLE function with no arguments. | |
3416 | ||
3417 | *** The `setpwent', `setgrent', `sethostent', `setnetent', | |
3418 | `setprotoent', and `setservent' routines now take no arguments. | |
3419 | ||
3420 | *** The `gethost', `getproto', `getnet', and `getserv' functions now | |
3421 | provide more useful information when they throw an exception. | |
3422 | ||
3423 | *** The `lnaof' function has been renamed to `inet-lnaof'. | |
3424 | ||
3425 | *** Guile now claims to have the `current-time' feature. | |
3426 | ||
3427 | *** The `mktime' function now takes an optional second argument ZONE, | |
3428 | giving the time zone to use for the conversion. ZONE should be a | |
3429 | string, in the same format as expected for the "TZ" environment variable. | |
3430 | ||
3431 | *** The `strptime' function now returns a pair (TIME . COUNT), where | |
3432 | TIME is the parsed time as a vector, and COUNT is the number of | |
3433 | characters from the string left unparsed. This function used to | |
3434 | return the remaining characters as a string. | |
3435 | ||
3436 | *** The `gettimeofday' function has replaced the old `time+ticks' function. | |
3437 | The return value is now (SECONDS . MICROSECONDS); the fractional | |
3438 | component is no longer expressed in "ticks". | |
3439 | ||
3440 | *** The `ticks/sec' constant has been removed, in light of the above change. | |
6685dc83 | 3441 | |
ea00ecba MG |
3442 | * Changes to the gh_ interface |
3443 | ||
3444 | ** gh_eval_str() now returns an SCM object which is the result of the | |
3445 | evaluation | |
3446 | ||
aaef0d2a MG |
3447 | ** gh_scm2str() now copies the Scheme data to a caller-provided C |
3448 | array | |
3449 | ||
3450 | ** gh_scm2newstr() now makes a C array, copies the Scheme data to it, | |
3451 | and returns the array | |
3452 | ||
3453 | ** gh_scm2str0() is gone: there is no need to distinguish | |
3454 | null-terminated from non-null-terminated, since gh_scm2newstr() allows | |
3455 | the user to interpret the data both ways. | |
3456 | ||
f3b1485f JB |
3457 | * Changes to the scm_ interface |
3458 | ||
095936d2 JB |
3459 | ** The new function scm_symbol_value0 provides an easy way to get a |
3460 | symbol's value from C code: | |
3461 | ||
3462 | SCM scm_symbol_value0 (char *NAME) | |
3463 | Return the value of the symbol named by the null-terminated string | |
3464 | NAME in the current module. If the symbol named NAME is unbound in | |
3465 | the current module, return SCM_UNDEFINED. | |
3466 | ||
3467 | ** The new function scm_sysintern0 creates new top-level variables, | |
3468 | without assigning them a value. | |
3469 | ||
3470 | SCM scm_sysintern0 (char *NAME) | |
3471 | Create a new Scheme top-level variable named NAME. NAME is a | |
3472 | null-terminated string. Return the variable's value cell. | |
3473 | ||
3474 | ** The function scm_internal_catch is the guts of catch. It handles | |
3475 | all the mechanics of setting up a catch target, invoking the catch | |
3476 | body, and perhaps invoking the handler if the body does a throw. | |
3477 | ||
3478 | The function is designed to be usable from C code, but is general | |
3479 | enough to implement all the semantics Guile Scheme expects from throw. | |
3480 | ||
3481 | TAG is the catch tag. Typically, this is a symbol, but this function | |
3482 | doesn't actually care about that. | |
3483 | ||
3484 | BODY is a pointer to a C function which runs the body of the catch; | |
3485 | this is the code you can throw from. We call it like this: | |
3486 | BODY (BODY_DATA, JMPBUF) | |
3487 | where: | |
3488 | BODY_DATA is just the BODY_DATA argument we received; we pass it | |
3489 | through to BODY as its first argument. The caller can make | |
3490 | BODY_DATA point to anything useful that BODY might need. | |
3491 | JMPBUF is the Scheme jmpbuf object corresponding to this catch, | |
3492 | which we have just created and initialized. | |
3493 | ||
3494 | HANDLER is a pointer to a C function to deal with a throw to TAG, | |
3495 | should one occur. We call it like this: | |
3496 | HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS) | |
3497 | where | |
3498 | HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the | |
3499 | same idea as BODY_DATA above. | |
3500 | THROWN_TAG is the tag that the user threw to; usually this is | |
3501 | TAG, but it could be something else if TAG was #t (i.e., a | |
3502 | catch-all), or the user threw to a jmpbuf. | |
3503 | THROW_ARGS is the list of arguments the user passed to the THROW | |
3504 | function. | |
3505 | ||
3506 | BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA | |
3507 | is just a pointer we pass through to HANDLER. We don't actually | |
3508 | use either of those pointers otherwise ourselves. The idea is | |
3509 | that, if our caller wants to communicate something to BODY or | |
3510 | HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and | |
3511 | HANDLER can then use. Think of it as a way to make BODY and | |
3512 | HANDLER closures, not just functions; MUMBLE_DATA points to the | |
3513 | enclosed variables. | |
3514 | ||
3515 | Of course, it's up to the caller to make sure that any data a | |
3516 | MUMBLE_DATA needs is protected from GC. A common way to do this is | |
3517 | to make MUMBLE_DATA a pointer to data stored in an automatic | |
3518 | structure variable; since the collector must scan the stack for | |
3519 | references anyway, this assures that any references in MUMBLE_DATA | |
3520 | will be found. | |
3521 | ||
3522 | ** The new function scm_internal_lazy_catch is exactly like | |
3523 | scm_internal_catch, except: | |
3524 | ||
3525 | - It does not unwind the stack (this is the major difference). | |
3526 | - If handler returns, its value is returned from the throw. | |
3527 | - BODY always receives #f as its JMPBUF argument (since there's no | |
3528 | jmpbuf associated with a lazy catch, because we don't unwind the | |
3529 | stack.) | |
3530 | ||
3531 | ** scm_body_thunk is a new body function you can pass to | |
3532 | scm_internal_catch if you want the body to be like Scheme's `catch' | |
3533 | --- a thunk, or a function of one argument if the tag is #f. | |
3534 | ||
3535 | BODY_DATA is a pointer to a scm_body_thunk_data structure, which | |
3536 | contains the Scheme procedure to invoke as the body, and the tag | |
3537 | we're catching. If the tag is #f, then we pass JMPBUF (created by | |
3538 | scm_internal_catch) to the body procedure; otherwise, the body gets | |
3539 | no arguments. | |
3540 | ||
3541 | ** scm_handle_by_proc is a new handler function you can pass to | |
3542 | scm_internal_catch if you want the handler to act like Scheme's catch | |
3543 | --- call a procedure with the tag and the throw arguments. | |
3544 | ||
3545 | If the user does a throw to this catch, this function runs a handler | |
3546 | procedure written in Scheme. HANDLER_DATA is a pointer to an SCM | |
3547 | variable holding the Scheme procedure object to invoke. It ought to | |
3548 | be a pointer to an automatic variable (i.e., one living on the stack), | |
3549 | or the procedure object should be otherwise protected from GC. | |
3550 | ||
3551 | ** scm_handle_by_message is a new handler function to use with | |
3552 | `scm_internal_catch' if you want Guile to print a message and die. | |
3553 | It's useful for dealing with throws to uncaught keys at the top level. | |
3554 | ||
3555 | HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a | |
3556 | message header to print; if zero, we use "guile" instead. That | |
3557 | text is followed by a colon, then the message described by ARGS. | |
3558 | ||
3559 | ** The return type of scm_boot_guile is now void; the function does | |
3560 | not return a value, and indeed, never returns at all. | |
3561 | ||
f3b1485f JB |
3562 | ** The new function scm_shell makes it easy for user applications to |
3563 | process command-line arguments in a way that is compatible with the | |
3564 | stand-alone guile interpreter (which is in turn compatible with SCSH, | |
3565 | the Scheme shell). | |
3566 | ||
3567 | To use the scm_shell function, first initialize any guile modules | |
3568 | linked into your application, and then call scm_shell with the values | |
7ed46dc8 | 3569 | of ARGC and ARGV your `main' function received. scm_shell will add |
f3b1485f JB |
3570 | any SCSH-style meta-arguments from the top of the script file to the |
3571 | argument vector, and then process the command-line arguments. This | |
3572 | generally means loading a script file or starting up an interactive | |
3573 | command interpreter. For details, see "Changes to the stand-alone | |
3574 | interpreter" above. | |
3575 | ||
095936d2 JB |
3576 | ** The new functions scm_get_meta_args and scm_count_argv help you |
3577 | implement the SCSH-style meta-argument, `\'. | |
3578 | ||
3579 | char **scm_get_meta_args (int ARGC, char **ARGV) | |
3580 | If the second element of ARGV is a string consisting of a single | |
3581 | backslash character (i.e. "\\" in Scheme notation), open the file | |
3582 | named by the following argument, parse arguments from it, and return | |
3583 | the spliced command line. The returned array is terminated by a | |
3584 | null pointer. | |
3585 | ||
3586 | For details of argument parsing, see above, under "guile now accepts | |
3587 | command-line arguments compatible with SCSH..." | |
3588 | ||
3589 | int scm_count_argv (char **ARGV) | |
3590 | Count the arguments in ARGV, assuming it is terminated by a null | |
3591 | pointer. | |
3592 | ||
3593 | For an example of how these functions might be used, see the source | |
3594 | code for the function scm_shell in libguile/script.c. | |
3595 | ||
3596 | You will usually want to use scm_shell instead of calling this | |
3597 | function yourself. | |
3598 | ||
3599 | ** The new function scm_compile_shell_switches turns an array of | |
3600 | command-line arguments into Scheme code to carry out the actions they | |
3601 | describe. Given ARGC and ARGV, it returns a Scheme expression to | |
3602 | evaluate, and calls scm_set_program_arguments to make any remaining | |
3603 | command-line arguments available to the Scheme code. For example, | |
3604 | given the following arguments: | |
3605 | ||
3606 | -e main -s ekko a speckled gecko | |
3607 | ||
3608 | scm_set_program_arguments will return the following expression: | |
3609 | ||
3610 | (begin (load "ekko") (main (command-line)) (quit)) | |
3611 | ||
3612 | You will usually want to use scm_shell instead of calling this | |
3613 | function yourself. | |
3614 | ||
3615 | ** The function scm_shell_usage prints a usage message appropriate for | |
3616 | an interpreter that uses scm_compile_shell_switches to handle its | |
3617 | command-line arguments. | |
3618 | ||
3619 | void scm_shell_usage (int FATAL, char *MESSAGE) | |
3620 | Print a usage message to the standard error output. If MESSAGE is | |
3621 | non-zero, write it before the usage message, followed by a newline. | |
3622 | If FATAL is non-zero, exit the process, using FATAL as the | |
3623 | termination status. (If you want to be compatible with Guile, | |
3624 | always use 1 as the exit status when terminating due to command-line | |
3625 | usage problems.) | |
3626 | ||
3627 | You will usually want to use scm_shell instead of calling this | |
3628 | function yourself. | |
48d224d7 JB |
3629 | |
3630 | ** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no | |
095936d2 JB |
3631 | expressions. It used to return SCM_EOL. Earth-shattering. |
3632 | ||
3633 | ** The macros for declaring scheme objects in C code have been | |
3634 | rearranged slightly. They are now: | |
3635 | ||
3636 | SCM_SYMBOL (C_NAME, SCHEME_NAME) | |
3637 | Declare a static SCM variable named C_NAME, and initialize it to | |
3638 | point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should | |
3639 | be a C identifier, and SCHEME_NAME should be a C string. | |
3640 | ||
3641 | SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME) | |
3642 | Just like SCM_SYMBOL, but make C_NAME globally visible. | |
3643 | ||
3644 | SCM_VCELL (C_NAME, SCHEME_NAME) | |
3645 | Create a global variable at the Scheme level named SCHEME_NAME. | |
3646 | Declare a static SCM variable named C_NAME, and initialize it to | |
3647 | point to the Scheme variable's value cell. | |
3648 | ||
3649 | SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME) | |
3650 | Just like SCM_VCELL, but make C_NAME globally visible. | |
3651 | ||
3652 | The `guile-snarf' script writes initialization code for these macros | |
3653 | to its standard output, given C source code as input. | |
3654 | ||
3655 | The SCM_GLOBAL macro is gone. | |
3656 | ||
3657 | ** The scm_read_line and scm_read_line_x functions have been replaced | |
3658 | by Scheme code based on the %read-delimited! procedure (known to C | |
3659 | code as scm_read_delimited_x). See its description above for more | |
3660 | information. | |
48d224d7 | 3661 | |
095936d2 JB |
3662 | ** The function scm_sys_open has been renamed to scm_open. It now |
3663 | returns a port instead of an FD object. | |
ea00ecba | 3664 | |
095936d2 JB |
3665 | * The dynamic linking support has changed. For more information, see |
3666 | libguile/DYNAMIC-LINKING. | |
ea00ecba | 3667 | |
f7b47737 JB |
3668 | \f |
3669 | Guile 1.0b3 | |
3065a62a | 3670 | |
f3b1485f JB |
3671 | User-visible changes from Thursday, September 5, 1996 until Guile 1.0 |
3672 | (Sun 5 Jan 1997): | |
3065a62a | 3673 | |
4b521edb | 3674 | * Changes to the 'guile' program: |
3065a62a | 3675 | |
4b521edb JB |
3676 | ** Guile now loads some new files when it starts up. Guile first |
3677 | searches the load path for init.scm, and loads it if found. Then, if | |
3678 | Guile is not being used to execute a script, and the user's home | |
3679 | directory contains a file named `.guile', Guile loads that. | |
c6486f8a | 3680 | |
4b521edb | 3681 | ** You can now use Guile as a shell script interpreter. |
3065a62a JB |
3682 | |
3683 | To paraphrase the SCSH manual: | |
3684 | ||
3685 | When Unix tries to execute an executable file whose first two | |
3686 | characters are the `#!', it treats the file not as machine code to | |
3687 | be directly executed by the native processor, but as source code | |
3688 | to be executed by some interpreter. The interpreter to use is | |
3689 | specified immediately after the #! sequence on the first line of | |
3690 | the source file. The kernel reads in the name of the interpreter, | |
3691 | and executes that instead. It passes the interpreter the source | |
3692 | filename as its first argument, with the original arguments | |
3693 | following. Consult the Unix man page for the `exec' system call | |
3694 | for more information. | |
3695 | ||
1a1945be JB |
3696 | Now you can use Guile as an interpreter, using a mechanism which is a |
3697 | compatible subset of that provided by SCSH. | |
3698 | ||
3065a62a JB |
3699 | Guile now recognizes a '-s' command line switch, whose argument is the |
3700 | name of a file of Scheme code to load. It also treats the two | |
3701 | characters `#!' as the start of a comment, terminated by `!#'. Thus, | |
3702 | to make a file of Scheme code directly executable by Unix, insert the | |
3703 | following two lines at the top of the file: | |
3704 | ||
3705 | #!/usr/local/bin/guile -s | |
3706 | !# | |
3707 | ||
3708 | Guile treats the argument of the `-s' command-line switch as the name | |
3709 | of a file of Scheme code to load, and treats the sequence `#!' as the | |
3710 | start of a block comment, terminated by `!#'. | |
3711 | ||
3712 | For example, here's a version of 'echo' written in Scheme: | |
3713 | ||
3714 | #!/usr/local/bin/guile -s | |
3715 | !# | |
3716 | (let loop ((args (cdr (program-arguments)))) | |
3717 | (if (pair? args) | |
3718 | (begin | |
3719 | (display (car args)) | |
3720 | (if (pair? (cdr args)) | |
3721 | (display " ")) | |
3722 | (loop (cdr args))))) | |
3723 | (newline) | |
3724 | ||
3725 | Why does `#!' start a block comment terminated by `!#', instead of the | |
3726 | end of the line? That is the notation SCSH uses, and although we | |
3727 | don't yet support the other SCSH features that motivate that choice, | |
3728 | we would like to be backward-compatible with any existing Guile | |
3763761c JB |
3729 | scripts once we do. Furthermore, if the path to Guile on your system |
3730 | is too long for your kernel, you can start the script with this | |
3731 | horrible hack: | |
3732 | ||
3733 | #!/bin/sh | |
3734 | exec /really/long/path/to/guile -s "$0" ${1+"$@"} | |
3735 | !# | |
3065a62a JB |
3736 | |
3737 | Note that some very old Unix systems don't support the `#!' syntax. | |
3738 | ||
c6486f8a | 3739 | |
4b521edb | 3740 | ** You can now run Guile without installing it. |
6685dc83 JB |
3741 | |
3742 | Previous versions of the interactive Guile interpreter (`guile') | |
3743 | couldn't start up unless Guile's Scheme library had been installed; | |
3744 | they used the value of the environment variable `SCHEME_LOAD_PATH' | |
3745 | later on in the startup process, but not to find the startup code | |
3746 | itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme | |
3747 | code. | |
3748 | ||
3749 | To run Guile without installing it, build it in the normal way, and | |
3750 | then set the environment variable `SCHEME_LOAD_PATH' to a | |
3751 | colon-separated list of directories, including the top-level directory | |
3752 | of the Guile sources. For example, if you unpacked Guile so that the | |
3753 | full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then | |
3754 | you might say | |
3755 | ||
3756 | export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3 | |
3757 | ||
c6486f8a | 3758 | |
4b521edb JB |
3759 | ** Guile's read-eval-print loop no longer prints #<unspecified> |
3760 | results. If the user wants to see this, she can evaluate the | |
3761 | expression (assert-repl-print-unspecified #t), perhaps in her startup | |
48d224d7 | 3762 | file. |
6685dc83 | 3763 | |
4b521edb JB |
3764 | ** Guile no longer shows backtraces by default when an error occurs; |
3765 | however, it does display a message saying how to get one, and how to | |
3766 | request that they be displayed by default. After an error, evaluate | |
3767 | (backtrace) | |
3768 | to see a backtrace, and | |
3769 | (debug-enable 'backtrace) | |
3770 | to see them by default. | |
6685dc83 | 3771 | |
6685dc83 | 3772 | |
d9fb83d9 | 3773 | |
4b521edb JB |
3774 | * Changes to Guile Scheme: |
3775 | ||
3776 | ** Guile now distinguishes between #f and the empty list. | |
3777 | ||
3778 | This is for compatibility with the IEEE standard, the (possibly) | |
3779 | upcoming Revised^5 Report on Scheme, and many extant Scheme | |
3780 | implementations. | |
3781 | ||
3782 | Guile used to have #f and '() denote the same object, to make Scheme's | |
3783 | type system more compatible with Emacs Lisp's. However, the change | |
3784 | caused too much trouble for Scheme programmers, and we found another | |
3785 | way to reconcile Emacs Lisp with Scheme that didn't require this. | |
3786 | ||
3787 | ||
3788 | ** Guile's delq, delv, delete functions, and their destructive | |
c6486f8a JB |
3789 | counterparts, delq!, delv!, and delete!, now remove all matching |
3790 | elements from the list, not just the first. This matches the behavior | |
3791 | of the corresponding Emacs Lisp functions, and (I believe) the Maclisp | |
3792 | functions which inspired them. | |
3793 | ||
3794 | I recognize that this change may break code in subtle ways, but it | |
3795 | seems best to make the change before the FSF's first Guile release, | |
3796 | rather than after. | |
3797 | ||
3798 | ||
4b521edb | 3799 | ** The compiled-library-path function has been deleted from libguile. |
6685dc83 | 3800 | |
4b521edb | 3801 | ** The facilities for loading Scheme source files have changed. |
c6486f8a | 3802 | |
4b521edb | 3803 | *** The variable %load-path now tells Guile which directories to search |
6685dc83 JB |
3804 | for Scheme code. Its value is a list of strings, each of which names |
3805 | a directory. | |
3806 | ||
4b521edb JB |
3807 | *** The variable %load-extensions now tells Guile which extensions to |
3808 | try appending to a filename when searching the load path. Its value | |
3809 | is a list of strings. Its default value is ("" ".scm"). | |
3810 | ||
3811 | *** (%search-load-path FILENAME) searches the directories listed in the | |
3812 | value of the %load-path variable for a Scheme file named FILENAME, | |
3813 | with all the extensions listed in %load-extensions. If it finds a | |
3814 | match, then it returns its full filename. If FILENAME is absolute, it | |
3815 | returns it unchanged. Otherwise, it returns #f. | |
6685dc83 | 3816 | |
4b521edb JB |
3817 | %search-load-path will not return matches that refer to directories. |
3818 | ||
3819 | *** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP) | |
3820 | uses %seach-load-path to find a file named FILENAME, and loads it if | |
3821 | it finds it. If it can't read FILENAME for any reason, it throws an | |
3822 | error. | |
6685dc83 JB |
3823 | |
3824 | The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the | |
4b521edb JB |
3825 | `read' function. |
3826 | ||
3827 | *** load uses the same searching semantics as primitive-load. | |
3828 | ||
3829 | *** The functions %try-load, try-load-with-path, %load, load-with-path, | |
3830 | basic-try-load-with-path, basic-load-with-path, try-load-module-with- | |
3831 | path, and load-module-with-path have been deleted. The functions | |
3832 | above should serve their purposes. | |
3833 | ||
3834 | *** If the value of the variable %load-hook is a procedure, | |
3835 | `primitive-load' applies its value to the name of the file being | |
3836 | loaded (without the load path directory name prepended). If its value | |
3837 | is #f, it is ignored. Otherwise, an error occurs. | |
3838 | ||
3839 | This is mostly useful for printing load notification messages. | |
3840 | ||
3841 | ||
3842 | ** The function `eval!' is no longer accessible from the scheme level. | |
3843 | We can't allow operations which introduce glocs into the scheme level, | |
3844 | because Guile's type system can't handle these as data. Use `eval' or | |
3845 | `read-and-eval!' (see below) as replacement. | |
3846 | ||
3847 | ** The new function read-and-eval! reads an expression from PORT, | |
3848 | evaluates it, and returns the result. This is more efficient than | |
3849 | simply calling `read' and `eval', since it is not necessary to make a | |
3850 | copy of the expression for the evaluator to munge. | |
3851 | ||
3852 | Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as | |
3853 | for the `read' function. | |
3854 | ||
3855 | ||
3856 | ** The function `int?' has been removed; its definition was identical | |
3857 | to that of `integer?'. | |
3858 | ||
3859 | ** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should | |
3860 | use the R4RS names for these functions. | |
3861 | ||
3862 | ** The function object-properties no longer returns the hash handle; | |
3863 | it simply returns the object's property list. | |
3864 | ||
3865 | ** Many functions have been changed to throw errors, instead of | |
3866 | returning #f on failure. The point of providing exception handling in | |
3867 | the language is to simplify the logic of user code, but this is less | |
3868 | useful if Guile's primitives don't throw exceptions. | |
3869 | ||
3870 | ** The function `fileno' has been renamed from `%fileno'. | |
3871 | ||
3872 | ** The function primitive-mode->fdes returns #t or #f now, not 1 or 0. | |
3873 | ||
3874 | ||
3875 | * Changes to Guile's C interface: | |
3876 | ||
3877 | ** The library's initialization procedure has been simplified. | |
3878 | scm_boot_guile now has the prototype: | |
3879 | ||
3880 | void scm_boot_guile (int ARGC, | |
3881 | char **ARGV, | |
3882 | void (*main_func) (), | |
3883 | void *closure); | |
3884 | ||
3885 | scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV. | |
3886 | MAIN_FUNC should do all the work of the program (initializing other | |
3887 | packages, reading user input, etc.) before returning. When MAIN_FUNC | |
3888 | returns, call exit (0); this function never returns. If you want some | |
3889 | other exit value, MAIN_FUNC may call exit itself. | |
3890 | ||
3891 | scm_boot_guile arranges for program-arguments to return the strings | |
3892 | given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call | |
3893 | scm_set_program_arguments with the final list, so Scheme code will | |
3894 | know which arguments have been processed. | |
3895 | ||
3896 | scm_boot_guile establishes a catch-all catch handler which prints an | |
3897 | error message and exits the process. This means that Guile exits in a | |
3898 | coherent way when system errors occur and the user isn't prepared to | |
3899 | handle it. If the user doesn't like this behavior, they can establish | |
3900 | their own universal catcher in MAIN_FUNC to shadow this one. | |
3901 | ||
3902 | Why must the caller do all the real work from MAIN_FUNC? The garbage | |
3903 | collector assumes that all local variables of type SCM will be above | |
3904 | scm_boot_guile's stack frame on the stack. If you try to manipulate | |
3905 | SCM values after this function returns, it's the luck of the draw | |
3906 | whether the GC will be able to find the objects you allocate. So, | |
3907 | scm_boot_guile function exits, rather than returning, to discourage | |
3908 | people from making that mistake. | |
3909 | ||
3910 | The IN, OUT, and ERR arguments were removed; there are other | |
3911 | convenient ways to override these when desired. | |
3912 | ||
3913 | The RESULT argument was deleted; this function should never return. | |
3914 | ||
3915 | The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more | |
3916 | general. | |
3917 | ||
3918 | ||
3919 | ** Guile's header files should no longer conflict with your system's | |
3920 | header files. | |
3921 | ||
3922 | In order to compile code which #included <libguile.h>, previous | |
3923 | versions of Guile required you to add a directory containing all the | |
3924 | Guile header files to your #include path. This was a problem, since | |
3925 | Guile's header files have names which conflict with many systems' | |
3926 | header files. | |
3927 | ||
3928 | Now only <libguile.h> need appear in your #include path; you must | |
3929 | refer to all Guile's other header files as <libguile/mumble.h>. | |
3930 | Guile's installation procedure puts libguile.h in $(includedir), and | |
3931 | the rest in $(includedir)/libguile. | |
3932 | ||
3933 | ||
3934 | ** Two new C functions, scm_protect_object and scm_unprotect_object, | |
3935 | have been added to the Guile library. | |
3936 | ||
3937 | scm_protect_object (OBJ) protects OBJ from the garbage collector. | |
3938 | OBJ will not be freed, even if all other references are dropped, | |
3939 | until someone does scm_unprotect_object (OBJ). Both functions | |
3940 | return OBJ. | |
3941 | ||
3942 | Note that calls to scm_protect_object do not nest. You can call | |
3943 | scm_protect_object any number of times on a given object, and the | |
3944 | next call to scm_unprotect_object will unprotect it completely. | |
3945 | ||
3946 | Basically, scm_protect_object and scm_unprotect_object just | |
3947 | maintain a list of references to things. Since the GC knows about | |
3948 | this list, all objects it mentions stay alive. scm_protect_object | |
3949 | adds its argument to the list; scm_unprotect_object remove its | |
3950 | argument from the list. | |
3951 | ||
3952 | ||
3953 | ** scm_eval_0str now returns the value of the last expression | |
3954 | evaluated. | |
3955 | ||
3956 | ** The new function scm_read_0str reads an s-expression from a | |
3957 | null-terminated string, and returns it. | |
3958 | ||
3959 | ** The new function `scm_stdio_to_port' converts a STDIO file pointer | |
3960 | to a Scheme port object. | |
3961 | ||
3962 | ** The new function `scm_set_program_arguments' allows C code to set | |
e80c8fea | 3963 | the value returned by the Scheme `program-arguments' function. |
6685dc83 | 3964 | |
6685dc83 | 3965 | \f |
1a1945be JB |
3966 | Older changes: |
3967 | ||
3968 | * Guile no longer includes sophisticated Tcl/Tk support. | |
3969 | ||
3970 | The old Tcl/Tk support was unsatisfying to us, because it required the | |
3971 | user to link against the Tcl library, as well as Tk and Guile. The | |
3972 | interface was also un-lispy, in that it preserved Tcl/Tk's practice of | |
3973 | referring to widgets by names, rather than exporting widgets to Scheme | |
3974 | code as a special datatype. | |
3975 | ||
3976 | In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk | |
3977 | maintainers described some very interesting changes in progress to the | |
3978 | Tcl/Tk internals, which would facilitate clean interfaces between lone | |
3979 | Tk and other interpreters --- even for garbage-collected languages | |
3980 | like Scheme. They expected the new Tk to be publicly available in the | |
3981 | fall of 1996. | |
3982 | ||
3983 | Since it seems that Guile might soon have a new, cleaner interface to | |
3984 | lone Tk, and that the old Guile/Tk glue code would probably need to be | |
3985 | completely rewritten, we (Jim Blandy and Richard Stallman) have | |
3986 | decided not to support the old code. We'll spend the time instead on | |
3987 | a good interface to the newer Tk, as soon as it is available. | |
5c54da76 | 3988 | |
8512dea6 | 3989 | Until then, gtcltk-lib provides trivial, low-maintenance functionality. |
deb95d71 | 3990 | |
5c54da76 JB |
3991 | \f |
3992 | Copyright information: | |
3993 | ||
ea00ecba | 3994 | Copyright (C) 1996,1997 Free Software Foundation, Inc. |
5c54da76 JB |
3995 | |
3996 | Permission is granted to anyone to make or distribute verbatim copies | |
3997 | of this document as received, in any medium, provided that the | |
3998 | copyright notice and this permission notice are preserved, | |
3999 | thus giving the recipient permission to redistribute in turn. | |
4000 | ||
4001 | Permission is granted to distribute modified versions | |
4002 | of this document, or of portions of it, | |
4003 | under the above conditions, provided also that they | |
4004 | carry prominent notices stating who last changed them. | |
4005 | ||
48d224d7 JB |
4006 | \f |
4007 | Local variables: | |
4008 | mode: outline | |
4009 | paragraph-separate: "[ \f]*$" | |
4010 | end: | |
4011 |