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