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