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