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