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