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