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