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