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