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