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