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