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