Formatting tweak.
[bpt/guile.git] / NEWS
CommitLineData
f7b47737 1Guile NEWS --- history of user-visible changes. -*- text -*-
d23bbf3e 2Copyright (C) 1996, 1997, 1998 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
f3227c7a
JB
7Changes since Guile 1.3:
8
d77fb593
JB
9* Changes to the distribution
10
11** The configure script now accepts a --with-readline flag.
12
13By default, Guile includes support for the readline line-editing
14library, if a sufficiently recent version of the library is installed
15on your system.
16
17If you do not want readline included in Guile, pass the following flag
18to the configure script:
19
20 --with-readline=no
21
22You may not want to configure Guile to use readline if you are unable
23to release your program under the GNU General Public License; the
24readline library is released under the GPL, so anything linked with it
25must also be distributed under the GPL.
26
27Enabling readline support does not significantly increase the size of
28the Guile library. Readline itself is a shared library on most
29systems, and the readline interface code in Guile is less than 3
30kilobytes long.
31
32In future releases of Guile, we hope to have the readline support
33linked into Guile dynamically, if and when you use it. This would
34make this configuration option unnecessary; the same Guile library
35could be used both with and without the readline library.
36
e4eae9b1
MD
37* Changes to the stand-alone interpreter
38
2a2d0d0e 39** Command-line editing is enhanced.
b3a941b9 40
2a2d0d0e
JB
41If you have a sufficiently recent version of the GNU readline library
42installed on your system, Guile will use it to read expressions
43interactively.
e4eae9b1 44
2a2d0d0e
JB
45You can now use the readline-options interface to control readline's
46behavior. You can now control the readline library's behavior by
47changing the options listed below.
e4eae9b1 48
2a2d0d0e
JB
49 (readline-enable 'history-file)
50 Tell readline to record your commands in a file when you exit
51 Guile, and restore them when you restart Guile. By default, Guile
52 saves commands to `$HOME/.guile_history', but if the
53 `GUILE_HISTORY' environment variable is set, Guile will use its
54 value as the name of the history file.
55
56 If Guile is unable to save or restore lines from the history file,
57 the operation is simply not performed; the user is not notified.
58
59 (readline-disable 'history-file)
60 Tell Guile not to save or restore command history.
61
62 (readline-set! history-length N)
63 Tell Guile to save at most N lines of command history.
64
65 (readline-set! bounce-parens N)
66 Tell Guile to indicate the matching opening parenthesis when you
67 type a closing parenthesis, by resting the cursor on it for N
68 milliseconds. If N is zero, do not highlight opening parethesis.
e4eae9b1 69
67ad463a
MD
70** All builtins now print as primitives.
71Previously builtin procedures not belonging to the fundamental subr
72types printed as #<compiled closure #<primitive-procedure gsubr-apply>>.
73Now, they print as #<primitive-procedure NAME>.
74
75** Backtraces slightly more intelligible.
76gsubr-apply and macro transformer application frames no longer appear
77in backtraces.
78
69c6acbb
JB
79* Changes to Scheme functions and syntax
80
deaceb4e
JB
81** New module (ice-9 getopt-long), with the function `getopt-long'.
82
83getopt-long is a function for parsing command-line arguments in a
84manner consistent with other GNU programs.
85
86(getopt-long ARGS GRAMMAR)
87Parse the arguments ARGS according to the argument list grammar GRAMMAR.
88
89ARGS should be a list of strings. Its first element should be the
90name of the program; subsequent elements should be the arguments
91that were passed to the program on the command line. The
92`program-arguments' procedure returns a list of this form.
93
94GRAMMAR is a list of the form:
95((OPTION (PROPERTY VALUE) ...) ...)
96
97Each OPTION should be a symbol. `getopt-long' will accept a
98command-line option named `--OPTION'.
99Each option can have the following (PROPERTY VALUE) pairs:
100
101 (single-char CHAR) --- Accept `-CHAR' as a single-character
102 equivalent to `--OPTION'. This is how to specify traditional
103 Unix-style flags.
104 (required? BOOL) --- If BOOL is true, the option is required.
105 getopt-long will raise an error if it is not found in ARGS.
106 (value BOOL) --- If BOOL is #t, the option accepts a value; if
107 it is #f, it does not; and if it is the symbol
108 `optional', the option may appear in ARGS with or
109 without a value.
110 (predicate FUNC) --- If the option accepts a value (i.e. you
111 specified `(value #t)' for this option), then getopt
112 will apply FUNC to the value, and throw an exception
113 if it returns #f. FUNC should be a procedure which
114 accepts a string and returns a boolean value; you may
115 need to use quasiquotes to get it into GRAMMAR.
116
117The (PROPERTY VALUE) pairs may occur in any order, but each
118property may occur only once. By default, options do not have
119single-character equivalents, are not required, and do not take
120values.
121
122In ARGS, single-character options may be combined, in the usual
123Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option
124accepts values, then it must be the last option in the
125combination; the value is the next argument. So, for example, using
126the following grammar:
127 ((apples (single-char #\a))
128 (blimps (single-char #\b) (value #t))
129 (catalexis (single-char #\c) (value #t)))
130the following argument lists would be acceptable:
131 ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values
132 for "blimps" and "catalexis")
133 ("-ab" "bang" "-c" "couth") (same)
134 ("-ac" "couth" "-b" "bang") (same)
135 ("-abc" "couth" "bang") (an error, since `-b' is not the
136 last option in its combination)
137
138If an option's value is optional, then `getopt-long' decides
139whether it has a value by looking at what follows it in ARGS. If
140the next element is a string, and it does not appear to be an
141option itself, then that string is the option's value.
142
143The value of a long option can appear as the next element in ARGS,
144or it can follow the option name, separated by an `=' character.
145Thus, using the same grammar as above, the following argument lists
146are equivalent:
147 ("--apples" "Braeburn" "--blimps" "Goodyear")
148 ("--apples=Braeburn" "--blimps" "Goodyear")
149 ("--blimps" "Goodyear" "--apples=Braeburn")
150
151If the option "--" appears in ARGS, argument parsing stops there;
152subsequent arguments are returned as ordinary arguments, even if
153they resemble options. So, in the argument list:
154 ("--apples" "Granny Smith" "--" "--blimp" "Goodyear")
155`getopt-long' will recognize the `apples' option as having the
156value "Granny Smith", but it will not recognize the `blimp'
157option; it will return the strings "--blimp" and "Goodyear" as
158ordinary argument strings.
159
160The `getopt-long' function returns the parsed argument list as an
161assocation list, mapping option names --- the symbols from GRAMMAR
162--- onto their values, or #t if the option does not accept a value.
163Unused options do not appear in the alist.
164
165All arguments that are not the value of any option are returned
166as a list, associated with the empty list.
167
168`getopt-long' throws an exception if:
169- it finds an unrecognized option in ARGS
170- a required option is omitted
171- an option that requires an argument doesn't get one
172- an option that doesn't accept an argument does get one (this can
173 only happen using the long option `--opt=value' syntax)
174- an option predicate fails
175
176So, for example:
177
178(define grammar
179 `((lockfile-dir (required? #t)
180 (value #t)
181 (single-char #\k)
182 (predicate ,file-is-directory?))
183 (verbose (required? #f)
184 (single-char #\v)
185 (value #f))
186 (x-includes (single-char #\x))
187 (rnet-server (single-char #\y)
188 (predicate ,string?))))
189
190(getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include"
191 "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3")
192 grammar)
193=> ((() "foo1" "-fred" "foo2" "foo3")
194 (rnet-server . "lamprod")
195 (x-includes . "/usr/include")
196 (lockfile-dir . "/tmp")
197 (verbose . #t))
198
199** The (ice-9 getopt-gnu-style) module is obsolete; use (ice-9 getopt-long).
200
201It will be removed in a few releases.
202
08394899
MS
203** New syntax: lambda*
204** New syntax: define*
205** New syntax: define*-public
206** New syntax: defmacro*
207** New syntax: defmacro*-public
208Guile now supports optional arguments.
209
210`lambda*', `define*', `define*-public', `defmacro*' and
211`defmacro*-public' are identical to the non-* versions except that
212they use an extended type of parameter list that has the following BNF
213syntax (parentheses are literal, square brackets indicate grouping,
214and `*', `+' and `?' have the usual meaning):
215
216 ext-param-list ::= ( [identifier]* [#&optional [ext-var-decl]+]?
217 [#&key [ext-var-decl]+ [#&allow-other-keys]?]?
218 [[#&rest identifier]|[. identifier]]? ) | [identifier]
219
220 ext-var-decl ::= identifier | ( identifier expression )
221
222The semantics are best illustrated with the following documentation
223and examples for `lambda*':
224
225 lambda* args . body
226 lambda extended for optional and keyword arguments
227
228 lambda* creates a procedure that takes optional arguments. These
229 are specified by putting them inside brackets at the end of the
230 paramater list, but before any dotted rest argument. For example,
231 (lambda* (a b #&optional c d . e) '())
232 creates a procedure with fixed arguments a and b, optional arguments c
233 and d, and rest argument e. If the optional arguments are omitted
234 in a call, the variables for them are unbound in the procedure. This
235 can be checked with the bound? macro.
236
237 lambda* can also take keyword arguments. For example, a procedure
238 defined like this:
239 (lambda* (#&key xyzzy larch) '())
240 can be called with any of the argument lists (#:xyzzy 11)
241 (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments
242 are given as keywords are bound to values.
243
244 Optional and keyword arguments can also be given default values
245 which they take on when they are not present in a call, by giving a
246 two-item list in place of an optional argument, for example in:
247 (lambda* (foo #&optional (bar 42) #&key (baz 73)) (list foo bar baz))
248 foo is a fixed argument, bar is an optional argument with default
249 value 42, and baz is a keyword argument with default value 73.
250 Default value expressions are not evaluated unless they are needed
251 and until the procedure is called.
252
253 lambda* now supports two more special parameter list keywords.
254
255 lambda*-defined procedures now throw an error by default if a
256 keyword other than one of those specified is found in the actual
257 passed arguments. However, specifying #&allow-other-keys
258 immediately after the kyword argument declarations restores the
259 previous behavior of ignoring unknown keywords. lambda* also now
260 guarantees that if the same keyword is passed more than once, the
261 last one passed is the one that takes effect. For example,
262 ((lambda* (#&key (heads 0) (tails 0)) (display (list heads tails)))
263 #:heads 37 #:tails 42 #:heads 99)
264 would result in (99 47) being displayed.
265
266 #&rest is also now provided as a synonym for the dotted syntax rest
267 argument. The argument lists (a . b) and (a #&rest b) are equivalent in
268 all respects to lambda*. This is provided for more similarity to DSSSL,
269 MIT-Scheme and Kawa among others, as well as for refugees from other
270 Lisp dialects.
271
272Further documentation may be found in the optargs.scm file itself.
273
274The optional argument module also exports the macros `let-optional',
275`let-optional*', `let-keywords', `let-keywords*' and `bound?'. These
276are not documented here because they may be removed in the future, but
277full documentation is still available in optargs.scm.
278
2e132553
JB
279** New syntax: and-let*
280Guile now supports the `and-let*' form, described in the draft SRFI-2.
281
282Syntax: (land* (<clause> ...) <body> ...)
283Each <clause> should have one of the following forms:
284 (<variable> <expression>)
285 (<expression>)
286 <bound-variable>
287Each <variable> or <bound-variable> should be an identifier. Each
288<expression> should be a valid expression. The <body> should be a
289possibly empty sequence of expressions, like the <body> of a
290lambda form.
291
292Semantics: A LAND* expression is evaluated by evaluating the
293<expression> or <bound-variable> of each of the <clause>s from
294left to right. The value of the first <expression> or
295<bound-variable> that evaluates to a false value is returned; the
296remaining <expression>s and <bound-variable>s are not evaluated.
297The <body> forms are evaluated iff all the <expression>s and
298<bound-variable>s evaluate to true values.
299
300The <expression>s and the <body> are evaluated in an environment
301binding each <variable> of the preceding (<variable> <expression>)
302clauses to the value of the <expression>. Later bindings
303shadow earlier bindings.
304
305Guile's and-let* macro was contributed by Michael Livshin.
306
ed8c8636
MD
307** New function: sorted? SEQUENCE LESS?
308Returns `#t' when the sequence argument is in non-decreasing order
309according to LESS? (that is, there is no adjacent pair `... x y
310...' for which `(less? y x)').
311
312Returns `#f' when the sequence contains at least one out-of-order
313pair. It is an error if the sequence is neither a list nor a
314vector.
315
316** New function: merge LIST1 LIST2 LESS?
317LIST1 and LIST2 are sorted lists.
318Returns the sorted list of all elements in LIST1 and LIST2.
319
320Assume that the elements a and b1 in LIST1 and b2 in LIST2 are "equal"
321in the sense that (LESS? x y) --> #f for x, y in {a, b1, b2},
322and that a < b1 in LIST1. Then a < b1 < b2 in the result.
323(Here "<" should read "comes before".)
324
325** New procedure: merge! LIST1 LIST2 LESS?
326Merges two lists, re-using the pairs of LIST1 and LIST2 to build
327the result. If the code is compiled, and LESS? constructs no new
328pairs, no pairs at all will be allocated. The first pair of the
329result will be either the first pair of LIST1 or the first pair of
330LIST2.
331
332** New function: sort SEQUENCE LESS?
333Accepts either a list or a vector, and returns a new sequence
334which is sorted. The new sequence is the same type as the input.
335Always `(sorted? (sort sequence less?) less?)'. The original
336sequence is not altered in any way. The new sequence shares its
337elements with the old one; no elements are copied.
338
339** New procedure: sort! SEQUENCE LESS
340Returns its sorted result in the original boxes. No new storage is
341allocated at all. Proper usage: (set! slist (sort! slist <))
342
343** New function: stable-sort SEQUENCE LESS?
344Similar to `sort' but stable. That is, if "equal" elements are
345ordered a < b in the original sequence, they will have the same order
346in the result.
347
348** New function: stable-sort! SEQUENCE LESS?
349Similar to `sort!' but stable.
350Uses temporary storage when sorting vectors.
351
352** New functions: sort-list, sort-list!
353Added for compatibility with scsh.
354
3e8370c3
MD
355** New function: random N [STATE]
356Accepts a positive integer or real N and returns a number of the
357same type between zero (inclusive) and N (exclusive). The values
358returned have a uniform distribution.
359
360The optional argument STATE must be of the type produced by
416075f1
MD
361`copy-random-state' or `seed->random-state'. It defaults to the value
362of the variable `*random-state*'. This object is used to maintain the
363state of the pseudo-random-number generator and is altered as a side
364effect of the `random' operation.
3e8370c3
MD
365
366** New variable: *random-state*
367Holds a data structure that encodes the internal state of the
368random-number generator that `random' uses by default. The nature
369of this data structure is implementation-dependent. It may be
370printed out and successfully read back in, but may or may not
371function correctly as a random-number state object in another
372implementation.
373
416075f1 374** New function: copy-random-state [STATE]
3e8370c3
MD
375Returns a new object of type suitable for use as the value of the
376variable `*random-state*' and as a second argument to `random'.
377If argument STATE is given, a copy of it is returned. Otherwise a
378copy of `*random-state*' is returned.
416075f1
MD
379
380** New function: seed->random-state SEED
381Returns a new object of type suitable for use as the value of the
382variable `*random-state*' and as a second argument to `random'.
383SEED is a string or a number. A new state is generated and
384initialized using SEED.
3e8370c3
MD
385
386** New function: random:uniform [STATE]
387Returns an uniformly distributed inexact real random number in the
388range between 0 and 1.
389
390** New procedure: random:solid-sphere! VECT [STATE]
391Fills VECT with inexact real random numbers the sum of whose
392squares is less than 1.0. Thinking of VECT as coordinates in
393space of dimension N = `(vector-length VECT)', the coordinates are
394uniformly distributed within the unit N-shere. The sum of the
395squares of the numbers is returned. VECT can be either a vector
396or a uniform vector of doubles.
397
398** New procedure: random:hollow-sphere! VECT [STATE]
399Fills VECT with inexact real random numbers the sum of whose squares
400is equal to 1.0. Thinking of VECT as coordinates in space of
401dimension n = `(vector-length VECT)', the coordinates are uniformly
402distributed over the surface of the unit n-shere. VECT can be either
403a vector or a uniform vector of doubles.
404
405** New function: random:normal [STATE]
406Returns an inexact real in a normal distribution with mean 0 and
407standard deviation 1. For a normal distribution with mean M and
408standard deviation D use `(+ M (* D (random:normal)))'.
409
410** New procedure: random:normal-vector! VECT [STATE]
411Fills VECT with inexact real random numbers which are independent and
412standard normally distributed (i.e., with mean 0 and variance 1).
413VECT can be either a vector or a uniform vector of doubles.
414
415** New function: random:exp STATE
416Returns an inexact real in an exponential distribution with mean 1.
417For an exponential distribution with mean U use (* U (random:exp)).
418
69c6acbb
JB
419** The range of logand, logior, logxor, logtest, and logbit? have changed.
420
421These functions now operate on numbers in the range of a C unsigned
422long.
423
424These functions used to operate on numbers in the range of a C signed
425long; however, this seems inappropriate, because Guile integers don't
426overflow.
427
ba4ee0d6
MD
428** New function: make-guardian
429This is an implementation of guardians as described in
430R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a
431Generation-Based Garbage Collector" ACM SIGPLAN Conference on
432Programming Language Design and Implementation, June 1993
433ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz
434
88ceea5c
MD
435** New functions: delq1!, delv1!, delete1!
436These procedures behave similar to delq! and friends but delete only
437one object if at all.
438
55254a6a
MD
439** New function: unread-string STRING PORT
440Unread STRING to PORT, that is, push it back onto the port so that
441next read operation will work on the pushed back characters.
442
443** unread-char can now be called multiple times
444If unread-char is called multiple times, the unread characters will be
445read again in last-in first-out order.
446
67ad463a 447** New function: map-in-order PROC LIST1 LIST2 ...
d41b3904
MD
448Version of `map' which guarantees that the procedure is applied to the
449lists in serial order.
450
67ad463a
MD
451** Renamed `serial-array-copy!' and `serial-array-map!' to
452`array-copy-in-order!' and `array-map-in-order!'. The old names are
453now obsolete and will go away in release 1.5.
454
cf7132b3 455** New syntax: collect BODY1 ...
d41b3904
MD
456Version of `begin' which returns a list of the results of the body
457forms instead of the result of the last body form. In contrast to
cf7132b3 458`begin', `collect' allows an empty body.
d41b3904 459
e4eae9b1
MD
460** New functions: read-history FILENAME, write-history FILENAME
461Read/write command line history from/to file. Returns #t on success
462and #f if an error occured.
463
3ffc7a36
MD
464* Changes to the gh_ interface
465
466** gh_scm2doubles
467
468Now takes a second argument which is the result array. If this
469pointer is NULL, a new array is malloced (the old behaviour).
470
471** gh_chars2byvect, gh_shorts2svect, gh_floats2fvect, gh_scm2chars,
472 gh_scm2shorts, gh_scm2longs, gh_scm2floats
473
474New functions.
475
3e8370c3
MD
476* Changes to the scm_ interface
477
478** Plug in interface for random number generators
479The variable `scm_the_rng' in random.c contains a value and three
480function pointers which together define the current random number
481generator being used by the Scheme level interface and the random
482number library functions.
483
484The user is free to replace the default generator with the generator
485of his own choice.
486
487*** Variable: size_t scm_the_rng.rstate_size
488The size of the random state type used by the current RNG
489measured in chars.
490
491*** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE)
492Given the random STATE, return 32 random bits.
493
494*** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N)
495Seed random state STATE using string S of length N.
496
497*** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE)
498Given random state STATE, return a malloced copy.
499
500** Default RNG
501The default RNG is the MWC (Multiply With Carry) random number
502generator described by George Marsaglia at the Department of
503Statistics and Supercomputer Computations Research Institute, The
504Florida State University (http://stat.fsu.edu/~geo).
505
506It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and
507passes all tests in the DIEHARD test suite
508(http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits
509costs one multiply and one add on platforms which either supports long
510longs (gcc does this on most systems) or have 64 bit longs. The cost
511is four multiply on other systems but this can be optimized by writing
512scm_i_uniform32 in assembler.
513
514These functions are provided through the scm_the_rng interface for use
515by libguile and the application.
516
517*** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE)
518Given the random STATE, return 32 random bits.
519Don't use this function directly. Instead go through the plugin
520interface (see "Plug in interface" above).
521
522*** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N)
523Initialize STATE using SEED of length N.
524
525*** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE)
526Return a malloc:ed copy of STATE. This function can easily be re-used
527in the interfaces to other RNGs.
528
529** Random number library functions
530These functions use the current RNG through the scm_the_rng interface.
531It might be a good idea to use these functions from your C code so
532that only one random generator is used by all code in your program.
533
534You can get the default random state using:
535
536*** Variable: SCM scm_var_random_state
537Contains the vcell of the Scheme variable "*random-state*" which is
538used as default state by all random number functions in the Scheme
539level interface.
540
541Example:
542
543 double x = scm_i_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state)));
544
545*** Function: double scm_i_uniform01 (scm_rstate *STATE)
546Return a sample from the uniform(0,1) distribution.
547
548*** Function: double scm_i_normal01 (scm_rstate *STATE)
549Return a sample from the normal(0,1) distribution.
550
551*** Function: double scm_i_exp1 (scm_rstate *STATE)
552Return a sample from the exp(1) distribution.
553
554*** Function: unsigned long scm_i_random (unsigned long M, scm_rstate *STATE)
555Return a sample from the discrete uniform(0,M) distribution.
556
f3227c7a 557\f
d23bbf3e 558Changes in Guile 1.3 (released Monday, October 19, 1998):
c484bf7f
JB
559
560* Changes to the distribution
561
e2d6569c
JB
562** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
563To avoid conflicts, programs should name environment variables after
564themselves, except when there's a common practice establishing some
565other convention.
566
567For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
568giving the former precedence, and printing a warning message if the
569latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
570
571** The header files related to multi-byte characters have been removed.
572They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
573which referred to these explicitly will probably need to be rewritten,
574since the support for the variant string types has been removed; see
575below.
576
577** The header files append.h and sequences.h have been removed. These
578files implemented non-R4RS operations which would encourage
579non-portable programming style and less easy-to-read code.
3a97e020 580
c484bf7f
JB
581* Changes to the stand-alone interpreter
582
2e368582 583** New procedures have been added to implement a "batch mode":
ec4ab4fd 584
2e368582 585*** Function: batch-mode?
ec4ab4fd
GH
586
587 Returns a boolean indicating whether the interpreter is in batch
588 mode.
589
2e368582 590*** Function: set-batch-mode?! ARG
ec4ab4fd
GH
591
592 If ARG is true, switches the interpreter to batch mode. The `#f'
593 case has not been implemented.
594
2e368582
JB
595** Guile now provides full command-line editing, when run interactively.
596To use this feature, you must have the readline library installed.
597The Guile build process will notice it, and automatically include
598support for it.
599
600The readline library is available via anonymous FTP from any GNU
601mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
602
a5d6d578
MD
603** the-last-stack is now a fluid.
604
c484bf7f
JB
605* Changes to the procedure for linking libguile with your programs
606
71f20534 607** You can now use the `guile-config' utility to build programs that use Guile.
2e368582 608
2adfe1c0 609Guile now includes a command-line utility called `guile-config', which
71f20534
JB
610can provide information about how to compile and link programs that
611use Guile.
612
613*** `guile-config compile' prints any C compiler flags needed to use Guile.
614You should include this command's output on the command line you use
615to compile C or C++ code that #includes the Guile header files. It's
616usually just a `-I' flag to help the compiler find the Guile headers.
617
618
619*** `guile-config link' prints any linker flags necessary to link with Guile.
8aa5c148 620
71f20534 621This command writes to its standard output a list of flags which you
8aa5c148
JB
622must pass to the linker to link your code against the Guile library.
623The flags include '-lguile' itself, any other libraries the Guile
624library depends upon, and any `-L' flags needed to help the linker
625find those libraries.
2e368582
JB
626
627For example, here is a Makefile rule that builds a program named 'foo'
628from the object files ${FOO_OBJECTS}, and links them against Guile:
629
630 foo: ${FOO_OBJECTS}
2adfe1c0 631 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
2e368582 632
e2d6569c
JB
633Previous Guile releases recommended that you use autoconf to detect
634which of a predefined set of libraries were present on your system.
2adfe1c0 635It is more robust to use `guile-config', since it records exactly which
e2d6569c
JB
636libraries the installed Guile library requires.
637
2adfe1c0
JB
638This was originally called `build-guile', but was renamed to
639`guile-config' before Guile 1.3 was released, to be consistent with
640the analogous script for the GTK+ GUI toolkit, which is called
641`gtk-config'.
642
2e368582 643
8aa5c148
JB
644** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
645
646If you are using the GNU autoconf package to configure your program,
647you can use the GUILE_FLAGS autoconf macro to call `guile-config'
648(described above) and gather the necessary values for use in your
649Makefiles.
650
651The GUILE_FLAGS macro expands to configure script code which runs the
652`guile-config' script, to find out where Guile's header files and
653libraries are installed. It sets two variables, marked for
654substitution, as by AC_SUBST.
655
656 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
657 code that uses Guile header files. This is almost always just a
658 -I flag.
659
660 GUILE_LDFLAGS --- flags to pass to the linker to link a
661 program against Guile. This includes `-lguile' for the Guile
662 library itself, any libraries that Guile itself requires (like
663 -lqthreads), and so on. It may also include a -L flag to tell the
664 compiler where to find the libraries.
665
666GUILE_FLAGS is defined in the file guile.m4, in the top-level
667directory of the Guile distribution. You can copy it into your
668package's aclocal.m4 file, and then use it in your configure.in file.
669
670If you are using the `aclocal' program, distributed with GNU automake,
671to maintain your aclocal.m4 file, the Guile installation process
672installs guile.m4 where aclocal will find it. All you need to do is
673use GUILE_FLAGS in your configure.in file, and then run `aclocal';
674this will copy the definition of GUILE_FLAGS into your aclocal.m4
675file.
676
677
c484bf7f 678* Changes to Scheme functions and syntax
7ad3c1e7 679
02755d59 680** Multi-byte strings have been removed, as have multi-byte and wide
e2d6569c
JB
681ports. We felt that these were the wrong approach to
682internationalization support.
02755d59 683
2e368582
JB
684** New function: readline [PROMPT]
685Read a line from the terminal, and allow the user to edit it,
686prompting with PROMPT. READLINE provides a large set of Emacs-like
687editing commands, lets the user recall previously typed lines, and
688works on almost every kind of terminal, including dumb terminals.
689
690READLINE assumes that the cursor is at the beginning of the line when
691it is invoked. Thus, you can't print a prompt yourself, and then call
692READLINE; you need to package up your prompt as a string, pass it to
693the function, and let READLINE print the prompt itself. This is
694because READLINE needs to know the prompt's screen width.
695
8cd57bd0
JB
696For Guile to provide this function, you must have the readline
697library, version 2.1 or later, installed on your system. Readline is
698available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
699any GNU mirror site.
2e368582
JB
700
701See also ADD-HISTORY function.
702
703** New function: add-history STRING
704Add STRING as the most recent line in the history used by the READLINE
705command. READLINE does not add lines to the history itself; you must
706call ADD-HISTORY to make previous input available to the user.
707
8cd57bd0
JB
708** The behavior of the read-line function has changed.
709
710This function now uses standard C library functions to read the line,
711for speed. This means that it doesn not respect the value of
712scm-line-incrementors; it assumes that lines are delimited with
713#\newline.
714
715(Note that this is read-line, the function that reads a line of text
716from a port, not readline, the function that reads a line from a
717terminal, providing full editing capabilities.)
718
1a0106ef
JB
719** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
720
721This module provides some simple argument parsing. It exports one
722function:
723
724Function: getopt-gnu-style ARG-LS
725 Parse a list of program arguments into an alist of option
726 descriptions.
727
728 Each item in the list of program arguments is examined to see if
729 it meets the syntax of a GNU long-named option. An argument like
730 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
731 returned alist, where MUMBLE is a keyword object with the same
732 name as the argument. An argument like `--MUMBLE=FROB' produces
733 an element of the form (MUMBLE . FROB), where FROB is a string.
734
735 As a special case, the returned alist also contains a pair whose
736 car is the symbol `rest'. The cdr of this pair is a list
737 containing all the items in the argument list that are not options
738 of the form mentioned above.
739
740 The argument `--' is treated specially: all items in the argument
741 list appearing after such an argument are not examined, and are
742 returned in the special `rest' list.
743
744 This function does not parse normal single-character switches.
745 You will need to parse them out of the `rest' list yourself.
746
8cd57bd0
JB
747** The read syntax for byte vectors and short vectors has changed.
748
749Instead of #bytes(...), write #y(...).
750
751Instead of #short(...), write #h(...).
752
753This may seem nutty, but, like the other uniform vectors, byte vectors
754and short vectors want to have the same print and read syntax (and,
755more basic, want to have read syntax!). Changing the read syntax to
756use multiple characters after the hash sign breaks with the
757conventions used in R5RS and the conventions used for the other
758uniform vectors. It also introduces complexity in the current reader,
759both on the C and Scheme levels. (The Right solution is probably to
760change the syntax and prototypes for uniform vectors entirely.)
761
762
763** The new module (ice-9 session) provides useful interactive functions.
764
765*** New procedure: (apropos REGEXP OPTION ...)
766
767Display a list of top-level variables whose names match REGEXP, and
768the modules they are imported from. Each OPTION should be one of the
769following symbols:
770
771 value --- Show the value of each matching variable.
772 shadow --- Show bindings shadowed by subsequently imported modules.
773 full --- Same as both `shadow' and `value'.
774
775For example:
776
777 guile> (apropos "trace" 'full)
778 debug: trace #<procedure trace args>
779 debug: untrace #<procedure untrace args>
780 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
781 the-scm-module: before-backtrace-hook ()
782 the-scm-module: backtrace #<primitive-procedure backtrace>
783 the-scm-module: after-backtrace-hook ()
784 the-scm-module: has-shown-backtrace-hint? #f
785 guile>
786
787** There are new functions and syntax for working with macros.
788
789Guile implements macros as a special object type. Any variable whose
790top-level binding is a macro object acts as a macro. The macro object
791specifies how the expression should be transformed before evaluation.
792
793*** Macro objects now print in a reasonable way, resembling procedures.
794
795*** New function: (macro? OBJ)
796True iff OBJ is a macro object.
797
798*** New function: (primitive-macro? OBJ)
799Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
800macro transformers, implemented in eval.c rather than Scheme code.
801
dbdd0c16
JB
802Why do we have this function?
803- For symmetry with procedure? and primitive-procedure?,
804- to allow custom print procedures to tell whether a macro is
805 primitive, and display it differently, and
806- to allow compilers and user-written evaluators to distinguish
807 builtin special forms from user-defined ones, which could be
808 compiled.
809
8cd57bd0
JB
810*** New function: (macro-type OBJ)
811Return a value indicating what kind of macro OBJ is. Possible return
812values are:
813
814 The symbol `syntax' --- a macro created by procedure->syntax.
815 The symbol `macro' --- a macro created by procedure->macro.
816 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
817 The boolean #f --- if OBJ is not a macro object.
818
819*** New function: (macro-name MACRO)
820Return the name of the macro object MACRO's procedure, as returned by
821procedure-name.
822
823*** New function: (macro-transformer MACRO)
824Return the transformer procedure for MACRO.
825
826*** New syntax: (use-syntax MODULE ... TRANSFORMER)
827
828Specify a new macro expander to use in the current module. Each
829MODULE is a module name, with the same meaning as in the `use-modules'
830form; each named module's exported bindings are added to the current
831top-level environment. TRANSFORMER is an expression evaluated in the
832resulting environment which must yield a procedure to use as the
833module's eval transformer: every expression evaluated in this module
834is passed to this function, and the result passed to the Guile
835interpreter.
836
837*** macro-eval! is removed. Use local-eval instead.
29521173 838
8d9dcb3c
MV
839** Some magic has been added to the printer to better handle user
840written printing routines (like record printers, closure printers).
841
842The problem is that these user written routines must have access to
7fbd77df 843the current `print-state' to be able to handle fancy things like
8d9dcb3c
MV
844detection of circular references. These print-states have to be
845passed to the builtin printing routines (display, write, etc) to
846properly continue the print chain.
847
848We didn't want to change all existing print code so that it
8cd57bd0 849explicitly passes thru a print state in addition to a port. Instead,
8d9dcb3c
MV
850we extented the possible values that the builtin printing routines
851accept as a `port'. In addition to a normal port, they now also take
852a pair of a normal port and a print-state. Printing will go to the
853port and the print-state will be used to control the detection of
854circular references, etc. If the builtin function does not care for a
855print-state, it is simply ignored.
856
857User written callbacks are now called with such a pair as their
858`port', but because every function now accepts this pair as a PORT
859argument, you don't have to worry about that. In fact, it is probably
860safest to not check for these pairs.
861
862However, it is sometimes necessary to continue a print chain on a
863different port, for example to get a intermediate string
864representation of the printed value, mangle that string somehow, and
865then to finally print the mangled string. Use the new function
866
867 inherit-print-state OLD-PORT NEW-PORT
868
869for this. It constructs a new `port' that prints to NEW-PORT but
870inherits the print-state of OLD-PORT.
871
ef1ea498
MD
872** struct-vtable-offset renamed to vtable-offset-user
873
874** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
875
876** There is now a fourth (optional) argument to make-vtable-vtable and
877 make-struct when constructing new types (vtables). This argument
878 initializes field vtable-index-printer of the vtable.
879
4851dc57
MV
880** The detection of circular references has been extended to structs.
881That is, a structure that -- in the process of being printed -- prints
882itself does not lead to infinite recursion.
883
884** There is now some basic support for fluids. Please read
885"libguile/fluid.h" to find out more. It is accessible from Scheme with
886the following functions and macros:
887
9c3fb66f
MV
888Function: make-fluid
889
890 Create a new fluid object. Fluids are not special variables or
891 some other extension to the semantics of Scheme, but rather
892 ordinary Scheme objects. You can store them into variables (that
893 are still lexically scoped, of course) or into any other place you
894 like. Every fluid has a initial value of `#f'.
04c76b58 895
9c3fb66f 896Function: fluid? OBJ
04c76b58 897
9c3fb66f 898 Test whether OBJ is a fluid.
04c76b58 899
9c3fb66f
MV
900Function: fluid-ref FLUID
901Function: fluid-set! FLUID VAL
04c76b58
MV
902
903 Access/modify the fluid FLUID. Modifications are only visible
904 within the current dynamic root (that includes threads).
905
9c3fb66f
MV
906Function: with-fluids* FLUIDS VALUES THUNK
907
908 FLUIDS is a list of fluids and VALUES a corresponding list of
909 values for these fluids. Before THUNK gets called the values are
910 installed in the fluids and the old values of the fluids are
911 saved in the VALUES list. When the flow of control leaves THUNK
912 or reenters it, the values get swapped again. You might think of
913 this as a `safe-fluid-excursion'. Note that the VALUES list is
914 modified by `with-fluids*'.
915
916Macro: with-fluids ((FLUID VALUE) ...) FORM ...
917
918 The same as `with-fluids*' but with a different syntax. It looks
919 just like `let', but both FLUID and VALUE are evaluated. Remember,
920 fluids are not special variables but ordinary objects. FLUID
921 should evaluate to a fluid.
04c76b58 922
e2d6569c 923** Changes to system call interfaces:
64d01d13 924
e2d6569c 925*** close-port, close-input-port and close-output-port now return a
64d01d13
GH
926boolean instead of an `unspecified' object. #t means that the port
927was successfully closed, while #f means it was already closed. It is
928also now possible for these procedures to raise an exception if an
929error occurs (some errors from write can be delayed until close.)
930
e2d6569c 931*** the first argument to chmod, fcntl, ftell and fseek can now be a
6afcd3b2
GH
932file descriptor.
933
e2d6569c 934*** the third argument to fcntl is now optional.
6afcd3b2 935
e2d6569c 936*** the first argument to chown can now be a file descriptor or a port.
6afcd3b2 937
e2d6569c 938*** the argument to stat can now be a port.
6afcd3b2 939
e2d6569c 940*** The following new procedures have been added (most use scsh
64d01d13
GH
941interfaces):
942
e2d6569c 943*** procedure: close PORT/FD
ec4ab4fd
GH
944 Similar to close-port (*note close-port: Closing Ports.), but also
945 works on file descriptors. A side effect of closing a file
946 descriptor is that any ports using that file descriptor are moved
947 to a different file descriptor and have their revealed counts set
948 to zero.
949
e2d6569c 950*** procedure: port->fdes PORT
ec4ab4fd
GH
951 Returns the integer file descriptor underlying PORT. As a side
952 effect the revealed count of PORT is incremented.
953
e2d6569c 954*** procedure: fdes->ports FDES
ec4ab4fd
GH
955 Returns a list of existing ports which have FDES as an underlying
956 file descriptor, without changing their revealed counts.
957
e2d6569c 958*** procedure: fdes->inport FDES
ec4ab4fd
GH
959 Returns an existing input port which has FDES as its underlying
960 file descriptor, if one exists, and increments its revealed count.
961 Otherwise, returns a new input port with a revealed count of 1.
962
e2d6569c 963*** procedure: fdes->outport FDES
ec4ab4fd
GH
964 Returns an existing output port which has FDES as its underlying
965 file descriptor, if one exists, and increments its revealed count.
966 Otherwise, returns a new output port with a revealed count of 1.
967
968 The next group of procedures perform a `dup2' system call, if NEWFD
969(an integer) is supplied, otherwise a `dup'. The file descriptor to be
970duplicated can be supplied as an integer or contained in a port. The
64d01d13
GH
971type of value returned varies depending on which procedure is used.
972
ec4ab4fd
GH
973 All procedures also have the side effect when performing `dup2' that
974any ports using NEWFD are moved to a different file descriptor and have
64d01d13
GH
975their revealed counts set to zero.
976
e2d6569c 977*** procedure: dup->fdes PORT/FD [NEWFD]
ec4ab4fd 978 Returns an integer file descriptor.
64d01d13 979
e2d6569c 980*** procedure: dup->inport PORT/FD [NEWFD]
ec4ab4fd 981 Returns a new input port using the new file descriptor.
64d01d13 982
e2d6569c 983*** procedure: dup->outport PORT/FD [NEWFD]
ec4ab4fd 984 Returns a new output port using the new file descriptor.
64d01d13 985
e2d6569c 986*** procedure: dup PORT/FD [NEWFD]
ec4ab4fd
GH
987 Returns a new port if PORT/FD is a port, with the same mode as the
988 supplied port, otherwise returns an integer file descriptor.
64d01d13 989
e2d6569c 990*** procedure: dup->port PORT/FD MODE [NEWFD]
ec4ab4fd
GH
991 Returns a new port using the new file descriptor. MODE supplies a
992 mode string for the port (*note open-file: File Ports.).
64d01d13 993
e2d6569c 994*** procedure: setenv NAME VALUE
ec4ab4fd
GH
995 Modifies the environment of the current process, which is also the
996 default environment inherited by child processes.
64d01d13 997
ec4ab4fd
GH
998 If VALUE is `#f', then NAME is removed from the environment.
999 Otherwise, the string NAME=VALUE is added to the environment,
1000 replacing any existing string with name matching NAME.
64d01d13 1001
ec4ab4fd 1002 The return value is unspecified.
956055a9 1003
e2d6569c 1004*** procedure: truncate-file OBJ SIZE
6afcd3b2
GH
1005 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
1006 can be a string containing a file name or an integer file
1007 descriptor or port open for output on the file. The underlying
1008 system calls are `truncate' and `ftruncate'.
1009
1010 The return value is unspecified.
1011
e2d6569c 1012*** procedure: setvbuf PORT MODE [SIZE]
7a6f1ffa
GH
1013 Set the buffering mode for PORT. MODE can be:
1014 `_IONBF'
1015 non-buffered
1016
1017 `_IOLBF'
1018 line buffered
1019
1020 `_IOFBF'
1021 block buffered, using a newly allocated buffer of SIZE bytes.
1022 However if SIZE is zero or unspecified, the port will be made
1023 non-buffered.
1024
1025 This procedure should not be used after I/O has been performed with
1026 the port.
1027
1028 Ports are usually block buffered by default, with a default buffer
1029 size. Procedures e.g., *Note open-file: File Ports, which accept a
1030 mode string allow `0' to be added to request an unbuffered port.
1031
e2d6569c 1032*** procedure: fsync PORT/FD
6afcd3b2
GH
1033 Copies any unwritten data for the specified output file descriptor
1034 to disk. If PORT/FD is a port, its buffer is flushed before the
1035 underlying file descriptor is fsync'd. The return value is
1036 unspecified.
1037
e2d6569c 1038*** procedure: open-fdes PATH FLAGS [MODES]
6afcd3b2
GH
1039 Similar to `open' but returns a file descriptor instead of a port.
1040
e2d6569c 1041*** procedure: execle PATH ENV [ARG] ...
6afcd3b2
GH
1042 Similar to `execl', but the environment of the new process is
1043 specified by ENV, which must be a list of strings as returned by
1044 the `environ' procedure.
1045
1046 This procedure is currently implemented using the `execve' system
1047 call, but we call it `execle' because of its Scheme calling
1048 interface.
1049
e2d6569c 1050*** procedure: strerror ERRNO
ec4ab4fd
GH
1051 Returns the Unix error message corresponding to ERRNO, an integer.
1052
e2d6569c 1053*** procedure: primitive-exit [STATUS]
6afcd3b2
GH
1054 Terminate the current process without unwinding the Scheme stack.
1055 This is would typically be useful after a fork. The exit status
1056 is STATUS if supplied, otherwise zero.
1057
e2d6569c 1058*** procedure: times
6afcd3b2
GH
1059 Returns an object with information about real and processor time.
1060 The following procedures accept such an object as an argument and
1061 return a selected component:
1062
1063 `tms:clock'
1064 The current real time, expressed as time units relative to an
1065 arbitrary base.
1066
1067 `tms:utime'
1068 The CPU time units used by the calling process.
1069
1070 `tms:stime'
1071 The CPU time units used by the system on behalf of the
1072 calling process.
1073
1074 `tms:cutime'
1075 The CPU time units used by terminated child processes of the
1076 calling process, whose status has been collected (e.g., using
1077 `waitpid').
1078
1079 `tms:cstime'
1080 Similarly, the CPU times units used by the system on behalf of
1081 terminated child processes.
7ad3c1e7 1082
e2d6569c
JB
1083** Removed: list-length
1084** Removed: list-append, list-append!
1085** Removed: list-reverse, list-reverse!
1086
1087** array-map renamed to array-map!
1088
1089** serial-array-map renamed to serial-array-map!
1090
660f41fa
MD
1091** catch doesn't take #f as first argument any longer
1092
1093Previously, it was possible to pass #f instead of a key to `catch'.
1094That would cause `catch' to pass a jump buffer object to the procedure
1095passed as second argument. The procedure could then use this jump
1096buffer objekt as an argument to throw.
1097
1098This mechanism has been removed since its utility doesn't motivate the
1099extra complexity it introduces.
1100
332d00f6
JB
1101** The `#/' notation for lists now provokes a warning message from Guile.
1102This syntax will be removed from Guile in the near future.
1103
1104To disable the warning message, set the GUILE_HUSH environment
1105variable to any non-empty value.
1106
8cd57bd0
JB
1107** The newline character now prints as `#\newline', following the
1108normal Scheme notation, not `#\nl'.
1109
c484bf7f
JB
1110* Changes to the gh_ interface
1111
8986901b
JB
1112** The gh_enter function now takes care of loading the Guile startup files.
1113gh_enter works by calling scm_boot_guile; see the remarks below.
1114
5424b4f7
MD
1115** Function: void gh_write (SCM x)
1116
1117Write the printed representation of the scheme object x to the current
1118output port. Corresponds to the scheme level `write'.
1119
3a97e020
MD
1120** gh_list_length renamed to gh_length.
1121
8d6787b6
MG
1122** vector handling routines
1123
1124Several major changes. In particular, gh_vector() now resembles
1125(vector ...) (with a caveat -- see manual), and gh_make_vector() now
956328d2
MG
1126exists and behaves like (make-vector ...). gh_vset() and gh_vref()
1127have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
8d6787b6
MG
1128vector-related gh_ functions have been implemented.
1129
7fee59bd
MG
1130** pair and list routines
1131
1132Implemented several of the R4RS pair and list functions that were
1133missing.
1134
171422a9
MD
1135** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
1136
1137New function. Converts double arrays back and forth between Scheme
1138and C.
1139
c484bf7f
JB
1140* Changes to the scm_ interface
1141
8986901b
JB
1142** The function scm_boot_guile now takes care of loading the startup files.
1143
1144Guile's primary initialization function, scm_boot_guile, now takes
1145care of loading `boot-9.scm', in the `ice-9' module, to initialize
1146Guile, define the module system, and put together some standard
1147bindings. It also loads `init.scm', which is intended to hold
1148site-specific initialization code.
1149
1150Since Guile cannot operate properly until boot-9.scm is loaded, there
1151is no reason to separate loading boot-9.scm from Guile's other
1152initialization processes.
1153
1154This job used to be done by scm_compile_shell_switches, which didn't
1155make much sense; in particular, it meant that people using Guile for
1156non-shell-like applications had to jump through hoops to get Guile
1157initialized properly.
1158
1159** The function scm_compile_shell_switches no longer loads the startup files.
1160Now, Guile always loads the startup files, whenever it is initialized;
1161see the notes above for scm_boot_guile and scm_load_startup_files.
1162
1163** Function: scm_load_startup_files
1164This new function takes care of loading Guile's initialization file
1165(`boot-9.scm'), and the site initialization file, `init.scm'. Since
1166this is always called by the Guile initialization process, it's
1167probably not too useful to call this yourself, but it's there anyway.
1168
87148d9e
JB
1169** The semantics of smob marking have changed slightly.
1170
1171The smob marking function (the `mark' member of the scm_smobfuns
1172structure) is no longer responsible for setting the mark bit on the
1173smob. The generic smob handling code in the garbage collector will
1174set this bit. The mark function need only ensure that any other
1175objects the smob refers to get marked.
1176
1177Note that this change means that the smob's GC8MARK bit is typically
1178already set upon entry to the mark function. Thus, marking functions
1179which look like this:
1180
1181 {
1182 if (SCM_GC8MARKP (ptr))
1183 return SCM_BOOL_F;
1184 SCM_SETGC8MARK (ptr);
1185 ... mark objects to which the smob refers ...
1186 }
1187
1188are now incorrect, since they will return early, and fail to mark any
1189other objects the smob refers to. Some code in the Guile library used
1190to work this way.
1191
1cf84ea5
JB
1192** The semantics of the I/O port functions in scm_ptobfuns have changed.
1193
1194If you have implemented your own I/O port type, by writing the
1195functions required by the scm_ptobfuns and then calling scm_newptob,
1196you will need to change your functions slightly.
1197
1198The functions in a scm_ptobfuns structure now expect the port itself
1199as their argument; they used to expect the `stream' member of the
1200port's scm_port_table structure. This allows functions in an
1201scm_ptobfuns structure to easily access the port's cell (and any flags
1202it its CAR), and the port's scm_port_table structure.
1203
1204Guile now passes the I/O port itself as the `port' argument in the
1205following scm_ptobfuns functions:
1206
1207 int (*free) (SCM port);
1208 int (*fputc) (int, SCM port);
1209 int (*fputs) (char *, SCM port);
1210 scm_sizet (*fwrite) SCM_P ((char *ptr,
1211 scm_sizet size,
1212 scm_sizet nitems,
1213 SCM port));
1214 int (*fflush) (SCM port);
1215 int (*fgetc) (SCM port);
1216 int (*fclose) (SCM port);
1217
1218The interfaces to the `mark', `print', `equalp', and `fgets' methods
1219are unchanged.
1220
1221If you have existing code which defines its own port types, it is easy
1222to convert your code to the new interface; simply apply SCM_STREAM to
1223the port argument to yield the value you code used to expect.
1224
1225Note that since both the port and the stream have the same type in the
1226C code --- they are both SCM values --- the C compiler will not remind
1227you if you forget to update your scm_ptobfuns functions.
1228
1229
933a7411
MD
1230** Function: int scm_internal_select (int fds,
1231 SELECT_TYPE *rfds,
1232 SELECT_TYPE *wfds,
1233 SELECT_TYPE *efds,
1234 struct timeval *timeout);
1235
1236This is a replacement for the `select' function provided by the OS.
1237It enables I/O blocking and sleeping to happen for one cooperative
1238thread without blocking other threads. It also avoids busy-loops in
1239these situations. It is intended that all I/O blocking and sleeping
1240will finally go through this function. Currently, this function is
1241only available on systems providing `gettimeofday' and `select'.
1242
5424b4f7
MD
1243** Function: SCM scm_internal_stack_catch (SCM tag,
1244 scm_catch_body_t body,
1245 void *body_data,
1246 scm_catch_handler_t handler,
1247 void *handler_data)
1248
1249A new sibling to the other two C level `catch' functions
1250scm_internal_catch and scm_internal_lazy_catch. Use it if you want
1251the stack to be saved automatically into the variable `the-last-stack'
1252(scm_the_last_stack_var) on error. This is necessary if you want to
1253use advanced error reporting, such as calling scm_display_error and
1254scm_display_backtrace. (They both take a stack object as argument.)
1255
df366c26
MD
1256** Function: SCM scm_spawn_thread (scm_catch_body_t body,
1257 void *body_data,
1258 scm_catch_handler_t handler,
1259 void *handler_data)
1260
1261Spawns a new thread. It does a job similar to
1262scm_call_with_new_thread but takes arguments more suitable when
1263spawning threads from application C code.
1264
88482b31
MD
1265** The hook scm_error_callback has been removed. It was originally
1266intended as a way for the user to install his own error handler. But
1267that method works badly since it intervenes between throw and catch,
1268thereby changing the semantics of expressions like (catch #t ...).
1269The correct way to do it is to use one of the C level catch functions
1270in throw.c: scm_internal_catch/lazy_catch/stack_catch.
1271
3a97e020
MD
1272** Removed functions:
1273
1274scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
1275scm_list_reverse, scm_list_reverse_x
1276
1277** New macros: SCM_LISTn where n is one of the integers 0-9.
1278
1279These can be used for pretty list creation from C. The idea is taken
1280from Erick Gallesio's STk.
1281
298aa6e3
MD
1282** scm_array_map renamed to scm_array_map_x
1283
527da704
MD
1284** mbstrings are now removed
1285
1286This means that the type codes scm_tc7_mb_string and
1287scm_tc7_mb_substring has been removed.
1288
8cd57bd0
JB
1289** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
1290
1291Since we no longer support multi-byte strings, these I/O functions
1292have been simplified, and renamed. Here are their old names, and
1293their new names and arguments:
1294
1295scm_gen_putc -> void scm_putc (int c, SCM port);
1296scm_gen_puts -> void scm_puts (char *s, SCM port);
1297scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
1298scm_gen_getc -> void scm_getc (SCM port);
1299
1300
527da704
MD
1301** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
1302
1303** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
1304
1305SCM_TYP7S now masks away the bit which distinguishes substrings from
1306strings.
1307
660f41fa
MD
1308** scm_catch_body_t: Backward incompatible change!
1309
1310Body functions to scm_internal_catch and friends do not any longer
1311take a second argument. This is because it is no longer possible to
1312pass a #f arg to catch.
1313
a8e05009
JB
1314** Calls to scm_protect_object and scm_unprotect now nest properly.
1315
1316The function scm_protect_object protects its argument from being freed
1317by the garbage collector. scm_unprotect_object removes that
1318protection.
1319
1320These functions now nest properly. That is, for every object O, there
1321is a counter which scm_protect_object(O) increments and
1322scm_unprotect_object(O) decrements, if the counter is greater than
1323zero. Every object's counter is zero when it is first created. If an
1324object's counter is greater than zero, the garbage collector will not
1325reclaim its storage.
1326
1327This allows you to use scm_protect_object in your code without
1328worrying that some other function you call will call
1329scm_unprotect_object, and allow it to be freed. Assuming that the
1330functions you call are well-behaved, and unprotect only those objects
1331they protect, you can follow the same rule and have confidence that
1332objects will be freed only at appropriate times.
1333
c484bf7f
JB
1334\f
1335Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 1336
737c9113
JB
1337* Changes to the distribution
1338
832b09ed
JB
1339** Nightly snapshots are now available from ftp.red-bean.com.
1340The old server, ftp.cyclic.com, has been relinquished to its rightful
1341owner.
1342
1343Nightly snapshots of the Guile development sources are now available via
1344anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
1345
1346Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
1347For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
1348
0fcab5ed
JB
1349** To run Guile without installing it, the procedure has changed a bit.
1350
1351If you used a separate build directory to compile Guile, you'll need
1352to include the build directory in SCHEME_LOAD_PATH, as well as the
1353source directory. See the `INSTALL' file for examples.
1354
737c9113
JB
1355* Changes to the procedure for linking libguile with your programs
1356
94982a4e
JB
1357** The standard Guile load path for Scheme code now includes
1358$(datadir)/guile (usually /usr/local/share/guile). This means that
1359you can install your own Scheme files there, and Guile will find them.
1360(Previous versions of Guile only checked a directory whose name
1361contained the Guile version number, so you had to re-install or move
1362your Scheme sources each time you installed a fresh version of Guile.)
1363
1364The load path also includes $(datadir)/guile/site; we recommend
1365putting individual Scheme files there. If you want to install a
1366package with multiple source files, create a directory for them under
1367$(datadir)/guile.
1368
1369** Guile 1.2 will now use the Rx regular expression library, if it is
1370installed on your system. When you are linking libguile into your own
1371programs, this means you will have to link against -lguile, -lqt (if
1372you configured Guile with thread support), and -lrx.
27590f82
JB
1373
1374If you are using autoconf to generate configuration scripts for your
1375application, the following lines should suffice to add the appropriate
1376libraries to your link command:
1377
1378### Find Rx, quickthreads and libguile.
1379AC_CHECK_LIB(rx, main)
1380AC_CHECK_LIB(qt, main)
1381AC_CHECK_LIB(guile, scm_shell)
1382
94982a4e
JB
1383The Guile 1.2 distribution does not contain sources for the Rx
1384library, as Guile 1.0 did. If you want to use Rx, you'll need to
1385retrieve it from a GNU FTP site and install it separately.
1386
b83b8bee
JB
1387* Changes to Scheme functions and syntax
1388
e035e7e6
MV
1389** The dynamic linking features of Guile are now enabled by default.
1390You can disable them by giving the `--disable-dynamic-linking' option
1391to configure.
1392
e035e7e6
MV
1393 (dynamic-link FILENAME)
1394
1395 Find the object file denoted by FILENAME (a string) and link it
1396 into the running Guile application. When everything works out,
1397 return a Scheme object suitable for representing the linked object
1398 file. Otherwise an error is thrown. How object files are
1399 searched is system dependent.
1400
1401 (dynamic-object? VAL)
1402
1403 Determine whether VAL represents a dynamically linked object file.
1404
1405 (dynamic-unlink DYNOBJ)
1406
1407 Unlink the indicated object file from the application. DYNOBJ
1408 should be one of the values returned by `dynamic-link'.
1409
1410 (dynamic-func FUNCTION DYNOBJ)
1411
1412 Search the C function indicated by FUNCTION (a string or symbol)
1413 in DYNOBJ and return some Scheme object that can later be used
1414 with `dynamic-call' to actually call this function. Right now,
1415 these Scheme objects are formed by casting the address of the
1416 function to `long' and converting this number to its Scheme
1417 representation.
1418
1419 (dynamic-call FUNCTION DYNOBJ)
1420
1421 Call the C function indicated by FUNCTION and DYNOBJ. The
1422 function is passed no arguments and its return value is ignored.
1423 When FUNCTION is something returned by `dynamic-func', call that
1424 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
1425 etc.), look it up in DYNOBJ; this is equivalent to
1426
1427 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
1428
1429 Interrupts are deferred while the C function is executing (with
1430 SCM_DEFER_INTS/SCM_ALLOW_INTS).
1431
1432 (dynamic-args-call FUNCTION DYNOBJ ARGS)
1433
1434 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
1435 some arguments and return its return value. The C function is
1436 expected to take two arguments and return an `int', just like
1437 `main':
1438
1439 int c_func (int argc, char **argv);
1440
1441 ARGS must be a list of strings and is converted into an array of
1442 `char *'. The array is passed in ARGV and its size in ARGC. The
1443 return value is converted to a Scheme number and returned from the
1444 call to `dynamic-args-call'.
1445
0fcab5ed
JB
1446When dynamic linking is disabled or not supported on your system,
1447the above functions throw errors, but they are still available.
1448
e035e7e6
MV
1449Here is a small example that works on GNU/Linux:
1450
1451 (define libc-obj (dynamic-link "libc.so"))
1452 (dynamic-args-call 'rand libc-obj '())
1453
1454See the file `libguile/DYNAMIC-LINKING' for additional comments.
1455
27590f82
JB
1456** The #/ syntax for module names is depreciated, and will be removed
1457in a future version of Guile. Instead of
1458
1459 #/foo/bar/baz
1460
1461instead write
1462
1463 (foo bar baz)
1464
1465The latter syntax is more consistent with existing Lisp practice.
1466
5dade857
MV
1467** Guile now does fancier printing of structures. Structures are the
1468underlying implementation for records, which in turn are used to
1469implement modules, so all of these object now print differently and in
1470a more informative way.
1471
161029df
JB
1472The Scheme printer will examine the builtin variable *struct-printer*
1473whenever it needs to print a structure object. When this variable is
1474not `#f' it is deemed to be a procedure and will be applied to the
1475structure object and the output port. When *struct-printer* is `#f'
1476or the procedure return `#f' the structure object will be printed in
1477the boring #<struct 80458270> form.
5dade857
MV
1478
1479This hook is used by some routines in ice-9/boot-9.scm to implement
1480type specific printing routines. Please read the comments there about
1481"printing structs".
1482
1483One of the more specific uses of structs are records. The printing
1484procedure that could be passed to MAKE-RECORD-TYPE is now actually
1485called. It should behave like a *struct-printer* procedure (described
1486above).
1487
b83b8bee
JB
1488** Guile now supports a new R4RS-compliant syntax for keywords. A
1489token of the form #:NAME, where NAME has the same syntax as a Scheme
1490symbol, is the external representation of the keyword named NAME.
1491Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
1492keyword objects can be read back into Guile. When used in an
1493expression, keywords are self-quoting objects.
b83b8bee
JB
1494
1495Guile suports this read syntax, and uses this print syntax, regardless
1496of the current setting of the `keyword' read option. The `keyword'
1497read option only controls whether Guile recognizes the `:NAME' syntax,
1498which is incompatible with R4RS. (R4RS says such token represent
1499symbols.)
737c9113
JB
1500
1501** Guile has regular expression support again. Guile 1.0 included
1502functions for matching regular expressions, based on the Rx library.
1503In Guile 1.1, the Guile/Rx interface was removed to simplify the
1504distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
15051.2 again supports the most commonly used functions, and supports all
1506of SCSH's regular expression functions.
2409cdfa 1507
94982a4e
JB
1508If your system does not include a POSIX regular expression library,
1509and you have not linked Guile with a third-party regexp library such as
1510Rx, these functions will not be available. You can tell whether your
1511Guile installation includes regular expression support by checking
1512whether the `*features*' list includes the `regex' symbol.
737c9113 1513
94982a4e 1514*** regexp functions
161029df 1515
94982a4e
JB
1516By default, Guile supports POSIX extended regular expressions. That
1517means that the characters `(', `)', `+' and `?' are special, and must
1518be escaped if you wish to match the literal characters.
e1a191a8 1519
94982a4e
JB
1520This regular expression interface was modeled after that implemented
1521by SCSH, the Scheme Shell. It is intended to be upwardly compatible
1522with SCSH regular expressions.
1523
1524**** Function: string-match PATTERN STR [START]
1525 Compile the string PATTERN into a regular expression and compare
1526 it with STR. The optional numeric argument START specifies the
1527 position of STR at which to begin matching.
1528
1529 `string-match' returns a "match structure" which describes what,
1530 if anything, was matched by the regular expression. *Note Match
1531 Structures::. If STR does not match PATTERN at all,
1532 `string-match' returns `#f'.
1533
1534 Each time `string-match' is called, it must compile its PATTERN
1535argument into a regular expression structure. This operation is
1536expensive, which makes `string-match' inefficient if the same regular
1537expression is used several times (for example, in a loop). For better
1538performance, you can compile a regular expression in advance and then
1539match strings against the compiled regexp.
1540
1541**** Function: make-regexp STR [FLAGS]
1542 Compile the regular expression described by STR, and return the
1543 compiled regexp structure. If STR does not describe a legal
1544 regular expression, `make-regexp' throws a
1545 `regular-expression-syntax' error.
1546
1547 FLAGS may be the bitwise-or of one or more of the following:
1548
1549**** Constant: regexp/extended
1550 Use POSIX Extended Regular Expression syntax when interpreting
1551 STR. If not set, POSIX Basic Regular Expression syntax is used.
1552 If the FLAGS argument is omitted, we assume regexp/extended.
1553
1554**** Constant: regexp/icase
1555 Do not differentiate case. Subsequent searches using the
1556 returned regular expression will be case insensitive.
1557
1558**** Constant: regexp/newline
1559 Match-any-character operators don't match a newline.
1560
1561 A non-matching list ([^...]) not containing a newline matches a
1562 newline.
1563
1564 Match-beginning-of-line operator (^) matches the empty string
1565 immediately after a newline, regardless of whether the FLAGS
1566 passed to regexp-exec contain regexp/notbol.
1567
1568 Match-end-of-line operator ($) matches the empty string
1569 immediately before a newline, regardless of whether the FLAGS
1570 passed to regexp-exec contain regexp/noteol.
1571
1572**** Function: regexp-exec REGEXP STR [START [FLAGS]]
1573 Match the compiled regular expression REGEXP against `str'. If
1574 the optional integer START argument is provided, begin matching
1575 from that position in the string. Return a match structure
1576 describing the results of the match, or `#f' if no match could be
1577 found.
1578
1579 FLAGS may be the bitwise-or of one or more of the following:
1580
1581**** Constant: regexp/notbol
1582 The match-beginning-of-line operator always fails to match (but
1583 see the compilation flag regexp/newline above) This flag may be
1584 used when different portions of a string are passed to
1585 regexp-exec and the beginning of the string should not be
1586 interpreted as the beginning of the line.
1587
1588**** Constant: regexp/noteol
1589 The match-end-of-line operator always fails to match (but see the
1590 compilation flag regexp/newline above)
1591
1592**** Function: regexp? OBJ
1593 Return `#t' if OBJ is a compiled regular expression, or `#f'
1594 otherwise.
1595
1596 Regular expressions are commonly used to find patterns in one string
1597and replace them with the contents of another string.
1598
1599**** Function: regexp-substitute PORT MATCH [ITEM...]
1600 Write to the output port PORT selected contents of the match
1601 structure MATCH. Each ITEM specifies what should be written, and
1602 may be one of the following arguments:
1603
1604 * A string. String arguments are written out verbatim.
1605
1606 * An integer. The submatch with that number is written.
1607
1608 * The symbol `pre'. The portion of the matched string preceding
1609 the regexp match is written.
1610
1611 * The symbol `post'. The portion of the matched string
1612 following the regexp match is written.
1613
1614 PORT may be `#f', in which case nothing is written; instead,
1615 `regexp-substitute' constructs a string from the specified ITEMs
1616 and returns that.
1617
1618**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
1619 Similar to `regexp-substitute', but can be used to perform global
1620 substitutions on STR. Instead of taking a match structure as an
1621 argument, `regexp-substitute/global' takes two string arguments: a
1622 REGEXP string describing a regular expression, and a TARGET string
1623 which should be matched against this regular expression.
1624
1625 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
1626 exceptions:
1627
1628 * A function may be supplied. When this function is called, it
1629 will be passed one argument: a match structure for a given
1630 regular expression match. It should return a string to be
1631 written out to PORT.
1632
1633 * The `post' symbol causes `regexp-substitute/global' to recurse
1634 on the unmatched portion of STR. This *must* be supplied in
1635 order to perform global search-and-replace on STR; if it is
1636 not present among the ITEMs, then `regexp-substitute/global'
1637 will return after processing a single match.
1638
1639*** Match Structures
1640
1641 A "match structure" is the object returned by `string-match' and
1642`regexp-exec'. It describes which portion of a string, if any, matched
1643the given regular expression. Match structures include: a reference to
1644the string that was checked for matches; the starting and ending
1645positions of the regexp match; and, if the regexp included any
1646parenthesized subexpressions, the starting and ending positions of each
1647submatch.
1648
1649 In each of the regexp match functions described below, the `match'
1650argument must be a match structure returned by a previous call to
1651`string-match' or `regexp-exec'. Most of these functions return some
1652information about the original target string that was matched against a
1653regular expression; we will call that string TARGET for easy reference.
1654
1655**** Function: regexp-match? OBJ
1656 Return `#t' if OBJ is a match structure returned by a previous
1657 call to `regexp-exec', or `#f' otherwise.
1658
1659**** Function: match:substring MATCH [N]
1660 Return the portion of TARGET matched by subexpression number N.
1661 Submatch 0 (the default) represents the entire regexp match. If
1662 the regular expression as a whole matched, but the subexpression
1663 number N did not match, return `#f'.
1664
1665**** Function: match:start MATCH [N]
1666 Return the starting position of submatch number N.
1667
1668**** Function: match:end MATCH [N]
1669 Return the ending position of submatch number N.
1670
1671**** Function: match:prefix MATCH
1672 Return the unmatched portion of TARGET preceding the regexp match.
1673
1674**** Function: match:suffix MATCH
1675 Return the unmatched portion of TARGET following the regexp match.
1676
1677**** Function: match:count MATCH
1678 Return the number of parenthesized subexpressions from MATCH.
1679 Note that the entire regular expression match itself counts as a
1680 subexpression, and failed submatches are included in the count.
1681
1682**** Function: match:string MATCH
1683 Return the original TARGET string.
1684
1685*** Backslash Escapes
1686
1687 Sometimes you will want a regexp to match characters like `*' or `$'
1688exactly. For example, to check whether a particular string represents
1689a menu entry from an Info node, it would be useful to match it against
1690a regexp like `^* [^:]*::'. However, this won't work; because the
1691asterisk is a metacharacter, it won't match the `*' at the beginning of
1692the string. In this case, we want to make the first asterisk un-magic.
1693
1694 You can do this by preceding the metacharacter with a backslash
1695character `\'. (This is also called "quoting" the metacharacter, and
1696is known as a "backslash escape".) When Guile sees a backslash in a
1697regular expression, it considers the following glyph to be an ordinary
1698character, no matter what special meaning it would ordinarily have.
1699Therefore, we can make the above example work by changing the regexp to
1700`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
1701to match only a single asterisk in the target string.
1702
1703 Since the backslash is itself a metacharacter, you may force a
1704regexp to match a backslash in the target string by preceding the
1705backslash with itself. For example, to find variable references in a
1706TeX program, you might want to find occurrences of the string `\let\'
1707followed by any number of alphabetic characters. The regular expression
1708`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
1709each match a single backslash in the target string.
1710
1711**** Function: regexp-quote STR
1712 Quote each special character found in STR with a backslash, and
1713 return the resulting string.
1714
1715 *Very important:* Using backslash escapes in Guile source code (as
1716in Emacs Lisp or C) can be tricky, because the backslash character has
1717special meaning for the Guile reader. For example, if Guile encounters
1718the character sequence `\n' in the middle of a string while processing
1719Scheme code, it replaces those characters with a newline character.
1720Similarly, the character sequence `\t' is replaced by a horizontal tab.
1721Several of these "escape sequences" are processed by the Guile reader
1722before your code is executed. Unrecognized escape sequences are
1723ignored: if the characters `\*' appear in a string, they will be
1724translated to the single character `*'.
1725
1726 This translation is obviously undesirable for regular expressions,
1727since we want to be able to include backslashes in a string in order to
1728escape regexp metacharacters. Therefore, to make sure that a backslash
1729is preserved in a string in your Guile program, you must use *two*
1730consecutive backslashes:
1731
1732 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
1733
1734 The string in this example is preprocessed by the Guile reader before
1735any code is executed. The resulting argument to `make-regexp' is the
1736string `^\* [^:]*', which is what we really want.
1737
1738 This also means that in order to write a regular expression that
1739matches a single backslash character, the regular expression string in
1740the source code must include *four* backslashes. Each consecutive pair
1741of backslashes gets translated by the Guile reader to a single
1742backslash, and the resulting double-backslash is interpreted by the
1743regexp engine as matching a single backslash character. Hence:
1744
1745 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
1746
1747 The reason for the unwieldiness of this syntax is historical. Both
1748regular expression pattern matchers and Unix string processing systems
1749have traditionally used backslashes with the special meanings described
1750above. The POSIX regular expression specification and ANSI C standard
1751both require these semantics. Attempting to abandon either convention
1752would cause other kinds of compatibility problems, possibly more severe
1753ones. Therefore, without extending the Scheme reader to support
1754strings with different quoting conventions (an ungainly and confusing
1755extension when implemented in other languages), we must adhere to this
1756cumbersome escape syntax.
1757
7ad3c1e7
GH
1758* Changes to the gh_ interface
1759
1760* Changes to the scm_ interface
1761
1762* Changes to system call interfaces:
94982a4e 1763
7ad3c1e7 1764** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
1765if an error occurs.
1766
94982a4e 1767*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
1768
1769(sigaction signum [action] [flags])
1770
1771signum is the signal number, which can be specified using the value
1772of SIGINT etc.
1773
1774If action is omitted, sigaction returns a pair: the CAR is the current
1775signal hander, which will be either an integer with the value SIG_DFL
1776(default action) or SIG_IGN (ignore), or the Scheme procedure which
1777handles the signal, or #f if a non-Scheme procedure handles the
1778signal. The CDR contains the current sigaction flags for the handler.
1779
1780If action is provided, it is installed as the new handler for signum.
1781action can be a Scheme procedure taking one argument, or the value of
1782SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
1783whatever signal handler was installed before sigaction was first used.
1784Flags can optionally be specified for the new handler (SA_RESTART is
1785always used if the system provides it, so need not be specified.) The
1786return value is a pair with information about the old handler as
1787described above.
1788
1789This interface does not provide access to the "signal blocking"
1790facility. Maybe this is not needed, since the thread support may
1791provide solutions to the problem of consistent access to data
1792structures.
e1a191a8 1793
94982a4e 1794*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
1795`force-output' on every port open for output.
1796
94982a4e
JB
1797** Guile now provides information on how it was built, via the new
1798global variable, %guile-build-info. This variable records the values
1799of the standard GNU makefile directory variables as an assocation
1800list, mapping variable names (symbols) onto directory paths (strings).
1801For example, to find out where the Guile link libraries were
1802installed, you can say:
1803
1804guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
1805
1806
1807* Changes to the scm_ interface
1808
1809** The new function scm_handle_by_message_noexit is just like the
1810existing scm_handle_by_message function, except that it doesn't call
1811exit to terminate the process. Instead, it prints a message and just
1812returns #f. This might be a more appropriate catch-all handler for
1813new dynamic roots and threads.
1814
cf78e9e8 1815\f
c484bf7f 1816Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
1817
1818* Changes to the distribution.
1819
1820The Guile 1.0 distribution has been split up into several smaller
1821pieces:
1822guile-core --- the Guile interpreter itself.
1823guile-tcltk --- the interface between the Guile interpreter and
1824 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
1825 is a toolkit for building graphical user interfaces.
1826guile-rgx-ctax --- the interface between Guile and the Rx regular
1827 expression matcher, and the translator for the Ctax
1828 programming language. These are packaged together because the
1829 Ctax translator uses Rx to parse Ctax source code.
1830
095936d2
JB
1831This NEWS file describes the changes made to guile-core since the 1.0
1832release.
1833
48d224d7
JB
1834We no longer distribute the documentation, since it was either out of
1835date, or incomplete. As soon as we have current documentation, we
1836will distribute it.
1837
0fcab5ed
JB
1838
1839
f3b1485f
JB
1840* Changes to the stand-alone interpreter
1841
48d224d7
JB
1842** guile now accepts command-line arguments compatible with SCSH, Olin
1843Shivers' Scheme Shell.
1844
1845In general, arguments are evaluated from left to right, but there are
1846exceptions. The following switches stop argument processing, and
1847stash all remaining command-line arguments as the value returned by
1848the (command-line) function.
1849 -s SCRIPT load Scheme source code from FILE, and exit
1850 -c EXPR evalute Scheme expression EXPR, and exit
1851 -- stop scanning arguments; run interactively
1852
1853The switches below are processed as they are encountered.
1854 -l FILE load Scheme source code from FILE
1855 -e FUNCTION after reading script, apply FUNCTION to
1856 command line arguments
1857 -ds do -s script at this point
1858 --emacs enable Emacs protocol (experimental)
1859 -h, --help display this help and exit
1860 -v, --version display version information and exit
1861 \ read arguments from following script lines
1862
1863So, for example, here is a Guile script named `ekko' (thanks, Olin)
1864which re-implements the traditional "echo" command:
1865
1866#!/usr/local/bin/guile -s
1867!#
1868(define (main args)
1869 (map (lambda (arg) (display arg) (display " "))
1870 (cdr args))
1871 (newline))
1872
1873(main (command-line))
1874
1875Suppose we invoke this script as follows:
1876
1877 ekko a speckled gecko
1878
1879Through the magic of Unix script processing (triggered by the `#!'
1880token at the top of the file), /usr/local/bin/guile receives the
1881following list of command-line arguments:
1882
1883 ("-s" "./ekko" "a" "speckled" "gecko")
1884
1885Unix inserts the name of the script after the argument specified on
1886the first line of the file (in this case, "-s"), and then follows that
1887with the arguments given to the script. Guile loads the script, which
1888defines the `main' function, and then applies it to the list of
1889remaining command-line arguments, ("a" "speckled" "gecko").
1890
095936d2
JB
1891In Unix, the first line of a script file must take the following form:
1892
1893#!INTERPRETER ARGUMENT
1894
1895where INTERPRETER is the absolute filename of the interpreter
1896executable, and ARGUMENT is a single command-line argument to pass to
1897the interpreter.
1898
1899You may only pass one argument to the interpreter, and its length is
1900limited. These restrictions can be annoying to work around, so Guile
1901provides a general mechanism (borrowed from, and compatible with,
1902SCSH) for circumventing them.
1903
1904If the ARGUMENT in a Guile script is a single backslash character,
1905`\', Guile will open the script file, parse arguments from its second
1906and subsequent lines, and replace the `\' with them. So, for example,
1907here is another implementation of the `ekko' script:
1908
1909#!/usr/local/bin/guile \
1910-e main -s
1911!#
1912(define (main args)
1913 (for-each (lambda (arg) (display arg) (display " "))
1914 (cdr args))
1915 (newline))
1916
1917If the user invokes this script as follows:
1918
1919 ekko a speckled gecko
1920
1921Unix expands this into
1922
1923 /usr/local/bin/guile \ ekko a speckled gecko
1924
1925When Guile sees the `\' argument, it replaces it with the arguments
1926read from the second line of the script, producing:
1927
1928 /usr/local/bin/guile -e main -s ekko a speckled gecko
1929
1930This tells Guile to load the `ekko' script, and apply the function
1931`main' to the argument list ("a" "speckled" "gecko").
1932
1933Here is how Guile parses the command-line arguments:
1934- Each space character terminates an argument. This means that two
1935 spaces in a row introduce an empty-string argument.
1936- The tab character is not permitted (unless you quote it with the
1937 backslash character, as described below), to avoid confusion.
1938- The newline character terminates the sequence of arguments, and will
1939 also terminate a final non-empty argument. (However, a newline
1940 following a space will not introduce a final empty-string argument;
1941 it only terminates the argument list.)
1942- The backslash character is the escape character. It escapes
1943 backslash, space, tab, and newline. The ANSI C escape sequences
1944 like \n and \t are also supported. These produce argument
1945 constituents; the two-character combination \n doesn't act like a
1946 terminating newline. The escape sequence \NNN for exactly three
1947 octal digits reads as the character whose ASCII code is NNN. As
1948 above, characters produced this way are argument constituents.
1949 Backslash followed by other characters is not allowed.
1950
48d224d7
JB
1951* Changes to the procedure for linking libguile with your programs
1952
1953** Guile now builds and installs a shared guile library, if your
1954system support shared libraries. (It still builds a static library on
1955all systems.) Guile automatically detects whether your system
1956supports shared libraries. To prevent Guile from buildisg shared
1957libraries, pass the `--disable-shared' flag to the configure script.
1958
1959Guile takes longer to compile when it builds shared libraries, because
1960it must compile every file twice --- once to produce position-
1961independent object code, and once to produce normal object code.
1962
1963** The libthreads library has been merged into libguile.
1964
1965To link a program against Guile, you now need only link against
1966-lguile and -lqt; -lthreads is no longer needed. If you are using
1967autoconf to generate configuration scripts for your application, the
1968following lines should suffice to add the appropriate libraries to
1969your link command:
1970
1971### Find quickthreads and libguile.
1972AC_CHECK_LIB(qt, main)
1973AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
1974
1975* Changes to Scheme functions
1976
095936d2
JB
1977** Guile Scheme's special syntax for keyword objects is now optional,
1978and disabled by default.
1979
1980The syntax variation from R4RS made it difficult to port some
1981interesting packages to Guile. The routines which accepted keyword
1982arguments (mostly in the module system) have been modified to also
1983accept symbols whose names begin with `:'.
1984
1985To change the keyword syntax, you must first import the (ice-9 debug)
1986module:
1987 (use-modules (ice-9 debug))
1988
1989Then you can enable the keyword syntax as follows:
1990 (read-set! keywords 'prefix)
1991
1992To disable keyword syntax, do this:
1993 (read-set! keywords #f)
1994
1995** Many more primitive functions accept shared substrings as
1996arguments. In the past, these functions required normal, mutable
1997strings as arguments, although they never made use of this
1998restriction.
1999
2000** The uniform array functions now operate on byte vectors. These
2001functions are `array-fill!', `serial-array-copy!', `array-copy!',
2002`serial-array-map', `array-map', `array-for-each', and
2003`array-index-map!'.
2004
2005** The new functions `trace' and `untrace' implement simple debugging
2006support for Scheme functions.
2007
2008The `trace' function accepts any number of procedures as arguments,
2009and tells the Guile interpreter to display each procedure's name and
2010arguments each time the procedure is invoked. When invoked with no
2011arguments, `trace' returns the list of procedures currently being
2012traced.
2013
2014The `untrace' function accepts any number of procedures as arguments,
2015and tells the Guile interpreter not to trace them any more. When
2016invoked with no arguments, `untrace' untraces all curretly traced
2017procedures.
2018
2019The tracing in Guile has an advantage over most other systems: we
2020don't create new procedure objects, but mark the procedure objects
2021themselves. This means that anonymous and internal procedures can be
2022traced.
2023
2024** The function `assert-repl-prompt' has been renamed to
2025`set-repl-prompt!'. It takes one argument, PROMPT.
2026- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
2027- If PROMPT is a string, we use it as a prompt.
2028- If PROMPT is a procedure accepting no arguments, we call it, and
2029 display the result as a prompt.
2030- Otherwise, we display "> ".
2031
2032** The new function `eval-string' reads Scheme expressions from a
2033string and evaluates them, returning the value of the last expression
2034in the string. If the string contains no expressions, it returns an
2035unspecified value.
2036
2037** The new function `thunk?' returns true iff its argument is a
2038procedure of zero arguments.
2039
2040** `defined?' is now a builtin function, instead of syntax. This
2041means that its argument should be quoted. It returns #t iff its
2042argument is bound in the current module.
2043
2044** The new syntax `use-modules' allows you to add new modules to your
2045environment without re-typing a complete `define-module' form. It
2046accepts any number of module names as arguments, and imports their
2047public bindings into the current module.
2048
2049** The new function (module-defined? NAME MODULE) returns true iff
2050NAME, a symbol, is defined in MODULE, a module object.
2051
2052** The new function `builtin-bindings' creates and returns a hash
2053table containing copies of all the root module's bindings.
2054
2055** The new function `builtin-weak-bindings' does the same as
2056`builtin-bindings', but creates a doubly-weak hash table.
2057
2058** The `equal?' function now considers variable objects to be
2059equivalent if they have the same name and the same value.
2060
2061** The new function `command-line' returns the command-line arguments
2062given to Guile, as a list of strings.
2063
2064When using guile as a script interpreter, `command-line' returns the
2065script's arguments; those processed by the interpreter (like `-s' or
2066`-c') are omitted. (In other words, you get the normal, expected
2067behavior.) Any application that uses scm_shell to process its
2068command-line arguments gets this behavior as well.
2069
2070** The new function `load-user-init' looks for a file called `.guile'
2071in the user's home directory, and loads it if it exists. This is
2072mostly for use by the code generated by scm_compile_shell_switches,
2073but we thought it might also be useful in other circumstances.
2074
2075** The new function `log10' returns the base-10 logarithm of its
2076argument.
2077
2078** Changes to I/O functions
2079
2080*** The functions `read', `primitive-load', `read-and-eval!', and
2081`primitive-load-path' no longer take optional arguments controlling
2082case insensitivity and a `#' parser.
2083
2084Case sensitivity is now controlled by a read option called
2085`case-insensitive'. The user can add new `#' syntaxes with the
2086`read-hash-extend' function (see below).
2087
2088*** The new function `read-hash-extend' allows the user to change the
2089syntax of Guile Scheme in a somewhat controlled way.
2090
2091(read-hash-extend CHAR PROC)
2092 When parsing S-expressions, if we read a `#' character followed by
2093 the character CHAR, use PROC to parse an object from the stream.
2094 If PROC is #f, remove any parsing procedure registered for CHAR.
2095
2096 The reader applies PROC to two arguments: CHAR and an input port.
2097
2098*** The new functions read-delimited and read-delimited! provide a
2099general mechanism for doing delimited input on streams.
2100
2101(read-delimited DELIMS [PORT HANDLE-DELIM])
2102 Read until we encounter one of the characters in DELIMS (a string),
2103 or end-of-file. PORT is the input port to read from; it defaults to
2104 the current input port. The HANDLE-DELIM parameter determines how
2105 the terminating character is handled; it should be one of the
2106 following symbols:
2107
2108 'trim omit delimiter from result
2109 'peek leave delimiter character in input stream
2110 'concat append delimiter character to returned value
2111 'split return a pair: (RESULT . TERMINATOR)
2112
2113 HANDLE-DELIM defaults to 'peek.
2114
2115(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
2116 A side-effecting variant of `read-delimited'.
2117
2118 The data is written into the string BUF at the indices in the
2119 half-open interval [START, END); the default interval is the whole
2120 string: START = 0 and END = (string-length BUF). The values of
2121 START and END must specify a well-defined interval in BUF, i.e.
2122 0 <= START <= END <= (string-length BUF).
2123
2124 It returns NBYTES, the number of bytes read. If the buffer filled
2125 up without a delimiter character being found, it returns #f. If the
2126 port is at EOF when the read starts, it returns the EOF object.
2127
2128 If an integer is returned (i.e., the read is successfully terminated
2129 by reading a delimiter character), then the HANDLE-DELIM parameter
2130 determines how to handle the terminating character. It is described
2131 above, and defaults to 'peek.
2132
2133(The descriptions of these functions were borrowed from the SCSH
2134manual, by Olin Shivers and Brian Carlstrom.)
2135
2136*** The `%read-delimited!' function is the primitive used to implement
2137`read-delimited' and `read-delimited!'.
2138
2139(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
2140
2141This returns a pair of values: (TERMINATOR . NUM-READ).
2142- TERMINATOR describes why the read was terminated. If it is a
2143 character or the eof object, then that is the value that terminated
2144 the read. If it is #f, the function filled the buffer without finding
2145 a delimiting character.
2146- NUM-READ is the number of characters read into BUF.
2147
2148If the read is successfully terminated by reading a delimiter
2149character, then the gobble? parameter determines what to do with the
2150terminating character. If true, the character is removed from the
2151input stream; if false, the character is left in the input stream
2152where a subsequent read operation will retrieve it. In either case,
2153the character is also the first value returned by the procedure call.
2154
2155(The descriptions of this function was borrowed from the SCSH manual,
2156by Olin Shivers and Brian Carlstrom.)
2157
2158*** The `read-line' and `read-line!' functions have changed; they now
2159trim the terminator by default; previously they appended it to the
2160returned string. For the old behavior, use (read-line PORT 'concat).
2161
2162*** The functions `uniform-array-read!' and `uniform-array-write!' now
2163take new optional START and END arguments, specifying the region of
2164the array to read and write.
2165
f348c807
JB
2166*** The `ungetc-char-ready?' function has been removed. We feel it's
2167inappropriate for an interface to expose implementation details this
2168way.
095936d2
JB
2169
2170** Changes to the Unix library and system call interface
2171
2172*** The new fcntl function provides access to the Unix `fcntl' system
2173call.
2174
2175(fcntl PORT COMMAND VALUE)
2176 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
2177 Values for COMMAND are:
2178
2179 F_DUPFD duplicate a file descriptor
2180 F_GETFD read the descriptor's close-on-exec flag
2181 F_SETFD set the descriptor's close-on-exec flag to VALUE
2182 F_GETFL read the descriptor's flags, as set on open
2183 F_SETFL set the descriptor's flags, as set on open to VALUE
2184 F_GETOWN return the process ID of a socket's owner, for SIGIO
2185 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
2186 FD_CLOEXEC not sure what this is
2187
2188For details, see the documentation for the fcntl system call.
2189
2190*** The arguments to `select' have changed, for compatibility with
2191SCSH. The TIMEOUT parameter may now be non-integral, yielding the
2192expected behavior. The MILLISECONDS parameter has been changed to
2193MICROSECONDS, to more closely resemble the underlying system call.
2194The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
2195corresponding return set will be the same.
2196
2197*** The arguments to the `mknod' system call have changed. They are
2198now:
2199
2200(mknod PATH TYPE PERMS DEV)
2201 Create a new file (`node') in the file system. PATH is the name of
2202 the file to create. TYPE is the kind of file to create; it should
2203 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
2204 permission bits to give the newly created file. If TYPE is
2205 'block-special or 'char-special, DEV specifies which device the
2206 special file refers to; its interpretation depends on the kind of
2207 special file being created.
2208
2209*** The `fork' function has been renamed to `primitive-fork', to avoid
2210clashing with various SCSH forks.
2211
2212*** The `recv' and `recvfrom' functions have been renamed to `recv!'
2213and `recvfrom!'. They no longer accept a size for a second argument;
2214you must pass a string to hold the received value. They no longer
2215return the buffer. Instead, `recv' returns the length of the message
2216received, and `recvfrom' returns a pair containing the packet's length
2217and originating address.
2218
2219*** The file descriptor datatype has been removed, as have the
2220`read-fd', `write-fd', `close', `lseek', and `dup' functions.
2221We plan to replace these functions with a SCSH-compatible interface.
2222
2223*** The `create' function has been removed; it's just a special case
2224of `open'.
2225
2226*** There are new functions to break down process termination status
2227values. In the descriptions below, STATUS is a value returned by
2228`waitpid'.
2229
2230(status:exit-val STATUS)
2231 If the child process exited normally, this function returns the exit
2232 code for the child process (i.e., the value passed to exit, or
2233 returned from main). If the child process did not exit normally,
2234 this function returns #f.
2235
2236(status:stop-sig STATUS)
2237 If the child process was suspended by a signal, this function
2238 returns the signal that suspended the child. Otherwise, it returns
2239 #f.
2240
2241(status:term-sig STATUS)
2242 If the child process terminated abnormally, this function returns
2243 the signal that terminated the child. Otherwise, this function
2244 returns false.
2245
2246POSIX promises that exactly one of these functions will return true on
2247a valid STATUS value.
2248
2249These functions are compatible with SCSH.
2250
2251*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
2252returned by `localtime', `gmtime', and that ilk. They are:
2253
2254 Component Accessor Setter
2255 ========================= ============ ============
2256 seconds tm:sec set-tm:sec
2257 minutes tm:min set-tm:min
2258 hours tm:hour set-tm:hour
2259 day of the month tm:mday set-tm:mday
2260 month tm:mon set-tm:mon
2261 year tm:year set-tm:year
2262 day of the week tm:wday set-tm:wday
2263 day in the year tm:yday set-tm:yday
2264 daylight saving time tm:isdst set-tm:isdst
2265 GMT offset, seconds tm:gmtoff set-tm:gmtoff
2266 name of time zone tm:zone set-tm:zone
2267
095936d2
JB
2268*** There are new accessors for the vectors returned by `uname',
2269describing the host system:
48d224d7
JB
2270
2271 Component Accessor
2272 ============================================== ================
2273 name of the operating system implementation utsname:sysname
2274 network name of this machine utsname:nodename
2275 release level of the operating system utsname:release
2276 version level of the operating system utsname:version
2277 machine hardware platform utsname:machine
2278
095936d2
JB
2279*** There are new accessors for the vectors returned by `getpw',
2280`getpwnam', `getpwuid', and `getpwent', describing entries from the
2281system's user database:
2282
2283 Component Accessor
2284 ====================== =================
2285 user name passwd:name
2286 user password passwd:passwd
2287 user id passwd:uid
2288 group id passwd:gid
2289 real name passwd:gecos
2290 home directory passwd:dir
2291 shell program passwd:shell
2292
2293*** There are new accessors for the vectors returned by `getgr',
2294`getgrnam', `getgrgid', and `getgrent', describing entries from the
2295system's group database:
2296
2297 Component Accessor
2298 ======================= ============
2299 group name group:name
2300 group password group:passwd
2301 group id group:gid
2302 group members group:mem
2303
2304*** There are new accessors for the vectors returned by `gethost',
2305`gethostbyaddr', `gethostbyname', and `gethostent', describing
2306internet hosts:
2307
2308 Component Accessor
2309 ========================= ===============
2310 official name of host hostent:name
2311 alias list hostent:aliases
2312 host address type hostent:addrtype
2313 length of address hostent:length
2314 list of addresses hostent:addr-list
2315
2316*** There are new accessors for the vectors returned by `getnet',
2317`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
2318networks:
2319
2320 Component Accessor
2321 ========================= ===============
2322 official name of net netent:name
2323 alias list netent:aliases
2324 net number type netent:addrtype
2325 net number netent:net
2326
2327*** There are new accessors for the vectors returned by `getproto',
2328`getprotobyname', `getprotobynumber', and `getprotoent', describing
2329internet protocols:
2330
2331 Component Accessor
2332 ========================= ===============
2333 official protocol name protoent:name
2334 alias list protoent:aliases
2335 protocol number protoent:proto
2336
2337*** There are new accessors for the vectors returned by `getserv',
2338`getservbyname', `getservbyport', and `getservent', describing
2339internet protocols:
2340
2341 Component Accessor
2342 ========================= ===============
2343 official service name servent:name
2344 alias list servent:aliases
2345 port number servent:port
2346 protocol to use servent:proto
2347
2348*** There are new accessors for the sockaddr structures returned by
2349`accept', `getsockname', `getpeername', `recvfrom!':
2350
2351 Component Accessor
2352 ======================================== ===============
2353 address format (`family') sockaddr:fam
2354 path, for file domain addresses sockaddr:path
2355 address, for internet domain addresses sockaddr:addr
2356 TCP or UDP port, for internet sockaddr:port
2357
2358*** The `getpwent', `getgrent', `gethostent', `getnetent',
2359`getprotoent', and `getservent' functions now return #f at the end of
2360the user database. (They used to throw an exception.)
2361
2362Note that calling MUMBLEent function is equivalent to calling the
2363corresponding MUMBLE function with no arguments.
2364
2365*** The `setpwent', `setgrent', `sethostent', `setnetent',
2366`setprotoent', and `setservent' routines now take no arguments.
2367
2368*** The `gethost', `getproto', `getnet', and `getserv' functions now
2369provide more useful information when they throw an exception.
2370
2371*** The `lnaof' function has been renamed to `inet-lnaof'.
2372
2373*** Guile now claims to have the `current-time' feature.
2374
2375*** The `mktime' function now takes an optional second argument ZONE,
2376giving the time zone to use for the conversion. ZONE should be a
2377string, in the same format as expected for the "TZ" environment variable.
2378
2379*** The `strptime' function now returns a pair (TIME . COUNT), where
2380TIME is the parsed time as a vector, and COUNT is the number of
2381characters from the string left unparsed. This function used to
2382return the remaining characters as a string.
2383
2384*** The `gettimeofday' function has replaced the old `time+ticks' function.
2385The return value is now (SECONDS . MICROSECONDS); the fractional
2386component is no longer expressed in "ticks".
2387
2388*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 2389
ea00ecba
MG
2390* Changes to the gh_ interface
2391
2392** gh_eval_str() now returns an SCM object which is the result of the
2393evaluation
2394
aaef0d2a
MG
2395** gh_scm2str() now copies the Scheme data to a caller-provided C
2396array
2397
2398** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
2399and returns the array
2400
2401** gh_scm2str0() is gone: there is no need to distinguish
2402null-terminated from non-null-terminated, since gh_scm2newstr() allows
2403the user to interpret the data both ways.
2404
f3b1485f
JB
2405* Changes to the scm_ interface
2406
095936d2
JB
2407** The new function scm_symbol_value0 provides an easy way to get a
2408symbol's value from C code:
2409
2410SCM scm_symbol_value0 (char *NAME)
2411 Return the value of the symbol named by the null-terminated string
2412 NAME in the current module. If the symbol named NAME is unbound in
2413 the current module, return SCM_UNDEFINED.
2414
2415** The new function scm_sysintern0 creates new top-level variables,
2416without assigning them a value.
2417
2418SCM scm_sysintern0 (char *NAME)
2419 Create a new Scheme top-level variable named NAME. NAME is a
2420 null-terminated string. Return the variable's value cell.
2421
2422** The function scm_internal_catch is the guts of catch. It handles
2423all the mechanics of setting up a catch target, invoking the catch
2424body, and perhaps invoking the handler if the body does a throw.
2425
2426The function is designed to be usable from C code, but is general
2427enough to implement all the semantics Guile Scheme expects from throw.
2428
2429TAG is the catch tag. Typically, this is a symbol, but this function
2430doesn't actually care about that.
2431
2432BODY is a pointer to a C function which runs the body of the catch;
2433this is the code you can throw from. We call it like this:
2434 BODY (BODY_DATA, JMPBUF)
2435where:
2436 BODY_DATA is just the BODY_DATA argument we received; we pass it
2437 through to BODY as its first argument. The caller can make
2438 BODY_DATA point to anything useful that BODY might need.
2439 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
2440 which we have just created and initialized.
2441
2442HANDLER is a pointer to a C function to deal with a throw to TAG,
2443should one occur. We call it like this:
2444 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
2445where
2446 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
2447 same idea as BODY_DATA above.
2448 THROWN_TAG is the tag that the user threw to; usually this is
2449 TAG, but it could be something else if TAG was #t (i.e., a
2450 catch-all), or the user threw to a jmpbuf.
2451 THROW_ARGS is the list of arguments the user passed to the THROW
2452 function.
2453
2454BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
2455is just a pointer we pass through to HANDLER. We don't actually
2456use either of those pointers otherwise ourselves. The idea is
2457that, if our caller wants to communicate something to BODY or
2458HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
2459HANDLER can then use. Think of it as a way to make BODY and
2460HANDLER closures, not just functions; MUMBLE_DATA points to the
2461enclosed variables.
2462
2463Of course, it's up to the caller to make sure that any data a
2464MUMBLE_DATA needs is protected from GC. A common way to do this is
2465to make MUMBLE_DATA a pointer to data stored in an automatic
2466structure variable; since the collector must scan the stack for
2467references anyway, this assures that any references in MUMBLE_DATA
2468will be found.
2469
2470** The new function scm_internal_lazy_catch is exactly like
2471scm_internal_catch, except:
2472
2473- It does not unwind the stack (this is the major difference).
2474- If handler returns, its value is returned from the throw.
2475- BODY always receives #f as its JMPBUF argument (since there's no
2476 jmpbuf associated with a lazy catch, because we don't unwind the
2477 stack.)
2478
2479** scm_body_thunk is a new body function you can pass to
2480scm_internal_catch if you want the body to be like Scheme's `catch'
2481--- a thunk, or a function of one argument if the tag is #f.
2482
2483BODY_DATA is a pointer to a scm_body_thunk_data structure, which
2484contains the Scheme procedure to invoke as the body, and the tag
2485we're catching. If the tag is #f, then we pass JMPBUF (created by
2486scm_internal_catch) to the body procedure; otherwise, the body gets
2487no arguments.
2488
2489** scm_handle_by_proc is a new handler function you can pass to
2490scm_internal_catch if you want the handler to act like Scheme's catch
2491--- call a procedure with the tag and the throw arguments.
2492
2493If the user does a throw to this catch, this function runs a handler
2494procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
2495variable holding the Scheme procedure object to invoke. It ought to
2496be a pointer to an automatic variable (i.e., one living on the stack),
2497or the procedure object should be otherwise protected from GC.
2498
2499** scm_handle_by_message is a new handler function to use with
2500`scm_internal_catch' if you want Guile to print a message and die.
2501It's useful for dealing with throws to uncaught keys at the top level.
2502
2503HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
2504message header to print; if zero, we use "guile" instead. That
2505text is followed by a colon, then the message described by ARGS.
2506
2507** The return type of scm_boot_guile is now void; the function does
2508not return a value, and indeed, never returns at all.
2509
f3b1485f
JB
2510** The new function scm_shell makes it easy for user applications to
2511process command-line arguments in a way that is compatible with the
2512stand-alone guile interpreter (which is in turn compatible with SCSH,
2513the Scheme shell).
2514
2515To use the scm_shell function, first initialize any guile modules
2516linked into your application, and then call scm_shell with the values
7ed46dc8 2517of ARGC and ARGV your `main' function received. scm_shell will add
f3b1485f
JB
2518any SCSH-style meta-arguments from the top of the script file to the
2519argument vector, and then process the command-line arguments. This
2520generally means loading a script file or starting up an interactive
2521command interpreter. For details, see "Changes to the stand-alone
2522interpreter" above.
2523
095936d2
JB
2524** The new functions scm_get_meta_args and scm_count_argv help you
2525implement the SCSH-style meta-argument, `\'.
2526
2527char **scm_get_meta_args (int ARGC, char **ARGV)
2528 If the second element of ARGV is a string consisting of a single
2529 backslash character (i.e. "\\" in Scheme notation), open the file
2530 named by the following argument, parse arguments from it, and return
2531 the spliced command line. The returned array is terminated by a
2532 null pointer.
2533
2534 For details of argument parsing, see above, under "guile now accepts
2535 command-line arguments compatible with SCSH..."
2536
2537int scm_count_argv (char **ARGV)
2538 Count the arguments in ARGV, assuming it is terminated by a null
2539 pointer.
2540
2541For an example of how these functions might be used, see the source
2542code for the function scm_shell in libguile/script.c.
2543
2544You will usually want to use scm_shell instead of calling this
2545function yourself.
2546
2547** The new function scm_compile_shell_switches turns an array of
2548command-line arguments into Scheme code to carry out the actions they
2549describe. Given ARGC and ARGV, it returns a Scheme expression to
2550evaluate, and calls scm_set_program_arguments to make any remaining
2551command-line arguments available to the Scheme code. For example,
2552given the following arguments:
2553
2554 -e main -s ekko a speckled gecko
2555
2556scm_set_program_arguments will return the following expression:
2557
2558 (begin (load "ekko") (main (command-line)) (quit))
2559
2560You will usually want to use scm_shell instead of calling this
2561function yourself.
2562
2563** The function scm_shell_usage prints a usage message appropriate for
2564an interpreter that uses scm_compile_shell_switches to handle its
2565command-line arguments.
2566
2567void scm_shell_usage (int FATAL, char *MESSAGE)
2568 Print a usage message to the standard error output. If MESSAGE is
2569 non-zero, write it before the usage message, followed by a newline.
2570 If FATAL is non-zero, exit the process, using FATAL as the
2571 termination status. (If you want to be compatible with Guile,
2572 always use 1 as the exit status when terminating due to command-line
2573 usage problems.)
2574
2575You will usually want to use scm_shell instead of calling this
2576function yourself.
48d224d7
JB
2577
2578** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
2579expressions. It used to return SCM_EOL. Earth-shattering.
2580
2581** The macros for declaring scheme objects in C code have been
2582rearranged slightly. They are now:
2583
2584SCM_SYMBOL (C_NAME, SCHEME_NAME)
2585 Declare a static SCM variable named C_NAME, and initialize it to
2586 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
2587 be a C identifier, and SCHEME_NAME should be a C string.
2588
2589SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
2590 Just like SCM_SYMBOL, but make C_NAME globally visible.
2591
2592SCM_VCELL (C_NAME, SCHEME_NAME)
2593 Create a global variable at the Scheme level named SCHEME_NAME.
2594 Declare a static SCM variable named C_NAME, and initialize it to
2595 point to the Scheme variable's value cell.
2596
2597SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
2598 Just like SCM_VCELL, but make C_NAME globally visible.
2599
2600The `guile-snarf' script writes initialization code for these macros
2601to its standard output, given C source code as input.
2602
2603The SCM_GLOBAL macro is gone.
2604
2605** The scm_read_line and scm_read_line_x functions have been replaced
2606by Scheme code based on the %read-delimited! procedure (known to C
2607code as scm_read_delimited_x). See its description above for more
2608information.
48d224d7 2609
095936d2
JB
2610** The function scm_sys_open has been renamed to scm_open. It now
2611returns a port instead of an FD object.
ea00ecba 2612
095936d2
JB
2613* The dynamic linking support has changed. For more information, see
2614libguile/DYNAMIC-LINKING.
ea00ecba 2615
f7b47737
JB
2616\f
2617Guile 1.0b3
3065a62a 2618
f3b1485f
JB
2619User-visible changes from Thursday, September 5, 1996 until Guile 1.0
2620(Sun 5 Jan 1997):
3065a62a 2621
4b521edb 2622* Changes to the 'guile' program:
3065a62a 2623
4b521edb
JB
2624** Guile now loads some new files when it starts up. Guile first
2625searches the load path for init.scm, and loads it if found. Then, if
2626Guile is not being used to execute a script, and the user's home
2627directory contains a file named `.guile', Guile loads that.
c6486f8a 2628
4b521edb 2629** You can now use Guile as a shell script interpreter.
3065a62a
JB
2630
2631To paraphrase the SCSH manual:
2632
2633 When Unix tries to execute an executable file whose first two
2634 characters are the `#!', it treats the file not as machine code to
2635 be directly executed by the native processor, but as source code
2636 to be executed by some interpreter. The interpreter to use is
2637 specified immediately after the #! sequence on the first line of
2638 the source file. The kernel reads in the name of the interpreter,
2639 and executes that instead. It passes the interpreter the source
2640 filename as its first argument, with the original arguments
2641 following. Consult the Unix man page for the `exec' system call
2642 for more information.
2643
1a1945be
JB
2644Now you can use Guile as an interpreter, using a mechanism which is a
2645compatible subset of that provided by SCSH.
2646
3065a62a
JB
2647Guile now recognizes a '-s' command line switch, whose argument is the
2648name of a file of Scheme code to load. It also treats the two
2649characters `#!' as the start of a comment, terminated by `!#'. Thus,
2650to make a file of Scheme code directly executable by Unix, insert the
2651following two lines at the top of the file:
2652
2653#!/usr/local/bin/guile -s
2654!#
2655
2656Guile treats the argument of the `-s' command-line switch as the name
2657of a file of Scheme code to load, and treats the sequence `#!' as the
2658start of a block comment, terminated by `!#'.
2659
2660For example, here's a version of 'echo' written in Scheme:
2661
2662#!/usr/local/bin/guile -s
2663!#
2664(let loop ((args (cdr (program-arguments))))
2665 (if (pair? args)
2666 (begin
2667 (display (car args))
2668 (if (pair? (cdr args))
2669 (display " "))
2670 (loop (cdr args)))))
2671(newline)
2672
2673Why does `#!' start a block comment terminated by `!#', instead of the
2674end of the line? That is the notation SCSH uses, and although we
2675don't yet support the other SCSH features that motivate that choice,
2676we would like to be backward-compatible with any existing Guile
3763761c
JB
2677scripts once we do. Furthermore, if the path to Guile on your system
2678is too long for your kernel, you can start the script with this
2679horrible hack:
2680
2681#!/bin/sh
2682exec /really/long/path/to/guile -s "$0" ${1+"$@"}
2683!#
3065a62a
JB
2684
2685Note that some very old Unix systems don't support the `#!' syntax.
2686
c6486f8a 2687
4b521edb 2688** You can now run Guile without installing it.
6685dc83
JB
2689
2690Previous versions of the interactive Guile interpreter (`guile')
2691couldn't start up unless Guile's Scheme library had been installed;
2692they used the value of the environment variable `SCHEME_LOAD_PATH'
2693later on in the startup process, but not to find the startup code
2694itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
2695code.
2696
2697To run Guile without installing it, build it in the normal way, and
2698then set the environment variable `SCHEME_LOAD_PATH' to a
2699colon-separated list of directories, including the top-level directory
2700of the Guile sources. For example, if you unpacked Guile so that the
2701full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
2702you might say
2703
2704 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
2705
c6486f8a 2706
4b521edb
JB
2707** Guile's read-eval-print loop no longer prints #<unspecified>
2708results. If the user wants to see this, she can evaluate the
2709expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 2710file.
6685dc83 2711
4b521edb
JB
2712** Guile no longer shows backtraces by default when an error occurs;
2713however, it does display a message saying how to get one, and how to
2714request that they be displayed by default. After an error, evaluate
2715 (backtrace)
2716to see a backtrace, and
2717 (debug-enable 'backtrace)
2718to see them by default.
6685dc83 2719
6685dc83 2720
d9fb83d9 2721
4b521edb
JB
2722* Changes to Guile Scheme:
2723
2724** Guile now distinguishes between #f and the empty list.
2725
2726This is for compatibility with the IEEE standard, the (possibly)
2727upcoming Revised^5 Report on Scheme, and many extant Scheme
2728implementations.
2729
2730Guile used to have #f and '() denote the same object, to make Scheme's
2731type system more compatible with Emacs Lisp's. However, the change
2732caused too much trouble for Scheme programmers, and we found another
2733way to reconcile Emacs Lisp with Scheme that didn't require this.
2734
2735
2736** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
2737counterparts, delq!, delv!, and delete!, now remove all matching
2738elements from the list, not just the first. This matches the behavior
2739of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
2740functions which inspired them.
2741
2742I recognize that this change may break code in subtle ways, but it
2743seems best to make the change before the FSF's first Guile release,
2744rather than after.
2745
2746
4b521edb 2747** The compiled-library-path function has been deleted from libguile.
6685dc83 2748
4b521edb 2749** The facilities for loading Scheme source files have changed.
c6486f8a 2750
4b521edb 2751*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
2752for Scheme code. Its value is a list of strings, each of which names
2753a directory.
2754
4b521edb
JB
2755*** The variable %load-extensions now tells Guile which extensions to
2756try appending to a filename when searching the load path. Its value
2757is a list of strings. Its default value is ("" ".scm").
2758
2759*** (%search-load-path FILENAME) searches the directories listed in the
2760value of the %load-path variable for a Scheme file named FILENAME,
2761with all the extensions listed in %load-extensions. If it finds a
2762match, then it returns its full filename. If FILENAME is absolute, it
2763returns it unchanged. Otherwise, it returns #f.
6685dc83 2764
4b521edb
JB
2765%search-load-path will not return matches that refer to directories.
2766
2767*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
2768uses %seach-load-path to find a file named FILENAME, and loads it if
2769it finds it. If it can't read FILENAME for any reason, it throws an
2770error.
6685dc83
JB
2771
2772The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
2773`read' function.
2774
2775*** load uses the same searching semantics as primitive-load.
2776
2777*** The functions %try-load, try-load-with-path, %load, load-with-path,
2778basic-try-load-with-path, basic-load-with-path, try-load-module-with-
2779path, and load-module-with-path have been deleted. The functions
2780above should serve their purposes.
2781
2782*** If the value of the variable %load-hook is a procedure,
2783`primitive-load' applies its value to the name of the file being
2784loaded (without the load path directory name prepended). If its value
2785is #f, it is ignored. Otherwise, an error occurs.
2786
2787This is mostly useful for printing load notification messages.
2788
2789
2790** The function `eval!' is no longer accessible from the scheme level.
2791We can't allow operations which introduce glocs into the scheme level,
2792because Guile's type system can't handle these as data. Use `eval' or
2793`read-and-eval!' (see below) as replacement.
2794
2795** The new function read-and-eval! reads an expression from PORT,
2796evaluates it, and returns the result. This is more efficient than
2797simply calling `read' and `eval', since it is not necessary to make a
2798copy of the expression for the evaluator to munge.
2799
2800Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
2801for the `read' function.
2802
2803
2804** The function `int?' has been removed; its definition was identical
2805to that of `integer?'.
2806
2807** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
2808use the R4RS names for these functions.
2809
2810** The function object-properties no longer returns the hash handle;
2811it simply returns the object's property list.
2812
2813** Many functions have been changed to throw errors, instead of
2814returning #f on failure. The point of providing exception handling in
2815the language is to simplify the logic of user code, but this is less
2816useful if Guile's primitives don't throw exceptions.
2817
2818** The function `fileno' has been renamed from `%fileno'.
2819
2820** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
2821
2822
2823* Changes to Guile's C interface:
2824
2825** The library's initialization procedure has been simplified.
2826scm_boot_guile now has the prototype:
2827
2828void scm_boot_guile (int ARGC,
2829 char **ARGV,
2830 void (*main_func) (),
2831 void *closure);
2832
2833scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
2834MAIN_FUNC should do all the work of the program (initializing other
2835packages, reading user input, etc.) before returning. When MAIN_FUNC
2836returns, call exit (0); this function never returns. If you want some
2837other exit value, MAIN_FUNC may call exit itself.
2838
2839scm_boot_guile arranges for program-arguments to return the strings
2840given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
2841scm_set_program_arguments with the final list, so Scheme code will
2842know which arguments have been processed.
2843
2844scm_boot_guile establishes a catch-all catch handler which prints an
2845error message and exits the process. This means that Guile exits in a
2846coherent way when system errors occur and the user isn't prepared to
2847handle it. If the user doesn't like this behavior, they can establish
2848their own universal catcher in MAIN_FUNC to shadow this one.
2849
2850Why must the caller do all the real work from MAIN_FUNC? The garbage
2851collector assumes that all local variables of type SCM will be above
2852scm_boot_guile's stack frame on the stack. If you try to manipulate
2853SCM values after this function returns, it's the luck of the draw
2854whether the GC will be able to find the objects you allocate. So,
2855scm_boot_guile function exits, rather than returning, to discourage
2856people from making that mistake.
2857
2858The IN, OUT, and ERR arguments were removed; there are other
2859convenient ways to override these when desired.
2860
2861The RESULT argument was deleted; this function should never return.
2862
2863The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
2864general.
2865
2866
2867** Guile's header files should no longer conflict with your system's
2868header files.
2869
2870In order to compile code which #included <libguile.h>, previous
2871versions of Guile required you to add a directory containing all the
2872Guile header files to your #include path. This was a problem, since
2873Guile's header files have names which conflict with many systems'
2874header files.
2875
2876Now only <libguile.h> need appear in your #include path; you must
2877refer to all Guile's other header files as <libguile/mumble.h>.
2878Guile's installation procedure puts libguile.h in $(includedir), and
2879the rest in $(includedir)/libguile.
2880
2881
2882** Two new C functions, scm_protect_object and scm_unprotect_object,
2883have been added to the Guile library.
2884
2885scm_protect_object (OBJ) protects OBJ from the garbage collector.
2886OBJ will not be freed, even if all other references are dropped,
2887until someone does scm_unprotect_object (OBJ). Both functions
2888return OBJ.
2889
2890Note that calls to scm_protect_object do not nest. You can call
2891scm_protect_object any number of times on a given object, and the
2892next call to scm_unprotect_object will unprotect it completely.
2893
2894Basically, scm_protect_object and scm_unprotect_object just
2895maintain a list of references to things. Since the GC knows about
2896this list, all objects it mentions stay alive. scm_protect_object
2897adds its argument to the list; scm_unprotect_object remove its
2898argument from the list.
2899
2900
2901** scm_eval_0str now returns the value of the last expression
2902evaluated.
2903
2904** The new function scm_read_0str reads an s-expression from a
2905null-terminated string, and returns it.
2906
2907** The new function `scm_stdio_to_port' converts a STDIO file pointer
2908to a Scheme port object.
2909
2910** The new function `scm_set_program_arguments' allows C code to set
e80c8fea 2911the value returned by the Scheme `program-arguments' function.
6685dc83 2912
6685dc83 2913\f
1a1945be
JB
2914Older changes:
2915
2916* Guile no longer includes sophisticated Tcl/Tk support.
2917
2918The old Tcl/Tk support was unsatisfying to us, because it required the
2919user to link against the Tcl library, as well as Tk and Guile. The
2920interface was also un-lispy, in that it preserved Tcl/Tk's practice of
2921referring to widgets by names, rather than exporting widgets to Scheme
2922code as a special datatype.
2923
2924In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
2925maintainers described some very interesting changes in progress to the
2926Tcl/Tk internals, which would facilitate clean interfaces between lone
2927Tk and other interpreters --- even for garbage-collected languages
2928like Scheme. They expected the new Tk to be publicly available in the
2929fall of 1996.
2930
2931Since it seems that Guile might soon have a new, cleaner interface to
2932lone Tk, and that the old Guile/Tk glue code would probably need to be
2933completely rewritten, we (Jim Blandy and Richard Stallman) have
2934decided not to support the old code. We'll spend the time instead on
2935a good interface to the newer Tk, as soon as it is available.
5c54da76 2936
8512dea6 2937Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 2938
5c54da76
JB
2939\f
2940Copyright information:
2941
ea00ecba 2942Copyright (C) 1996,1997 Free Software Foundation, Inc.
5c54da76
JB
2943
2944 Permission is granted to anyone to make or distribute verbatim copies
2945 of this document as received, in any medium, provided that the
2946 copyright notice and this permission notice are preserved,
2947 thus giving the recipient permission to redistribute in turn.
2948
2949 Permission is granted to distribute modified versions
2950 of this document, or of portions of it,
2951 under the above conditions, provided also that they
2952 carry prominent notices stating who last changed them.
2953
48d224d7
JB
2954\f
2955Local variables:
2956mode: outline
2957paragraph-separate: "[ \f]*$"
2958end:
2959