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