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