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