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