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