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