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