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