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