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