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