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