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