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