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