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