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