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