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