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