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