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