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