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