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