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