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