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