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