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