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