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