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