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