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