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