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