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