*** empty log message ***
[bpt/guile.git] / NEWS
1 Guile NEWS --- history of user-visible changes. -*- text -*-
2 Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 See the end for copying conditions.
4
5 Please send Guile bug reports to bug-guile@gnu.org.
6 \f
7 Changes since Guile 1.3:
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 ** The procedure truncate-file now works on string ports as well
993 as file ports. If the size argument is omitted, the current
994 file position is now used.
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 smob interface
1067
1068 The interface for creating smobs has changed. For documentation, see
1069 data-rep.info (made from guile-core/doc/data-rep.texi).
1070
1071 *** Deprecated function: SCM scm_newsmob (scm_smobfuns *)
1072
1073 >>> This function will be removed in 1.3.4. <<<
1074
1075 It is replaced by:
1076
1077 *** Function: SCM scm_make_smob_type (const char *name, scm_sizet size)
1078 This function adds a new smob type, named NAME, with instance size
1079 SIZE to the system. The return value is a tag that is used in
1080 creating instances of the type. If SIZE is 0, then no memory will
1081 be allocated when instances of the smob are created, and nothing
1082 will be freed by the default free function.
1083
1084 *** Function: void scm_set_smob_mark (long tc, SCM (*mark) (SCM))
1085 This function sets the smob marking procedure for the smob type
1086 specified by the tag TC. TC is the tag returned by
1087 `scm_make_smob_type'.
1088
1089 *** Function: void scm_set_smob_free (long tc, SCM (*mark) (SCM))
1090 This function sets the smob freeing procedure for the smob type
1091 specified by the tag TC. TC is the tag returned by
1092 `scm_make_smob_type'.
1093
1094 *** Function: void scm_set_smob_print (tc, print)
1095
1096 - Function: void scm_set_smob_print (long tc,
1097 scm_sizet (*print) (SCM,
1098 SCM,
1099 scm_print_state *))
1100
1101 This function sets the smob printing procedure for the smob type
1102 specified by the tag TC. TC is the tag returned by
1103 `scm_make_smob_type'.
1104
1105 *** Function: void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM))
1106 This function sets the smob equality-testing predicate for the
1107 smob type specified by the tag TC. TC is the tag returned by
1108 `scm_make_smob_type'.
1109
1110 *** Macro: void SCM_NEWSMOB (SCM var, long tc, void *data)
1111 Make VALUE contain a smob instance of the type with type code TC and
1112 smob data DATA. VALUE must be previously declared as C type `SCM'.
1113
1114 *** Macro: fn_returns SCM_RETURN_NEWSMOB (long tc, void *data)
1115 This macro expands to a block of code that creates a smob instance
1116 of the type with type code TC and smob data DATA, and returns that
1117 `SCM' value. It should be the last piece of code in a block.
1118
1119 ** The interfaces for using I/O ports and implementing port types
1120 (ptobs) have changed significantly. The new interface is based on
1121 shared access to buffers and a new set of ptob procedures.
1122
1123 *** scm_newptob has been removed
1124
1125 It is replaced by:
1126
1127 *** Function: SCM scm_make_port_type (type_name, fill_buffer, write_flush)
1128
1129 - Function: SCM scm_make_port_type (char *type_name,
1130 int (*fill_buffer) (SCM port),
1131 void (*write_flush) (SCM port));
1132
1133 Similarly to the new smob interface, there is a set of function
1134 setters by which the user can customize the behaviour of his port
1135 type. See ports.h (scm_set_ptob_XXX).
1136
1137 ** scm_strport_to_string: New function: creates a new string from
1138 a string port's buffer.
1139
1140 ** Plug in interface for random number generators
1141 The variable `scm_the_rng' in random.c contains a value and three
1142 function pointers which together define the current random number
1143 generator being used by the Scheme level interface and the random
1144 number library functions.
1145
1146 The user is free to replace the default generator with the generator
1147 of his own choice.
1148
1149 *** Variable: size_t scm_the_rng.rstate_size
1150 The size of the random state type used by the current RNG
1151 measured in chars.
1152
1153 *** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE)
1154 Given the random STATE, return 32 random bits.
1155
1156 *** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N)
1157 Seed random state STATE using string S of length N.
1158
1159 *** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE)
1160 Given random state STATE, return a malloced copy.
1161
1162 ** Default RNG
1163 The default RNG is the MWC (Multiply With Carry) random number
1164 generator described by George Marsaglia at the Department of
1165 Statistics and Supercomputer Computations Research Institute, The
1166 Florida State University (http://stat.fsu.edu/~geo).
1167
1168 It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and
1169 passes all tests in the DIEHARD test suite
1170 (http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits
1171 costs one multiply and one add on platforms which either supports long
1172 longs (gcc does this on most systems) or have 64 bit longs. The cost
1173 is four multiply on other systems but this can be optimized by writing
1174 scm_i_uniform32 in assembler.
1175
1176 These functions are provided through the scm_the_rng interface for use
1177 by libguile and the application.
1178
1179 *** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE)
1180 Given the random STATE, return 32 random bits.
1181 Don't use this function directly. Instead go through the plugin
1182 interface (see "Plug in interface" above).
1183
1184 *** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N)
1185 Initialize STATE using SEED of length N.
1186
1187 *** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE)
1188 Return a malloc:ed copy of STATE. This function can easily be re-used
1189 in the interfaces to other RNGs.
1190
1191 ** Random number library functions
1192 These functions use the current RNG through the scm_the_rng interface.
1193 It might be a good idea to use these functions from your C code so
1194 that only one random generator is used by all code in your program.
1195
1196 You can get the default random state using:
1197
1198 *** Variable: SCM scm_var_random_state
1199 Contains the vcell of the Scheme variable "*random-state*" which is
1200 used as default state by all random number functions in the Scheme
1201 level interface.
1202
1203 Example:
1204
1205 double x = scm_i_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state)));
1206
1207 *** Function: double scm_i_uniform01 (scm_rstate *STATE)
1208 Return a sample from the uniform(0,1) distribution.
1209
1210 *** Function: double scm_i_normal01 (scm_rstate *STATE)
1211 Return a sample from the normal(0,1) distribution.
1212
1213 *** Function: double scm_i_exp1 (scm_rstate *STATE)
1214 Return a sample from the exp(1) distribution.
1215
1216 *** Function: unsigned long scm_i_random (unsigned long M, scm_rstate *STATE)
1217 Return a sample from the discrete uniform(0,M) distribution.
1218
1219
1220 \f
1221 Changes in Guile 1.3 (released Monday, October 19, 1998):
1222
1223 * Changes to the distribution
1224
1225 ** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
1226 To avoid conflicts, programs should name environment variables after
1227 themselves, except when there's a common practice establishing some
1228 other convention.
1229
1230 For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
1231 giving the former precedence, and printing a warning message if the
1232 latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
1233
1234 ** The header files related to multi-byte characters have been removed.
1235 They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
1236 which referred to these explicitly will probably need to be rewritten,
1237 since the support for the variant string types has been removed; see
1238 below.
1239
1240 ** The header files append.h and sequences.h have been removed. These
1241 files implemented non-R4RS operations which would encourage
1242 non-portable programming style and less easy-to-read code.
1243
1244 * Changes to the stand-alone interpreter
1245
1246 ** New procedures have been added to implement a "batch mode":
1247
1248 *** Function: batch-mode?
1249
1250 Returns a boolean indicating whether the interpreter is in batch
1251 mode.
1252
1253 *** Function: set-batch-mode?! ARG
1254
1255 If ARG is true, switches the interpreter to batch mode. The `#f'
1256 case has not been implemented.
1257
1258 ** Guile now provides full command-line editing, when run interactively.
1259 To use this feature, you must have the readline library installed.
1260 The Guile build process will notice it, and automatically include
1261 support for it.
1262
1263 The readline library is available via anonymous FTP from any GNU
1264 mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
1265
1266 ** the-last-stack is now a fluid.
1267
1268 * Changes to the procedure for linking libguile with your programs
1269
1270 ** You can now use the `guile-config' utility to build programs that use Guile.
1271
1272 Guile now includes a command-line utility called `guile-config', which
1273 can provide information about how to compile and link programs that
1274 use Guile.
1275
1276 *** `guile-config compile' prints any C compiler flags needed to use Guile.
1277 You should include this command's output on the command line you use
1278 to compile C or C++ code that #includes the Guile header files. It's
1279 usually just a `-I' flag to help the compiler find the Guile headers.
1280
1281
1282 *** `guile-config link' prints any linker flags necessary to link with Guile.
1283
1284 This command writes to its standard output a list of flags which you
1285 must pass to the linker to link your code against the Guile library.
1286 The flags include '-lguile' itself, any other libraries the Guile
1287 library depends upon, and any `-L' flags needed to help the linker
1288 find those libraries.
1289
1290 For example, here is a Makefile rule that builds a program named 'foo'
1291 from the object files ${FOO_OBJECTS}, and links them against Guile:
1292
1293 foo: ${FOO_OBJECTS}
1294 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
1295
1296 Previous Guile releases recommended that you use autoconf to detect
1297 which of a predefined set of libraries were present on your system.
1298 It is more robust to use `guile-config', since it records exactly which
1299 libraries the installed Guile library requires.
1300
1301 This was originally called `build-guile', but was renamed to
1302 `guile-config' before Guile 1.3 was released, to be consistent with
1303 the analogous script for the GTK+ GUI toolkit, which is called
1304 `gtk-config'.
1305
1306
1307 ** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
1308
1309 If you are using the GNU autoconf package to configure your program,
1310 you can use the GUILE_FLAGS autoconf macro to call `guile-config'
1311 (described above) and gather the necessary values for use in your
1312 Makefiles.
1313
1314 The GUILE_FLAGS macro expands to configure script code which runs the
1315 `guile-config' script, to find out where Guile's header files and
1316 libraries are installed. It sets two variables, marked for
1317 substitution, as by AC_SUBST.
1318
1319 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
1320 code that uses Guile header files. This is almost always just a
1321 -I flag.
1322
1323 GUILE_LDFLAGS --- flags to pass to the linker to link a
1324 program against Guile. This includes `-lguile' for the Guile
1325 library itself, any libraries that Guile itself requires (like
1326 -lqthreads), and so on. It may also include a -L flag to tell the
1327 compiler where to find the libraries.
1328
1329 GUILE_FLAGS is defined in the file guile.m4, in the top-level
1330 directory of the Guile distribution. You can copy it into your
1331 package's aclocal.m4 file, and then use it in your configure.in file.
1332
1333 If you are using the `aclocal' program, distributed with GNU automake,
1334 to maintain your aclocal.m4 file, the Guile installation process
1335 installs guile.m4 where aclocal will find it. All you need to do is
1336 use GUILE_FLAGS in your configure.in file, and then run `aclocal';
1337 this will copy the definition of GUILE_FLAGS into your aclocal.m4
1338 file.
1339
1340
1341 * Changes to Scheme functions and syntax
1342
1343 ** Multi-byte strings have been removed, as have multi-byte and wide
1344 ports. We felt that these were the wrong approach to
1345 internationalization support.
1346
1347 ** New function: readline [PROMPT]
1348 Read a line from the terminal, and allow the user to edit it,
1349 prompting with PROMPT. READLINE provides a large set of Emacs-like
1350 editing commands, lets the user recall previously typed lines, and
1351 works on almost every kind of terminal, including dumb terminals.
1352
1353 READLINE assumes that the cursor is at the beginning of the line when
1354 it is invoked. Thus, you can't print a prompt yourself, and then call
1355 READLINE; you need to package up your prompt as a string, pass it to
1356 the function, and let READLINE print the prompt itself. This is
1357 because READLINE needs to know the prompt's screen width.
1358
1359 For Guile to provide this function, you must have the readline
1360 library, version 2.1 or later, installed on your system. Readline is
1361 available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
1362 any GNU mirror site.
1363
1364 See also ADD-HISTORY function.
1365
1366 ** New function: add-history STRING
1367 Add STRING as the most recent line in the history used by the READLINE
1368 command. READLINE does not add lines to the history itself; you must
1369 call ADD-HISTORY to make previous input available to the user.
1370
1371 ** The behavior of the read-line function has changed.
1372
1373 This function now uses standard C library functions to read the line,
1374 for speed. This means that it doesn not respect the value of
1375 scm-line-incrementors; it assumes that lines are delimited with
1376 #\newline.
1377
1378 (Note that this is read-line, the function that reads a line of text
1379 from a port, not readline, the function that reads a line from a
1380 terminal, providing full editing capabilities.)
1381
1382 ** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
1383
1384 This module provides some simple argument parsing. It exports one
1385 function:
1386
1387 Function: getopt-gnu-style ARG-LS
1388 Parse a list of program arguments into an alist of option
1389 descriptions.
1390
1391 Each item in the list of program arguments is examined to see if
1392 it meets the syntax of a GNU long-named option. An argument like
1393 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
1394 returned alist, where MUMBLE is a keyword object with the same
1395 name as the argument. An argument like `--MUMBLE=FROB' produces
1396 an element of the form (MUMBLE . FROB), where FROB is a string.
1397
1398 As a special case, the returned alist also contains a pair whose
1399 car is the symbol `rest'. The cdr of this pair is a list
1400 containing all the items in the argument list that are not options
1401 of the form mentioned above.
1402
1403 The argument `--' is treated specially: all items in the argument
1404 list appearing after such an argument are not examined, and are
1405 returned in the special `rest' list.
1406
1407 This function does not parse normal single-character switches.
1408 You will need to parse them out of the `rest' list yourself.
1409
1410 ** The read syntax for byte vectors and short vectors has changed.
1411
1412 Instead of #bytes(...), write #y(...).
1413
1414 Instead of #short(...), write #h(...).
1415
1416 This may seem nutty, but, like the other uniform vectors, byte vectors
1417 and short vectors want to have the same print and read syntax (and,
1418 more basic, want to have read syntax!). Changing the read syntax to
1419 use multiple characters after the hash sign breaks with the
1420 conventions used in R5RS and the conventions used for the other
1421 uniform vectors. It also introduces complexity in the current reader,
1422 both on the C and Scheme levels. (The Right solution is probably to
1423 change the syntax and prototypes for uniform vectors entirely.)
1424
1425
1426 ** The new module (ice-9 session) provides useful interactive functions.
1427
1428 *** New procedure: (apropos REGEXP OPTION ...)
1429
1430 Display a list of top-level variables whose names match REGEXP, and
1431 the modules they are imported from. Each OPTION should be one of the
1432 following symbols:
1433
1434 value --- Show the value of each matching variable.
1435 shadow --- Show bindings shadowed by subsequently imported modules.
1436 full --- Same as both `shadow' and `value'.
1437
1438 For example:
1439
1440 guile> (apropos "trace" 'full)
1441 debug: trace #<procedure trace args>
1442 debug: untrace #<procedure untrace args>
1443 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
1444 the-scm-module: before-backtrace-hook ()
1445 the-scm-module: backtrace #<primitive-procedure backtrace>
1446 the-scm-module: after-backtrace-hook ()
1447 the-scm-module: has-shown-backtrace-hint? #f
1448 guile>
1449
1450 ** There are new functions and syntax for working with macros.
1451
1452 Guile implements macros as a special object type. Any variable whose
1453 top-level binding is a macro object acts as a macro. The macro object
1454 specifies how the expression should be transformed before evaluation.
1455
1456 *** Macro objects now print in a reasonable way, resembling procedures.
1457
1458 *** New function: (macro? OBJ)
1459 True iff OBJ is a macro object.
1460
1461 *** New function: (primitive-macro? OBJ)
1462 Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
1463 macro transformers, implemented in eval.c rather than Scheme code.
1464
1465 Why do we have this function?
1466 - For symmetry with procedure? and primitive-procedure?,
1467 - to allow custom print procedures to tell whether a macro is
1468 primitive, and display it differently, and
1469 - to allow compilers and user-written evaluators to distinguish
1470 builtin special forms from user-defined ones, which could be
1471 compiled.
1472
1473 *** New function: (macro-type OBJ)
1474 Return a value indicating what kind of macro OBJ is. Possible return
1475 values are:
1476
1477 The symbol `syntax' --- a macro created by procedure->syntax.
1478 The symbol `macro' --- a macro created by procedure->macro.
1479 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
1480 The boolean #f --- if OBJ is not a macro object.
1481
1482 *** New function: (macro-name MACRO)
1483 Return the name of the macro object MACRO's procedure, as returned by
1484 procedure-name.
1485
1486 *** New function: (macro-transformer MACRO)
1487 Return the transformer procedure for MACRO.
1488
1489 *** New syntax: (use-syntax MODULE ... TRANSFORMER)
1490
1491 Specify a new macro expander to use in the current module. Each
1492 MODULE is a module name, with the same meaning as in the `use-modules'
1493 form; each named module's exported bindings are added to the current
1494 top-level environment. TRANSFORMER is an expression evaluated in the
1495 resulting environment which must yield a procedure to use as the
1496 module's eval transformer: every expression evaluated in this module
1497 is passed to this function, and the result passed to the Guile
1498 interpreter.
1499
1500 *** macro-eval! is removed. Use local-eval instead.
1501
1502 ** Some magic has been added to the printer to better handle user
1503 written printing routines (like record printers, closure printers).
1504
1505 The problem is that these user written routines must have access to
1506 the current `print-state' to be able to handle fancy things like
1507 detection of circular references. These print-states have to be
1508 passed to the builtin printing routines (display, write, etc) to
1509 properly continue the print chain.
1510
1511 We didn't want to change all existing print code so that it
1512 explicitly passes thru a print state in addition to a port. Instead,
1513 we extented the possible values that the builtin printing routines
1514 accept as a `port'. In addition to a normal port, they now also take
1515 a pair of a normal port and a print-state. Printing will go to the
1516 port and the print-state will be used to control the detection of
1517 circular references, etc. If the builtin function does not care for a
1518 print-state, it is simply ignored.
1519
1520 User written callbacks are now called with such a pair as their
1521 `port', but because every function now accepts this pair as a PORT
1522 argument, you don't have to worry about that. In fact, it is probably
1523 safest to not check for these pairs.
1524
1525 However, it is sometimes necessary to continue a print chain on a
1526 different port, for example to get a intermediate string
1527 representation of the printed value, mangle that string somehow, and
1528 then to finally print the mangled string. Use the new function
1529
1530 inherit-print-state OLD-PORT NEW-PORT
1531
1532 for this. It constructs a new `port' that prints to NEW-PORT but
1533 inherits the print-state of OLD-PORT.
1534
1535 ** struct-vtable-offset renamed to vtable-offset-user
1536
1537 ** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
1538
1539 ** There is now a fourth (optional) argument to make-vtable-vtable and
1540 make-struct when constructing new types (vtables). This argument
1541 initializes field vtable-index-printer of the vtable.
1542
1543 ** The detection of circular references has been extended to structs.
1544 That is, a structure that -- in the process of being printed -- prints
1545 itself does not lead to infinite recursion.
1546
1547 ** There is now some basic support for fluids. Please read
1548 "libguile/fluid.h" to find out more. It is accessible from Scheme with
1549 the following functions and macros:
1550
1551 Function: make-fluid
1552
1553 Create a new fluid object. Fluids are not special variables or
1554 some other extension to the semantics of Scheme, but rather
1555 ordinary Scheme objects. You can store them into variables (that
1556 are still lexically scoped, of course) or into any other place you
1557 like. Every fluid has a initial value of `#f'.
1558
1559 Function: fluid? OBJ
1560
1561 Test whether OBJ is a fluid.
1562
1563 Function: fluid-ref FLUID
1564 Function: fluid-set! FLUID VAL
1565
1566 Access/modify the fluid FLUID. Modifications are only visible
1567 within the current dynamic root (that includes threads).
1568
1569 Function: with-fluids* FLUIDS VALUES THUNK
1570
1571 FLUIDS is a list of fluids and VALUES a corresponding list of
1572 values for these fluids. Before THUNK gets called the values are
1573 installed in the fluids and the old values of the fluids are
1574 saved in the VALUES list. When the flow of control leaves THUNK
1575 or reenters it, the values get swapped again. You might think of
1576 this as a `safe-fluid-excursion'. Note that the VALUES list is
1577 modified by `with-fluids*'.
1578
1579 Macro: with-fluids ((FLUID VALUE) ...) FORM ...
1580
1581 The same as `with-fluids*' but with a different syntax. It looks
1582 just like `let', but both FLUID and VALUE are evaluated. Remember,
1583 fluids are not special variables but ordinary objects. FLUID
1584 should evaluate to a fluid.
1585
1586 ** Changes to system call interfaces:
1587
1588 *** close-port, close-input-port and close-output-port now return a
1589 boolean instead of an `unspecified' object. #t means that the port
1590 was successfully closed, while #f means it was already closed. It is
1591 also now possible for these procedures to raise an exception if an
1592 error occurs (some errors from write can be delayed until close.)
1593
1594 *** the first argument to chmod, fcntl, ftell and fseek can now be a
1595 file descriptor.
1596
1597 *** the third argument to fcntl is now optional.
1598
1599 *** the first argument to chown can now be a file descriptor or a port.
1600
1601 *** the argument to stat can now be a port.
1602
1603 *** The following new procedures have been added (most use scsh
1604 interfaces):
1605
1606 *** procedure: close PORT/FD
1607 Similar to close-port (*note close-port: Closing Ports.), but also
1608 works on file descriptors. A side effect of closing a file
1609 descriptor is that any ports using that file descriptor are moved
1610 to a different file descriptor and have their revealed counts set
1611 to zero.
1612
1613 *** procedure: port->fdes PORT
1614 Returns the integer file descriptor underlying PORT. As a side
1615 effect the revealed count of PORT is incremented.
1616
1617 *** procedure: fdes->ports FDES
1618 Returns a list of existing ports which have FDES as an underlying
1619 file descriptor, without changing their revealed counts.
1620
1621 *** procedure: fdes->inport FDES
1622 Returns an existing input port which has FDES as its underlying
1623 file descriptor, if one exists, and increments its revealed count.
1624 Otherwise, returns a new input port with a revealed count of 1.
1625
1626 *** procedure: fdes->outport FDES
1627 Returns an existing output port which has FDES as its underlying
1628 file descriptor, if one exists, and increments its revealed count.
1629 Otherwise, returns a new output port with a revealed count of 1.
1630
1631 The next group of procedures perform a `dup2' system call, if NEWFD
1632 (an integer) is supplied, otherwise a `dup'. The file descriptor to be
1633 duplicated can be supplied as an integer or contained in a port. The
1634 type of value returned varies depending on which procedure is used.
1635
1636 All procedures also have the side effect when performing `dup2' that
1637 any ports using NEWFD are moved to a different file descriptor and have
1638 their revealed counts set to zero.
1639
1640 *** procedure: dup->fdes PORT/FD [NEWFD]
1641 Returns an integer file descriptor.
1642
1643 *** procedure: dup->inport PORT/FD [NEWFD]
1644 Returns a new input port using the new file descriptor.
1645
1646 *** procedure: dup->outport PORT/FD [NEWFD]
1647 Returns a new output port using the new file descriptor.
1648
1649 *** procedure: dup PORT/FD [NEWFD]
1650 Returns a new port if PORT/FD is a port, with the same mode as the
1651 supplied port, otherwise returns an integer file descriptor.
1652
1653 *** procedure: dup->port PORT/FD MODE [NEWFD]
1654 Returns a new port using the new file descriptor. MODE supplies a
1655 mode string for the port (*note open-file: File Ports.).
1656
1657 *** procedure: setenv NAME VALUE
1658 Modifies the environment of the current process, which is also the
1659 default environment inherited by child processes.
1660
1661 If VALUE is `#f', then NAME is removed from the environment.
1662 Otherwise, the string NAME=VALUE is added to the environment,
1663 replacing any existing string with name matching NAME.
1664
1665 The return value is unspecified.
1666
1667 *** procedure: truncate-file OBJ SIZE
1668 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
1669 can be a string containing a file name or an integer file
1670 descriptor or port open for output on the file. The underlying
1671 system calls are `truncate' and `ftruncate'.
1672
1673 The return value is unspecified.
1674
1675 *** procedure: setvbuf PORT MODE [SIZE]
1676 Set the buffering mode for PORT. MODE can be:
1677 `_IONBF'
1678 non-buffered
1679
1680 `_IOLBF'
1681 line buffered
1682
1683 `_IOFBF'
1684 block buffered, using a newly allocated buffer of SIZE bytes.
1685 However if SIZE is zero or unspecified, the port will be made
1686 non-buffered.
1687
1688 This procedure should not be used after I/O has been performed with
1689 the port.
1690
1691 Ports are usually block buffered by default, with a default buffer
1692 size. Procedures e.g., *Note open-file: File Ports, which accept a
1693 mode string allow `0' to be added to request an unbuffered port.
1694
1695 *** procedure: fsync PORT/FD
1696 Copies any unwritten data for the specified output file descriptor
1697 to disk. If PORT/FD is a port, its buffer is flushed before the
1698 underlying file descriptor is fsync'd. The return value is
1699 unspecified.
1700
1701 *** procedure: open-fdes PATH FLAGS [MODES]
1702 Similar to `open' but returns a file descriptor instead of a port.
1703
1704 *** procedure: execle PATH ENV [ARG] ...
1705 Similar to `execl', but the environment of the new process is
1706 specified by ENV, which must be a list of strings as returned by
1707 the `environ' procedure.
1708
1709 This procedure is currently implemented using the `execve' system
1710 call, but we call it `execle' because of its Scheme calling
1711 interface.
1712
1713 *** procedure: strerror ERRNO
1714 Returns the Unix error message corresponding to ERRNO, an integer.
1715
1716 *** procedure: primitive-exit [STATUS]
1717 Terminate the current process without unwinding the Scheme stack.
1718 This is would typically be useful after a fork. The exit status
1719 is STATUS if supplied, otherwise zero.
1720
1721 *** procedure: times
1722 Returns an object with information about real and processor time.
1723 The following procedures accept such an object as an argument and
1724 return a selected component:
1725
1726 `tms:clock'
1727 The current real time, expressed as time units relative to an
1728 arbitrary base.
1729
1730 `tms:utime'
1731 The CPU time units used by the calling process.
1732
1733 `tms:stime'
1734 The CPU time units used by the system on behalf of the
1735 calling process.
1736
1737 `tms:cutime'
1738 The CPU time units used by terminated child processes of the
1739 calling process, whose status has been collected (e.g., using
1740 `waitpid').
1741
1742 `tms:cstime'
1743 Similarly, the CPU times units used by the system on behalf of
1744 terminated child processes.
1745
1746 ** Removed: list-length
1747 ** Removed: list-append, list-append!
1748 ** Removed: list-reverse, list-reverse!
1749
1750 ** array-map renamed to array-map!
1751
1752 ** serial-array-map renamed to serial-array-map!
1753
1754 ** catch doesn't take #f as first argument any longer
1755
1756 Previously, it was possible to pass #f instead of a key to `catch'.
1757 That would cause `catch' to pass a jump buffer object to the procedure
1758 passed as second argument. The procedure could then use this jump
1759 buffer objekt as an argument to throw.
1760
1761 This mechanism has been removed since its utility doesn't motivate the
1762 extra complexity it introduces.
1763
1764 ** The `#/' notation for lists now provokes a warning message from Guile.
1765 This syntax will be removed from Guile in the near future.
1766
1767 To disable the warning message, set the GUILE_HUSH environment
1768 variable to any non-empty value.
1769
1770 ** The newline character now prints as `#\newline', following the
1771 normal Scheme notation, not `#\nl'.
1772
1773 * Changes to the gh_ interface
1774
1775 ** The gh_enter function now takes care of loading the Guile startup files.
1776 gh_enter works by calling scm_boot_guile; see the remarks below.
1777
1778 ** Function: void gh_write (SCM x)
1779
1780 Write the printed representation of the scheme object x to the current
1781 output port. Corresponds to the scheme level `write'.
1782
1783 ** gh_list_length renamed to gh_length.
1784
1785 ** vector handling routines
1786
1787 Several major changes. In particular, gh_vector() now resembles
1788 (vector ...) (with a caveat -- see manual), and gh_make_vector() now
1789 exists and behaves like (make-vector ...). gh_vset() and gh_vref()
1790 have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
1791 vector-related gh_ functions have been implemented.
1792
1793 ** pair and list routines
1794
1795 Implemented several of the R4RS pair and list functions that were
1796 missing.
1797
1798 ** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
1799
1800 New function. Converts double arrays back and forth between Scheme
1801 and C.
1802
1803 * Changes to the scm_ interface
1804
1805 ** The function scm_boot_guile now takes care of loading the startup files.
1806
1807 Guile's primary initialization function, scm_boot_guile, now takes
1808 care of loading `boot-9.scm', in the `ice-9' module, to initialize
1809 Guile, define the module system, and put together some standard
1810 bindings. It also loads `init.scm', which is intended to hold
1811 site-specific initialization code.
1812
1813 Since Guile cannot operate properly until boot-9.scm is loaded, there
1814 is no reason to separate loading boot-9.scm from Guile's other
1815 initialization processes.
1816
1817 This job used to be done by scm_compile_shell_switches, which didn't
1818 make much sense; in particular, it meant that people using Guile for
1819 non-shell-like applications had to jump through hoops to get Guile
1820 initialized properly.
1821
1822 ** The function scm_compile_shell_switches no longer loads the startup files.
1823 Now, Guile always loads the startup files, whenever it is initialized;
1824 see the notes above for scm_boot_guile and scm_load_startup_files.
1825
1826 ** Function: scm_load_startup_files
1827 This new function takes care of loading Guile's initialization file
1828 (`boot-9.scm'), and the site initialization file, `init.scm'. Since
1829 this is always called by the Guile initialization process, it's
1830 probably not too useful to call this yourself, but it's there anyway.
1831
1832 ** The semantics of smob marking have changed slightly.
1833
1834 The smob marking function (the `mark' member of the scm_smobfuns
1835 structure) is no longer responsible for setting the mark bit on the
1836 smob. The generic smob handling code in the garbage collector will
1837 set this bit. The mark function need only ensure that any other
1838 objects the smob refers to get marked.
1839
1840 Note that this change means that the smob's GC8MARK bit is typically
1841 already set upon entry to the mark function. Thus, marking functions
1842 which look like this:
1843
1844 {
1845 if (SCM_GC8MARKP (ptr))
1846 return SCM_BOOL_F;
1847 SCM_SETGC8MARK (ptr);
1848 ... mark objects to which the smob refers ...
1849 }
1850
1851 are now incorrect, since they will return early, and fail to mark any
1852 other objects the smob refers to. Some code in the Guile library used
1853 to work this way.
1854
1855 ** The semantics of the I/O port functions in scm_ptobfuns have changed.
1856
1857 If you have implemented your own I/O port type, by writing the
1858 functions required by the scm_ptobfuns and then calling scm_newptob,
1859 you will need to change your functions slightly.
1860
1861 The functions in a scm_ptobfuns structure now expect the port itself
1862 as their argument; they used to expect the `stream' member of the
1863 port's scm_port_table structure. This allows functions in an
1864 scm_ptobfuns structure to easily access the port's cell (and any flags
1865 it its CAR), and the port's scm_port_table structure.
1866
1867 Guile now passes the I/O port itself as the `port' argument in the
1868 following scm_ptobfuns functions:
1869
1870 int (*free) (SCM port);
1871 int (*fputc) (int, SCM port);
1872 int (*fputs) (char *, SCM port);
1873 scm_sizet (*fwrite) SCM_P ((char *ptr,
1874 scm_sizet size,
1875 scm_sizet nitems,
1876 SCM port));
1877 int (*fflush) (SCM port);
1878 int (*fgetc) (SCM port);
1879 int (*fclose) (SCM port);
1880
1881 The interfaces to the `mark', `print', `equalp', and `fgets' methods
1882 are unchanged.
1883
1884 If you have existing code which defines its own port types, it is easy
1885 to convert your code to the new interface; simply apply SCM_STREAM to
1886 the port argument to yield the value you code used to expect.
1887
1888 Note that since both the port and the stream have the same type in the
1889 C code --- they are both SCM values --- the C compiler will not remind
1890 you if you forget to update your scm_ptobfuns functions.
1891
1892
1893 ** Function: int scm_internal_select (int fds,
1894 SELECT_TYPE *rfds,
1895 SELECT_TYPE *wfds,
1896 SELECT_TYPE *efds,
1897 struct timeval *timeout);
1898
1899 This is a replacement for the `select' function provided by the OS.
1900 It enables I/O blocking and sleeping to happen for one cooperative
1901 thread without blocking other threads. It also avoids busy-loops in
1902 these situations. It is intended that all I/O blocking and sleeping
1903 will finally go through this function. Currently, this function is
1904 only available on systems providing `gettimeofday' and `select'.
1905
1906 ** Function: SCM scm_internal_stack_catch (SCM tag,
1907 scm_catch_body_t body,
1908 void *body_data,
1909 scm_catch_handler_t handler,
1910 void *handler_data)
1911
1912 A new sibling to the other two C level `catch' functions
1913 scm_internal_catch and scm_internal_lazy_catch. Use it if you want
1914 the stack to be saved automatically into the variable `the-last-stack'
1915 (scm_the_last_stack_var) on error. This is necessary if you want to
1916 use advanced error reporting, such as calling scm_display_error and
1917 scm_display_backtrace. (They both take a stack object as argument.)
1918
1919 ** Function: SCM scm_spawn_thread (scm_catch_body_t body,
1920 void *body_data,
1921 scm_catch_handler_t handler,
1922 void *handler_data)
1923
1924 Spawns a new thread. It does a job similar to
1925 scm_call_with_new_thread but takes arguments more suitable when
1926 spawning threads from application C code.
1927
1928 ** The hook scm_error_callback has been removed. It was originally
1929 intended as a way for the user to install his own error handler. But
1930 that method works badly since it intervenes between throw and catch,
1931 thereby changing the semantics of expressions like (catch #t ...).
1932 The correct way to do it is to use one of the C level catch functions
1933 in throw.c: scm_internal_catch/lazy_catch/stack_catch.
1934
1935 ** Removed functions:
1936
1937 scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
1938 scm_list_reverse, scm_list_reverse_x
1939
1940 ** New macros: SCM_LISTn where n is one of the integers 0-9.
1941
1942 These can be used for pretty list creation from C. The idea is taken
1943 from Erick Gallesio's STk.
1944
1945 ** scm_array_map renamed to scm_array_map_x
1946
1947 ** mbstrings are now removed
1948
1949 This means that the type codes scm_tc7_mb_string and
1950 scm_tc7_mb_substring has been removed.
1951
1952 ** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
1953
1954 Since we no longer support multi-byte strings, these I/O functions
1955 have been simplified, and renamed. Here are their old names, and
1956 their new names and arguments:
1957
1958 scm_gen_putc -> void scm_putc (int c, SCM port);
1959 scm_gen_puts -> void scm_puts (char *s, SCM port);
1960 scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
1961 scm_gen_getc -> void scm_getc (SCM port);
1962
1963
1964 ** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
1965
1966 ** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
1967
1968 SCM_TYP7S now masks away the bit which distinguishes substrings from
1969 strings.
1970
1971 ** scm_catch_body_t: Backward incompatible change!
1972
1973 Body functions to scm_internal_catch and friends do not any longer
1974 take a second argument. This is because it is no longer possible to
1975 pass a #f arg to catch.
1976
1977 ** Calls to scm_protect_object and scm_unprotect now nest properly.
1978
1979 The function scm_protect_object protects its argument from being freed
1980 by the garbage collector. scm_unprotect_object removes that
1981 protection.
1982
1983 These functions now nest properly. That is, for every object O, there
1984 is a counter which scm_protect_object(O) increments and
1985 scm_unprotect_object(O) decrements, if the counter is greater than
1986 zero. Every object's counter is zero when it is first created. If an
1987 object's counter is greater than zero, the garbage collector will not
1988 reclaim its storage.
1989
1990 This allows you to use scm_protect_object in your code without
1991 worrying that some other function you call will call
1992 scm_unprotect_object, and allow it to be freed. Assuming that the
1993 functions you call are well-behaved, and unprotect only those objects
1994 they protect, you can follow the same rule and have confidence that
1995 objects will be freed only at appropriate times.
1996
1997 \f
1998 Changes in Guile 1.2 (released Tuesday, June 24 1997):
1999
2000 * Changes to the distribution
2001
2002 ** Nightly snapshots are now available from ftp.red-bean.com.
2003 The old server, ftp.cyclic.com, has been relinquished to its rightful
2004 owner.
2005
2006 Nightly snapshots of the Guile development sources are now available via
2007 anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
2008
2009 Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
2010 For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
2011
2012 ** To run Guile without installing it, the procedure has changed a bit.
2013
2014 If you used a separate build directory to compile Guile, you'll need
2015 to include the build directory in SCHEME_LOAD_PATH, as well as the
2016 source directory. See the `INSTALL' file for examples.
2017
2018 * Changes to the procedure for linking libguile with your programs
2019
2020 ** The standard Guile load path for Scheme code now includes
2021 $(datadir)/guile (usually /usr/local/share/guile). This means that
2022 you can install your own Scheme files there, and Guile will find them.
2023 (Previous versions of Guile only checked a directory whose name
2024 contained the Guile version number, so you had to re-install or move
2025 your Scheme sources each time you installed a fresh version of Guile.)
2026
2027 The load path also includes $(datadir)/guile/site; we recommend
2028 putting individual Scheme files there. If you want to install a
2029 package with multiple source files, create a directory for them under
2030 $(datadir)/guile.
2031
2032 ** Guile 1.2 will now use the Rx regular expression library, if it is
2033 installed on your system. When you are linking libguile into your own
2034 programs, this means you will have to link against -lguile, -lqt (if
2035 you configured Guile with thread support), and -lrx.
2036
2037 If you are using autoconf to generate configuration scripts for your
2038 application, the following lines should suffice to add the appropriate
2039 libraries to your link command:
2040
2041 ### Find Rx, quickthreads and libguile.
2042 AC_CHECK_LIB(rx, main)
2043 AC_CHECK_LIB(qt, main)
2044 AC_CHECK_LIB(guile, scm_shell)
2045
2046 The Guile 1.2 distribution does not contain sources for the Rx
2047 library, as Guile 1.0 did. If you want to use Rx, you'll need to
2048 retrieve it from a GNU FTP site and install it separately.
2049
2050 * Changes to Scheme functions and syntax
2051
2052 ** The dynamic linking features of Guile are now enabled by default.
2053 You can disable them by giving the `--disable-dynamic-linking' option
2054 to configure.
2055
2056 (dynamic-link FILENAME)
2057
2058 Find the object file denoted by FILENAME (a string) and link it
2059 into the running Guile application. When everything works out,
2060 return a Scheme object suitable for representing the linked object
2061 file. Otherwise an error is thrown. How object files are
2062 searched is system dependent.
2063
2064 (dynamic-object? VAL)
2065
2066 Determine whether VAL represents a dynamically linked object file.
2067
2068 (dynamic-unlink DYNOBJ)
2069
2070 Unlink the indicated object file from the application. DYNOBJ
2071 should be one of the values returned by `dynamic-link'.
2072
2073 (dynamic-func FUNCTION DYNOBJ)
2074
2075 Search the C function indicated by FUNCTION (a string or symbol)
2076 in DYNOBJ and return some Scheme object that can later be used
2077 with `dynamic-call' to actually call this function. Right now,
2078 these Scheme objects are formed by casting the address of the
2079 function to `long' and converting this number to its Scheme
2080 representation.
2081
2082 (dynamic-call FUNCTION DYNOBJ)
2083
2084 Call the C function indicated by FUNCTION and DYNOBJ. The
2085 function is passed no arguments and its return value is ignored.
2086 When FUNCTION is something returned by `dynamic-func', call that
2087 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
2088 etc.), look it up in DYNOBJ; this is equivalent to
2089
2090 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
2091
2092 Interrupts are deferred while the C function is executing (with
2093 SCM_DEFER_INTS/SCM_ALLOW_INTS).
2094
2095 (dynamic-args-call FUNCTION DYNOBJ ARGS)
2096
2097 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
2098 some arguments and return its return value. The C function is
2099 expected to take two arguments and return an `int', just like
2100 `main':
2101
2102 int c_func (int argc, char **argv);
2103
2104 ARGS must be a list of strings and is converted into an array of
2105 `char *'. The array is passed in ARGV and its size in ARGC. The
2106 return value is converted to a Scheme number and returned from the
2107 call to `dynamic-args-call'.
2108
2109 When dynamic linking is disabled or not supported on your system,
2110 the above functions throw errors, but they are still available.
2111
2112 Here is a small example that works on GNU/Linux:
2113
2114 (define libc-obj (dynamic-link "libc.so"))
2115 (dynamic-args-call 'rand libc-obj '())
2116
2117 See the file `libguile/DYNAMIC-LINKING' for additional comments.
2118
2119 ** The #/ syntax for module names is depreciated, and will be removed
2120 in a future version of Guile. Instead of
2121
2122 #/foo/bar/baz
2123
2124 instead write
2125
2126 (foo bar baz)
2127
2128 The latter syntax is more consistent with existing Lisp practice.
2129
2130 ** Guile now does fancier printing of structures. Structures are the
2131 underlying implementation for records, which in turn are used to
2132 implement modules, so all of these object now print differently and in
2133 a more informative way.
2134
2135 The Scheme printer will examine the builtin variable *struct-printer*
2136 whenever it needs to print a structure object. When this variable is
2137 not `#f' it is deemed to be a procedure and will be applied to the
2138 structure object and the output port. When *struct-printer* is `#f'
2139 or the procedure return `#f' the structure object will be printed in
2140 the boring #<struct 80458270> form.
2141
2142 This hook is used by some routines in ice-9/boot-9.scm to implement
2143 type specific printing routines. Please read the comments there about
2144 "printing structs".
2145
2146 One of the more specific uses of structs are records. The printing
2147 procedure that could be passed to MAKE-RECORD-TYPE is now actually
2148 called. It should behave like a *struct-printer* procedure (described
2149 above).
2150
2151 ** Guile now supports a new R4RS-compliant syntax for keywords. A
2152 token of the form #:NAME, where NAME has the same syntax as a Scheme
2153 symbol, is the external representation of the keyword named NAME.
2154 Keyword objects print using this syntax as well, so values containing
2155 keyword objects can be read back into Guile. When used in an
2156 expression, keywords are self-quoting objects.
2157
2158 Guile suports this read syntax, and uses this print syntax, regardless
2159 of the current setting of the `keyword' read option. The `keyword'
2160 read option only controls whether Guile recognizes the `:NAME' syntax,
2161 which is incompatible with R4RS. (R4RS says such token represent
2162 symbols.)
2163
2164 ** Guile has regular expression support again. Guile 1.0 included
2165 functions for matching regular expressions, based on the Rx library.
2166 In Guile 1.1, the Guile/Rx interface was removed to simplify the
2167 distribution, and thus Guile had no regular expression support. Guile
2168 1.2 again supports the most commonly used functions, and supports all
2169 of SCSH's regular expression functions.
2170
2171 If your system does not include a POSIX regular expression library,
2172 and you have not linked Guile with a third-party regexp library such as
2173 Rx, these functions will not be available. You can tell whether your
2174 Guile installation includes regular expression support by checking
2175 whether the `*features*' list includes the `regex' symbol.
2176
2177 *** regexp functions
2178
2179 By default, Guile supports POSIX extended regular expressions. That
2180 means that the characters `(', `)', `+' and `?' are special, and must
2181 be escaped if you wish to match the literal characters.
2182
2183 This regular expression interface was modeled after that implemented
2184 by SCSH, the Scheme Shell. It is intended to be upwardly compatible
2185 with SCSH regular expressions.
2186
2187 **** Function: string-match PATTERN STR [START]
2188 Compile the string PATTERN into a regular expression and compare
2189 it with STR. The optional numeric argument START specifies the
2190 position of STR at which to begin matching.
2191
2192 `string-match' returns a "match structure" which describes what,
2193 if anything, was matched by the regular expression. *Note Match
2194 Structures::. If STR does not match PATTERN at all,
2195 `string-match' returns `#f'.
2196
2197 Each time `string-match' is called, it must compile its PATTERN
2198 argument into a regular expression structure. This operation is
2199 expensive, which makes `string-match' inefficient if the same regular
2200 expression is used several times (for example, in a loop). For better
2201 performance, you can compile a regular expression in advance and then
2202 match strings against the compiled regexp.
2203
2204 **** Function: make-regexp STR [FLAGS]
2205 Compile the regular expression described by STR, and return the
2206 compiled regexp structure. If STR does not describe a legal
2207 regular expression, `make-regexp' throws a
2208 `regular-expression-syntax' error.
2209
2210 FLAGS may be the bitwise-or of one or more of the following:
2211
2212 **** Constant: regexp/extended
2213 Use POSIX Extended Regular Expression syntax when interpreting
2214 STR. If not set, POSIX Basic Regular Expression syntax is used.
2215 If the FLAGS argument is omitted, we assume regexp/extended.
2216
2217 **** Constant: regexp/icase
2218 Do not differentiate case. Subsequent searches using the
2219 returned regular expression will be case insensitive.
2220
2221 **** Constant: regexp/newline
2222 Match-any-character operators don't match a newline.
2223
2224 A non-matching list ([^...]) not containing a newline matches a
2225 newline.
2226
2227 Match-beginning-of-line operator (^) matches the empty string
2228 immediately after a newline, regardless of whether the FLAGS
2229 passed to regexp-exec contain regexp/notbol.
2230
2231 Match-end-of-line operator ($) matches the empty string
2232 immediately before a newline, regardless of whether the FLAGS
2233 passed to regexp-exec contain regexp/noteol.
2234
2235 **** Function: regexp-exec REGEXP STR [START [FLAGS]]
2236 Match the compiled regular expression REGEXP against `str'. If
2237 the optional integer START argument is provided, begin matching
2238 from that position in the string. Return a match structure
2239 describing the results of the match, or `#f' if no match could be
2240 found.
2241
2242 FLAGS may be the bitwise-or of one or more of the following:
2243
2244 **** Constant: regexp/notbol
2245 The match-beginning-of-line operator always fails to match (but
2246 see the compilation flag regexp/newline above) This flag may be
2247 used when different portions of a string are passed to
2248 regexp-exec and the beginning of the string should not be
2249 interpreted as the beginning of the line.
2250
2251 **** Constant: regexp/noteol
2252 The match-end-of-line operator always fails to match (but see the
2253 compilation flag regexp/newline above)
2254
2255 **** Function: regexp? OBJ
2256 Return `#t' if OBJ is a compiled regular expression, or `#f'
2257 otherwise.
2258
2259 Regular expressions are commonly used to find patterns in one string
2260 and replace them with the contents of another string.
2261
2262 **** Function: regexp-substitute PORT MATCH [ITEM...]
2263 Write to the output port PORT selected contents of the match
2264 structure MATCH. Each ITEM specifies what should be written, and
2265 may be one of the following arguments:
2266
2267 * A string. String arguments are written out verbatim.
2268
2269 * An integer. The submatch with that number is written.
2270
2271 * The symbol `pre'. The portion of the matched string preceding
2272 the regexp match is written.
2273
2274 * The symbol `post'. The portion of the matched string
2275 following the regexp match is written.
2276
2277 PORT may be `#f', in which case nothing is written; instead,
2278 `regexp-substitute' constructs a string from the specified ITEMs
2279 and returns that.
2280
2281 **** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
2282 Similar to `regexp-substitute', but can be used to perform global
2283 substitutions on STR. Instead of taking a match structure as an
2284 argument, `regexp-substitute/global' takes two string arguments: a
2285 REGEXP string describing a regular expression, and a TARGET string
2286 which should be matched against this regular expression.
2287
2288 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
2289 exceptions:
2290
2291 * A function may be supplied. When this function is called, it
2292 will be passed one argument: a match structure for a given
2293 regular expression match. It should return a string to be
2294 written out to PORT.
2295
2296 * The `post' symbol causes `regexp-substitute/global' to recurse
2297 on the unmatched portion of STR. This *must* be supplied in
2298 order to perform global search-and-replace on STR; if it is
2299 not present among the ITEMs, then `regexp-substitute/global'
2300 will return after processing a single match.
2301
2302 *** Match Structures
2303
2304 A "match structure" is the object returned by `string-match' and
2305 `regexp-exec'. It describes which portion of a string, if any, matched
2306 the given regular expression. Match structures include: a reference to
2307 the string that was checked for matches; the starting and ending
2308 positions of the regexp match; and, if the regexp included any
2309 parenthesized subexpressions, the starting and ending positions of each
2310 submatch.
2311
2312 In each of the regexp match functions described below, the `match'
2313 argument must be a match structure returned by a previous call to
2314 `string-match' or `regexp-exec'. Most of these functions return some
2315 information about the original target string that was matched against a
2316 regular expression; we will call that string TARGET for easy reference.
2317
2318 **** Function: regexp-match? OBJ
2319 Return `#t' if OBJ is a match structure returned by a previous
2320 call to `regexp-exec', or `#f' otherwise.
2321
2322 **** Function: match:substring MATCH [N]
2323 Return the portion of TARGET matched by subexpression number N.
2324 Submatch 0 (the default) represents the entire regexp match. If
2325 the regular expression as a whole matched, but the subexpression
2326 number N did not match, return `#f'.
2327
2328 **** Function: match:start MATCH [N]
2329 Return the starting position of submatch number N.
2330
2331 **** Function: match:end MATCH [N]
2332 Return the ending position of submatch number N.
2333
2334 **** Function: match:prefix MATCH
2335 Return the unmatched portion of TARGET preceding the regexp match.
2336
2337 **** Function: match:suffix MATCH
2338 Return the unmatched portion of TARGET following the regexp match.
2339
2340 **** Function: match:count MATCH
2341 Return the number of parenthesized subexpressions from MATCH.
2342 Note that the entire regular expression match itself counts as a
2343 subexpression, and failed submatches are included in the count.
2344
2345 **** Function: match:string MATCH
2346 Return the original TARGET string.
2347
2348 *** Backslash Escapes
2349
2350 Sometimes you will want a regexp to match characters like `*' or `$'
2351 exactly. For example, to check whether a particular string represents
2352 a menu entry from an Info node, it would be useful to match it against
2353 a regexp like `^* [^:]*::'. However, this won't work; because the
2354 asterisk is a metacharacter, it won't match the `*' at the beginning of
2355 the string. In this case, we want to make the first asterisk un-magic.
2356
2357 You can do this by preceding the metacharacter with a backslash
2358 character `\'. (This is also called "quoting" the metacharacter, and
2359 is known as a "backslash escape".) When Guile sees a backslash in a
2360 regular expression, it considers the following glyph to be an ordinary
2361 character, no matter what special meaning it would ordinarily have.
2362 Therefore, we can make the above example work by changing the regexp to
2363 `^\* [^:]*::'. The `\*' sequence tells the regular expression engine
2364 to match only a single asterisk in the target string.
2365
2366 Since the backslash is itself a metacharacter, you may force a
2367 regexp to match a backslash in the target string by preceding the
2368 backslash with itself. For example, to find variable references in a
2369 TeX program, you might want to find occurrences of the string `\let\'
2370 followed by any number of alphabetic characters. The regular expression
2371 `\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
2372 each match a single backslash in the target string.
2373
2374 **** Function: regexp-quote STR
2375 Quote each special character found in STR with a backslash, and
2376 return the resulting string.
2377
2378 *Very important:* Using backslash escapes in Guile source code (as
2379 in Emacs Lisp or C) can be tricky, because the backslash character has
2380 special meaning for the Guile reader. For example, if Guile encounters
2381 the character sequence `\n' in the middle of a string while processing
2382 Scheme code, it replaces those characters with a newline character.
2383 Similarly, the character sequence `\t' is replaced by a horizontal tab.
2384 Several of these "escape sequences" are processed by the Guile reader
2385 before your code is executed. Unrecognized escape sequences are
2386 ignored: if the characters `\*' appear in a string, they will be
2387 translated to the single character `*'.
2388
2389 This translation is obviously undesirable for regular expressions,
2390 since we want to be able to include backslashes in a string in order to
2391 escape regexp metacharacters. Therefore, to make sure that a backslash
2392 is preserved in a string in your Guile program, you must use *two*
2393 consecutive backslashes:
2394
2395 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
2396
2397 The string in this example is preprocessed by the Guile reader before
2398 any code is executed. The resulting argument to `make-regexp' is the
2399 string `^\* [^:]*', which is what we really want.
2400
2401 This also means that in order to write a regular expression that
2402 matches a single backslash character, the regular expression string in
2403 the source code must include *four* backslashes. Each consecutive pair
2404 of backslashes gets translated by the Guile reader to a single
2405 backslash, and the resulting double-backslash is interpreted by the
2406 regexp engine as matching a single backslash character. Hence:
2407
2408 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
2409
2410 The reason for the unwieldiness of this syntax is historical. Both
2411 regular expression pattern matchers and Unix string processing systems
2412 have traditionally used backslashes with the special meanings described
2413 above. The POSIX regular expression specification and ANSI C standard
2414 both require these semantics. Attempting to abandon either convention
2415 would cause other kinds of compatibility problems, possibly more severe
2416 ones. Therefore, without extending the Scheme reader to support
2417 strings with different quoting conventions (an ungainly and confusing
2418 extension when implemented in other languages), we must adhere to this
2419 cumbersome escape syntax.
2420
2421 * Changes to the gh_ interface
2422
2423 * Changes to the scm_ interface
2424
2425 * Changes to system call interfaces:
2426
2427 ** The value returned by `raise' is now unspecified. It throws an exception
2428 if an error occurs.
2429
2430 *** A new procedure `sigaction' can be used to install signal handlers
2431
2432 (sigaction signum [action] [flags])
2433
2434 signum is the signal number, which can be specified using the value
2435 of SIGINT etc.
2436
2437 If action is omitted, sigaction returns a pair: the CAR is the current
2438 signal hander, which will be either an integer with the value SIG_DFL
2439 (default action) or SIG_IGN (ignore), or the Scheme procedure which
2440 handles the signal, or #f if a non-Scheme procedure handles the
2441 signal. The CDR contains the current sigaction flags for the handler.
2442
2443 If action is provided, it is installed as the new handler for signum.
2444 action can be a Scheme procedure taking one argument, or the value of
2445 SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
2446 whatever signal handler was installed before sigaction was first used.
2447 Flags can optionally be specified for the new handler (SA_RESTART is
2448 always used if the system provides it, so need not be specified.) The
2449 return value is a pair with information about the old handler as
2450 described above.
2451
2452 This interface does not provide access to the "signal blocking"
2453 facility. Maybe this is not needed, since the thread support may
2454 provide solutions to the problem of consistent access to data
2455 structures.
2456
2457 *** A new procedure `flush-all-ports' is equivalent to running
2458 `force-output' on every port open for output.
2459
2460 ** Guile now provides information on how it was built, via the new
2461 global variable, %guile-build-info. This variable records the values
2462 of the standard GNU makefile directory variables as an assocation
2463 list, mapping variable names (symbols) onto directory paths (strings).
2464 For example, to find out where the Guile link libraries were
2465 installed, you can say:
2466
2467 guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
2468
2469
2470 * Changes to the scm_ interface
2471
2472 ** The new function scm_handle_by_message_noexit is just like the
2473 existing scm_handle_by_message function, except that it doesn't call
2474 exit to terminate the process. Instead, it prints a message and just
2475 returns #f. This might be a more appropriate catch-all handler for
2476 new dynamic roots and threads.
2477
2478 \f
2479 Changes in Guile 1.1 (released Friday, May 16 1997):
2480
2481 * Changes to the distribution.
2482
2483 The Guile 1.0 distribution has been split up into several smaller
2484 pieces:
2485 guile-core --- the Guile interpreter itself.
2486 guile-tcltk --- the interface between the Guile interpreter and
2487 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
2488 is a toolkit for building graphical user interfaces.
2489 guile-rgx-ctax --- the interface between Guile and the Rx regular
2490 expression matcher, and the translator for the Ctax
2491 programming language. These are packaged together because the
2492 Ctax translator uses Rx to parse Ctax source code.
2493
2494 This NEWS file describes the changes made to guile-core since the 1.0
2495 release.
2496
2497 We no longer distribute the documentation, since it was either out of
2498 date, or incomplete. As soon as we have current documentation, we
2499 will distribute it.
2500
2501
2502
2503 * Changes to the stand-alone interpreter
2504
2505 ** guile now accepts command-line arguments compatible with SCSH, Olin
2506 Shivers' Scheme Shell.
2507
2508 In general, arguments are evaluated from left to right, but there are
2509 exceptions. The following switches stop argument processing, and
2510 stash all remaining command-line arguments as the value returned by
2511 the (command-line) function.
2512 -s SCRIPT load Scheme source code from FILE, and exit
2513 -c EXPR evalute Scheme expression EXPR, and exit
2514 -- stop scanning arguments; run interactively
2515
2516 The switches below are processed as they are encountered.
2517 -l FILE load Scheme source code from FILE
2518 -e FUNCTION after reading script, apply FUNCTION to
2519 command line arguments
2520 -ds do -s script at this point
2521 --emacs enable Emacs protocol (experimental)
2522 -h, --help display this help and exit
2523 -v, --version display version information and exit
2524 \ read arguments from following script lines
2525
2526 So, for example, here is a Guile script named `ekko' (thanks, Olin)
2527 which re-implements the traditional "echo" command:
2528
2529 #!/usr/local/bin/guile -s
2530 !#
2531 (define (main args)
2532 (map (lambda (arg) (display arg) (display " "))
2533 (cdr args))
2534 (newline))
2535
2536 (main (command-line))
2537
2538 Suppose we invoke this script as follows:
2539
2540 ekko a speckled gecko
2541
2542 Through the magic of Unix script processing (triggered by the `#!'
2543 token at the top of the file), /usr/local/bin/guile receives the
2544 following list of command-line arguments:
2545
2546 ("-s" "./ekko" "a" "speckled" "gecko")
2547
2548 Unix inserts the name of the script after the argument specified on
2549 the first line of the file (in this case, "-s"), and then follows that
2550 with the arguments given to the script. Guile loads the script, which
2551 defines the `main' function, and then applies it to the list of
2552 remaining command-line arguments, ("a" "speckled" "gecko").
2553
2554 In Unix, the first line of a script file must take the following form:
2555
2556 #!INTERPRETER ARGUMENT
2557
2558 where INTERPRETER is the absolute filename of the interpreter
2559 executable, and ARGUMENT is a single command-line argument to pass to
2560 the interpreter.
2561
2562 You may only pass one argument to the interpreter, and its length is
2563 limited. These restrictions can be annoying to work around, so Guile
2564 provides a general mechanism (borrowed from, and compatible with,
2565 SCSH) for circumventing them.
2566
2567 If the ARGUMENT in a Guile script is a single backslash character,
2568 `\', Guile will open the script file, parse arguments from its second
2569 and subsequent lines, and replace the `\' with them. So, for example,
2570 here is another implementation of the `ekko' script:
2571
2572 #!/usr/local/bin/guile \
2573 -e main -s
2574 !#
2575 (define (main args)
2576 (for-each (lambda (arg) (display arg) (display " "))
2577 (cdr args))
2578 (newline))
2579
2580 If the user invokes this script as follows:
2581
2582 ekko a speckled gecko
2583
2584 Unix expands this into
2585
2586 /usr/local/bin/guile \ ekko a speckled gecko
2587
2588 When Guile sees the `\' argument, it replaces it with the arguments
2589 read from the second line of the script, producing:
2590
2591 /usr/local/bin/guile -e main -s ekko a speckled gecko
2592
2593 This tells Guile to load the `ekko' script, and apply the function
2594 `main' to the argument list ("a" "speckled" "gecko").
2595
2596 Here is how Guile parses the command-line arguments:
2597 - Each space character terminates an argument. This means that two
2598 spaces in a row introduce an empty-string argument.
2599 - The tab character is not permitted (unless you quote it with the
2600 backslash character, as described below), to avoid confusion.
2601 - The newline character terminates the sequence of arguments, and will
2602 also terminate a final non-empty argument. (However, a newline
2603 following a space will not introduce a final empty-string argument;
2604 it only terminates the argument list.)
2605 - The backslash character is the escape character. It escapes
2606 backslash, space, tab, and newline. The ANSI C escape sequences
2607 like \n and \t are also supported. These produce argument
2608 constituents; the two-character combination \n doesn't act like a
2609 terminating newline. The escape sequence \NNN for exactly three
2610 octal digits reads as the character whose ASCII code is NNN. As
2611 above, characters produced this way are argument constituents.
2612 Backslash followed by other characters is not allowed.
2613
2614 * Changes to the procedure for linking libguile with your programs
2615
2616 ** Guile now builds and installs a shared guile library, if your
2617 system support shared libraries. (It still builds a static library on
2618 all systems.) Guile automatically detects whether your system
2619 supports shared libraries. To prevent Guile from buildisg shared
2620 libraries, pass the `--disable-shared' flag to the configure script.
2621
2622 Guile takes longer to compile when it builds shared libraries, because
2623 it must compile every file twice --- once to produce position-
2624 independent object code, and once to produce normal object code.
2625
2626 ** The libthreads library has been merged into libguile.
2627
2628 To link a program against Guile, you now need only link against
2629 -lguile and -lqt; -lthreads is no longer needed. If you are using
2630 autoconf to generate configuration scripts for your application, the
2631 following lines should suffice to add the appropriate libraries to
2632 your link command:
2633
2634 ### Find quickthreads and libguile.
2635 AC_CHECK_LIB(qt, main)
2636 AC_CHECK_LIB(guile, scm_shell)
2637
2638 * Changes to Scheme functions
2639
2640 ** Guile Scheme's special syntax for keyword objects is now optional,
2641 and disabled by default.
2642
2643 The syntax variation from R4RS made it difficult to port some
2644 interesting packages to Guile. The routines which accepted keyword
2645 arguments (mostly in the module system) have been modified to also
2646 accept symbols whose names begin with `:'.
2647
2648 To change the keyword syntax, you must first import the (ice-9 debug)
2649 module:
2650 (use-modules (ice-9 debug))
2651
2652 Then you can enable the keyword syntax as follows:
2653 (read-set! keywords 'prefix)
2654
2655 To disable keyword syntax, do this:
2656 (read-set! keywords #f)
2657
2658 ** Many more primitive functions accept shared substrings as
2659 arguments. In the past, these functions required normal, mutable
2660 strings as arguments, although they never made use of this
2661 restriction.
2662
2663 ** The uniform array functions now operate on byte vectors. These
2664 functions are `array-fill!', `serial-array-copy!', `array-copy!',
2665 `serial-array-map', `array-map', `array-for-each', and
2666 `array-index-map!'.
2667
2668 ** The new functions `trace' and `untrace' implement simple debugging
2669 support for Scheme functions.
2670
2671 The `trace' function accepts any number of procedures as arguments,
2672 and tells the Guile interpreter to display each procedure's name and
2673 arguments each time the procedure is invoked. When invoked with no
2674 arguments, `trace' returns the list of procedures currently being
2675 traced.
2676
2677 The `untrace' function accepts any number of procedures as arguments,
2678 and tells the Guile interpreter not to trace them any more. When
2679 invoked with no arguments, `untrace' untraces all curretly traced
2680 procedures.
2681
2682 The tracing in Guile has an advantage over most other systems: we
2683 don't create new procedure objects, but mark the procedure objects
2684 themselves. This means that anonymous and internal procedures can be
2685 traced.
2686
2687 ** The function `assert-repl-prompt' has been renamed to
2688 `set-repl-prompt!'. It takes one argument, PROMPT.
2689 - If PROMPT is #f, the Guile read-eval-print loop will not prompt.
2690 - If PROMPT is a string, we use it as a prompt.
2691 - If PROMPT is a procedure accepting no arguments, we call it, and
2692 display the result as a prompt.
2693 - Otherwise, we display "> ".
2694
2695 ** The new function `eval-string' reads Scheme expressions from a
2696 string and evaluates them, returning the value of the last expression
2697 in the string. If the string contains no expressions, it returns an
2698 unspecified value.
2699
2700 ** The new function `thunk?' returns true iff its argument is a
2701 procedure of zero arguments.
2702
2703 ** `defined?' is now a builtin function, instead of syntax. This
2704 means that its argument should be quoted. It returns #t iff its
2705 argument is bound in the current module.
2706
2707 ** The new syntax `use-modules' allows you to add new modules to your
2708 environment without re-typing a complete `define-module' form. It
2709 accepts any number of module names as arguments, and imports their
2710 public bindings into the current module.
2711
2712 ** The new function (module-defined? NAME MODULE) returns true iff
2713 NAME, a symbol, is defined in MODULE, a module object.
2714
2715 ** The new function `builtin-bindings' creates and returns a hash
2716 table containing copies of all the root module's bindings.
2717
2718 ** The new function `builtin-weak-bindings' does the same as
2719 `builtin-bindings', but creates a doubly-weak hash table.
2720
2721 ** The `equal?' function now considers variable objects to be
2722 equivalent if they have the same name and the same value.
2723
2724 ** The new function `command-line' returns the command-line arguments
2725 given to Guile, as a list of strings.
2726
2727 When using guile as a script interpreter, `command-line' returns the
2728 script's arguments; those processed by the interpreter (like `-s' or
2729 `-c') are omitted. (In other words, you get the normal, expected
2730 behavior.) Any application that uses scm_shell to process its
2731 command-line arguments gets this behavior as well.
2732
2733 ** The new function `load-user-init' looks for a file called `.guile'
2734 in the user's home directory, and loads it if it exists. This is
2735 mostly for use by the code generated by scm_compile_shell_switches,
2736 but we thought it might also be useful in other circumstances.
2737
2738 ** The new function `log10' returns the base-10 logarithm of its
2739 argument.
2740
2741 ** Changes to I/O functions
2742
2743 *** The functions `read', `primitive-load', `read-and-eval!', and
2744 `primitive-load-path' no longer take optional arguments controlling
2745 case insensitivity and a `#' parser.
2746
2747 Case sensitivity is now controlled by a read option called
2748 `case-insensitive'. The user can add new `#' syntaxes with the
2749 `read-hash-extend' function (see below).
2750
2751 *** The new function `read-hash-extend' allows the user to change the
2752 syntax of Guile Scheme in a somewhat controlled way.
2753
2754 (read-hash-extend CHAR PROC)
2755 When parsing S-expressions, if we read a `#' character followed by
2756 the character CHAR, use PROC to parse an object from the stream.
2757 If PROC is #f, remove any parsing procedure registered for CHAR.
2758
2759 The reader applies PROC to two arguments: CHAR and an input port.
2760
2761 *** The new functions read-delimited and read-delimited! provide a
2762 general mechanism for doing delimited input on streams.
2763
2764 (read-delimited DELIMS [PORT HANDLE-DELIM])
2765 Read until we encounter one of the characters in DELIMS (a string),
2766 or end-of-file. PORT is the input port to read from; it defaults to
2767 the current input port. The HANDLE-DELIM parameter determines how
2768 the terminating character is handled; it should be one of the
2769 following symbols:
2770
2771 'trim omit delimiter from result
2772 'peek leave delimiter character in input stream
2773 'concat append delimiter character to returned value
2774 'split return a pair: (RESULT . TERMINATOR)
2775
2776 HANDLE-DELIM defaults to 'peek.
2777
2778 (read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
2779 A side-effecting variant of `read-delimited'.
2780
2781 The data is written into the string BUF at the indices in the
2782 half-open interval [START, END); the default interval is the whole
2783 string: START = 0 and END = (string-length BUF). The values of
2784 START and END must specify a well-defined interval in BUF, i.e.
2785 0 <= START <= END <= (string-length BUF).
2786
2787 It returns NBYTES, the number of bytes read. If the buffer filled
2788 up without a delimiter character being found, it returns #f. If the
2789 port is at EOF when the read starts, it returns the EOF object.
2790
2791 If an integer is returned (i.e., the read is successfully terminated
2792 by reading a delimiter character), then the HANDLE-DELIM parameter
2793 determines how to handle the terminating character. It is described
2794 above, and defaults to 'peek.
2795
2796 (The descriptions of these functions were borrowed from the SCSH
2797 manual, by Olin Shivers and Brian Carlstrom.)
2798
2799 *** The `%read-delimited!' function is the primitive used to implement
2800 `read-delimited' and `read-delimited!'.
2801
2802 (%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
2803
2804 This returns a pair of values: (TERMINATOR . NUM-READ).
2805 - TERMINATOR describes why the read was terminated. If it is a
2806 character or the eof object, then that is the value that terminated
2807 the read. If it is #f, the function filled the buffer without finding
2808 a delimiting character.
2809 - NUM-READ is the number of characters read into BUF.
2810
2811 If the read is successfully terminated by reading a delimiter
2812 character, then the gobble? parameter determines what to do with the
2813 terminating character. If true, the character is removed from the
2814 input stream; if false, the character is left in the input stream
2815 where a subsequent read operation will retrieve it. In either case,
2816 the character is also the first value returned by the procedure call.
2817
2818 (The descriptions of this function was borrowed from the SCSH manual,
2819 by Olin Shivers and Brian Carlstrom.)
2820
2821 *** The `read-line' and `read-line!' functions have changed; they now
2822 trim the terminator by default; previously they appended it to the
2823 returned string. For the old behavior, use (read-line PORT 'concat).
2824
2825 *** The functions `uniform-array-read!' and `uniform-array-write!' now
2826 take new optional START and END arguments, specifying the region of
2827 the array to read and write.
2828
2829 *** The `ungetc-char-ready?' function has been removed. We feel it's
2830 inappropriate for an interface to expose implementation details this
2831 way.
2832
2833 ** Changes to the Unix library and system call interface
2834
2835 *** The new fcntl function provides access to the Unix `fcntl' system
2836 call.
2837
2838 (fcntl PORT COMMAND VALUE)
2839 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
2840 Values for COMMAND are:
2841
2842 F_DUPFD duplicate a file descriptor
2843 F_GETFD read the descriptor's close-on-exec flag
2844 F_SETFD set the descriptor's close-on-exec flag to VALUE
2845 F_GETFL read the descriptor's flags, as set on open
2846 F_SETFL set the descriptor's flags, as set on open to VALUE
2847 F_GETOWN return the process ID of a socket's owner, for SIGIO
2848 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
2849 FD_CLOEXEC not sure what this is
2850
2851 For details, see the documentation for the fcntl system call.
2852
2853 *** The arguments to `select' have changed, for compatibility with
2854 SCSH. The TIMEOUT parameter may now be non-integral, yielding the
2855 expected behavior. The MILLISECONDS parameter has been changed to
2856 MICROSECONDS, to more closely resemble the underlying system call.
2857 The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
2858 corresponding return set will be the same.
2859
2860 *** The arguments to the `mknod' system call have changed. They are
2861 now:
2862
2863 (mknod PATH TYPE PERMS DEV)
2864 Create a new file (`node') in the file system. PATH is the name of
2865 the file to create. TYPE is the kind of file to create; it should
2866 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
2867 permission bits to give the newly created file. If TYPE is
2868 'block-special or 'char-special, DEV specifies which device the
2869 special file refers to; its interpretation depends on the kind of
2870 special file being created.
2871
2872 *** The `fork' function has been renamed to `primitive-fork', to avoid
2873 clashing with various SCSH forks.
2874
2875 *** The `recv' and `recvfrom' functions have been renamed to `recv!'
2876 and `recvfrom!'. They no longer accept a size for a second argument;
2877 you must pass a string to hold the received value. They no longer
2878 return the buffer. Instead, `recv' returns the length of the message
2879 received, and `recvfrom' returns a pair containing the packet's length
2880 and originating address.
2881
2882 *** The file descriptor datatype has been removed, as have the
2883 `read-fd', `write-fd', `close', `lseek', and `dup' functions.
2884 We plan to replace these functions with a SCSH-compatible interface.
2885
2886 *** The `create' function has been removed; it's just a special case
2887 of `open'.
2888
2889 *** There are new functions to break down process termination status
2890 values. In the descriptions below, STATUS is a value returned by
2891 `waitpid'.
2892
2893 (status:exit-val STATUS)
2894 If the child process exited normally, this function returns the exit
2895 code for the child process (i.e., the value passed to exit, or
2896 returned from main). If the child process did not exit normally,
2897 this function returns #f.
2898
2899 (status:stop-sig STATUS)
2900 If the child process was suspended by a signal, this function
2901 returns the signal that suspended the child. Otherwise, it returns
2902 #f.
2903
2904 (status:term-sig STATUS)
2905 If the child process terminated abnormally, this function returns
2906 the signal that terminated the child. Otherwise, this function
2907 returns false.
2908
2909 POSIX promises that exactly one of these functions will return true on
2910 a valid STATUS value.
2911
2912 These functions are compatible with SCSH.
2913
2914 *** There are new accessors and setters for the broken-out time vectors
2915 returned by `localtime', `gmtime', and that ilk. They are:
2916
2917 Component Accessor Setter
2918 ========================= ============ ============
2919 seconds tm:sec set-tm:sec
2920 minutes tm:min set-tm:min
2921 hours tm:hour set-tm:hour
2922 day of the month tm:mday set-tm:mday
2923 month tm:mon set-tm:mon
2924 year tm:year set-tm:year
2925 day of the week tm:wday set-tm:wday
2926 day in the year tm:yday set-tm:yday
2927 daylight saving time tm:isdst set-tm:isdst
2928 GMT offset, seconds tm:gmtoff set-tm:gmtoff
2929 name of time zone tm:zone set-tm:zone
2930
2931 *** There are new accessors for the vectors returned by `uname',
2932 describing the host system:
2933
2934 Component Accessor
2935 ============================================== ================
2936 name of the operating system implementation utsname:sysname
2937 network name of this machine utsname:nodename
2938 release level of the operating system utsname:release
2939 version level of the operating system utsname:version
2940 machine hardware platform utsname:machine
2941
2942 *** There are new accessors for the vectors returned by `getpw',
2943 `getpwnam', `getpwuid', and `getpwent', describing entries from the
2944 system's user database:
2945
2946 Component Accessor
2947 ====================== =================
2948 user name passwd:name
2949 user password passwd:passwd
2950 user id passwd:uid
2951 group id passwd:gid
2952 real name passwd:gecos
2953 home directory passwd:dir
2954 shell program passwd:shell
2955
2956 *** There are new accessors for the vectors returned by `getgr',
2957 `getgrnam', `getgrgid', and `getgrent', describing entries from the
2958 system's group database:
2959
2960 Component Accessor
2961 ======================= ============
2962 group name group:name
2963 group password group:passwd
2964 group id group:gid
2965 group members group:mem
2966
2967 *** There are new accessors for the vectors returned by `gethost',
2968 `gethostbyaddr', `gethostbyname', and `gethostent', describing
2969 internet hosts:
2970
2971 Component Accessor
2972 ========================= ===============
2973 official name of host hostent:name
2974 alias list hostent:aliases
2975 host address type hostent:addrtype
2976 length of address hostent:length
2977 list of addresses hostent:addr-list
2978
2979 *** There are new accessors for the vectors returned by `getnet',
2980 `getnetbyaddr', `getnetbyname', and `getnetent', describing internet
2981 networks:
2982
2983 Component Accessor
2984 ========================= ===============
2985 official name of net netent:name
2986 alias list netent:aliases
2987 net number type netent:addrtype
2988 net number netent:net
2989
2990 *** There are new accessors for the vectors returned by `getproto',
2991 `getprotobyname', `getprotobynumber', and `getprotoent', describing
2992 internet protocols:
2993
2994 Component Accessor
2995 ========================= ===============
2996 official protocol name protoent:name
2997 alias list protoent:aliases
2998 protocol number protoent:proto
2999
3000 *** There are new accessors for the vectors returned by `getserv',
3001 `getservbyname', `getservbyport', and `getservent', describing
3002 internet protocols:
3003
3004 Component Accessor
3005 ========================= ===============
3006 official service name servent:name
3007 alias list servent:aliases
3008 port number servent:port
3009 protocol to use servent:proto
3010
3011 *** There are new accessors for the sockaddr structures returned by
3012 `accept', `getsockname', `getpeername', `recvfrom!':
3013
3014 Component Accessor
3015 ======================================== ===============
3016 address format (`family') sockaddr:fam
3017 path, for file domain addresses sockaddr:path
3018 address, for internet domain addresses sockaddr:addr
3019 TCP or UDP port, for internet sockaddr:port
3020
3021 *** The `getpwent', `getgrent', `gethostent', `getnetent',
3022 `getprotoent', and `getservent' functions now return #f at the end of
3023 the user database. (They used to throw an exception.)
3024
3025 Note that calling MUMBLEent function is equivalent to calling the
3026 corresponding MUMBLE function with no arguments.
3027
3028 *** The `setpwent', `setgrent', `sethostent', `setnetent',
3029 `setprotoent', and `setservent' routines now take no arguments.
3030
3031 *** The `gethost', `getproto', `getnet', and `getserv' functions now
3032 provide more useful information when they throw an exception.
3033
3034 *** The `lnaof' function has been renamed to `inet-lnaof'.
3035
3036 *** Guile now claims to have the `current-time' feature.
3037
3038 *** The `mktime' function now takes an optional second argument ZONE,
3039 giving the time zone to use for the conversion. ZONE should be a
3040 string, in the same format as expected for the "TZ" environment variable.
3041
3042 *** The `strptime' function now returns a pair (TIME . COUNT), where
3043 TIME is the parsed time as a vector, and COUNT is the number of
3044 characters from the string left unparsed. This function used to
3045 return the remaining characters as a string.
3046
3047 *** The `gettimeofday' function has replaced the old `time+ticks' function.
3048 The return value is now (SECONDS . MICROSECONDS); the fractional
3049 component is no longer expressed in "ticks".
3050
3051 *** The `ticks/sec' constant has been removed, in light of the above change.
3052
3053 * Changes to the gh_ interface
3054
3055 ** gh_eval_str() now returns an SCM object which is the result of the
3056 evaluation
3057
3058 ** gh_scm2str() now copies the Scheme data to a caller-provided C
3059 array
3060
3061 ** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
3062 and returns the array
3063
3064 ** gh_scm2str0() is gone: there is no need to distinguish
3065 null-terminated from non-null-terminated, since gh_scm2newstr() allows
3066 the user to interpret the data both ways.
3067
3068 * Changes to the scm_ interface
3069
3070 ** The new function scm_symbol_value0 provides an easy way to get a
3071 symbol's value from C code:
3072
3073 SCM scm_symbol_value0 (char *NAME)
3074 Return the value of the symbol named by the null-terminated string
3075 NAME in the current module. If the symbol named NAME is unbound in
3076 the current module, return SCM_UNDEFINED.
3077
3078 ** The new function scm_sysintern0 creates new top-level variables,
3079 without assigning them a value.
3080
3081 SCM scm_sysintern0 (char *NAME)
3082 Create a new Scheme top-level variable named NAME. NAME is a
3083 null-terminated string. Return the variable's value cell.
3084
3085 ** The function scm_internal_catch is the guts of catch. It handles
3086 all the mechanics of setting up a catch target, invoking the catch
3087 body, and perhaps invoking the handler if the body does a throw.
3088
3089 The function is designed to be usable from C code, but is general
3090 enough to implement all the semantics Guile Scheme expects from throw.
3091
3092 TAG is the catch tag. Typically, this is a symbol, but this function
3093 doesn't actually care about that.
3094
3095 BODY is a pointer to a C function which runs the body of the catch;
3096 this is the code you can throw from. We call it like this:
3097 BODY (BODY_DATA, JMPBUF)
3098 where:
3099 BODY_DATA is just the BODY_DATA argument we received; we pass it
3100 through to BODY as its first argument. The caller can make
3101 BODY_DATA point to anything useful that BODY might need.
3102 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
3103 which we have just created and initialized.
3104
3105 HANDLER is a pointer to a C function to deal with a throw to TAG,
3106 should one occur. We call it like this:
3107 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
3108 where
3109 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
3110 same idea as BODY_DATA above.
3111 THROWN_TAG is the tag that the user threw to; usually this is
3112 TAG, but it could be something else if TAG was #t (i.e., a
3113 catch-all), or the user threw to a jmpbuf.
3114 THROW_ARGS is the list of arguments the user passed to the THROW
3115 function.
3116
3117 BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
3118 is just a pointer we pass through to HANDLER. We don't actually
3119 use either of those pointers otherwise ourselves. The idea is
3120 that, if our caller wants to communicate something to BODY or
3121 HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
3122 HANDLER can then use. Think of it as a way to make BODY and
3123 HANDLER closures, not just functions; MUMBLE_DATA points to the
3124 enclosed variables.
3125
3126 Of course, it's up to the caller to make sure that any data a
3127 MUMBLE_DATA needs is protected from GC. A common way to do this is
3128 to make MUMBLE_DATA a pointer to data stored in an automatic
3129 structure variable; since the collector must scan the stack for
3130 references anyway, this assures that any references in MUMBLE_DATA
3131 will be found.
3132
3133 ** The new function scm_internal_lazy_catch is exactly like
3134 scm_internal_catch, except:
3135
3136 - It does not unwind the stack (this is the major difference).
3137 - If handler returns, its value is returned from the throw.
3138 - BODY always receives #f as its JMPBUF argument (since there's no
3139 jmpbuf associated with a lazy catch, because we don't unwind the
3140 stack.)
3141
3142 ** scm_body_thunk is a new body function you can pass to
3143 scm_internal_catch if you want the body to be like Scheme's `catch'
3144 --- a thunk, or a function of one argument if the tag is #f.
3145
3146 BODY_DATA is a pointer to a scm_body_thunk_data structure, which
3147 contains the Scheme procedure to invoke as the body, and the tag
3148 we're catching. If the tag is #f, then we pass JMPBUF (created by
3149 scm_internal_catch) to the body procedure; otherwise, the body gets
3150 no arguments.
3151
3152 ** scm_handle_by_proc is a new handler function you can pass to
3153 scm_internal_catch if you want the handler to act like Scheme's catch
3154 --- call a procedure with the tag and the throw arguments.
3155
3156 If the user does a throw to this catch, this function runs a handler
3157 procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
3158 variable holding the Scheme procedure object to invoke. It ought to
3159 be a pointer to an automatic variable (i.e., one living on the stack),
3160 or the procedure object should be otherwise protected from GC.
3161
3162 ** scm_handle_by_message is a new handler function to use with
3163 `scm_internal_catch' if you want Guile to print a message and die.
3164 It's useful for dealing with throws to uncaught keys at the top level.
3165
3166 HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
3167 message header to print; if zero, we use "guile" instead. That
3168 text is followed by a colon, then the message described by ARGS.
3169
3170 ** The return type of scm_boot_guile is now void; the function does
3171 not return a value, and indeed, never returns at all.
3172
3173 ** The new function scm_shell makes it easy for user applications to
3174 process command-line arguments in a way that is compatible with the
3175 stand-alone guile interpreter (which is in turn compatible with SCSH,
3176 the Scheme shell).
3177
3178 To use the scm_shell function, first initialize any guile modules
3179 linked into your application, and then call scm_shell with the values
3180 of ARGC and ARGV your `main' function received. scm_shell will add
3181 any SCSH-style meta-arguments from the top of the script file to the
3182 argument vector, and then process the command-line arguments. This
3183 generally means loading a script file or starting up an interactive
3184 command interpreter. For details, see "Changes to the stand-alone
3185 interpreter" above.
3186
3187 ** The new functions scm_get_meta_args and scm_count_argv help you
3188 implement the SCSH-style meta-argument, `\'.
3189
3190 char **scm_get_meta_args (int ARGC, char **ARGV)
3191 If the second element of ARGV is a string consisting of a single
3192 backslash character (i.e. "\\" in Scheme notation), open the file
3193 named by the following argument, parse arguments from it, and return
3194 the spliced command line. The returned array is terminated by a
3195 null pointer.
3196
3197 For details of argument parsing, see above, under "guile now accepts
3198 command-line arguments compatible with SCSH..."
3199
3200 int scm_count_argv (char **ARGV)
3201 Count the arguments in ARGV, assuming it is terminated by a null
3202 pointer.
3203
3204 For an example of how these functions might be used, see the source
3205 code for the function scm_shell in libguile/script.c.
3206
3207 You will usually want to use scm_shell instead of calling this
3208 function yourself.
3209
3210 ** The new function scm_compile_shell_switches turns an array of
3211 command-line arguments into Scheme code to carry out the actions they
3212 describe. Given ARGC and ARGV, it returns a Scheme expression to
3213 evaluate, and calls scm_set_program_arguments to make any remaining
3214 command-line arguments available to the Scheme code. For example,
3215 given the following arguments:
3216
3217 -e main -s ekko a speckled gecko
3218
3219 scm_set_program_arguments will return the following expression:
3220
3221 (begin (load "ekko") (main (command-line)) (quit))
3222
3223 You will usually want to use scm_shell instead of calling this
3224 function yourself.
3225
3226 ** The function scm_shell_usage prints a usage message appropriate for
3227 an interpreter that uses scm_compile_shell_switches to handle its
3228 command-line arguments.
3229
3230 void scm_shell_usage (int FATAL, char *MESSAGE)
3231 Print a usage message to the standard error output. If MESSAGE is
3232 non-zero, write it before the usage message, followed by a newline.
3233 If FATAL is non-zero, exit the process, using FATAL as the
3234 termination status. (If you want to be compatible with Guile,
3235 always use 1 as the exit status when terminating due to command-line
3236 usage problems.)
3237
3238 You will usually want to use scm_shell instead of calling this
3239 function yourself.
3240
3241 ** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
3242 expressions. It used to return SCM_EOL. Earth-shattering.
3243
3244 ** The macros for declaring scheme objects in C code have been
3245 rearranged slightly. They are now:
3246
3247 SCM_SYMBOL (C_NAME, SCHEME_NAME)
3248 Declare a static SCM variable named C_NAME, and initialize it to
3249 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
3250 be a C identifier, and SCHEME_NAME should be a C string.
3251
3252 SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
3253 Just like SCM_SYMBOL, but make C_NAME globally visible.
3254
3255 SCM_VCELL (C_NAME, SCHEME_NAME)
3256 Create a global variable at the Scheme level named SCHEME_NAME.
3257 Declare a static SCM variable named C_NAME, and initialize it to
3258 point to the Scheme variable's value cell.
3259
3260 SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
3261 Just like SCM_VCELL, but make C_NAME globally visible.
3262
3263 The `guile-snarf' script writes initialization code for these macros
3264 to its standard output, given C source code as input.
3265
3266 The SCM_GLOBAL macro is gone.
3267
3268 ** The scm_read_line and scm_read_line_x functions have been replaced
3269 by Scheme code based on the %read-delimited! procedure (known to C
3270 code as scm_read_delimited_x). See its description above for more
3271 information.
3272
3273 ** The function scm_sys_open has been renamed to scm_open. It now
3274 returns a port instead of an FD object.
3275
3276 * The dynamic linking support has changed. For more information, see
3277 libguile/DYNAMIC-LINKING.
3278
3279 \f
3280 Guile 1.0b3
3281
3282 User-visible changes from Thursday, September 5, 1996 until Guile 1.0
3283 (Sun 5 Jan 1997):
3284
3285 * Changes to the 'guile' program:
3286
3287 ** Guile now loads some new files when it starts up. Guile first
3288 searches the load path for init.scm, and loads it if found. Then, if
3289 Guile is not being used to execute a script, and the user's home
3290 directory contains a file named `.guile', Guile loads that.
3291
3292 ** You can now use Guile as a shell script interpreter.
3293
3294 To paraphrase the SCSH manual:
3295
3296 When Unix tries to execute an executable file whose first two
3297 characters are the `#!', it treats the file not as machine code to
3298 be directly executed by the native processor, but as source code
3299 to be executed by some interpreter. The interpreter to use is
3300 specified immediately after the #! sequence on the first line of
3301 the source file. The kernel reads in the name of the interpreter,
3302 and executes that instead. It passes the interpreter the source
3303 filename as its first argument, with the original arguments
3304 following. Consult the Unix man page for the `exec' system call
3305 for more information.
3306
3307 Now you can use Guile as an interpreter, using a mechanism which is a
3308 compatible subset of that provided by SCSH.
3309
3310 Guile now recognizes a '-s' command line switch, whose argument is the
3311 name of a file of Scheme code to load. It also treats the two
3312 characters `#!' as the start of a comment, terminated by `!#'. Thus,
3313 to make a file of Scheme code directly executable by Unix, insert the
3314 following two lines at the top of the file:
3315
3316 #!/usr/local/bin/guile -s
3317 !#
3318
3319 Guile treats the argument of the `-s' command-line switch as the name
3320 of a file of Scheme code to load, and treats the sequence `#!' as the
3321 start of a block comment, terminated by `!#'.
3322
3323 For example, here's a version of 'echo' written in Scheme:
3324
3325 #!/usr/local/bin/guile -s
3326 !#
3327 (let loop ((args (cdr (program-arguments))))
3328 (if (pair? args)
3329 (begin
3330 (display (car args))
3331 (if (pair? (cdr args))
3332 (display " "))
3333 (loop (cdr args)))))
3334 (newline)
3335
3336 Why does `#!' start a block comment terminated by `!#', instead of the
3337 end of the line? That is the notation SCSH uses, and although we
3338 don't yet support the other SCSH features that motivate that choice,
3339 we would like to be backward-compatible with any existing Guile
3340 scripts once we do. Furthermore, if the path to Guile on your system
3341 is too long for your kernel, you can start the script with this
3342 horrible hack:
3343
3344 #!/bin/sh
3345 exec /really/long/path/to/guile -s "$0" ${1+"$@"}
3346 !#
3347
3348 Note that some very old Unix systems don't support the `#!' syntax.
3349
3350
3351 ** You can now run Guile without installing it.
3352
3353 Previous versions of the interactive Guile interpreter (`guile')
3354 couldn't start up unless Guile's Scheme library had been installed;
3355 they used the value of the environment variable `SCHEME_LOAD_PATH'
3356 later on in the startup process, but not to find the startup code
3357 itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
3358 code.
3359
3360 To run Guile without installing it, build it in the normal way, and
3361 then set the environment variable `SCHEME_LOAD_PATH' to a
3362 colon-separated list of directories, including the top-level directory
3363 of the Guile sources. For example, if you unpacked Guile so that the
3364 full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
3365 you might say
3366
3367 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
3368
3369
3370 ** Guile's read-eval-print loop no longer prints #<unspecified>
3371 results. If the user wants to see this, she can evaluate the
3372 expression (assert-repl-print-unspecified #t), perhaps in her startup
3373 file.
3374
3375 ** Guile no longer shows backtraces by default when an error occurs;
3376 however, it does display a message saying how to get one, and how to
3377 request that they be displayed by default. After an error, evaluate
3378 (backtrace)
3379 to see a backtrace, and
3380 (debug-enable 'backtrace)
3381 to see them by default.
3382
3383
3384
3385 * Changes to Guile Scheme:
3386
3387 ** Guile now distinguishes between #f and the empty list.
3388
3389 This is for compatibility with the IEEE standard, the (possibly)
3390 upcoming Revised^5 Report on Scheme, and many extant Scheme
3391 implementations.
3392
3393 Guile used to have #f and '() denote the same object, to make Scheme's
3394 type system more compatible with Emacs Lisp's. However, the change
3395 caused too much trouble for Scheme programmers, and we found another
3396 way to reconcile Emacs Lisp with Scheme that didn't require this.
3397
3398
3399 ** Guile's delq, delv, delete functions, and their destructive
3400 counterparts, delq!, delv!, and delete!, now remove all matching
3401 elements from the list, not just the first. This matches the behavior
3402 of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
3403 functions which inspired them.
3404
3405 I recognize that this change may break code in subtle ways, but it
3406 seems best to make the change before the FSF's first Guile release,
3407 rather than after.
3408
3409
3410 ** The compiled-library-path function has been deleted from libguile.
3411
3412 ** The facilities for loading Scheme source files have changed.
3413
3414 *** The variable %load-path now tells Guile which directories to search
3415 for Scheme code. Its value is a list of strings, each of which names
3416 a directory.
3417
3418 *** The variable %load-extensions now tells Guile which extensions to
3419 try appending to a filename when searching the load path. Its value
3420 is a list of strings. Its default value is ("" ".scm").
3421
3422 *** (%search-load-path FILENAME) searches the directories listed in the
3423 value of the %load-path variable for a Scheme file named FILENAME,
3424 with all the extensions listed in %load-extensions. If it finds a
3425 match, then it returns its full filename. If FILENAME is absolute, it
3426 returns it unchanged. Otherwise, it returns #f.
3427
3428 %search-load-path will not return matches that refer to directories.
3429
3430 *** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
3431 uses %seach-load-path to find a file named FILENAME, and loads it if
3432 it finds it. If it can't read FILENAME for any reason, it throws an
3433 error.
3434
3435 The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
3436 `read' function.
3437
3438 *** load uses the same searching semantics as primitive-load.
3439
3440 *** The functions %try-load, try-load-with-path, %load, load-with-path,
3441 basic-try-load-with-path, basic-load-with-path, try-load-module-with-
3442 path, and load-module-with-path have been deleted. The functions
3443 above should serve their purposes.
3444
3445 *** If the value of the variable %load-hook is a procedure,
3446 `primitive-load' applies its value to the name of the file being
3447 loaded (without the load path directory name prepended). If its value
3448 is #f, it is ignored. Otherwise, an error occurs.
3449
3450 This is mostly useful for printing load notification messages.
3451
3452
3453 ** The function `eval!' is no longer accessible from the scheme level.
3454 We can't allow operations which introduce glocs into the scheme level,
3455 because Guile's type system can't handle these as data. Use `eval' or
3456 `read-and-eval!' (see below) as replacement.
3457
3458 ** The new function read-and-eval! reads an expression from PORT,
3459 evaluates it, and returns the result. This is more efficient than
3460 simply calling `read' and `eval', since it is not necessary to make a
3461 copy of the expression for the evaluator to munge.
3462
3463 Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
3464 for the `read' function.
3465
3466
3467 ** The function `int?' has been removed; its definition was identical
3468 to that of `integer?'.
3469
3470 ** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
3471 use the R4RS names for these functions.
3472
3473 ** The function object-properties no longer returns the hash handle;
3474 it simply returns the object's property list.
3475
3476 ** Many functions have been changed to throw errors, instead of
3477 returning #f on failure. The point of providing exception handling in
3478 the language is to simplify the logic of user code, but this is less
3479 useful if Guile's primitives don't throw exceptions.
3480
3481 ** The function `fileno' has been renamed from `%fileno'.
3482
3483 ** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
3484
3485
3486 * Changes to Guile's C interface:
3487
3488 ** The library's initialization procedure has been simplified.
3489 scm_boot_guile now has the prototype:
3490
3491 void scm_boot_guile (int ARGC,
3492 char **ARGV,
3493 void (*main_func) (),
3494 void *closure);
3495
3496 scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
3497 MAIN_FUNC should do all the work of the program (initializing other
3498 packages, reading user input, etc.) before returning. When MAIN_FUNC
3499 returns, call exit (0); this function never returns. If you want some
3500 other exit value, MAIN_FUNC may call exit itself.
3501
3502 scm_boot_guile arranges for program-arguments to return the strings
3503 given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
3504 scm_set_program_arguments with the final list, so Scheme code will
3505 know which arguments have been processed.
3506
3507 scm_boot_guile establishes a catch-all catch handler which prints an
3508 error message and exits the process. This means that Guile exits in a
3509 coherent way when system errors occur and the user isn't prepared to
3510 handle it. If the user doesn't like this behavior, they can establish
3511 their own universal catcher in MAIN_FUNC to shadow this one.
3512
3513 Why must the caller do all the real work from MAIN_FUNC? The garbage
3514 collector assumes that all local variables of type SCM will be above
3515 scm_boot_guile's stack frame on the stack. If you try to manipulate
3516 SCM values after this function returns, it's the luck of the draw
3517 whether the GC will be able to find the objects you allocate. So,
3518 scm_boot_guile function exits, rather than returning, to discourage
3519 people from making that mistake.
3520
3521 The IN, OUT, and ERR arguments were removed; there are other
3522 convenient ways to override these when desired.
3523
3524 The RESULT argument was deleted; this function should never return.
3525
3526 The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
3527 general.
3528
3529
3530 ** Guile's header files should no longer conflict with your system's
3531 header files.
3532
3533 In order to compile code which #included <libguile.h>, previous
3534 versions of Guile required you to add a directory containing all the
3535 Guile header files to your #include path. This was a problem, since
3536 Guile's header files have names which conflict with many systems'
3537 header files.
3538
3539 Now only <libguile.h> need appear in your #include path; you must
3540 refer to all Guile's other header files as <libguile/mumble.h>.
3541 Guile's installation procedure puts libguile.h in $(includedir), and
3542 the rest in $(includedir)/libguile.
3543
3544
3545 ** Two new C functions, scm_protect_object and scm_unprotect_object,
3546 have been added to the Guile library.
3547
3548 scm_protect_object (OBJ) protects OBJ from the garbage collector.
3549 OBJ will not be freed, even if all other references are dropped,
3550 until someone does scm_unprotect_object (OBJ). Both functions
3551 return OBJ.
3552
3553 Note that calls to scm_protect_object do not nest. You can call
3554 scm_protect_object any number of times on a given object, and the
3555 next call to scm_unprotect_object will unprotect it completely.
3556
3557 Basically, scm_protect_object and scm_unprotect_object just
3558 maintain a list of references to things. Since the GC knows about
3559 this list, all objects it mentions stay alive. scm_protect_object
3560 adds its argument to the list; scm_unprotect_object remove its
3561 argument from the list.
3562
3563
3564 ** scm_eval_0str now returns the value of the last expression
3565 evaluated.
3566
3567 ** The new function scm_read_0str reads an s-expression from a
3568 null-terminated string, and returns it.
3569
3570 ** The new function `scm_stdio_to_port' converts a STDIO file pointer
3571 to a Scheme port object.
3572
3573 ** The new function `scm_set_program_arguments' allows C code to set
3574 the value returned by the Scheme `program-arguments' function.
3575
3576 \f
3577 Older changes:
3578
3579 * Guile no longer includes sophisticated Tcl/Tk support.
3580
3581 The old Tcl/Tk support was unsatisfying to us, because it required the
3582 user to link against the Tcl library, as well as Tk and Guile. The
3583 interface was also un-lispy, in that it preserved Tcl/Tk's practice of
3584 referring to widgets by names, rather than exporting widgets to Scheme
3585 code as a special datatype.
3586
3587 In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
3588 maintainers described some very interesting changes in progress to the
3589 Tcl/Tk internals, which would facilitate clean interfaces between lone
3590 Tk and other interpreters --- even for garbage-collected languages
3591 like Scheme. They expected the new Tk to be publicly available in the
3592 fall of 1996.
3593
3594 Since it seems that Guile might soon have a new, cleaner interface to
3595 lone Tk, and that the old Guile/Tk glue code would probably need to be
3596 completely rewritten, we (Jim Blandy and Richard Stallman) have
3597 decided not to support the old code. We'll spend the time instead on
3598 a good interface to the newer Tk, as soon as it is available.
3599
3600 Until then, gtcltk-lib provides trivial, low-maintenance functionality.
3601
3602 \f
3603 Copyright information:
3604
3605 Copyright (C) 1996,1997 Free Software Foundation, Inc.
3606
3607 Permission is granted to anyone to make or distribute verbatim copies
3608 of this document as received, in any medium, provided that the
3609 copyright notice and this permission notice are preserved,
3610 thus giving the recipient permission to redistribute in turn.
3611
3612 Permission is granted to distribute modified versions
3613 of this document, or of portions of it,
3614 under the above conditions, provided also that they
3615 carry prominent notices stating who last changed them.
3616
3617 \f
3618 Local variables:
3619 mode: outline
3620 paragraph-separate: "[ \f]*$"
3621 end:
3622