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