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