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