Update `NEWS' wrt. `mutex-lock' deadlock fix.
[bpt/guile.git] / NEWS
CommitLineData
b2cbe8d8 1Guile NEWS --- history of user-visible changes.
189171c5 2Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5c54da76
JB
3See the end for copying conditions.
4
51d079ab
NJ
5Please send Guile bug reports to bug-guile@gnu.org. Note that you
6must be subscribed to this list first, in order to successfully send a
7report to it.
5ebbe4ef 8
5c54da76 9\f
6caac03c 10Changes in 1.9.0:
a4f1c77d 11
24d6fae8
LC
12* New modules (see the manual for details)
13
7b28af22 14** `(srfi srfi-18)', multithreading support
24d6fae8
LC
15** The `(ice-9 i18n)' module provides internationalization support
16
a4f1c77d 17* Changes to the distribution
6caac03c
LC
18
19** Guile now uses Gnulib as a portability aid
20
a4f1c77d
KR
21* Changes to the stand-alone interpreter
22* Changes to Scheme functions and syntax
8a9faebc 23
24d6fae8 24** A new 'memoize-symbol evaluator trap has been added. This trap can
8a9faebc
HWN
25be used for efficiently implementing a Scheme code coverage.
26
24d6fae8
LC
27** Duplicate bindings among used modules are resolved lazily.
28This slightly improves program startup times.
29
2e77f720
LC
30** New thread cancellation and thread cleanup API
31See `cancel-thread', `set-thread-cleanup!', and `thread-cleanup'.
32
62560650
HWN
33* Changes to the C interface
34
32e29e24
LC
35** Internal `scm_i_' functions now have "hidden" linkage with GCC/ELF
36
37This makes these internal functions technically not callable from
38application code.
39
24d6fae8
LC
40** Functions for handling `scm_option' now no longer require an argument
41indicating length of the `scm_t_option' array.
a4f1c77d 42
d41668fa
LC
43
44\f
8c40b75d
LC
45Changes in 1.8.6 (since 1.8.5)
46
071bb6a8
LC
47* New features (see the manual for details)
48
49** New convenience function `scm_c_symbol_length ()'
50
091baf9e
NJ
51** Single stepping through code from Emacs
52
53When you use GDS to evaluate Scheme code from Emacs, you can now use
54`C-u' to indicate that you want to single step through that code. See
55`Evaluating Scheme Code' in the manual for more details.
56
8c40b75d
LC
57* Bugs fixed
58
589d9eb8 59** `guile-config link' now prints `-L$libdir' before `-lguile'
4a1db3a9 60** Fix memory corruption involving GOOPS' `class-redefinition'
191e7165 61** Fix possible deadlock in `mutex-lock'
95c6523b 62** Fix build issue on Tru64 and ia64-hp-hpux11.23 (`SCM_UNPACK' macro)
4696a666 63** Fix build issue on mips, mipsel, powerpc and ia64 (stack direction)
450be18d 64** Fix build issue on hppa2.0w-hp-hpux11.11 (`dirent64' and `readdir64_r')
76dae881 65** Fix misleading output from `(help rationalize)'
5ea8e76e 66** Fix build failure on Debian hppa architecture (bad stack growth detection)
6eadcdab 67
8c40b75d 68\f
5305df84
LC
69Changes in 1.8.5 (since 1.8.4)
70
4b824aae
LC
71* Infrastructure changes
72
73** Guile repository switched from CVS to Git
74
75The new repository can be accessed using
76"git-clone git://git.sv.gnu.org/guile.git", or can be browsed on-line at
77http://git.sv.gnu.org/gitweb/?p=guile.git . See `README' for details.
78
92826dd0
LC
79** Add support for `pkg-config'
80
81See "Autoconf Support" in the manual for details.
82
189681f5
LC
83* New modules (see the manual for details)
84
85** `(srfi srfi-88)'
86
ef4cbc08
LC
87* New features (see the manual for details)
88
89** New `postfix' read option, for SRFI-88 keyword syntax
f5c2af4b 90** Some I/O primitives have been inlined, which improves I/O performance
b20ef3a6 91** New object-based traps infrastructure
ef4cbc08 92
b20ef3a6
NJ
93This is a GOOPS-based infrastructure that builds on Guile's low-level
94evaluator trap calls and facilitates the development of debugging
95features like single-stepping, breakpoints, tracing and profiling.
96See the `Traps' node of the manual for details.
97
98** New support for working on Guile code from within Emacs
99
100Guile now incorporates the `GDS' library (previously distributed
101separately) for working on Guile code from within Emacs. See the
102`Using Guile In Emacs' node of the manual for details.
103
5305df84
LC
104* Bugs fixed
105
e27d2495
LC
106** `scm_add_slot ()' no longer segfaults (fixes bug #22369)
107** Fixed `(ice-9 match)' for patterns like `((_ ...) ...)'
108
109Previously, expressions like `(match '((foo) (bar)) (((_ ...) ...) #t))'
110would trigger an unbound variable error for `match:andmap'.
111
62c5382b
LC
112** `(oop goops describe)' now properly provides the `describe' feature
113** Fixed `args-fold' from `(srfi srfi-37)'
114
115Previously, parsing short option names of argument-less options would
116lead to a stack overflow.
117
816e3edf 118** `(srfi srfi-35)' is now visible through `cond-expand'
61b6542a 119** Fixed type-checking for the second argument of `eval'
0fb11ae4 120** Fixed type-checking for SRFI-1 `partition'
f1c212b1
LC
121** Fixed `struct-ref' and `struct-set!' on "light structs"
122** Honor struct field access rights in GOOPS
be10cba8 123** Changed the storage strategy of source properties, which fixes a deadlock
979eade6 124** Allow compilation of Guile-using programs in C99 mode with GCC 4.3 and later
bfb64eb4 125** Fixed build issue for GNU/Linux on IA64
fa80e280 126** Fixed build issues on NetBSD 1.6
a2c25234 127** Fixed build issue on Solaris 2.10 x86_64
3f520967 128** Fixed build issue with DEC/Compaq/HP's compiler
c2ad98ad
LC
129** Fixed `scm_from_complex_double' build issue on FreeBSD
130** Fixed `alloca' build issue on FreeBSD 6
a7286720 131** Removed use of non-portable makefile constructs
535b3592 132** Fixed shadowing of libc's <random.h> on Tru64, which broke compilation
eedcb08a 133** Make sure all tests honor `$TMPDIR'
5305df84 134
d53f85dd
NJ
135* Changes to the distribution
136
137** New FAQ
138
139We've started collecting Frequently Asked Questions (FAQ), and will
140distribute these (with answers!) in future Guile releases.
141
5305df84 142\f
d41668fa
LC
143Changes in 1.8.4 (since 1.8.3)
144
145* Bugs fixed
146
147** CR (ASCII 0x0d) is (again) recognized as a token delimiter by the reader
6e14de7d
NJ
148** Fixed a segmentation fault which occurred when displaying the
149backtrace of a stack with a promise object (made by `delay') in it.
7d1fc872 150** Make `accept' leave guile mode while blocking
693758d5 151** `scm_c_read ()' and `scm_c_write ()' now type-check their port argument
378cc645 152** Fixed a build problem on AIX (use of func_data identifier)
15bd90ea
NJ
153** Fixed a segmentation fault which occurred when hashx-ref or hashx-set! was
154called with an associator proc that returns neither a pair nor #f.
3ac8359a 155** Secondary threads now always return a valid module for (current-module).
d05bcb2e
NJ
156** Avoid MacOS build problems caused by incorrect combination of "64"
157system and library calls.
9a6fac59 158** `guile-snarf' now honors `$TMPDIR'
25a640ca 159** `guile-config compile' now reports CPPFLAGS used at compile-time
7f74cf9a 160** Fixed build with Sun Studio (Solaris 9)
4a19ed04
NJ
161** Fixed wrong-type-arg errors when creating zero length SRFI-4
162uniform vectors on AIX.
86a597f8 163** Fixed a deadlock that occurs upon GC with multiple threads.
4b26c03e 164** Fixed compile problem with GCC on Solaris and AIX (use of _Complex_I)
d4a00708 165** Fixed autotool-derived build problems on AIX 6.1.
9a6fac59 166** Fixed NetBSD/alpha support
b226295a 167** Fixed MacOS build problem caused by use of rl_get_keymap(_name)
7d1fc872
LC
168
169* New modules (see the manual for details)
170
171** `(srfi srfi-69)'
d41668fa 172
b226295a
NJ
173* Documentation fixes and improvements
174
175** Removed premature breakpoint documentation
176
177The features described are not available in the series of 1.8.x
178releases, so the documentation was misleading and has been removed.
179
180** More about Guile's default *random-state* variable
181
182** GOOPS: more about how to use `next-method'
183
d3cf93bc
NJ
184* Changes to the distribution
185
186** Corrected a few files that referred incorrectly to the old GPL + special exception licence
187
188In fact Guile since 1.8.0 has been licensed with the GNU Lesser
189General Public License, and the few incorrect files have now been
190fixed to agree with the rest of the Guile distribution.
191
5e42b8e7
NJ
192** Removed unnecessary extra copies of COPYING*
193
194The distribution now contains a single COPYING.LESSER at its top level.
195
a4f1c77d 196\f
d4c38221
LC
197Changes in 1.8.3 (since 1.8.2)
198
199* New modules (see the manual for details)
200
f50ca8da 201** `(srfi srfi-35)'
d4c38221
LC
202** `(srfi srfi-37)'
203
e08f3f7a
LC
204* Bugs fixed
205
dc061a74 206** The `(ice-9 slib)' module now works as expected
e08f3f7a 207** Expressions like "(set! 'x #t)" no longer yield a crash
d7c0c26d 208** Warnings about duplicate bindings now go to stderr
1ac5fb45 209** A memory leak in `make-socket-address' was fixed
f43f3620 210** Alignment issues (e.g., on SPARC) in network routines were fixed
29776e85 211** A threading issue that showed up at least on NetBSD was fixed
66302618 212** Build problems on Solaris and IRIX fixed
e08f3f7a 213
1fdd8ffa
LC
214* Implementation improvements
215
7ff6c169 216** The reader is now faster, which reduces startup time
1fdd8ffa
LC
217** Procedures returned by `record-accessor' and `record-modifier' are faster
218
219
d4c38221 220\f
45c0ff10
KR
221Changes in 1.8.2 (since 1.8.1):
222
223* New procedures (see the manual for details)
224
225** set-program-arguments
b3aa4626 226** make-vtable
45c0ff10
KR
227
228* Bugs fixed
229
230** Fractions were not `equal?' if stored in unreduced form.
231(A subtle problem, since printing a value reduced it, making it work.)
232** srfi-60 `copy-bit' failed on 64-bit systems
233** "guile --use-srfi" option at the REPL can replace core functions
234(Programs run with that option were ok, but in the interactive REPL
235the core bindings got priority, preventing SRFI replacements or
236extensions.)
237** `regexp-exec' doesn't abort() on #\nul in the input or bad flags arg
df449722 238** `kill' on mingw throws an error for a PID other than oneself
45c0ff10
KR
239** Procedure names are attached to procedure-with-setters
240** Array read syntax works with negative lower bound
241** `array-in-bounds?' fix if an array has different lower bounds on each index
242** `*' returns exact 0 for "(* inexact 0)"
243This follows what it always did for "(* 0 inexact)".
c122500a 244** SRFI-19: Value returned by `(current-time time-process)' was incorrect
0867f7ba 245** SRFI-19: `date->julian-day' did not account for timezone offset
a1ef7406 246** `ttyname' no longer crashes when passed a non-tty argument
27782696 247** `inet-ntop' no longer crashes on SPARC when passed an `AF_INET' address
0867f7ba 248** Small memory leaks have been fixed in `make-fluid' and `add-history'
b1f57ea4 249** GOOPS: Fixed a bug in `method-more-specific?'
45c0ff10 250** Build problems on Solaris fixed
df449722
LC
251** Build problems on HP-UX IA64 fixed
252** Build problems on MinGW fixed
45c0ff10
KR
253
254\f
a4f1c77d
KR
255Changes in 1.8.1 (since 1.8.0):
256
8ab3d8a0 257* LFS functions are now used to access 64-bit files on 32-bit systems.
a4f1c77d 258
8ab3d8a0 259* New procedures (see the manual for details)
4f416616 260
8ab3d8a0
KR
261** primitive-_exit - [Scheme] the-root-module
262** scm_primitive__exit - [C]
263** make-completion-function - [Scheme] (ice-9 readline)
264** scm_c_locale_stringn_to_number - [C]
265** scm_srfi1_append_reverse [C]
266** scm_srfi1_append_reverse_x [C]
267** scm_log - [C]
268** scm_log10 - [C]
269** scm_exp - [C]
270** scm_sqrt - [C]
271
b89c4943
LC
272* New `(ice-9 i18n)' module (see the manual for details)
273
8ab3d8a0
KR
274* Bugs fixed
275
276** Build problems have been fixed on MacOS, SunOS, and QNX.
af4f8612 277
b3aa4626
KR
278** `strftime' fix sign of %z timezone offset.
279
534cd148 280** A one-dimensional array can now be 'equal?' to a vector.
8ab3d8a0 281
ad97642e 282** Structures, records, and SRFI-9 records can now be compared with `equal?'.
af4f8612 283
8ab3d8a0
KR
284** SRFI-14 standard char sets are recomputed upon a successful `setlocale'.
285
286** `record-accessor' and `record-modifier' now have strict type checks.
287
288Record accessor and modifier procedures now throw an error if the
289record type of the record they're given is not the type expected.
290(Previously accessors returned #f and modifiers silently did nothing).
291
292** It is now OK to use both autoload and use-modules on a given module.
293
294** `apply' checks the number of arguments more carefully on "0 or 1" funcs.
295
296Previously there was no checking on primatives like make-vector that
297accept "one or two" arguments. Now there is.
298
299** The srfi-1 assoc function now calls its equality predicate properly.
300
301Previously srfi-1 assoc would call the equality predicate with the key
302last. According to the SRFI, the key should be first.
303
304** A bug in n-par-for-each and n-for-each-par-map has been fixed.
305
306** The array-set! procedure no longer segfaults when given a bit vector.
307
308** Bugs in make-shared-array have been fixed.
309
310** string<? and friends now follow char<? etc order on 8-bit chars.
311
312** The format procedure now handles inf and nan values for ~f correctly.
313
314** exact->inexact should no longer overflow when given certain large fractions.
315
316** srfi-9 accessor and modifier procedures now have strict record type checks.
a4f1c77d 317
8ab3d8a0 318This matches the srfi-9 specification.
a4f1c77d 319
8ab3d8a0 320** (ice-9 ftw) procedures won't ignore different files with same inode number.
a4f1c77d 321
8ab3d8a0
KR
322Previously the (ice-9 ftw) procedures would ignore any file that had
323the same inode number as a file they had already seen, even if that
324file was on a different device.
4f416616
KR
325
326\f
8ab3d8a0 327Changes in 1.8.0 (changes since the 1.6.x series):
ee0c7345 328
4e250ded
MV
329* Changes to the distribution
330
eff2965e
MV
331** Guile is now licensed with the GNU Lesser General Public License.
332
77e51fd6
MV
333** The manual is now licensed with the GNU Free Documentation License.
334
e2d0a649
RB
335** Guile now requires GNU MP (http://swox.com/gmp).
336
337Guile now uses the GNU MP library for arbitrary precision arithmetic.
e2d0a649 338
5ebbe4ef
RB
339** Guile now has separate private and public configuration headers.
340
b0d10ba6
MV
341That is, things like HAVE_STRING_H no longer leak from Guile's
342headers.
5ebbe4ef
RB
343
344** Guile now provides and uses an "effective" version number.
b2cbe8d8
RB
345
346Guile now provides scm_effective_version and effective-version
347functions which return the "effective" version number. This is just
348the normal full version string without the final micro-version number,
a4f1c77d 349so the current effective-version is "1.8". The effective version
b2cbe8d8
RB
350should remain unchanged during a stable series, and should be used for
351items like the versioned share directory name
a4f1c77d 352i.e. /usr/share/guile/1.8.
b2cbe8d8
RB
353
354Providing an unchanging version number during a stable release for
355things like the versioned share directory can be particularly
356important for Guile "add-on" packages, since it provides a directory
357that they can install to that won't be changed out from under them
358with each micro release during a stable series.
359
8d54e73a 360** Thread implementation has changed.
f0b4d944
MV
361
362When you configure "--with-threads=null", you will get the usual
363threading API (call-with-new-thread, make-mutex, etc), but you can't
429d88d4
MV
364actually create new threads. Also, "--with-threads=no" is now
365equivalent to "--with-threads=null". This means that the thread API
366is always present, although you might not be able to create new
367threads.
f0b4d944 368
8d54e73a
MV
369When you configure "--with-threads=pthreads" or "--with-threads=yes",
370you will get threads that are implemented with the portable POSIX
371threads. These threads can run concurrently (unlike the previous
372"coop" thread implementation), but need to cooperate for things like
a558cc63 373the GC.
f0b4d944 374
8d54e73a
MV
375The default is "pthreads", unless your platform doesn't have pthreads,
376in which case "null" threads are used.
2902a459 377
a6d75e53
MV
378See the manual for details, nodes "Initialization", "Multi-Threading",
379"Blocking", and others.
a558cc63 380
f74bdbd3
MV
381** There is the new notion of 'discouraged' features.
382
383This is a milder form of deprecation.
384
385Things that are discouraged should not be used in new code, but it is
386OK to leave them in old code for now. When a discouraged feature is
387used, no warning message is printed like there is for 'deprecated'
388features. Also, things that are merely discouraged are nevertheless
389implemented efficiently, while deprecated features can be very slow.
390
391You can omit discouraged features from libguile by configuring it with
392the '--disable-discouraged' option.
393
394** Deprecation warnings can be controlled at run-time.
395
396(debug-enable 'warn-deprecated) switches them on and (debug-disable
397'warn-deprecated) switches them off.
398
0f24e75b 399** Support for SRFI 61, extended cond syntax for multiple values has
a81d0de1
MV
400 been added.
401
402This SRFI is always available.
403
f7fb2f39 404** Support for require-extension, SRFI-55, has been added.
9a5fc8c2 405
f7fb2f39
RB
406The SRFI-55 special form `require-extension' has been added. It is
407available at startup, and provides a portable way to load Scheme
408extensions. SRFI-55 only requires support for one type of extension,
409"srfi"; so a set of SRFIs may be loaded via (require-extension (srfi 1
41013 14)).
411
412** New module (srfi srfi-26) provides support for `cut' and `cute'.
413
414The (srfi srfi-26) module is an implementation of SRFI-26 which
415provides the `cut' and `cute' syntax. These may be used to specialize
416parameters without currying.
9a5fc8c2 417
f5d54eb7
RB
418** New module (srfi srfi-31)
419
420This is an implementation of SRFI-31 which provides a special form
421`rec' for recursive evaluation.
422
7b1574ed
MV
423** The modules (srfi srfi-13), (srfi srfi-14) and (srfi srfi-4) have
424 been merged with the core, making their functionality always
425 available.
c5080b51 426
ce7c0293
MV
427The modules are still available, tho, and you could use them together
428with a renaming import, for example.
c5080b51 429
6191ccec 430** Guile no longer includes its own version of libltdl.
4e250ded 431
6191ccec 432The official version is good enough now.
4e250ded 433
ae7ded56
MV
434** The --enable-htmldoc option has been removed from 'configure'.
435
436Support for translating the documentation into HTML is now always
437provided. Use 'make html'.
438
0f24e75b
MV
439** New module (ice-9 serialize):
440
441(serialize FORM1 ...) and (parallelize FORM1 ...) are useful when you
442don't trust the thread safety of most of your program, but where you
443have some section(s) of code which you consider can run in parallel to
444other sections. See ice-9/serialize.scm for more information.
445
c34e5780
MV
446** The configure option '--disable-arrays' has been removed.
447
448Support for arrays and uniform numeric arrays is now always included
449in Guile.
450
328dc9a3 451* Changes to the stand-alone interpreter
f12ef3fd 452
3ece39d6
MV
453** New command line option `-L'.
454
455This option adds a directory to the front of the load path.
456
f12ef3fd
MV
457** New command line option `--no-debug'.
458
459Specifying `--no-debug' on the command line will keep the debugging
460evaluator turned off, even for interactive sessions.
461
462** User-init file ~/.guile is now loaded with the debugging evaluator.
463
464Previously, the normal evaluator would have been used. Using the
465debugging evaluator gives better error messages.
466
aff7e166
MV
467** The '-e' option now 'read's its argument.
468
469This is to allow the new '(@ MODULE-NAME VARIABLE-NAME)' construct to
470be used with '-e'. For example, you can now write a script like
471
472 #! /bin/sh
473 exec guile -e '(@ (demo) main)' -s "$0" "$@"
474 !#
475
476 (define-module (demo)
477 :export (main))
478
479 (define (main args)
480 (format #t "Demo: ~a~%" args))
481
482
f12ef3fd
MV
483* Changes to Scheme functions and syntax
484
930888e8
MV
485** Guardians have changed back to their original semantics
486
487Guardians now behave like described in the paper by Dybvig et al. In
488particular, they no longer make guarantees about the order in which
489they return objects, and they can no longer be greedy.
490
491They no longer drop cyclic data structures.
492
493The C function scm_make_guardian has been changed incompatibly and no
494longer takes the 'greedy_p' argument.
495
87bdbdbc
MV
496** New function hashx-remove!
497
498This function completes the set of 'hashx' functions.
499
a558cc63
MV
500** The concept of dynamic roots has been factored into continuation
501 barriers and dynamic states.
502
503Each thread has a current dynamic state that carries the values of the
504fluids. You can create and copy dynamic states and use them as the
505second argument for 'eval'. See "Fluids and Dynamic States" in the
506manual.
507
508To restrict the influence that captured continuations can have on the
509control flow, you can errect continuation barriers. See "Continuation
510Barriers" in the manual.
511
512The function call-with-dynamic-root now essentially temporarily
513installs a new dynamic state and errects a continuation barrier.
514
a2b6a0e7
MV
515** The default load path no longer includes "." at the end.
516
517Automatically loading modules from the current directory should not
518happen by default. If you want to allow it in a more controlled
519manner, set the environment variable GUILE_LOAD_PATH or the Scheme
520variable %load-path.
521
7b1574ed
MV
522** The uniform vector and array support has been overhauled.
523
524It now complies with SRFI-4 and the weird prototype based uniform
525array creation has been deprecated. See the manual for more details.
526
d233b123
MV
527Some non-compatible changes have been made:
528 - characters can no longer be stored into byte arrays.
0f24e75b
MV
529 - strings and bit vectors are no longer considered to be uniform numeric
530 vectors.
3167d5e4
MV
531 - array-rank throws an error for non-arrays instead of returning zero.
532 - array-ref does no longer accept non-arrays when no indices are given.
d233b123
MV
533
534There is the new notion of 'generalized vectors' and corresponding
535procedures like 'generalized-vector-ref'. Generalized vectors include
c34e5780 536strings, bitvectors, ordinary vectors, and uniform numeric vectors.
d233b123 537
a558cc63
MV
538Arrays use generalized vectors as their storage, so that you still
539have arrays of characters, bits, etc. However, uniform-array-read!
540and uniform-array-write can no longer read/write strings and
541bitvectors.
bb9f50ae 542
ce7c0293
MV
543** There is now support for copy-on-write substrings, mutation-sharing
544 substrings and read-only strings.
3ff9283d 545
ce7c0293
MV
546Three new procedures are related to this: substring/shared,
547substring/copy, and substring/read-only. See the manual for more
548information.
549
6a1d27ea
MV
550** Backtraces will now highlight the value that caused the error.
551
552By default, these values are enclosed in "{...}", such as in this
553example:
554
555 guile> (car 'a)
556
557 Backtrace:
558 In current input:
559 1: 0* [car {a}]
560
561 <unnamed port>:1:1: In procedure car in expression (car (quote a)):
562 <unnamed port>:1:1: Wrong type (expecting pair): a
563 ABORT: (wrong-type-arg)
564
565The prefix and suffix used for highlighting can be set via the two new
566printer options 'highlight-prefix' and 'highlight-suffix'. For
567example, putting this into ~/.guile will output the bad value in bold
568on an ANSI terminal:
569
570 (print-set! highlight-prefix "\x1b[1m")
571 (print-set! highlight-suffix "\x1b[22m")
572
573
8dbafacd
MV
574** 'gettext' support for internationalization has been added.
575
576See the manual for details.
577
aff7e166
MV
578** New syntax '@' and '@@':
579
580You can now directly refer to variables exported from a module by
581writing
582
583 (@ MODULE-NAME VARIABLE-NAME)
584
585For example (@ (ice-9 pretty-print) pretty-print) will directly access
586the pretty-print variable exported from the (ice-9 pretty-print)
587module. You don't need to 'use' that module first. You can also use
b0d10ba6 588'@' as a target of 'set!', as in (set! (@ mod var) val).
aff7e166
MV
589
590The related syntax (@@ MODULE-NAME VARIABLE-NAME) works just like '@',
591but it can also access variables that have not been exported. It is
592intended only for kluges and temporary fixes and for debugging, not
593for ordinary code.
594
aef0bdb4
MV
595** Keyword syntax has been made more disciplined.
596
597Previously, the name of a keyword was read as a 'token' but printed as
598a symbol. Now, it is read as a general Scheme datum which must be a
599symbol.
600
601Previously:
602
603 guile> #:12
604 #:#{12}#
605 guile> #:#{12}#
606 #:#{\#{12}\#}#
607 guile> #:(a b c)
608 #:#{}#
609 ERROR: In expression (a b c):
610 Unbound variable: a
611 guile> #: foo
612 #:#{}#
613 ERROR: Unbound variable: foo
614
615Now:
616
617 guile> #:12
618 ERROR: Wrong type (expecting symbol): 12
619 guile> #:#{12}#
620 #:#{12}#
621 guile> #:(a b c)
622 ERROR: Wrong type (expecting symbol): (a b c)
623 guile> #: foo
624 #:foo
625
227eafdb
MV
626** The printing of symbols that might look like keywords can be
627 controlled.
628
629The new printer option 'quote-keywordish-symbols' controls how symbols
630are printed that have a colon as their first or last character. The
631default now is to only quote a symbol with #{...}# when the read
632option 'keywords' is not '#f'. Thus:
633
634 guile> (define foo (string->symbol ":foo"))
635 guile> (read-set! keywords #f)
636 guile> foo
637 :foo
638 guile> (read-set! keywords 'prefix)
639 guile> foo
640 #{:foo}#
641 guile> (print-set! quote-keywordish-symbols #f)
642 guile> foo
643 :foo
644
1363e3e7
KR
645** 'while' now provides 'break' and 'continue'
646
647break and continue were previously bound in a while loop, but not
648documented, and continue didn't quite work properly. The undocumented
649parameter to break which gave a return value for the while has been
650dropped.
651
570b5b14
MV
652** 'call-with-current-continuation' is now also available under the name
653 'call/cc'.
654
b0d10ba6 655** The module system now checks for duplicate bindings.
7b07e5ef 656
fe6ee052
MD
657The module system now can check for name conflicts among imported
658bindings.
f595ccfe 659
b0d10ba6 660The behavior can be controlled by specifying one or more 'duplicates'
fe6ee052
MD
661handlers. For example, to make Guile return an error for every name
662collision, write:
7b07e5ef
MD
663
664(define-module (foo)
665 :use-module (bar)
666 :use-module (baz)
fe6ee052 667 :duplicates check)
f595ccfe 668
fe6ee052
MD
669The new default behavior of the module system when a name collision
670has been detected is to
671
672 1. Give priority to bindings marked as a replacement.
6496a663 673 2. Issue a warning (different warning if overriding core binding).
fe6ee052
MD
674 3. Give priority to the last encountered binding (this corresponds to
675 the old behavior).
676
677If you want the old behavior back without replacements or warnings you
678can add the line:
f595ccfe 679
70a9dc9c 680 (default-duplicate-binding-handler 'last)
7b07e5ef 681
fe6ee052 682to your .guile init file.
7b07e5ef 683
f595ccfe
MD
684** New define-module option: :replace
685
686:replace works as :export, but, in addition, marks the binding as a
687replacement.
688
689A typical example is `format' in (ice-9 format) which is a replacement
690for the core binding `format'.
7b07e5ef 691
70da0033
MD
692** Adding prefixes to imported bindings in the module system
693
694There is now a new :use-module option :prefix. It can be used to add
695a prefix to all imported bindings.
696
697 (define-module (foo)
698 :use-module ((bar) :prefix bar:))
699
700will import all bindings exported from bar, but rename them by adding
701the prefix `bar:'.
702
b0d10ba6
MV
703** Conflicting generic functions can be automatically merged.
704
705When two imported bindings conflict and they are both generic
706functions, the two functions can now be merged automatically. This is
707activated with the 'duplicates' handler 'merge-generics'.
708
b2cbe8d8
RB
709** New function: effective-version
710
711Returns the "effective" version number. This is just the normal full
712version string without the final micro-version number. See "Changes
713to the distribution" above.
714
382053e9 715** New threading functions: parallel, letpar, par-map, and friends
dbe30084 716
382053e9
KR
717These are convenient ways to run calculations in parallel in new
718threads. See "Parallel forms" in the manual for details.
359aab24 719
e2d820a1
MV
720** New function 'try-mutex'.
721
722This function will attempt to lock a mutex but will return immediately
0f24e75b 723instead of blocking and indicate failure.
e2d820a1
MV
724
725** Waiting on a condition variable can have a timeout.
726
0f24e75b 727The function 'wait-condition-variable' now takes a third, optional
e2d820a1
MV
728argument that specifies the point in time where the waiting should be
729aborted.
730
731** New function 'broadcast-condition-variable'.
732
5e405a60
MV
733** New functions 'all-threads' and 'current-thread'.
734
735** Signals and system asyncs work better with threads.
736
737The function 'sigaction' now takes a fourth, optional, argument that
738specifies the thread that the handler should run in. When the
739argument is omitted, the handler will run in the thread that called
740'sigaction'.
741
742Likewise, 'system-async-mark' takes a second, optional, argument that
743specifies the thread that the async should run in. When it is
744omitted, the async will run in the thread that called
745'system-async-mark'.
746
747C code can use the new functions scm_sigaction_for_thread and
748scm_system_async_mark_for_thread to pass the new thread argument.
749
a558cc63
MV
750When a thread blocks on a mutex, a condition variable or is waiting
751for IO to be possible, it will still execute system asyncs. This can
752be used to interrupt such a thread by making it execute a 'throw', for
753example.
754
5e405a60
MV
755** The function 'system-async' is deprecated.
756
757You can now pass any zero-argument procedure to 'system-async-mark'.
758The function 'system-async' will just return its argument unchanged
759now.
760
acfa1f52
MV
761** New functions 'call-with-blocked-asyncs' and
762 'call-with-unblocked-asyncs'
763
764The expression (call-with-blocked-asyncs PROC) will call PROC and will
765block execution of system asyncs for the current thread by one level
766while PROC runs. Likewise, call-with-unblocked-asyncs will call a
767procedure and will unblock the execution of system asyncs by one
768level for the current thread.
769
770Only system asyncs are affected by these functions.
771
772** The functions 'mask-signals' and 'unmask-signals' are deprecated.
773
774Use 'call-with-blocked-asyncs' or 'call-with-unblocked-asyncs'
775instead. Those functions are easier to use correctly and can be
776nested.
777
7b232758
MV
778** New function 'unsetenv'.
779
f30482f3
MV
780** New macro 'define-syntax-public'.
781
782It works like 'define-syntax' and also exports the defined macro (but
783only on top-level).
784
1ee34062
MV
785** There is support for Infinity and NaNs.
786
787Following PLT Scheme, Guile can now work with infinite numbers, and
788'not-a-numbers'.
789
790There is new syntax for numbers: "+inf.0" (infinity), "-inf.0"
791(negative infinity), "+nan.0" (not-a-number), and "-nan.0" (same as
792"+nan.0"). These numbers are inexact and have no exact counterpart.
793
794Dividing by an inexact zero returns +inf.0 or -inf.0, depending on the
795sign of the dividend. The infinities are integers, and they answer #t
796for both 'even?' and 'odd?'. The +nan.0 value is not an integer and is
797not '=' to itself, but '+nan.0' is 'eqv?' to itself.
798
799For example
800
801 (/ 1 0.0)
802 => +inf.0
803
804 (/ 0 0.0)
805 => +nan.0
806
807 (/ 0)
808 ERROR: Numerical overflow
809
7b232758
MV
810Two new predicates 'inf?' and 'nan?' can be used to test for the
811special values.
812
ba1b077b
MV
813** Inexact zero can have a sign.
814
815Guile can now distinguish between plus and minus inexact zero, if your
816platform supports this, too. The two zeros are equal according to
817'=', but not according to 'eqv?'. For example
818
819 (- 0.0)
820 => -0.0
821
822 (= 0.0 (- 0.0))
823 => #t
824
825 (eqv? 0.0 (- 0.0))
826 => #f
827
bdf26b60
MV
828** Guile now has exact rationals.
829
830Guile can now represent fractions such as 1/3 exactly. Computing with
831them is also done exactly, of course:
832
833 (* 1/3 3/2)
834 => 1/2
835
836** 'floor', 'ceiling', 'round' and 'truncate' now return exact numbers
837 for exact arguments.
838
839For example: (floor 2) now returns an exact 2 where in the past it
840returned an inexact 2.0. Likewise, (floor 5/4) returns an exact 1.
841
842** inexact->exact no longer returns only integers.
843
844Without exact rationals, the closest exact number was always an
845integer, but now inexact->exact returns the fraction that is exactly
846equal to a floating point number. For example:
847
848 (inexact->exact 1.234)
849 => 694680242521899/562949953421312
850
e299cee2 851When you want the old behavior, use 'round' explicitly:
bdf26b60
MV
852
853 (inexact->exact (round 1.234))
854 => 1
855
856** New function 'rationalize'.
857
858This function finds a simple fraction that is close to a given real
859number. For example (and compare with inexact->exact above):
860
fb16d26e 861 (rationalize (inexact->exact 1.234) 1/2000)
bdf26b60
MV
862 => 58/47
863
fb16d26e
MV
864Note that, as required by R5RS, rationalize returns only then an exact
865result when both its arguments are exact.
866
bdf26b60
MV
867** 'odd?' and 'even?' work also for inexact integers.
868
869Previously, (odd? 1.0) would signal an error since only exact integers
870were recognized as integers. Now (odd? 1.0) returns #t, (odd? 2.0)
871returns #f and (odd? 1.5) signals an error.
872
b0d10ba6 873** Guile now has uninterned symbols.
610922b2 874
b0d10ba6 875The new function 'make-symbol' will return an uninterned symbol. This
610922b2
MV
876is a symbol that is unique and is guaranteed to remain unique.
877However, uninterned symbols can not yet be read back in.
878
879Use the new function 'symbol-interned?' to check whether a symbol is
880interned or not.
881
0e6f7775
MV
882** pretty-print has more options.
883
884The function pretty-print from the (ice-9 pretty-print) module can now
885also be invoked with keyword arguments that control things like
71f271b2 886maximum output width. See the manual for details.
0e6f7775 887
8c84b81e 888** Variables have no longer a special behavior for `equal?'.
ee0c7345
MV
889
890Previously, comparing two variables with `equal?' would recursivly
891compare their values. This is no longer done. Variables are now only
892`equal?' if they are `eq?'.
893
4e21fa60
MV
894** `(begin)' is now valid.
895
896You can now use an empty `begin' form. It will yield #<unspecified>
897when evaluated and simply be ignored in a definition context.
898
3063e30a
DH
899** Deprecated: procedure->macro
900
b0d10ba6
MV
901Change your code to use 'define-macro' or r5rs macros. Also, be aware
902that macro expansion will not be done during evaluation, but prior to
903evaluation.
3063e30a 904
0a50eeaa
NJ
905** Soft ports now allow a `char-ready?' procedure
906
907The vector argument to `make-soft-port' can now have a length of
908either 5 or 6. (Previously the length had to be 5.) The optional 6th
909element is interpreted as an `input-waiting' thunk -- i.e. a thunk
910that returns the number of characters that can be read immediately
911without the soft port blocking.
912
63dd3413
DH
913** Deprecated: undefine
914
915There is no replacement for undefine.
916
9abd541e
NJ
917** The functions make-keyword-from-dash-symbol and keyword-dash-symbol
918 have been discouraged.
aef0bdb4
MV
919
920They are relics from a time where a keyword like #:foo was used
921directly as a Tcl option "-foo" and thus keywords were internally
922stored as a symbol with a starting dash. We now store a symbol
923without the dash.
924
925Use symbol->keyword and keyword->symbol instead.
926
9abd541e
NJ
927** The `cheap' debug option is now obsolete
928
929Evaluator trap calls are now unconditionally "cheap" - in other words,
930they pass a debug object to the trap handler rather than a full
931continuation. The trap handler code can capture a full continuation
932by using `call-with-current-continuation' in the usual way, if it so
933desires.
934
935The `cheap' option is retained for now so as not to break existing
936code which gets or sets it, but setting it now has no effect. It will
937be removed in the next major Guile release.
938
939** Evaluator trap calls now support `tweaking'
940
941`Tweaking' means that the trap handler code can modify the Scheme
942expression that is about to be evaluated (in the case of an
943enter-frame trap) or the value that is being returned (in the case of
944an exit-frame trap). The trap handler code indicates that it wants to
945do this by returning a pair whose car is the symbol 'instead and whose
946cdr is the modified expression or return value.
36a9b236 947
b00418df
DH
948* Changes to the C interface
949
87bdbdbc
MV
950** The functions scm_hash_fn_remove_x and scm_hashx_remove_x no longer
951 take a 'delete' function argument.
952
953This argument makes no sense since the delete function is used to
954remove a pair from an alist, and this must not be configurable.
955
956This is an incompatible change.
957
1cf1bb95
MV
958** The GH interface is now subject to the deprecation mechanism
959
960The GH interface has been deprecated for quite some time but now it is
961actually removed from Guile when it is configured with
962--disable-deprecated.
963
964See the manual "Transitioning away from GH" for more information.
965
f7f3964e
MV
966** A new family of functions for converting between C values and
967 Scheme values has been added.
968
969These functions follow a common naming scheme and are designed to be
970easier to use, thread-safe and more future-proof than the older
971alternatives.
972
973 - int scm_is_* (...)
974
975 These are predicates that return a C boolean: 1 or 0. Instead of
976 SCM_NFALSEP, you can now use scm_is_true, for example.
977
978 - <type> scm_to_<type> (SCM val, ...)
979
980 These are functions that convert a Scheme value into an appropriate
981 C value. For example, you can use scm_to_int to safely convert from
982 a SCM to an int.
983
a2b6a0e7 984 - SCM scm_from_<type> (<type> val, ...)
f7f3964e
MV
985
986 These functions convert from a C type to a SCM value; for example,
987 scm_from_int for ints.
988
989There is a huge number of these functions, for numbers, strings,
990symbols, vectors, etc. They are documented in the reference manual in
991the API section together with the types that they apply to.
992
96d8c217
MV
993** New functions for dealing with complex numbers in C have been added.
994
995The new functions are scm_c_make_rectangular, scm_c_make_polar,
996scm_c_real_part, scm_c_imag_part, scm_c_magnitude and scm_c_angle.
997They work like scm_make_rectangular etc but take or return doubles
998directly.
999
1000** The function scm_make_complex has been discouraged.
1001
1002Use scm_c_make_rectangular instead.
1003
f7f3964e
MV
1004** The INUM macros have been deprecated.
1005
1006A lot of code uses these macros to do general integer conversions,
b0d10ba6
MV
1007although the macros only work correctly with fixnums. Use the
1008following alternatives.
f7f3964e
MV
1009
1010 SCM_INUMP -> scm_is_integer or similar
1011 SCM_NINUMP -> !scm_is_integer or similar
1012 SCM_MAKINUM -> scm_from_int or similar
1013 SCM_INUM -> scm_to_int or similar
1014
b0d10ba6 1015 SCM_VALIDATE_INUM_* -> Do not use these; scm_to_int, etc. will
f7f3964e
MV
1016 do the validating for you.
1017
f9656a9f
MV
1018** The scm_num2<type> and scm_<type>2num functions and scm_make_real
1019 have been discouraged.
f7f3964e
MV
1020
1021Use the newer scm_to_<type> and scm_from_<type> functions instead for
1022new code. The functions have been discouraged since they don't fit
1023the naming scheme.
1024
1025** The 'boolean' macros SCM_FALSEP etc have been discouraged.
1026
1027They have strange names, especially SCM_NFALSEP, and SCM_BOOLP
1028evaluates its argument twice. Use scm_is_true, etc. instead for new
1029code.
1030
1031** The macro SCM_EQ_P has been discouraged.
1032
1033Use scm_is_eq for new code, which fits better into the naming
1034conventions.
d5b203a6 1035
d5ac9b2a
MV
1036** The macros SCM_CONSP, SCM_NCONSP, SCM_NULLP, and SCM_NNULLP have
1037 been discouraged.
1038
1039Use the function scm_is_pair or scm_is_null instead.
1040
409eb4e5
MV
1041** The functions scm_round and scm_truncate have been deprecated and
1042 are now available as scm_c_round and scm_c_truncate, respectively.
1043
1044These functions occupy the names that scm_round_number and
1045scm_truncate_number should have.
1046
3ff9283d
MV
1047** The functions scm_c_string2str, scm_c_substring2str, and
1048 scm_c_symbol2str have been deprecated.
c41acab3
MV
1049
1050Use scm_to_locale_stringbuf or similar instead, maybe together with
1051scm_substring.
1052
3ff9283d
MV
1053** New functions scm_c_make_string, scm_c_string_length,
1054 scm_c_string_ref, scm_c_string_set_x, scm_c_substring,
1055 scm_c_substring_shared, scm_c_substring_copy.
1056
1057These are like scm_make_string, scm_length, etc. but are slightly
1058easier to use from C.
1059
1060** The macros SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_LENGTH,
1061 SCM_SYMBOL_CHARS, and SCM_SYMBOL_LENGTH have been deprecated.
1062
1063They export too many assumptions about the implementation of strings
1064and symbols that are no longer true in the presence of
b0d10ba6
MV
1065mutation-sharing substrings and when Guile switches to some form of
1066Unicode.
3ff9283d
MV
1067
1068When working with strings, it is often best to use the normal string
1069functions provided by Guile, such as scm_c_string_ref,
b0d10ba6
MV
1070scm_c_string_set_x, scm_string_append, etc. Be sure to look in the
1071manual since many more such functions are now provided than
1072previously.
3ff9283d
MV
1073
1074When you want to convert a SCM string to a C string, use the
1075scm_to_locale_string function or similar instead. For symbols, use
1076scm_symbol_to_string and then work with that string. Because of the
1077new string representation, scm_symbol_to_string does not need to copy
1078and is thus quite efficient.
1079
aef0bdb4 1080** Some string, symbol and keyword functions have been discouraged.
3ff9283d 1081
b0d10ba6 1082They don't fit into the uniform naming scheme and are not explicit
3ff9283d
MV
1083about the character encoding.
1084
1085Replace according to the following table:
1086
1087 scm_allocate_string -> scm_c_make_string
1088 scm_take_str -> scm_take_locale_stringn
1089 scm_take0str -> scm_take_locale_string
1090 scm_mem2string -> scm_from_locale_stringn
1091 scm_str2string -> scm_from_locale_string
1092 scm_makfrom0str -> scm_from_locale_string
1093 scm_mem2symbol -> scm_from_locale_symboln
b0d10ba6 1094 scm_mem2uninterned_symbol -> scm_from_locale_stringn + scm_make_symbol
3ff9283d
MV
1095 scm_str2symbol -> scm_from_locale_symbol
1096
1097 SCM_SYMBOL_HASH -> scm_hashq
1098 SCM_SYMBOL_INTERNED_P -> scm_symbol_interned_p
1099
aef0bdb4
MV
1100 scm_c_make_keyword -> scm_from_locale_keyword
1101
1102** The functions scm_keyword_to_symbol and sym_symbol_to_keyword are
1103 now also available to C code.
1104
1105** SCM_KEYWORDP and SCM_KEYWORDSYM have been deprecated.
1106
1107Use scm_is_keyword and scm_keyword_to_symbol instead, but note that
1108the latter returns the true name of the keyword, not the 'dash name',
1109as SCM_KEYWORDSYM used to do.
1110
dc91d8de
MV
1111** A new way to access arrays in a thread-safe and efficient way has
1112 been added.
1113
1114See the manual, node "Accessing Arrays From C".
1115
3167d5e4
MV
1116** The old uniform vector and bitvector implementations have been
1117 unceremoniously removed.
d4ea47c8 1118
a558cc63 1119This implementation exposed the details of the tagging system of
d4ea47c8 1120Guile. Use the new C API explained in the manual in node "Uniform
c34e5780 1121Numeric Vectors" and "Bit Vectors", respectively.
d4ea47c8
MV
1122
1123The following macros are gone: SCM_UVECTOR_BASE, SCM_SET_UVECTOR_BASE,
1124SCM_UVECTOR_MAXLENGTH, SCM_UVECTOR_LENGTH, SCM_MAKE_UVECTOR_TAG,
3167d5e4
MV
1125SCM_SET_UVECTOR_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
1126SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
1127SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
0b63c1ee
MV
1128SCM_SET_BITVECTOR_LENGTH, SCM_BITVEC_REF, SCM_BITVEC_SET,
1129SCM_BITVEC_CLR.
d4ea47c8 1130
c34e5780
MV
1131** The macros dealing with vectors have been deprecated.
1132
1133Use the new functions scm_is_vector, scm_vector_elements,
0b63c1ee
MV
1134scm_vector_writable_elements, etc, or scm_is_simple_vector,
1135SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, etc instead. See the
1136manual for more details.
c34e5780
MV
1137
1138Deprecated are SCM_VECTORP, SCM_VELTS, SCM_VECTOR_MAX_LENGTH,
1139SCM_VECTOR_LENGTH, SCM_VECTOR_REF, SCM_VECTOR_SET, SCM_WRITABLE_VELTS.
1140
1141The following macros have been removed: SCM_VECTOR_BASE,
1142SCM_SET_VECTOR_BASE, SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH,
1143SCM_VELTS_AS_STACKITEMS, SCM_SETVELTS, SCM_GC_WRITABLE_VELTS.
1144
0c7a5cab 1145** Some C functions and macros related to arrays have been deprecated.
dc91d8de
MV
1146
1147Migrate according to the following table:
1148
e94d0be2 1149 scm_make_uve -> scm_make_typed_array, scm_make_u8vector etc.
dc91d8de
MV
1150 scm_make_ra -> scm_make_array
1151 scm_shap2ra -> scm_make_array
1152 scm_cvref -> scm_c_generalized_vector_ref
1153 scm_ra_set_contp -> do not use
1154 scm_aind -> scm_array_handle_pos
1155 scm_raprin1 -> scm_display or scm_write
1156
0c7a5cab
MV
1157 SCM_ARRAYP -> scm_is_array
1158 SCM_ARRAY_NDIM -> scm_c_array_rank
1159 SCM_ARRAY_DIMS -> scm_array_handle_dims
1160 SCM_ARRAY_CONTP -> do not use
1161 SCM_ARRAY_MEM -> do not use
1162 SCM_ARRAY_V -> scm_array_handle_elements or similar
1163 SCM_ARRAY_BASE -> do not use
1164
c1e7caf7
MV
1165** SCM_CELL_WORD_LOC has been deprecated.
1166
b0d10ba6 1167Use the new macro SCM_CELL_OBJECT_LOC instead, which returns a pointer
c1e7caf7
MV
1168to a SCM, as opposed to a pointer to a scm_t_bits.
1169
1170This was done to allow the correct use of pointers into the Scheme
1171heap. Previously, the heap words were of type scm_t_bits and local
1172variables and function arguments were of type SCM, making it
1173non-standards-conformant to have a pointer that can point to both.
1174
3ff9283d 1175** New macros SCM_SMOB_DATA_2, SCM_SMOB_DATA_3, etc.
27968825
MV
1176
1177These macros should be used instead of SCM_CELL_WORD_2/3 to access the
1178second and third words of double smobs. Likewise for
1179SCM_SET_SMOB_DATA_2 and SCM_SET_SMOB_DATA_3.
1180
1181Also, there is SCM_SMOB_FLAGS and SCM_SET_SMOB_FLAGS that should be
1182used to get and set the 16 exra bits in the zeroth word of a smob.
1183
1184And finally, there is SCM_SMOB_OBJECT and SCM_SMOB_SET_OBJECT for
1185accesing the first immediate word of a smob as a SCM value, and there
1186is SCM_SMOB_OBJECT_LOC for getting a pointer to the first immediate
b0d10ba6 1187smob word. Like wise for SCM_SMOB_OBJECT_2, etc.
27968825 1188
b0d10ba6 1189** New way to deal with non-local exits and re-entries.
9879d390
MV
1190
1191There is a new set of functions that essentially do what
fc6bb283
MV
1192scm_internal_dynamic_wind does, but in a way that is more convenient
1193for C code in some situations. Here is a quick example of how to
1194prevent a potential memory leak:
9879d390
MV
1195
1196 void
1197 foo ()
1198 {
1199 char *mem;
1200
661ae7ab 1201 scm_dynwind_begin (0);
9879d390
MV
1202
1203 mem = scm_malloc (100);
661ae7ab 1204 scm_dynwind_unwind_handler (free, mem, SCM_F_WIND_EXPLICITLY);
f1da8e4e
MV
1205
1206 /* MEM would leak if BAR throws an error.
661ae7ab 1207 SCM_DYNWIND_UNWIND_HANDLER frees it nevertheless.
c41acab3 1208 */
9879d390 1209
9879d390
MV
1210 bar ();
1211
661ae7ab 1212 scm_dynwind_end ();
9879d390 1213
e299cee2 1214 /* Because of SCM_F_WIND_EXPLICITLY, MEM will be freed by
661ae7ab 1215 SCM_DYNWIND_END as well.
9879d390
MV
1216 */
1217 }
1218
661ae7ab 1219For full documentation, see the node "Dynamic Wind" in the manual.
9879d390 1220
661ae7ab 1221** New function scm_dynwind_free
c41acab3 1222
661ae7ab
MV
1223This function calls 'free' on a given pointer when a dynwind context
1224is left. Thus the call to scm_dynwind_unwind_handler above could be
1225replaced with simply scm_dynwind_free (mem).
c41acab3 1226
a6d75e53
MV
1227** New functions scm_c_call_with_blocked_asyncs and
1228 scm_c_call_with_unblocked_asyncs
1229
1230Like scm_call_with_blocked_asyncs etc. but for C functions.
1231
661ae7ab 1232** New functions scm_dynwind_block_asyncs and scm_dynwind_unblock_asyncs
49c00ecc
MV
1233
1234In addition to scm_c_call_with_blocked_asyncs you can now also use
661ae7ab
MV
1235scm_dynwind_block_asyncs in a 'dynwind context' (see above). Likewise for
1236scm_c_call_with_unblocked_asyncs and scm_dynwind_unblock_asyncs.
49c00ecc 1237
a558cc63
MV
1238** The macros SCM_DEFER_INTS, SCM_ALLOW_INTS, SCM_REDEFER_INTS,
1239 SCM_REALLOW_INTS have been deprecated.
1240
1241They do no longer fulfill their original role of blocking signal
1242delivery. Depending on what you want to achieve, replace a pair of
661ae7ab
MV
1243SCM_DEFER_INTS and SCM_ALLOW_INTS with a dynwind context that locks a
1244mutex, blocks asyncs, or both. See node "Critical Sections" in the
1245manual.
a6d75e53
MV
1246
1247** The value 'scm_mask_ints' is no longer writable.
1248
1249Previously, you could set scm_mask_ints directly. This is no longer
1250possible. Use scm_c_call_with_blocked_asyncs and
1251scm_c_call_with_unblocked_asyncs instead.
a558cc63 1252
49c00ecc
MV
1253** New way to temporarily set the current input, output or error ports
1254
661ae7ab 1255C code can now use scm_dynwind_current_<foo>_port in a 'dynwind
0f24e75b 1256context' (see above). <foo> is one of "input", "output" or "error".
49c00ecc 1257
fc6bb283
MV
1258** New way to temporarily set fluids
1259
661ae7ab 1260C code can now use scm_dynwind_fluid in a 'dynwind context' (see
fc6bb283
MV
1261above) to temporarily set the value of a fluid.
1262
89fcf1b4
MV
1263** New types scm_t_intmax and scm_t_uintmax.
1264
1265On platforms that have them, these types are identical to intmax_t and
1266uintmax_t, respectively. On other platforms, they are identical to
1267the largest integer types that Guile knows about.
1268
b0d10ba6 1269** The functions scm_unmemocopy and scm_unmemoize have been removed.
9fcf3cbb 1270
b0d10ba6 1271You should not have used them.
9fcf3cbb 1272
5ebbe4ef
RB
1273** Many public #defines with generic names have been made private.
1274
1275#defines with generic names like HAVE_FOO or SIZEOF_FOO have been made
b0d10ba6 1276private or renamed with a more suitable public name.
f03314f9
DH
1277
1278** The macro SCM_TYP16S has been deprecated.
1279
b0d10ba6 1280This macro is not intended for public use.
f03314f9 1281
0d5e3480
DH
1282** The macro SCM_SLOPPY_INEXACTP has been deprecated.
1283
b0d10ba6 1284Use scm_is_true (scm_inexact_p (...)) instead.
0d5e3480
DH
1285
1286** The macro SCM_SLOPPY_REALP has been deprecated.
1287
b0d10ba6 1288Use scm_is_real instead.
0d5e3480
DH
1289
1290** The macro SCM_SLOPPY_COMPLEXP has been deprecated.
1291
b0d10ba6 1292Use scm_is_complex instead.
5ebbe4ef 1293
b0d10ba6 1294** Some preprocessor defines have been deprecated.
5ebbe4ef 1295
b0d10ba6
MV
1296These defines indicated whether a certain feature was present in Guile
1297or not. Going forward, assume that the features are always present.
5ebbe4ef 1298
b0d10ba6
MV
1299The macros are: USE_THREADS, GUILE_ISELECT, READER_EXTENSIONS,
1300DEBUG_EXTENSIONS, DYNAMIC_LINKING.
5ebbe4ef 1301
b0d10ba6
MV
1302The following macros have been removed completely: MEMOIZE_LOCALS,
1303SCM_RECKLESS, SCM_CAUTIOUS.
5ebbe4ef
RB
1304
1305** The preprocessor define STACK_DIRECTION has been deprecated.
1306
1307There should be no need to know about the stack direction for ordinary
b0d10ba6 1308programs.
5ebbe4ef 1309
b2cbe8d8
RB
1310** New function: scm_effective_version
1311
1312Returns the "effective" version number. This is just the normal full
1313version string without the final micro-version number. See "Changes
1314to the distribution" above.
1315
2902a459
MV
1316** The function scm_call_with_new_thread has a new prototype.
1317
1318Instead of taking a list with the thunk and handler, these two
1319arguments are now passed directly:
1320
1321 SCM scm_call_with_new_thread (SCM thunk, SCM handler);
1322
1323This is an incompatible change.
1324
ffd0ef3b
MV
1325** New snarfer macro SCM_DEFINE_PUBLIC.
1326
1327This is like SCM_DEFINE, but also calls scm_c_export for the defined
1328function in the init section.
1329
8734ce02
MV
1330** The snarfer macro SCM_SNARF_INIT is now officially supported.
1331
39e8f371
HWN
1332** Garbage collector rewrite.
1333
1334The garbage collector is cleaned up a lot, and now uses lazy
1335sweeping. This is reflected in the output of (gc-stats); since cells
1336are being freed when they are allocated, the cells-allocated field
1337stays roughly constant.
1338
1339For malloc related triggers, the behavior is changed. It uses the same
1340heuristic as the cell-triggered collections. It may be tuned with the
1341environment variables GUILE_MIN_YIELD_MALLOC. This is the percentage
1342for minimum yield of malloc related triggers. The default is 40.
1343GUILE_INIT_MALLOC_LIMIT sets the initial trigger for doing a GC. The
1344default is 200 kb.
1345
1346Debugging operations for the freelist have been deprecated, along with
1347the C variables that control garbage collection. The environment
1348variables GUILE_MAX_SEGMENT_SIZE, GUILE_INIT_SEGMENT_SIZE_2,
1349GUILE_INIT_SEGMENT_SIZE_1, and GUILE_MIN_YIELD_2 should be used.
1350
1367aa5e
HWN
1351For understanding the memory usage of a GUILE program, the routine
1352gc-live-object-stats returns an alist containing the number of live
1353objects for every type.
1354
1355
5ec1d2c8
DH
1356** The function scm_definedp has been renamed to scm_defined_p
1357
1358The name scm_definedp is deprecated.
1359
b0d10ba6 1360** The struct scm_cell type has been renamed to scm_t_cell
228a24ef
DH
1361
1362This is in accordance to Guile's naming scheme for types. Note that
1363the name scm_cell is now used for a function that allocates and
1364initializes a new cell (see below).
1365
0906625f
MV
1366** New functions for memory management
1367
1368A new set of functions for memory management has been added since the
1369old way (scm_must_malloc, scm_must_free, etc) was error prone and
1370indeed, Guile itself contained some long standing bugs that could
1371cause aborts in long running programs.
1372
1373The new functions are more symmetrical and do not need cooperation
1374from smob free routines, among other improvements.
1375
eab1b259
HWN
1376The new functions are scm_malloc, scm_realloc, scm_calloc, scm_strdup,
1377scm_strndup, scm_gc_malloc, scm_gc_calloc, scm_gc_realloc,
1378scm_gc_free, scm_gc_register_collectable_memory, and
0906625f
MV
1379scm_gc_unregister_collectable_memory. Refer to the manual for more
1380details and for upgrading instructions.
1381
1382The old functions for memory management have been deprecated. They
1383are: scm_must_malloc, scm_must_realloc, scm_must_free,
1384scm_must_strdup, scm_must_strndup, scm_done_malloc, scm_done_free.
1385
4aa104a4
MV
1386** Declarations of exported features are marked with SCM_API.
1387
1388Every declaration of a feature that belongs to the exported Guile API
1389has been marked by adding the macro "SCM_API" to the start of the
1390declaration. This macro can expand into different things, the most
1391common of which is just "extern" for Unix platforms. On Win32, it can
1392be used to control which symbols are exported from a DLL.
1393
8f99e3f3 1394If you `#define SCM_IMPORT' before including <libguile.h>, SCM_API
4aa104a4
MV
1395will expand into "__declspec (dllimport) extern", which is needed for
1396linking to the Guile DLL in Windows.
1397
b0d10ba6 1398There are also SCM_RL_IMPORT, SCM_SRFI1314_IMPORT, and
8f99e3f3 1399SCM_SRFI4_IMPORT, for the corresponding libraries.
4aa104a4 1400
a9930d22
MV
1401** SCM_NEWCELL and SCM_NEWCELL2 have been deprecated.
1402
b0d10ba6
MV
1403Use the new functions scm_cell and scm_double_cell instead. The old
1404macros had problems because with them allocation and initialization
1405was separated and the GC could sometimes observe half initialized
1406cells. Only careful coding by the user of SCM_NEWCELL and
1407SCM_NEWCELL2 could make this safe and efficient.
a9930d22 1408
5132eef0
DH
1409** CHECK_ENTRY, CHECK_APPLY and CHECK_EXIT have been deprecated.
1410
1411Use the variables scm_check_entry_p, scm_check_apply_p and scm_check_exit_p
1412instead.
1413
bc76d628
DH
1414** SRCBRKP has been deprecated.
1415
1416Use scm_c_source_property_breakpoint_p instead.
1417
3063e30a
DH
1418** Deprecated: scm_makmacro
1419
b0d10ba6
MV
1420Change your code to use either scm_makmmacro or to define macros in
1421Scheme, using 'define-macro'.
1e5f92ce 1422
1a61d41b
MV
1423** New function scm_c_port_for_each.
1424
1425This function is like scm_port_for_each but takes a pointer to a C
1426function as the callback instead of a SCM value.
1427
1f834c95
MV
1428** The names scm_internal_select, scm_thread_sleep, and
1429 scm_thread_usleep have been discouraged.
1430
1431Use scm_std_select, scm_std_sleep, scm_std_usleep instead.
1432
aa9200e5
MV
1433** The GC can no longer be blocked.
1434
1435The global flags scm_gc_heap_lock and scm_block_gc have been removed.
1436The GC can now run (partially) concurrently with other code and thus
1437blocking it is not well defined.
1438
b0d10ba6
MV
1439** Many definitions have been removed that were previously deprecated.
1440
1441scm_lisp_nil, scm_lisp_t, s_nil_ify, scm_m_nil_ify, s_t_ify,
1442scm_m_t_ify, s_0_cond, scm_m_0_cond, s_0_ify, scm_m_0_ify, s_1_ify,
1443scm_m_1_ify, scm_debug_newcell, scm_debug_newcell2,
1444scm_tc16_allocated, SCM_SET_SYMBOL_HASH, SCM_IM_NIL_IFY, SCM_IM_T_IFY,
1445SCM_IM_0_COND, SCM_IM_0_IFY, SCM_IM_1_IFY, SCM_GC_SET_ALLOCATED,
1446scm_debug_newcell, scm_debug_newcell2, SCM_HUP_SIGNAL, SCM_INT_SIGNAL,
1447SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL, SCM_ALRM_SIGNAL,
1448SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD, SCM_ORD_SIG,
1449SCM_NUM_SIGS, scm_top_level_lookup_closure_var,
1450*top-level-lookup-closure*, scm_system_transformer, scm_eval_3,
1451scm_eval2, root_module_lookup_closure, SCM_SLOPPY_STRINGP,
1452SCM_RWSTRINGP, scm_read_only_string_p, scm_make_shared_substring,
1453scm_tc7_substring, sym_huh, SCM_VARVCELL, SCM_UDVARIABLEP,
1454SCM_DEFVARIABLEP, scm_mkbig, scm_big2inum, scm_adjbig, scm_normbig,
1455scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl, SCM_FIXNUM_BIT,
1456SCM_SETCHARS, SCM_SLOPPY_SUBSTRP, SCM_SUBSTR_STR, SCM_SUBSTR_OFFSET,
1457SCM_LENGTH_MAX, SCM_SETLENGTH, SCM_ROSTRINGP, SCM_ROLENGTH,
1458SCM_ROCHARS, SCM_ROUCHARS, SCM_SUBSTRP, SCM_COERCE_SUBSTR,
1459scm_sym2vcell, scm_intern, scm_intern0, scm_sysintern, scm_sysintern0,
66c8ded2 1460scm_sysintern0_no_module_lookup, scm_init_symbols_deprecated,
2109da78 1461scm_vector_set_length_x, scm_contregs, scm_debug_info,
983e697d
MV
1462scm_debug_frame, SCM_DSIDEVAL, SCM_CONST_LONG, SCM_VCELL,
1463SCM_GLOBAL_VCELL, SCM_VCELL_INIT, SCM_GLOBAL_VCELL_INIT,
1464SCM_HUGE_LENGTH, SCM_VALIDATE_STRINGORSUBSTR, SCM_VALIDATE_ROSTRING,
1465SCM_VALIDATE_ROSTRING_COPY, SCM_VALIDATE_NULLORROSTRING_COPY,
1466SCM_VALIDATE_RWSTRING, DIGITS, scm_small_istr2int, scm_istr2int,
2109da78
MV
1467scm_istr2flo, scm_istring2number, scm_istr2int, scm_istr2flo,
1468scm_istring2number, scm_vtable_index_vcell, scm_si_vcell, SCM_ECONSP,
1469SCM_NECONSP, SCM_GLOC_VAR, SCM_GLOC_VAL, SCM_GLOC_SET_VAL,
c41acab3
MV
1470SCM_GLOC_VAL_LOC, scm_make_gloc, scm_gloc_p, scm_tc16_variable,
1471SCM_CHARS, SCM_LENGTH, SCM_SET_STRING_CHARS, SCM_SET_STRING_LENGTH.
b51bad08 1472
09172f9c
NJ
1473* Changes to bundled modules
1474
1475** (ice-9 debug)
1476
1477Using the (ice-9 debug) module no longer automatically switches Guile
1478to use the debugging evaluator. If you want to switch to the
1479debugging evaluator (which is needed for backtrace information if you
1480hit an error), please add an explicit "(debug-enable 'debug)" to your
1481code just after the code to use (ice-9 debug).
1482
328dc9a3 1483\f
c299f186
MD
1484Changes since Guile 1.4:
1485
1486* Changes to the distribution
1487
32d6f999
TTN
1488** A top-level TODO file is included.
1489
311b6a3c 1490** Guile now uses a versioning scheme similar to that of the Linux kernel.
c81ea65d
RB
1491
1492Guile now always uses three numbers to represent the version,
1493i.e. "1.6.5". The first number, 1, is the major version number, the
1494second number, 6, is the minor version number, and the third number,
14955, is the micro version number. Changes in major version number
1496indicate major changes in Guile.
1497
1498Minor version numbers that are even denote stable releases, and odd
1499minor version numbers denote development versions (which may be
1500unstable). The micro version number indicates a minor sub-revision of
1501a given MAJOR.MINOR release.
1502
1503In keeping with the new scheme, (minor-version) and scm_minor_version
1504no longer return everything but the major version number. They now
1505just return the minor version number. Two new functions
1506(micro-version) and scm_micro_version have been added to report the
1507micro version number.
1508
1509In addition, ./GUILE-VERSION now defines GUILE_MICRO_VERSION.
1510
5c790b44
RB
1511** New preprocessor definitions are available for checking versions.
1512
1513version.h now #defines SCM_MAJOR_VERSION, SCM_MINOR_VERSION, and
1514SCM_MICRO_VERSION to the appropriate integer values.
1515
311b6a3c
MV
1516** Guile now actively warns about deprecated features.
1517
1518The new configure option `--enable-deprecated=LEVEL' and the
1519environment variable GUILE_WARN_DEPRECATED control this mechanism.
1520See INSTALL and README for more information.
1521
0b073f0f
RB
1522** Guile is much more likely to work on 64-bit architectures.
1523
1524Guile now compiles and passes "make check" with only two UNRESOLVED GC
5e137c65
RB
1525cases on Alpha and ia64 based machines now. Thanks to John Goerzen
1526for the use of a test machine, and thanks to Stefan Jahn for ia64
1527patches.
0b073f0f 1528
e658215a
RB
1529** New functions: setitimer and getitimer.
1530
1531These implement a fairly direct interface to the libc functions of the
1532same name.
1533
8630fdfc
RB
1534** The #. reader extension is now disabled by default.
1535
1536For safety reasons, #. evaluation is disabled by default. To
1537re-enable it, set the fluid read-eval? to #t. For example:
1538
67b7dd9e 1539 (fluid-set! read-eval? #t)
8630fdfc
RB
1540
1541but make sure you realize the potential security risks involved. With
1542read-eval? enabled, reading a data file from an untrusted source can
1543be dangerous.
1544
f2a75d81 1545** New SRFI modules have been added:
4df36934 1546
dfdf5826
MG
1547SRFI-0 `cond-expand' is now supported in Guile, without requiring
1548using a module.
1549
e8bb0476
MG
1550(srfi srfi-1) is a library containing many useful pair- and list-processing
1551 procedures.
1552
7adc2c58 1553(srfi srfi-2) exports and-let*.
4df36934 1554
b74a7ec8
MG
1555(srfi srfi-4) implements homogeneous numeric vector datatypes.
1556
7adc2c58
RB
1557(srfi srfi-6) is a dummy module for now, since guile already provides
1558 all of the srfi-6 procedures by default: open-input-string,
1559 open-output-string, get-output-string.
4df36934 1560
7adc2c58 1561(srfi srfi-8) exports receive.
4df36934 1562
7adc2c58 1563(srfi srfi-9) exports define-record-type.
4df36934 1564
dfdf5826
MG
1565(srfi srfi-10) exports define-reader-ctor and implements the reader
1566 extension #,().
1567
7adc2c58 1568(srfi srfi-11) exports let-values and let*-values.
4df36934 1569
7adc2c58 1570(srfi srfi-13) implements the SRFI String Library.
53e29a1e 1571
7adc2c58 1572(srfi srfi-14) implements the SRFI Character-Set Library.
53e29a1e 1573
dfdf5826
MG
1574(srfi srfi-17) implements setter and getter-with-setter and redefines
1575 some accessor procedures as procedures with getters. (such as car,
1576 cdr, vector-ref etc.)
1577
1578(srfi srfi-19) implements the SRFI Time/Date Library.
2b60bc95 1579
466bb4b3
TTN
1580** New scripts / "executable modules"
1581
1582Subdirectory "scripts" contains Scheme modules that are packaged to
1583also be executable as scripts. At this time, these scripts are available:
1584
1585 display-commentary
1586 doc-snarf
1587 generate-autoload
1588 punify
58e5b910 1589 read-scheme-source
466bb4b3
TTN
1590 use2dot
1591
1592See README there for more info.
1593
54c17ccb
TTN
1594These scripts can be invoked from the shell with the new program
1595"guile-tools", which keeps track of installation directory for you.
1596For example:
1597
1598 $ guile-tools display-commentary srfi/*.scm
1599
1600guile-tools is copied to the standard $bindir on "make install".
1601
0109c4bf
MD
1602** New module (ice-9 stack-catch):
1603
1604stack-catch is like catch, but saves the current state of the stack in
3c1d1301
RB
1605the fluid the-last-stack. This fluid can be useful when using the
1606debugger and when re-throwing an error.
0109c4bf 1607
fbf0c8c7
MV
1608** The module (ice-9 and-let*) has been renamed to (ice-9 and-let-star)
1609
1610This has been done to prevent problems on lesser operating systems
1611that can't tolerate `*'s in file names. The exported macro continues
1612to be named `and-let*', of course.
1613
4f60cc33 1614On systems that support it, there is also a compatibility module named
fbf0c8c7 1615(ice-9 and-let*). It will go away in the next release.
6c0201ad 1616
9d774814 1617** New modules (oop goops) etc.:
14f1d9fe
MD
1618
1619 (oop goops)
1620 (oop goops describe)
1621 (oop goops save)
1622 (oop goops active-slot)
1623 (oop goops composite-slot)
1624
9d774814 1625The Guile Object Oriented Programming System (GOOPS) has been
311b6a3c
MV
1626integrated into Guile. For further information, consult the GOOPS
1627manual and tutorial in the `doc' directory.
14f1d9fe 1628
9d774814
GH
1629** New module (ice-9 rdelim).
1630
1631This exports the following procedures which were previously defined
1c8cbd62 1632in the default environment:
9d774814 1633
1c8cbd62
GH
1634read-line read-line! read-delimited read-delimited! %read-delimited!
1635%read-line write-line
9d774814 1636
1c8cbd62
GH
1637For backwards compatibility the definitions are still imported into the
1638default environment in this version of Guile. However you should add:
9d774814
GH
1639
1640(use-modules (ice-9 rdelim))
1641
1c8cbd62
GH
1642to any program which uses the definitions, since this may change in
1643future.
9d774814
GH
1644
1645Alternatively, if guile-scsh is installed, the (scsh rdelim) module
1646can be used for similar functionality.
1647
7e267da1
GH
1648** New module (ice-9 rw)
1649
1650This is a subset of the (scsh rw) module from guile-scsh. Currently
373f4948 1651it defines two procedures:
7e267da1 1652
311b6a3c 1653*** New function: read-string!/partial str [port_or_fdes [start [end]]]
7e267da1 1654
4bcdfe46
GH
1655 Read characters from a port or file descriptor into a string STR.
1656 A port must have an underlying file descriptor -- a so-called
1657 fport. This procedure is scsh-compatible and can efficiently read
311b6a3c 1658 large strings.
7e267da1 1659
4bcdfe46
GH
1660*** New function: write-string/partial str [port_or_fdes [start [end]]]
1661
1662 Write characters from a string STR to a port or file descriptor.
1663 A port must have an underlying file descriptor -- a so-called
1664 fport. This procedure is mostly compatible and can efficiently
1665 write large strings.
1666
e5005373
KN
1667** New module (ice-9 match)
1668
311b6a3c
MV
1669This module includes Andrew K. Wright's pattern matcher. See
1670ice-9/match.scm for brief description or
e5005373 1671
311b6a3c 1672 http://www.star-lab.com/wright/code.html
e5005373 1673
311b6a3c 1674for complete documentation.
e5005373 1675
4f60cc33
NJ
1676** New module (ice-9 buffered-input)
1677
1678This module provides procedures to construct an input port from an
1679underlying source of input that reads and returns its input in chunks.
1680The underlying input source is a Scheme procedure, specified by the
1681caller, which the port invokes whenever it needs more input.
1682
1683This is useful when building an input port whose back end is Readline
1684or a UI element such as the GtkEntry widget.
1685
1686** Documentation
1687
1688The reference and tutorial documentation that was previously
1689distributed separately, as `guile-doc', is now included in the core
1690Guile distribution. The documentation consists of the following
1691manuals.
1692
1693- The Guile Tutorial (guile-tut.texi) contains a tutorial introduction
1694 to using Guile.
1695
1696- The Guile Reference Manual (guile.texi) contains (or is intended to
1697 contain) reference documentation on all aspects of Guile.
1698
1699- The GOOPS Manual (goops.texi) contains both tutorial-style and
1700 reference documentation for using GOOPS, Guile's Object Oriented
1701 Programming System.
1702
c3e62877
NJ
1703- The Revised^5 Report on the Algorithmic Language Scheme
1704 (r5rs.texi).
4f60cc33
NJ
1705
1706See the README file in the `doc' directory for more details.
1707
094a67bb
MV
1708** There are a couple of examples in the examples/ directory now.
1709
9d774814
GH
1710* Changes to the stand-alone interpreter
1711
e7e58018
MG
1712** New command line option `--use-srfi'
1713
1714Using this option, SRFI modules can be loaded on startup and be
1715available right from the beginning. This makes programming portable
1716Scheme programs easier.
1717
1718The option `--use-srfi' expects a comma-separated list of numbers,
1719each representing a SRFI number to be loaded into the interpreter
1720before starting evaluating a script file or the REPL. Additionally,
1721the feature identifier for the loaded SRFIs is recognized by
1722`cond-expand' when using this option.
1723
1724Example:
1725$ guile --use-srfi=8,13
1726guile> (receive (x z) (values 1 2) (+ 1 2))
17273
58e5b910 1728guile> (string-pad "bla" 20)
e7e58018
MG
1729" bla"
1730
094a67bb
MV
1731** Guile now always starts up in the `(guile-user)' module.
1732
6e9382f1 1733Previously, scripts executed via the `-s' option would run in the
094a67bb
MV
1734`(guile)' module and the repl would run in the `(guile-user)' module.
1735Now every user action takes place in the `(guile-user)' module by
1736default.
e7e58018 1737
c299f186
MD
1738* Changes to Scheme functions and syntax
1739
720e1c30
MV
1740** Character classifiers work for non-ASCII characters.
1741
1742The predicates `char-alphabetic?', `char-numeric?',
1743`char-whitespace?', `char-lower?', `char-upper?' and `char-is-both?'
1744no longer check whether their arguments are ASCII characters.
1745Previously, a character would only be considered alphabetic when it
1746was also ASCII, for example.
1747
311b6a3c
MV
1748** Previously deprecated Scheme functions have been removed:
1749
1750 tag - no replacement.
1751 fseek - replaced by seek.
1752 list* - replaced by cons*.
1753
1754** It's now possible to create modules with controlled environments
1755
1756Example:
1757
1758(use-modules (ice-9 safe))
1759(define m (make-safe-module))
1760;;; m will now be a module containing only a safe subset of R5RS
1761(eval '(+ 1 2) m) --> 3
1762(eval 'load m) --> ERROR: Unbound variable: load
1763
1764** Evaluation of "()", the empty list, is now an error.
8c2c9967
MV
1765
1766Previously, the expression "()" evaluated to the empty list. This has
1767been changed to signal a "missing expression" error. The correct way
1768to write the empty list as a literal constant is to use quote: "'()".
1769
311b6a3c
MV
1770** New concept of `Guile Extensions'.
1771
1772A Guile Extension is just a ordinary shared library that can be linked
1773at run-time. We found it advantageous to give this simple concept a
1774dedicated name to distinguish the issues related to shared libraries
1775from the issues related to the module system.
1776
1777*** New function: load-extension
1778
1779Executing (load-extension lib init) is mostly equivalent to
1780
1781 (dynamic-call init (dynamic-link lib))
1782
1783except when scm_register_extension has been called previously.
1784Whenever appropriate, you should use `load-extension' instead of
1785dynamic-link and dynamic-call.
1786
1787*** New C function: scm_c_register_extension
1788
1789This function registers a initialization function for use by
1790`load-extension'. Use it when you don't want specific extensions to
1791be loaded as shared libraries (for example on platforms that don't
1792support dynamic linking).
1793
8c2c9967
MV
1794** Auto-loading of compiled-code modules is deprecated.
1795
1796Guile used to be able to automatically find and link a shared
c10ecc4c 1797library to satisfy requests for a module. For example, the module
8c2c9967
MV
1798`(foo bar)' could be implemented by placing a shared library named
1799"foo/libbar.so" (or with a different extension) in a directory on the
1800load path of Guile.
1801
311b6a3c
MV
1802This has been found to be too tricky, and is no longer supported. The
1803shared libraries are now called "extensions". You should now write a
1804small Scheme file that calls `load-extension' to load the shared
e299cee2 1805library and initialize it explicitly.
8c2c9967
MV
1806
1807The shared libraries themselves should be installed in the usual
1808places for shared libraries, with names like "libguile-foo-bar".
1809
1810For example, place this into a file "foo/bar.scm"
1811
1812 (define-module (foo bar))
1813
311b6a3c
MV
1814 (load-extension "libguile-foo-bar" "foobar_init")
1815
1816** Backward incompatible change: eval EXP ENVIRONMENT-SPECIFIER
1817
1818`eval' is now R5RS, that is it takes two arguments.
1819The second argument is an environment specifier, i.e. either
1820
1821 (scheme-report-environment 5)
1822 (null-environment 5)
1823 (interaction-environment)
1824
1825or
8c2c9967 1826
311b6a3c 1827 any module.
8c2c9967 1828
6f76852b
MV
1829** The module system has been made more disciplined.
1830
311b6a3c
MV
1831The function `eval' will save and restore the current module around
1832the evaluation of the specified expression. While this expression is
1833evaluated, `(current-module)' will now return the right module, which
1834is the module specified as the second argument to `eval'.
6f76852b 1835
311b6a3c 1836A consequence of this change is that `eval' is not particularly
6f76852b
MV
1837useful when you want allow the evaluated code to change what module is
1838designated as the current module and have this change persist from one
1839call to `eval' to the next. The read-eval-print-loop is an example
1840where `eval' is now inadequate. To compensate, there is a new
1841function `primitive-eval' that does not take a module specifier and
1842that does not save/restore the current module. You should use this
1843function together with `set-current-module', `current-module', etc
1844when you want to have more control over the state that is carried from
1845one eval to the next.
1846
1847Additionally, it has been made sure that forms that are evaluated at
1848the top level are always evaluated with respect to the current module.
1849Previously, subforms of top-level forms such as `begin', `case',
1850etc. did not respect changes to the current module although these
1851subforms are at the top-level as well.
1852
311b6a3c 1853To prevent strange behavior, the forms `define-module',
6f76852b
MV
1854`use-modules', `use-syntax', and `export' have been restricted to only
1855work on the top level. The forms `define-public' and
1856`defmacro-public' only export the new binding on the top level. They
1857behave just like `define' and `defmacro', respectively, when they are
1858used in a lexical environment.
1859
0a892a2c
MV
1860Also, `export' will no longer silently re-export bindings imported
1861from a used module. It will emit a `deprecation' warning and will
1862cease to perform any re-export in the next version. If you actually
1863want to re-export bindings, use the new `re-export' in place of
1864`export'. The new `re-export' will not make copies of variables when
1865rexporting them, as `export' did wrongly.
1866
047dc3ae
TTN
1867** Module system now allows selection and renaming of imported bindings
1868
1869Previously, when using `use-modules' or the `#:use-module' clause in
1870the `define-module' form, all the bindings (association of symbols to
1871values) for imported modules were added to the "current module" on an
1872as-is basis. This has been changed to allow finer control through two
1873new facilities: selection and renaming.
1874
1875You can now select which of the imported module's bindings are to be
1876visible in the current module by using the `:select' clause. This
1877clause also can be used to rename individual bindings. For example:
1878
1879 ;; import all bindings no questions asked
1880 (use-modules (ice-9 common-list))
1881
1882 ;; import four bindings, renaming two of them;
1883 ;; the current module sees: every some zonk-y zonk-n
1884 (use-modules ((ice-9 common-list)
1885 :select (every some
1886 (remove-if . zonk-y)
1887 (remove-if-not . zonk-n))))
1888
1889You can also programmatically rename all selected bindings using the
1890`:renamer' clause, which specifies a proc that takes a symbol and
1891returns another symbol. Because it is common practice to use a prefix,
1892we now provide the convenience procedure `symbol-prefix-proc'. For
1893example:
1894
1895 ;; import four bindings, renaming two of them specifically,
1896 ;; and all four w/ prefix "CL:";
1897 ;; the current module sees: CL:every CL:some CL:zonk-y CL:zonk-n
1898 (use-modules ((ice-9 common-list)
1899 :select (every some
1900 (remove-if . zonk-y)
1901 (remove-if-not . zonk-n))
1902 :renamer (symbol-prefix-proc 'CL:)))
1903
1904 ;; import four bindings, renaming two of them specifically,
1905 ;; and all four by upcasing.
1906 ;; the current module sees: EVERY SOME ZONK-Y ZONK-N
1907 (define (upcase-symbol sym)
1908 (string->symbol (string-upcase (symbol->string sym))))
1909
1910 (use-modules ((ice-9 common-list)
1911 :select (every some
1912 (remove-if . zonk-y)
1913 (remove-if-not . zonk-n))
1914 :renamer upcase-symbol))
1915
1916Note that programmatic renaming is done *after* individual renaming.
1917Also, the above examples show `use-modules', but the same facilities are
1918available for the `#:use-module' clause of `define-module'.
1919
1920See manual for more info.
1921
b7d69200 1922** The semantics of guardians have changed.
56495472 1923
b7d69200 1924The changes are for the most part compatible. An important criterion
6c0201ad 1925was to keep the typical usage of guardians as simple as before, but to
c0a5d888 1926make the semantics safer and (as a result) more useful.
56495472 1927
c0a5d888 1928*** All objects returned from guardians are now properly alive.
56495472 1929
c0a5d888
ML
1930It is now guaranteed that any object referenced by an object returned
1931from a guardian is alive. It's now impossible for a guardian to
1932return a "contained" object before its "containing" object.
56495472
ML
1933
1934One incompatible (but probably not very important) change resulting
1935from this is that it is no longer possible to guard objects that
1936indirectly reference themselves (i.e. are parts of cycles). If you do
1937so accidentally, you'll get a warning.
1938
c0a5d888
ML
1939*** There are now two types of guardians: greedy and sharing.
1940
1941If you call (make-guardian #t) or just (make-guardian), you'll get a
1942greedy guardian, and for (make-guardian #f) a sharing guardian.
1943
1944Greedy guardians are the default because they are more "defensive".
1945You can only greedily guard an object once. If you guard an object
1946more than once, once in a greedy guardian and the rest of times in
1947sharing guardians, then it is guaranteed that the object won't be
1948returned from sharing guardians as long as it is greedily guarded
1949and/or alive.
1950
1951Guardians returned by calls to `make-guardian' can now take one more
1952optional parameter, which says whether to throw an error in case an
1953attempt is made to greedily guard an object that is already greedily
1954guarded. The default is true, i.e. throw an error. If the parameter
1955is false, the guardian invocation returns #t if guarding was
1956successful and #f if it wasn't.
1957
1958Also, since greedy guarding is, in effect, a side-effecting operation
1959on objects, a new function is introduced: `destroy-guardian!'.
1960Invoking this function on a guardian renders it unoperative and, if
1961the guardian is greedy, clears the "greedily guarded" property of the
1962objects that were guarded by it, thus undoing the side effect.
1963
1964Note that all this hair is hardly very important, since guardian
1965objects are usually permanent.
1966
311b6a3c
MV
1967** Continuations created by call-with-current-continuation now accept
1968any number of arguments, as required by R5RS.
818febc0 1969
c10ecc4c 1970** New function `issue-deprecation-warning'
56426fdb 1971
311b6a3c 1972This function is used to display the deprecation messages that are
c10ecc4c 1973controlled by GUILE_WARN_DEPRECATION as explained in the README.
56426fdb
KN
1974
1975 (define (id x)
c10ecc4c
MV
1976 (issue-deprecation-warning "`id' is deprecated. Use `identity' instead.")
1977 (identity x))
56426fdb
KN
1978
1979 guile> (id 1)
1980 ;; `id' is deprecated. Use `identity' instead.
1981 1
1982 guile> (id 1)
1983 1
1984
c10ecc4c
MV
1985** New syntax `begin-deprecated'
1986
1987When deprecated features are included (as determined by the configure
1988option --enable-deprecated), `begin-deprecated' is identical to
1989`begin'. When deprecated features are excluded, it always evaluates
1990to `#f', ignoring the body forms.
1991
17f367e0
MV
1992** New function `make-object-property'
1993
1994This function returns a new `procedure with setter' P that can be used
1995to attach a property to objects. When calling P as
1996
1997 (set! (P obj) val)
1998
1999where `obj' is any kind of object, it attaches `val' to `obj' in such
2000a way that it can be retrieved by calling P as
2001
2002 (P obj)
2003
2004This function will replace procedure properties, symbol properties and
2005source properties eventually.
2006
76ef92f3
MV
2007** Module (ice-9 optargs) now uses keywords instead of `#&'.
2008
2009Instead of #&optional, #&key, etc you should now use #:optional,
2010#:key, etc. Since #:optional is a keyword, you can write it as just
2011:optional when (read-set! keywords 'prefix) is active.
2012
2013The old reader syntax `#&' is still supported, but deprecated. It
2014will be removed in the next release.
2015
c0997079
MD
2016** New define-module option: pure
2017
2018Tells the module system not to include any bindings from the root
2019module.
2020
2021Example:
2022
2023(define-module (totally-empty-module)
2024 :pure)
2025
2026** New define-module option: export NAME1 ...
2027
2028Export names NAME1 ...
2029
2030This option is required if you want to be able to export bindings from
2031a module which doesn't import one of `define-public' or `export'.
2032
2033Example:
2034
311b6a3c
MV
2035 (define-module (foo)
2036 :pure
2037 :use-module (ice-9 r5rs)
2038 :export (bar))
69b5f65a 2039
311b6a3c 2040 ;;; Note that we're pure R5RS below this point!
69b5f65a 2041
311b6a3c
MV
2042 (define (bar)
2043 ...)
daa6ba18 2044
1f3908c4
KN
2045** New function: object->string OBJ
2046
2047Return a Scheme string obtained by printing a given object.
2048
eb5c0a2a
GH
2049** New function: port? X
2050
2051Returns a boolean indicating whether X is a port. Equivalent to
2052`(or (input-port? X) (output-port? X))'.
2053
efa40607
DH
2054** New function: file-port?
2055
2056Determines whether a given object is a port that is related to a file.
2057
34b56ec4
GH
2058** New function: port-for-each proc
2059
311b6a3c
MV
2060Apply PROC to each port in the Guile port table in turn. The return
2061value is unspecified. More specifically, PROC is applied exactly once
2062to every port that exists in the system at the time PORT-FOR-EACH is
2063invoked. Changes to the port table while PORT-FOR-EACH is running
2064have no effect as far as PORT-FOR-EACH is concerned.
34b56ec4
GH
2065
2066** New function: dup2 oldfd newfd
2067
2068A simple wrapper for the `dup2' system call. Copies the file
2069descriptor OLDFD to descriptor number NEWFD, replacing the
2070previous meaning of NEWFD. Both OLDFD and NEWFD must be integers.
2071Unlike for dup->fdes or primitive-move->fdes, no attempt is made
264e9cbc 2072to move away ports which are using NEWFD. The return value is
34b56ec4
GH
2073unspecified.
2074
2075** New function: close-fdes fd
2076
2077A simple wrapper for the `close' system call. Close file
2078descriptor FD, which must be an integer. Unlike close (*note
2079close: Ports and File Descriptors.), the file descriptor will be
2080closed even if a port is using it. The return value is
2081unspecified.
2082
94e6d793
MG
2083** New function: crypt password salt
2084
2085Encrypts `password' using the standard unix password encryption
2086algorithm.
2087
2088** New function: chroot path
2089
2090Change the root directory of the running process to `path'.
2091
2092** New functions: getlogin, cuserid
2093
2094Return the login name or the user name of the current effective user
2095id, respectively.
2096
2097** New functions: getpriority which who, setpriority which who prio
2098
2099Get or set the priority of the running process.
2100
2101** New function: getpass prompt
2102
2103Read a password from the terminal, first displaying `prompt' and
2104disabling echoing.
2105
2106** New function: flock file operation
2107
2108Set/remove an advisory shared or exclusive lock on `file'.
2109
2110** New functions: sethostname name, gethostname
2111
2112Set or get the hostname of the machine the current process is running
2113on.
2114
6d163216 2115** New function: mkstemp! tmpl
4f60cc33 2116
6d163216
GH
2117mkstemp creates a new unique file in the file system and returns a
2118new buffered port open for reading and writing to the file. TMPL
2119is a string specifying where the file should be created: it must
2120end with `XXXXXX' and will be changed in place to return the name
2121of the temporary file.
2122
62e63ba9
MG
2123** New function: open-input-string string
2124
2125Return an input string port which delivers the characters from
4f60cc33 2126`string'. This procedure, together with `open-output-string' and
62e63ba9
MG
2127`get-output-string' implements SRFI-6.
2128
2129** New function: open-output-string
2130
2131Return an output string port which collects all data written to it.
2132The data can then be retrieved by `get-output-string'.
2133
2134** New function: get-output-string
2135
2136Return the contents of an output string port.
2137
56426fdb
KN
2138** New function: identity
2139
2140Return the argument.
2141
5bef627d
GH
2142** socket, connect, accept etc., now have support for IPv6. IPv6 addresses
2143 are represented in Scheme as integers with normal host byte ordering.
2144
2145** New function: inet-pton family address
2146
311b6a3c
MV
2147Convert a printable string network address into an integer. Note that
2148unlike the C version of this function, the result is an integer with
2149normal host byte ordering. FAMILY can be `AF_INET' or `AF_INET6'.
2150e.g.,
2151
2152 (inet-pton AF_INET "127.0.0.1") => 2130706433
2153 (inet-pton AF_INET6 "::1") => 1
5bef627d
GH
2154
2155** New function: inet-ntop family address
2156
311b6a3c
MV
2157Convert an integer network address into a printable string. Note that
2158unlike the C version of this function, the input is an integer with
2159normal host byte ordering. FAMILY can be `AF_INET' or `AF_INET6'.
2160e.g.,
2161
2162 (inet-ntop AF_INET 2130706433) => "127.0.0.1"
2163 (inet-ntop AF_INET6 (- (expt 2 128) 1)) =>
5bef627d
GH
2164 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
2165
56426fdb
KN
2166** Deprecated: id
2167
2168Use `identity' instead.
2169
5cd06d5e
DH
2170** Deprecated: -1+
2171
2172Use `1-' instead.
2173
2174** Deprecated: return-it
2175
311b6a3c 2176Do without it.
5cd06d5e
DH
2177
2178** Deprecated: string-character-length
2179
2180Use `string-length' instead.
2181
2182** Deprecated: flags
2183
2184Use `logior' instead.
2185
4f60cc33
NJ
2186** Deprecated: close-all-ports-except.
2187
2188This was intended for closing ports in a child process after a fork,
2189but it has the undesirable side effect of flushing buffers.
2190port-for-each is more flexible.
34b56ec4
GH
2191
2192** The (ice-9 popen) module now attempts to set up file descriptors in
2193the child process from the current Scheme ports, instead of using the
2194current values of file descriptors 0, 1, and 2 in the parent process.
2195
b52e071b
DH
2196** Removed function: builtin-weak-bindings
2197
2198There is no such concept as a weak binding any more.
2199
9d774814 2200** Removed constants: bignum-radix, scm-line-incrementors
0f979f3f 2201
7d435120
MD
2202** define-method: New syntax mandatory.
2203
2204The new method syntax is now mandatory:
2205
2206(define-method (NAME ARG-SPEC ...) BODY ...)
2207(define-method (NAME ARG-SPEC ... . REST-ARG) BODY ...)
2208
2209 ARG-SPEC ::= ARG-NAME | (ARG-NAME TYPE)
2210 REST-ARG ::= ARG-NAME
2211
2212If you have old code using the old syntax, import
2213(oop goops old-define-method) before (oop goops) as in:
2214
2215 (use-modules (oop goops old-define-method) (oop goops))
2216
f3f9dcbc
MV
2217** Deprecated function: builtin-variable
2218 Removed function: builtin-bindings
2219
2220There is no longer a distinction between builtin or other variables.
2221Use module system operations for all variables.
2222
311b6a3c
MV
2223** Lazy-catch handlers are no longer allowed to return.
2224
2225That is, a call to `throw', `error', etc is now guaranteed to not
2226return.
2227
a583bf1e 2228** Bugfixes for (ice-9 getopt-long)
8c84b81e 2229
a583bf1e
TTN
2230This module is now tested using test-suite/tests/getopt-long.test.
2231The following bugs have been fixed:
2232
2233*** Parsing for options that are specified to have `optional' args now checks
2234if the next element is an option instead of unconditionally taking it as the
8c84b81e
TTN
2235option arg.
2236
a583bf1e
TTN
2237*** An error is now thrown for `--opt=val' when the option description
2238does not specify `(value #t)' or `(value optional)'. This condition used to
2239be accepted w/o error, contrary to the documentation.
2240
2241*** The error message for unrecognized options is now more informative.
2242It used to be "not a record", an artifact of the implementation.
2243
2244*** The error message for `--opt' terminating the arg list (no value), when
2245`(value #t)' is specified, is now more informative. It used to be "not enough
2246args".
2247
2248*** "Clumped" single-char args now preserve trailing string, use it as arg.
2249The expansion used to be like so:
2250
2251 ("-abc5d" "--xyz") => ("-a" "-b" "-c" "--xyz")
2252
2253Note that the "5d" is dropped. Now it is like so:
2254
2255 ("-abc5d" "--xyz") => ("-a" "-b" "-c" "5d" "--xyz")
2256
2257This enables single-char options to have adjoining arguments as long as their
2258constituent characters are not potential single-char options.
8c84b81e 2259
998bfc70
TTN
2260** (ice-9 session) procedure `arity' now works with (ice-9 optargs) `lambda*'
2261
2262The `lambda*' and derivative forms in (ice-9 optargs) now set a procedure
2263property `arglist', which can be retrieved by `arity'. The result is that
2264`arity' can give more detailed information than before:
2265
2266Before:
2267
2268 guile> (use-modules (ice-9 optargs))
2269 guile> (define* (foo #:optional a b c) a)
2270 guile> (arity foo)
2271 0 or more arguments in `lambda*:G0'.
2272
2273After:
2274
2275 guile> (arity foo)
2276 3 optional arguments: `a', `b' and `c'.
2277 guile> (define* (bar a b #:key c d #:allow-other-keys) a)
2278 guile> (arity bar)
2279 2 required arguments: `a' and `b', 2 keyword arguments: `c'
2280 and `d', other keywords allowed.
2281 guile> (define* (baz a b #:optional c #:rest r) a)
2282 guile> (arity baz)
2283 2 required arguments: `a' and `b', 1 optional argument: `c',
2284 the rest in `r'.
2285
311b6a3c
MV
2286* Changes to the C interface
2287
c81c130e
MV
2288** Types have been renamed from scm_*_t to scm_t_*.
2289
2290This has been done for POSIX sake. It reserves identifiers ending
2291with "_t". What a concept.
2292
2293The old names are still available with status `deprecated'.
2294
2295** scm_t_bits (former scm_bits_t) is now a unsigned type.
2296
6e9382f1 2297** Deprecated features have been removed.
e6c9e497
MV
2298
2299*** Macros removed
2300
2301 SCM_INPORTP, SCM_OUTPORTP SCM_ICHRP, SCM_ICHR, SCM_MAKICHR
2302 SCM_SETJMPBUF SCM_NSTRINGP SCM_NRWSTRINGP SCM_NVECTORP SCM_DOUBLE_CELLP
2303
2304*** C Functions removed
2305
2306 scm_sysmissing scm_tag scm_tc16_flo scm_tc_flo
2307 scm_fseek - replaced by scm_seek.
2308 gc-thunk - replaced by after-gc-hook.
2309 gh_int2scmb - replaced by gh_bool2scm.
2310 scm_tc_dblr - replaced by scm_tc16_real.
2311 scm_tc_dblc - replaced by scm_tc16_complex.
2312 scm_list_star - replaced by scm_cons_star.
2313
36284627
DH
2314** Deprecated: scm_makfromstr
2315
2316Use scm_mem2string instead.
2317
311b6a3c
MV
2318** Deprecated: scm_make_shared_substring
2319
2320Explicit shared substrings will disappear from Guile.
2321
2322Instead, "normal" strings will be implemented using sharing
2323internally, combined with a copy-on-write strategy.
2324
2325** Deprecated: scm_read_only_string_p
2326
2327The concept of read-only strings will disappear in next release of
2328Guile.
2329
2330** Deprecated: scm_sloppy_memq, scm_sloppy_memv, scm_sloppy_member
c299f186 2331
311b6a3c 2332Instead, use scm_c_memq or scm_memq, scm_memv, scm_member.
c299f186 2333
dd0e04ed
KN
2334** New functions: scm_call_0, scm_call_1, scm_call_2, scm_call_3
2335
83dbedcc
KR
2336Call a procedure with the indicated number of arguments. See "Fly
2337Evaluation" in the manual.
dd0e04ed
KN
2338
2339** New functions: scm_apply_0, scm_apply_1, scm_apply_2, scm_apply_3
2340
83dbedcc
KR
2341Call a procedure with the indicated number of arguments and a list of
2342further arguments. See "Fly Evaluation" in the manual.
dd0e04ed 2343
e235f2a6
KN
2344** New functions: scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5
2345
83dbedcc
KR
2346Create a list of the given number of elements. See "List
2347Constructors" in the manual.
e235f2a6
KN
2348
2349** Renamed function: scm_listify has been replaced by scm_list_n.
2350
2351** Deprecated macros: SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4,
2352SCM_LIST5, SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9.
2353
2354Use functions scm_list_N instead.
2355
6fe692e9
MD
2356** New function: scm_c_read (SCM port, void *buffer, scm_sizet size)
2357
2358Used by an application to read arbitrary number of bytes from a port.
2359Same semantics as libc read, except that scm_c_read only returns less
2360than SIZE bytes if at end-of-file.
2361
2362Warning: Doesn't update port line and column counts!
2363
2364** New function: scm_c_write (SCM port, const void *ptr, scm_sizet size)
2365
2366Used by an application to write arbitrary number of bytes to an SCM
2367port. Similar semantics as libc write. However, unlike libc
2368write, scm_c_write writes the requested number of bytes and has no
2369return value.
2370
2371Warning: Doesn't update port line and column counts!
2372
17f367e0
MV
2373** New function: scm_init_guile ()
2374
2375In contrast to scm_boot_guile, scm_init_guile will return normally
2376after initializing Guile. It is not available on all systems, tho.
2377
23ade5e7
DH
2378** New functions: scm_str2symbol, scm_mem2symbol
2379
2380The function scm_str2symbol takes a const char* pointing to a zero-terminated
2381field of characters and creates a scheme symbol object from that C string.
2382The function scm_mem2symbol takes a const char* and a number of characters and
2383creates a symbol from the characters in that memory area.
2384
17f367e0
MV
2385** New functions: scm_primitive_make_property
2386 scm_primitive_property_ref
2387 scm_primitive_property_set_x
2388 scm_primitive_property_del_x
2389
2390These functions implement a new way to deal with object properties.
2391See libguile/properties.c for their documentation.
2392
9d47a1e6
ML
2393** New function: scm_done_free (long size)
2394
2395This function is the inverse of scm_done_malloc. Use it to report the
2396amount of smob memory you free. The previous method, which involved
2397calling scm_done_malloc with negative argument, was somewhat
2398unintuitive (and is still available, of course).
2399
79a3dafe
DH
2400** New function: scm_c_memq (SCM obj, SCM list)
2401
2402This function provides a fast C level alternative for scm_memq for the case
2403that the list parameter is known to be a proper list. The function is a
2404replacement for scm_sloppy_memq, but is stricter in its requirements on its
2405list input parameter, since for anything else but a proper list the function's
2406behaviour is undefined - it may even crash or loop endlessly. Further, for
2407the case that the object is not found in the list, scm_c_memq returns #f which
2408is similar to scm_memq, but different from scm_sloppy_memq's behaviour.
2409
6c0201ad 2410** New functions: scm_remember_upto_here_1, scm_remember_upto_here_2,
5d2b97cd
DH
2411scm_remember_upto_here
2412
2413These functions replace the function scm_remember.
2414
2415** Deprecated function: scm_remember
2416
2417Use one of the new functions scm_remember_upto_here_1,
2418scm_remember_upto_here_2 or scm_remember_upto_here instead.
2419
be54b15d
DH
2420** New function: scm_allocate_string
2421
2422This function replaces the function scm_makstr.
2423
2424** Deprecated function: scm_makstr
2425
2426Use the new function scm_allocate_string instead.
2427
32d0d4b1
DH
2428** New global variable scm_gc_running_p introduced.
2429
2430Use this variable to find out if garbage collection is being executed. Up to
2431now applications have used scm_gc_heap_lock to test if garbage collection was
2432running, which also works because of the fact that up to know only the garbage
2433collector has set this variable. But, this is an implementation detail that
2434may change. Further, scm_gc_heap_lock is not set throughout gc, thus the use
2435of this variable is (and has been) not fully safe anyway.
2436
5b9eb8ae
DH
2437** New macros: SCM_BITVECTOR_MAX_LENGTH, SCM_UVECTOR_MAX_LENGTH
2438
2439Use these instead of SCM_LENGTH_MAX.
2440
6c0201ad 2441** New macros: SCM_CONTINUATION_LENGTH, SCM_CCLO_LENGTH, SCM_STACK_LENGTH,
a6d9e5ab
DH
2442SCM_STRING_LENGTH, SCM_SYMBOL_LENGTH, SCM_UVECTOR_LENGTH,
2443SCM_BITVECTOR_LENGTH, SCM_VECTOR_LENGTH.
2444
2445Use these instead of SCM_LENGTH.
2446
6c0201ad 2447** New macros: SCM_SET_CONTINUATION_LENGTH, SCM_SET_STRING_LENGTH,
93778877
DH
2448SCM_SET_SYMBOL_LENGTH, SCM_SET_VECTOR_LENGTH, SCM_SET_UVECTOR_LENGTH,
2449SCM_SET_BITVECTOR_LENGTH
bc0eaf7b
DH
2450
2451Use these instead of SCM_SETLENGTH
2452
6c0201ad 2453** New macros: SCM_STRING_CHARS, SCM_SYMBOL_CHARS, SCM_CCLO_BASE,
a6d9e5ab
DH
2454SCM_VECTOR_BASE, SCM_UVECTOR_BASE, SCM_BITVECTOR_BASE, SCM_COMPLEX_MEM,
2455SCM_ARRAY_MEM
2456
e51fe79c
DH
2457Use these instead of SCM_CHARS, SCM_UCHARS, SCM_ROCHARS, SCM_ROUCHARS or
2458SCM_VELTS.
a6d9e5ab 2459
6c0201ad 2460** New macros: SCM_SET_BIGNUM_BASE, SCM_SET_STRING_CHARS,
6a0476fd
DH
2461SCM_SET_SYMBOL_CHARS, SCM_SET_UVECTOR_BASE, SCM_SET_BITVECTOR_BASE,
2462SCM_SET_VECTOR_BASE
2463
2464Use these instead of SCM_SETCHARS.
2465
a6d9e5ab
DH
2466** New macro: SCM_BITVECTOR_P
2467
2468** New macro: SCM_STRING_COERCE_0TERMINATION_X
2469
2470Use instead of SCM_COERCE_SUBSTR.
2471
30ea841d
DH
2472** New macros: SCM_DIR_OPEN_P, SCM_DIR_FLAG_OPEN
2473
2474For directory objects, use these instead of SCM_OPDIRP and SCM_OPN.
2475
6c0201ad
TTN
2476** Deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,
2477SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL,
2478SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD,
d1ca2c64 2479SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SYMBOL_SLOTS, SCM_SLOTS, SCM_SLOPPY_STRINGP,
a6d9e5ab
DH
2480SCM_VALIDATE_STRINGORSUBSTR, SCM_FREEP, SCM_NFREEP, SCM_CHARS, SCM_UCHARS,
2481SCM_VALIDATE_ROSTRING, SCM_VALIDATE_ROSTRING_COPY,
2482SCM_VALIDATE_NULLORROSTRING_COPY, SCM_ROLENGTH, SCM_LENGTH, SCM_HUGE_LENGTH,
b24b5e13 2483SCM_SUBSTRP, SCM_SUBSTR_STR, SCM_SUBSTR_OFFSET, SCM_COERCE_SUBSTR,
34f0f2b8 2484SCM_ROSTRINGP, SCM_RWSTRINGP, SCM_VALIDATE_RWSTRING, SCM_ROCHARS,
fd336365 2485SCM_ROUCHARS, SCM_SETLENGTH, SCM_SETCHARS, SCM_LENGTH_MAX, SCM_GC8MARKP,
30ea841d 2486SCM_SETGC8MARK, SCM_CLRGC8MARK, SCM_GCTYP16, SCM_GCCDR, SCM_SUBR_DOC,
b3fcac34
DH
2487SCM_OPDIRP, SCM_VALIDATE_OPDIR, SCM_WTA, RETURN_SCM_WTA, SCM_CONST_LONG,
2488SCM_WNA, SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
61045190 2489SCM_VALIDATE_NUMBER_DEF_COPY, SCM_SLOPPY_CONSP, SCM_SLOPPY_NCONSP,
e038c042 2490SCM_SETAND_CDR, SCM_SETOR_CDR, SCM_SETAND_CAR, SCM_SETOR_CAR
b63a956d
DH
2491
2492Use SCM_ASSERT_RANGE or SCM_VALIDATE_XXX_RANGE instead of SCM_OUTOFRANGE.
2493Use scm_memory_error instead of SCM_NALLOC.
c1aef037 2494Use SCM_STRINGP instead of SCM_SLOPPY_STRINGP.
d1ca2c64
DH
2495Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_STRINGORSUBSTR.
2496Use SCM_FREE_CELL_P instead of SCM_FREEP/SCM_NFREEP
a6d9e5ab 2497Use a type specific accessor macro instead of SCM_CHARS/SCM_UCHARS.
6c0201ad 2498Use a type specific accessor instead of SCM(_|_RO|_HUGE_)LENGTH.
a6d9e5ab
DH
2499Use SCM_VALIDATE_(SYMBOL|STRING) instead of SCM_VALIDATE_ROSTRING.
2500Use SCM_STRING_COERCE_0TERMINATION_X instead of SCM_COERCE_SUBSTR.
b24b5e13 2501Use SCM_STRINGP or SCM_SYMBOLP instead of SCM_ROSTRINGP.
f0942910
DH
2502Use SCM_STRINGP instead of SCM_RWSTRINGP.
2503Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_RWSTRING.
34f0f2b8
DH
2504Use SCM_STRING_CHARS instead of SCM_ROCHARS.
2505Use SCM_STRING_UCHARS instead of SCM_ROUCHARS.
93778877 2506Use a type specific setter macro instead of SCM_SETLENGTH.
6a0476fd 2507Use a type specific setter macro instead of SCM_SETCHARS.
5b9eb8ae 2508Use a type specific length macro instead of SCM_LENGTH_MAX.
fd336365
DH
2509Use SCM_GCMARKP instead of SCM_GC8MARKP.
2510Use SCM_SETGCMARK instead of SCM_SETGC8MARK.
2511Use SCM_CLRGCMARK instead of SCM_CLRGC8MARK.
2512Use SCM_TYP16 instead of SCM_GCTYP16.
2513Use SCM_CDR instead of SCM_GCCDR.
30ea841d 2514Use SCM_DIR_OPEN_P instead of SCM_OPDIRP.
276dd677
DH
2515Use SCM_MISC_ERROR or SCM_WRONG_TYPE_ARG instead of SCM_WTA.
2516Use SCM_MISC_ERROR or SCM_WRONG_TYPE_ARG instead of RETURN_SCM_WTA.
8dea8611 2517Use SCM_VCELL_INIT instead of SCM_CONST_LONG.
b3fcac34 2518Use SCM_WRONG_NUM_ARGS instead of SCM_WNA.
ced99e92
DH
2519Use SCM_CONSP instead of SCM_SLOPPY_CONSP.
2520Use !SCM_CONSP instead of SCM_SLOPPY_NCONSP.
b63a956d 2521
f7620510
DH
2522** Removed function: scm_struct_init
2523
93d40df2
DH
2524** Removed variable: scm_symhash_dim
2525
818febc0
GH
2526** Renamed function: scm_make_cont has been replaced by
2527scm_make_continuation, which has a different interface.
2528
cc4feeca
DH
2529** Deprecated function: scm_call_catching_errors
2530
2531Use scm_catch or scm_lazy_catch from throw.[ch] instead.
2532
28b06554
DH
2533** Deprecated function: scm_strhash
2534
2535Use scm_string_hash instead.
2536
1b9be268
DH
2537** Deprecated function: scm_vector_set_length_x
2538
2539Instead, create a fresh vector of the desired size and copy the contents.
2540
302f229e
MD
2541** scm_gensym has changed prototype
2542
2543scm_gensym now only takes one argument.
2544
1660782e
DH
2545** Deprecated type tags: scm_tc7_ssymbol, scm_tc7_msymbol, scm_tcs_symbols,
2546scm_tc7_lvector
28b06554
DH
2547
2548There is now only a single symbol type scm_tc7_symbol.
1660782e 2549The tag scm_tc7_lvector was not used anyway.
28b06554 2550
2f6fb7c5
KN
2551** Deprecated function: scm_make_smob_type_mfpe, scm_set_smob_mfpe.
2552
2553Use scm_make_smob_type and scm_set_smob_XXX instead.
2554
2555** New function scm_set_smob_apply.
2556
2557This can be used to set an apply function to a smob type.
2558
1f3908c4
KN
2559** Deprecated function: scm_strprint_obj
2560
2561Use scm_object_to_string instead.
2562
b3fcac34
DH
2563** Deprecated function: scm_wta
2564
2565Use scm_wrong_type_arg, or another appropriate error signalling function
2566instead.
2567
f3f9dcbc
MV
2568** Explicit support for obarrays has been deprecated.
2569
2570Use `scm_str2symbol' and the generic hashtable functions instead.
2571
2572** The concept of `vcells' has been deprecated.
2573
2574The data type `variable' is now used exclusively. `Vcells' have been
2575a low-level concept so you are likely not affected by this change.
2576
2577*** Deprecated functions: scm_sym2vcell, scm_sysintern,
2578 scm_sysintern0, scm_symbol_value0, scm_intern, scm_intern0.
2579
2580Use scm_c_define or scm_c_lookup instead, as appropriate.
2581
2582*** New functions: scm_c_module_lookup, scm_c_lookup,
2583 scm_c_module_define, scm_c_define, scm_module_lookup, scm_lookup,
2584 scm_module_define, scm_define.
2585
2586These functions work with variables instead of with vcells.
2587
311b6a3c
MV
2588** New functions for creating and defining `subr's and `gsubr's.
2589
2590The new functions more clearly distinguish between creating a subr (or
2591gsubr) object and adding it to the current module.
2592
2593These new functions are available: scm_c_make_subr, scm_c_define_subr,
2594scm_c_make_subr_with_generic, scm_c_define_subr_with_generic,
2595scm_c_make_gsubr, scm_c_define_gsubr, scm_c_make_gsubr_with_generic,
2596scm_c_define_gsubr_with_generic.
2597
2598** Deprecated functions: scm_make_subr, scm_make_subr_opt,
2599 scm_make_subr_with_generic, scm_make_gsubr,
2600 scm_make_gsubr_with_generic.
2601
2602Use the new ones from above instead.
2603
2604** C interface to the module system has changed.
2605
2606While we suggest that you avoid as many explicit module system
2607operations from C as possible for the time being, the C interface has
2608been made more similar to the high-level Scheme module system.
2609
2610*** New functions: scm_c_define_module, scm_c_use_module,
2611 scm_c_export, scm_c_resolve_module.
2612
2613They mostly work like their Scheme namesakes. scm_c_define_module
2614takes a function that is called a context where the new module is
2615current.
2616
2617*** Deprecated functions: scm_the_root_module, scm_make_module,
2618 scm_ensure_user_module, scm_load_scheme_module.
2619
2620Use the new functions instead.
2621
2622** Renamed function: scm_internal_with_fluids becomes
2623 scm_c_with_fluids.
2624
2625scm_internal_with_fluids is available as a deprecated function.
2626
2627** New function: scm_c_with_fluid.
2628
2629Just like scm_c_with_fluids, but takes one fluid and one value instead
2630of lists of same.
2631
1be6b49c
ML
2632** Deprecated typedefs: long_long, ulong_long.
2633
2634They are of questionable utility and they pollute the global
2635namespace.
2636
1be6b49c
ML
2637** Deprecated typedef: scm_sizet
2638
2639It is of questionable utility now that Guile requires ANSI C, and is
2640oddly named.
2641
2642** Deprecated typedefs: scm_port_rw_active, scm_port,
2643 scm_ptob_descriptor, scm_debug_info, scm_debug_frame, scm_fport,
2644 scm_option, scm_rstate, scm_rng, scm_array, scm_array_dim.
2645
2646Made more compliant with the naming policy by adding a _t at the end.
2647
2648** Deprecated functions: scm_mkbig, scm_big2num, scm_adjbig,
2649 scm_normbig, scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl
2650
373f4948 2651With the exception of the mysterious scm_2ulong2big, they are still
1be6b49c
ML
2652available under new names (scm_i_mkbig etc). These functions are not
2653intended to be used in user code. You should avoid dealing with
2654bignums directly, and should deal with numbers in general (which can
2655be bignums).
2656
147c18a0
MD
2657** Change in behavior: scm_num2long, scm_num2ulong
2658
2659The scm_num2[u]long functions don't any longer accept an inexact
2660argument. This change in behavior is motivated by concordance with
2661R5RS: It is more common that a primitive doesn't want to accept an
2662inexact for an exact.
2663
1be6b49c 2664** New functions: scm_short2num, scm_ushort2num, scm_int2num,
f3f70257
ML
2665 scm_uint2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
2666 scm_num2ushort, scm_num2int, scm_num2uint, scm_num2ptrdiff,
1be6b49c
ML
2667 scm_num2size.
2668
2669These are conversion functions between the various ANSI C integral
147c18a0
MD
2670types and Scheme numbers. NOTE: The scm_num2xxx functions don't
2671accept an inexact argument.
1be6b49c 2672
5437598b
MD
2673** New functions: scm_float2num, scm_double2num,
2674 scm_num2float, scm_num2double.
2675
2676These are conversion functions between the two ANSI C float types and
2677Scheme numbers.
2678
1be6b49c 2679** New number validation macros:
f3f70257 2680 SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,INT,UINT}[_DEF]
1be6b49c
ML
2681
2682See above.
2683
fc62c86a
ML
2684** New functions: scm_gc_protect_object, scm_gc_unprotect_object
2685
2686These are just nicer-named old scm_protect_object and
2687scm_unprotect_object.
2688
2689** Deprecated functions: scm_protect_object, scm_unprotect_object
2690
2691** New functions: scm_gc_[un]register_root, scm_gc_[un]register_roots
2692
2693These functions can be used to register pointers to locations that
2694hold SCM values.
2695
5b2ad23b
ML
2696** Deprecated function: scm_create_hook.
2697
2698Its sins are: misleading name, non-modularity and lack of general
2699usefulness.
2700
c299f186 2701\f
cc36e791
JB
2702Changes since Guile 1.3.4:
2703
80f27102
JB
2704* Changes to the distribution
2705
ce358662
JB
2706** Trees from nightly snapshots and CVS now require you to run autogen.sh.
2707
2708We've changed the way we handle generated files in the Guile source
2709repository. As a result, the procedure for building trees obtained
2710from the nightly FTP snapshots or via CVS has changed:
2711- You must have appropriate versions of autoconf, automake, and
2712 libtool installed on your system. See README for info on how to
2713 obtain these programs.
2714- Before configuring the tree, you must first run the script
2715 `autogen.sh' at the top of the source tree.
2716
2717The Guile repository used to contain not only source files, written by
2718humans, but also some generated files, like configure scripts and
2719Makefile.in files. Even though the contents of these files could be
2720derived mechanically from other files present, we thought it would
2721make the tree easier to build if we checked them into CVS.
2722
2723However, this approach means that minor differences between
2724developer's installed tools and habits affected the whole team.
2725So we have removed the generated files from the repository, and
2726added the autogen.sh script, which will reconstruct them
2727appropriately.
2728
2729
dc914156
GH
2730** configure now has experimental options to remove support for certain
2731features:
52cfc69b 2732
dc914156
GH
2733--disable-arrays omit array and uniform array support
2734--disable-posix omit posix interfaces
2735--disable-networking omit networking interfaces
2736--disable-regex omit regular expression interfaces
52cfc69b
GH
2737
2738These are likely to become separate modules some day.
2739
9764c29b 2740** New configure option --enable-debug-freelist
e1b0d0ac 2741
38a15cfd
GB
2742This enables a debugging version of SCM_NEWCELL(), and also registers
2743an extra primitive, the setter `gc-set-debug-check-freelist!'.
2744
2745Configure with the --enable-debug-freelist option to enable
2746the gc-set-debug-check-freelist! primitive, and then use:
2747
2748(gc-set-debug-check-freelist! #t) # turn on checking of the freelist
2749(gc-set-debug-check-freelist! #f) # turn off checking
2750
2751Checking of the freelist forces a traversal of the freelist and
2752a garbage collection before each allocation of a cell. This can
2753slow down the interpreter dramatically, so the setter should be used to
2754turn on this extra processing only when necessary.
e1b0d0ac 2755
9764c29b
MD
2756** New configure option --enable-debug-malloc
2757
2758Include code for debugging of calls to scm_must_malloc/realloc/free.
2759
2760Checks that
2761
27621. objects freed by scm_must_free has been mallocated by scm_must_malloc
27632. objects reallocated by scm_must_realloc has been allocated by
2764 scm_must_malloc
27653. reallocated objects are reallocated with the same what string
2766
2767But, most importantly, it records the number of allocated objects of
2768each kind. This is useful when searching for memory leaks.
2769
2770A Guile compiled with this option provides the primitive
2771`malloc-stats' which returns an alist with pairs of kind and the
2772number of objects of that kind.
2773
e415cb06
MD
2774** All includes are now referenced relative to the root directory
2775
2776Since some users have had problems with mixups between Guile and
2777system headers, we have decided to always refer to Guile headers via
2778their parent directories. This essentially creates a "private name
2779space" for Guile headers. This means that the compiler only is given
2780-I options for the root build and root source directory.
2781
341f78c9
MD
2782** Header files kw.h and genio.h have been removed.
2783
2784** The module (ice-9 getopt-gnu-style) has been removed.
2785
e8855f8d
MD
2786** New module (ice-9 documentation)
2787
2788Implements the interface to documentation strings associated with
2789objects.
2790
0c0ffe09
KN
2791** New module (ice-9 time)
2792
2793Provides a macro `time', which displays execution time of a given form.
2794
cf7a5ee5
KN
2795** New module (ice-9 history)
2796
2797Loading this module enables value history in the repl.
2798
0af43c4a 2799* Changes to the stand-alone interpreter
bd9e24b3 2800
67ef2dca
MD
2801** New command line option --debug
2802
2803Start Guile with debugging evaluator and backtraces enabled.
2804
2805This is useful when debugging your .guile init file or scripts.
2806
aa4bb95d
MD
2807** New help facility
2808
341f78c9
MD
2809Usage: (help NAME) gives documentation about objects named NAME (a symbol)
2810 (help REGEXP) ditto for objects with names matching REGEXP (a string)
58e5b910 2811 (help 'NAME) gives documentation for NAME, even if it is not an object
341f78c9 2812 (help ,EXPR) gives documentation for object returned by EXPR
6c0201ad 2813 (help (my module)) gives module commentary for `(my module)'
341f78c9
MD
2814 (help) gives this text
2815
2816`help' searches among bindings exported from loaded modules, while
2817`apropos' searches among bindings visible from the "current" module.
2818
2819Examples: (help help)
2820 (help cons)
2821 (help "output-string")
aa4bb95d 2822
e8855f8d
MD
2823** `help' and `apropos' now prints full module names
2824
0af43c4a 2825** Dynamic linking now uses libltdl from the libtool package.
bd9e24b3 2826
0af43c4a
MD
2827The old system dependent code for doing dynamic linking has been
2828replaced with calls to the libltdl functions which do all the hairy
2829details for us.
bd9e24b3 2830
0af43c4a
MD
2831The major improvement is that you can now directly pass libtool
2832library names like "libfoo.la" to `dynamic-link' and `dynamic-link'
2833will be able to do the best shared library job you can get, via
2834libltdl.
bd9e24b3 2835
0af43c4a
MD
2836The way dynamic libraries are found has changed and is not really
2837portable across platforms, probably. It is therefore recommended to
2838use absolute filenames when possible.
2839
2840If you pass a filename without an extension to `dynamic-link', it will
2841try a few appropriate ones. Thus, the most platform ignorant way is
2842to specify a name like "libfoo", without any directories and
2843extensions.
0573ddae 2844
91163914
MD
2845** Guile COOP threads are now compatible with LinuxThreads
2846
2847Previously, COOP threading wasn't possible in applications linked with
2848Linux POSIX threads due to their use of the stack pointer to find the
2849thread context. This has now been fixed with a workaround which uses
2850the pthreads to allocate the stack.
2851
6c0201ad 2852** New primitives: `pkgdata-dir', `site-dir', `library-dir'
62b82274 2853
9770d235
MD
2854** Positions of erring expression in scripts
2855
2856With version 1.3.4, the location of the erring expression in Guile
2857scipts is no longer automatically reported. (This should have been
2858documented before the 1.3.4 release.)
2859
2860You can get this information by enabling recording of positions of
2861source expressions and running the debugging evaluator. Put this at
2862the top of your script (or in your "site" file):
2863
2864 (read-enable 'positions)
2865 (debug-enable 'debug)
2866
0573ddae
MD
2867** Backtraces in scripts
2868
2869It is now possible to get backtraces in scripts.
2870
2871Put
2872
2873 (debug-enable 'debug 'backtrace)
2874
2875at the top of the script.
2876
2877(The first options enables the debugging evaluator.
2878 The second enables backtraces.)
2879
e8855f8d
MD
2880** Part of module system symbol lookup now implemented in C
2881
2882The eval closure of most modules is now implemented in C. Since this
2883was one of the bottlenecks for loading speed, Guile now loads code
2884substantially faster than before.
2885
f25f761d
GH
2886** Attempting to get the value of an unbound variable now produces
2887an exception with a key of 'unbound-variable instead of 'misc-error.
2888
1a35eadc
GH
2889** The initial default output port is now unbuffered if it's using a
2890tty device. Previously in this situation it was line-buffered.
2891
820920e6
MD
2892** New hook: after-gc-hook
2893
2894after-gc-hook takes over the role of gc-thunk. This hook is run at
2895the first SCM_TICK after a GC. (Thus, the code is run at the same
2896point during evaluation as signal handlers.)
2897
2898Note that this hook should be used only for diagnostic and debugging
2899purposes. It is not certain that it will continue to be well-defined
2900when this hook is run in the future.
2901
2902C programmers: Note the new C level hooks scm_before_gc_c_hook,
2903scm_before_sweep_c_hook, scm_after_gc_c_hook.
2904
b5074b23
MD
2905** Improvements to garbage collector
2906
2907Guile 1.4 has a new policy for triggering heap allocation and
2908determining the sizes of heap segments. It fixes a number of problems
2909in the old GC.
2910
29111. The new policy can handle two separate pools of cells
2912 (2-word/4-word) better. (The old policy would run wild, allocating
2913 more and more memory for certain programs.)
2914
29152. The old code would sometimes allocate far too much heap so that the
2916 Guile process became gigantic. The new code avoids this.
2917
29183. The old code would sometimes allocate too little so that few cells
2919 were freed at GC so that, in turn, too much time was spent in GC.
2920
29214. The old code would often trigger heap allocation several times in a
2922 row. (The new scheme predicts how large the segments needs to be
2923 in order not to need further allocation.)
2924
e8855f8d
MD
2925All in all, the new GC policy will make larger applications more
2926efficient.
2927
b5074b23
MD
2928The new GC scheme also is prepared for POSIX threading. Threads can
2929allocate private pools of cells ("clusters") with just a single
2930function call. Allocation of single cells from such a cluster can
2931then proceed without any need of inter-thread synchronization.
2932
2933** New environment variables controlling GC parameters
2934
2935GUILE_MAX_SEGMENT_SIZE Maximal segment size
2936 (default = 2097000)
2937
2938Allocation of 2-word cell heaps:
2939
2940GUILE_INIT_SEGMENT_SIZE_1 Size of initial heap segment in bytes
2941 (default = 360000)
2942
2943GUILE_MIN_YIELD_1 Minimum number of freed cells at each
2944 GC in percent of total heap size
2945 (default = 40)
2946
2947Allocation of 4-word cell heaps
2948(used for real numbers and misc other objects):
2949
2950GUILE_INIT_SEGMENT_SIZE_2, GUILE_MIN_YIELD_2
2951
2952(See entry "Way for application to customize GC parameters" under
2953 section "Changes to the scm_ interface" below.)
2954
67ef2dca
MD
2955** Guile now implements reals using 4-word cells
2956
2957This speeds up computation with reals. (They were earlier allocated
2958with `malloc'.) There is still some room for optimizations, however.
2959
2960** Some further steps toward POSIX thread support have been taken
2961
2962*** Guile's critical sections (SCM_DEFER/ALLOW_INTS)
2963don't have much effect any longer, and many of them will be removed in
2964next release.
2965
2966*** Signals
2967are only handled at the top of the evaluator loop, immediately after
2968I/O, and in scm_equalp.
2969
2970*** The GC can allocate thread private pools of pairs.
2971
0af43c4a
MD
2972* Changes to Scheme functions and syntax
2973
a0128ebe 2974** close-input-port and close-output-port are now R5RS
7c1e0b12 2975
a0128ebe 2976These procedures have been turned into primitives and have R5RS behaviour.
7c1e0b12 2977
0af43c4a
MD
2978** New procedure: simple-format PORT MESSAGE ARG1 ...
2979
2980(ice-9 boot) makes `format' an alias for `simple-format' until possibly
2981extended by the more sophisticated version in (ice-9 format)
2982
2983(simple-format port message . args)
2984Write MESSAGE to DESTINATION, defaulting to `current-output-port'.
2985MESSAGE can contain ~A (was %s) and ~S (was %S) escapes. When printed,
2986the escapes are replaced with corresponding members of ARGS:
2987~A formats using `display' and ~S formats using `write'.
2988If DESTINATION is #t, then use the `current-output-port',
2989if DESTINATION is #f, then return a string containing the formatted text.
2990Does not add a trailing newline."
2991
2992** string-ref: the second argument is no longer optional.
2993
2994** string, list->string: no longer accept strings in their arguments,
2995only characters, for compatibility with R5RS.
2996
2997** New procedure: port-closed? PORT
2998Returns #t if PORT is closed or #f if it is open.
2999
0a9e521f
MD
3000** Deprecated: list*
3001
3002The list* functionality is now provided by cons* (SRFI-1 compliant)
3003
b5074b23
MD
3004** New procedure: cons* ARG1 ARG2 ... ARGn
3005
3006Like `list', but the last arg provides the tail of the constructed list,
3007returning (cons ARG1 (cons ARG2 (cons ... ARGn))).
3008
3009Requires at least one argument. If given one argument, that argument
3010is returned as result.
3011
3012This function is called `list*' in some other Schemes and in Common LISP.
3013
341f78c9
MD
3014** Removed deprecated: serial-map, serial-array-copy!, serial-array-map!
3015
e8855f8d
MD
3016** New procedure: object-documentation OBJECT
3017
3018Returns the documentation string associated with OBJECT. The
3019procedure uses a caching mechanism so that subsequent lookups are
3020faster.
3021
3022Exported by (ice-9 documentation).
3023
3024** module-name now returns full names of modules
3025
3026Previously, only the last part of the name was returned (`session' for
3027`(ice-9 session)'). Ex: `(ice-9 session)'.
3028
894a712b
DH
3029* Changes to the gh_ interface
3030
3031** Deprecated: gh_int2scmb
3032
3033Use gh_bool2scm instead.
3034
a2349a28
GH
3035* Changes to the scm_ interface
3036
810e1aec
MD
3037** Guile primitives now carry docstrings!
3038
3039Thanks to Greg Badros!
3040
0a9e521f 3041** Guile primitives are defined in a new way: SCM_DEFINE/SCM_DEFINE1/SCM_PROC
0af43c4a 3042
0a9e521f
MD
3043Now Guile primitives are defined using the SCM_DEFINE/SCM_DEFINE1/SCM_PROC
3044macros and must contain a docstring that is extracted into foo.doc using a new
0af43c4a
MD
3045guile-doc-snarf script (that uses guile-doc-snarf.awk).
3046
0a9e521f
MD
3047However, a major overhaul of these macros is scheduled for the next release of
3048guile.
3049
0af43c4a
MD
3050** Guile primitives use a new technique for validation of arguments
3051
3052SCM_VALIDATE_* macros are defined to ease the redundancy and improve
3053the readability of argument checking.
3054
3055** All (nearly?) K&R prototypes for functions replaced with ANSI C equivalents.
3056
894a712b 3057** New macros: SCM_PACK, SCM_UNPACK
f8a72ca4
MD
3058
3059Compose/decompose an SCM value.
3060
894a712b
DH
3061The SCM type is now treated as an abstract data type and may be defined as a
3062long, a void* or as a struct, depending on the architecture and compile time
3063options. This makes it easier to find several types of bugs, for example when
3064SCM values are treated as integers without conversion. Values of the SCM type
3065should be treated as "atomic" values. These macros are used when
f8a72ca4
MD
3066composing/decomposing an SCM value, either because you want to access
3067individual bits, or because you want to treat it as an integer value.
3068
3069E.g., in order to set bit 7 in an SCM value x, use the expression
3070
3071 SCM_PACK (SCM_UNPACK (x) | 0x80)
3072
e11f8b42
DH
3073** The name property of hooks is deprecated.
3074Thus, the use of SCM_HOOK_NAME and scm_make_hook_with_name is deprecated.
3075
3076You can emulate this feature by using object properties.
3077
6c0201ad 3078** Deprecated macros: SCM_INPORTP, SCM_OUTPORTP, SCM_CRDY, SCM_ICHRP,
894a712b
DH
3079SCM_ICHR, SCM_MAKICHR, SCM_SETJMPBUF, SCM_NSTRINGP, SCM_NRWSTRINGP,
3080SCM_NVECTORP
f8a72ca4 3081
894a712b 3082These macros will be removed in a future release of Guile.
7c1e0b12 3083
6c0201ad 3084** The following types, functions and macros from numbers.h are deprecated:
0a9e521f
MD
3085scm_dblproc, SCM_UNEGFIXABLE, SCM_FLOBUFLEN, SCM_INEXP, SCM_CPLXP, SCM_REAL,
3086SCM_IMAG, SCM_REALPART, scm_makdbl, SCM_SINGP, SCM_NUM2DBL, SCM_NO_BIGDIG
3087
a2349a28
GH
3088** Port internals: the rw_random variable in the scm_port structure
3089must be set to non-zero in any random access port. In recent Guile
3090releases it was only set for bidirectional random-access ports.
3091
7dcb364d
GH
3092** Port internals: the seek ptob procedure is now responsible for
3093resetting the buffers if required. The change was made so that in the
3094special case of reading the current position (i.e., seek p 0 SEEK_CUR)
3095the fport and strport ptobs can avoid resetting the buffers,
3096in particular to avoid discarding unread chars. An existing port
3097type can be fixed by adding something like the following to the
3098beginning of the ptob seek procedure:
3099
3100 if (pt->rw_active == SCM_PORT_READ)
3101 scm_end_input (object);
3102 else if (pt->rw_active == SCM_PORT_WRITE)
3103 ptob->flush (object);
3104
3105although to actually avoid resetting the buffers and discard unread
3106chars requires further hacking that depends on the characteristics
3107of the ptob.
3108
894a712b
DH
3109** Deprecated functions: scm_fseek, scm_tag
3110
3111These functions are no longer used and will be removed in a future version.
3112
f25f761d
GH
3113** The scm_sysmissing procedure is no longer used in libguile.
3114Unless it turns out to be unexpectedly useful to somebody, it will be
3115removed in a future version.
3116
0af43c4a
MD
3117** The format of error message strings has changed
3118
3119The two C procedures: scm_display_error and scm_error, as well as the
3120primitive `scm-error', now use scm_simple_format to do their work.
3121This means that the message strings of all code must be updated to use
3122~A where %s was used before, and ~S where %S was used before.
3123
3124During the period when there still are a lot of old Guiles out there,
3125you might want to support both old and new versions of Guile.
3126
3127There are basically two methods to achieve this. Both methods use
3128autoconf. Put
3129
3130 AC_CHECK_FUNCS(scm_simple_format)
3131
3132in your configure.in.
3133
3134Method 1: Use the string concatenation features of ANSI C's
3135 preprocessor.
3136
3137In C:
3138
3139#ifdef HAVE_SCM_SIMPLE_FORMAT
3140#define FMT_S "~S"
3141#else
3142#define FMT_S "%S"
3143#endif
3144
3145Then represent each of your error messages using a preprocessor macro:
3146
3147#define E_SPIDER_ERROR "There's a spider in your " ## FMT_S ## "!!!"
3148
3149In Scheme:
3150
3151(define fmt-s (if (defined? 'simple-format) "~S" "%S"))
3152(define make-message string-append)
3153
3154(define e-spider-error (make-message "There's a spider in your " fmt-s "!!!"))
3155
3156Method 2: Use the oldfmt function found in doc/oldfmt.c.
3157
3158In C:
3159
3160scm_misc_error ("picnic", scm_c_oldfmt0 ("There's a spider in your ~S!!!"),
3161 ...);
3162
3163In Scheme:
3164
3165(scm-error 'misc-error "picnic" (oldfmt "There's a spider in your ~S!!!")
3166 ...)
3167
3168
f3b5e185
MD
3169** Deprecated: coop_mutex_init, coop_condition_variable_init
3170
3171Don't use the functions coop_mutex_init and
3172coop_condition_variable_init. They will change.
3173
3174Use scm_mutex_init and scm_cond_init instead.
3175
f3b5e185
MD
3176** New function: int scm_cond_timedwait (scm_cond_t *COND, scm_mutex_t *MUTEX, const struct timespec *ABSTIME)
3177 `scm_cond_timedwait' atomically unlocks MUTEX and waits on
3178 COND, as `scm_cond_wait' does, but it also bounds the duration
3179 of the wait. If COND has not been signaled before time ABSTIME,
3180 the mutex MUTEX is re-acquired and `scm_cond_timedwait'
3181 returns the error code `ETIMEDOUT'.
3182
3183 The ABSTIME parameter specifies an absolute time, with the same
3184 origin as `time' and `gettimeofday': an ABSTIME of 0 corresponds
3185 to 00:00:00 GMT, January 1, 1970.
3186
3187** New function: scm_cond_broadcast (scm_cond_t *COND)
3188 `scm_cond_broadcast' restarts all the threads that are waiting
3189 on the condition variable COND. Nothing happens if no threads are
3190 waiting on COND.
3191
3192** New function: scm_key_create (scm_key_t *KEY, void (*destr_function) (void *))
3193 `scm_key_create' allocates a new TSD key. The key is stored in
3194 the location pointed to by KEY. There is no limit on the number
3195 of keys allocated at a given time. The value initially associated
3196 with the returned key is `NULL' in all currently executing threads.
3197
3198 The DESTR_FUNCTION argument, if not `NULL', specifies a destructor
3199 function associated with the key. When a thread terminates,
3200 DESTR_FUNCTION is called on the value associated with the key in
3201 that thread. The DESTR_FUNCTION is not called if a key is deleted
3202 with `scm_key_delete' or a value is changed with
3203 `scm_setspecific'. The order in which destructor functions are
3204 called at thread termination time is unspecified.
3205
3206 Destructors are not yet implemented.
3207
3208** New function: scm_setspecific (scm_key_t KEY, const void *POINTER)
3209 `scm_setspecific' changes the value associated with KEY in the
3210 calling thread, storing the given POINTER instead.
3211
3212** New function: scm_getspecific (scm_key_t KEY)
3213 `scm_getspecific' returns the value currently associated with
3214 KEY in the calling thread.
3215
3216** New function: scm_key_delete (scm_key_t KEY)
3217 `scm_key_delete' deallocates a TSD key. It does not check
3218 whether non-`NULL' values are associated with that key in the
3219 currently executing threads, nor call the destructor function
3220 associated with the key.
3221
820920e6
MD
3222** New function: scm_c_hook_init (scm_c_hook_t *HOOK, void *HOOK_DATA, scm_c_hook_type_t TYPE)
3223
3224Initialize a C level hook HOOK with associated HOOK_DATA and type
3225TYPE. (See scm_c_hook_run ().)
3226
3227** New function: scm_c_hook_add (scm_c_hook_t *HOOK, scm_c_hook_function_t FUNC, void *FUNC_DATA, int APPENDP)
3228
3229Add hook function FUNC with associated FUNC_DATA to HOOK. If APPENDP
3230is true, add it last, otherwise first. The same FUNC can be added
3231multiple times if FUNC_DATA differ and vice versa.
3232
3233** New function: scm_c_hook_remove (scm_c_hook_t *HOOK, scm_c_hook_function_t FUNC, void *FUNC_DATA)
3234
3235Remove hook function FUNC with associated FUNC_DATA from HOOK. A
3236function is only removed if both FUNC and FUNC_DATA matches.
3237
3238** New function: void *scm_c_hook_run (scm_c_hook_t *HOOK, void *DATA)
3239
3240Run hook HOOK passing DATA to the hook functions.
3241
3242If TYPE is SCM_C_HOOK_NORMAL, all hook functions are run. The value
3243returned is undefined.
3244
3245If TYPE is SCM_C_HOOK_OR, hook functions are run until a function
3246returns a non-NULL value. This value is returned as the result of
3247scm_c_hook_run. If all functions return NULL, NULL is returned.
3248
3249If TYPE is SCM_C_HOOK_AND, hook functions are run until a function
3250returns a NULL value, and NULL is returned. If all functions returns
3251a non-NULL value, the last value is returned.
3252
3253** New C level GC hooks
3254
3255Five new C level hooks has been added to the garbage collector.
3256
3257 scm_before_gc_c_hook
3258 scm_after_gc_c_hook
3259
3260are run before locking and after unlocking the heap. The system is
3261thus in a mode where evaluation can take place. (Except that
3262scm_before_gc_c_hook must not allocate new cells.)
3263
3264 scm_before_mark_c_hook
3265 scm_before_sweep_c_hook
3266 scm_after_sweep_c_hook
3267
3268are run when the heap is locked. These are intended for extension of
3269the GC in a modular fashion. Examples are the weaks and guardians
3270modules.
3271
b5074b23
MD
3272** Way for application to customize GC parameters
3273
3274The application can set up other default values for the GC heap
3275allocation parameters
3276
3277 GUILE_INIT_HEAP_SIZE_1, GUILE_MIN_YIELD_1,
3278 GUILE_INIT_HEAP_SIZE_2, GUILE_MIN_YIELD_2,
3279 GUILE_MAX_SEGMENT_SIZE,
3280
3281by setting
3282
3283 scm_default_init_heap_size_1, scm_default_min_yield_1,
3284 scm_default_init_heap_size_2, scm_default_min_yield_2,
3285 scm_default_max_segment_size
3286
3287respectively before callong scm_boot_guile.
3288
3289(See entry "New environment variables ..." in section
3290"Changes to the stand-alone interpreter" above.)
3291
9704841c
MD
3292** scm_protect_object/scm_unprotect_object now nest
3293
67ef2dca
MD
3294This means that you can call scm_protect_object multiple times on an
3295object and count on the object being protected until
3296scm_unprotect_object has been call the same number of times.
3297
3298The functions also have better time complexity.
3299
3300Still, it is usually possible to structure the application in a way
3301that you don't need to use these functions. For example, if you use a
3302protected standard Guile list to keep track of live objects rather
3303than some custom data type, objects will die a natural death when they
3304are no longer needed.
3305
0a9e521f
MD
3306** Deprecated type tags: scm_tc16_flo, scm_tc_flo, scm_tc_dblr, scm_tc_dblc
3307
3308Guile does not provide the float representation for inexact real numbers any
3309more. Now, only doubles are used to represent inexact real numbers. Further,
3310the tag names scm_tc_dblr and scm_tc_dblc have been changed to scm_tc16_real
3311and scm_tc16_complex, respectively.
3312
341f78c9
MD
3313** Removed deprecated type scm_smobfuns
3314
3315** Removed deprecated function scm_newsmob
3316
b5074b23
MD
3317** Warning: scm_make_smob_type_mfpe might become deprecated in a future release
3318
3319There is an ongoing discussion among the developers whether to
3320deprecate `scm_make_smob_type_mfpe' or not. Please use the current
3321standard interface (scm_make_smob_type, scm_set_smob_XXX) in new code
3322until this issue has been settled.
3323
341f78c9
MD
3324** Removed deprecated type tag scm_tc16_kw
3325
2728d7f4
MD
3326** Added type tag scm_tc16_keyword
3327
3328(This was introduced already in release 1.3.4 but was not documented
3329 until now.)
3330
67ef2dca
MD
3331** gdb_print now prints "*** Guile not initialized ***" until Guile initialized
3332
f25f761d
GH
3333* Changes to system call interfaces:
3334
28d77376
GH
3335** The "select" procedure now tests port buffers for the ability to
3336provide input or accept output. Previously only the underlying file
3337descriptors were checked.
3338
bd9e24b3
GH
3339** New variable PIPE_BUF: the maximum number of bytes that can be
3340atomically written to a pipe.
3341
f25f761d
GH
3342** If a facility is not available on the system when Guile is
3343compiled, the corresponding primitive procedure will not be defined.
3344Previously it would have been defined but would throw a system-error
3345exception if called. Exception handlers which catch this case may
3346need minor modification: an error will be thrown with key
3347'unbound-variable instead of 'system-error. Alternatively it's
3348now possible to use `defined?' to check whether the facility is
3349available.
3350
38c1d3c4 3351** Procedures which depend on the timezone should now give the correct
6c0201ad 3352result on systems which cache the TZ environment variable, even if TZ
38c1d3c4
GH
3353is changed without calling tzset.
3354
5c11cc9d
GH
3355* Changes to the networking interfaces:
3356
3357** New functions: htons, ntohs, htonl, ntohl: for converting short and
3358long integers between network and host format. For now, it's not
3359particularly convenient to do this kind of thing, but consider:
3360
3361(define write-network-long
3362 (lambda (value port)
3363 (let ((v (make-uniform-vector 1 1 0)))
3364 (uniform-vector-set! v 0 (htonl value))
3365 (uniform-vector-write v port))))
3366
3367(define read-network-long
3368 (lambda (port)
3369 (let ((v (make-uniform-vector 1 1 0)))
3370 (uniform-vector-read! v port)
3371 (ntohl (uniform-vector-ref v 0)))))
3372
3373** If inet-aton fails, it now throws an error with key 'misc-error
3374instead of 'system-error, since errno is not relevant.
3375
3376** Certain gethostbyname/gethostbyaddr failures now throw errors with
3377specific keys instead of 'system-error. The latter is inappropriate
3378since errno will not have been set. The keys are:
afe5177e 3379'host-not-found, 'try-again, 'no-recovery and 'no-data.
5c11cc9d
GH
3380
3381** sethostent, setnetent, setprotoent, setservent: now take an
3382optional argument STAYOPEN, which specifies whether the database
3383remains open after a database entry is accessed randomly (e.g., using
3384gethostbyname for the hosts database.) The default is #f. Previously
3385#t was always used.
3386
cc36e791 3387\f
43fa9a05
JB
3388Changes since Guile 1.3.2:
3389
0fdcbcaa
MD
3390* Changes to the stand-alone interpreter
3391
3392** Debugger
3393
3394An initial version of the Guile debugger written by Chris Hanson has
3395been added. The debugger is still under development but is included
3396in the distribution anyway since it is already quite useful.
3397
3398Type
3399
3400 (debug)
3401
3402after an error to enter the debugger. Type `help' inside the debugger
3403for a description of available commands.
3404
3405If you prefer to have stack frames numbered and printed in
3406anti-chronological order and prefer up in the stack to be down on the
3407screen as is the case in gdb, you can put
3408
3409 (debug-enable 'backwards)
3410
3411in your .guile startup file. (However, this means that Guile can't
3412use indentation to indicate stack level.)
3413
3414The debugger is autoloaded into Guile at the first use.
3415
3416** Further enhancements to backtraces
3417
3418There is a new debug option `width' which controls the maximum width
3419on the screen of printed stack frames. Fancy printing parameters
3420("level" and "length" as in Common LISP) are adaptively adjusted for
3421each stack frame to give maximum information while still fitting
3422within the bounds. If the stack frame can't be made to fit by
3423adjusting parameters, it is simply cut off at the end. This is marked
3424with a `$'.
3425
3426** Some modules are now only loaded when the repl is started
3427
3428The modules (ice-9 debug), (ice-9 session), (ice-9 threads) and (ice-9
3429regex) are now loaded into (guile-user) only if the repl has been
3430started. The effect is that the startup time for scripts has been
3431reduced to 30% of what it was previously.
3432
3433Correctly written scripts load the modules they require at the top of
3434the file and should not be affected by this change.
3435
ece41168
MD
3436** Hooks are now represented as smobs
3437
6822fe53
MD
3438* Changes to Scheme functions and syntax
3439
0ce204b0
MV
3440** Readline support has changed again.
3441
3442The old (readline-activator) module is gone. Use (ice-9 readline)
3443instead, which now contains all readline functionality. So the code
3444to activate readline is now
3445
3446 (use-modules (ice-9 readline))
3447 (activate-readline)
3448
3449This should work at any time, including from the guile prompt.
3450
5d195868
JB
3451To avoid confusion about the terms of Guile's license, please only
3452enable readline for your personal use; please don't make it the
3453default for others. Here is why we make this rather odd-sounding
3454request:
3455
3456Guile is normally licensed under a weakened form of the GNU General
3457Public License, which allows you to link code with Guile without
3458placing that code under the GPL. This exception is important to some
3459people.
3460
3461However, since readline is distributed under the GNU General Public
3462License, when you link Guile with readline, either statically or
3463dynamically, you effectively change Guile's license to the strict GPL.
3464Whenever you link any strictly GPL'd code into Guile, uses of Guile
3465which are normally permitted become forbidden. This is a rather
3466non-obvious consequence of the licensing terms.
3467
3468So, to make sure things remain clear, please let people choose for
3469themselves whether to link GPL'd libraries like readline with Guile.
3470
25b0654e
JB
3471** regexp-substitute/global has changed slightly, but incompatibly.
3472
3473If you include a function in the item list, the string of the match
3474object it receives is the same string passed to
3475regexp-substitute/global, not some suffix of that string.
3476Correspondingly, the match's positions are relative to the entire
3477string, not the suffix.
3478
3479If the regexp can match the empty string, the way matches are chosen
3480from the string has changed. regexp-substitute/global recognizes the
3481same set of matches that list-matches does; see below.
3482
3483** New function: list-matches REGEXP STRING [FLAGS]
3484
3485Return a list of match objects, one for every non-overlapping, maximal
3486match of REGEXP in STRING. The matches appear in left-to-right order.
3487list-matches only reports matches of the empty string if there are no
3488other matches which begin on, end at, or include the empty match's
3489position.
3490
3491If present, FLAGS is passed as the FLAGS argument to regexp-exec.
3492
3493** New function: fold-matches REGEXP STRING INIT PROC [FLAGS]
3494
3495For each match of REGEXP in STRING, apply PROC to the match object,
3496and the last value PROC returned, or INIT for the first call. Return
3497the last value returned by PROC. We apply PROC to the matches as they
3498appear from left to right.
3499
3500This function recognizes matches according to the same criteria as
3501list-matches.
3502
3503Thus, you could define list-matches like this:
3504
3505 (define (list-matches regexp string . flags)
3506 (reverse! (apply fold-matches regexp string '() cons flags)))
3507
3508If present, FLAGS is passed as the FLAGS argument to regexp-exec.
3509
bc848f7f
MD
3510** Hooks
3511
3512*** New function: hook? OBJ
3513
3514Return #t if OBJ is a hook, otherwise #f.
3515
ece41168
MD
3516*** New function: make-hook-with-name NAME [ARITY]
3517
3518Return a hook with name NAME and arity ARITY. The default value for
3519ARITY is 0. The only effect of NAME is that it will appear when the
3520hook object is printed to ease debugging.
3521
bc848f7f
MD
3522*** New function: hook-empty? HOOK
3523
3524Return #t if HOOK doesn't contain any procedures, otherwise #f.
3525
3526*** New function: hook->list HOOK
3527
3528Return a list of the procedures that are called when run-hook is
3529applied to HOOK.
3530
b074884f
JB
3531** `map' signals an error if its argument lists are not all the same length.
3532
3533This is the behavior required by R5RS, so this change is really a bug
3534fix. But it seems to affect a lot of people's code, so we're
3535mentioning it here anyway.
3536
6822fe53
MD
3537** Print-state handling has been made more transparent
3538
3539Under certain circumstances, ports are represented as a port with an
3540associated print state. Earlier, this pair was represented as a pair
3541(see "Some magic has been added to the printer" below). It is now
3542indistinguishable (almost; see `get-print-state') from a port on the
3543user level.
3544
3545*** New function: port-with-print-state OUTPUT-PORT PRINT-STATE
3546
3547Return a new port with the associated print state PRINT-STATE.
3548
3549*** New function: get-print-state OUTPUT-PORT
3550
3551Return the print state associated with this port if it exists,
3552otherwise return #f.
3553
340a8770 3554*** New function: directory-stream? OBJECT
77242ff9 3555
340a8770 3556Returns true iff OBJECT is a directory stream --- the sort of object
77242ff9
GH
3557returned by `opendir'.
3558
0fdcbcaa
MD
3559** New function: using-readline?
3560
3561Return #t if readline is in use in the current repl.
3562
26405bc1
MD
3563** structs will be removed in 1.4
3564
3565Structs will be replaced in Guile 1.4. We will merge GOOPS into Guile
3566and use GOOPS objects as the fundamental record type.
3567
49199eaa
MD
3568* Changes to the scm_ interface
3569
26405bc1
MD
3570** structs will be removed in 1.4
3571
3572The entire current struct interface (struct.c, struct.h) will be
3573replaced in Guile 1.4. We will merge GOOPS into libguile and use
3574GOOPS objects as the fundamental record type.
3575
49199eaa
MD
3576** The internal representation of subr's has changed
3577
3578Instead of giving a hint to the subr name, the CAR field of the subr
3579now contains an index to a subr entry in scm_subr_table.
3580
3581*** New variable: scm_subr_table
3582
3583An array of subr entries. A subr entry contains the name, properties
3584and documentation associated with the subr. The properties and
3585documentation slots are not yet used.
3586
3587** A new scheme for "forwarding" calls to a builtin to a generic function
3588
3589It is now possible to extend the functionality of some Guile
3590primitives by letting them defer a call to a GOOPS generic function on
240ed66f 3591argument mismatch. This means that there is no loss of efficiency in
daf516d6 3592normal evaluation.
49199eaa
MD
3593
3594Example:
3595
daf516d6 3596 (use-modules (oop goops)) ; Must be GOOPS version 0.2.
49199eaa
MD
3597 (define-method + ((x <string>) (y <string>))
3598 (string-append x y))
3599
86a4d62e
MD
3600+ will still be as efficient as usual in numerical calculations, but
3601can also be used for concatenating strings.
49199eaa 3602
86a4d62e 3603Who will be the first one to extend Guile's numerical tower to
daf516d6
MD
3604rationals? :) [OK, there a few other things to fix before this can
3605be made in a clean way.]
49199eaa
MD
3606
3607*** New snarf macros for defining primitives: SCM_GPROC, SCM_GPROC1
3608
3609 New macro: SCM_GPROC (CNAME, SNAME, REQ, OPT, VAR, CFUNC, GENERIC)
3610
3611 New macro: SCM_GPROC1 (CNAME, SNAME, TYPE, CFUNC, GENERIC)
3612
d02cafe7 3613These do the same job as SCM_PROC and SCM_PROC1, but they also define
49199eaa
MD
3614a variable GENERIC which can be used by the dispatch macros below.
3615
3616[This is experimental code which may change soon.]
3617
3618*** New macros for forwarding control to a generic on arg type error
3619
3620 New macro: SCM_WTA_DISPATCH_1 (GENERIC, ARG1, POS, SUBR)
3621
3622 New macro: SCM_WTA_DISPATCH_2 (GENERIC, ARG1, ARG2, POS, SUBR)
3623
3624These correspond to the scm_wta function call, and have the same
3625behaviour until the user has called the GOOPS primitive
3626`enable-primitive-generic!'. After that, these macros will apply the
3627generic function GENERIC to the argument(s) instead of calling
3628scm_wta.
3629
3630[This is experimental code which may change soon.]
3631
3632*** New macros for argument testing with generic dispatch
3633
3634 New macro: SCM_GASSERT1 (COND, GENERIC, ARG1, POS, SUBR)
3635
3636 New macro: SCM_GASSERT2 (COND, GENERIC, ARG1, ARG2, POS, SUBR)
3637
3638These correspond to the SCM_ASSERT macro, but will defer control to
3639GENERIC on error after `enable-primitive-generic!' has been called.
3640
3641[This is experimental code which may change soon.]
3642
3643** New function: SCM scm_eval_body (SCM body, SCM env)
3644
3645Evaluates the body of a special form.
3646
3647** The internal representation of struct's has changed
3648
3649Previously, four slots were allocated for the procedure(s) of entities
3650and operators. The motivation for this representation had to do with
3651the structure of the evaluator, the wish to support tail-recursive
3652generic functions, and efficiency. Since the generic function
3653dispatch mechanism has changed, there is no longer a need for such an
3654expensive representation, and the representation has been simplified.
3655
3656This should not make any difference for most users.
3657
3658** GOOPS support has been cleaned up.
3659
3660Some code has been moved from eval.c to objects.c and code in both of
3661these compilation units has been cleaned up and better structured.
3662
3663*** New functions for applying generic functions
3664
3665 New function: SCM scm_apply_generic (GENERIC, ARGS)
3666 New function: SCM scm_call_generic_0 (GENERIC)
3667 New function: SCM scm_call_generic_1 (GENERIC, ARG1)
3668 New function: SCM scm_call_generic_2 (GENERIC, ARG1, ARG2)
3669 New function: SCM scm_call_generic_3 (GENERIC, ARG1, ARG2, ARG3)
3670
ece41168
MD
3671** Deprecated function: scm_make_named_hook
3672
3673It is now replaced by:
3674
3675** New function: SCM scm_create_hook (const char *name, int arity)
3676
3677Creates a hook in the same way as make-hook above but also
3678binds a variable named NAME to it.
3679
3680This is the typical way of creating a hook from C code.
3681
3682Currently, the variable is created in the "current" module.
3683This might change when we get the new module system.
3684
3685[The behaviour is identical to scm_make_named_hook.]
3686
3687
43fa9a05 3688\f
f3227c7a
JB
3689Changes since Guile 1.3:
3690
6ca345f3
JB
3691* Changes to mailing lists
3692
3693** Some of the Guile mailing lists have moved to sourceware.cygnus.com.
3694
3695See the README file to find current addresses for all the Guile
3696mailing lists.
3697
d77fb593
JB
3698* Changes to the distribution
3699
1d335863
JB
3700** Readline support is no longer included with Guile by default.
3701
3702Based on the different license terms of Guile and Readline, we
3703concluded that Guile should not *by default* cause the linking of
3704Readline into an application program. Readline support is now offered
3705as a separate module, which is linked into an application only when
3706you explicitly specify it.
3707
3708Although Guile is GNU software, its distribution terms add a special
3709exception to the usual GNU General Public License (GPL). Guile's
3710license includes a clause that allows you to link Guile with non-free
3711programs. We add this exception so as not to put Guile at a
3712disadvantage vis-a-vis other extensibility packages that support other
3713languages.
3714
3715In contrast, the GNU Readline library is distributed under the GNU
3716General Public License pure and simple. This means that you may not
3717link Readline, even dynamically, into an application unless it is
3718distributed under a free software license that is compatible the GPL.
3719
3720Because of this difference in distribution terms, an application that
3721can use Guile may not be able to use Readline. Now users will be
3722explicitly offered two independent decisions about the use of these
3723two packages.
d77fb593 3724
0e8a8468
MV
3725You can activate the readline support by issuing
3726
3727 (use-modules (readline-activator))
3728 (activate-readline)
3729
3730from your ".guile" file, for example.
3731
e4eae9b1
MD
3732* Changes to the stand-alone interpreter
3733
67ad463a
MD
3734** All builtins now print as primitives.
3735Previously builtin procedures not belonging to the fundamental subr
3736types printed as #<compiled closure #<primitive-procedure gsubr-apply>>.
3737Now, they print as #<primitive-procedure NAME>.
3738
3739** Backtraces slightly more intelligible.
3740gsubr-apply and macro transformer application frames no longer appear
3741in backtraces.
3742
69c6acbb
JB
3743* Changes to Scheme functions and syntax
3744
2a52b429
MD
3745** Guile now correctly handles internal defines by rewriting them into
3746their equivalent letrec. Previously, internal defines would
3747incrementally add to the innermost environment, without checking
3748whether the restrictions specified in RnRS were met. This lead to the
3749correct behaviour when these restriction actually were met, but didn't
3750catch all illegal uses. Such an illegal use could lead to crashes of
3751the Guile interpreter or or other unwanted results. An example of
3752incorrect internal defines that made Guile behave erratically:
3753
3754 (let ()
3755 (define a 1)
3756 (define (b) a)
3757 (define c (1+ (b)))
3758 (define d 3)
3759
3760 (b))
3761
3762 => 2
3763
3764The problem with this example is that the definition of `c' uses the
3765value of `b' directly. This confuses the meoization machine of Guile
3766so that the second call of `b' (this time in a larger environment that
3767also contains bindings for `c' and `d') refers to the binding of `c'
3768instead of `a'. You could also make Guile crash with a variation on
3769this theme:
3770
3771 (define (foo flag)
3772 (define a 1)
3773 (define (b flag) (if flag a 1))
3774 (define c (1+ (b flag)))
3775 (define d 3)
3776
3777 (b #t))
3778
3779 (foo #f)
3780 (foo #t)
3781
3782From now on, Guile will issue an `Unbound variable: b' error message
3783for both examples.
3784
36d3d540
MD
3785** Hooks
3786
3787A hook contains a list of functions which should be called on
3788particular occasions in an existing program. Hooks are used for
3789customization.
3790
3791A window manager might have a hook before-window-map-hook. The window
3792manager uses the function run-hooks to call all functions stored in
3793before-window-map-hook each time a window is mapped. The user can
3794store functions in the hook using add-hook!.
3795
3796In Guile, hooks are first class objects.
3797
3798*** New function: make-hook [N_ARGS]
3799
3800Return a hook for hook functions which can take N_ARGS arguments.
3801The default value for N_ARGS is 0.
3802
ad91d6c3
MD
3803(See also scm_make_named_hook below.)
3804
36d3d540
MD
3805*** New function: add-hook! HOOK PROC [APPEND_P]
3806
3807Put PROC at the beginning of the list of functions stored in HOOK.
3808If APPEND_P is supplied, and non-false, put PROC at the end instead.
3809
3810PROC must be able to take the number of arguments specified when the
3811hook was created.
3812
3813If PROC already exists in HOOK, then remove it first.
3814
3815*** New function: remove-hook! HOOK PROC
3816
3817Remove PROC from the list of functions in HOOK.
3818
3819*** New function: reset-hook! HOOK
3820
3821Clear the list of hook functions stored in HOOK.
3822
3823*** New function: run-hook HOOK ARG1 ...
3824
3825Run all hook functions stored in HOOK with arguments ARG1 ... .
3826The number of arguments supplied must correspond to the number given
3827when the hook was created.
3828
56a19408
MV
3829** The function `dynamic-link' now takes optional keyword arguments.
3830 The only keyword argument that is currently defined is `:global
3831 BOOL'. With it, you can control whether the shared library will be
3832 linked in global mode or not. In global mode, the symbols from the
3833 linked library can be used to resolve references from other
3834 dynamically linked libraries. In non-global mode, the linked
3835 library is essentially invisible and can only be accessed via
3836 `dynamic-func', etc. The default is now to link in global mode.
3837 Previously, the default has been non-global mode.
3838
3839 The `#:global' keyword is only effective on platforms that support
3840 the dlopen family of functions.
3841
ad226f25 3842** New function `provided?'
b7e13f65
JB
3843
3844 - Function: provided? FEATURE
3845 Return true iff FEATURE is supported by this installation of
3846 Guile. FEATURE must be a symbol naming a feature; the global
3847 variable `*features*' is a list of available features.
3848
ad226f25
JB
3849** Changes to the module (ice-9 expect):
3850
3851*** The expect-strings macro now matches `$' in a regular expression
3852 only at a line-break or end-of-file by default. Previously it would
ab711359
JB
3853 match the end of the string accumulated so far. The old behaviour
3854 can be obtained by setting the variable `expect-strings-exec-flags'
3855 to 0.
ad226f25
JB
3856
3857*** The expect-strings macro now uses a variable `expect-strings-exec-flags'
3858 for the regexp-exec flags. If `regexp/noteol' is included, then `$'
3859 in a regular expression will still match before a line-break or
3860 end-of-file. The default is `regexp/noteol'.
3861
6c0201ad 3862*** The expect-strings macro now uses a variable
ad226f25
JB
3863 `expect-strings-compile-flags' for the flags to be supplied to
3864 `make-regexp'. The default is `regexp/newline', which was previously
3865 hard-coded.
3866
3867*** The expect macro now supplies two arguments to a match procedure:
ab711359
JB
3868 the current accumulated string and a flag to indicate whether
3869 end-of-file has been reached. Previously only the string was supplied.
3870 If end-of-file is reached, the match procedure will be called an
3871 additional time with the same accumulated string as the previous call
3872 but with the flag set.
ad226f25 3873
b7e13f65
JB
3874** New module (ice-9 format), implementing the Common Lisp `format' function.
3875
3876This code, and the documentation for it that appears here, was
3877borrowed from SLIB, with minor adaptations for Guile.
3878
3879 - Function: format DESTINATION FORMAT-STRING . ARGUMENTS
3880 An almost complete implementation of Common LISP format description
3881 according to the CL reference book `Common LISP' from Guy L.
3882 Steele, Digital Press. Backward compatible to most of the
3883 available Scheme format implementations.
3884
3885 Returns `#t', `#f' or a string; has side effect of printing
3886 according to FORMAT-STRING. If DESTINATION is `#t', the output is
3887 to the current output port and `#t' is returned. If DESTINATION
3888 is `#f', a formatted string is returned as the result of the call.
3889 NEW: If DESTINATION is a string, DESTINATION is regarded as the
3890 format string; FORMAT-STRING is then the first argument and the
3891 output is returned as a string. If DESTINATION is a number, the
3892 output is to the current error port if available by the
3893 implementation. Otherwise DESTINATION must be an output port and
3894 `#t' is returned.
3895
3896 FORMAT-STRING must be a string. In case of a formatting error
3897 format returns `#f' and prints a message on the current output or
3898 error port. Characters are output as if the string were output by
3899 the `display' function with the exception of those prefixed by a
3900 tilde (~). For a detailed description of the FORMAT-STRING syntax
3901 please consult a Common LISP format reference manual. For a test
3902 suite to verify this format implementation load `formatst.scm'.
3903 Please send bug reports to `lutzeb@cs.tu-berlin.de'.
3904
3905 Note: `format' is not reentrant, i.e. only one `format'-call may
3906 be executed at a time.
3907
3908
3909*** Format Specification (Format version 3.0)
3910
3911 Please consult a Common LISP format reference manual for a detailed
3912description of the format string syntax. For a demonstration of the
3913implemented directives see `formatst.scm'.
3914
3915 This implementation supports directive parameters and modifiers (`:'
3916and `@' characters). Multiple parameters must be separated by a comma
3917(`,'). Parameters can be numerical parameters (positive or negative),
3918character parameters (prefixed by a quote character (`''), variable
3919parameters (`v'), number of rest arguments parameter (`#'), empty and
3920default parameters. Directive characters are case independent. The
3921general form of a directive is:
3922
3923DIRECTIVE ::= ~{DIRECTIVE-PARAMETER,}[:][@]DIRECTIVE-CHARACTER
3924
3925DIRECTIVE-PARAMETER ::= [ [-|+]{0-9}+ | 'CHARACTER | v | # ]
3926
3927*** Implemented CL Format Control Directives
3928
3929 Documentation syntax: Uppercase characters represent the
3930corresponding control directive characters. Lowercase characters
3931represent control directive parameter descriptions.
3932
3933`~A'
3934 Any (print as `display' does).
3935 `~@A'
3936 left pad.
3937
3938 `~MINCOL,COLINC,MINPAD,PADCHARA'
3939 full padding.
3940
3941`~S'
3942 S-expression (print as `write' does).
3943 `~@S'
3944 left pad.
3945
3946 `~MINCOL,COLINC,MINPAD,PADCHARS'
3947 full padding.
3948
3949`~D'
3950 Decimal.
3951 `~@D'
3952 print number sign always.
3953
3954 `~:D'
3955 print comma separated.
3956
3957 `~MINCOL,PADCHAR,COMMACHARD'
3958 padding.
3959
3960`~X'
3961 Hexadecimal.
3962 `~@X'
3963 print number sign always.
3964
3965 `~:X'
3966 print comma separated.
3967
3968 `~MINCOL,PADCHAR,COMMACHARX'
3969 padding.
3970
3971`~O'
3972 Octal.
3973 `~@O'
3974 print number sign always.
3975
3976 `~:O'
3977 print comma separated.
3978
3979 `~MINCOL,PADCHAR,COMMACHARO'
3980 padding.
3981
3982`~B'
3983 Binary.
3984 `~@B'
3985 print number sign always.
3986
3987 `~:B'
3988 print comma separated.
3989
3990 `~MINCOL,PADCHAR,COMMACHARB'
3991 padding.
3992
3993`~NR'
3994 Radix N.
3995 `~N,MINCOL,PADCHAR,COMMACHARR'
3996 padding.
3997
3998`~@R'
3999 print a number as a Roman numeral.
4000
4001`~:@R'
4002 print a number as an "old fashioned" Roman numeral.
4003
4004`~:R'
4005 print a number as an ordinal English number.
4006
4007`~:@R'
4008 print a number as a cardinal English number.
4009
4010`~P'
4011 Plural.
4012 `~@P'
4013 prints `y' and `ies'.
4014
4015 `~:P'
4016 as `~P but jumps 1 argument backward.'
4017
4018 `~:@P'
4019 as `~@P but jumps 1 argument backward.'
4020
4021`~C'
4022 Character.
4023 `~@C'
4024 prints a character as the reader can understand it (i.e. `#\'
4025 prefixing).
4026
4027 `~:C'
4028 prints a character as emacs does (eg. `^C' for ASCII 03).
4029
4030`~F'
4031 Fixed-format floating-point (prints a flonum like MMM.NNN).
4032 `~WIDTH,DIGITS,SCALE,OVERFLOWCHAR,PADCHARF'
4033 `~@F'
4034 If the number is positive a plus sign is printed.
4035
4036`~E'
4037 Exponential floating-point (prints a flonum like MMM.NNN`E'EE).
4038 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARE'
4039 `~@E'
4040 If the number is positive a plus sign is printed.
4041
4042`~G'
4043 General floating-point (prints a flonum either fixed or
4044 exponential).
4045 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARG'
4046 `~@G'
4047 If the number is positive a plus sign is printed.
4048
4049`~$'
4050 Dollars floating-point (prints a flonum in fixed with signs
4051 separated).
4052 `~DIGITS,SCALE,WIDTH,PADCHAR$'
4053 `~@$'
4054 If the number is positive a plus sign is printed.
4055
4056 `~:@$'
4057 A sign is always printed and appears before the padding.
4058
4059 `~:$'
4060 The sign appears before the padding.
4061
4062`~%'
4063 Newline.
4064 `~N%'
4065 print N newlines.
4066
4067`~&'
4068 print newline if not at the beginning of the output line.
4069 `~N&'
4070 prints `~&' and then N-1 newlines.
4071
4072`~|'
4073 Page Separator.
4074 `~N|'
4075 print N page separators.
4076
4077`~~'
4078 Tilde.
4079 `~N~'
4080 print N tildes.
4081
4082`~'<newline>
4083 Continuation Line.
4084 `~:'<newline>
4085 newline is ignored, white space left.
4086
4087 `~@'<newline>
4088 newline is left, white space ignored.
4089
4090`~T'
4091 Tabulation.
4092 `~@T'
4093 relative tabulation.
4094
4095 `~COLNUM,COLINCT'
4096 full tabulation.
4097
4098`~?'
4099 Indirection (expects indirect arguments as a list).
4100 `~@?'
4101 extracts indirect arguments from format arguments.
4102
4103`~(STR~)'
4104 Case conversion (converts by `string-downcase').
4105 `~:(STR~)'
4106 converts by `string-capitalize'.
4107
4108 `~@(STR~)'
4109 converts by `string-capitalize-first'.
4110
4111 `~:@(STR~)'
4112 converts by `string-upcase'.
4113
4114`~*'
4115 Argument Jumping (jumps 1 argument forward).
4116 `~N*'
4117 jumps N arguments forward.
4118
4119 `~:*'
4120 jumps 1 argument backward.
4121
4122 `~N:*'
4123 jumps N arguments backward.
4124
4125 `~@*'
4126 jumps to the 0th argument.
4127
4128 `~N@*'
4129 jumps to the Nth argument (beginning from 0)
4130
4131`~[STR0~;STR1~;...~;STRN~]'
4132 Conditional Expression (numerical clause conditional).
4133 `~N['
4134 take argument from N.
4135
4136 `~@['
4137 true test conditional.
4138
4139 `~:['
4140 if-else-then conditional.
4141
4142 `~;'
4143 clause separator.
4144
4145 `~:;'
4146 default clause follows.
4147
4148`~{STR~}'
4149 Iteration (args come from the next argument (a list)).
4150 `~N{'
4151 at most N iterations.
4152
4153 `~:{'
4154 args from next arg (a list of lists).
4155
4156 `~@{'
4157 args from the rest of arguments.
4158
4159 `~:@{'
4160 args from the rest args (lists).
4161
4162`~^'
4163 Up and out.
4164 `~N^'
4165 aborts if N = 0
4166
4167 `~N,M^'
4168 aborts if N = M
4169
4170 `~N,M,K^'
4171 aborts if N <= M <= K
4172
4173*** Not Implemented CL Format Control Directives
4174
4175`~:A'
4176 print `#f' as an empty list (see below).
4177
4178`~:S'
4179 print `#f' as an empty list (see below).
4180
4181`~<~>'
4182 Justification.
4183
4184`~:^'
4185 (sorry I don't understand its semantics completely)
4186
4187*** Extended, Replaced and Additional Control Directives
4188
4189`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHD'
4190`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHX'
4191`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHO'
4192`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHB'
4193`~N,MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHR'
4194 COMMAWIDTH is the number of characters between two comma
4195 characters.
4196
4197`~I'
4198 print a R4RS complex number as `~F~@Fi' with passed parameters for
4199 `~F'.
4200
4201`~Y'
4202 Pretty print formatting of an argument for scheme code lists.
4203
4204`~K'
4205 Same as `~?.'
4206
4207`~!'
4208 Flushes the output if format DESTINATION is a port.
4209
4210`~_'
4211 Print a `#\space' character
4212 `~N_'
4213 print N `#\space' characters.
4214
4215`~/'
4216 Print a `#\tab' character
4217 `~N/'
4218 print N `#\tab' characters.
4219
4220`~NC'
4221 Takes N as an integer representation for a character. No arguments
4222 are consumed. N is converted to a character by `integer->char'. N
4223 must be a positive decimal number.
4224
4225`~:S'
4226 Print out readproof. Prints out internal objects represented as
4227 `#<...>' as strings `"#<...>"' so that the format output can always
4228 be processed by `read'.
4229
4230`~:A'
4231 Print out readproof. Prints out internal objects represented as
4232 `#<...>' as strings `"#<...>"' so that the format output can always
4233 be processed by `read'.
4234
4235`~Q'
4236 Prints information and a copyright notice on the format
4237 implementation.
4238 `~:Q'
4239 prints format version.
4240
4241`~F, ~E, ~G, ~$'
4242 may also print number strings, i.e. passing a number as a string
4243 and format it accordingly.
4244
4245*** Configuration Variables
4246
4247 The format module exports some configuration variables to suit the
4248systems and users needs. There should be no modification necessary for
4249the configuration that comes with Guile. Format detects automatically
4250if the running scheme system implements floating point numbers and
4251complex numbers.
4252
4253format:symbol-case-conv
4254 Symbols are converted by `symbol->string' so the case type of the
4255 printed symbols is implementation dependent.
4256 `format:symbol-case-conv' is a one arg closure which is either
4257 `#f' (no conversion), `string-upcase', `string-downcase' or
4258 `string-capitalize'. (default `#f')
4259
4260format:iobj-case-conv
4261 As FORMAT:SYMBOL-CASE-CONV but applies for the representation of
4262 implementation internal objects. (default `#f')
4263
4264format:expch
4265 The character prefixing the exponent value in `~E' printing.
4266 (default `#\E')
4267
4268*** Compatibility With Other Format Implementations
4269
4270SLIB format 2.x:
4271 See `format.doc'.
4272
4273SLIB format 1.4:
4274 Downward compatible except for padding support and `~A', `~S',
4275 `~P', `~X' uppercase printing. SLIB format 1.4 uses C-style
4276 `printf' padding support which is completely replaced by the CL
4277 `format' padding style.
4278
4279MIT C-Scheme 7.1:
4280 Downward compatible except for `~', which is not documented
4281 (ignores all characters inside the format string up to a newline
4282 character). (7.1 implements `~a', `~s', ~NEWLINE, `~~', `~%',
4283 numerical and variable parameters and `:/@' modifiers in the CL
4284 sense).
4285
4286Elk 1.5/2.0:
4287 Downward compatible except for `~A' and `~S' which print in
4288 uppercase. (Elk implements `~a', `~s', `~~', and `~%' (no
4289 directive parameters or modifiers)).
4290
4291Scheme->C 01nov91:
4292 Downward compatible except for an optional destination parameter:
4293 S2C accepts a format call without a destination which returns a
4294 formatted string. This is equivalent to a #f destination in S2C.
4295 (S2C implements `~a', `~s', `~c', `~%', and `~~' (no directive
4296 parameters or modifiers)).
4297
4298
e7d37b0a 4299** Changes to string-handling functions.
b7e13f65 4300
e7d37b0a 4301These functions were added to support the (ice-9 format) module, above.
b7e13f65 4302
e7d37b0a
JB
4303*** New function: string-upcase STRING
4304*** New function: string-downcase STRING
b7e13f65 4305
e7d37b0a
JB
4306These are non-destructive versions of the existing string-upcase! and
4307string-downcase! functions.
b7e13f65 4308
e7d37b0a
JB
4309*** New function: string-capitalize! STRING
4310*** New function: string-capitalize STRING
4311
4312These functions convert the first letter of each word in the string to
4313upper case. Thus:
4314
4315 (string-capitalize "howdy there")
4316 => "Howdy There"
4317
4318As with the other functions, string-capitalize! modifies the string in
4319place, while string-capitalize returns a modified copy of its argument.
4320
4321*** New function: string-ci->symbol STRING
4322
4323Return a symbol whose name is STRING, but having the same case as if
4324the symbol had be read by `read'.
4325
4326Guile can be configured to be sensitive or insensitive to case
4327differences in Scheme identifiers. If Guile is case-insensitive, all
4328symbols are converted to lower case on input. The `string-ci->symbol'
4329function returns a symbol whose name in STRING, transformed as Guile
4330would if STRING were input.
4331
4332*** New function: substring-move! STRING1 START END STRING2 START
4333
4334Copy the substring of STRING1 from START (inclusive) to END
4335(exclusive) to STRING2 at START. STRING1 and STRING2 may be the same
4336string, and the source and destination areas may overlap; in all
4337cases, the function behaves as if all the characters were copied
4338simultanously.
4339
6c0201ad 4340*** Extended functions: substring-move-left! substring-move-right!
e7d37b0a
JB
4341
4342These functions now correctly copy arbitrarily overlapping substrings;
4343they are both synonyms for substring-move!.
b7e13f65 4344
b7e13f65 4345
deaceb4e
JB
4346** New module (ice-9 getopt-long), with the function `getopt-long'.
4347
4348getopt-long is a function for parsing command-line arguments in a
4349manner consistent with other GNU programs.
4350
4351(getopt-long ARGS GRAMMAR)
4352Parse the arguments ARGS according to the argument list grammar GRAMMAR.
4353
4354ARGS should be a list of strings. Its first element should be the
4355name of the program; subsequent elements should be the arguments
4356that were passed to the program on the command line. The
4357`program-arguments' procedure returns a list of this form.
4358
4359GRAMMAR is a list of the form:
4360((OPTION (PROPERTY VALUE) ...) ...)
4361
4362Each OPTION should be a symbol. `getopt-long' will accept a
4363command-line option named `--OPTION'.
4364Each option can have the following (PROPERTY VALUE) pairs:
4365
4366 (single-char CHAR) --- Accept `-CHAR' as a single-character
4367 equivalent to `--OPTION'. This is how to specify traditional
4368 Unix-style flags.
4369 (required? BOOL) --- If BOOL is true, the option is required.
4370 getopt-long will raise an error if it is not found in ARGS.
4371 (value BOOL) --- If BOOL is #t, the option accepts a value; if
4372 it is #f, it does not; and if it is the symbol
4373 `optional', the option may appear in ARGS with or
6c0201ad 4374 without a value.
deaceb4e
JB
4375 (predicate FUNC) --- If the option accepts a value (i.e. you
4376 specified `(value #t)' for this option), then getopt
4377 will apply FUNC to the value, and throw an exception
4378 if it returns #f. FUNC should be a procedure which
4379 accepts a string and returns a boolean value; you may
4380 need to use quasiquotes to get it into GRAMMAR.
4381
4382The (PROPERTY VALUE) pairs may occur in any order, but each
4383property may occur only once. By default, options do not have
4384single-character equivalents, are not required, and do not take
4385values.
4386
4387In ARGS, single-character options may be combined, in the usual
4388Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option
4389accepts values, then it must be the last option in the
4390combination; the value is the next argument. So, for example, using
4391the following grammar:
4392 ((apples (single-char #\a))
4393 (blimps (single-char #\b) (value #t))
4394 (catalexis (single-char #\c) (value #t)))
4395the following argument lists would be acceptable:
4396 ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values
4397 for "blimps" and "catalexis")
4398 ("-ab" "bang" "-c" "couth") (same)
4399 ("-ac" "couth" "-b" "bang") (same)
4400 ("-abc" "couth" "bang") (an error, since `-b' is not the
4401 last option in its combination)
4402
4403If an option's value is optional, then `getopt-long' decides
4404whether it has a value by looking at what follows it in ARGS. If
4405the next element is a string, and it does not appear to be an
4406option itself, then that string is the option's value.
4407
4408The value of a long option can appear as the next element in ARGS,
4409or it can follow the option name, separated by an `=' character.
4410Thus, using the same grammar as above, the following argument lists
4411are equivalent:
4412 ("--apples" "Braeburn" "--blimps" "Goodyear")
4413 ("--apples=Braeburn" "--blimps" "Goodyear")
4414 ("--blimps" "Goodyear" "--apples=Braeburn")
4415
4416If the option "--" appears in ARGS, argument parsing stops there;
4417subsequent arguments are returned as ordinary arguments, even if
4418they resemble options. So, in the argument list:
4419 ("--apples" "Granny Smith" "--" "--blimp" "Goodyear")
4420`getopt-long' will recognize the `apples' option as having the
4421value "Granny Smith", but it will not recognize the `blimp'
4422option; it will return the strings "--blimp" and "Goodyear" as
4423ordinary argument strings.
4424
4425The `getopt-long' function returns the parsed argument list as an
4426assocation list, mapping option names --- the symbols from GRAMMAR
4427--- onto their values, or #t if the option does not accept a value.
4428Unused options do not appear in the alist.
4429
4430All arguments that are not the value of any option are returned
4431as a list, associated with the empty list.
4432
4433`getopt-long' throws an exception if:
4434- it finds an unrecognized option in ARGS
4435- a required option is omitted
4436- an option that requires an argument doesn't get one
4437- an option that doesn't accept an argument does get one (this can
4438 only happen using the long option `--opt=value' syntax)
4439- an option predicate fails
4440
4441So, for example:
4442
4443(define grammar
4444 `((lockfile-dir (required? #t)
4445 (value #t)
4446 (single-char #\k)
4447 (predicate ,file-is-directory?))
4448 (verbose (required? #f)
4449 (single-char #\v)
4450 (value #f))
4451 (x-includes (single-char #\x))
6c0201ad 4452 (rnet-server (single-char #\y)
deaceb4e
JB
4453 (predicate ,string?))))
4454
6c0201ad 4455(getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include"
deaceb4e
JB
4456 "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3")
4457 grammar)
4458=> ((() "foo1" "-fred" "foo2" "foo3")
4459 (rnet-server . "lamprod")
4460 (x-includes . "/usr/include")
4461 (lockfile-dir . "/tmp")
4462 (verbose . #t))
4463
4464** The (ice-9 getopt-gnu-style) module is obsolete; use (ice-9 getopt-long).
4465
4466It will be removed in a few releases.
4467
08394899
MS
4468** New syntax: lambda*
4469** New syntax: define*
6c0201ad 4470** New syntax: define*-public
08394899
MS
4471** New syntax: defmacro*
4472** New syntax: defmacro*-public
6c0201ad 4473Guile now supports optional arguments.
08394899
MS
4474
4475`lambda*', `define*', `define*-public', `defmacro*' and
4476`defmacro*-public' are identical to the non-* versions except that
4477they use an extended type of parameter list that has the following BNF
4478syntax (parentheses are literal, square brackets indicate grouping,
4479and `*', `+' and `?' have the usual meaning):
4480
4481 ext-param-list ::= ( [identifier]* [#&optional [ext-var-decl]+]?
6c0201ad 4482 [#&key [ext-var-decl]+ [#&allow-other-keys]?]?
08394899
MS
4483 [[#&rest identifier]|[. identifier]]? ) | [identifier]
4484
6c0201ad 4485 ext-var-decl ::= identifier | ( identifier expression )
08394899
MS
4486
4487The semantics are best illustrated with the following documentation
4488and examples for `lambda*':
4489
4490 lambda* args . body
4491 lambda extended for optional and keyword arguments
6c0201ad 4492
08394899
MS
4493 lambda* creates a procedure that takes optional arguments. These
4494 are specified by putting them inside brackets at the end of the
4495 paramater list, but before any dotted rest argument. For example,
4496 (lambda* (a b #&optional c d . e) '())
4497 creates a procedure with fixed arguments a and b, optional arguments c
4498 and d, and rest argument e. If the optional arguments are omitted
4499 in a call, the variables for them are unbound in the procedure. This
4500 can be checked with the bound? macro.
4501
4502 lambda* can also take keyword arguments. For example, a procedure
4503 defined like this:
4504 (lambda* (#&key xyzzy larch) '())
4505 can be called with any of the argument lists (#:xyzzy 11)
4506 (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments
4507 are given as keywords are bound to values.
4508
4509 Optional and keyword arguments can also be given default values
4510 which they take on when they are not present in a call, by giving a
4511 two-item list in place of an optional argument, for example in:
6c0201ad 4512 (lambda* (foo #&optional (bar 42) #&key (baz 73)) (list foo bar baz))
08394899
MS
4513 foo is a fixed argument, bar is an optional argument with default
4514 value 42, and baz is a keyword argument with default value 73.
4515 Default value expressions are not evaluated unless they are needed
6c0201ad 4516 and until the procedure is called.
08394899
MS
4517
4518 lambda* now supports two more special parameter list keywords.
4519
4520 lambda*-defined procedures now throw an error by default if a
4521 keyword other than one of those specified is found in the actual
4522 passed arguments. However, specifying #&allow-other-keys
4523 immediately after the kyword argument declarations restores the
4524 previous behavior of ignoring unknown keywords. lambda* also now
4525 guarantees that if the same keyword is passed more than once, the
4526 last one passed is the one that takes effect. For example,
4527 ((lambda* (#&key (heads 0) (tails 0)) (display (list heads tails)))
4528 #:heads 37 #:tails 42 #:heads 99)
4529 would result in (99 47) being displayed.
4530
4531 #&rest is also now provided as a synonym for the dotted syntax rest
4532 argument. The argument lists (a . b) and (a #&rest b) are equivalent in
4533 all respects to lambda*. This is provided for more similarity to DSSSL,
4534 MIT-Scheme and Kawa among others, as well as for refugees from other
4535 Lisp dialects.
4536
4537Further documentation may be found in the optargs.scm file itself.
4538
4539The optional argument module also exports the macros `let-optional',
4540`let-optional*', `let-keywords', `let-keywords*' and `bound?'. These
4541are not documented here because they may be removed in the future, but
4542full documentation is still available in optargs.scm.
4543
2e132553
JB
4544** New syntax: and-let*
4545Guile now supports the `and-let*' form, described in the draft SRFI-2.
4546
4547Syntax: (land* (<clause> ...) <body> ...)
4548Each <clause> should have one of the following forms:
4549 (<variable> <expression>)
4550 (<expression>)
4551 <bound-variable>
4552Each <variable> or <bound-variable> should be an identifier. Each
4553<expression> should be a valid expression. The <body> should be a
4554possibly empty sequence of expressions, like the <body> of a
4555lambda form.
4556
4557Semantics: A LAND* expression is evaluated by evaluating the
4558<expression> or <bound-variable> of each of the <clause>s from
4559left to right. The value of the first <expression> or
4560<bound-variable> that evaluates to a false value is returned; the
4561remaining <expression>s and <bound-variable>s are not evaluated.
4562The <body> forms are evaluated iff all the <expression>s and
4563<bound-variable>s evaluate to true values.
4564
4565The <expression>s and the <body> are evaluated in an environment
4566binding each <variable> of the preceding (<variable> <expression>)
4567clauses to the value of the <expression>. Later bindings
4568shadow earlier bindings.
4569
4570Guile's and-let* macro was contributed by Michael Livshin.
4571
36d3d540
MD
4572** New sorting functions
4573
4574*** New function: sorted? SEQUENCE LESS?
ed8c8636
MD
4575Returns `#t' when the sequence argument is in non-decreasing order
4576according to LESS? (that is, there is no adjacent pair `... x y
4577...' for which `(less? y x)').
4578
4579Returns `#f' when the sequence contains at least one out-of-order
4580pair. It is an error if the sequence is neither a list nor a
4581vector.
4582
36d3d540 4583*** New function: merge LIST1 LIST2 LESS?
ed8c8636
MD
4584LIST1 and LIST2 are sorted lists.
4585Returns the sorted list of all elements in LIST1 and LIST2.
4586
4587Assume that the elements a and b1 in LIST1 and b2 in LIST2 are "equal"
4588in the sense that (LESS? x y) --> #f for x, y in {a, b1, b2},
4589and that a < b1 in LIST1. Then a < b1 < b2 in the result.
4590(Here "<" should read "comes before".)
4591
36d3d540 4592*** New procedure: merge! LIST1 LIST2 LESS?
ed8c8636
MD
4593Merges two lists, re-using the pairs of LIST1 and LIST2 to build
4594the result. If the code is compiled, and LESS? constructs no new
4595pairs, no pairs at all will be allocated. The first pair of the
4596result will be either the first pair of LIST1 or the first pair of
4597LIST2.
4598
36d3d540 4599*** New function: sort SEQUENCE LESS?
ed8c8636
MD
4600Accepts either a list or a vector, and returns a new sequence
4601which is sorted. The new sequence is the same type as the input.
4602Always `(sorted? (sort sequence less?) less?)'. The original
4603sequence is not altered in any way. The new sequence shares its
4604elements with the old one; no elements are copied.
4605
36d3d540 4606*** New procedure: sort! SEQUENCE LESS
ed8c8636
MD
4607Returns its sorted result in the original boxes. No new storage is
4608allocated at all. Proper usage: (set! slist (sort! slist <))
4609
36d3d540 4610*** New function: stable-sort SEQUENCE LESS?
ed8c8636
MD
4611Similar to `sort' but stable. That is, if "equal" elements are
4612ordered a < b in the original sequence, they will have the same order
4613in the result.
4614
36d3d540 4615*** New function: stable-sort! SEQUENCE LESS?
ed8c8636
MD
4616Similar to `sort!' but stable.
4617Uses temporary storage when sorting vectors.
4618
36d3d540 4619*** New functions: sort-list, sort-list!
ed8c8636
MD
4620Added for compatibility with scsh.
4621
36d3d540
MD
4622** New built-in random number support
4623
4624*** New function: random N [STATE]
3e8370c3
MD
4625Accepts a positive integer or real N and returns a number of the
4626same type between zero (inclusive) and N (exclusive). The values
4627returned have a uniform distribution.
4628
4629The optional argument STATE must be of the type produced by
416075f1
MD
4630`copy-random-state' or `seed->random-state'. It defaults to the value
4631of the variable `*random-state*'. This object is used to maintain the
4632state of the pseudo-random-number generator and is altered as a side
4633effect of the `random' operation.
3e8370c3 4634
36d3d540 4635*** New variable: *random-state*
3e8370c3
MD
4636Holds a data structure that encodes the internal state of the
4637random-number generator that `random' uses by default. The nature
4638of this data structure is implementation-dependent. It may be
4639printed out and successfully read back in, but may or may not
4640function correctly as a random-number state object in another
4641implementation.
4642
36d3d540 4643*** New function: copy-random-state [STATE]
3e8370c3
MD
4644Returns a new object of type suitable for use as the value of the
4645variable `*random-state*' and as a second argument to `random'.
4646If argument STATE is given, a copy of it is returned. Otherwise a
4647copy of `*random-state*' is returned.
416075f1 4648
36d3d540 4649*** New function: seed->random-state SEED
416075f1
MD
4650Returns a new object of type suitable for use as the value of the
4651variable `*random-state*' and as a second argument to `random'.
4652SEED is a string or a number. A new state is generated and
4653initialized using SEED.
3e8370c3 4654
36d3d540 4655*** New function: random:uniform [STATE]
3e8370c3
MD
4656Returns an uniformly distributed inexact real random number in the
4657range between 0 and 1.
4658
36d3d540 4659*** New procedure: random:solid-sphere! VECT [STATE]
3e8370c3
MD
4660Fills VECT with inexact real random numbers the sum of whose
4661squares is less than 1.0. Thinking of VECT as coordinates in
4662space of dimension N = `(vector-length VECT)', the coordinates are
4663uniformly distributed within the unit N-shere. The sum of the
4664squares of the numbers is returned. VECT can be either a vector
4665or a uniform vector of doubles.
4666
36d3d540 4667*** New procedure: random:hollow-sphere! VECT [STATE]
3e8370c3
MD
4668Fills VECT with inexact real random numbers the sum of whose squares
4669is equal to 1.0. Thinking of VECT as coordinates in space of
4670dimension n = `(vector-length VECT)', the coordinates are uniformly
4671distributed over the surface of the unit n-shere. VECT can be either
4672a vector or a uniform vector of doubles.
4673
36d3d540 4674*** New function: random:normal [STATE]
3e8370c3
MD
4675Returns an inexact real in a normal distribution with mean 0 and
4676standard deviation 1. For a normal distribution with mean M and
4677standard deviation D use `(+ M (* D (random:normal)))'.
4678
36d3d540 4679*** New procedure: random:normal-vector! VECT [STATE]
3e8370c3
MD
4680Fills VECT with inexact real random numbers which are independent and
4681standard normally distributed (i.e., with mean 0 and variance 1).
4682VECT can be either a vector or a uniform vector of doubles.
4683
36d3d540 4684*** New function: random:exp STATE
3e8370c3
MD
4685Returns an inexact real in an exponential distribution with mean 1.
4686For an exponential distribution with mean U use (* U (random:exp)).
4687
69c6acbb
JB
4688** The range of logand, logior, logxor, logtest, and logbit? have changed.
4689
4690These functions now operate on numbers in the range of a C unsigned
4691long.
4692
4693These functions used to operate on numbers in the range of a C signed
4694long; however, this seems inappropriate, because Guile integers don't
4695overflow.
4696
ba4ee0d6
MD
4697** New function: make-guardian
4698This is an implementation of guardians as described in
4699R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a
4700Generation-Based Garbage Collector" ACM SIGPLAN Conference on
4701Programming Language Design and Implementation, June 1993
4702ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz
4703
88ceea5c
MD
4704** New functions: delq1!, delv1!, delete1!
4705These procedures behave similar to delq! and friends but delete only
4706one object if at all.
4707
55254a6a
MD
4708** New function: unread-string STRING PORT
4709Unread STRING to PORT, that is, push it back onto the port so that
4710next read operation will work on the pushed back characters.
4711
4712** unread-char can now be called multiple times
4713If unread-char is called multiple times, the unread characters will be
4714read again in last-in first-out order.
4715
9e97c52d
GH
4716** the procedures uniform-array-read! and uniform-array-write! now
4717work on any kind of port, not just ports which are open on a file.
4718
b074884f 4719** Now 'l' in a port mode requests line buffering.
9e97c52d 4720
69bc9ff3
GH
4721** The procedure truncate-file now works on string ports as well
4722as file ports. If the size argument is omitted, the current
1b9c3dae 4723file position is used.
9e97c52d 4724
c94577b4 4725** new procedure: seek PORT/FDES OFFSET WHENCE
9e97c52d
GH
4726The arguments are the same as for the old fseek procedure, but it
4727works on string ports as well as random-access file ports.
4728
4729** the fseek procedure now works on string ports, since it has been
c94577b4 4730redefined using seek.
9e97c52d
GH
4731
4732** the setvbuf procedure now uses a default size if mode is _IOFBF and
4733size is not supplied.
4734
4735** the newline procedure no longer flushes the port if it's not
4736line-buffered: previously it did if it was the current output port.
4737
4738** open-pipe and close-pipe are no longer primitive procedures, but
4739an emulation can be obtained using `(use-modules (ice-9 popen))'.
4740
4741** the freopen procedure has been removed.
4742
4743** new procedure: drain-input PORT
4744Drains PORT's read buffers (including any pushed-back characters)
4745and returns the contents as a single string.
4746
67ad463a 4747** New function: map-in-order PROC LIST1 LIST2 ...
d41b3904
MD
4748Version of `map' which guarantees that the procedure is applied to the
4749lists in serial order.
4750
67ad463a
MD
4751** Renamed `serial-array-copy!' and `serial-array-map!' to
4752`array-copy-in-order!' and `array-map-in-order!'. The old names are
4753now obsolete and will go away in release 1.5.
4754
cf7132b3 4755** New syntax: collect BODY1 ...
d41b3904
MD
4756Version of `begin' which returns a list of the results of the body
4757forms instead of the result of the last body form. In contrast to
cf7132b3 4758`begin', `collect' allows an empty body.
d41b3904 4759
e4eae9b1
MD
4760** New functions: read-history FILENAME, write-history FILENAME
4761Read/write command line history from/to file. Returns #t on success
4762and #f if an error occured.
4763
d21ffe26
JB
4764** `ls' and `lls' in module (ice-9 ls) now handle no arguments.
4765
4766These procedures return a list of definitions available in the specified
4767argument, a relative module reference. In the case of no argument,
4768`(current-module)' is now consulted for definitions to return, instead
4769of simply returning #f, the former behavior.
4770
f8c9d497
JB
4771** The #/ syntax for lists is no longer supported.
4772
4773Earlier versions of Scheme accepted this syntax, but printed a
4774warning.
4775
4776** Guile no longer consults the SCHEME_LOAD_PATH environment variable.
4777
4778Instead, you should set GUILE_LOAD_PATH to tell Guile where to find
4779modules.
4780
3ffc7a36
MD
4781* Changes to the gh_ interface
4782
4783** gh_scm2doubles
4784
4785Now takes a second argument which is the result array. If this
4786pointer is NULL, a new array is malloced (the old behaviour).
4787
4788** gh_chars2byvect, gh_shorts2svect, gh_floats2fvect, gh_scm2chars,
4789 gh_scm2shorts, gh_scm2longs, gh_scm2floats
4790
4791New functions.
4792
3e8370c3
MD
4793* Changes to the scm_ interface
4794
ad91d6c3
MD
4795** Function: scm_make_named_hook (char* name, int n_args)
4796
4797Creates a hook in the same way as make-hook above but also
4798binds a variable named NAME to it.
4799
4800This is the typical way of creating a hook from C code.
4801
ece41168
MD
4802Currently, the variable is created in the "current" module. This
4803might change when we get the new module system.
ad91d6c3 4804
16a5a9a4
MD
4805** The smob interface
4806
4807The interface for creating smobs has changed. For documentation, see
4808data-rep.info (made from guile-core/doc/data-rep.texi).
4809
4810*** Deprecated function: SCM scm_newsmob (scm_smobfuns *)
4811
4812>>> This function will be removed in 1.3.4. <<<
4813
4814It is replaced by:
4815
4816*** Function: SCM scm_make_smob_type (const char *name, scm_sizet size)
4817This function adds a new smob type, named NAME, with instance size
4818SIZE to the system. The return value is a tag that is used in
4819creating instances of the type. If SIZE is 0, then no memory will
4820be allocated when instances of the smob are created, and nothing
4821will be freed by the default free function.
6c0201ad 4822
16a5a9a4
MD
4823*** Function: void scm_set_smob_mark (long tc, SCM (*mark) (SCM))
4824This function sets the smob marking procedure for the smob type
4825specified by the tag TC. TC is the tag returned by
4826`scm_make_smob_type'.
4827
4828*** Function: void scm_set_smob_free (long tc, SCM (*mark) (SCM))
4829This function sets the smob freeing procedure for the smob type
4830specified by the tag TC. TC is the tag returned by
4831`scm_make_smob_type'.
4832
4833*** Function: void scm_set_smob_print (tc, print)
4834
4835 - Function: void scm_set_smob_print (long tc,
4836 scm_sizet (*print) (SCM,
4837 SCM,
4838 scm_print_state *))
4839
4840This function sets the smob printing procedure for the smob type
4841specified by the tag TC. TC is the tag returned by
4842`scm_make_smob_type'.
4843
4844*** Function: void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM))
4845This function sets the smob equality-testing predicate for the
4846smob type specified by the tag TC. TC is the tag returned by
4847`scm_make_smob_type'.
4848
4849*** Macro: void SCM_NEWSMOB (SCM var, long tc, void *data)
4850Make VALUE contain a smob instance of the type with type code TC and
4851smob data DATA. VALUE must be previously declared as C type `SCM'.
4852
4853*** Macro: fn_returns SCM_RETURN_NEWSMOB (long tc, void *data)
4854This macro expands to a block of code that creates a smob instance
4855of the type with type code TC and smob data DATA, and returns that
4856`SCM' value. It should be the last piece of code in a block.
4857
9e97c52d
GH
4858** The interfaces for using I/O ports and implementing port types
4859(ptobs) have changed significantly. The new interface is based on
4860shared access to buffers and a new set of ptob procedures.
4861
16a5a9a4
MD
4862*** scm_newptob has been removed
4863
4864It is replaced by:
4865
4866*** Function: SCM scm_make_port_type (type_name, fill_buffer, write_flush)
4867
4868- Function: SCM scm_make_port_type (char *type_name,
4869 int (*fill_buffer) (SCM port),
4870 void (*write_flush) (SCM port));
4871
4872Similarly to the new smob interface, there is a set of function
4873setters by which the user can customize the behaviour of his port
544e9093 4874type. See ports.h (scm_set_port_XXX).
16a5a9a4 4875
9e97c52d
GH
4876** scm_strport_to_string: New function: creates a new string from
4877a string port's buffer.
4878
3e8370c3
MD
4879** Plug in interface for random number generators
4880The variable `scm_the_rng' in random.c contains a value and three
4881function pointers which together define the current random number
4882generator being used by the Scheme level interface and the random
4883number library functions.
4884
4885The user is free to replace the default generator with the generator
4886of his own choice.
4887
4888*** Variable: size_t scm_the_rng.rstate_size
4889The size of the random state type used by the current RNG
4890measured in chars.
4891
4892*** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE)
4893Given the random STATE, return 32 random bits.
4894
4895*** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N)
4896Seed random state STATE using string S of length N.
4897
4898*** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE)
4899Given random state STATE, return a malloced copy.
4900
4901** Default RNG
4902The default RNG is the MWC (Multiply With Carry) random number
4903generator described by George Marsaglia at the Department of
4904Statistics and Supercomputer Computations Research Institute, The
4905Florida State University (http://stat.fsu.edu/~geo).
4906
4907It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and
4908passes all tests in the DIEHARD test suite
4909(http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits
4910costs one multiply and one add on platforms which either supports long
4911longs (gcc does this on most systems) or have 64 bit longs. The cost
4912is four multiply on other systems but this can be optimized by writing
4913scm_i_uniform32 in assembler.
4914
4915These functions are provided through the scm_the_rng interface for use
4916by libguile and the application.
4917
4918*** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE)
4919Given the random STATE, return 32 random bits.
4920Don't use this function directly. Instead go through the plugin
4921interface (see "Plug in interface" above).
4922
4923*** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N)
4924Initialize STATE using SEED of length N.
4925
4926*** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE)
4927Return a malloc:ed copy of STATE. This function can easily be re-used
4928in the interfaces to other RNGs.
4929
4930** Random number library functions
4931These functions use the current RNG through the scm_the_rng interface.
4932It might be a good idea to use these functions from your C code so
4933that only one random generator is used by all code in your program.
4934
259529f2 4935The default random state is stored in:
3e8370c3
MD
4936
4937*** Variable: SCM scm_var_random_state
4938Contains the vcell of the Scheme variable "*random-state*" which is
4939used as default state by all random number functions in the Scheme
4940level interface.
4941
4942Example:
4943
259529f2 4944 double x = scm_c_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state)));
3e8370c3 4945
259529f2
MD
4946*** Function: scm_rstate *scm_c_default_rstate (void)
4947This is a convenience function which returns the value of
4948scm_var_random_state. An error message is generated if this value
4949isn't a random state.
4950
4951*** Function: scm_rstate *scm_c_make_rstate (char *SEED, int LENGTH)
4952Make a new random state from the string SEED of length LENGTH.
4953
4954It is generally not a good idea to use multiple random states in a
4955program. While subsequent random numbers generated from one random
4956state are guaranteed to be reasonably independent, there is no such
4957guarantee for numbers generated from different random states.
4958
4959*** Macro: unsigned long scm_c_uniform32 (scm_rstate *STATE)
4960Return 32 random bits.
4961
4962*** Function: double scm_c_uniform01 (scm_rstate *STATE)
3e8370c3
MD
4963Return a sample from the uniform(0,1) distribution.
4964
259529f2 4965*** Function: double scm_c_normal01 (scm_rstate *STATE)
3e8370c3
MD
4966Return a sample from the normal(0,1) distribution.
4967
259529f2 4968*** Function: double scm_c_exp1 (scm_rstate *STATE)
3e8370c3
MD
4969Return a sample from the exp(1) distribution.
4970
259529f2
MD
4971*** Function: unsigned long scm_c_random (scm_rstate *STATE, unsigned long M)
4972Return a sample from the discrete uniform(0,M) distribution.
4973
4974*** Function: SCM scm_c_random_bignum (scm_rstate *STATE, SCM M)
3e8370c3 4975Return a sample from the discrete uniform(0,M) distribution.
259529f2 4976M must be a bignum object. The returned value may be an INUM.
3e8370c3 4977
9e97c52d 4978
f3227c7a 4979\f
d23bbf3e 4980Changes in Guile 1.3 (released Monday, October 19, 1998):
c484bf7f
JB
4981
4982* Changes to the distribution
4983
e2d6569c
JB
4984** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
4985To avoid conflicts, programs should name environment variables after
4986themselves, except when there's a common practice establishing some
4987other convention.
4988
4989For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
4990giving the former precedence, and printing a warning message if the
4991latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
4992
4993** The header files related to multi-byte characters have been removed.
4994They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
4995which referred to these explicitly will probably need to be rewritten,
4996since the support for the variant string types has been removed; see
4997below.
4998
4999** The header files append.h and sequences.h have been removed. These
5000files implemented non-R4RS operations which would encourage
5001non-portable programming style and less easy-to-read code.
3a97e020 5002
c484bf7f
JB
5003* Changes to the stand-alone interpreter
5004
2e368582 5005** New procedures have been added to implement a "batch mode":
ec4ab4fd 5006
2e368582 5007*** Function: batch-mode?
ec4ab4fd
GH
5008
5009 Returns a boolean indicating whether the interpreter is in batch
5010 mode.
5011
2e368582 5012*** Function: set-batch-mode?! ARG
ec4ab4fd
GH
5013
5014 If ARG is true, switches the interpreter to batch mode. The `#f'
5015 case has not been implemented.
5016
2e368582
JB
5017** Guile now provides full command-line editing, when run interactively.
5018To use this feature, you must have the readline library installed.
5019The Guile build process will notice it, and automatically include
5020support for it.
5021
5022The readline library is available via anonymous FTP from any GNU
5023mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
5024
a5d6d578
MD
5025** the-last-stack is now a fluid.
5026
c484bf7f
JB
5027* Changes to the procedure for linking libguile with your programs
5028
71f20534 5029** You can now use the `guile-config' utility to build programs that use Guile.
2e368582 5030
2adfe1c0 5031Guile now includes a command-line utility called `guile-config', which
71f20534
JB
5032can provide information about how to compile and link programs that
5033use Guile.
5034
5035*** `guile-config compile' prints any C compiler flags needed to use Guile.
5036You should include this command's output on the command line you use
5037to compile C or C++ code that #includes the Guile header files. It's
5038usually just a `-I' flag to help the compiler find the Guile headers.
5039
5040
5041*** `guile-config link' prints any linker flags necessary to link with Guile.
8aa5c148 5042
71f20534 5043This command writes to its standard output a list of flags which you
8aa5c148
JB
5044must pass to the linker to link your code against the Guile library.
5045The flags include '-lguile' itself, any other libraries the Guile
5046library depends upon, and any `-L' flags needed to help the linker
5047find those libraries.
2e368582
JB
5048
5049For example, here is a Makefile rule that builds a program named 'foo'
5050from the object files ${FOO_OBJECTS}, and links them against Guile:
5051
5052 foo: ${FOO_OBJECTS}
2adfe1c0 5053 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
2e368582 5054
e2d6569c
JB
5055Previous Guile releases recommended that you use autoconf to detect
5056which of a predefined set of libraries were present on your system.
2adfe1c0 5057It is more robust to use `guile-config', since it records exactly which
e2d6569c
JB
5058libraries the installed Guile library requires.
5059
2adfe1c0
JB
5060This was originally called `build-guile', but was renamed to
5061`guile-config' before Guile 1.3 was released, to be consistent with
5062the analogous script for the GTK+ GUI toolkit, which is called
5063`gtk-config'.
5064
2e368582 5065
8aa5c148
JB
5066** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
5067
5068If you are using the GNU autoconf package to configure your program,
5069you can use the GUILE_FLAGS autoconf macro to call `guile-config'
5070(described above) and gather the necessary values for use in your
5071Makefiles.
5072
5073The GUILE_FLAGS macro expands to configure script code which runs the
5074`guile-config' script, to find out where Guile's header files and
5075libraries are installed. It sets two variables, marked for
5076substitution, as by AC_SUBST.
5077
5078 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
5079 code that uses Guile header files. This is almost always just a
5080 -I flag.
5081
5082 GUILE_LDFLAGS --- flags to pass to the linker to link a
5083 program against Guile. This includes `-lguile' for the Guile
5084 library itself, any libraries that Guile itself requires (like
5085 -lqthreads), and so on. It may also include a -L flag to tell the
5086 compiler where to find the libraries.
5087
5088GUILE_FLAGS is defined in the file guile.m4, in the top-level
5089directory of the Guile distribution. You can copy it into your
5090package's aclocal.m4 file, and then use it in your configure.in file.
5091
5092If you are using the `aclocal' program, distributed with GNU automake,
5093to maintain your aclocal.m4 file, the Guile installation process
5094installs guile.m4 where aclocal will find it. All you need to do is
5095use GUILE_FLAGS in your configure.in file, and then run `aclocal';
5096this will copy the definition of GUILE_FLAGS into your aclocal.m4
5097file.
5098
5099
c484bf7f 5100* Changes to Scheme functions and syntax
7ad3c1e7 5101
02755d59 5102** Multi-byte strings have been removed, as have multi-byte and wide
e2d6569c
JB
5103ports. We felt that these were the wrong approach to
5104internationalization support.
02755d59 5105
2e368582
JB
5106** New function: readline [PROMPT]
5107Read a line from the terminal, and allow the user to edit it,
5108prompting with PROMPT. READLINE provides a large set of Emacs-like
5109editing commands, lets the user recall previously typed lines, and
5110works on almost every kind of terminal, including dumb terminals.
5111
5112READLINE assumes that the cursor is at the beginning of the line when
5113it is invoked. Thus, you can't print a prompt yourself, and then call
5114READLINE; you need to package up your prompt as a string, pass it to
5115the function, and let READLINE print the prompt itself. This is
5116because READLINE needs to know the prompt's screen width.
5117
8cd57bd0
JB
5118For Guile to provide this function, you must have the readline
5119library, version 2.1 or later, installed on your system. Readline is
5120available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
5121any GNU mirror site.
2e368582
JB
5122
5123See also ADD-HISTORY function.
5124
5125** New function: add-history STRING
5126Add STRING as the most recent line in the history used by the READLINE
5127command. READLINE does not add lines to the history itself; you must
5128call ADD-HISTORY to make previous input available to the user.
5129
8cd57bd0
JB
5130** The behavior of the read-line function has changed.
5131
5132This function now uses standard C library functions to read the line,
5133for speed. This means that it doesn not respect the value of
5134scm-line-incrementors; it assumes that lines are delimited with
5135#\newline.
5136
5137(Note that this is read-line, the function that reads a line of text
5138from a port, not readline, the function that reads a line from a
5139terminal, providing full editing capabilities.)
5140
1a0106ef
JB
5141** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
5142
5143This module provides some simple argument parsing. It exports one
5144function:
5145
5146Function: getopt-gnu-style ARG-LS
5147 Parse a list of program arguments into an alist of option
5148 descriptions.
5149
5150 Each item in the list of program arguments is examined to see if
5151 it meets the syntax of a GNU long-named option. An argument like
5152 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
5153 returned alist, where MUMBLE is a keyword object with the same
5154 name as the argument. An argument like `--MUMBLE=FROB' produces
5155 an element of the form (MUMBLE . FROB), where FROB is a string.
5156
5157 As a special case, the returned alist also contains a pair whose
5158 car is the symbol `rest'. The cdr of this pair is a list
5159 containing all the items in the argument list that are not options
5160 of the form mentioned above.
5161
5162 The argument `--' is treated specially: all items in the argument
5163 list appearing after such an argument are not examined, and are
5164 returned in the special `rest' list.
5165
5166 This function does not parse normal single-character switches.
5167 You will need to parse them out of the `rest' list yourself.
5168
8cd57bd0
JB
5169** The read syntax for byte vectors and short vectors has changed.
5170
5171Instead of #bytes(...), write #y(...).
5172
5173Instead of #short(...), write #h(...).
5174
5175This may seem nutty, but, like the other uniform vectors, byte vectors
5176and short vectors want to have the same print and read syntax (and,
5177more basic, want to have read syntax!). Changing the read syntax to
5178use multiple characters after the hash sign breaks with the
5179conventions used in R5RS and the conventions used for the other
5180uniform vectors. It also introduces complexity in the current reader,
5181both on the C and Scheme levels. (The Right solution is probably to
5182change the syntax and prototypes for uniform vectors entirely.)
5183
5184
5185** The new module (ice-9 session) provides useful interactive functions.
5186
5187*** New procedure: (apropos REGEXP OPTION ...)
5188
5189Display a list of top-level variables whose names match REGEXP, and
5190the modules they are imported from. Each OPTION should be one of the
5191following symbols:
5192
5193 value --- Show the value of each matching variable.
5194 shadow --- Show bindings shadowed by subsequently imported modules.
5195 full --- Same as both `shadow' and `value'.
5196
5197For example:
5198
5199 guile> (apropos "trace" 'full)
5200 debug: trace #<procedure trace args>
5201 debug: untrace #<procedure untrace args>
5202 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
5203 the-scm-module: before-backtrace-hook ()
5204 the-scm-module: backtrace #<primitive-procedure backtrace>
5205 the-scm-module: after-backtrace-hook ()
5206 the-scm-module: has-shown-backtrace-hint? #f
6c0201ad 5207 guile>
8cd57bd0
JB
5208
5209** There are new functions and syntax for working with macros.
5210
5211Guile implements macros as a special object type. Any variable whose
5212top-level binding is a macro object acts as a macro. The macro object
5213specifies how the expression should be transformed before evaluation.
5214
5215*** Macro objects now print in a reasonable way, resembling procedures.
5216
5217*** New function: (macro? OBJ)
5218True iff OBJ is a macro object.
5219
5220*** New function: (primitive-macro? OBJ)
5221Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
5222macro transformers, implemented in eval.c rather than Scheme code.
5223
dbdd0c16
JB
5224Why do we have this function?
5225- For symmetry with procedure? and primitive-procedure?,
5226- to allow custom print procedures to tell whether a macro is
5227 primitive, and display it differently, and
5228- to allow compilers and user-written evaluators to distinguish
5229 builtin special forms from user-defined ones, which could be
5230 compiled.
5231
8cd57bd0
JB
5232*** New function: (macro-type OBJ)
5233Return a value indicating what kind of macro OBJ is. Possible return
5234values are:
5235
5236 The symbol `syntax' --- a macro created by procedure->syntax.
5237 The symbol `macro' --- a macro created by procedure->macro.
5238 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
6c0201ad 5239 The boolean #f --- if OBJ is not a macro object.
8cd57bd0
JB
5240
5241*** New function: (macro-name MACRO)
5242Return the name of the macro object MACRO's procedure, as returned by
5243procedure-name.
5244
5245*** New function: (macro-transformer MACRO)
5246Return the transformer procedure for MACRO.
5247
5248*** New syntax: (use-syntax MODULE ... TRANSFORMER)
5249
5250Specify a new macro expander to use in the current module. Each
5251MODULE is a module name, with the same meaning as in the `use-modules'
5252form; each named module's exported bindings are added to the current
5253top-level environment. TRANSFORMER is an expression evaluated in the
5254resulting environment which must yield a procedure to use as the
5255module's eval transformer: every expression evaluated in this module
5256is passed to this function, and the result passed to the Guile
6c0201ad 5257interpreter.
8cd57bd0
JB
5258
5259*** macro-eval! is removed. Use local-eval instead.
29521173 5260
8d9dcb3c
MV
5261** Some magic has been added to the printer to better handle user
5262written printing routines (like record printers, closure printers).
5263
5264The problem is that these user written routines must have access to
7fbd77df 5265the current `print-state' to be able to handle fancy things like
8d9dcb3c
MV
5266detection of circular references. These print-states have to be
5267passed to the builtin printing routines (display, write, etc) to
5268properly continue the print chain.
5269
5270We didn't want to change all existing print code so that it
8cd57bd0 5271explicitly passes thru a print state in addition to a port. Instead,
8d9dcb3c
MV
5272we extented the possible values that the builtin printing routines
5273accept as a `port'. In addition to a normal port, they now also take
5274a pair of a normal port and a print-state. Printing will go to the
5275port and the print-state will be used to control the detection of
5276circular references, etc. If the builtin function does not care for a
5277print-state, it is simply ignored.
5278
5279User written callbacks are now called with such a pair as their
5280`port', but because every function now accepts this pair as a PORT
5281argument, you don't have to worry about that. In fact, it is probably
5282safest to not check for these pairs.
5283
5284However, it is sometimes necessary to continue a print chain on a
5285different port, for example to get a intermediate string
5286representation of the printed value, mangle that string somehow, and
5287then to finally print the mangled string. Use the new function
5288
5289 inherit-print-state OLD-PORT NEW-PORT
5290
5291for this. It constructs a new `port' that prints to NEW-PORT but
5292inherits the print-state of OLD-PORT.
5293
ef1ea498
MD
5294** struct-vtable-offset renamed to vtable-offset-user
5295
5296** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
5297
e478dffa
MD
5298** There is now a third optional argument to make-vtable-vtable
5299 (and fourth to make-struct) when constructing new types (vtables).
5300 This argument initializes field vtable-index-printer of the vtable.
ef1ea498 5301
4851dc57
MV
5302** The detection of circular references has been extended to structs.
5303That is, a structure that -- in the process of being printed -- prints
5304itself does not lead to infinite recursion.
5305
5306** There is now some basic support for fluids. Please read
5307"libguile/fluid.h" to find out more. It is accessible from Scheme with
5308the following functions and macros:
5309
9c3fb66f
MV
5310Function: make-fluid
5311
5312 Create a new fluid object. Fluids are not special variables or
5313 some other extension to the semantics of Scheme, but rather
5314 ordinary Scheme objects. You can store them into variables (that
5315 are still lexically scoped, of course) or into any other place you
5316 like. Every fluid has a initial value of `#f'.
04c76b58 5317
9c3fb66f 5318Function: fluid? OBJ
04c76b58 5319
9c3fb66f 5320 Test whether OBJ is a fluid.
04c76b58 5321
9c3fb66f
MV
5322Function: fluid-ref FLUID
5323Function: fluid-set! FLUID VAL
04c76b58
MV
5324
5325 Access/modify the fluid FLUID. Modifications are only visible
5326 within the current dynamic root (that includes threads).
5327
9c3fb66f
MV
5328Function: with-fluids* FLUIDS VALUES THUNK
5329
5330 FLUIDS is a list of fluids and VALUES a corresponding list of
5331 values for these fluids. Before THUNK gets called the values are
6c0201ad 5332 installed in the fluids and the old values of the fluids are
9c3fb66f
MV
5333 saved in the VALUES list. When the flow of control leaves THUNK
5334 or reenters it, the values get swapped again. You might think of
5335 this as a `safe-fluid-excursion'. Note that the VALUES list is
5336 modified by `with-fluids*'.
5337
5338Macro: with-fluids ((FLUID VALUE) ...) FORM ...
5339
5340 The same as `with-fluids*' but with a different syntax. It looks
5341 just like `let', but both FLUID and VALUE are evaluated. Remember,
5342 fluids are not special variables but ordinary objects. FLUID
5343 should evaluate to a fluid.
04c76b58 5344
e2d6569c 5345** Changes to system call interfaces:
64d01d13 5346
e2d6569c 5347*** close-port, close-input-port and close-output-port now return a
64d01d13
GH
5348boolean instead of an `unspecified' object. #t means that the port
5349was successfully closed, while #f means it was already closed. It is
5350also now possible for these procedures to raise an exception if an
5351error occurs (some errors from write can be delayed until close.)
5352
e2d6569c 5353*** the first argument to chmod, fcntl, ftell and fseek can now be a
6afcd3b2
GH
5354file descriptor.
5355
e2d6569c 5356*** the third argument to fcntl is now optional.
6afcd3b2 5357
e2d6569c 5358*** the first argument to chown can now be a file descriptor or a port.
6afcd3b2 5359
e2d6569c 5360*** the argument to stat can now be a port.
6afcd3b2 5361
e2d6569c 5362*** The following new procedures have been added (most use scsh
64d01d13
GH
5363interfaces):
5364
e2d6569c 5365*** procedure: close PORT/FD
ec4ab4fd
GH
5366 Similar to close-port (*note close-port: Closing Ports.), but also
5367 works on file descriptors. A side effect of closing a file
5368 descriptor is that any ports using that file descriptor are moved
5369 to a different file descriptor and have their revealed counts set
5370 to zero.
5371
e2d6569c 5372*** procedure: port->fdes PORT
ec4ab4fd
GH
5373 Returns the integer file descriptor underlying PORT. As a side
5374 effect the revealed count of PORT is incremented.
5375
e2d6569c 5376*** procedure: fdes->ports FDES
ec4ab4fd
GH
5377 Returns a list of existing ports which have FDES as an underlying
5378 file descriptor, without changing their revealed counts.
5379
e2d6569c 5380*** procedure: fdes->inport FDES
ec4ab4fd
GH
5381 Returns an existing input port which has FDES as its underlying
5382 file descriptor, if one exists, and increments its revealed count.
5383 Otherwise, returns a new input port with a revealed count of 1.
5384
e2d6569c 5385*** procedure: fdes->outport FDES
ec4ab4fd
GH
5386 Returns an existing output port which has FDES as its underlying
5387 file descriptor, if one exists, and increments its revealed count.
5388 Otherwise, returns a new output port with a revealed count of 1.
5389
5390 The next group of procedures perform a `dup2' system call, if NEWFD
5391(an integer) is supplied, otherwise a `dup'. The file descriptor to be
5392duplicated can be supplied as an integer or contained in a port. The
64d01d13
GH
5393type of value returned varies depending on which procedure is used.
5394
ec4ab4fd
GH
5395 All procedures also have the side effect when performing `dup2' that
5396any ports using NEWFD are moved to a different file descriptor and have
64d01d13
GH
5397their revealed counts set to zero.
5398
e2d6569c 5399*** procedure: dup->fdes PORT/FD [NEWFD]
ec4ab4fd 5400 Returns an integer file descriptor.
64d01d13 5401
e2d6569c 5402*** procedure: dup->inport PORT/FD [NEWFD]
ec4ab4fd 5403 Returns a new input port using the new file descriptor.
64d01d13 5404
e2d6569c 5405*** procedure: dup->outport PORT/FD [NEWFD]
ec4ab4fd 5406 Returns a new output port using the new file descriptor.
64d01d13 5407
e2d6569c 5408*** procedure: dup PORT/FD [NEWFD]
ec4ab4fd
GH
5409 Returns a new port if PORT/FD is a port, with the same mode as the
5410 supplied port, otherwise returns an integer file descriptor.
64d01d13 5411
e2d6569c 5412*** procedure: dup->port PORT/FD MODE [NEWFD]
ec4ab4fd
GH
5413 Returns a new port using the new file descriptor. MODE supplies a
5414 mode string for the port (*note open-file: File Ports.).
64d01d13 5415
e2d6569c 5416*** procedure: setenv NAME VALUE
ec4ab4fd
GH
5417 Modifies the environment of the current process, which is also the
5418 default environment inherited by child processes.
64d01d13 5419
ec4ab4fd
GH
5420 If VALUE is `#f', then NAME is removed from the environment.
5421 Otherwise, the string NAME=VALUE is added to the environment,
5422 replacing any existing string with name matching NAME.
64d01d13 5423
ec4ab4fd 5424 The return value is unspecified.
956055a9 5425
e2d6569c 5426*** procedure: truncate-file OBJ SIZE
6afcd3b2
GH
5427 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
5428 can be a string containing a file name or an integer file
5429 descriptor or port open for output on the file. The underlying
5430 system calls are `truncate' and `ftruncate'.
5431
5432 The return value is unspecified.
5433
e2d6569c 5434*** procedure: setvbuf PORT MODE [SIZE]
7a6f1ffa
GH
5435 Set the buffering mode for PORT. MODE can be:
5436 `_IONBF'
5437 non-buffered
5438
5439 `_IOLBF'
5440 line buffered
5441
5442 `_IOFBF'
5443 block buffered, using a newly allocated buffer of SIZE bytes.
5444 However if SIZE is zero or unspecified, the port will be made
5445 non-buffered.
5446
5447 This procedure should not be used after I/O has been performed with
5448 the port.
5449
5450 Ports are usually block buffered by default, with a default buffer
5451 size. Procedures e.g., *Note open-file: File Ports, which accept a
5452 mode string allow `0' to be added to request an unbuffered port.
5453
e2d6569c 5454*** procedure: fsync PORT/FD
6afcd3b2
GH
5455 Copies any unwritten data for the specified output file descriptor
5456 to disk. If PORT/FD is a port, its buffer is flushed before the
5457 underlying file descriptor is fsync'd. The return value is
5458 unspecified.
5459
e2d6569c 5460*** procedure: open-fdes PATH FLAGS [MODES]
6afcd3b2
GH
5461 Similar to `open' but returns a file descriptor instead of a port.
5462
e2d6569c 5463*** procedure: execle PATH ENV [ARG] ...
6afcd3b2
GH
5464 Similar to `execl', but the environment of the new process is
5465 specified by ENV, which must be a list of strings as returned by
5466 the `environ' procedure.
5467
5468 This procedure is currently implemented using the `execve' system
5469 call, but we call it `execle' because of its Scheme calling
5470 interface.
5471
e2d6569c 5472*** procedure: strerror ERRNO
ec4ab4fd
GH
5473 Returns the Unix error message corresponding to ERRNO, an integer.
5474
e2d6569c 5475*** procedure: primitive-exit [STATUS]
6afcd3b2
GH
5476 Terminate the current process without unwinding the Scheme stack.
5477 This is would typically be useful after a fork. The exit status
5478 is STATUS if supplied, otherwise zero.
5479
e2d6569c 5480*** procedure: times
6afcd3b2
GH
5481 Returns an object with information about real and processor time.
5482 The following procedures accept such an object as an argument and
5483 return a selected component:
5484
5485 `tms:clock'
5486 The current real time, expressed as time units relative to an
5487 arbitrary base.
5488
5489 `tms:utime'
5490 The CPU time units used by the calling process.
5491
5492 `tms:stime'
5493 The CPU time units used by the system on behalf of the
5494 calling process.
5495
5496 `tms:cutime'
5497 The CPU time units used by terminated child processes of the
5498 calling process, whose status has been collected (e.g., using
5499 `waitpid').
5500
5501 `tms:cstime'
5502 Similarly, the CPU times units used by the system on behalf of
5503 terminated child processes.
7ad3c1e7 5504
e2d6569c
JB
5505** Removed: list-length
5506** Removed: list-append, list-append!
5507** Removed: list-reverse, list-reverse!
5508
5509** array-map renamed to array-map!
5510
5511** serial-array-map renamed to serial-array-map!
5512
660f41fa
MD
5513** catch doesn't take #f as first argument any longer
5514
5515Previously, it was possible to pass #f instead of a key to `catch'.
5516That would cause `catch' to pass a jump buffer object to the procedure
5517passed as second argument. The procedure could then use this jump
5518buffer objekt as an argument to throw.
5519
5520This mechanism has been removed since its utility doesn't motivate the
5521extra complexity it introduces.
5522
332d00f6
JB
5523** The `#/' notation for lists now provokes a warning message from Guile.
5524This syntax will be removed from Guile in the near future.
5525
5526To disable the warning message, set the GUILE_HUSH environment
5527variable to any non-empty value.
5528
8cd57bd0
JB
5529** The newline character now prints as `#\newline', following the
5530normal Scheme notation, not `#\nl'.
5531
c484bf7f
JB
5532* Changes to the gh_ interface
5533
8986901b
JB
5534** The gh_enter function now takes care of loading the Guile startup files.
5535gh_enter works by calling scm_boot_guile; see the remarks below.
5536
5424b4f7
MD
5537** Function: void gh_write (SCM x)
5538
5539Write the printed representation of the scheme object x to the current
5540output port. Corresponds to the scheme level `write'.
5541
3a97e020
MD
5542** gh_list_length renamed to gh_length.
5543
8d6787b6
MG
5544** vector handling routines
5545
5546Several major changes. In particular, gh_vector() now resembles
5547(vector ...) (with a caveat -- see manual), and gh_make_vector() now
956328d2
MG
5548exists and behaves like (make-vector ...). gh_vset() and gh_vref()
5549have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
8d6787b6
MG
5550vector-related gh_ functions have been implemented.
5551
7fee59bd
MG
5552** pair and list routines
5553
5554Implemented several of the R4RS pair and list functions that were
5555missing.
5556
171422a9
MD
5557** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
5558
5559New function. Converts double arrays back and forth between Scheme
5560and C.
5561
c484bf7f
JB
5562* Changes to the scm_ interface
5563
8986901b
JB
5564** The function scm_boot_guile now takes care of loading the startup files.
5565
5566Guile's primary initialization function, scm_boot_guile, now takes
5567care of loading `boot-9.scm', in the `ice-9' module, to initialize
5568Guile, define the module system, and put together some standard
5569bindings. It also loads `init.scm', which is intended to hold
5570site-specific initialization code.
5571
5572Since Guile cannot operate properly until boot-9.scm is loaded, there
5573is no reason to separate loading boot-9.scm from Guile's other
5574initialization processes.
5575
5576This job used to be done by scm_compile_shell_switches, which didn't
5577make much sense; in particular, it meant that people using Guile for
5578non-shell-like applications had to jump through hoops to get Guile
5579initialized properly.
5580
5581** The function scm_compile_shell_switches no longer loads the startup files.
5582Now, Guile always loads the startup files, whenever it is initialized;
5583see the notes above for scm_boot_guile and scm_load_startup_files.
5584
5585** Function: scm_load_startup_files
5586This new function takes care of loading Guile's initialization file
5587(`boot-9.scm'), and the site initialization file, `init.scm'. Since
5588this is always called by the Guile initialization process, it's
5589probably not too useful to call this yourself, but it's there anyway.
5590
87148d9e
JB
5591** The semantics of smob marking have changed slightly.
5592
5593The smob marking function (the `mark' member of the scm_smobfuns
5594structure) is no longer responsible for setting the mark bit on the
5595smob. The generic smob handling code in the garbage collector will
5596set this bit. The mark function need only ensure that any other
5597objects the smob refers to get marked.
5598
5599Note that this change means that the smob's GC8MARK bit is typically
5600already set upon entry to the mark function. Thus, marking functions
5601which look like this:
5602
5603 {
5604 if (SCM_GC8MARKP (ptr))
5605 return SCM_BOOL_F;
5606 SCM_SETGC8MARK (ptr);
5607 ... mark objects to which the smob refers ...
5608 }
5609
5610are now incorrect, since they will return early, and fail to mark any
5611other objects the smob refers to. Some code in the Guile library used
5612to work this way.
5613
1cf84ea5
JB
5614** The semantics of the I/O port functions in scm_ptobfuns have changed.
5615
5616If you have implemented your own I/O port type, by writing the
5617functions required by the scm_ptobfuns and then calling scm_newptob,
5618you will need to change your functions slightly.
5619
5620The functions in a scm_ptobfuns structure now expect the port itself
5621as their argument; they used to expect the `stream' member of the
5622port's scm_port_table structure. This allows functions in an
5623scm_ptobfuns structure to easily access the port's cell (and any flags
5624it its CAR), and the port's scm_port_table structure.
5625
5626Guile now passes the I/O port itself as the `port' argument in the
5627following scm_ptobfuns functions:
5628
5629 int (*free) (SCM port);
5630 int (*fputc) (int, SCM port);
5631 int (*fputs) (char *, SCM port);
5632 scm_sizet (*fwrite) SCM_P ((char *ptr,
5633 scm_sizet size,
5634 scm_sizet nitems,
5635 SCM port));
5636 int (*fflush) (SCM port);
5637 int (*fgetc) (SCM port);
5638 int (*fclose) (SCM port);
5639
5640The interfaces to the `mark', `print', `equalp', and `fgets' methods
5641are unchanged.
5642
5643If you have existing code which defines its own port types, it is easy
5644to convert your code to the new interface; simply apply SCM_STREAM to
5645the port argument to yield the value you code used to expect.
5646
5647Note that since both the port and the stream have the same type in the
5648C code --- they are both SCM values --- the C compiler will not remind
5649you if you forget to update your scm_ptobfuns functions.
5650
5651
933a7411
MD
5652** Function: int scm_internal_select (int fds,
5653 SELECT_TYPE *rfds,
5654 SELECT_TYPE *wfds,
5655 SELECT_TYPE *efds,
5656 struct timeval *timeout);
5657
5658This is a replacement for the `select' function provided by the OS.
5659It enables I/O blocking and sleeping to happen for one cooperative
5660thread without blocking other threads. It also avoids busy-loops in
5661these situations. It is intended that all I/O blocking and sleeping
5662will finally go through this function. Currently, this function is
5663only available on systems providing `gettimeofday' and `select'.
5664
5424b4f7
MD
5665** Function: SCM scm_internal_stack_catch (SCM tag,
5666 scm_catch_body_t body,
5667 void *body_data,
5668 scm_catch_handler_t handler,
5669 void *handler_data)
5670
5671A new sibling to the other two C level `catch' functions
5672scm_internal_catch and scm_internal_lazy_catch. Use it if you want
5673the stack to be saved automatically into the variable `the-last-stack'
5674(scm_the_last_stack_var) on error. This is necessary if you want to
5675use advanced error reporting, such as calling scm_display_error and
5676scm_display_backtrace. (They both take a stack object as argument.)
5677
df366c26
MD
5678** Function: SCM scm_spawn_thread (scm_catch_body_t body,
5679 void *body_data,
5680 scm_catch_handler_t handler,
5681 void *handler_data)
5682
5683Spawns a new thread. It does a job similar to
5684scm_call_with_new_thread but takes arguments more suitable when
5685spawning threads from application C code.
5686
88482b31
MD
5687** The hook scm_error_callback has been removed. It was originally
5688intended as a way for the user to install his own error handler. But
5689that method works badly since it intervenes between throw and catch,
5690thereby changing the semantics of expressions like (catch #t ...).
5691The correct way to do it is to use one of the C level catch functions
5692in throw.c: scm_internal_catch/lazy_catch/stack_catch.
5693
3a97e020
MD
5694** Removed functions:
5695
5696scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
5697scm_list_reverse, scm_list_reverse_x
5698
5699** New macros: SCM_LISTn where n is one of the integers 0-9.
5700
5701These can be used for pretty list creation from C. The idea is taken
5702from Erick Gallesio's STk.
5703
298aa6e3
MD
5704** scm_array_map renamed to scm_array_map_x
5705
527da704
MD
5706** mbstrings are now removed
5707
5708This means that the type codes scm_tc7_mb_string and
5709scm_tc7_mb_substring has been removed.
5710
8cd57bd0
JB
5711** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
5712
5713Since we no longer support multi-byte strings, these I/O functions
5714have been simplified, and renamed. Here are their old names, and
5715their new names and arguments:
5716
5717scm_gen_putc -> void scm_putc (int c, SCM port);
5718scm_gen_puts -> void scm_puts (char *s, SCM port);
5719scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
5720scm_gen_getc -> void scm_getc (SCM port);
5721
5722
527da704
MD
5723** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
5724
5725** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
5726
5727SCM_TYP7S now masks away the bit which distinguishes substrings from
5728strings.
5729
660f41fa
MD
5730** scm_catch_body_t: Backward incompatible change!
5731
5732Body functions to scm_internal_catch and friends do not any longer
5733take a second argument. This is because it is no longer possible to
5734pass a #f arg to catch.
5735
a8e05009
JB
5736** Calls to scm_protect_object and scm_unprotect now nest properly.
5737
5738The function scm_protect_object protects its argument from being freed
5739by the garbage collector. scm_unprotect_object removes that
5740protection.
5741
5742These functions now nest properly. That is, for every object O, there
5743is a counter which scm_protect_object(O) increments and
5744scm_unprotect_object(O) decrements, if the counter is greater than
5745zero. Every object's counter is zero when it is first created. If an
5746object's counter is greater than zero, the garbage collector will not
5747reclaim its storage.
5748
5749This allows you to use scm_protect_object in your code without
5750worrying that some other function you call will call
5751scm_unprotect_object, and allow it to be freed. Assuming that the
5752functions you call are well-behaved, and unprotect only those objects
5753they protect, you can follow the same rule and have confidence that
5754objects will be freed only at appropriate times.
5755
c484bf7f
JB
5756\f
5757Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 5758
737c9113
JB
5759* Changes to the distribution
5760
832b09ed
JB
5761** Nightly snapshots are now available from ftp.red-bean.com.
5762The old server, ftp.cyclic.com, has been relinquished to its rightful
5763owner.
5764
5765Nightly snapshots of the Guile development sources are now available via
5766anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
5767
5768Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
5769For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
5770
0fcab5ed
JB
5771** To run Guile without installing it, the procedure has changed a bit.
5772
5773If you used a separate build directory to compile Guile, you'll need
5774to include the build directory in SCHEME_LOAD_PATH, as well as the
5775source directory. See the `INSTALL' file for examples.
5776
737c9113
JB
5777* Changes to the procedure for linking libguile with your programs
5778
94982a4e
JB
5779** The standard Guile load path for Scheme code now includes
5780$(datadir)/guile (usually /usr/local/share/guile). This means that
5781you can install your own Scheme files there, and Guile will find them.
5782(Previous versions of Guile only checked a directory whose name
5783contained the Guile version number, so you had to re-install or move
5784your Scheme sources each time you installed a fresh version of Guile.)
5785
5786The load path also includes $(datadir)/guile/site; we recommend
5787putting individual Scheme files there. If you want to install a
5788package with multiple source files, create a directory for them under
5789$(datadir)/guile.
5790
5791** Guile 1.2 will now use the Rx regular expression library, if it is
5792installed on your system. When you are linking libguile into your own
5793programs, this means you will have to link against -lguile, -lqt (if
5794you configured Guile with thread support), and -lrx.
27590f82
JB
5795
5796If you are using autoconf to generate configuration scripts for your
5797application, the following lines should suffice to add the appropriate
5798libraries to your link command:
5799
5800### Find Rx, quickthreads and libguile.
5801AC_CHECK_LIB(rx, main)
5802AC_CHECK_LIB(qt, main)
5803AC_CHECK_LIB(guile, scm_shell)
5804
94982a4e
JB
5805The Guile 1.2 distribution does not contain sources for the Rx
5806library, as Guile 1.0 did. If you want to use Rx, you'll need to
5807retrieve it from a GNU FTP site and install it separately.
5808
b83b8bee
JB
5809* Changes to Scheme functions and syntax
5810
e035e7e6
MV
5811** The dynamic linking features of Guile are now enabled by default.
5812You can disable them by giving the `--disable-dynamic-linking' option
5813to configure.
5814
e035e7e6
MV
5815 (dynamic-link FILENAME)
5816
5817 Find the object file denoted by FILENAME (a string) and link it
5818 into the running Guile application. When everything works out,
5819 return a Scheme object suitable for representing the linked object
5820 file. Otherwise an error is thrown. How object files are
5821 searched is system dependent.
5822
5823 (dynamic-object? VAL)
5824
5825 Determine whether VAL represents a dynamically linked object file.
5826
5827 (dynamic-unlink DYNOBJ)
5828
5829 Unlink the indicated object file from the application. DYNOBJ
5830 should be one of the values returned by `dynamic-link'.
5831
5832 (dynamic-func FUNCTION DYNOBJ)
5833
5834 Search the C function indicated by FUNCTION (a string or symbol)
5835 in DYNOBJ and return some Scheme object that can later be used
5836 with `dynamic-call' to actually call this function. Right now,
5837 these Scheme objects are formed by casting the address of the
5838 function to `long' and converting this number to its Scheme
5839 representation.
5840
5841 (dynamic-call FUNCTION DYNOBJ)
5842
5843 Call the C function indicated by FUNCTION and DYNOBJ. The
5844 function is passed no arguments and its return value is ignored.
5845 When FUNCTION is something returned by `dynamic-func', call that
5846 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
5847 etc.), look it up in DYNOBJ; this is equivalent to
5848
5849 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
5850
5851 Interrupts are deferred while the C function is executing (with
5852 SCM_DEFER_INTS/SCM_ALLOW_INTS).
5853
5854 (dynamic-args-call FUNCTION DYNOBJ ARGS)
5855
5856 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
5857 some arguments and return its return value. The C function is
5858 expected to take two arguments and return an `int', just like
5859 `main':
5860
5861 int c_func (int argc, char **argv);
5862
5863 ARGS must be a list of strings and is converted into an array of
5864 `char *'. The array is passed in ARGV and its size in ARGC. The
5865 return value is converted to a Scheme number and returned from the
5866 call to `dynamic-args-call'.
5867
0fcab5ed
JB
5868When dynamic linking is disabled or not supported on your system,
5869the above functions throw errors, but they are still available.
5870
e035e7e6
MV
5871Here is a small example that works on GNU/Linux:
5872
5873 (define libc-obj (dynamic-link "libc.so"))
5874 (dynamic-args-call 'rand libc-obj '())
5875
5876See the file `libguile/DYNAMIC-LINKING' for additional comments.
5877
27590f82 5878** The #/ syntax for module names is depreciated, and will be removed
6c0201ad 5879in a future version of Guile. Instead of
27590f82
JB
5880
5881 #/foo/bar/baz
5882
5883instead write
5884
5885 (foo bar baz)
5886
5887The latter syntax is more consistent with existing Lisp practice.
5888
5dade857
MV
5889** Guile now does fancier printing of structures. Structures are the
5890underlying implementation for records, which in turn are used to
5891implement modules, so all of these object now print differently and in
5892a more informative way.
5893
161029df
JB
5894The Scheme printer will examine the builtin variable *struct-printer*
5895whenever it needs to print a structure object. When this variable is
5896not `#f' it is deemed to be a procedure and will be applied to the
5897structure object and the output port. When *struct-printer* is `#f'
5898or the procedure return `#f' the structure object will be printed in
5899the boring #<struct 80458270> form.
5dade857
MV
5900
5901This hook is used by some routines in ice-9/boot-9.scm to implement
5902type specific printing routines. Please read the comments there about
5903"printing structs".
5904
5905One of the more specific uses of structs are records. The printing
5906procedure that could be passed to MAKE-RECORD-TYPE is now actually
5907called. It should behave like a *struct-printer* procedure (described
5908above).
5909
b83b8bee
JB
5910** Guile now supports a new R4RS-compliant syntax for keywords. A
5911token of the form #:NAME, where NAME has the same syntax as a Scheme
5912symbol, is the external representation of the keyword named NAME.
5913Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
5914keyword objects can be read back into Guile. When used in an
5915expression, keywords are self-quoting objects.
b83b8bee
JB
5916
5917Guile suports this read syntax, and uses this print syntax, regardless
5918of the current setting of the `keyword' read option. The `keyword'
5919read option only controls whether Guile recognizes the `:NAME' syntax,
5920which is incompatible with R4RS. (R4RS says such token represent
5921symbols.)
737c9113
JB
5922
5923** Guile has regular expression support again. Guile 1.0 included
5924functions for matching regular expressions, based on the Rx library.
5925In Guile 1.1, the Guile/Rx interface was removed to simplify the
5926distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
59271.2 again supports the most commonly used functions, and supports all
5928of SCSH's regular expression functions.
2409cdfa 5929
94982a4e
JB
5930If your system does not include a POSIX regular expression library,
5931and you have not linked Guile with a third-party regexp library such as
5932Rx, these functions will not be available. You can tell whether your
5933Guile installation includes regular expression support by checking
5934whether the `*features*' list includes the `regex' symbol.
737c9113 5935
94982a4e 5936*** regexp functions
161029df 5937
94982a4e
JB
5938By default, Guile supports POSIX extended regular expressions. That
5939means that the characters `(', `)', `+' and `?' are special, and must
5940be escaped if you wish to match the literal characters.
e1a191a8 5941
94982a4e
JB
5942This regular expression interface was modeled after that implemented
5943by SCSH, the Scheme Shell. It is intended to be upwardly compatible
5944with SCSH regular expressions.
5945
5946**** Function: string-match PATTERN STR [START]
5947 Compile the string PATTERN into a regular expression and compare
5948 it with STR. The optional numeric argument START specifies the
5949 position of STR at which to begin matching.
5950
5951 `string-match' returns a "match structure" which describes what,
5952 if anything, was matched by the regular expression. *Note Match
5953 Structures::. If STR does not match PATTERN at all,
5954 `string-match' returns `#f'.
5955
5956 Each time `string-match' is called, it must compile its PATTERN
5957argument into a regular expression structure. This operation is
5958expensive, which makes `string-match' inefficient if the same regular
5959expression is used several times (for example, in a loop). For better
5960performance, you can compile a regular expression in advance and then
5961match strings against the compiled regexp.
5962
5963**** Function: make-regexp STR [FLAGS]
5964 Compile the regular expression described by STR, and return the
5965 compiled regexp structure. If STR does not describe a legal
5966 regular expression, `make-regexp' throws a
5967 `regular-expression-syntax' error.
5968
5969 FLAGS may be the bitwise-or of one or more of the following:
5970
5971**** Constant: regexp/extended
5972 Use POSIX Extended Regular Expression syntax when interpreting
5973 STR. If not set, POSIX Basic Regular Expression syntax is used.
5974 If the FLAGS argument is omitted, we assume regexp/extended.
5975
5976**** Constant: regexp/icase
5977 Do not differentiate case. Subsequent searches using the
5978 returned regular expression will be case insensitive.
5979
5980**** Constant: regexp/newline
5981 Match-any-character operators don't match a newline.
5982
5983 A non-matching list ([^...]) not containing a newline matches a
5984 newline.
5985
5986 Match-beginning-of-line operator (^) matches the empty string
5987 immediately after a newline, regardless of whether the FLAGS
5988 passed to regexp-exec contain regexp/notbol.
5989
5990 Match-end-of-line operator ($) matches the empty string
5991 immediately before a newline, regardless of whether the FLAGS
5992 passed to regexp-exec contain regexp/noteol.
5993
5994**** Function: regexp-exec REGEXP STR [START [FLAGS]]
5995 Match the compiled regular expression REGEXP against `str'. If
5996 the optional integer START argument is provided, begin matching
5997 from that position in the string. Return a match structure
5998 describing the results of the match, or `#f' if no match could be
5999 found.
6000
6001 FLAGS may be the bitwise-or of one or more of the following:
6002
6003**** Constant: regexp/notbol
6004 The match-beginning-of-line operator always fails to match (but
6005 see the compilation flag regexp/newline above) This flag may be
6006 used when different portions of a string are passed to
6007 regexp-exec and the beginning of the string should not be
6008 interpreted as the beginning of the line.
6009
6010**** Constant: regexp/noteol
6011 The match-end-of-line operator always fails to match (but see the
6012 compilation flag regexp/newline above)
6013
6014**** Function: regexp? OBJ
6015 Return `#t' if OBJ is a compiled regular expression, or `#f'
6016 otherwise.
6017
6018 Regular expressions are commonly used to find patterns in one string
6019and replace them with the contents of another string.
6020
6021**** Function: regexp-substitute PORT MATCH [ITEM...]
6022 Write to the output port PORT selected contents of the match
6023 structure MATCH. Each ITEM specifies what should be written, and
6024 may be one of the following arguments:
6025
6026 * A string. String arguments are written out verbatim.
6027
6028 * An integer. The submatch with that number is written.
6029
6030 * The symbol `pre'. The portion of the matched string preceding
6031 the regexp match is written.
6032
6033 * The symbol `post'. The portion of the matched string
6034 following the regexp match is written.
6035
6036 PORT may be `#f', in which case nothing is written; instead,
6037 `regexp-substitute' constructs a string from the specified ITEMs
6038 and returns that.
6039
6040**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
6041 Similar to `regexp-substitute', but can be used to perform global
6042 substitutions on STR. Instead of taking a match structure as an
6043 argument, `regexp-substitute/global' takes two string arguments: a
6044 REGEXP string describing a regular expression, and a TARGET string
6045 which should be matched against this regular expression.
6046
6047 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
6048 exceptions:
6049
6050 * A function may be supplied. When this function is called, it
6051 will be passed one argument: a match structure for a given
6052 regular expression match. It should return a string to be
6053 written out to PORT.
6054
6055 * The `post' symbol causes `regexp-substitute/global' to recurse
6056 on the unmatched portion of STR. This *must* be supplied in
6057 order to perform global search-and-replace on STR; if it is
6058 not present among the ITEMs, then `regexp-substitute/global'
6059 will return after processing a single match.
6060
6061*** Match Structures
6062
6063 A "match structure" is the object returned by `string-match' and
6064`regexp-exec'. It describes which portion of a string, if any, matched
6065the given regular expression. Match structures include: a reference to
6066the string that was checked for matches; the starting and ending
6067positions of the regexp match; and, if the regexp included any
6068parenthesized subexpressions, the starting and ending positions of each
6069submatch.
6070
6071 In each of the regexp match functions described below, the `match'
6072argument must be a match structure returned by a previous call to
6073`string-match' or `regexp-exec'. Most of these functions return some
6074information about the original target string that was matched against a
6075regular expression; we will call that string TARGET for easy reference.
6076
6077**** Function: regexp-match? OBJ
6078 Return `#t' if OBJ is a match structure returned by a previous
6079 call to `regexp-exec', or `#f' otherwise.
6080
6081**** Function: match:substring MATCH [N]
6082 Return the portion of TARGET matched by subexpression number N.
6083 Submatch 0 (the default) represents the entire regexp match. If
6084 the regular expression as a whole matched, but the subexpression
6085 number N did not match, return `#f'.
6086
6087**** Function: match:start MATCH [N]
6088 Return the starting position of submatch number N.
6089
6090**** Function: match:end MATCH [N]
6091 Return the ending position of submatch number N.
6092
6093**** Function: match:prefix MATCH
6094 Return the unmatched portion of TARGET preceding the regexp match.
6095
6096**** Function: match:suffix MATCH
6097 Return the unmatched portion of TARGET following the regexp match.
6098
6099**** Function: match:count MATCH
6100 Return the number of parenthesized subexpressions from MATCH.
6101 Note that the entire regular expression match itself counts as a
6102 subexpression, and failed submatches are included in the count.
6103
6104**** Function: match:string MATCH
6105 Return the original TARGET string.
6106
6107*** Backslash Escapes
6108
6109 Sometimes you will want a regexp to match characters like `*' or `$'
6110exactly. For example, to check whether a particular string represents
6111a menu entry from an Info node, it would be useful to match it against
6112a regexp like `^* [^:]*::'. However, this won't work; because the
6113asterisk is a metacharacter, it won't match the `*' at the beginning of
6114the string. In this case, we want to make the first asterisk un-magic.
6115
6116 You can do this by preceding the metacharacter with a backslash
6117character `\'. (This is also called "quoting" the metacharacter, and
6118is known as a "backslash escape".) When Guile sees a backslash in a
6119regular expression, it considers the following glyph to be an ordinary
6120character, no matter what special meaning it would ordinarily have.
6121Therefore, we can make the above example work by changing the regexp to
6122`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
6123to match only a single asterisk in the target string.
6124
6125 Since the backslash is itself a metacharacter, you may force a
6126regexp to match a backslash in the target string by preceding the
6127backslash with itself. For example, to find variable references in a
6128TeX program, you might want to find occurrences of the string `\let\'
6129followed by any number of alphabetic characters. The regular expression
6130`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
6131each match a single backslash in the target string.
6132
6133**** Function: regexp-quote STR
6134 Quote each special character found in STR with a backslash, and
6135 return the resulting string.
6136
6137 *Very important:* Using backslash escapes in Guile source code (as
6138in Emacs Lisp or C) can be tricky, because the backslash character has
6139special meaning for the Guile reader. For example, if Guile encounters
6140the character sequence `\n' in the middle of a string while processing
6141Scheme code, it replaces those characters with a newline character.
6142Similarly, the character sequence `\t' is replaced by a horizontal tab.
6143Several of these "escape sequences" are processed by the Guile reader
6144before your code is executed. Unrecognized escape sequences are
6145ignored: if the characters `\*' appear in a string, they will be
6146translated to the single character `*'.
6147
6148 This translation is obviously undesirable for regular expressions,
6149since we want to be able to include backslashes in a string in order to
6150escape regexp metacharacters. Therefore, to make sure that a backslash
6151is preserved in a string in your Guile program, you must use *two*
6152consecutive backslashes:
6153
6154 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
6155
6156 The string in this example is preprocessed by the Guile reader before
6157any code is executed. The resulting argument to `make-regexp' is the
6158string `^\* [^:]*', which is what we really want.
6159
6160 This also means that in order to write a regular expression that
6161matches a single backslash character, the regular expression string in
6162the source code must include *four* backslashes. Each consecutive pair
6163of backslashes gets translated by the Guile reader to a single
6164backslash, and the resulting double-backslash is interpreted by the
6165regexp engine as matching a single backslash character. Hence:
6166
6167 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
6168
6169 The reason for the unwieldiness of this syntax is historical. Both
6170regular expression pattern matchers and Unix string processing systems
6171have traditionally used backslashes with the special meanings described
6172above. The POSIX regular expression specification and ANSI C standard
6173both require these semantics. Attempting to abandon either convention
6174would cause other kinds of compatibility problems, possibly more severe
6175ones. Therefore, without extending the Scheme reader to support
6176strings with different quoting conventions (an ungainly and confusing
6177extension when implemented in other languages), we must adhere to this
6178cumbersome escape syntax.
6179
7ad3c1e7
GH
6180* Changes to the gh_ interface
6181
6182* Changes to the scm_ interface
6183
6184* Changes to system call interfaces:
94982a4e 6185
7ad3c1e7 6186** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
6187if an error occurs.
6188
94982a4e 6189*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
6190
6191(sigaction signum [action] [flags])
6192
6193signum is the signal number, which can be specified using the value
6194of SIGINT etc.
6195
6196If action is omitted, sigaction returns a pair: the CAR is the current
6197signal hander, which will be either an integer with the value SIG_DFL
6198(default action) or SIG_IGN (ignore), or the Scheme procedure which
6199handles the signal, or #f if a non-Scheme procedure handles the
6200signal. The CDR contains the current sigaction flags for the handler.
6201
6202If action is provided, it is installed as the new handler for signum.
6203action can be a Scheme procedure taking one argument, or the value of
6204SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
6205whatever signal handler was installed before sigaction was first used.
6206Flags can optionally be specified for the new handler (SA_RESTART is
6207always used if the system provides it, so need not be specified.) The
6208return value is a pair with information about the old handler as
6209described above.
6210
6211This interface does not provide access to the "signal blocking"
6212facility. Maybe this is not needed, since the thread support may
6213provide solutions to the problem of consistent access to data
6214structures.
e1a191a8 6215
94982a4e 6216*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
6217`force-output' on every port open for output.
6218
94982a4e
JB
6219** Guile now provides information on how it was built, via the new
6220global variable, %guile-build-info. This variable records the values
6221of the standard GNU makefile directory variables as an assocation
6222list, mapping variable names (symbols) onto directory paths (strings).
6223For example, to find out where the Guile link libraries were
6224installed, you can say:
6225
6226guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
6227
6228
6229* Changes to the scm_ interface
6230
6231** The new function scm_handle_by_message_noexit is just like the
6232existing scm_handle_by_message function, except that it doesn't call
6233exit to terminate the process. Instead, it prints a message and just
6234returns #f. This might be a more appropriate catch-all handler for
6235new dynamic roots and threads.
6236
cf78e9e8 6237\f
c484bf7f 6238Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
6239
6240* Changes to the distribution.
6241
6242The Guile 1.0 distribution has been split up into several smaller
6243pieces:
6244guile-core --- the Guile interpreter itself.
6245guile-tcltk --- the interface between the Guile interpreter and
6246 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
6247 is a toolkit for building graphical user interfaces.
6248guile-rgx-ctax --- the interface between Guile and the Rx regular
6249 expression matcher, and the translator for the Ctax
6250 programming language. These are packaged together because the
6251 Ctax translator uses Rx to parse Ctax source code.
6252
095936d2
JB
6253This NEWS file describes the changes made to guile-core since the 1.0
6254release.
6255
48d224d7
JB
6256We no longer distribute the documentation, since it was either out of
6257date, or incomplete. As soon as we have current documentation, we
6258will distribute it.
6259
0fcab5ed
JB
6260
6261
f3b1485f
JB
6262* Changes to the stand-alone interpreter
6263
48d224d7
JB
6264** guile now accepts command-line arguments compatible with SCSH, Olin
6265Shivers' Scheme Shell.
6266
6267In general, arguments are evaluated from left to right, but there are
6268exceptions. The following switches stop argument processing, and
6269stash all remaining command-line arguments as the value returned by
6270the (command-line) function.
6271 -s SCRIPT load Scheme source code from FILE, and exit
6272 -c EXPR evalute Scheme expression EXPR, and exit
6273 -- stop scanning arguments; run interactively
6274
6275The switches below are processed as they are encountered.
6276 -l FILE load Scheme source code from FILE
6277 -e FUNCTION after reading script, apply FUNCTION to
6278 command line arguments
6279 -ds do -s script at this point
6280 --emacs enable Emacs protocol (experimental)
6281 -h, --help display this help and exit
6282 -v, --version display version information and exit
6283 \ read arguments from following script lines
6284
6285So, for example, here is a Guile script named `ekko' (thanks, Olin)
6286which re-implements the traditional "echo" command:
6287
6288#!/usr/local/bin/guile -s
6289!#
6290(define (main args)
6291 (map (lambda (arg) (display arg) (display " "))
6292 (cdr args))
6293 (newline))
6294
6295(main (command-line))
6296
6297Suppose we invoke this script as follows:
6298
6299 ekko a speckled gecko
6300
6301Through the magic of Unix script processing (triggered by the `#!'
6302token at the top of the file), /usr/local/bin/guile receives the
6303following list of command-line arguments:
6304
6305 ("-s" "./ekko" "a" "speckled" "gecko")
6306
6307Unix inserts the name of the script after the argument specified on
6308the first line of the file (in this case, "-s"), and then follows that
6309with the arguments given to the script. Guile loads the script, which
6310defines the `main' function, and then applies it to the list of
6311remaining command-line arguments, ("a" "speckled" "gecko").
6312
095936d2
JB
6313In Unix, the first line of a script file must take the following form:
6314
6315#!INTERPRETER ARGUMENT
6316
6317where INTERPRETER is the absolute filename of the interpreter
6318executable, and ARGUMENT is a single command-line argument to pass to
6319the interpreter.
6320
6321You may only pass one argument to the interpreter, and its length is
6322limited. These restrictions can be annoying to work around, so Guile
6323provides a general mechanism (borrowed from, and compatible with,
6324SCSH) for circumventing them.
6325
6326If the ARGUMENT in a Guile script is a single backslash character,
6327`\', Guile will open the script file, parse arguments from its second
6328and subsequent lines, and replace the `\' with them. So, for example,
6329here is another implementation of the `ekko' script:
6330
6331#!/usr/local/bin/guile \
6332-e main -s
6333!#
6334(define (main args)
6335 (for-each (lambda (arg) (display arg) (display " "))
6336 (cdr args))
6337 (newline))
6338
6339If the user invokes this script as follows:
6340
6341 ekko a speckled gecko
6342
6343Unix expands this into
6344
6345 /usr/local/bin/guile \ ekko a speckled gecko
6346
6347When Guile sees the `\' argument, it replaces it with the arguments
6348read from the second line of the script, producing:
6349
6350 /usr/local/bin/guile -e main -s ekko a speckled gecko
6351
6352This tells Guile to load the `ekko' script, and apply the function
6353`main' to the argument list ("a" "speckled" "gecko").
6354
6355Here is how Guile parses the command-line arguments:
6356- Each space character terminates an argument. This means that two
6357 spaces in a row introduce an empty-string argument.
6358- The tab character is not permitted (unless you quote it with the
6359 backslash character, as described below), to avoid confusion.
6360- The newline character terminates the sequence of arguments, and will
6361 also terminate a final non-empty argument. (However, a newline
6362 following a space will not introduce a final empty-string argument;
6363 it only terminates the argument list.)
6364- The backslash character is the escape character. It escapes
6365 backslash, space, tab, and newline. The ANSI C escape sequences
6366 like \n and \t are also supported. These produce argument
6367 constituents; the two-character combination \n doesn't act like a
6368 terminating newline. The escape sequence \NNN for exactly three
6369 octal digits reads as the character whose ASCII code is NNN. As
6370 above, characters produced this way are argument constituents.
6371 Backslash followed by other characters is not allowed.
6372
48d224d7
JB
6373* Changes to the procedure for linking libguile with your programs
6374
6375** Guile now builds and installs a shared guile library, if your
6376system support shared libraries. (It still builds a static library on
6377all systems.) Guile automatically detects whether your system
6378supports shared libraries. To prevent Guile from buildisg shared
6379libraries, pass the `--disable-shared' flag to the configure script.
6380
6381Guile takes longer to compile when it builds shared libraries, because
6382it must compile every file twice --- once to produce position-
6383independent object code, and once to produce normal object code.
6384
6385** The libthreads library has been merged into libguile.
6386
6387To link a program against Guile, you now need only link against
6388-lguile and -lqt; -lthreads is no longer needed. If you are using
6389autoconf to generate configuration scripts for your application, the
6390following lines should suffice to add the appropriate libraries to
6391your link command:
6392
6393### Find quickthreads and libguile.
6394AC_CHECK_LIB(qt, main)
6395AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
6396
6397* Changes to Scheme functions
6398
095936d2
JB
6399** Guile Scheme's special syntax for keyword objects is now optional,
6400and disabled by default.
6401
6402The syntax variation from R4RS made it difficult to port some
6403interesting packages to Guile. The routines which accepted keyword
6404arguments (mostly in the module system) have been modified to also
6405accept symbols whose names begin with `:'.
6406
6407To change the keyword syntax, you must first import the (ice-9 debug)
6408module:
6409 (use-modules (ice-9 debug))
6410
6411Then you can enable the keyword syntax as follows:
6412 (read-set! keywords 'prefix)
6413
6414To disable keyword syntax, do this:
6415 (read-set! keywords #f)
6416
6417** Many more primitive functions accept shared substrings as
6418arguments. In the past, these functions required normal, mutable
6419strings as arguments, although they never made use of this
6420restriction.
6421
6422** The uniform array functions now operate on byte vectors. These
6423functions are `array-fill!', `serial-array-copy!', `array-copy!',
6424`serial-array-map', `array-map', `array-for-each', and
6425`array-index-map!'.
6426
6427** The new functions `trace' and `untrace' implement simple debugging
6428support for Scheme functions.
6429
6430The `trace' function accepts any number of procedures as arguments,
6431and tells the Guile interpreter to display each procedure's name and
6432arguments each time the procedure is invoked. When invoked with no
6433arguments, `trace' returns the list of procedures currently being
6434traced.
6435
6436The `untrace' function accepts any number of procedures as arguments,
6437and tells the Guile interpreter not to trace them any more. When
6438invoked with no arguments, `untrace' untraces all curretly traced
6439procedures.
6440
6441The tracing in Guile has an advantage over most other systems: we
6442don't create new procedure objects, but mark the procedure objects
6443themselves. This means that anonymous and internal procedures can be
6444traced.
6445
6446** The function `assert-repl-prompt' has been renamed to
6447`set-repl-prompt!'. It takes one argument, PROMPT.
6448- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
6449- If PROMPT is a string, we use it as a prompt.
6450- If PROMPT is a procedure accepting no arguments, we call it, and
6451 display the result as a prompt.
6452- Otherwise, we display "> ".
6453
6454** The new function `eval-string' reads Scheme expressions from a
6455string and evaluates them, returning the value of the last expression
6456in the string. If the string contains no expressions, it returns an
6457unspecified value.
6458
6459** The new function `thunk?' returns true iff its argument is a
6460procedure of zero arguments.
6461
6462** `defined?' is now a builtin function, instead of syntax. This
6463means that its argument should be quoted. It returns #t iff its
6464argument is bound in the current module.
6465
6466** The new syntax `use-modules' allows you to add new modules to your
6467environment without re-typing a complete `define-module' form. It
6468accepts any number of module names as arguments, and imports their
6469public bindings into the current module.
6470
6471** The new function (module-defined? NAME MODULE) returns true iff
6472NAME, a symbol, is defined in MODULE, a module object.
6473
6474** The new function `builtin-bindings' creates and returns a hash
6475table containing copies of all the root module's bindings.
6476
6477** The new function `builtin-weak-bindings' does the same as
6478`builtin-bindings', but creates a doubly-weak hash table.
6479
6480** The `equal?' function now considers variable objects to be
6481equivalent if they have the same name and the same value.
6482
6483** The new function `command-line' returns the command-line arguments
6484given to Guile, as a list of strings.
6485
6486When using guile as a script interpreter, `command-line' returns the
6487script's arguments; those processed by the interpreter (like `-s' or
6488`-c') are omitted. (In other words, you get the normal, expected
6489behavior.) Any application that uses scm_shell to process its
6490command-line arguments gets this behavior as well.
6491
6492** The new function `load-user-init' looks for a file called `.guile'
6493in the user's home directory, and loads it if it exists. This is
6494mostly for use by the code generated by scm_compile_shell_switches,
6495but we thought it might also be useful in other circumstances.
6496
6497** The new function `log10' returns the base-10 logarithm of its
6498argument.
6499
6500** Changes to I/O functions
6501
6c0201ad 6502*** The functions `read', `primitive-load', `read-and-eval!', and
095936d2
JB
6503`primitive-load-path' no longer take optional arguments controlling
6504case insensitivity and a `#' parser.
6505
6506Case sensitivity is now controlled by a read option called
6507`case-insensitive'. The user can add new `#' syntaxes with the
6508`read-hash-extend' function (see below).
6509
6510*** The new function `read-hash-extend' allows the user to change the
6511syntax of Guile Scheme in a somewhat controlled way.
6512
6513(read-hash-extend CHAR PROC)
6514 When parsing S-expressions, if we read a `#' character followed by
6515 the character CHAR, use PROC to parse an object from the stream.
6516 If PROC is #f, remove any parsing procedure registered for CHAR.
6517
6518 The reader applies PROC to two arguments: CHAR and an input port.
6519
6c0201ad 6520*** The new functions read-delimited and read-delimited! provide a
095936d2
JB
6521general mechanism for doing delimited input on streams.
6522
6523(read-delimited DELIMS [PORT HANDLE-DELIM])
6524 Read until we encounter one of the characters in DELIMS (a string),
6525 or end-of-file. PORT is the input port to read from; it defaults to
6526 the current input port. The HANDLE-DELIM parameter determines how
6527 the terminating character is handled; it should be one of the
6528 following symbols:
6529
6530 'trim omit delimiter from result
6531 'peek leave delimiter character in input stream
6532 'concat append delimiter character to returned value
6533 'split return a pair: (RESULT . TERMINATOR)
6534
6535 HANDLE-DELIM defaults to 'peek.
6536
6537(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
6538 A side-effecting variant of `read-delimited'.
6539
6540 The data is written into the string BUF at the indices in the
6541 half-open interval [START, END); the default interval is the whole
6542 string: START = 0 and END = (string-length BUF). The values of
6543 START and END must specify a well-defined interval in BUF, i.e.
6544 0 <= START <= END <= (string-length BUF).
6545
6546 It returns NBYTES, the number of bytes read. If the buffer filled
6547 up without a delimiter character being found, it returns #f. If the
6548 port is at EOF when the read starts, it returns the EOF object.
6549
6550 If an integer is returned (i.e., the read is successfully terminated
6551 by reading a delimiter character), then the HANDLE-DELIM parameter
6552 determines how to handle the terminating character. It is described
6553 above, and defaults to 'peek.
6554
6555(The descriptions of these functions were borrowed from the SCSH
6556manual, by Olin Shivers and Brian Carlstrom.)
6557
6558*** The `%read-delimited!' function is the primitive used to implement
6559`read-delimited' and `read-delimited!'.
6560
6561(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
6562
6563This returns a pair of values: (TERMINATOR . NUM-READ).
6564- TERMINATOR describes why the read was terminated. If it is a
6565 character or the eof object, then that is the value that terminated
6566 the read. If it is #f, the function filled the buffer without finding
6567 a delimiting character.
6568- NUM-READ is the number of characters read into BUF.
6569
6570If the read is successfully terminated by reading a delimiter
6571character, then the gobble? parameter determines what to do with the
6572terminating character. If true, the character is removed from the
6573input stream; if false, the character is left in the input stream
6574where a subsequent read operation will retrieve it. In either case,
6575the character is also the first value returned by the procedure call.
6576
6577(The descriptions of this function was borrowed from the SCSH manual,
6578by Olin Shivers and Brian Carlstrom.)
6579
6580*** The `read-line' and `read-line!' functions have changed; they now
6581trim the terminator by default; previously they appended it to the
6582returned string. For the old behavior, use (read-line PORT 'concat).
6583
6584*** The functions `uniform-array-read!' and `uniform-array-write!' now
6585take new optional START and END arguments, specifying the region of
6586the array to read and write.
6587
f348c807
JB
6588*** The `ungetc-char-ready?' function has been removed. We feel it's
6589inappropriate for an interface to expose implementation details this
6590way.
095936d2
JB
6591
6592** Changes to the Unix library and system call interface
6593
6594*** The new fcntl function provides access to the Unix `fcntl' system
6595call.
6596
6597(fcntl PORT COMMAND VALUE)
6598 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
6599 Values for COMMAND are:
6600
6601 F_DUPFD duplicate a file descriptor
6602 F_GETFD read the descriptor's close-on-exec flag
6603 F_SETFD set the descriptor's close-on-exec flag to VALUE
6604 F_GETFL read the descriptor's flags, as set on open
6605 F_SETFL set the descriptor's flags, as set on open to VALUE
6606 F_GETOWN return the process ID of a socket's owner, for SIGIO
6607 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
6608 FD_CLOEXEC not sure what this is
6609
6610For details, see the documentation for the fcntl system call.
6611
6612*** The arguments to `select' have changed, for compatibility with
6613SCSH. The TIMEOUT parameter may now be non-integral, yielding the
6614expected behavior. The MILLISECONDS parameter has been changed to
6615MICROSECONDS, to more closely resemble the underlying system call.
6616The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
6617corresponding return set will be the same.
6618
6619*** The arguments to the `mknod' system call have changed. They are
6620now:
6621
6622(mknod PATH TYPE PERMS DEV)
6623 Create a new file (`node') in the file system. PATH is the name of
6624 the file to create. TYPE is the kind of file to create; it should
6625 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
6626 permission bits to give the newly created file. If TYPE is
6627 'block-special or 'char-special, DEV specifies which device the
6628 special file refers to; its interpretation depends on the kind of
6629 special file being created.
6630
6631*** The `fork' function has been renamed to `primitive-fork', to avoid
6632clashing with various SCSH forks.
6633
6634*** The `recv' and `recvfrom' functions have been renamed to `recv!'
6635and `recvfrom!'. They no longer accept a size for a second argument;
6636you must pass a string to hold the received value. They no longer
6637return the buffer. Instead, `recv' returns the length of the message
6638received, and `recvfrom' returns a pair containing the packet's length
6c0201ad 6639and originating address.
095936d2
JB
6640
6641*** The file descriptor datatype has been removed, as have the
6642`read-fd', `write-fd', `close', `lseek', and `dup' functions.
6643We plan to replace these functions with a SCSH-compatible interface.
6644
6645*** The `create' function has been removed; it's just a special case
6646of `open'.
6647
6648*** There are new functions to break down process termination status
6649values. In the descriptions below, STATUS is a value returned by
6650`waitpid'.
6651
6652(status:exit-val STATUS)
6653 If the child process exited normally, this function returns the exit
6654 code for the child process (i.e., the value passed to exit, or
6655 returned from main). If the child process did not exit normally,
6656 this function returns #f.
6657
6658(status:stop-sig STATUS)
6659 If the child process was suspended by a signal, this function
6660 returns the signal that suspended the child. Otherwise, it returns
6661 #f.
6662
6663(status:term-sig STATUS)
6664 If the child process terminated abnormally, this function returns
6665 the signal that terminated the child. Otherwise, this function
6666 returns false.
6667
6668POSIX promises that exactly one of these functions will return true on
6669a valid STATUS value.
6670
6671These functions are compatible with SCSH.
6672
6673*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
6674returned by `localtime', `gmtime', and that ilk. They are:
6675
6676 Component Accessor Setter
6677 ========================= ============ ============
6678 seconds tm:sec set-tm:sec
6679 minutes tm:min set-tm:min
6680 hours tm:hour set-tm:hour
6681 day of the month tm:mday set-tm:mday
6682 month tm:mon set-tm:mon
6683 year tm:year set-tm:year
6684 day of the week tm:wday set-tm:wday
6685 day in the year tm:yday set-tm:yday
6686 daylight saving time tm:isdst set-tm:isdst
6687 GMT offset, seconds tm:gmtoff set-tm:gmtoff
6688 name of time zone tm:zone set-tm:zone
6689
095936d2
JB
6690*** There are new accessors for the vectors returned by `uname',
6691describing the host system:
48d224d7
JB
6692
6693 Component Accessor
6694 ============================================== ================
6695 name of the operating system implementation utsname:sysname
6696 network name of this machine utsname:nodename
6697 release level of the operating system utsname:release
6698 version level of the operating system utsname:version
6699 machine hardware platform utsname:machine
6700
095936d2
JB
6701*** There are new accessors for the vectors returned by `getpw',
6702`getpwnam', `getpwuid', and `getpwent', describing entries from the
6703system's user database:
6704
6705 Component Accessor
6706 ====================== =================
6707 user name passwd:name
6708 user password passwd:passwd
6709 user id passwd:uid
6710 group id passwd:gid
6711 real name passwd:gecos
6712 home directory passwd:dir
6713 shell program passwd:shell
6714
6715*** There are new accessors for the vectors returned by `getgr',
6716`getgrnam', `getgrgid', and `getgrent', describing entries from the
6717system's group database:
6718
6719 Component Accessor
6720 ======================= ============
6721 group name group:name
6722 group password group:passwd
6723 group id group:gid
6724 group members group:mem
6725
6726*** There are new accessors for the vectors returned by `gethost',
6727`gethostbyaddr', `gethostbyname', and `gethostent', describing
6728internet hosts:
6729
6730 Component Accessor
6731 ========================= ===============
6732 official name of host hostent:name
6733 alias list hostent:aliases
6734 host address type hostent:addrtype
6735 length of address hostent:length
6736 list of addresses hostent:addr-list
6737
6738*** There are new accessors for the vectors returned by `getnet',
6739`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
6740networks:
6741
6742 Component Accessor
6743 ========================= ===============
6744 official name of net netent:name
6745 alias list netent:aliases
6746 net number type netent:addrtype
6747 net number netent:net
6748
6749*** There are new accessors for the vectors returned by `getproto',
6750`getprotobyname', `getprotobynumber', and `getprotoent', describing
6751internet protocols:
6752
6753 Component Accessor
6754 ========================= ===============
6755 official protocol name protoent:name
6756 alias list protoent:aliases
6757 protocol number protoent:proto
6758
6759*** There are new accessors for the vectors returned by `getserv',
6760`getservbyname', `getservbyport', and `getservent', describing
6761internet protocols:
6762
6763 Component Accessor
6764 ========================= ===============
6c0201ad 6765 official service name servent:name
095936d2 6766 alias list servent:aliases
6c0201ad
TTN
6767 port number servent:port
6768 protocol to use servent:proto
095936d2
JB
6769
6770*** There are new accessors for the sockaddr structures returned by
6771`accept', `getsockname', `getpeername', `recvfrom!':
6772
6773 Component Accessor
6774 ======================================== ===============
6c0201ad 6775 address format (`family') sockaddr:fam
095936d2
JB
6776 path, for file domain addresses sockaddr:path
6777 address, for internet domain addresses sockaddr:addr
6778 TCP or UDP port, for internet sockaddr:port
6779
6780*** The `getpwent', `getgrent', `gethostent', `getnetent',
6781`getprotoent', and `getservent' functions now return #f at the end of
6782the user database. (They used to throw an exception.)
6783
6784Note that calling MUMBLEent function is equivalent to calling the
6785corresponding MUMBLE function with no arguments.
6786
6787*** The `setpwent', `setgrent', `sethostent', `setnetent',
6788`setprotoent', and `setservent' routines now take no arguments.
6789
6790*** The `gethost', `getproto', `getnet', and `getserv' functions now
6791provide more useful information when they throw an exception.
6792
6793*** The `lnaof' function has been renamed to `inet-lnaof'.
6794
6795*** Guile now claims to have the `current-time' feature.
6796
6797*** The `mktime' function now takes an optional second argument ZONE,
6798giving the time zone to use for the conversion. ZONE should be a
6799string, in the same format as expected for the "TZ" environment variable.
6800
6801*** The `strptime' function now returns a pair (TIME . COUNT), where
6802TIME is the parsed time as a vector, and COUNT is the number of
6803characters from the string left unparsed. This function used to
6804return the remaining characters as a string.
6805
6806*** The `gettimeofday' function has replaced the old `time+ticks' function.
6807The return value is now (SECONDS . MICROSECONDS); the fractional
6808component is no longer expressed in "ticks".
6809
6810*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 6811
ea00ecba
MG
6812* Changes to the gh_ interface
6813
6814** gh_eval_str() now returns an SCM object which is the result of the
6815evaluation
6816
aaef0d2a
MG
6817** gh_scm2str() now copies the Scheme data to a caller-provided C
6818array
6819
6820** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
6821and returns the array
6822
6823** gh_scm2str0() is gone: there is no need to distinguish
6824null-terminated from non-null-terminated, since gh_scm2newstr() allows
6825the user to interpret the data both ways.
6826
f3b1485f
JB
6827* Changes to the scm_ interface
6828
095936d2
JB
6829** The new function scm_symbol_value0 provides an easy way to get a
6830symbol's value from C code:
6831
6832SCM scm_symbol_value0 (char *NAME)
6833 Return the value of the symbol named by the null-terminated string
6834 NAME in the current module. If the symbol named NAME is unbound in
6835 the current module, return SCM_UNDEFINED.
6836
6837** The new function scm_sysintern0 creates new top-level variables,
6838without assigning them a value.
6839
6840SCM scm_sysintern0 (char *NAME)
6841 Create a new Scheme top-level variable named NAME. NAME is a
6842 null-terminated string. Return the variable's value cell.
6843
6844** The function scm_internal_catch is the guts of catch. It handles
6845all the mechanics of setting up a catch target, invoking the catch
6846body, and perhaps invoking the handler if the body does a throw.
6847
6848The function is designed to be usable from C code, but is general
6849enough to implement all the semantics Guile Scheme expects from throw.
6850
6851TAG is the catch tag. Typically, this is a symbol, but this function
6852doesn't actually care about that.
6853
6854BODY is a pointer to a C function which runs the body of the catch;
6855this is the code you can throw from. We call it like this:
6856 BODY (BODY_DATA, JMPBUF)
6857where:
6858 BODY_DATA is just the BODY_DATA argument we received; we pass it
6859 through to BODY as its first argument. The caller can make
6860 BODY_DATA point to anything useful that BODY might need.
6861 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
6862 which we have just created and initialized.
6863
6864HANDLER is a pointer to a C function to deal with a throw to TAG,
6865should one occur. We call it like this:
6866 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
6867where
6868 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
6869 same idea as BODY_DATA above.
6870 THROWN_TAG is the tag that the user threw to; usually this is
6871 TAG, but it could be something else if TAG was #t (i.e., a
6872 catch-all), or the user threw to a jmpbuf.
6873 THROW_ARGS is the list of arguments the user passed to the THROW
6874 function.
6875
6876BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
6877is just a pointer we pass through to HANDLER. We don't actually
6878use either of those pointers otherwise ourselves. The idea is
6879that, if our caller wants to communicate something to BODY or
6880HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
6881HANDLER can then use. Think of it as a way to make BODY and
6882HANDLER closures, not just functions; MUMBLE_DATA points to the
6883enclosed variables.
6884
6885Of course, it's up to the caller to make sure that any data a
6886MUMBLE_DATA needs is protected from GC. A common way to do this is
6887to make MUMBLE_DATA a pointer to data stored in an automatic
6888structure variable; since the collector must scan the stack for
6889references anyway, this assures that any references in MUMBLE_DATA
6890will be found.
6891
6892** The new function scm_internal_lazy_catch is exactly like
6893scm_internal_catch, except:
6894
6895- It does not unwind the stack (this is the major difference).
6896- If handler returns, its value is returned from the throw.
6897- BODY always receives #f as its JMPBUF argument (since there's no
6898 jmpbuf associated with a lazy catch, because we don't unwind the
6899 stack.)
6900
6901** scm_body_thunk is a new body function you can pass to
6902scm_internal_catch if you want the body to be like Scheme's `catch'
6903--- a thunk, or a function of one argument if the tag is #f.
6904
6905BODY_DATA is a pointer to a scm_body_thunk_data structure, which
6906contains the Scheme procedure to invoke as the body, and the tag
6907we're catching. If the tag is #f, then we pass JMPBUF (created by
6908scm_internal_catch) to the body procedure; otherwise, the body gets
6909no arguments.
6910
6911** scm_handle_by_proc is a new handler function you can pass to
6912scm_internal_catch if you want the handler to act like Scheme's catch
6913--- call a procedure with the tag and the throw arguments.
6914
6915If the user does a throw to this catch, this function runs a handler
6916procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
6917variable holding the Scheme procedure object to invoke. It ought to
6918be a pointer to an automatic variable (i.e., one living on the stack),
6919or the procedure object should be otherwise protected from GC.
6920
6921** scm_handle_by_message is a new handler function to use with
6922`scm_internal_catch' if you want Guile to print a message and die.
6923It's useful for dealing with throws to uncaught keys at the top level.
6924
6925HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
6926message header to print; if zero, we use "guile" instead. That
6927text is followed by a colon, then the message described by ARGS.
6928
6929** The return type of scm_boot_guile is now void; the function does
6930not return a value, and indeed, never returns at all.
6931
f3b1485f
JB
6932** The new function scm_shell makes it easy for user applications to
6933process command-line arguments in a way that is compatible with the
6934stand-alone guile interpreter (which is in turn compatible with SCSH,
6935the Scheme shell).
6936
6937To use the scm_shell function, first initialize any guile modules
6938linked into your application, and then call scm_shell with the values
7ed46dc8 6939of ARGC and ARGV your `main' function received. scm_shell will add
f3b1485f
JB
6940any SCSH-style meta-arguments from the top of the script file to the
6941argument vector, and then process the command-line arguments. This
6942generally means loading a script file or starting up an interactive
6943command interpreter. For details, see "Changes to the stand-alone
6944interpreter" above.
6945
095936d2 6946** The new functions scm_get_meta_args and scm_count_argv help you
6c0201ad 6947implement the SCSH-style meta-argument, `\'.
095936d2
JB
6948
6949char **scm_get_meta_args (int ARGC, char **ARGV)
6950 If the second element of ARGV is a string consisting of a single
6951 backslash character (i.e. "\\" in Scheme notation), open the file
6952 named by the following argument, parse arguments from it, and return
6953 the spliced command line. The returned array is terminated by a
6954 null pointer.
6c0201ad 6955
095936d2
JB
6956 For details of argument parsing, see above, under "guile now accepts
6957 command-line arguments compatible with SCSH..."
6958
6959int scm_count_argv (char **ARGV)
6960 Count the arguments in ARGV, assuming it is terminated by a null
6961 pointer.
6962
6963For an example of how these functions might be used, see the source
6964code for the function scm_shell in libguile/script.c.
6965
6966You will usually want to use scm_shell instead of calling this
6967function yourself.
6968
6969** The new function scm_compile_shell_switches turns an array of
6970command-line arguments into Scheme code to carry out the actions they
6971describe. Given ARGC and ARGV, it returns a Scheme expression to
6972evaluate, and calls scm_set_program_arguments to make any remaining
6973command-line arguments available to the Scheme code. For example,
6974given the following arguments:
6975
6976 -e main -s ekko a speckled gecko
6977
6978scm_set_program_arguments will return the following expression:
6979
6980 (begin (load "ekko") (main (command-line)) (quit))
6981
6982You will usually want to use scm_shell instead of calling this
6983function yourself.
6984
6985** The function scm_shell_usage prints a usage message appropriate for
6986an interpreter that uses scm_compile_shell_switches to handle its
6987command-line arguments.
6988
6989void scm_shell_usage (int FATAL, char *MESSAGE)
6990 Print a usage message to the standard error output. If MESSAGE is
6991 non-zero, write it before the usage message, followed by a newline.
6992 If FATAL is non-zero, exit the process, using FATAL as the
6993 termination status. (If you want to be compatible with Guile,
6994 always use 1 as the exit status when terminating due to command-line
6995 usage problems.)
6996
6997You will usually want to use scm_shell instead of calling this
6998function yourself.
48d224d7
JB
6999
7000** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
7001expressions. It used to return SCM_EOL. Earth-shattering.
7002
7003** The macros for declaring scheme objects in C code have been
7004rearranged slightly. They are now:
7005
7006SCM_SYMBOL (C_NAME, SCHEME_NAME)
7007 Declare a static SCM variable named C_NAME, and initialize it to
7008 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
7009 be a C identifier, and SCHEME_NAME should be a C string.
7010
7011SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
7012 Just like SCM_SYMBOL, but make C_NAME globally visible.
7013
7014SCM_VCELL (C_NAME, SCHEME_NAME)
7015 Create a global variable at the Scheme level named SCHEME_NAME.
7016 Declare a static SCM variable named C_NAME, and initialize it to
7017 point to the Scheme variable's value cell.
7018
7019SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
7020 Just like SCM_VCELL, but make C_NAME globally visible.
7021
7022The `guile-snarf' script writes initialization code for these macros
7023to its standard output, given C source code as input.
7024
7025The SCM_GLOBAL macro is gone.
7026
7027** The scm_read_line and scm_read_line_x functions have been replaced
7028by Scheme code based on the %read-delimited! procedure (known to C
7029code as scm_read_delimited_x). See its description above for more
7030information.
48d224d7 7031
095936d2
JB
7032** The function scm_sys_open has been renamed to scm_open. It now
7033returns a port instead of an FD object.
ea00ecba 7034
095936d2
JB
7035* The dynamic linking support has changed. For more information, see
7036libguile/DYNAMIC-LINKING.
ea00ecba 7037
f7b47737
JB
7038\f
7039Guile 1.0b3
3065a62a 7040
f3b1485f
JB
7041User-visible changes from Thursday, September 5, 1996 until Guile 1.0
7042(Sun 5 Jan 1997):
3065a62a 7043
4b521edb 7044* Changes to the 'guile' program:
3065a62a 7045
4b521edb
JB
7046** Guile now loads some new files when it starts up. Guile first
7047searches the load path for init.scm, and loads it if found. Then, if
7048Guile is not being used to execute a script, and the user's home
7049directory contains a file named `.guile', Guile loads that.
c6486f8a 7050
4b521edb 7051** You can now use Guile as a shell script interpreter.
3065a62a
JB
7052
7053To paraphrase the SCSH manual:
7054
7055 When Unix tries to execute an executable file whose first two
7056 characters are the `#!', it treats the file not as machine code to
7057 be directly executed by the native processor, but as source code
7058 to be executed by some interpreter. The interpreter to use is
7059 specified immediately after the #! sequence on the first line of
7060 the source file. The kernel reads in the name of the interpreter,
7061 and executes that instead. It passes the interpreter the source
7062 filename as its first argument, with the original arguments
7063 following. Consult the Unix man page for the `exec' system call
7064 for more information.
7065
1a1945be
JB
7066Now you can use Guile as an interpreter, using a mechanism which is a
7067compatible subset of that provided by SCSH.
7068
3065a62a
JB
7069Guile now recognizes a '-s' command line switch, whose argument is the
7070name of a file of Scheme code to load. It also treats the two
7071characters `#!' as the start of a comment, terminated by `!#'. Thus,
7072to make a file of Scheme code directly executable by Unix, insert the
7073following two lines at the top of the file:
7074
7075#!/usr/local/bin/guile -s
7076!#
7077
7078Guile treats the argument of the `-s' command-line switch as the name
7079of a file of Scheme code to load, and treats the sequence `#!' as the
7080start of a block comment, terminated by `!#'.
7081
7082For example, here's a version of 'echo' written in Scheme:
7083
7084#!/usr/local/bin/guile -s
7085!#
7086(let loop ((args (cdr (program-arguments))))
7087 (if (pair? args)
7088 (begin
7089 (display (car args))
7090 (if (pair? (cdr args))
7091 (display " "))
7092 (loop (cdr args)))))
7093(newline)
7094
7095Why does `#!' start a block comment terminated by `!#', instead of the
7096end of the line? That is the notation SCSH uses, and although we
7097don't yet support the other SCSH features that motivate that choice,
7098we would like to be backward-compatible with any existing Guile
3763761c
JB
7099scripts once we do. Furthermore, if the path to Guile on your system
7100is too long for your kernel, you can start the script with this
7101horrible hack:
7102
7103#!/bin/sh
7104exec /really/long/path/to/guile -s "$0" ${1+"$@"}
7105!#
3065a62a
JB
7106
7107Note that some very old Unix systems don't support the `#!' syntax.
7108
c6486f8a 7109
4b521edb 7110** You can now run Guile without installing it.
6685dc83
JB
7111
7112Previous versions of the interactive Guile interpreter (`guile')
7113couldn't start up unless Guile's Scheme library had been installed;
7114they used the value of the environment variable `SCHEME_LOAD_PATH'
7115later on in the startup process, but not to find the startup code
7116itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
7117code.
7118
7119To run Guile without installing it, build it in the normal way, and
7120then set the environment variable `SCHEME_LOAD_PATH' to a
7121colon-separated list of directories, including the top-level directory
7122of the Guile sources. For example, if you unpacked Guile so that the
7123full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
7124you might say
7125
7126 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
7127
c6486f8a 7128
4b521edb
JB
7129** Guile's read-eval-print loop no longer prints #<unspecified>
7130results. If the user wants to see this, she can evaluate the
7131expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 7132file.
6685dc83 7133
4b521edb
JB
7134** Guile no longer shows backtraces by default when an error occurs;
7135however, it does display a message saying how to get one, and how to
7136request that they be displayed by default. After an error, evaluate
7137 (backtrace)
7138to see a backtrace, and
7139 (debug-enable 'backtrace)
7140to see them by default.
6685dc83 7141
6685dc83 7142
d9fb83d9 7143
4b521edb
JB
7144* Changes to Guile Scheme:
7145
7146** Guile now distinguishes between #f and the empty list.
7147
7148This is for compatibility with the IEEE standard, the (possibly)
7149upcoming Revised^5 Report on Scheme, and many extant Scheme
7150implementations.
7151
7152Guile used to have #f and '() denote the same object, to make Scheme's
7153type system more compatible with Emacs Lisp's. However, the change
7154caused too much trouble for Scheme programmers, and we found another
7155way to reconcile Emacs Lisp with Scheme that didn't require this.
7156
7157
7158** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
7159counterparts, delq!, delv!, and delete!, now remove all matching
7160elements from the list, not just the first. This matches the behavior
7161of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
7162functions which inspired them.
7163
7164I recognize that this change may break code in subtle ways, but it
7165seems best to make the change before the FSF's first Guile release,
7166rather than after.
7167
7168
4b521edb 7169** The compiled-library-path function has been deleted from libguile.
6685dc83 7170
4b521edb 7171** The facilities for loading Scheme source files have changed.
c6486f8a 7172
4b521edb 7173*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
7174for Scheme code. Its value is a list of strings, each of which names
7175a directory.
7176
4b521edb
JB
7177*** The variable %load-extensions now tells Guile which extensions to
7178try appending to a filename when searching the load path. Its value
7179is a list of strings. Its default value is ("" ".scm").
7180
7181*** (%search-load-path FILENAME) searches the directories listed in the
7182value of the %load-path variable for a Scheme file named FILENAME,
7183with all the extensions listed in %load-extensions. If it finds a
7184match, then it returns its full filename. If FILENAME is absolute, it
7185returns it unchanged. Otherwise, it returns #f.
6685dc83 7186
4b521edb
JB
7187%search-load-path will not return matches that refer to directories.
7188
7189*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
7190uses %seach-load-path to find a file named FILENAME, and loads it if
7191it finds it. If it can't read FILENAME for any reason, it throws an
7192error.
6685dc83
JB
7193
7194The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
7195`read' function.
7196
7197*** load uses the same searching semantics as primitive-load.
7198
7199*** The functions %try-load, try-load-with-path, %load, load-with-path,
7200basic-try-load-with-path, basic-load-with-path, try-load-module-with-
7201path, and load-module-with-path have been deleted. The functions
7202above should serve their purposes.
7203
7204*** If the value of the variable %load-hook is a procedure,
7205`primitive-load' applies its value to the name of the file being
7206loaded (without the load path directory name prepended). If its value
7207is #f, it is ignored. Otherwise, an error occurs.
7208
7209This is mostly useful for printing load notification messages.
7210
7211
7212** The function `eval!' is no longer accessible from the scheme level.
7213We can't allow operations which introduce glocs into the scheme level,
7214because Guile's type system can't handle these as data. Use `eval' or
7215`read-and-eval!' (see below) as replacement.
7216
7217** The new function read-and-eval! reads an expression from PORT,
7218evaluates it, and returns the result. This is more efficient than
7219simply calling `read' and `eval', since it is not necessary to make a
7220copy of the expression for the evaluator to munge.
7221
7222Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
7223for the `read' function.
7224
7225
7226** The function `int?' has been removed; its definition was identical
7227to that of `integer?'.
7228
7229** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
7230use the R4RS names for these functions.
7231
7232** The function object-properties no longer returns the hash handle;
7233it simply returns the object's property list.
7234
7235** Many functions have been changed to throw errors, instead of
7236returning #f on failure. The point of providing exception handling in
7237the language is to simplify the logic of user code, but this is less
7238useful if Guile's primitives don't throw exceptions.
7239
7240** The function `fileno' has been renamed from `%fileno'.
7241
7242** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
7243
7244
7245* Changes to Guile's C interface:
7246
7247** The library's initialization procedure has been simplified.
7248scm_boot_guile now has the prototype:
7249
7250void scm_boot_guile (int ARGC,
7251 char **ARGV,
7252 void (*main_func) (),
7253 void *closure);
7254
7255scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
7256MAIN_FUNC should do all the work of the program (initializing other
7257packages, reading user input, etc.) before returning. When MAIN_FUNC
7258returns, call exit (0); this function never returns. If you want some
7259other exit value, MAIN_FUNC may call exit itself.
7260
7261scm_boot_guile arranges for program-arguments to return the strings
7262given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
7263scm_set_program_arguments with the final list, so Scheme code will
7264know which arguments have been processed.
7265
7266scm_boot_guile establishes a catch-all catch handler which prints an
7267error message and exits the process. This means that Guile exits in a
7268coherent way when system errors occur and the user isn't prepared to
7269handle it. If the user doesn't like this behavior, they can establish
7270their own universal catcher in MAIN_FUNC to shadow this one.
7271
7272Why must the caller do all the real work from MAIN_FUNC? The garbage
7273collector assumes that all local variables of type SCM will be above
7274scm_boot_guile's stack frame on the stack. If you try to manipulate
7275SCM values after this function returns, it's the luck of the draw
7276whether the GC will be able to find the objects you allocate. So,
7277scm_boot_guile function exits, rather than returning, to discourage
7278people from making that mistake.
7279
7280The IN, OUT, and ERR arguments were removed; there are other
7281convenient ways to override these when desired.
7282
7283The RESULT argument was deleted; this function should never return.
7284
7285The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
7286general.
7287
7288
7289** Guile's header files should no longer conflict with your system's
7290header files.
7291
7292In order to compile code which #included <libguile.h>, previous
7293versions of Guile required you to add a directory containing all the
7294Guile header files to your #include path. This was a problem, since
7295Guile's header files have names which conflict with many systems'
7296header files.
7297
7298Now only <libguile.h> need appear in your #include path; you must
7299refer to all Guile's other header files as <libguile/mumble.h>.
7300Guile's installation procedure puts libguile.h in $(includedir), and
7301the rest in $(includedir)/libguile.
7302
7303
7304** Two new C functions, scm_protect_object and scm_unprotect_object,
7305have been added to the Guile library.
7306
7307scm_protect_object (OBJ) protects OBJ from the garbage collector.
7308OBJ will not be freed, even if all other references are dropped,
7309until someone does scm_unprotect_object (OBJ). Both functions
7310return OBJ.
7311
7312Note that calls to scm_protect_object do not nest. You can call
7313scm_protect_object any number of times on a given object, and the
7314next call to scm_unprotect_object will unprotect it completely.
7315
7316Basically, scm_protect_object and scm_unprotect_object just
7317maintain a list of references to things. Since the GC knows about
7318this list, all objects it mentions stay alive. scm_protect_object
7319adds its argument to the list; scm_unprotect_object remove its
7320argument from the list.
7321
7322
7323** scm_eval_0str now returns the value of the last expression
7324evaluated.
7325
7326** The new function scm_read_0str reads an s-expression from a
7327null-terminated string, and returns it.
7328
7329** The new function `scm_stdio_to_port' converts a STDIO file pointer
7330to a Scheme port object.
7331
7332** The new function `scm_set_program_arguments' allows C code to set
e80c8fea 7333the value returned by the Scheme `program-arguments' function.
6685dc83 7334
6685dc83 7335\f
1a1945be
JB
7336Older changes:
7337
7338* Guile no longer includes sophisticated Tcl/Tk support.
7339
7340The old Tcl/Tk support was unsatisfying to us, because it required the
7341user to link against the Tcl library, as well as Tk and Guile. The
7342interface was also un-lispy, in that it preserved Tcl/Tk's practice of
7343referring to widgets by names, rather than exporting widgets to Scheme
7344code as a special datatype.
7345
7346In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
7347maintainers described some very interesting changes in progress to the
7348Tcl/Tk internals, which would facilitate clean interfaces between lone
7349Tk and other interpreters --- even for garbage-collected languages
7350like Scheme. They expected the new Tk to be publicly available in the
7351fall of 1996.
7352
7353Since it seems that Guile might soon have a new, cleaner interface to
7354lone Tk, and that the old Guile/Tk glue code would probably need to be
7355completely rewritten, we (Jim Blandy and Richard Stallman) have
7356decided not to support the old code. We'll spend the time instead on
7357a good interface to the newer Tk, as soon as it is available.
5c54da76 7358
8512dea6 7359Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 7360
5c54da76
JB
7361\f
7362Copyright information:
7363
4f416616 7364Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
5c54da76
JB
7365
7366 Permission is granted to anyone to make or distribute verbatim copies
7367 of this document as received, in any medium, provided that the
7368 copyright notice and this permission notice are preserved,
7369 thus giving the recipient permission to redistribute in turn.
7370
7371 Permission is granted to distribute modified versions
7372 of this document, or of portions of it,
7373 under the above conditions, provided also that they
7374 carry prominent notices stating who last changed them.
7375
48d224d7
JB
7376\f
7377Local variables:
7378mode: outline
7379paragraph-separate: "[ \f]*$"
7380end: