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