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