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