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