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