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