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