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