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