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