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