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