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