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