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