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