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