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