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