*** empty log message ***
[bpt/guile.git] / NEWS
CommitLineData
f7b47737 1Guile NEWS --- history of user-visible changes. -*- text -*-
0af43c4a 2Copyright (C) 1996, 1997, 1998, 1999, 2000 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
cc36e791
JB
7Changes since Guile 1.3.4:
8
80f27102
JB
9* Changes to the distribution
10
ce358662
JB
11** Trees from nightly snapshots and CVS now require you to run autogen.sh.
12
13We've changed the way we handle generated files in the Guile source
14repository. As a result, the procedure for building trees obtained
15from the nightly FTP snapshots or via CVS has changed:
16- You must have appropriate versions of autoconf, automake, and
17 libtool installed on your system. See README for info on how to
18 obtain these programs.
19- Before configuring the tree, you must first run the script
20 `autogen.sh' at the top of the source tree.
21
22The Guile repository used to contain not only source files, written by
23humans, but also some generated files, like configure scripts and
24Makefile.in files. Even though the contents of these files could be
25derived mechanically from other files present, we thought it would
26make the tree easier to build if we checked them into CVS.
27
28However, this approach means that minor differences between
29developer's installed tools and habits affected the whole team.
30So we have removed the generated files from the repository, and
31added the autogen.sh script, which will reconstruct them
32appropriately.
33
34
dc914156
GH
35** configure now has experimental options to remove support for certain
36features:
52cfc69b 37
dc914156
GH
38--disable-arrays omit array and uniform array support
39--disable-posix omit posix interfaces
40--disable-networking omit networking interfaces
41--disable-regex omit regular expression interfaces
52cfc69b
GH
42
43These are likely to become separate modules some day.
44
80f27102 45** Added new configure option --enable-debug-freelist
e1b0d0ac 46
38a15cfd
GB
47This enables a debugging version of SCM_NEWCELL(), and also registers
48an extra primitive, the setter `gc-set-debug-check-freelist!'.
49
50Configure with the --enable-debug-freelist option to enable
51the gc-set-debug-check-freelist! primitive, and then use:
52
53(gc-set-debug-check-freelist! #t) # turn on checking of the freelist
54(gc-set-debug-check-freelist! #f) # turn off checking
55
56Checking of the freelist forces a traversal of the freelist and
57a garbage collection before each allocation of a cell. This can
58slow down the interpreter dramatically, so the setter should be used to
59turn on this extra processing only when necessary.
e1b0d0ac 60
0af43c4a 61* Changes to the stand-alone interpreter
bd9e24b3 62
0af43c4a 63** Dynamic linking now uses libltdl from the libtool package.
bd9e24b3 64
0af43c4a
MD
65The old system dependent code for doing dynamic linking has been
66replaced with calls to the libltdl functions which do all the hairy
67details for us.
bd9e24b3 68
0af43c4a
MD
69The major improvement is that you can now directly pass libtool
70library names like "libfoo.la" to `dynamic-link' and `dynamic-link'
71will be able to do the best shared library job you can get, via
72libltdl.
bd9e24b3 73
0af43c4a
MD
74The way dynamic libraries are found has changed and is not really
75portable across platforms, probably. It is therefore recommended to
76use absolute filenames when possible.
77
78If you pass a filename without an extension to `dynamic-link', it will
79try a few appropriate ones. Thus, the most platform ignorant way is
80to specify a name like "libfoo", without any directories and
81extensions.
0573ddae 82
62b82274
GB
83** New primitives: `pkgdata-dir', `site-dir', `library-dir'
84
9770d235
MD
85** Positions of erring expression in scripts
86
87With version 1.3.4, the location of the erring expression in Guile
88scipts is no longer automatically reported. (This should have been
89documented before the 1.3.4 release.)
90
91You can get this information by enabling recording of positions of
92source expressions and running the debugging evaluator. Put this at
93the top of your script (or in your "site" file):
94
95 (read-enable 'positions)
96 (debug-enable 'debug)
97
0573ddae
MD
98** Backtraces in scripts
99
100It is now possible to get backtraces in scripts.
101
102Put
103
104 (debug-enable 'debug 'backtrace)
105
106at the top of the script.
107
108(The first options enables the debugging evaluator.
109 The second enables backtraces.)
110
f25f761d
GH
111** Attempting to get the value of an unbound variable now produces
112an exception with a key of 'unbound-variable instead of 'misc-error.
113
1a35eadc
GH
114** The initial default output port is now unbuffered if it's using a
115tty device. Previously in this situation it was line-buffered.
116
0af43c4a
MD
117* Changes to Scheme functions and syntax
118
119** New procedure: simple-format PORT MESSAGE ARG1 ...
120
121(ice-9 boot) makes `format' an alias for `simple-format' until possibly
122extended by the more sophisticated version in (ice-9 format)
123
124(simple-format port message . args)
125Write MESSAGE to DESTINATION, defaulting to `current-output-port'.
126MESSAGE can contain ~A (was %s) and ~S (was %S) escapes. When printed,
127the escapes are replaced with corresponding members of ARGS:
128~A formats using `display' and ~S formats using `write'.
129If DESTINATION is #t, then use the `current-output-port',
130if DESTINATION is #f, then return a string containing the formatted text.
131Does not add a trailing newline."
132
133** string-ref: the second argument is no longer optional.
134
135** string, list->string: no longer accept strings in their arguments,
136only characters, for compatibility with R5RS.
137
138** New procedure: port-closed? PORT
139Returns #t if PORT is closed or #f if it is open.
140
a2349a28
GH
141* Changes to the scm_ interface
142
810e1aec
MD
143** Guile primitives now carry docstrings!
144
145Thanks to Greg Badros!
146
0af43c4a
MD
147** Guile primitives are defined in a new way: GUILE_PROC/GUILE_PROC1
148
149Now Guile primitives are defined using the GUILE_PROC/GUILE_PROC1 macros
150and must contain a docstring that is extracted into foo.doc using a new
151guile-doc-snarf script (that uses guile-doc-snarf.awk).
152
153** Guile primitives use a new technique for validation of arguments
154
155SCM_VALIDATE_* macros are defined to ease the redundancy and improve
156the readability of argument checking.
157
158** All (nearly?) K&R prototypes for functions replaced with ANSI C equivalents.
159
f8a72ca4
MD
160** New macros: SCM_PACK, SCM_UNPACK, SCM_UNPACK_CAR
161
162Compose/decompose an SCM value.
163
164The SCM type is now defined as void * on most architectures. This
165makes it easier to find several types of bugs, for example when SCM
166values are treated as integers without conversion. Values of the SCM
167type should be treated as "atomic" values. These macros are used when
168composing/decomposing an SCM value, either because you want to access
169individual bits, or because you want to treat it as an integer value.
170
171E.g., in order to set bit 7 in an SCM value x, use the expression
172
173 SCM_PACK (SCM_UNPACK (x) | 0x80)
174
175SCM_UNPACK_CAR (X) is defined as SCM_UNPACK (SCM_CAR (X))
176
a2349a28
GH
177** Port internals: the rw_random variable in the scm_port structure
178must be set to non-zero in any random access port. In recent Guile
179releases it was only set for bidirectional random-access ports.
180
7dcb364d
GH
181** Port internals: the seek ptob procedure is now responsible for
182resetting the buffers if required. The change was made so that in the
183special case of reading the current position (i.e., seek p 0 SEEK_CUR)
184the fport and strport ptobs can avoid resetting the buffers,
185in particular to avoid discarding unread chars. An existing port
186type can be fixed by adding something like the following to the
187beginning of the ptob seek procedure:
188
189 if (pt->rw_active == SCM_PORT_READ)
190 scm_end_input (object);
191 else if (pt->rw_active == SCM_PORT_WRITE)
192 ptob->flush (object);
193
194although to actually avoid resetting the buffers and discard unread
195chars requires further hacking that depends on the characteristics
196of the ptob.
197
f25f761d
GH
198** The scm_sysmissing procedure is no longer used in libguile.
199Unless it turns out to be unexpectedly useful to somebody, it will be
200removed in a future version.
201
0af43c4a
MD
202** The format of error message strings has changed
203
204The two C procedures: scm_display_error and scm_error, as well as the
205primitive `scm-error', now use scm_simple_format to do their work.
206This means that the message strings of all code must be updated to use
207~A where %s was used before, and ~S where %S was used before.
208
209During the period when there still are a lot of old Guiles out there,
210you might want to support both old and new versions of Guile.
211
212There are basically two methods to achieve this. Both methods use
213autoconf. Put
214
215 AC_CHECK_FUNCS(scm_simple_format)
216
217in your configure.in.
218
219Method 1: Use the string concatenation features of ANSI C's
220 preprocessor.
221
222In C:
223
224#ifdef HAVE_SCM_SIMPLE_FORMAT
225#define FMT_S "~S"
226#else
227#define FMT_S "%S"
228#endif
229
230Then represent each of your error messages using a preprocessor macro:
231
232#define E_SPIDER_ERROR "There's a spider in your " ## FMT_S ## "!!!"
233
234In Scheme:
235
236(define fmt-s (if (defined? 'simple-format) "~S" "%S"))
237(define make-message string-append)
238
239(define e-spider-error (make-message "There's a spider in your " fmt-s "!!!"))
240
241Method 2: Use the oldfmt function found in doc/oldfmt.c.
242
243In C:
244
245scm_misc_error ("picnic", scm_c_oldfmt0 ("There's a spider in your ~S!!!"),
246 ...);
247
248In Scheme:
249
250(scm-error 'misc-error "picnic" (oldfmt "There's a spider in your ~S!!!")
251 ...)
252
253
f3b5e185
MD
254** Deprecated: coop_mutex_init, coop_condition_variable_init
255
256Don't use the functions coop_mutex_init and
257coop_condition_variable_init. They will change.
258
259Use scm_mutex_init and scm_cond_init instead.
260
f3b5e185
MD
261** New function: int scm_cond_timedwait (scm_cond_t *COND, scm_mutex_t *MUTEX, const struct timespec *ABSTIME)
262 `scm_cond_timedwait' atomically unlocks MUTEX and waits on
263 COND, as `scm_cond_wait' does, but it also bounds the duration
264 of the wait. If COND has not been signaled before time ABSTIME,
265 the mutex MUTEX is re-acquired and `scm_cond_timedwait'
266 returns the error code `ETIMEDOUT'.
267
268 The ABSTIME parameter specifies an absolute time, with the same
269 origin as `time' and `gettimeofday': an ABSTIME of 0 corresponds
270 to 00:00:00 GMT, January 1, 1970.
271
272** New function: scm_cond_broadcast (scm_cond_t *COND)
273 `scm_cond_broadcast' restarts all the threads that are waiting
274 on the condition variable COND. Nothing happens if no threads are
275 waiting on COND.
276
277** New function: scm_key_create (scm_key_t *KEY, void (*destr_function) (void *))
278 `scm_key_create' allocates a new TSD key. The key is stored in
279 the location pointed to by KEY. There is no limit on the number
280 of keys allocated at a given time. The value initially associated
281 with the returned key is `NULL' in all currently executing threads.
282
283 The DESTR_FUNCTION argument, if not `NULL', specifies a destructor
284 function associated with the key. When a thread terminates,
285 DESTR_FUNCTION is called on the value associated with the key in
286 that thread. The DESTR_FUNCTION is not called if a key is deleted
287 with `scm_key_delete' or a value is changed with
288 `scm_setspecific'. The order in which destructor functions are
289 called at thread termination time is unspecified.
290
291 Destructors are not yet implemented.
292
293** New function: scm_setspecific (scm_key_t KEY, const void *POINTER)
294 `scm_setspecific' changes the value associated with KEY in the
295 calling thread, storing the given POINTER instead.
296
297** New function: scm_getspecific (scm_key_t KEY)
298 `scm_getspecific' returns the value currently associated with
299 KEY in the calling thread.
300
301** New function: scm_key_delete (scm_key_t KEY)
302 `scm_key_delete' deallocates a TSD key. It does not check
303 whether non-`NULL' values are associated with that key in the
304 currently executing threads, nor call the destructor function
305 associated with the key.
306
f25f761d
GH
307* Changes to system call interfaces:
308
28d77376
GH
309** The "select" procedure now tests port buffers for the ability to
310provide input or accept output. Previously only the underlying file
311descriptors were checked.
312
bd9e24b3
GH
313** New variable PIPE_BUF: the maximum number of bytes that can be
314atomically written to a pipe.
315
f25f761d
GH
316** If a facility is not available on the system when Guile is
317compiled, the corresponding primitive procedure will not be defined.
318Previously it would have been defined but would throw a system-error
319exception if called. Exception handlers which catch this case may
320need minor modification: an error will be thrown with key
321'unbound-variable instead of 'system-error. Alternatively it's
322now possible to use `defined?' to check whether the facility is
323available.
324
38c1d3c4
GH
325** Procedures which depend on the timezone should now give the correct
326result on systems which cache the TZ environment variable, even if TZ
327is changed without calling tzset.
328
5c11cc9d
GH
329* Changes to the networking interfaces:
330
331** New functions: htons, ntohs, htonl, ntohl: for converting short and
332long integers between network and host format. For now, it's not
333particularly convenient to do this kind of thing, but consider:
334
335(define write-network-long
336 (lambda (value port)
337 (let ((v (make-uniform-vector 1 1 0)))
338 (uniform-vector-set! v 0 (htonl value))
339 (uniform-vector-write v port))))
340
341(define read-network-long
342 (lambda (port)
343 (let ((v (make-uniform-vector 1 1 0)))
344 (uniform-vector-read! v port)
345 (ntohl (uniform-vector-ref v 0)))))
346
347** If inet-aton fails, it now throws an error with key 'misc-error
348instead of 'system-error, since errno is not relevant.
349
350** Certain gethostbyname/gethostbyaddr failures now throw errors with
351specific keys instead of 'system-error. The latter is inappropriate
352since errno will not have been set. The keys are:
afe5177e 353'host-not-found, 'try-again, 'no-recovery and 'no-data.
5c11cc9d
GH
354
355** sethostent, setnetent, setprotoent, setservent: now take an
356optional argument STAYOPEN, which specifies whether the database
357remains open after a database entry is accessed randomly (e.g., using
358gethostbyname for the hosts database.) The default is #f. Previously
359#t was always used.
360
cc36e791 361\f
43fa9a05
JB
362Changes since Guile 1.3.2:
363
0fdcbcaa
MD
364* Changes to the stand-alone interpreter
365
366** Debugger
367
368An initial version of the Guile debugger written by Chris Hanson has
369been added. The debugger is still under development but is included
370in the distribution anyway since it is already quite useful.
371
372Type
373
374 (debug)
375
376after an error to enter the debugger. Type `help' inside the debugger
377for a description of available commands.
378
379If you prefer to have stack frames numbered and printed in
380anti-chronological order and prefer up in the stack to be down on the
381screen as is the case in gdb, you can put
382
383 (debug-enable 'backwards)
384
385in your .guile startup file. (However, this means that Guile can't
386use indentation to indicate stack level.)
387
388The debugger is autoloaded into Guile at the first use.
389
390** Further enhancements to backtraces
391
392There is a new debug option `width' which controls the maximum width
393on the screen of printed stack frames. Fancy printing parameters
394("level" and "length" as in Common LISP) are adaptively adjusted for
395each stack frame to give maximum information while still fitting
396within the bounds. If the stack frame can't be made to fit by
397adjusting parameters, it is simply cut off at the end. This is marked
398with a `$'.
399
400** Some modules are now only loaded when the repl is started
401
402The modules (ice-9 debug), (ice-9 session), (ice-9 threads) and (ice-9
403regex) are now loaded into (guile-user) only if the repl has been
404started. The effect is that the startup time for scripts has been
405reduced to 30% of what it was previously.
406
407Correctly written scripts load the modules they require at the top of
408the file and should not be affected by this change.
409
ece41168
MD
410** Hooks are now represented as smobs
411
6822fe53
MD
412* Changes to Scheme functions and syntax
413
0ce204b0
MV
414** Readline support has changed again.
415
416The old (readline-activator) module is gone. Use (ice-9 readline)
417instead, which now contains all readline functionality. So the code
418to activate readline is now
419
420 (use-modules (ice-9 readline))
421 (activate-readline)
422
423This should work at any time, including from the guile prompt.
424
5d195868
JB
425To avoid confusion about the terms of Guile's license, please only
426enable readline for your personal use; please don't make it the
427default for others. Here is why we make this rather odd-sounding
428request:
429
430Guile is normally licensed under a weakened form of the GNU General
431Public License, which allows you to link code with Guile without
432placing that code under the GPL. This exception is important to some
433people.
434
435However, since readline is distributed under the GNU General Public
436License, when you link Guile with readline, either statically or
437dynamically, you effectively change Guile's license to the strict GPL.
438Whenever you link any strictly GPL'd code into Guile, uses of Guile
439which are normally permitted become forbidden. This is a rather
440non-obvious consequence of the licensing terms.
441
442So, to make sure things remain clear, please let people choose for
443themselves whether to link GPL'd libraries like readline with Guile.
444
25b0654e
JB
445** regexp-substitute/global has changed slightly, but incompatibly.
446
447If you include a function in the item list, the string of the match
448object it receives is the same string passed to
449regexp-substitute/global, not some suffix of that string.
450Correspondingly, the match's positions are relative to the entire
451string, not the suffix.
452
453If the regexp can match the empty string, the way matches are chosen
454from the string has changed. regexp-substitute/global recognizes the
455same set of matches that list-matches does; see below.
456
457** New function: list-matches REGEXP STRING [FLAGS]
458
459Return a list of match objects, one for every non-overlapping, maximal
460match of REGEXP in STRING. The matches appear in left-to-right order.
461list-matches only reports matches of the empty string if there are no
462other matches which begin on, end at, or include the empty match's
463position.
464
465If present, FLAGS is passed as the FLAGS argument to regexp-exec.
466
467** New function: fold-matches REGEXP STRING INIT PROC [FLAGS]
468
469For each match of REGEXP in STRING, apply PROC to the match object,
470and the last value PROC returned, or INIT for the first call. Return
471the last value returned by PROC. We apply PROC to the matches as they
472appear from left to right.
473
474This function recognizes matches according to the same criteria as
475list-matches.
476
477Thus, you could define list-matches like this:
478
479 (define (list-matches regexp string . flags)
480 (reverse! (apply fold-matches regexp string '() cons flags)))
481
482If present, FLAGS is passed as the FLAGS argument to regexp-exec.
483
bc848f7f
MD
484** Hooks
485
486*** New function: hook? OBJ
487
488Return #t if OBJ is a hook, otherwise #f.
489
ece41168
MD
490*** New function: make-hook-with-name NAME [ARITY]
491
492Return a hook with name NAME and arity ARITY. The default value for
493ARITY is 0. The only effect of NAME is that it will appear when the
494hook object is printed to ease debugging.
495
bc848f7f
MD
496*** New function: hook-empty? HOOK
497
498Return #t if HOOK doesn't contain any procedures, otherwise #f.
499
500*** New function: hook->list HOOK
501
502Return a list of the procedures that are called when run-hook is
503applied to HOOK.
504
b074884f
JB
505** `map' signals an error if its argument lists are not all the same length.
506
507This is the behavior required by R5RS, so this change is really a bug
508fix. But it seems to affect a lot of people's code, so we're
509mentioning it here anyway.
510
6822fe53
MD
511** Print-state handling has been made more transparent
512
513Under certain circumstances, ports are represented as a port with an
514associated print state. Earlier, this pair was represented as a pair
515(see "Some magic has been added to the printer" below). It is now
516indistinguishable (almost; see `get-print-state') from a port on the
517user level.
518
519*** New function: port-with-print-state OUTPUT-PORT PRINT-STATE
520
521Return a new port with the associated print state PRINT-STATE.
522
523*** New function: get-print-state OUTPUT-PORT
524
525Return the print state associated with this port if it exists,
526otherwise return #f.
527
340a8770 528*** New function: directory-stream? OBJECT
77242ff9 529
340a8770 530Returns true iff OBJECT is a directory stream --- the sort of object
77242ff9
GH
531returned by `opendir'.
532
0fdcbcaa
MD
533** New function: using-readline?
534
535Return #t if readline is in use in the current repl.
536
26405bc1
MD
537** structs will be removed in 1.4
538
539Structs will be replaced in Guile 1.4. We will merge GOOPS into Guile
540and use GOOPS objects as the fundamental record type.
541
49199eaa
MD
542* Changes to the scm_ interface
543
26405bc1
MD
544** structs will be removed in 1.4
545
546The entire current struct interface (struct.c, struct.h) will be
547replaced in Guile 1.4. We will merge GOOPS into libguile and use
548GOOPS objects as the fundamental record type.
549
49199eaa
MD
550** The internal representation of subr's has changed
551
552Instead of giving a hint to the subr name, the CAR field of the subr
553now contains an index to a subr entry in scm_subr_table.
554
555*** New variable: scm_subr_table
556
557An array of subr entries. A subr entry contains the name, properties
558and documentation associated with the subr. The properties and
559documentation slots are not yet used.
560
561** A new scheme for "forwarding" calls to a builtin to a generic function
562
563It is now possible to extend the functionality of some Guile
564primitives by letting them defer a call to a GOOPS generic function on
240ed66f 565argument mismatch. This means that there is no loss of efficiency in
daf516d6 566normal evaluation.
49199eaa
MD
567
568Example:
569
daf516d6 570 (use-modules (oop goops)) ; Must be GOOPS version 0.2.
49199eaa
MD
571 (define-method + ((x <string>) (y <string>))
572 (string-append x y))
573
86a4d62e
MD
574+ will still be as efficient as usual in numerical calculations, but
575can also be used for concatenating strings.
49199eaa 576
86a4d62e 577Who will be the first one to extend Guile's numerical tower to
daf516d6
MD
578rationals? :) [OK, there a few other things to fix before this can
579be made in a clean way.]
49199eaa
MD
580
581*** New snarf macros for defining primitives: SCM_GPROC, SCM_GPROC1
582
583 New macro: SCM_GPROC (CNAME, SNAME, REQ, OPT, VAR, CFUNC, GENERIC)
584
585 New macro: SCM_GPROC1 (CNAME, SNAME, TYPE, CFUNC, GENERIC)
586
d02cafe7 587These do the same job as SCM_PROC and SCM_PROC1, but they also define
49199eaa
MD
588a variable GENERIC which can be used by the dispatch macros below.
589
590[This is experimental code which may change soon.]
591
592*** New macros for forwarding control to a generic on arg type error
593
594 New macro: SCM_WTA_DISPATCH_1 (GENERIC, ARG1, POS, SUBR)
595
596 New macro: SCM_WTA_DISPATCH_2 (GENERIC, ARG1, ARG2, POS, SUBR)
597
598These correspond to the scm_wta function call, and have the same
599behaviour until the user has called the GOOPS primitive
600`enable-primitive-generic!'. After that, these macros will apply the
601generic function GENERIC to the argument(s) instead of calling
602scm_wta.
603
604[This is experimental code which may change soon.]
605
606*** New macros for argument testing with generic dispatch
607
608 New macro: SCM_GASSERT1 (COND, GENERIC, ARG1, POS, SUBR)
609
610 New macro: SCM_GASSERT2 (COND, GENERIC, ARG1, ARG2, POS, SUBR)
611
612These correspond to the SCM_ASSERT macro, but will defer control to
613GENERIC on error after `enable-primitive-generic!' has been called.
614
615[This is experimental code which may change soon.]
616
617** New function: SCM scm_eval_body (SCM body, SCM env)
618
619Evaluates the body of a special form.
620
621** The internal representation of struct's has changed
622
623Previously, four slots were allocated for the procedure(s) of entities
624and operators. The motivation for this representation had to do with
625the structure of the evaluator, the wish to support tail-recursive
626generic functions, and efficiency. Since the generic function
627dispatch mechanism has changed, there is no longer a need for such an
628expensive representation, and the representation has been simplified.
629
630This should not make any difference for most users.
631
632** GOOPS support has been cleaned up.
633
634Some code has been moved from eval.c to objects.c and code in both of
635these compilation units has been cleaned up and better structured.
636
637*** New functions for applying generic functions
638
639 New function: SCM scm_apply_generic (GENERIC, ARGS)
640 New function: SCM scm_call_generic_0 (GENERIC)
641 New function: SCM scm_call_generic_1 (GENERIC, ARG1)
642 New function: SCM scm_call_generic_2 (GENERIC, ARG1, ARG2)
643 New function: SCM scm_call_generic_3 (GENERIC, ARG1, ARG2, ARG3)
644
ece41168
MD
645** Deprecated function: scm_make_named_hook
646
647It is now replaced by:
648
649** New function: SCM scm_create_hook (const char *name, int arity)
650
651Creates a hook in the same way as make-hook above but also
652binds a variable named NAME to it.
653
654This is the typical way of creating a hook from C code.
655
656Currently, the variable is created in the "current" module.
657This might change when we get the new module system.
658
659[The behaviour is identical to scm_make_named_hook.]
660
661
43fa9a05 662\f
f3227c7a
JB
663Changes since Guile 1.3:
664
6ca345f3
JB
665* Changes to mailing lists
666
667** Some of the Guile mailing lists have moved to sourceware.cygnus.com.
668
669See the README file to find current addresses for all the Guile
670mailing lists.
671
d77fb593
JB
672* Changes to the distribution
673
1d335863
JB
674** Readline support is no longer included with Guile by default.
675
676Based on the different license terms of Guile and Readline, we
677concluded that Guile should not *by default* cause the linking of
678Readline into an application program. Readline support is now offered
679as a separate module, which is linked into an application only when
680you explicitly specify it.
681
682Although Guile is GNU software, its distribution terms add a special
683exception to the usual GNU General Public License (GPL). Guile's
684license includes a clause that allows you to link Guile with non-free
685programs. We add this exception so as not to put Guile at a
686disadvantage vis-a-vis other extensibility packages that support other
687languages.
688
689In contrast, the GNU Readline library is distributed under the GNU
690General Public License pure and simple. This means that you may not
691link Readline, even dynamically, into an application unless it is
692distributed under a free software license that is compatible the GPL.
693
694Because of this difference in distribution terms, an application that
695can use Guile may not be able to use Readline. Now users will be
696explicitly offered two independent decisions about the use of these
697two packages.
d77fb593 698
0e8a8468
MV
699You can activate the readline support by issuing
700
701 (use-modules (readline-activator))
702 (activate-readline)
703
704from your ".guile" file, for example.
705
e4eae9b1
MD
706* Changes to the stand-alone interpreter
707
67ad463a
MD
708** All builtins now print as primitives.
709Previously builtin procedures not belonging to the fundamental subr
710types printed as #<compiled closure #<primitive-procedure gsubr-apply>>.
711Now, they print as #<primitive-procedure NAME>.
712
713** Backtraces slightly more intelligible.
714gsubr-apply and macro transformer application frames no longer appear
715in backtraces.
716
69c6acbb
JB
717* Changes to Scheme functions and syntax
718
2a52b429
MD
719** Guile now correctly handles internal defines by rewriting them into
720their equivalent letrec. Previously, internal defines would
721incrementally add to the innermost environment, without checking
722whether the restrictions specified in RnRS were met. This lead to the
723correct behaviour when these restriction actually were met, but didn't
724catch all illegal uses. Such an illegal use could lead to crashes of
725the Guile interpreter or or other unwanted results. An example of
726incorrect internal defines that made Guile behave erratically:
727
728 (let ()
729 (define a 1)
730 (define (b) a)
731 (define c (1+ (b)))
732 (define d 3)
733
734 (b))
735
736 => 2
737
738The problem with this example is that the definition of `c' uses the
739value of `b' directly. This confuses the meoization machine of Guile
740so that the second call of `b' (this time in a larger environment that
741also contains bindings for `c' and `d') refers to the binding of `c'
742instead of `a'. You could also make Guile crash with a variation on
743this theme:
744
745 (define (foo flag)
746 (define a 1)
747 (define (b flag) (if flag a 1))
748 (define c (1+ (b flag)))
749 (define d 3)
750
751 (b #t))
752
753 (foo #f)
754 (foo #t)
755
756From now on, Guile will issue an `Unbound variable: b' error message
757for both examples.
758
36d3d540
MD
759** Hooks
760
761A hook contains a list of functions which should be called on
762particular occasions in an existing program. Hooks are used for
763customization.
764
765A window manager might have a hook before-window-map-hook. The window
766manager uses the function run-hooks to call all functions stored in
767before-window-map-hook each time a window is mapped. The user can
768store functions in the hook using add-hook!.
769
770In Guile, hooks are first class objects.
771
772*** New function: make-hook [N_ARGS]
773
774Return a hook for hook functions which can take N_ARGS arguments.
775The default value for N_ARGS is 0.
776
ad91d6c3
MD
777(See also scm_make_named_hook below.)
778
36d3d540
MD
779*** New function: add-hook! HOOK PROC [APPEND_P]
780
781Put PROC at the beginning of the list of functions stored in HOOK.
782If APPEND_P is supplied, and non-false, put PROC at the end instead.
783
784PROC must be able to take the number of arguments specified when the
785hook was created.
786
787If PROC already exists in HOOK, then remove it first.
788
789*** New function: remove-hook! HOOK PROC
790
791Remove PROC from the list of functions in HOOK.
792
793*** New function: reset-hook! HOOK
794
795Clear the list of hook functions stored in HOOK.
796
797*** New function: run-hook HOOK ARG1 ...
798
799Run all hook functions stored in HOOK with arguments ARG1 ... .
800The number of arguments supplied must correspond to the number given
801when the hook was created.
802
56a19408
MV
803** The function `dynamic-link' now takes optional keyword arguments.
804 The only keyword argument that is currently defined is `:global
805 BOOL'. With it, you can control whether the shared library will be
806 linked in global mode or not. In global mode, the symbols from the
807 linked library can be used to resolve references from other
808 dynamically linked libraries. In non-global mode, the linked
809 library is essentially invisible and can only be accessed via
810 `dynamic-func', etc. The default is now to link in global mode.
811 Previously, the default has been non-global mode.
812
813 The `#:global' keyword is only effective on platforms that support
814 the dlopen family of functions.
815
ad226f25 816** New function `provided?'
b7e13f65
JB
817
818 - Function: provided? FEATURE
819 Return true iff FEATURE is supported by this installation of
820 Guile. FEATURE must be a symbol naming a feature; the global
821 variable `*features*' is a list of available features.
822
ad226f25
JB
823** Changes to the module (ice-9 expect):
824
825*** The expect-strings macro now matches `$' in a regular expression
826 only at a line-break or end-of-file by default. Previously it would
ab711359
JB
827 match the end of the string accumulated so far. The old behaviour
828 can be obtained by setting the variable `expect-strings-exec-flags'
829 to 0.
ad226f25
JB
830
831*** The expect-strings macro now uses a variable `expect-strings-exec-flags'
832 for the regexp-exec flags. If `regexp/noteol' is included, then `$'
833 in a regular expression will still match before a line-break or
834 end-of-file. The default is `regexp/noteol'.
835
836*** The expect-strings macro now uses a variable
837 `expect-strings-compile-flags' for the flags to be supplied to
838 `make-regexp'. The default is `regexp/newline', which was previously
839 hard-coded.
840
841*** The expect macro now supplies two arguments to a match procedure:
ab711359
JB
842 the current accumulated string and a flag to indicate whether
843 end-of-file has been reached. Previously only the string was supplied.
844 If end-of-file is reached, the match procedure will be called an
845 additional time with the same accumulated string as the previous call
846 but with the flag set.
ad226f25 847
b7e13f65
JB
848** New module (ice-9 format), implementing the Common Lisp `format' function.
849
850This code, and the documentation for it that appears here, was
851borrowed from SLIB, with minor adaptations for Guile.
852
853 - Function: format DESTINATION FORMAT-STRING . ARGUMENTS
854 An almost complete implementation of Common LISP format description
855 according to the CL reference book `Common LISP' from Guy L.
856 Steele, Digital Press. Backward compatible to most of the
857 available Scheme format implementations.
858
859 Returns `#t', `#f' or a string; has side effect of printing
860 according to FORMAT-STRING. If DESTINATION is `#t', the output is
861 to the current output port and `#t' is returned. If DESTINATION
862 is `#f', a formatted string is returned as the result of the call.
863 NEW: If DESTINATION is a string, DESTINATION is regarded as the
864 format string; FORMAT-STRING is then the first argument and the
865 output is returned as a string. If DESTINATION is a number, the
866 output is to the current error port if available by the
867 implementation. Otherwise DESTINATION must be an output port and
868 `#t' is returned.
869
870 FORMAT-STRING must be a string. In case of a formatting error
871 format returns `#f' and prints a message on the current output or
872 error port. Characters are output as if the string were output by
873 the `display' function with the exception of those prefixed by a
874 tilde (~). For a detailed description of the FORMAT-STRING syntax
875 please consult a Common LISP format reference manual. For a test
876 suite to verify this format implementation load `formatst.scm'.
877 Please send bug reports to `lutzeb@cs.tu-berlin.de'.
878
879 Note: `format' is not reentrant, i.e. only one `format'-call may
880 be executed at a time.
881
882
883*** Format Specification (Format version 3.0)
884
885 Please consult a Common LISP format reference manual for a detailed
886description of the format string syntax. For a demonstration of the
887implemented directives see `formatst.scm'.
888
889 This implementation supports directive parameters and modifiers (`:'
890and `@' characters). Multiple parameters must be separated by a comma
891(`,'). Parameters can be numerical parameters (positive or negative),
892character parameters (prefixed by a quote character (`''), variable
893parameters (`v'), number of rest arguments parameter (`#'), empty and
894default parameters. Directive characters are case independent. The
895general form of a directive is:
896
897DIRECTIVE ::= ~{DIRECTIVE-PARAMETER,}[:][@]DIRECTIVE-CHARACTER
898
899DIRECTIVE-PARAMETER ::= [ [-|+]{0-9}+ | 'CHARACTER | v | # ]
900
901*** Implemented CL Format Control Directives
902
903 Documentation syntax: Uppercase characters represent the
904corresponding control directive characters. Lowercase characters
905represent control directive parameter descriptions.
906
907`~A'
908 Any (print as `display' does).
909 `~@A'
910 left pad.
911
912 `~MINCOL,COLINC,MINPAD,PADCHARA'
913 full padding.
914
915`~S'
916 S-expression (print as `write' does).
917 `~@S'
918 left pad.
919
920 `~MINCOL,COLINC,MINPAD,PADCHARS'
921 full padding.
922
923`~D'
924 Decimal.
925 `~@D'
926 print number sign always.
927
928 `~:D'
929 print comma separated.
930
931 `~MINCOL,PADCHAR,COMMACHARD'
932 padding.
933
934`~X'
935 Hexadecimal.
936 `~@X'
937 print number sign always.
938
939 `~:X'
940 print comma separated.
941
942 `~MINCOL,PADCHAR,COMMACHARX'
943 padding.
944
945`~O'
946 Octal.
947 `~@O'
948 print number sign always.
949
950 `~:O'
951 print comma separated.
952
953 `~MINCOL,PADCHAR,COMMACHARO'
954 padding.
955
956`~B'
957 Binary.
958 `~@B'
959 print number sign always.
960
961 `~:B'
962 print comma separated.
963
964 `~MINCOL,PADCHAR,COMMACHARB'
965 padding.
966
967`~NR'
968 Radix N.
969 `~N,MINCOL,PADCHAR,COMMACHARR'
970 padding.
971
972`~@R'
973 print a number as a Roman numeral.
974
975`~:@R'
976 print a number as an "old fashioned" Roman numeral.
977
978`~:R'
979 print a number as an ordinal English number.
980
981`~:@R'
982 print a number as a cardinal English number.
983
984`~P'
985 Plural.
986 `~@P'
987 prints `y' and `ies'.
988
989 `~:P'
990 as `~P but jumps 1 argument backward.'
991
992 `~:@P'
993 as `~@P but jumps 1 argument backward.'
994
995`~C'
996 Character.
997 `~@C'
998 prints a character as the reader can understand it (i.e. `#\'
999 prefixing).
1000
1001 `~:C'
1002 prints a character as emacs does (eg. `^C' for ASCII 03).
1003
1004`~F'
1005 Fixed-format floating-point (prints a flonum like MMM.NNN).
1006 `~WIDTH,DIGITS,SCALE,OVERFLOWCHAR,PADCHARF'
1007 `~@F'
1008 If the number is positive a plus sign is printed.
1009
1010`~E'
1011 Exponential floating-point (prints a flonum like MMM.NNN`E'EE).
1012 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARE'
1013 `~@E'
1014 If the number is positive a plus sign is printed.
1015
1016`~G'
1017 General floating-point (prints a flonum either fixed or
1018 exponential).
1019 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARG'
1020 `~@G'
1021 If the number is positive a plus sign is printed.
1022
1023`~$'
1024 Dollars floating-point (prints a flonum in fixed with signs
1025 separated).
1026 `~DIGITS,SCALE,WIDTH,PADCHAR$'
1027 `~@$'
1028 If the number is positive a plus sign is printed.
1029
1030 `~:@$'
1031 A sign is always printed and appears before the padding.
1032
1033 `~:$'
1034 The sign appears before the padding.
1035
1036`~%'
1037 Newline.
1038 `~N%'
1039 print N newlines.
1040
1041`~&'
1042 print newline if not at the beginning of the output line.
1043 `~N&'
1044 prints `~&' and then N-1 newlines.
1045
1046`~|'
1047 Page Separator.
1048 `~N|'
1049 print N page separators.
1050
1051`~~'
1052 Tilde.
1053 `~N~'
1054 print N tildes.
1055
1056`~'<newline>
1057 Continuation Line.
1058 `~:'<newline>
1059 newline is ignored, white space left.
1060
1061 `~@'<newline>
1062 newline is left, white space ignored.
1063
1064`~T'
1065 Tabulation.
1066 `~@T'
1067 relative tabulation.
1068
1069 `~COLNUM,COLINCT'
1070 full tabulation.
1071
1072`~?'
1073 Indirection (expects indirect arguments as a list).
1074 `~@?'
1075 extracts indirect arguments from format arguments.
1076
1077`~(STR~)'
1078 Case conversion (converts by `string-downcase').
1079 `~:(STR~)'
1080 converts by `string-capitalize'.
1081
1082 `~@(STR~)'
1083 converts by `string-capitalize-first'.
1084
1085 `~:@(STR~)'
1086 converts by `string-upcase'.
1087
1088`~*'
1089 Argument Jumping (jumps 1 argument forward).
1090 `~N*'
1091 jumps N arguments forward.
1092
1093 `~:*'
1094 jumps 1 argument backward.
1095
1096 `~N:*'
1097 jumps N arguments backward.
1098
1099 `~@*'
1100 jumps to the 0th argument.
1101
1102 `~N@*'
1103 jumps to the Nth argument (beginning from 0)
1104
1105`~[STR0~;STR1~;...~;STRN~]'
1106 Conditional Expression (numerical clause conditional).
1107 `~N['
1108 take argument from N.
1109
1110 `~@['
1111 true test conditional.
1112
1113 `~:['
1114 if-else-then conditional.
1115
1116 `~;'
1117 clause separator.
1118
1119 `~:;'
1120 default clause follows.
1121
1122`~{STR~}'
1123 Iteration (args come from the next argument (a list)).
1124 `~N{'
1125 at most N iterations.
1126
1127 `~:{'
1128 args from next arg (a list of lists).
1129
1130 `~@{'
1131 args from the rest of arguments.
1132
1133 `~:@{'
1134 args from the rest args (lists).
1135
1136`~^'
1137 Up and out.
1138 `~N^'
1139 aborts if N = 0
1140
1141 `~N,M^'
1142 aborts if N = M
1143
1144 `~N,M,K^'
1145 aborts if N <= M <= K
1146
1147*** Not Implemented CL Format Control Directives
1148
1149`~:A'
1150 print `#f' as an empty list (see below).
1151
1152`~:S'
1153 print `#f' as an empty list (see below).
1154
1155`~<~>'
1156 Justification.
1157
1158`~:^'
1159 (sorry I don't understand its semantics completely)
1160
1161*** Extended, Replaced and Additional Control Directives
1162
1163`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHD'
1164`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHX'
1165`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHO'
1166`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHB'
1167`~N,MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHR'
1168 COMMAWIDTH is the number of characters between two comma
1169 characters.
1170
1171`~I'
1172 print a R4RS complex number as `~F~@Fi' with passed parameters for
1173 `~F'.
1174
1175`~Y'
1176 Pretty print formatting of an argument for scheme code lists.
1177
1178`~K'
1179 Same as `~?.'
1180
1181`~!'
1182 Flushes the output if format DESTINATION is a port.
1183
1184`~_'
1185 Print a `#\space' character
1186 `~N_'
1187 print N `#\space' characters.
1188
1189`~/'
1190 Print a `#\tab' character
1191 `~N/'
1192 print N `#\tab' characters.
1193
1194`~NC'
1195 Takes N as an integer representation for a character. No arguments
1196 are consumed. N is converted to a character by `integer->char'. N
1197 must be a positive decimal number.
1198
1199`~:S'
1200 Print out readproof. Prints out internal objects represented as
1201 `#<...>' as strings `"#<...>"' so that the format output can always
1202 be processed by `read'.
1203
1204`~:A'
1205 Print out readproof. Prints out internal objects represented as
1206 `#<...>' as strings `"#<...>"' so that the format output can always
1207 be processed by `read'.
1208
1209`~Q'
1210 Prints information and a copyright notice on the format
1211 implementation.
1212 `~:Q'
1213 prints format version.
1214
1215`~F, ~E, ~G, ~$'
1216 may also print number strings, i.e. passing a number as a string
1217 and format it accordingly.
1218
1219*** Configuration Variables
1220
1221 The format module exports some configuration variables to suit the
1222systems and users needs. There should be no modification necessary for
1223the configuration that comes with Guile. Format detects automatically
1224if the running scheme system implements floating point numbers and
1225complex numbers.
1226
1227format:symbol-case-conv
1228 Symbols are converted by `symbol->string' so the case type of the
1229 printed symbols is implementation dependent.
1230 `format:symbol-case-conv' is a one arg closure which is either
1231 `#f' (no conversion), `string-upcase', `string-downcase' or
1232 `string-capitalize'. (default `#f')
1233
1234format:iobj-case-conv
1235 As FORMAT:SYMBOL-CASE-CONV but applies for the representation of
1236 implementation internal objects. (default `#f')
1237
1238format:expch
1239 The character prefixing the exponent value in `~E' printing.
1240 (default `#\E')
1241
1242*** Compatibility With Other Format Implementations
1243
1244SLIB format 2.x:
1245 See `format.doc'.
1246
1247SLIB format 1.4:
1248 Downward compatible except for padding support and `~A', `~S',
1249 `~P', `~X' uppercase printing. SLIB format 1.4 uses C-style
1250 `printf' padding support which is completely replaced by the CL
1251 `format' padding style.
1252
1253MIT C-Scheme 7.1:
1254 Downward compatible except for `~', which is not documented
1255 (ignores all characters inside the format string up to a newline
1256 character). (7.1 implements `~a', `~s', ~NEWLINE, `~~', `~%',
1257 numerical and variable parameters and `:/@' modifiers in the CL
1258 sense).
1259
1260Elk 1.5/2.0:
1261 Downward compatible except for `~A' and `~S' which print in
1262 uppercase. (Elk implements `~a', `~s', `~~', and `~%' (no
1263 directive parameters or modifiers)).
1264
1265Scheme->C 01nov91:
1266 Downward compatible except for an optional destination parameter:
1267 S2C accepts a format call without a destination which returns a
1268 formatted string. This is equivalent to a #f destination in S2C.
1269 (S2C implements `~a', `~s', `~c', `~%', and `~~' (no directive
1270 parameters or modifiers)).
1271
1272
e7d37b0a 1273** Changes to string-handling functions.
b7e13f65 1274
e7d37b0a 1275These functions were added to support the (ice-9 format) module, above.
b7e13f65 1276
e7d37b0a
JB
1277*** New function: string-upcase STRING
1278*** New function: string-downcase STRING
b7e13f65 1279
e7d37b0a
JB
1280These are non-destructive versions of the existing string-upcase! and
1281string-downcase! functions.
b7e13f65 1282
e7d37b0a
JB
1283*** New function: string-capitalize! STRING
1284*** New function: string-capitalize STRING
1285
1286These functions convert the first letter of each word in the string to
1287upper case. Thus:
1288
1289 (string-capitalize "howdy there")
1290 => "Howdy There"
1291
1292As with the other functions, string-capitalize! modifies the string in
1293place, while string-capitalize returns a modified copy of its argument.
1294
1295*** New function: string-ci->symbol STRING
1296
1297Return a symbol whose name is STRING, but having the same case as if
1298the symbol had be read by `read'.
1299
1300Guile can be configured to be sensitive or insensitive to case
1301differences in Scheme identifiers. If Guile is case-insensitive, all
1302symbols are converted to lower case on input. The `string-ci->symbol'
1303function returns a symbol whose name in STRING, transformed as Guile
1304would if STRING were input.
1305
1306*** New function: substring-move! STRING1 START END STRING2 START
1307
1308Copy the substring of STRING1 from START (inclusive) to END
1309(exclusive) to STRING2 at START. STRING1 and STRING2 may be the same
1310string, and the source and destination areas may overlap; in all
1311cases, the function behaves as if all the characters were copied
1312simultanously.
1313
1314*** Extended functions: substring-move-left! substring-move-right!
1315
1316These functions now correctly copy arbitrarily overlapping substrings;
1317they are both synonyms for substring-move!.
b7e13f65 1318
b7e13f65 1319
deaceb4e
JB
1320** New module (ice-9 getopt-long), with the function `getopt-long'.
1321
1322getopt-long is a function for parsing command-line arguments in a
1323manner consistent with other GNU programs.
1324
1325(getopt-long ARGS GRAMMAR)
1326Parse the arguments ARGS according to the argument list grammar GRAMMAR.
1327
1328ARGS should be a list of strings. Its first element should be the
1329name of the program; subsequent elements should be the arguments
1330that were passed to the program on the command line. The
1331`program-arguments' procedure returns a list of this form.
1332
1333GRAMMAR is a list of the form:
1334((OPTION (PROPERTY VALUE) ...) ...)
1335
1336Each OPTION should be a symbol. `getopt-long' will accept a
1337command-line option named `--OPTION'.
1338Each option can have the following (PROPERTY VALUE) pairs:
1339
1340 (single-char CHAR) --- Accept `-CHAR' as a single-character
1341 equivalent to `--OPTION'. This is how to specify traditional
1342 Unix-style flags.
1343 (required? BOOL) --- If BOOL is true, the option is required.
1344 getopt-long will raise an error if it is not found in ARGS.
1345 (value BOOL) --- If BOOL is #t, the option accepts a value; if
1346 it is #f, it does not; and if it is the symbol
1347 `optional', the option may appear in ARGS with or
1348 without a value.
1349 (predicate FUNC) --- If the option accepts a value (i.e. you
1350 specified `(value #t)' for this option), then getopt
1351 will apply FUNC to the value, and throw an exception
1352 if it returns #f. FUNC should be a procedure which
1353 accepts a string and returns a boolean value; you may
1354 need to use quasiquotes to get it into GRAMMAR.
1355
1356The (PROPERTY VALUE) pairs may occur in any order, but each
1357property may occur only once. By default, options do not have
1358single-character equivalents, are not required, and do not take
1359values.
1360
1361In ARGS, single-character options may be combined, in the usual
1362Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option
1363accepts values, then it must be the last option in the
1364combination; the value is the next argument. So, for example, using
1365the following grammar:
1366 ((apples (single-char #\a))
1367 (blimps (single-char #\b) (value #t))
1368 (catalexis (single-char #\c) (value #t)))
1369the following argument lists would be acceptable:
1370 ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values
1371 for "blimps" and "catalexis")
1372 ("-ab" "bang" "-c" "couth") (same)
1373 ("-ac" "couth" "-b" "bang") (same)
1374 ("-abc" "couth" "bang") (an error, since `-b' is not the
1375 last option in its combination)
1376
1377If an option's value is optional, then `getopt-long' decides
1378whether it has a value by looking at what follows it in ARGS. If
1379the next element is a string, and it does not appear to be an
1380option itself, then that string is the option's value.
1381
1382The value of a long option can appear as the next element in ARGS,
1383or it can follow the option name, separated by an `=' character.
1384Thus, using the same grammar as above, the following argument lists
1385are equivalent:
1386 ("--apples" "Braeburn" "--blimps" "Goodyear")
1387 ("--apples=Braeburn" "--blimps" "Goodyear")
1388 ("--blimps" "Goodyear" "--apples=Braeburn")
1389
1390If the option "--" appears in ARGS, argument parsing stops there;
1391subsequent arguments are returned as ordinary arguments, even if
1392they resemble options. So, in the argument list:
1393 ("--apples" "Granny Smith" "--" "--blimp" "Goodyear")
1394`getopt-long' will recognize the `apples' option as having the
1395value "Granny Smith", but it will not recognize the `blimp'
1396option; it will return the strings "--blimp" and "Goodyear" as
1397ordinary argument strings.
1398
1399The `getopt-long' function returns the parsed argument list as an
1400assocation list, mapping option names --- the symbols from GRAMMAR
1401--- onto their values, or #t if the option does not accept a value.
1402Unused options do not appear in the alist.
1403
1404All arguments that are not the value of any option are returned
1405as a list, associated with the empty list.
1406
1407`getopt-long' throws an exception if:
1408- it finds an unrecognized option in ARGS
1409- a required option is omitted
1410- an option that requires an argument doesn't get one
1411- an option that doesn't accept an argument does get one (this can
1412 only happen using the long option `--opt=value' syntax)
1413- an option predicate fails
1414
1415So, for example:
1416
1417(define grammar
1418 `((lockfile-dir (required? #t)
1419 (value #t)
1420 (single-char #\k)
1421 (predicate ,file-is-directory?))
1422 (verbose (required? #f)
1423 (single-char #\v)
1424 (value #f))
1425 (x-includes (single-char #\x))
1426 (rnet-server (single-char #\y)
1427 (predicate ,string?))))
1428
1429(getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include"
1430 "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3")
1431 grammar)
1432=> ((() "foo1" "-fred" "foo2" "foo3")
1433 (rnet-server . "lamprod")
1434 (x-includes . "/usr/include")
1435 (lockfile-dir . "/tmp")
1436 (verbose . #t))
1437
1438** The (ice-9 getopt-gnu-style) module is obsolete; use (ice-9 getopt-long).
1439
1440It will be removed in a few releases.
1441
08394899
MS
1442** New syntax: lambda*
1443** New syntax: define*
1444** New syntax: define*-public
1445** New syntax: defmacro*
1446** New syntax: defmacro*-public
1447Guile now supports optional arguments.
1448
1449`lambda*', `define*', `define*-public', `defmacro*' and
1450`defmacro*-public' are identical to the non-* versions except that
1451they use an extended type of parameter list that has the following BNF
1452syntax (parentheses are literal, square brackets indicate grouping,
1453and `*', `+' and `?' have the usual meaning):
1454
1455 ext-param-list ::= ( [identifier]* [#&optional [ext-var-decl]+]?
1456 [#&key [ext-var-decl]+ [#&allow-other-keys]?]?
1457 [[#&rest identifier]|[. identifier]]? ) | [identifier]
1458
1459 ext-var-decl ::= identifier | ( identifier expression )
1460
1461The semantics are best illustrated with the following documentation
1462and examples for `lambda*':
1463
1464 lambda* args . body
1465 lambda extended for optional and keyword arguments
1466
1467 lambda* creates a procedure that takes optional arguments. These
1468 are specified by putting them inside brackets at the end of the
1469 paramater list, but before any dotted rest argument. For example,
1470 (lambda* (a b #&optional c d . e) '())
1471 creates a procedure with fixed arguments a and b, optional arguments c
1472 and d, and rest argument e. If the optional arguments are omitted
1473 in a call, the variables for them are unbound in the procedure. This
1474 can be checked with the bound? macro.
1475
1476 lambda* can also take keyword arguments. For example, a procedure
1477 defined like this:
1478 (lambda* (#&key xyzzy larch) '())
1479 can be called with any of the argument lists (#:xyzzy 11)
1480 (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments
1481 are given as keywords are bound to values.
1482
1483 Optional and keyword arguments can also be given default values
1484 which they take on when they are not present in a call, by giving a
1485 two-item list in place of an optional argument, for example in:
1486 (lambda* (foo #&optional (bar 42) #&key (baz 73)) (list foo bar baz))
1487 foo is a fixed argument, bar is an optional argument with default
1488 value 42, and baz is a keyword argument with default value 73.
1489 Default value expressions are not evaluated unless they are needed
1490 and until the procedure is called.
1491
1492 lambda* now supports two more special parameter list keywords.
1493
1494 lambda*-defined procedures now throw an error by default if a
1495 keyword other than one of those specified is found in the actual
1496 passed arguments. However, specifying #&allow-other-keys
1497 immediately after the kyword argument declarations restores the
1498 previous behavior of ignoring unknown keywords. lambda* also now
1499 guarantees that if the same keyword is passed more than once, the
1500 last one passed is the one that takes effect. For example,
1501 ((lambda* (#&key (heads 0) (tails 0)) (display (list heads tails)))
1502 #:heads 37 #:tails 42 #:heads 99)
1503 would result in (99 47) being displayed.
1504
1505 #&rest is also now provided as a synonym for the dotted syntax rest
1506 argument. The argument lists (a . b) and (a #&rest b) are equivalent in
1507 all respects to lambda*. This is provided for more similarity to DSSSL,
1508 MIT-Scheme and Kawa among others, as well as for refugees from other
1509 Lisp dialects.
1510
1511Further documentation may be found in the optargs.scm file itself.
1512
1513The optional argument module also exports the macros `let-optional',
1514`let-optional*', `let-keywords', `let-keywords*' and `bound?'. These
1515are not documented here because they may be removed in the future, but
1516full documentation is still available in optargs.scm.
1517
2e132553
JB
1518** New syntax: and-let*
1519Guile now supports the `and-let*' form, described in the draft SRFI-2.
1520
1521Syntax: (land* (<clause> ...) <body> ...)
1522Each <clause> should have one of the following forms:
1523 (<variable> <expression>)
1524 (<expression>)
1525 <bound-variable>
1526Each <variable> or <bound-variable> should be an identifier. Each
1527<expression> should be a valid expression. The <body> should be a
1528possibly empty sequence of expressions, like the <body> of a
1529lambda form.
1530
1531Semantics: A LAND* expression is evaluated by evaluating the
1532<expression> or <bound-variable> of each of the <clause>s from
1533left to right. The value of the first <expression> or
1534<bound-variable> that evaluates to a false value is returned; the
1535remaining <expression>s and <bound-variable>s are not evaluated.
1536The <body> forms are evaluated iff all the <expression>s and
1537<bound-variable>s evaluate to true values.
1538
1539The <expression>s and the <body> are evaluated in an environment
1540binding each <variable> of the preceding (<variable> <expression>)
1541clauses to the value of the <expression>. Later bindings
1542shadow earlier bindings.
1543
1544Guile's and-let* macro was contributed by Michael Livshin.
1545
36d3d540
MD
1546** New sorting functions
1547
1548*** New function: sorted? SEQUENCE LESS?
ed8c8636
MD
1549Returns `#t' when the sequence argument is in non-decreasing order
1550according to LESS? (that is, there is no adjacent pair `... x y
1551...' for which `(less? y x)').
1552
1553Returns `#f' when the sequence contains at least one out-of-order
1554pair. It is an error if the sequence is neither a list nor a
1555vector.
1556
36d3d540 1557*** New function: merge LIST1 LIST2 LESS?
ed8c8636
MD
1558LIST1 and LIST2 are sorted lists.
1559Returns the sorted list of all elements in LIST1 and LIST2.
1560
1561Assume that the elements a and b1 in LIST1 and b2 in LIST2 are "equal"
1562in the sense that (LESS? x y) --> #f for x, y in {a, b1, b2},
1563and that a < b1 in LIST1. Then a < b1 < b2 in the result.
1564(Here "<" should read "comes before".)
1565
36d3d540 1566*** New procedure: merge! LIST1 LIST2 LESS?
ed8c8636
MD
1567Merges two lists, re-using the pairs of LIST1 and LIST2 to build
1568the result. If the code is compiled, and LESS? constructs no new
1569pairs, no pairs at all will be allocated. The first pair of the
1570result will be either the first pair of LIST1 or the first pair of
1571LIST2.
1572
36d3d540 1573*** New function: sort SEQUENCE LESS?
ed8c8636
MD
1574Accepts either a list or a vector, and returns a new sequence
1575which is sorted. The new sequence is the same type as the input.
1576Always `(sorted? (sort sequence less?) less?)'. The original
1577sequence is not altered in any way. The new sequence shares its
1578elements with the old one; no elements are copied.
1579
36d3d540 1580*** New procedure: sort! SEQUENCE LESS
ed8c8636
MD
1581Returns its sorted result in the original boxes. No new storage is
1582allocated at all. Proper usage: (set! slist (sort! slist <))
1583
36d3d540 1584*** New function: stable-sort SEQUENCE LESS?
ed8c8636
MD
1585Similar to `sort' but stable. That is, if "equal" elements are
1586ordered a < b in the original sequence, they will have the same order
1587in the result.
1588
36d3d540 1589*** New function: stable-sort! SEQUENCE LESS?
ed8c8636
MD
1590Similar to `sort!' but stable.
1591Uses temporary storage when sorting vectors.
1592
36d3d540 1593*** New functions: sort-list, sort-list!
ed8c8636
MD
1594Added for compatibility with scsh.
1595
36d3d540
MD
1596** New built-in random number support
1597
1598*** New function: random N [STATE]
3e8370c3
MD
1599Accepts a positive integer or real N and returns a number of the
1600same type between zero (inclusive) and N (exclusive). The values
1601returned have a uniform distribution.
1602
1603The optional argument STATE must be of the type produced by
416075f1
MD
1604`copy-random-state' or `seed->random-state'. It defaults to the value
1605of the variable `*random-state*'. This object is used to maintain the
1606state of the pseudo-random-number generator and is altered as a side
1607effect of the `random' operation.
3e8370c3 1608
36d3d540 1609*** New variable: *random-state*
3e8370c3
MD
1610Holds a data structure that encodes the internal state of the
1611random-number generator that `random' uses by default. The nature
1612of this data structure is implementation-dependent. It may be
1613printed out and successfully read back in, but may or may not
1614function correctly as a random-number state object in another
1615implementation.
1616
36d3d540 1617*** New function: copy-random-state [STATE]
3e8370c3
MD
1618Returns a new object of type suitable for use as the value of the
1619variable `*random-state*' and as a second argument to `random'.
1620If argument STATE is given, a copy of it is returned. Otherwise a
1621copy of `*random-state*' is returned.
416075f1 1622
36d3d540 1623*** New function: seed->random-state SEED
416075f1
MD
1624Returns a new object of type suitable for use as the value of the
1625variable `*random-state*' and as a second argument to `random'.
1626SEED is a string or a number. A new state is generated and
1627initialized using SEED.
3e8370c3 1628
36d3d540 1629*** New function: random:uniform [STATE]
3e8370c3
MD
1630Returns an uniformly distributed inexact real random number in the
1631range between 0 and 1.
1632
36d3d540 1633*** New procedure: random:solid-sphere! VECT [STATE]
3e8370c3
MD
1634Fills VECT with inexact real random numbers the sum of whose
1635squares is less than 1.0. Thinking of VECT as coordinates in
1636space of dimension N = `(vector-length VECT)', the coordinates are
1637uniformly distributed within the unit N-shere. The sum of the
1638squares of the numbers is returned. VECT can be either a vector
1639or a uniform vector of doubles.
1640
36d3d540 1641*** New procedure: random:hollow-sphere! VECT [STATE]
3e8370c3
MD
1642Fills VECT with inexact real random numbers the sum of whose squares
1643is equal to 1.0. Thinking of VECT as coordinates in space of
1644dimension n = `(vector-length VECT)', the coordinates are uniformly
1645distributed over the surface of the unit n-shere. VECT can be either
1646a vector or a uniform vector of doubles.
1647
36d3d540 1648*** New function: random:normal [STATE]
3e8370c3
MD
1649Returns an inexact real in a normal distribution with mean 0 and
1650standard deviation 1. For a normal distribution with mean M and
1651standard deviation D use `(+ M (* D (random:normal)))'.
1652
36d3d540 1653*** New procedure: random:normal-vector! VECT [STATE]
3e8370c3
MD
1654Fills VECT with inexact real random numbers which are independent and
1655standard normally distributed (i.e., with mean 0 and variance 1).
1656VECT can be either a vector or a uniform vector of doubles.
1657
36d3d540 1658*** New function: random:exp STATE
3e8370c3
MD
1659Returns an inexact real in an exponential distribution with mean 1.
1660For an exponential distribution with mean U use (* U (random:exp)).
1661
69c6acbb
JB
1662** The range of logand, logior, logxor, logtest, and logbit? have changed.
1663
1664These functions now operate on numbers in the range of a C unsigned
1665long.
1666
1667These functions used to operate on numbers in the range of a C signed
1668long; however, this seems inappropriate, because Guile integers don't
1669overflow.
1670
ba4ee0d6
MD
1671** New function: make-guardian
1672This is an implementation of guardians as described in
1673R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a
1674Generation-Based Garbage Collector" ACM SIGPLAN Conference on
1675Programming Language Design and Implementation, June 1993
1676ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz
1677
88ceea5c
MD
1678** New functions: delq1!, delv1!, delete1!
1679These procedures behave similar to delq! and friends but delete only
1680one object if at all.
1681
55254a6a
MD
1682** New function: unread-string STRING PORT
1683Unread STRING to PORT, that is, push it back onto the port so that
1684next read operation will work on the pushed back characters.
1685
1686** unread-char can now be called multiple times
1687If unread-char is called multiple times, the unread characters will be
1688read again in last-in first-out order.
1689
9e97c52d
GH
1690** the procedures uniform-array-read! and uniform-array-write! now
1691work on any kind of port, not just ports which are open on a file.
1692
b074884f 1693** Now 'l' in a port mode requests line buffering.
9e97c52d 1694
69bc9ff3
GH
1695** The procedure truncate-file now works on string ports as well
1696as file ports. If the size argument is omitted, the current
1b9c3dae 1697file position is used.
9e97c52d 1698
c94577b4 1699** new procedure: seek PORT/FDES OFFSET WHENCE
9e97c52d
GH
1700The arguments are the same as for the old fseek procedure, but it
1701works on string ports as well as random-access file ports.
1702
1703** the fseek procedure now works on string ports, since it has been
c94577b4 1704redefined using seek.
9e97c52d
GH
1705
1706** the setvbuf procedure now uses a default size if mode is _IOFBF and
1707size is not supplied.
1708
1709** the newline procedure no longer flushes the port if it's not
1710line-buffered: previously it did if it was the current output port.
1711
1712** open-pipe and close-pipe are no longer primitive procedures, but
1713an emulation can be obtained using `(use-modules (ice-9 popen))'.
1714
1715** the freopen procedure has been removed.
1716
1717** new procedure: drain-input PORT
1718Drains PORT's read buffers (including any pushed-back characters)
1719and returns the contents as a single string.
1720
67ad463a 1721** New function: map-in-order PROC LIST1 LIST2 ...
d41b3904
MD
1722Version of `map' which guarantees that the procedure is applied to the
1723lists in serial order.
1724
67ad463a
MD
1725** Renamed `serial-array-copy!' and `serial-array-map!' to
1726`array-copy-in-order!' and `array-map-in-order!'. The old names are
1727now obsolete and will go away in release 1.5.
1728
cf7132b3 1729** New syntax: collect BODY1 ...
d41b3904
MD
1730Version of `begin' which returns a list of the results of the body
1731forms instead of the result of the last body form. In contrast to
cf7132b3 1732`begin', `collect' allows an empty body.
d41b3904 1733
e4eae9b1
MD
1734** New functions: read-history FILENAME, write-history FILENAME
1735Read/write command line history from/to file. Returns #t on success
1736and #f if an error occured.
1737
d21ffe26
JB
1738** `ls' and `lls' in module (ice-9 ls) now handle no arguments.
1739
1740These procedures return a list of definitions available in the specified
1741argument, a relative module reference. In the case of no argument,
1742`(current-module)' is now consulted for definitions to return, instead
1743of simply returning #f, the former behavior.
1744
f8c9d497
JB
1745** The #/ syntax for lists is no longer supported.
1746
1747Earlier versions of Scheme accepted this syntax, but printed a
1748warning.
1749
1750** Guile no longer consults the SCHEME_LOAD_PATH environment variable.
1751
1752Instead, you should set GUILE_LOAD_PATH to tell Guile where to find
1753modules.
1754
3ffc7a36
MD
1755* Changes to the gh_ interface
1756
1757** gh_scm2doubles
1758
1759Now takes a second argument which is the result array. If this
1760pointer is NULL, a new array is malloced (the old behaviour).
1761
1762** gh_chars2byvect, gh_shorts2svect, gh_floats2fvect, gh_scm2chars,
1763 gh_scm2shorts, gh_scm2longs, gh_scm2floats
1764
1765New functions.
1766
3e8370c3
MD
1767* Changes to the scm_ interface
1768
ad91d6c3
MD
1769** Function: scm_make_named_hook (char* name, int n_args)
1770
1771Creates a hook in the same way as make-hook above but also
1772binds a variable named NAME to it.
1773
1774This is the typical way of creating a hook from C code.
1775
ece41168
MD
1776Currently, the variable is created in the "current" module. This
1777might change when we get the new module system.
ad91d6c3 1778
16a5a9a4
MD
1779** The smob interface
1780
1781The interface for creating smobs has changed. For documentation, see
1782data-rep.info (made from guile-core/doc/data-rep.texi).
1783
1784*** Deprecated function: SCM scm_newsmob (scm_smobfuns *)
1785
1786>>> This function will be removed in 1.3.4. <<<
1787
1788It is replaced by:
1789
1790*** Function: SCM scm_make_smob_type (const char *name, scm_sizet size)
1791This function adds a new smob type, named NAME, with instance size
1792SIZE to the system. The return value is a tag that is used in
1793creating instances of the type. If SIZE is 0, then no memory will
1794be allocated when instances of the smob are created, and nothing
1795will be freed by the default free function.
1796
1797*** Function: void scm_set_smob_mark (long tc, SCM (*mark) (SCM))
1798This function sets the smob marking procedure for the smob type
1799specified by the tag TC. TC is the tag returned by
1800`scm_make_smob_type'.
1801
1802*** Function: void scm_set_smob_free (long tc, SCM (*mark) (SCM))
1803This function sets the smob freeing procedure for the smob type
1804specified by the tag TC. TC is the tag returned by
1805`scm_make_smob_type'.
1806
1807*** Function: void scm_set_smob_print (tc, print)
1808
1809 - Function: void scm_set_smob_print (long tc,
1810 scm_sizet (*print) (SCM,
1811 SCM,
1812 scm_print_state *))
1813
1814This function sets the smob printing procedure for the smob type
1815specified by the tag TC. TC is the tag returned by
1816`scm_make_smob_type'.
1817
1818*** Function: void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM))
1819This function sets the smob equality-testing predicate for the
1820smob type specified by the tag TC. TC is the tag returned by
1821`scm_make_smob_type'.
1822
1823*** Macro: void SCM_NEWSMOB (SCM var, long tc, void *data)
1824Make VALUE contain a smob instance of the type with type code TC and
1825smob data DATA. VALUE must be previously declared as C type `SCM'.
1826
1827*** Macro: fn_returns SCM_RETURN_NEWSMOB (long tc, void *data)
1828This macro expands to a block of code that creates a smob instance
1829of the type with type code TC and smob data DATA, and returns that
1830`SCM' value. It should be the last piece of code in a block.
1831
9e97c52d
GH
1832** The interfaces for using I/O ports and implementing port types
1833(ptobs) have changed significantly. The new interface is based on
1834shared access to buffers and a new set of ptob procedures.
1835
16a5a9a4
MD
1836*** scm_newptob has been removed
1837
1838It is replaced by:
1839
1840*** Function: SCM scm_make_port_type (type_name, fill_buffer, write_flush)
1841
1842- Function: SCM scm_make_port_type (char *type_name,
1843 int (*fill_buffer) (SCM port),
1844 void (*write_flush) (SCM port));
1845
1846Similarly to the new smob interface, there is a set of function
1847setters by which the user can customize the behaviour of his port
544e9093 1848type. See ports.h (scm_set_port_XXX).
16a5a9a4 1849
9e97c52d
GH
1850** scm_strport_to_string: New function: creates a new string from
1851a string port's buffer.
1852
3e8370c3
MD
1853** Plug in interface for random number generators
1854The variable `scm_the_rng' in random.c contains a value and three
1855function pointers which together define the current random number
1856generator being used by the Scheme level interface and the random
1857number library functions.
1858
1859The user is free to replace the default generator with the generator
1860of his own choice.
1861
1862*** Variable: size_t scm_the_rng.rstate_size
1863The size of the random state type used by the current RNG
1864measured in chars.
1865
1866*** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE)
1867Given the random STATE, return 32 random bits.
1868
1869*** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N)
1870Seed random state STATE using string S of length N.
1871
1872*** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE)
1873Given random state STATE, return a malloced copy.
1874
1875** Default RNG
1876The default RNG is the MWC (Multiply With Carry) random number
1877generator described by George Marsaglia at the Department of
1878Statistics and Supercomputer Computations Research Institute, The
1879Florida State University (http://stat.fsu.edu/~geo).
1880
1881It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and
1882passes all tests in the DIEHARD test suite
1883(http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits
1884costs one multiply and one add on platforms which either supports long
1885longs (gcc does this on most systems) or have 64 bit longs. The cost
1886is four multiply on other systems but this can be optimized by writing
1887scm_i_uniform32 in assembler.
1888
1889These functions are provided through the scm_the_rng interface for use
1890by libguile and the application.
1891
1892*** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE)
1893Given the random STATE, return 32 random bits.
1894Don't use this function directly. Instead go through the plugin
1895interface (see "Plug in interface" above).
1896
1897*** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N)
1898Initialize STATE using SEED of length N.
1899
1900*** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE)
1901Return a malloc:ed copy of STATE. This function can easily be re-used
1902in the interfaces to other RNGs.
1903
1904** Random number library functions
1905These functions use the current RNG through the scm_the_rng interface.
1906It might be a good idea to use these functions from your C code so
1907that only one random generator is used by all code in your program.
1908
259529f2 1909The default random state is stored in:
3e8370c3
MD
1910
1911*** Variable: SCM scm_var_random_state
1912Contains the vcell of the Scheme variable "*random-state*" which is
1913used as default state by all random number functions in the Scheme
1914level interface.
1915
1916Example:
1917
259529f2 1918 double x = scm_c_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state)));
3e8370c3 1919
259529f2
MD
1920*** Function: scm_rstate *scm_c_default_rstate (void)
1921This is a convenience function which returns the value of
1922scm_var_random_state. An error message is generated if this value
1923isn't a random state.
1924
1925*** Function: scm_rstate *scm_c_make_rstate (char *SEED, int LENGTH)
1926Make a new random state from the string SEED of length LENGTH.
1927
1928It is generally not a good idea to use multiple random states in a
1929program. While subsequent random numbers generated from one random
1930state are guaranteed to be reasonably independent, there is no such
1931guarantee for numbers generated from different random states.
1932
1933*** Macro: unsigned long scm_c_uniform32 (scm_rstate *STATE)
1934Return 32 random bits.
1935
1936*** Function: double scm_c_uniform01 (scm_rstate *STATE)
3e8370c3
MD
1937Return a sample from the uniform(0,1) distribution.
1938
259529f2 1939*** Function: double scm_c_normal01 (scm_rstate *STATE)
3e8370c3
MD
1940Return a sample from the normal(0,1) distribution.
1941
259529f2 1942*** Function: double scm_c_exp1 (scm_rstate *STATE)
3e8370c3
MD
1943Return a sample from the exp(1) distribution.
1944
259529f2
MD
1945*** Function: unsigned long scm_c_random (scm_rstate *STATE, unsigned long M)
1946Return a sample from the discrete uniform(0,M) distribution.
1947
1948*** Function: SCM scm_c_random_bignum (scm_rstate *STATE, SCM M)
3e8370c3 1949Return a sample from the discrete uniform(0,M) distribution.
259529f2 1950M must be a bignum object. The returned value may be an INUM.
3e8370c3 1951
9e97c52d 1952
f3227c7a 1953\f
d23bbf3e 1954Changes in Guile 1.3 (released Monday, October 19, 1998):
c484bf7f
JB
1955
1956* Changes to the distribution
1957
e2d6569c
JB
1958** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
1959To avoid conflicts, programs should name environment variables after
1960themselves, except when there's a common practice establishing some
1961other convention.
1962
1963For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
1964giving the former precedence, and printing a warning message if the
1965latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
1966
1967** The header files related to multi-byte characters have been removed.
1968They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
1969which referred to these explicitly will probably need to be rewritten,
1970since the support for the variant string types has been removed; see
1971below.
1972
1973** The header files append.h and sequences.h have been removed. These
1974files implemented non-R4RS operations which would encourage
1975non-portable programming style and less easy-to-read code.
3a97e020 1976
c484bf7f
JB
1977* Changes to the stand-alone interpreter
1978
2e368582 1979** New procedures have been added to implement a "batch mode":
ec4ab4fd 1980
2e368582 1981*** Function: batch-mode?
ec4ab4fd
GH
1982
1983 Returns a boolean indicating whether the interpreter is in batch
1984 mode.
1985
2e368582 1986*** Function: set-batch-mode?! ARG
ec4ab4fd
GH
1987
1988 If ARG is true, switches the interpreter to batch mode. The `#f'
1989 case has not been implemented.
1990
2e368582
JB
1991** Guile now provides full command-line editing, when run interactively.
1992To use this feature, you must have the readline library installed.
1993The Guile build process will notice it, and automatically include
1994support for it.
1995
1996The readline library is available via anonymous FTP from any GNU
1997mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
1998
a5d6d578
MD
1999** the-last-stack is now a fluid.
2000
c484bf7f
JB
2001* Changes to the procedure for linking libguile with your programs
2002
71f20534 2003** You can now use the `guile-config' utility to build programs that use Guile.
2e368582 2004
2adfe1c0 2005Guile now includes a command-line utility called `guile-config', which
71f20534
JB
2006can provide information about how to compile and link programs that
2007use Guile.
2008
2009*** `guile-config compile' prints any C compiler flags needed to use Guile.
2010You should include this command's output on the command line you use
2011to compile C or C++ code that #includes the Guile header files. It's
2012usually just a `-I' flag to help the compiler find the Guile headers.
2013
2014
2015*** `guile-config link' prints any linker flags necessary to link with Guile.
8aa5c148 2016
71f20534 2017This command writes to its standard output a list of flags which you
8aa5c148
JB
2018must pass to the linker to link your code against the Guile library.
2019The flags include '-lguile' itself, any other libraries the Guile
2020library depends upon, and any `-L' flags needed to help the linker
2021find those libraries.
2e368582
JB
2022
2023For example, here is a Makefile rule that builds a program named 'foo'
2024from the object files ${FOO_OBJECTS}, and links them against Guile:
2025
2026 foo: ${FOO_OBJECTS}
2adfe1c0 2027 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
2e368582 2028
e2d6569c
JB
2029Previous Guile releases recommended that you use autoconf to detect
2030which of a predefined set of libraries were present on your system.
2adfe1c0 2031It is more robust to use `guile-config', since it records exactly which
e2d6569c
JB
2032libraries the installed Guile library requires.
2033
2adfe1c0
JB
2034This was originally called `build-guile', but was renamed to
2035`guile-config' before Guile 1.3 was released, to be consistent with
2036the analogous script for the GTK+ GUI toolkit, which is called
2037`gtk-config'.
2038
2e368582 2039
8aa5c148
JB
2040** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
2041
2042If you are using the GNU autoconf package to configure your program,
2043you can use the GUILE_FLAGS autoconf macro to call `guile-config'
2044(described above) and gather the necessary values for use in your
2045Makefiles.
2046
2047The GUILE_FLAGS macro expands to configure script code which runs the
2048`guile-config' script, to find out where Guile's header files and
2049libraries are installed. It sets two variables, marked for
2050substitution, as by AC_SUBST.
2051
2052 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
2053 code that uses Guile header files. This is almost always just a
2054 -I flag.
2055
2056 GUILE_LDFLAGS --- flags to pass to the linker to link a
2057 program against Guile. This includes `-lguile' for the Guile
2058 library itself, any libraries that Guile itself requires (like
2059 -lqthreads), and so on. It may also include a -L flag to tell the
2060 compiler where to find the libraries.
2061
2062GUILE_FLAGS is defined in the file guile.m4, in the top-level
2063directory of the Guile distribution. You can copy it into your
2064package's aclocal.m4 file, and then use it in your configure.in file.
2065
2066If you are using the `aclocal' program, distributed with GNU automake,
2067to maintain your aclocal.m4 file, the Guile installation process
2068installs guile.m4 where aclocal will find it. All you need to do is
2069use GUILE_FLAGS in your configure.in file, and then run `aclocal';
2070this will copy the definition of GUILE_FLAGS into your aclocal.m4
2071file.
2072
2073
c484bf7f 2074* Changes to Scheme functions and syntax
7ad3c1e7 2075
02755d59 2076** Multi-byte strings have been removed, as have multi-byte and wide
e2d6569c
JB
2077ports. We felt that these were the wrong approach to
2078internationalization support.
02755d59 2079
2e368582
JB
2080** New function: readline [PROMPT]
2081Read a line from the terminal, and allow the user to edit it,
2082prompting with PROMPT. READLINE provides a large set of Emacs-like
2083editing commands, lets the user recall previously typed lines, and
2084works on almost every kind of terminal, including dumb terminals.
2085
2086READLINE assumes that the cursor is at the beginning of the line when
2087it is invoked. Thus, you can't print a prompt yourself, and then call
2088READLINE; you need to package up your prompt as a string, pass it to
2089the function, and let READLINE print the prompt itself. This is
2090because READLINE needs to know the prompt's screen width.
2091
8cd57bd0
JB
2092For Guile to provide this function, you must have the readline
2093library, version 2.1 or later, installed on your system. Readline is
2094available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
2095any GNU mirror site.
2e368582
JB
2096
2097See also ADD-HISTORY function.
2098
2099** New function: add-history STRING
2100Add STRING as the most recent line in the history used by the READLINE
2101command. READLINE does not add lines to the history itself; you must
2102call ADD-HISTORY to make previous input available to the user.
2103
8cd57bd0
JB
2104** The behavior of the read-line function has changed.
2105
2106This function now uses standard C library functions to read the line,
2107for speed. This means that it doesn not respect the value of
2108scm-line-incrementors; it assumes that lines are delimited with
2109#\newline.
2110
2111(Note that this is read-line, the function that reads a line of text
2112from a port, not readline, the function that reads a line from a
2113terminal, providing full editing capabilities.)
2114
1a0106ef
JB
2115** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
2116
2117This module provides some simple argument parsing. It exports one
2118function:
2119
2120Function: getopt-gnu-style ARG-LS
2121 Parse a list of program arguments into an alist of option
2122 descriptions.
2123
2124 Each item in the list of program arguments is examined to see if
2125 it meets the syntax of a GNU long-named option. An argument like
2126 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
2127 returned alist, where MUMBLE is a keyword object with the same
2128 name as the argument. An argument like `--MUMBLE=FROB' produces
2129 an element of the form (MUMBLE . FROB), where FROB is a string.
2130
2131 As a special case, the returned alist also contains a pair whose
2132 car is the symbol `rest'. The cdr of this pair is a list
2133 containing all the items in the argument list that are not options
2134 of the form mentioned above.
2135
2136 The argument `--' is treated specially: all items in the argument
2137 list appearing after such an argument are not examined, and are
2138 returned in the special `rest' list.
2139
2140 This function does not parse normal single-character switches.
2141 You will need to parse them out of the `rest' list yourself.
2142
8cd57bd0
JB
2143** The read syntax for byte vectors and short vectors has changed.
2144
2145Instead of #bytes(...), write #y(...).
2146
2147Instead of #short(...), write #h(...).
2148
2149This may seem nutty, but, like the other uniform vectors, byte vectors
2150and short vectors want to have the same print and read syntax (and,
2151more basic, want to have read syntax!). Changing the read syntax to
2152use multiple characters after the hash sign breaks with the
2153conventions used in R5RS and the conventions used for the other
2154uniform vectors. It also introduces complexity in the current reader,
2155both on the C and Scheme levels. (The Right solution is probably to
2156change the syntax and prototypes for uniform vectors entirely.)
2157
2158
2159** The new module (ice-9 session) provides useful interactive functions.
2160
2161*** New procedure: (apropos REGEXP OPTION ...)
2162
2163Display a list of top-level variables whose names match REGEXP, and
2164the modules they are imported from. Each OPTION should be one of the
2165following symbols:
2166
2167 value --- Show the value of each matching variable.
2168 shadow --- Show bindings shadowed by subsequently imported modules.
2169 full --- Same as both `shadow' and `value'.
2170
2171For example:
2172
2173 guile> (apropos "trace" 'full)
2174 debug: trace #<procedure trace args>
2175 debug: untrace #<procedure untrace args>
2176 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
2177 the-scm-module: before-backtrace-hook ()
2178 the-scm-module: backtrace #<primitive-procedure backtrace>
2179 the-scm-module: after-backtrace-hook ()
2180 the-scm-module: has-shown-backtrace-hint? #f
2181 guile>
2182
2183** There are new functions and syntax for working with macros.
2184
2185Guile implements macros as a special object type. Any variable whose
2186top-level binding is a macro object acts as a macro. The macro object
2187specifies how the expression should be transformed before evaluation.
2188
2189*** Macro objects now print in a reasonable way, resembling procedures.
2190
2191*** New function: (macro? OBJ)
2192True iff OBJ is a macro object.
2193
2194*** New function: (primitive-macro? OBJ)
2195Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
2196macro transformers, implemented in eval.c rather than Scheme code.
2197
dbdd0c16
JB
2198Why do we have this function?
2199- For symmetry with procedure? and primitive-procedure?,
2200- to allow custom print procedures to tell whether a macro is
2201 primitive, and display it differently, and
2202- to allow compilers and user-written evaluators to distinguish
2203 builtin special forms from user-defined ones, which could be
2204 compiled.
2205
8cd57bd0
JB
2206*** New function: (macro-type OBJ)
2207Return a value indicating what kind of macro OBJ is. Possible return
2208values are:
2209
2210 The symbol `syntax' --- a macro created by procedure->syntax.
2211 The symbol `macro' --- a macro created by procedure->macro.
2212 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
2213 The boolean #f --- if OBJ is not a macro object.
2214
2215*** New function: (macro-name MACRO)
2216Return the name of the macro object MACRO's procedure, as returned by
2217procedure-name.
2218
2219*** New function: (macro-transformer MACRO)
2220Return the transformer procedure for MACRO.
2221
2222*** New syntax: (use-syntax MODULE ... TRANSFORMER)
2223
2224Specify a new macro expander to use in the current module. Each
2225MODULE is a module name, with the same meaning as in the `use-modules'
2226form; each named module's exported bindings are added to the current
2227top-level environment. TRANSFORMER is an expression evaluated in the
2228resulting environment which must yield a procedure to use as the
2229module's eval transformer: every expression evaluated in this module
2230is passed to this function, and the result passed to the Guile
2231interpreter.
2232
2233*** macro-eval! is removed. Use local-eval instead.
29521173 2234
8d9dcb3c
MV
2235** Some magic has been added to the printer to better handle user
2236written printing routines (like record printers, closure printers).
2237
2238The problem is that these user written routines must have access to
7fbd77df 2239the current `print-state' to be able to handle fancy things like
8d9dcb3c
MV
2240detection of circular references. These print-states have to be
2241passed to the builtin printing routines (display, write, etc) to
2242properly continue the print chain.
2243
2244We didn't want to change all existing print code so that it
8cd57bd0 2245explicitly passes thru a print state in addition to a port. Instead,
8d9dcb3c
MV
2246we extented the possible values that the builtin printing routines
2247accept as a `port'. In addition to a normal port, they now also take
2248a pair of a normal port and a print-state. Printing will go to the
2249port and the print-state will be used to control the detection of
2250circular references, etc. If the builtin function does not care for a
2251print-state, it is simply ignored.
2252
2253User written callbacks are now called with such a pair as their
2254`port', but because every function now accepts this pair as a PORT
2255argument, you don't have to worry about that. In fact, it is probably
2256safest to not check for these pairs.
2257
2258However, it is sometimes necessary to continue a print chain on a
2259different port, for example to get a intermediate string
2260representation of the printed value, mangle that string somehow, and
2261then to finally print the mangled string. Use the new function
2262
2263 inherit-print-state OLD-PORT NEW-PORT
2264
2265for this. It constructs a new `port' that prints to NEW-PORT but
2266inherits the print-state of OLD-PORT.
2267
ef1ea498
MD
2268** struct-vtable-offset renamed to vtable-offset-user
2269
2270** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
2271
2272** There is now a fourth (optional) argument to make-vtable-vtable and
2273 make-struct when constructing new types (vtables). This argument
2274 initializes field vtable-index-printer of the vtable.
2275
4851dc57
MV
2276** The detection of circular references has been extended to structs.
2277That is, a structure that -- in the process of being printed -- prints
2278itself does not lead to infinite recursion.
2279
2280** There is now some basic support for fluids. Please read
2281"libguile/fluid.h" to find out more. It is accessible from Scheme with
2282the following functions and macros:
2283
9c3fb66f
MV
2284Function: make-fluid
2285
2286 Create a new fluid object. Fluids are not special variables or
2287 some other extension to the semantics of Scheme, but rather
2288 ordinary Scheme objects. You can store them into variables (that
2289 are still lexically scoped, of course) or into any other place you
2290 like. Every fluid has a initial value of `#f'.
04c76b58 2291
9c3fb66f 2292Function: fluid? OBJ
04c76b58 2293
9c3fb66f 2294 Test whether OBJ is a fluid.
04c76b58 2295
9c3fb66f
MV
2296Function: fluid-ref FLUID
2297Function: fluid-set! FLUID VAL
04c76b58
MV
2298
2299 Access/modify the fluid FLUID. Modifications are only visible
2300 within the current dynamic root (that includes threads).
2301
9c3fb66f
MV
2302Function: with-fluids* FLUIDS VALUES THUNK
2303
2304 FLUIDS is a list of fluids and VALUES a corresponding list of
2305 values for these fluids. Before THUNK gets called the values are
2306 installed in the fluids and the old values of the fluids are
2307 saved in the VALUES list. When the flow of control leaves THUNK
2308 or reenters it, the values get swapped again. You might think of
2309 this as a `safe-fluid-excursion'. Note that the VALUES list is
2310 modified by `with-fluids*'.
2311
2312Macro: with-fluids ((FLUID VALUE) ...) FORM ...
2313
2314 The same as `with-fluids*' but with a different syntax. It looks
2315 just like `let', but both FLUID and VALUE are evaluated. Remember,
2316 fluids are not special variables but ordinary objects. FLUID
2317 should evaluate to a fluid.
04c76b58 2318
e2d6569c 2319** Changes to system call interfaces:
64d01d13 2320
e2d6569c 2321*** close-port, close-input-port and close-output-port now return a
64d01d13
GH
2322boolean instead of an `unspecified' object. #t means that the port
2323was successfully closed, while #f means it was already closed. It is
2324also now possible for these procedures to raise an exception if an
2325error occurs (some errors from write can be delayed until close.)
2326
e2d6569c 2327*** the first argument to chmod, fcntl, ftell and fseek can now be a
6afcd3b2
GH
2328file descriptor.
2329
e2d6569c 2330*** the third argument to fcntl is now optional.
6afcd3b2 2331
e2d6569c 2332*** the first argument to chown can now be a file descriptor or a port.
6afcd3b2 2333
e2d6569c 2334*** the argument to stat can now be a port.
6afcd3b2 2335
e2d6569c 2336*** The following new procedures have been added (most use scsh
64d01d13
GH
2337interfaces):
2338
e2d6569c 2339*** procedure: close PORT/FD
ec4ab4fd
GH
2340 Similar to close-port (*note close-port: Closing Ports.), but also
2341 works on file descriptors. A side effect of closing a file
2342 descriptor is that any ports using that file descriptor are moved
2343 to a different file descriptor and have their revealed counts set
2344 to zero.
2345
e2d6569c 2346*** procedure: port->fdes PORT
ec4ab4fd
GH
2347 Returns the integer file descriptor underlying PORT. As a side
2348 effect the revealed count of PORT is incremented.
2349
e2d6569c 2350*** procedure: fdes->ports FDES
ec4ab4fd
GH
2351 Returns a list of existing ports which have FDES as an underlying
2352 file descriptor, without changing their revealed counts.
2353
e2d6569c 2354*** procedure: fdes->inport FDES
ec4ab4fd
GH
2355 Returns an existing input port which has FDES as its underlying
2356 file descriptor, if one exists, and increments its revealed count.
2357 Otherwise, returns a new input port with a revealed count of 1.
2358
e2d6569c 2359*** procedure: fdes->outport FDES
ec4ab4fd
GH
2360 Returns an existing output port which has FDES as its underlying
2361 file descriptor, if one exists, and increments its revealed count.
2362 Otherwise, returns a new output port with a revealed count of 1.
2363
2364 The next group of procedures perform a `dup2' system call, if NEWFD
2365(an integer) is supplied, otherwise a `dup'. The file descriptor to be
2366duplicated can be supplied as an integer or contained in a port. The
64d01d13
GH
2367type of value returned varies depending on which procedure is used.
2368
ec4ab4fd
GH
2369 All procedures also have the side effect when performing `dup2' that
2370any ports using NEWFD are moved to a different file descriptor and have
64d01d13
GH
2371their revealed counts set to zero.
2372
e2d6569c 2373*** procedure: dup->fdes PORT/FD [NEWFD]
ec4ab4fd 2374 Returns an integer file descriptor.
64d01d13 2375
e2d6569c 2376*** procedure: dup->inport PORT/FD [NEWFD]
ec4ab4fd 2377 Returns a new input port using the new file descriptor.
64d01d13 2378
e2d6569c 2379*** procedure: dup->outport PORT/FD [NEWFD]
ec4ab4fd 2380 Returns a new output port using the new file descriptor.
64d01d13 2381
e2d6569c 2382*** procedure: dup PORT/FD [NEWFD]
ec4ab4fd
GH
2383 Returns a new port if PORT/FD is a port, with the same mode as the
2384 supplied port, otherwise returns an integer file descriptor.
64d01d13 2385
e2d6569c 2386*** procedure: dup->port PORT/FD MODE [NEWFD]
ec4ab4fd
GH
2387 Returns a new port using the new file descriptor. MODE supplies a
2388 mode string for the port (*note open-file: File Ports.).
64d01d13 2389
e2d6569c 2390*** procedure: setenv NAME VALUE
ec4ab4fd
GH
2391 Modifies the environment of the current process, which is also the
2392 default environment inherited by child processes.
64d01d13 2393
ec4ab4fd
GH
2394 If VALUE is `#f', then NAME is removed from the environment.
2395 Otherwise, the string NAME=VALUE is added to the environment,
2396 replacing any existing string with name matching NAME.
64d01d13 2397
ec4ab4fd 2398 The return value is unspecified.
956055a9 2399
e2d6569c 2400*** procedure: truncate-file OBJ SIZE
6afcd3b2
GH
2401 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
2402 can be a string containing a file name or an integer file
2403 descriptor or port open for output on the file. The underlying
2404 system calls are `truncate' and `ftruncate'.
2405
2406 The return value is unspecified.
2407
e2d6569c 2408*** procedure: setvbuf PORT MODE [SIZE]
7a6f1ffa
GH
2409 Set the buffering mode for PORT. MODE can be:
2410 `_IONBF'
2411 non-buffered
2412
2413 `_IOLBF'
2414 line buffered
2415
2416 `_IOFBF'
2417 block buffered, using a newly allocated buffer of SIZE bytes.
2418 However if SIZE is zero or unspecified, the port will be made
2419 non-buffered.
2420
2421 This procedure should not be used after I/O has been performed with
2422 the port.
2423
2424 Ports are usually block buffered by default, with a default buffer
2425 size. Procedures e.g., *Note open-file: File Ports, which accept a
2426 mode string allow `0' to be added to request an unbuffered port.
2427
e2d6569c 2428*** procedure: fsync PORT/FD
6afcd3b2
GH
2429 Copies any unwritten data for the specified output file descriptor
2430 to disk. If PORT/FD is a port, its buffer is flushed before the
2431 underlying file descriptor is fsync'd. The return value is
2432 unspecified.
2433
e2d6569c 2434*** procedure: open-fdes PATH FLAGS [MODES]
6afcd3b2
GH
2435 Similar to `open' but returns a file descriptor instead of a port.
2436
e2d6569c 2437*** procedure: execle PATH ENV [ARG] ...
6afcd3b2
GH
2438 Similar to `execl', but the environment of the new process is
2439 specified by ENV, which must be a list of strings as returned by
2440 the `environ' procedure.
2441
2442 This procedure is currently implemented using the `execve' system
2443 call, but we call it `execle' because of its Scheme calling
2444 interface.
2445
e2d6569c 2446*** procedure: strerror ERRNO
ec4ab4fd
GH
2447 Returns the Unix error message corresponding to ERRNO, an integer.
2448
e2d6569c 2449*** procedure: primitive-exit [STATUS]
6afcd3b2
GH
2450 Terminate the current process without unwinding the Scheme stack.
2451 This is would typically be useful after a fork. The exit status
2452 is STATUS if supplied, otherwise zero.
2453
e2d6569c 2454*** procedure: times
6afcd3b2
GH
2455 Returns an object with information about real and processor time.
2456 The following procedures accept such an object as an argument and
2457 return a selected component:
2458
2459 `tms:clock'
2460 The current real time, expressed as time units relative to an
2461 arbitrary base.
2462
2463 `tms:utime'
2464 The CPU time units used by the calling process.
2465
2466 `tms:stime'
2467 The CPU time units used by the system on behalf of the
2468 calling process.
2469
2470 `tms:cutime'
2471 The CPU time units used by terminated child processes of the
2472 calling process, whose status has been collected (e.g., using
2473 `waitpid').
2474
2475 `tms:cstime'
2476 Similarly, the CPU times units used by the system on behalf of
2477 terminated child processes.
7ad3c1e7 2478
e2d6569c
JB
2479** Removed: list-length
2480** Removed: list-append, list-append!
2481** Removed: list-reverse, list-reverse!
2482
2483** array-map renamed to array-map!
2484
2485** serial-array-map renamed to serial-array-map!
2486
660f41fa
MD
2487** catch doesn't take #f as first argument any longer
2488
2489Previously, it was possible to pass #f instead of a key to `catch'.
2490That would cause `catch' to pass a jump buffer object to the procedure
2491passed as second argument. The procedure could then use this jump
2492buffer objekt as an argument to throw.
2493
2494This mechanism has been removed since its utility doesn't motivate the
2495extra complexity it introduces.
2496
332d00f6
JB
2497** The `#/' notation for lists now provokes a warning message from Guile.
2498This syntax will be removed from Guile in the near future.
2499
2500To disable the warning message, set the GUILE_HUSH environment
2501variable to any non-empty value.
2502
8cd57bd0
JB
2503** The newline character now prints as `#\newline', following the
2504normal Scheme notation, not `#\nl'.
2505
c484bf7f
JB
2506* Changes to the gh_ interface
2507
8986901b
JB
2508** The gh_enter function now takes care of loading the Guile startup files.
2509gh_enter works by calling scm_boot_guile; see the remarks below.
2510
5424b4f7
MD
2511** Function: void gh_write (SCM x)
2512
2513Write the printed representation of the scheme object x to the current
2514output port. Corresponds to the scheme level `write'.
2515
3a97e020
MD
2516** gh_list_length renamed to gh_length.
2517
8d6787b6
MG
2518** vector handling routines
2519
2520Several major changes. In particular, gh_vector() now resembles
2521(vector ...) (with a caveat -- see manual), and gh_make_vector() now
956328d2
MG
2522exists and behaves like (make-vector ...). gh_vset() and gh_vref()
2523have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
8d6787b6
MG
2524vector-related gh_ functions have been implemented.
2525
7fee59bd
MG
2526** pair and list routines
2527
2528Implemented several of the R4RS pair and list functions that were
2529missing.
2530
171422a9
MD
2531** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
2532
2533New function. Converts double arrays back and forth between Scheme
2534and C.
2535
c484bf7f
JB
2536* Changes to the scm_ interface
2537
8986901b
JB
2538** The function scm_boot_guile now takes care of loading the startup files.
2539
2540Guile's primary initialization function, scm_boot_guile, now takes
2541care of loading `boot-9.scm', in the `ice-9' module, to initialize
2542Guile, define the module system, and put together some standard
2543bindings. It also loads `init.scm', which is intended to hold
2544site-specific initialization code.
2545
2546Since Guile cannot operate properly until boot-9.scm is loaded, there
2547is no reason to separate loading boot-9.scm from Guile's other
2548initialization processes.
2549
2550This job used to be done by scm_compile_shell_switches, which didn't
2551make much sense; in particular, it meant that people using Guile for
2552non-shell-like applications had to jump through hoops to get Guile
2553initialized properly.
2554
2555** The function scm_compile_shell_switches no longer loads the startup files.
2556Now, Guile always loads the startup files, whenever it is initialized;
2557see the notes above for scm_boot_guile and scm_load_startup_files.
2558
2559** Function: scm_load_startup_files
2560This new function takes care of loading Guile's initialization file
2561(`boot-9.scm'), and the site initialization file, `init.scm'. Since
2562this is always called by the Guile initialization process, it's
2563probably not too useful to call this yourself, but it's there anyway.
2564
87148d9e
JB
2565** The semantics of smob marking have changed slightly.
2566
2567The smob marking function (the `mark' member of the scm_smobfuns
2568structure) is no longer responsible for setting the mark bit on the
2569smob. The generic smob handling code in the garbage collector will
2570set this bit. The mark function need only ensure that any other
2571objects the smob refers to get marked.
2572
2573Note that this change means that the smob's GC8MARK bit is typically
2574already set upon entry to the mark function. Thus, marking functions
2575which look like this:
2576
2577 {
2578 if (SCM_GC8MARKP (ptr))
2579 return SCM_BOOL_F;
2580 SCM_SETGC8MARK (ptr);
2581 ... mark objects to which the smob refers ...
2582 }
2583
2584are now incorrect, since they will return early, and fail to mark any
2585other objects the smob refers to. Some code in the Guile library used
2586to work this way.
2587
1cf84ea5
JB
2588** The semantics of the I/O port functions in scm_ptobfuns have changed.
2589
2590If you have implemented your own I/O port type, by writing the
2591functions required by the scm_ptobfuns and then calling scm_newptob,
2592you will need to change your functions slightly.
2593
2594The functions in a scm_ptobfuns structure now expect the port itself
2595as their argument; they used to expect the `stream' member of the
2596port's scm_port_table structure. This allows functions in an
2597scm_ptobfuns structure to easily access the port's cell (and any flags
2598it its CAR), and the port's scm_port_table structure.
2599
2600Guile now passes the I/O port itself as the `port' argument in the
2601following scm_ptobfuns functions:
2602
2603 int (*free) (SCM port);
2604 int (*fputc) (int, SCM port);
2605 int (*fputs) (char *, SCM port);
2606 scm_sizet (*fwrite) SCM_P ((char *ptr,
2607 scm_sizet size,
2608 scm_sizet nitems,
2609 SCM port));
2610 int (*fflush) (SCM port);
2611 int (*fgetc) (SCM port);
2612 int (*fclose) (SCM port);
2613
2614The interfaces to the `mark', `print', `equalp', and `fgets' methods
2615are unchanged.
2616
2617If you have existing code which defines its own port types, it is easy
2618to convert your code to the new interface; simply apply SCM_STREAM to
2619the port argument to yield the value you code used to expect.
2620
2621Note that since both the port and the stream have the same type in the
2622C code --- they are both SCM values --- the C compiler will not remind
2623you if you forget to update your scm_ptobfuns functions.
2624
2625
933a7411
MD
2626** Function: int scm_internal_select (int fds,
2627 SELECT_TYPE *rfds,
2628 SELECT_TYPE *wfds,
2629 SELECT_TYPE *efds,
2630 struct timeval *timeout);
2631
2632This is a replacement for the `select' function provided by the OS.
2633It enables I/O blocking and sleeping to happen for one cooperative
2634thread without blocking other threads. It also avoids busy-loops in
2635these situations. It is intended that all I/O blocking and sleeping
2636will finally go through this function. Currently, this function is
2637only available on systems providing `gettimeofday' and `select'.
2638
5424b4f7
MD
2639** Function: SCM scm_internal_stack_catch (SCM tag,
2640 scm_catch_body_t body,
2641 void *body_data,
2642 scm_catch_handler_t handler,
2643 void *handler_data)
2644
2645A new sibling to the other two C level `catch' functions
2646scm_internal_catch and scm_internal_lazy_catch. Use it if you want
2647the stack to be saved automatically into the variable `the-last-stack'
2648(scm_the_last_stack_var) on error. This is necessary if you want to
2649use advanced error reporting, such as calling scm_display_error and
2650scm_display_backtrace. (They both take a stack object as argument.)
2651
df366c26
MD
2652** Function: SCM scm_spawn_thread (scm_catch_body_t body,
2653 void *body_data,
2654 scm_catch_handler_t handler,
2655 void *handler_data)
2656
2657Spawns a new thread. It does a job similar to
2658scm_call_with_new_thread but takes arguments more suitable when
2659spawning threads from application C code.
2660
88482b31
MD
2661** The hook scm_error_callback has been removed. It was originally
2662intended as a way for the user to install his own error handler. But
2663that method works badly since it intervenes between throw and catch,
2664thereby changing the semantics of expressions like (catch #t ...).
2665The correct way to do it is to use one of the C level catch functions
2666in throw.c: scm_internal_catch/lazy_catch/stack_catch.
2667
3a97e020
MD
2668** Removed functions:
2669
2670scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
2671scm_list_reverse, scm_list_reverse_x
2672
2673** New macros: SCM_LISTn where n is one of the integers 0-9.
2674
2675These can be used for pretty list creation from C. The idea is taken
2676from Erick Gallesio's STk.
2677
298aa6e3
MD
2678** scm_array_map renamed to scm_array_map_x
2679
527da704
MD
2680** mbstrings are now removed
2681
2682This means that the type codes scm_tc7_mb_string and
2683scm_tc7_mb_substring has been removed.
2684
8cd57bd0
JB
2685** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
2686
2687Since we no longer support multi-byte strings, these I/O functions
2688have been simplified, and renamed. Here are their old names, and
2689their new names and arguments:
2690
2691scm_gen_putc -> void scm_putc (int c, SCM port);
2692scm_gen_puts -> void scm_puts (char *s, SCM port);
2693scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
2694scm_gen_getc -> void scm_getc (SCM port);
2695
2696
527da704
MD
2697** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
2698
2699** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
2700
2701SCM_TYP7S now masks away the bit which distinguishes substrings from
2702strings.
2703
660f41fa
MD
2704** scm_catch_body_t: Backward incompatible change!
2705
2706Body functions to scm_internal_catch and friends do not any longer
2707take a second argument. This is because it is no longer possible to
2708pass a #f arg to catch.
2709
a8e05009
JB
2710** Calls to scm_protect_object and scm_unprotect now nest properly.
2711
2712The function scm_protect_object protects its argument from being freed
2713by the garbage collector. scm_unprotect_object removes that
2714protection.
2715
2716These functions now nest properly. That is, for every object O, there
2717is a counter which scm_protect_object(O) increments and
2718scm_unprotect_object(O) decrements, if the counter is greater than
2719zero. Every object's counter is zero when it is first created. If an
2720object's counter is greater than zero, the garbage collector will not
2721reclaim its storage.
2722
2723This allows you to use scm_protect_object in your code without
2724worrying that some other function you call will call
2725scm_unprotect_object, and allow it to be freed. Assuming that the
2726functions you call are well-behaved, and unprotect only those objects
2727they protect, you can follow the same rule and have confidence that
2728objects will be freed only at appropriate times.
2729
c484bf7f
JB
2730\f
2731Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 2732
737c9113
JB
2733* Changes to the distribution
2734
832b09ed
JB
2735** Nightly snapshots are now available from ftp.red-bean.com.
2736The old server, ftp.cyclic.com, has been relinquished to its rightful
2737owner.
2738
2739Nightly snapshots of the Guile development sources are now available via
2740anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
2741
2742Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
2743For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
2744
0fcab5ed
JB
2745** To run Guile without installing it, the procedure has changed a bit.
2746
2747If you used a separate build directory to compile Guile, you'll need
2748to include the build directory in SCHEME_LOAD_PATH, as well as the
2749source directory. See the `INSTALL' file for examples.
2750
737c9113
JB
2751* Changes to the procedure for linking libguile with your programs
2752
94982a4e
JB
2753** The standard Guile load path for Scheme code now includes
2754$(datadir)/guile (usually /usr/local/share/guile). This means that
2755you can install your own Scheme files there, and Guile will find them.
2756(Previous versions of Guile only checked a directory whose name
2757contained the Guile version number, so you had to re-install or move
2758your Scheme sources each time you installed a fresh version of Guile.)
2759
2760The load path also includes $(datadir)/guile/site; we recommend
2761putting individual Scheme files there. If you want to install a
2762package with multiple source files, create a directory for them under
2763$(datadir)/guile.
2764
2765** Guile 1.2 will now use the Rx regular expression library, if it is
2766installed on your system. When you are linking libguile into your own
2767programs, this means you will have to link against -lguile, -lqt (if
2768you configured Guile with thread support), and -lrx.
27590f82
JB
2769
2770If you are using autoconf to generate configuration scripts for your
2771application, the following lines should suffice to add the appropriate
2772libraries to your link command:
2773
2774### Find Rx, quickthreads and libguile.
2775AC_CHECK_LIB(rx, main)
2776AC_CHECK_LIB(qt, main)
2777AC_CHECK_LIB(guile, scm_shell)
2778
94982a4e
JB
2779The Guile 1.2 distribution does not contain sources for the Rx
2780library, as Guile 1.0 did. If you want to use Rx, you'll need to
2781retrieve it from a GNU FTP site and install it separately.
2782
b83b8bee
JB
2783* Changes to Scheme functions and syntax
2784
e035e7e6
MV
2785** The dynamic linking features of Guile are now enabled by default.
2786You can disable them by giving the `--disable-dynamic-linking' option
2787to configure.
2788
e035e7e6
MV
2789 (dynamic-link FILENAME)
2790
2791 Find the object file denoted by FILENAME (a string) and link it
2792 into the running Guile application. When everything works out,
2793 return a Scheme object suitable for representing the linked object
2794 file. Otherwise an error is thrown. How object files are
2795 searched is system dependent.
2796
2797 (dynamic-object? VAL)
2798
2799 Determine whether VAL represents a dynamically linked object file.
2800
2801 (dynamic-unlink DYNOBJ)
2802
2803 Unlink the indicated object file from the application. DYNOBJ
2804 should be one of the values returned by `dynamic-link'.
2805
2806 (dynamic-func FUNCTION DYNOBJ)
2807
2808 Search the C function indicated by FUNCTION (a string or symbol)
2809 in DYNOBJ and return some Scheme object that can later be used
2810 with `dynamic-call' to actually call this function. Right now,
2811 these Scheme objects are formed by casting the address of the
2812 function to `long' and converting this number to its Scheme
2813 representation.
2814
2815 (dynamic-call FUNCTION DYNOBJ)
2816
2817 Call the C function indicated by FUNCTION and DYNOBJ. The
2818 function is passed no arguments and its return value is ignored.
2819 When FUNCTION is something returned by `dynamic-func', call that
2820 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
2821 etc.), look it up in DYNOBJ; this is equivalent to
2822
2823 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
2824
2825 Interrupts are deferred while the C function is executing (with
2826 SCM_DEFER_INTS/SCM_ALLOW_INTS).
2827
2828 (dynamic-args-call FUNCTION DYNOBJ ARGS)
2829
2830 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
2831 some arguments and return its return value. The C function is
2832 expected to take two arguments and return an `int', just like
2833 `main':
2834
2835 int c_func (int argc, char **argv);
2836
2837 ARGS must be a list of strings and is converted into an array of
2838 `char *'. The array is passed in ARGV and its size in ARGC. The
2839 return value is converted to a Scheme number and returned from the
2840 call to `dynamic-args-call'.
2841
0fcab5ed
JB
2842When dynamic linking is disabled or not supported on your system,
2843the above functions throw errors, but they are still available.
2844
e035e7e6
MV
2845Here is a small example that works on GNU/Linux:
2846
2847 (define libc-obj (dynamic-link "libc.so"))
2848 (dynamic-args-call 'rand libc-obj '())
2849
2850See the file `libguile/DYNAMIC-LINKING' for additional comments.
2851
27590f82
JB
2852** The #/ syntax for module names is depreciated, and will be removed
2853in a future version of Guile. Instead of
2854
2855 #/foo/bar/baz
2856
2857instead write
2858
2859 (foo bar baz)
2860
2861The latter syntax is more consistent with existing Lisp practice.
2862
5dade857
MV
2863** Guile now does fancier printing of structures. Structures are the
2864underlying implementation for records, which in turn are used to
2865implement modules, so all of these object now print differently and in
2866a more informative way.
2867
161029df
JB
2868The Scheme printer will examine the builtin variable *struct-printer*
2869whenever it needs to print a structure object. When this variable is
2870not `#f' it is deemed to be a procedure and will be applied to the
2871structure object and the output port. When *struct-printer* is `#f'
2872or the procedure return `#f' the structure object will be printed in
2873the boring #<struct 80458270> form.
5dade857
MV
2874
2875This hook is used by some routines in ice-9/boot-9.scm to implement
2876type specific printing routines. Please read the comments there about
2877"printing structs".
2878
2879One of the more specific uses of structs are records. The printing
2880procedure that could be passed to MAKE-RECORD-TYPE is now actually
2881called. It should behave like a *struct-printer* procedure (described
2882above).
2883
b83b8bee
JB
2884** Guile now supports a new R4RS-compliant syntax for keywords. A
2885token of the form #:NAME, where NAME has the same syntax as a Scheme
2886symbol, is the external representation of the keyword named NAME.
2887Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
2888keyword objects can be read back into Guile. When used in an
2889expression, keywords are self-quoting objects.
b83b8bee
JB
2890
2891Guile suports this read syntax, and uses this print syntax, regardless
2892of the current setting of the `keyword' read option. The `keyword'
2893read option only controls whether Guile recognizes the `:NAME' syntax,
2894which is incompatible with R4RS. (R4RS says such token represent
2895symbols.)
737c9113
JB
2896
2897** Guile has regular expression support again. Guile 1.0 included
2898functions for matching regular expressions, based on the Rx library.
2899In Guile 1.1, the Guile/Rx interface was removed to simplify the
2900distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
29011.2 again supports the most commonly used functions, and supports all
2902of SCSH's regular expression functions.
2409cdfa 2903
94982a4e
JB
2904If your system does not include a POSIX regular expression library,
2905and you have not linked Guile with a third-party regexp library such as
2906Rx, these functions will not be available. You can tell whether your
2907Guile installation includes regular expression support by checking
2908whether the `*features*' list includes the `regex' symbol.
737c9113 2909
94982a4e 2910*** regexp functions
161029df 2911
94982a4e
JB
2912By default, Guile supports POSIX extended regular expressions. That
2913means that the characters `(', `)', `+' and `?' are special, and must
2914be escaped if you wish to match the literal characters.
e1a191a8 2915
94982a4e
JB
2916This regular expression interface was modeled after that implemented
2917by SCSH, the Scheme Shell. It is intended to be upwardly compatible
2918with SCSH regular expressions.
2919
2920**** Function: string-match PATTERN STR [START]
2921 Compile the string PATTERN into a regular expression and compare
2922 it with STR. The optional numeric argument START specifies the
2923 position of STR at which to begin matching.
2924
2925 `string-match' returns a "match structure" which describes what,
2926 if anything, was matched by the regular expression. *Note Match
2927 Structures::. If STR does not match PATTERN at all,
2928 `string-match' returns `#f'.
2929
2930 Each time `string-match' is called, it must compile its PATTERN
2931argument into a regular expression structure. This operation is
2932expensive, which makes `string-match' inefficient if the same regular
2933expression is used several times (for example, in a loop). For better
2934performance, you can compile a regular expression in advance and then
2935match strings against the compiled regexp.
2936
2937**** Function: make-regexp STR [FLAGS]
2938 Compile the regular expression described by STR, and return the
2939 compiled regexp structure. If STR does not describe a legal
2940 regular expression, `make-regexp' throws a
2941 `regular-expression-syntax' error.
2942
2943 FLAGS may be the bitwise-or of one or more of the following:
2944
2945**** Constant: regexp/extended
2946 Use POSIX Extended Regular Expression syntax when interpreting
2947 STR. If not set, POSIX Basic Regular Expression syntax is used.
2948 If the FLAGS argument is omitted, we assume regexp/extended.
2949
2950**** Constant: regexp/icase
2951 Do not differentiate case. Subsequent searches using the
2952 returned regular expression will be case insensitive.
2953
2954**** Constant: regexp/newline
2955 Match-any-character operators don't match a newline.
2956
2957 A non-matching list ([^...]) not containing a newline matches a
2958 newline.
2959
2960 Match-beginning-of-line operator (^) matches the empty string
2961 immediately after a newline, regardless of whether the FLAGS
2962 passed to regexp-exec contain regexp/notbol.
2963
2964 Match-end-of-line operator ($) matches the empty string
2965 immediately before a newline, regardless of whether the FLAGS
2966 passed to regexp-exec contain regexp/noteol.
2967
2968**** Function: regexp-exec REGEXP STR [START [FLAGS]]
2969 Match the compiled regular expression REGEXP against `str'. If
2970 the optional integer START argument is provided, begin matching
2971 from that position in the string. Return a match structure
2972 describing the results of the match, or `#f' if no match could be
2973 found.
2974
2975 FLAGS may be the bitwise-or of one or more of the following:
2976
2977**** Constant: regexp/notbol
2978 The match-beginning-of-line operator always fails to match (but
2979 see the compilation flag regexp/newline above) This flag may be
2980 used when different portions of a string are passed to
2981 regexp-exec and the beginning of the string should not be
2982 interpreted as the beginning of the line.
2983
2984**** Constant: regexp/noteol
2985 The match-end-of-line operator always fails to match (but see the
2986 compilation flag regexp/newline above)
2987
2988**** Function: regexp? OBJ
2989 Return `#t' if OBJ is a compiled regular expression, or `#f'
2990 otherwise.
2991
2992 Regular expressions are commonly used to find patterns in one string
2993and replace them with the contents of another string.
2994
2995**** Function: regexp-substitute PORT MATCH [ITEM...]
2996 Write to the output port PORT selected contents of the match
2997 structure MATCH. Each ITEM specifies what should be written, and
2998 may be one of the following arguments:
2999
3000 * A string. String arguments are written out verbatim.
3001
3002 * An integer. The submatch with that number is written.
3003
3004 * The symbol `pre'. The portion of the matched string preceding
3005 the regexp match is written.
3006
3007 * The symbol `post'. The portion of the matched string
3008 following the regexp match is written.
3009
3010 PORT may be `#f', in which case nothing is written; instead,
3011 `regexp-substitute' constructs a string from the specified ITEMs
3012 and returns that.
3013
3014**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
3015 Similar to `regexp-substitute', but can be used to perform global
3016 substitutions on STR. Instead of taking a match structure as an
3017 argument, `regexp-substitute/global' takes two string arguments: a
3018 REGEXP string describing a regular expression, and a TARGET string
3019 which should be matched against this regular expression.
3020
3021 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
3022 exceptions:
3023
3024 * A function may be supplied. When this function is called, it
3025 will be passed one argument: a match structure for a given
3026 regular expression match. It should return a string to be
3027 written out to PORT.
3028
3029 * The `post' symbol causes `regexp-substitute/global' to recurse
3030 on the unmatched portion of STR. This *must* be supplied in
3031 order to perform global search-and-replace on STR; if it is
3032 not present among the ITEMs, then `regexp-substitute/global'
3033 will return after processing a single match.
3034
3035*** Match Structures
3036
3037 A "match structure" is the object returned by `string-match' and
3038`regexp-exec'. It describes which portion of a string, if any, matched
3039the given regular expression. Match structures include: a reference to
3040the string that was checked for matches; the starting and ending
3041positions of the regexp match; and, if the regexp included any
3042parenthesized subexpressions, the starting and ending positions of each
3043submatch.
3044
3045 In each of the regexp match functions described below, the `match'
3046argument must be a match structure returned by a previous call to
3047`string-match' or `regexp-exec'. Most of these functions return some
3048information about the original target string that was matched against a
3049regular expression; we will call that string TARGET for easy reference.
3050
3051**** Function: regexp-match? OBJ
3052 Return `#t' if OBJ is a match structure returned by a previous
3053 call to `regexp-exec', or `#f' otherwise.
3054
3055**** Function: match:substring MATCH [N]
3056 Return the portion of TARGET matched by subexpression number N.
3057 Submatch 0 (the default) represents the entire regexp match. If
3058 the regular expression as a whole matched, but the subexpression
3059 number N did not match, return `#f'.
3060
3061**** Function: match:start MATCH [N]
3062 Return the starting position of submatch number N.
3063
3064**** Function: match:end MATCH [N]
3065 Return the ending position of submatch number N.
3066
3067**** Function: match:prefix MATCH
3068 Return the unmatched portion of TARGET preceding the regexp match.
3069
3070**** Function: match:suffix MATCH
3071 Return the unmatched portion of TARGET following the regexp match.
3072
3073**** Function: match:count MATCH
3074 Return the number of parenthesized subexpressions from MATCH.
3075 Note that the entire regular expression match itself counts as a
3076 subexpression, and failed submatches are included in the count.
3077
3078**** Function: match:string MATCH
3079 Return the original TARGET string.
3080
3081*** Backslash Escapes
3082
3083 Sometimes you will want a regexp to match characters like `*' or `$'
3084exactly. For example, to check whether a particular string represents
3085a menu entry from an Info node, it would be useful to match it against
3086a regexp like `^* [^:]*::'. However, this won't work; because the
3087asterisk is a metacharacter, it won't match the `*' at the beginning of
3088the string. In this case, we want to make the first asterisk un-magic.
3089
3090 You can do this by preceding the metacharacter with a backslash
3091character `\'. (This is also called "quoting" the metacharacter, and
3092is known as a "backslash escape".) When Guile sees a backslash in a
3093regular expression, it considers the following glyph to be an ordinary
3094character, no matter what special meaning it would ordinarily have.
3095Therefore, we can make the above example work by changing the regexp to
3096`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
3097to match only a single asterisk in the target string.
3098
3099 Since the backslash is itself a metacharacter, you may force a
3100regexp to match a backslash in the target string by preceding the
3101backslash with itself. For example, to find variable references in a
3102TeX program, you might want to find occurrences of the string `\let\'
3103followed by any number of alphabetic characters. The regular expression
3104`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
3105each match a single backslash in the target string.
3106
3107**** Function: regexp-quote STR
3108 Quote each special character found in STR with a backslash, and
3109 return the resulting string.
3110
3111 *Very important:* Using backslash escapes in Guile source code (as
3112in Emacs Lisp or C) can be tricky, because the backslash character has
3113special meaning for the Guile reader. For example, if Guile encounters
3114the character sequence `\n' in the middle of a string while processing
3115Scheme code, it replaces those characters with a newline character.
3116Similarly, the character sequence `\t' is replaced by a horizontal tab.
3117Several of these "escape sequences" are processed by the Guile reader
3118before your code is executed. Unrecognized escape sequences are
3119ignored: if the characters `\*' appear in a string, they will be
3120translated to the single character `*'.
3121
3122 This translation is obviously undesirable for regular expressions,
3123since we want to be able to include backslashes in a string in order to
3124escape regexp metacharacters. Therefore, to make sure that a backslash
3125is preserved in a string in your Guile program, you must use *two*
3126consecutive backslashes:
3127
3128 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
3129
3130 The string in this example is preprocessed by the Guile reader before
3131any code is executed. The resulting argument to `make-regexp' is the
3132string `^\* [^:]*', which is what we really want.
3133
3134 This also means that in order to write a regular expression that
3135matches a single backslash character, the regular expression string in
3136the source code must include *four* backslashes. Each consecutive pair
3137of backslashes gets translated by the Guile reader to a single
3138backslash, and the resulting double-backslash is interpreted by the
3139regexp engine as matching a single backslash character. Hence:
3140
3141 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
3142
3143 The reason for the unwieldiness of this syntax is historical. Both
3144regular expression pattern matchers and Unix string processing systems
3145have traditionally used backslashes with the special meanings described
3146above. The POSIX regular expression specification and ANSI C standard
3147both require these semantics. Attempting to abandon either convention
3148would cause other kinds of compatibility problems, possibly more severe
3149ones. Therefore, without extending the Scheme reader to support
3150strings with different quoting conventions (an ungainly and confusing
3151extension when implemented in other languages), we must adhere to this
3152cumbersome escape syntax.
3153
7ad3c1e7
GH
3154* Changes to the gh_ interface
3155
3156* Changes to the scm_ interface
3157
3158* Changes to system call interfaces:
94982a4e 3159
7ad3c1e7 3160** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
3161if an error occurs.
3162
94982a4e 3163*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
3164
3165(sigaction signum [action] [flags])
3166
3167signum is the signal number, which can be specified using the value
3168of SIGINT etc.
3169
3170If action is omitted, sigaction returns a pair: the CAR is the current
3171signal hander, which will be either an integer with the value SIG_DFL
3172(default action) or SIG_IGN (ignore), or the Scheme procedure which
3173handles the signal, or #f if a non-Scheme procedure handles the
3174signal. The CDR contains the current sigaction flags for the handler.
3175
3176If action is provided, it is installed as the new handler for signum.
3177action can be a Scheme procedure taking one argument, or the value of
3178SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
3179whatever signal handler was installed before sigaction was first used.
3180Flags can optionally be specified for the new handler (SA_RESTART is
3181always used if the system provides it, so need not be specified.) The
3182return value is a pair with information about the old handler as
3183described above.
3184
3185This interface does not provide access to the "signal blocking"
3186facility. Maybe this is not needed, since the thread support may
3187provide solutions to the problem of consistent access to data
3188structures.
e1a191a8 3189
94982a4e 3190*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
3191`force-output' on every port open for output.
3192
94982a4e
JB
3193** Guile now provides information on how it was built, via the new
3194global variable, %guile-build-info. This variable records the values
3195of the standard GNU makefile directory variables as an assocation
3196list, mapping variable names (symbols) onto directory paths (strings).
3197For example, to find out where the Guile link libraries were
3198installed, you can say:
3199
3200guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
3201
3202
3203* Changes to the scm_ interface
3204
3205** The new function scm_handle_by_message_noexit is just like the
3206existing scm_handle_by_message function, except that it doesn't call
3207exit to terminate the process. Instead, it prints a message and just
3208returns #f. This might be a more appropriate catch-all handler for
3209new dynamic roots and threads.
3210
cf78e9e8 3211\f
c484bf7f 3212Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
3213
3214* Changes to the distribution.
3215
3216The Guile 1.0 distribution has been split up into several smaller
3217pieces:
3218guile-core --- the Guile interpreter itself.
3219guile-tcltk --- the interface between the Guile interpreter and
3220 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
3221 is a toolkit for building graphical user interfaces.
3222guile-rgx-ctax --- the interface between Guile and the Rx regular
3223 expression matcher, and the translator for the Ctax
3224 programming language. These are packaged together because the
3225 Ctax translator uses Rx to parse Ctax source code.
3226
095936d2
JB
3227This NEWS file describes the changes made to guile-core since the 1.0
3228release.
3229
48d224d7
JB
3230We no longer distribute the documentation, since it was either out of
3231date, or incomplete. As soon as we have current documentation, we
3232will distribute it.
3233
0fcab5ed
JB
3234
3235
f3b1485f
JB
3236* Changes to the stand-alone interpreter
3237
48d224d7
JB
3238** guile now accepts command-line arguments compatible with SCSH, Olin
3239Shivers' Scheme Shell.
3240
3241In general, arguments are evaluated from left to right, but there are
3242exceptions. The following switches stop argument processing, and
3243stash all remaining command-line arguments as the value returned by
3244the (command-line) function.
3245 -s SCRIPT load Scheme source code from FILE, and exit
3246 -c EXPR evalute Scheme expression EXPR, and exit
3247 -- stop scanning arguments; run interactively
3248
3249The switches below are processed as they are encountered.
3250 -l FILE load Scheme source code from FILE
3251 -e FUNCTION after reading script, apply FUNCTION to
3252 command line arguments
3253 -ds do -s script at this point
3254 --emacs enable Emacs protocol (experimental)
3255 -h, --help display this help and exit
3256 -v, --version display version information and exit
3257 \ read arguments from following script lines
3258
3259So, for example, here is a Guile script named `ekko' (thanks, Olin)
3260which re-implements the traditional "echo" command:
3261
3262#!/usr/local/bin/guile -s
3263!#
3264(define (main args)
3265 (map (lambda (arg) (display arg) (display " "))
3266 (cdr args))
3267 (newline))
3268
3269(main (command-line))
3270
3271Suppose we invoke this script as follows:
3272
3273 ekko a speckled gecko
3274
3275Through the magic of Unix script processing (triggered by the `#!'
3276token at the top of the file), /usr/local/bin/guile receives the
3277following list of command-line arguments:
3278
3279 ("-s" "./ekko" "a" "speckled" "gecko")
3280
3281Unix inserts the name of the script after the argument specified on
3282the first line of the file (in this case, "-s"), and then follows that
3283with the arguments given to the script. Guile loads the script, which
3284defines the `main' function, and then applies it to the list of
3285remaining command-line arguments, ("a" "speckled" "gecko").
3286
095936d2
JB
3287In Unix, the first line of a script file must take the following form:
3288
3289#!INTERPRETER ARGUMENT
3290
3291where INTERPRETER is the absolute filename of the interpreter
3292executable, and ARGUMENT is a single command-line argument to pass to
3293the interpreter.
3294
3295You may only pass one argument to the interpreter, and its length is
3296limited. These restrictions can be annoying to work around, so Guile
3297provides a general mechanism (borrowed from, and compatible with,
3298SCSH) for circumventing them.
3299
3300If the ARGUMENT in a Guile script is a single backslash character,
3301`\', Guile will open the script file, parse arguments from its second
3302and subsequent lines, and replace the `\' with them. So, for example,
3303here is another implementation of the `ekko' script:
3304
3305#!/usr/local/bin/guile \
3306-e main -s
3307!#
3308(define (main args)
3309 (for-each (lambda (arg) (display arg) (display " "))
3310 (cdr args))
3311 (newline))
3312
3313If the user invokes this script as follows:
3314
3315 ekko a speckled gecko
3316
3317Unix expands this into
3318
3319 /usr/local/bin/guile \ ekko a speckled gecko
3320
3321When Guile sees the `\' argument, it replaces it with the arguments
3322read from the second line of the script, producing:
3323
3324 /usr/local/bin/guile -e main -s ekko a speckled gecko
3325
3326This tells Guile to load the `ekko' script, and apply the function
3327`main' to the argument list ("a" "speckled" "gecko").
3328
3329Here is how Guile parses the command-line arguments:
3330- Each space character terminates an argument. This means that two
3331 spaces in a row introduce an empty-string argument.
3332- The tab character is not permitted (unless you quote it with the
3333 backslash character, as described below), to avoid confusion.
3334- The newline character terminates the sequence of arguments, and will
3335 also terminate a final non-empty argument. (However, a newline
3336 following a space will not introduce a final empty-string argument;
3337 it only terminates the argument list.)
3338- The backslash character is the escape character. It escapes
3339 backslash, space, tab, and newline. The ANSI C escape sequences
3340 like \n and \t are also supported. These produce argument
3341 constituents; the two-character combination \n doesn't act like a
3342 terminating newline. The escape sequence \NNN for exactly three
3343 octal digits reads as the character whose ASCII code is NNN. As
3344 above, characters produced this way are argument constituents.
3345 Backslash followed by other characters is not allowed.
3346
48d224d7
JB
3347* Changes to the procedure for linking libguile with your programs
3348
3349** Guile now builds and installs a shared guile library, if your
3350system support shared libraries. (It still builds a static library on
3351all systems.) Guile automatically detects whether your system
3352supports shared libraries. To prevent Guile from buildisg shared
3353libraries, pass the `--disable-shared' flag to the configure script.
3354
3355Guile takes longer to compile when it builds shared libraries, because
3356it must compile every file twice --- once to produce position-
3357independent object code, and once to produce normal object code.
3358
3359** The libthreads library has been merged into libguile.
3360
3361To link a program against Guile, you now need only link against
3362-lguile and -lqt; -lthreads is no longer needed. If you are using
3363autoconf to generate configuration scripts for your application, the
3364following lines should suffice to add the appropriate libraries to
3365your link command:
3366
3367### Find quickthreads and libguile.
3368AC_CHECK_LIB(qt, main)
3369AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
3370
3371* Changes to Scheme functions
3372
095936d2
JB
3373** Guile Scheme's special syntax for keyword objects is now optional,
3374and disabled by default.
3375
3376The syntax variation from R4RS made it difficult to port some
3377interesting packages to Guile. The routines which accepted keyword
3378arguments (mostly in the module system) have been modified to also
3379accept symbols whose names begin with `:'.
3380
3381To change the keyword syntax, you must first import the (ice-9 debug)
3382module:
3383 (use-modules (ice-9 debug))
3384
3385Then you can enable the keyword syntax as follows:
3386 (read-set! keywords 'prefix)
3387
3388To disable keyword syntax, do this:
3389 (read-set! keywords #f)
3390
3391** Many more primitive functions accept shared substrings as
3392arguments. In the past, these functions required normal, mutable
3393strings as arguments, although they never made use of this
3394restriction.
3395
3396** The uniform array functions now operate on byte vectors. These
3397functions are `array-fill!', `serial-array-copy!', `array-copy!',
3398`serial-array-map', `array-map', `array-for-each', and
3399`array-index-map!'.
3400
3401** The new functions `trace' and `untrace' implement simple debugging
3402support for Scheme functions.
3403
3404The `trace' function accepts any number of procedures as arguments,
3405and tells the Guile interpreter to display each procedure's name and
3406arguments each time the procedure is invoked. When invoked with no
3407arguments, `trace' returns the list of procedures currently being
3408traced.
3409
3410The `untrace' function accepts any number of procedures as arguments,
3411and tells the Guile interpreter not to trace them any more. When
3412invoked with no arguments, `untrace' untraces all curretly traced
3413procedures.
3414
3415The tracing in Guile has an advantage over most other systems: we
3416don't create new procedure objects, but mark the procedure objects
3417themselves. This means that anonymous and internal procedures can be
3418traced.
3419
3420** The function `assert-repl-prompt' has been renamed to
3421`set-repl-prompt!'. It takes one argument, PROMPT.
3422- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
3423- If PROMPT is a string, we use it as a prompt.
3424- If PROMPT is a procedure accepting no arguments, we call it, and
3425 display the result as a prompt.
3426- Otherwise, we display "> ".
3427
3428** The new function `eval-string' reads Scheme expressions from a
3429string and evaluates them, returning the value of the last expression
3430in the string. If the string contains no expressions, it returns an
3431unspecified value.
3432
3433** The new function `thunk?' returns true iff its argument is a
3434procedure of zero arguments.
3435
3436** `defined?' is now a builtin function, instead of syntax. This
3437means that its argument should be quoted. It returns #t iff its
3438argument is bound in the current module.
3439
3440** The new syntax `use-modules' allows you to add new modules to your
3441environment without re-typing a complete `define-module' form. It
3442accepts any number of module names as arguments, and imports their
3443public bindings into the current module.
3444
3445** The new function (module-defined? NAME MODULE) returns true iff
3446NAME, a symbol, is defined in MODULE, a module object.
3447
3448** The new function `builtin-bindings' creates and returns a hash
3449table containing copies of all the root module's bindings.
3450
3451** The new function `builtin-weak-bindings' does the same as
3452`builtin-bindings', but creates a doubly-weak hash table.
3453
3454** The `equal?' function now considers variable objects to be
3455equivalent if they have the same name and the same value.
3456
3457** The new function `command-line' returns the command-line arguments
3458given to Guile, as a list of strings.
3459
3460When using guile as a script interpreter, `command-line' returns the
3461script's arguments; those processed by the interpreter (like `-s' or
3462`-c') are omitted. (In other words, you get the normal, expected
3463behavior.) Any application that uses scm_shell to process its
3464command-line arguments gets this behavior as well.
3465
3466** The new function `load-user-init' looks for a file called `.guile'
3467in the user's home directory, and loads it if it exists. This is
3468mostly for use by the code generated by scm_compile_shell_switches,
3469but we thought it might also be useful in other circumstances.
3470
3471** The new function `log10' returns the base-10 logarithm of its
3472argument.
3473
3474** Changes to I/O functions
3475
3476*** The functions `read', `primitive-load', `read-and-eval!', and
3477`primitive-load-path' no longer take optional arguments controlling
3478case insensitivity and a `#' parser.
3479
3480Case sensitivity is now controlled by a read option called
3481`case-insensitive'. The user can add new `#' syntaxes with the
3482`read-hash-extend' function (see below).
3483
3484*** The new function `read-hash-extend' allows the user to change the
3485syntax of Guile Scheme in a somewhat controlled way.
3486
3487(read-hash-extend CHAR PROC)
3488 When parsing S-expressions, if we read a `#' character followed by
3489 the character CHAR, use PROC to parse an object from the stream.
3490 If PROC is #f, remove any parsing procedure registered for CHAR.
3491
3492 The reader applies PROC to two arguments: CHAR and an input port.
3493
3494*** The new functions read-delimited and read-delimited! provide a
3495general mechanism for doing delimited input on streams.
3496
3497(read-delimited DELIMS [PORT HANDLE-DELIM])
3498 Read until we encounter one of the characters in DELIMS (a string),
3499 or end-of-file. PORT is the input port to read from; it defaults to
3500 the current input port. The HANDLE-DELIM parameter determines how
3501 the terminating character is handled; it should be one of the
3502 following symbols:
3503
3504 'trim omit delimiter from result
3505 'peek leave delimiter character in input stream
3506 'concat append delimiter character to returned value
3507 'split return a pair: (RESULT . TERMINATOR)
3508
3509 HANDLE-DELIM defaults to 'peek.
3510
3511(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
3512 A side-effecting variant of `read-delimited'.
3513
3514 The data is written into the string BUF at the indices in the
3515 half-open interval [START, END); the default interval is the whole
3516 string: START = 0 and END = (string-length BUF). The values of
3517 START and END must specify a well-defined interval in BUF, i.e.
3518 0 <= START <= END <= (string-length BUF).
3519
3520 It returns NBYTES, the number of bytes read. If the buffer filled
3521 up without a delimiter character being found, it returns #f. If the
3522 port is at EOF when the read starts, it returns the EOF object.
3523
3524 If an integer is returned (i.e., the read is successfully terminated
3525 by reading a delimiter character), then the HANDLE-DELIM parameter
3526 determines how to handle the terminating character. It is described
3527 above, and defaults to 'peek.
3528
3529(The descriptions of these functions were borrowed from the SCSH
3530manual, by Olin Shivers and Brian Carlstrom.)
3531
3532*** The `%read-delimited!' function is the primitive used to implement
3533`read-delimited' and `read-delimited!'.
3534
3535(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
3536
3537This returns a pair of values: (TERMINATOR . NUM-READ).
3538- TERMINATOR describes why the read was terminated. If it is a
3539 character or the eof object, then that is the value that terminated
3540 the read. If it is #f, the function filled the buffer without finding
3541 a delimiting character.
3542- NUM-READ is the number of characters read into BUF.
3543
3544If the read is successfully terminated by reading a delimiter
3545character, then the gobble? parameter determines what to do with the
3546terminating character. If true, the character is removed from the
3547input stream; if false, the character is left in the input stream
3548where a subsequent read operation will retrieve it. In either case,
3549the character is also the first value returned by the procedure call.
3550
3551(The descriptions of this function was borrowed from the SCSH manual,
3552by Olin Shivers and Brian Carlstrom.)
3553
3554*** The `read-line' and `read-line!' functions have changed; they now
3555trim the terminator by default; previously they appended it to the
3556returned string. For the old behavior, use (read-line PORT 'concat).
3557
3558*** The functions `uniform-array-read!' and `uniform-array-write!' now
3559take new optional START and END arguments, specifying the region of
3560the array to read and write.
3561
f348c807
JB
3562*** The `ungetc-char-ready?' function has been removed. We feel it's
3563inappropriate for an interface to expose implementation details this
3564way.
095936d2
JB
3565
3566** Changes to the Unix library and system call interface
3567
3568*** The new fcntl function provides access to the Unix `fcntl' system
3569call.
3570
3571(fcntl PORT COMMAND VALUE)
3572 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
3573 Values for COMMAND are:
3574
3575 F_DUPFD duplicate a file descriptor
3576 F_GETFD read the descriptor's close-on-exec flag
3577 F_SETFD set the descriptor's close-on-exec flag to VALUE
3578 F_GETFL read the descriptor's flags, as set on open
3579 F_SETFL set the descriptor's flags, as set on open to VALUE
3580 F_GETOWN return the process ID of a socket's owner, for SIGIO
3581 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
3582 FD_CLOEXEC not sure what this is
3583
3584For details, see the documentation for the fcntl system call.
3585
3586*** The arguments to `select' have changed, for compatibility with
3587SCSH. The TIMEOUT parameter may now be non-integral, yielding the
3588expected behavior. The MILLISECONDS parameter has been changed to
3589MICROSECONDS, to more closely resemble the underlying system call.
3590The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
3591corresponding return set will be the same.
3592
3593*** The arguments to the `mknod' system call have changed. They are
3594now:
3595
3596(mknod PATH TYPE PERMS DEV)
3597 Create a new file (`node') in the file system. PATH is the name of
3598 the file to create. TYPE is the kind of file to create; it should
3599 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
3600 permission bits to give the newly created file. If TYPE is
3601 'block-special or 'char-special, DEV specifies which device the
3602 special file refers to; its interpretation depends on the kind of
3603 special file being created.
3604
3605*** The `fork' function has been renamed to `primitive-fork', to avoid
3606clashing with various SCSH forks.
3607
3608*** The `recv' and `recvfrom' functions have been renamed to `recv!'
3609and `recvfrom!'. They no longer accept a size for a second argument;
3610you must pass a string to hold the received value. They no longer
3611return the buffer. Instead, `recv' returns the length of the message
3612received, and `recvfrom' returns a pair containing the packet's length
3613and originating address.
3614
3615*** The file descriptor datatype has been removed, as have the
3616`read-fd', `write-fd', `close', `lseek', and `dup' functions.
3617We plan to replace these functions with a SCSH-compatible interface.
3618
3619*** The `create' function has been removed; it's just a special case
3620of `open'.
3621
3622*** There are new functions to break down process termination status
3623values. In the descriptions below, STATUS is a value returned by
3624`waitpid'.
3625
3626(status:exit-val STATUS)
3627 If the child process exited normally, this function returns the exit
3628 code for the child process (i.e., the value passed to exit, or
3629 returned from main). If the child process did not exit normally,
3630 this function returns #f.
3631
3632(status:stop-sig STATUS)
3633 If the child process was suspended by a signal, this function
3634 returns the signal that suspended the child. Otherwise, it returns
3635 #f.
3636
3637(status:term-sig STATUS)
3638 If the child process terminated abnormally, this function returns
3639 the signal that terminated the child. Otherwise, this function
3640 returns false.
3641
3642POSIX promises that exactly one of these functions will return true on
3643a valid STATUS value.
3644
3645These functions are compatible with SCSH.
3646
3647*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
3648returned by `localtime', `gmtime', and that ilk. They are:
3649
3650 Component Accessor Setter
3651 ========================= ============ ============
3652 seconds tm:sec set-tm:sec
3653 minutes tm:min set-tm:min
3654 hours tm:hour set-tm:hour
3655 day of the month tm:mday set-tm:mday
3656 month tm:mon set-tm:mon
3657 year tm:year set-tm:year
3658 day of the week tm:wday set-tm:wday
3659 day in the year tm:yday set-tm:yday
3660 daylight saving time tm:isdst set-tm:isdst
3661 GMT offset, seconds tm:gmtoff set-tm:gmtoff
3662 name of time zone tm:zone set-tm:zone
3663
095936d2
JB
3664*** There are new accessors for the vectors returned by `uname',
3665describing the host system:
48d224d7
JB
3666
3667 Component Accessor
3668 ============================================== ================
3669 name of the operating system implementation utsname:sysname
3670 network name of this machine utsname:nodename
3671 release level of the operating system utsname:release
3672 version level of the operating system utsname:version
3673 machine hardware platform utsname:machine
3674
095936d2
JB
3675*** There are new accessors for the vectors returned by `getpw',
3676`getpwnam', `getpwuid', and `getpwent', describing entries from the
3677system's user database:
3678
3679 Component Accessor
3680 ====================== =================
3681 user name passwd:name
3682 user password passwd:passwd
3683 user id passwd:uid
3684 group id passwd:gid
3685 real name passwd:gecos
3686 home directory passwd:dir
3687 shell program passwd:shell
3688
3689*** There are new accessors for the vectors returned by `getgr',
3690`getgrnam', `getgrgid', and `getgrent', describing entries from the
3691system's group database:
3692
3693 Component Accessor
3694 ======================= ============
3695 group name group:name
3696 group password group:passwd
3697 group id group:gid
3698 group members group:mem
3699
3700*** There are new accessors for the vectors returned by `gethost',
3701`gethostbyaddr', `gethostbyname', and `gethostent', describing
3702internet hosts:
3703
3704 Component Accessor
3705 ========================= ===============
3706 official name of host hostent:name
3707 alias list hostent:aliases
3708 host address type hostent:addrtype
3709 length of address hostent:length
3710 list of addresses hostent:addr-list
3711
3712*** There are new accessors for the vectors returned by `getnet',
3713`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
3714networks:
3715
3716 Component Accessor
3717 ========================= ===============
3718 official name of net netent:name
3719 alias list netent:aliases
3720 net number type netent:addrtype
3721 net number netent:net
3722
3723*** There are new accessors for the vectors returned by `getproto',
3724`getprotobyname', `getprotobynumber', and `getprotoent', describing
3725internet protocols:
3726
3727 Component Accessor
3728 ========================= ===============
3729 official protocol name protoent:name
3730 alias list protoent:aliases
3731 protocol number protoent:proto
3732
3733*** There are new accessors for the vectors returned by `getserv',
3734`getservbyname', `getservbyport', and `getservent', describing
3735internet protocols:
3736
3737 Component Accessor
3738 ========================= ===============
3739 official service name servent:name
3740 alias list servent:aliases
3741 port number servent:port
3742 protocol to use servent:proto
3743
3744*** There are new accessors for the sockaddr structures returned by
3745`accept', `getsockname', `getpeername', `recvfrom!':
3746
3747 Component Accessor
3748 ======================================== ===============
3749 address format (`family') sockaddr:fam
3750 path, for file domain addresses sockaddr:path
3751 address, for internet domain addresses sockaddr:addr
3752 TCP or UDP port, for internet sockaddr:port
3753
3754*** The `getpwent', `getgrent', `gethostent', `getnetent',
3755`getprotoent', and `getservent' functions now return #f at the end of
3756the user database. (They used to throw an exception.)
3757
3758Note that calling MUMBLEent function is equivalent to calling the
3759corresponding MUMBLE function with no arguments.
3760
3761*** The `setpwent', `setgrent', `sethostent', `setnetent',
3762`setprotoent', and `setservent' routines now take no arguments.
3763
3764*** The `gethost', `getproto', `getnet', and `getserv' functions now
3765provide more useful information when they throw an exception.
3766
3767*** The `lnaof' function has been renamed to `inet-lnaof'.
3768
3769*** Guile now claims to have the `current-time' feature.
3770
3771*** The `mktime' function now takes an optional second argument ZONE,
3772giving the time zone to use for the conversion. ZONE should be a
3773string, in the same format as expected for the "TZ" environment variable.
3774
3775*** The `strptime' function now returns a pair (TIME . COUNT), where
3776TIME is the parsed time as a vector, and COUNT is the number of
3777characters from the string left unparsed. This function used to
3778return the remaining characters as a string.
3779
3780*** The `gettimeofday' function has replaced the old `time+ticks' function.
3781The return value is now (SECONDS . MICROSECONDS); the fractional
3782component is no longer expressed in "ticks".
3783
3784*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 3785
ea00ecba
MG
3786* Changes to the gh_ interface
3787
3788** gh_eval_str() now returns an SCM object which is the result of the
3789evaluation
3790
aaef0d2a
MG
3791** gh_scm2str() now copies the Scheme data to a caller-provided C
3792array
3793
3794** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
3795and returns the array
3796
3797** gh_scm2str0() is gone: there is no need to distinguish
3798null-terminated from non-null-terminated, since gh_scm2newstr() allows
3799the user to interpret the data both ways.
3800
f3b1485f
JB
3801* Changes to the scm_ interface
3802
095936d2
JB
3803** The new function scm_symbol_value0 provides an easy way to get a
3804symbol's value from C code:
3805
3806SCM scm_symbol_value0 (char *NAME)
3807 Return the value of the symbol named by the null-terminated string
3808 NAME in the current module. If the symbol named NAME is unbound in
3809 the current module, return SCM_UNDEFINED.
3810
3811** The new function scm_sysintern0 creates new top-level variables,
3812without assigning them a value.
3813
3814SCM scm_sysintern0 (char *NAME)
3815 Create a new Scheme top-level variable named NAME. NAME is a
3816 null-terminated string. Return the variable's value cell.
3817
3818** The function scm_internal_catch is the guts of catch. It handles
3819all the mechanics of setting up a catch target, invoking the catch
3820body, and perhaps invoking the handler if the body does a throw.
3821
3822The function is designed to be usable from C code, but is general
3823enough to implement all the semantics Guile Scheme expects from throw.
3824
3825TAG is the catch tag. Typically, this is a symbol, but this function
3826doesn't actually care about that.
3827
3828BODY is a pointer to a C function which runs the body of the catch;
3829this is the code you can throw from. We call it like this:
3830 BODY (BODY_DATA, JMPBUF)
3831where:
3832 BODY_DATA is just the BODY_DATA argument we received; we pass it
3833 through to BODY as its first argument. The caller can make
3834 BODY_DATA point to anything useful that BODY might need.
3835 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
3836 which we have just created and initialized.
3837
3838HANDLER is a pointer to a C function to deal with a throw to TAG,
3839should one occur. We call it like this:
3840 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
3841where
3842 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
3843 same idea as BODY_DATA above.
3844 THROWN_TAG is the tag that the user threw to; usually this is
3845 TAG, but it could be something else if TAG was #t (i.e., a
3846 catch-all), or the user threw to a jmpbuf.
3847 THROW_ARGS is the list of arguments the user passed to the THROW
3848 function.
3849
3850BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
3851is just a pointer we pass through to HANDLER. We don't actually
3852use either of those pointers otherwise ourselves. The idea is
3853that, if our caller wants to communicate something to BODY or
3854HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
3855HANDLER can then use. Think of it as a way to make BODY and
3856HANDLER closures, not just functions; MUMBLE_DATA points to the
3857enclosed variables.
3858
3859Of course, it's up to the caller to make sure that any data a
3860MUMBLE_DATA needs is protected from GC. A common way to do this is
3861to make MUMBLE_DATA a pointer to data stored in an automatic
3862structure variable; since the collector must scan the stack for
3863references anyway, this assures that any references in MUMBLE_DATA
3864will be found.
3865
3866** The new function scm_internal_lazy_catch is exactly like
3867scm_internal_catch, except:
3868
3869- It does not unwind the stack (this is the major difference).
3870- If handler returns, its value is returned from the throw.
3871- BODY always receives #f as its JMPBUF argument (since there's no
3872 jmpbuf associated with a lazy catch, because we don't unwind the
3873 stack.)
3874
3875** scm_body_thunk is a new body function you can pass to
3876scm_internal_catch if you want the body to be like Scheme's `catch'
3877--- a thunk, or a function of one argument if the tag is #f.
3878
3879BODY_DATA is a pointer to a scm_body_thunk_data structure, which
3880contains the Scheme procedure to invoke as the body, and the tag
3881we're catching. If the tag is #f, then we pass JMPBUF (created by
3882scm_internal_catch) to the body procedure; otherwise, the body gets
3883no arguments.
3884
3885** scm_handle_by_proc is a new handler function you can pass to
3886scm_internal_catch if you want the handler to act like Scheme's catch
3887--- call a procedure with the tag and the throw arguments.
3888
3889If the user does a throw to this catch, this function runs a handler
3890procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
3891variable holding the Scheme procedure object to invoke. It ought to
3892be a pointer to an automatic variable (i.e., one living on the stack),
3893or the procedure object should be otherwise protected from GC.
3894
3895** scm_handle_by_message is a new handler function to use with
3896`scm_internal_catch' if you want Guile to print a message and die.
3897It's useful for dealing with throws to uncaught keys at the top level.
3898
3899HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
3900message header to print; if zero, we use "guile" instead. That
3901text is followed by a colon, then the message described by ARGS.
3902
3903** The return type of scm_boot_guile is now void; the function does
3904not return a value, and indeed, never returns at all.
3905
f3b1485f
JB
3906** The new function scm_shell makes it easy for user applications to
3907process command-line arguments in a way that is compatible with the
3908stand-alone guile interpreter (which is in turn compatible with SCSH,
3909the Scheme shell).
3910
3911To use the scm_shell function, first initialize any guile modules
3912linked into your application, and then call scm_shell with the values
7ed46dc8 3913of ARGC and ARGV your `main' function received. scm_shell will add
f3b1485f
JB
3914any SCSH-style meta-arguments from the top of the script file to the
3915argument vector, and then process the command-line arguments. This
3916generally means loading a script file or starting up an interactive
3917command interpreter. For details, see "Changes to the stand-alone
3918interpreter" above.
3919
095936d2
JB
3920** The new functions scm_get_meta_args and scm_count_argv help you
3921implement the SCSH-style meta-argument, `\'.
3922
3923char **scm_get_meta_args (int ARGC, char **ARGV)
3924 If the second element of ARGV is a string consisting of a single
3925 backslash character (i.e. "\\" in Scheme notation), open the file
3926 named by the following argument, parse arguments from it, and return
3927 the spliced command line. The returned array is terminated by a
3928 null pointer.
3929
3930 For details of argument parsing, see above, under "guile now accepts
3931 command-line arguments compatible with SCSH..."
3932
3933int scm_count_argv (char **ARGV)
3934 Count the arguments in ARGV, assuming it is terminated by a null
3935 pointer.
3936
3937For an example of how these functions might be used, see the source
3938code for the function scm_shell in libguile/script.c.
3939
3940You will usually want to use scm_shell instead of calling this
3941function yourself.
3942
3943** The new function scm_compile_shell_switches turns an array of
3944command-line arguments into Scheme code to carry out the actions they
3945describe. Given ARGC and ARGV, it returns a Scheme expression to
3946evaluate, and calls scm_set_program_arguments to make any remaining
3947command-line arguments available to the Scheme code. For example,
3948given the following arguments:
3949
3950 -e main -s ekko a speckled gecko
3951
3952scm_set_program_arguments will return the following expression:
3953
3954 (begin (load "ekko") (main (command-line)) (quit))
3955
3956You will usually want to use scm_shell instead of calling this
3957function yourself.
3958
3959** The function scm_shell_usage prints a usage message appropriate for
3960an interpreter that uses scm_compile_shell_switches to handle its
3961command-line arguments.
3962
3963void scm_shell_usage (int FATAL, char *MESSAGE)
3964 Print a usage message to the standard error output. If MESSAGE is
3965 non-zero, write it before the usage message, followed by a newline.
3966 If FATAL is non-zero, exit the process, using FATAL as the
3967 termination status. (If you want to be compatible with Guile,
3968 always use 1 as the exit status when terminating due to command-line
3969 usage problems.)
3970
3971You will usually want to use scm_shell instead of calling this
3972function yourself.
48d224d7
JB
3973
3974** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
3975expressions. It used to return SCM_EOL. Earth-shattering.
3976
3977** The macros for declaring scheme objects in C code have been
3978rearranged slightly. They are now:
3979
3980SCM_SYMBOL (C_NAME, SCHEME_NAME)
3981 Declare a static SCM variable named C_NAME, and initialize it to
3982 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
3983 be a C identifier, and SCHEME_NAME should be a C string.
3984
3985SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
3986 Just like SCM_SYMBOL, but make C_NAME globally visible.
3987
3988SCM_VCELL (C_NAME, SCHEME_NAME)
3989 Create a global variable at the Scheme level named SCHEME_NAME.
3990 Declare a static SCM variable named C_NAME, and initialize it to
3991 point to the Scheme variable's value cell.
3992
3993SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
3994 Just like SCM_VCELL, but make C_NAME globally visible.
3995
3996The `guile-snarf' script writes initialization code for these macros
3997to its standard output, given C source code as input.
3998
3999The SCM_GLOBAL macro is gone.
4000
4001** The scm_read_line and scm_read_line_x functions have been replaced
4002by Scheme code based on the %read-delimited! procedure (known to C
4003code as scm_read_delimited_x). See its description above for more
4004information.
48d224d7 4005
095936d2
JB
4006** The function scm_sys_open has been renamed to scm_open. It now
4007returns a port instead of an FD object.
ea00ecba 4008
095936d2
JB
4009* The dynamic linking support has changed. For more information, see
4010libguile/DYNAMIC-LINKING.
ea00ecba 4011
f7b47737
JB
4012\f
4013Guile 1.0b3
3065a62a 4014
f3b1485f
JB
4015User-visible changes from Thursday, September 5, 1996 until Guile 1.0
4016(Sun 5 Jan 1997):
3065a62a 4017
4b521edb 4018* Changes to the 'guile' program:
3065a62a 4019
4b521edb
JB
4020** Guile now loads some new files when it starts up. Guile first
4021searches the load path for init.scm, and loads it if found. Then, if
4022Guile is not being used to execute a script, and the user's home
4023directory contains a file named `.guile', Guile loads that.
c6486f8a 4024
4b521edb 4025** You can now use Guile as a shell script interpreter.
3065a62a
JB
4026
4027To paraphrase the SCSH manual:
4028
4029 When Unix tries to execute an executable file whose first two
4030 characters are the `#!', it treats the file not as machine code to
4031 be directly executed by the native processor, but as source code
4032 to be executed by some interpreter. The interpreter to use is
4033 specified immediately after the #! sequence on the first line of
4034 the source file. The kernel reads in the name of the interpreter,
4035 and executes that instead. It passes the interpreter the source
4036 filename as its first argument, with the original arguments
4037 following. Consult the Unix man page for the `exec' system call
4038 for more information.
4039
1a1945be
JB
4040Now you can use Guile as an interpreter, using a mechanism which is a
4041compatible subset of that provided by SCSH.
4042
3065a62a
JB
4043Guile now recognizes a '-s' command line switch, whose argument is the
4044name of a file of Scheme code to load. It also treats the two
4045characters `#!' as the start of a comment, terminated by `!#'. Thus,
4046to make a file of Scheme code directly executable by Unix, insert the
4047following two lines at the top of the file:
4048
4049#!/usr/local/bin/guile -s
4050!#
4051
4052Guile treats the argument of the `-s' command-line switch as the name
4053of a file of Scheme code to load, and treats the sequence `#!' as the
4054start of a block comment, terminated by `!#'.
4055
4056For example, here's a version of 'echo' written in Scheme:
4057
4058#!/usr/local/bin/guile -s
4059!#
4060(let loop ((args (cdr (program-arguments))))
4061 (if (pair? args)
4062 (begin
4063 (display (car args))
4064 (if (pair? (cdr args))
4065 (display " "))
4066 (loop (cdr args)))))
4067(newline)
4068
4069Why does `#!' start a block comment terminated by `!#', instead of the
4070end of the line? That is the notation SCSH uses, and although we
4071don't yet support the other SCSH features that motivate that choice,
4072we would like to be backward-compatible with any existing Guile
3763761c
JB
4073scripts once we do. Furthermore, if the path to Guile on your system
4074is too long for your kernel, you can start the script with this
4075horrible hack:
4076
4077#!/bin/sh
4078exec /really/long/path/to/guile -s "$0" ${1+"$@"}
4079!#
3065a62a
JB
4080
4081Note that some very old Unix systems don't support the `#!' syntax.
4082
c6486f8a 4083
4b521edb 4084** You can now run Guile without installing it.
6685dc83
JB
4085
4086Previous versions of the interactive Guile interpreter (`guile')
4087couldn't start up unless Guile's Scheme library had been installed;
4088they used the value of the environment variable `SCHEME_LOAD_PATH'
4089later on in the startup process, but not to find the startup code
4090itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
4091code.
4092
4093To run Guile without installing it, build it in the normal way, and
4094then set the environment variable `SCHEME_LOAD_PATH' to a
4095colon-separated list of directories, including the top-level directory
4096of the Guile sources. For example, if you unpacked Guile so that the
4097full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
4098you might say
4099
4100 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
4101
c6486f8a 4102
4b521edb
JB
4103** Guile's read-eval-print loop no longer prints #<unspecified>
4104results. If the user wants to see this, she can evaluate the
4105expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 4106file.
6685dc83 4107
4b521edb
JB
4108** Guile no longer shows backtraces by default when an error occurs;
4109however, it does display a message saying how to get one, and how to
4110request that they be displayed by default. After an error, evaluate
4111 (backtrace)
4112to see a backtrace, and
4113 (debug-enable 'backtrace)
4114to see them by default.
6685dc83 4115
6685dc83 4116
d9fb83d9 4117
4b521edb
JB
4118* Changes to Guile Scheme:
4119
4120** Guile now distinguishes between #f and the empty list.
4121
4122This is for compatibility with the IEEE standard, the (possibly)
4123upcoming Revised^5 Report on Scheme, and many extant Scheme
4124implementations.
4125
4126Guile used to have #f and '() denote the same object, to make Scheme's
4127type system more compatible with Emacs Lisp's. However, the change
4128caused too much trouble for Scheme programmers, and we found another
4129way to reconcile Emacs Lisp with Scheme that didn't require this.
4130
4131
4132** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
4133counterparts, delq!, delv!, and delete!, now remove all matching
4134elements from the list, not just the first. This matches the behavior
4135of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
4136functions which inspired them.
4137
4138I recognize that this change may break code in subtle ways, but it
4139seems best to make the change before the FSF's first Guile release,
4140rather than after.
4141
4142
4b521edb 4143** The compiled-library-path function has been deleted from libguile.
6685dc83 4144
4b521edb 4145** The facilities for loading Scheme source files have changed.
c6486f8a 4146
4b521edb 4147*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
4148for Scheme code. Its value is a list of strings, each of which names
4149a directory.
4150
4b521edb
JB
4151*** The variable %load-extensions now tells Guile which extensions to
4152try appending to a filename when searching the load path. Its value
4153is a list of strings. Its default value is ("" ".scm").
4154
4155*** (%search-load-path FILENAME) searches the directories listed in the
4156value of the %load-path variable for a Scheme file named FILENAME,
4157with all the extensions listed in %load-extensions. If it finds a
4158match, then it returns its full filename. If FILENAME is absolute, it
4159returns it unchanged. Otherwise, it returns #f.
6685dc83 4160
4b521edb
JB
4161%search-load-path will not return matches that refer to directories.
4162
4163*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
4164uses %seach-load-path to find a file named FILENAME, and loads it if
4165it finds it. If it can't read FILENAME for any reason, it throws an
4166error.
6685dc83
JB
4167
4168The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
4169`read' function.
4170
4171*** load uses the same searching semantics as primitive-load.
4172
4173*** The functions %try-load, try-load-with-path, %load, load-with-path,
4174basic-try-load-with-path, basic-load-with-path, try-load-module-with-
4175path, and load-module-with-path have been deleted. The functions
4176above should serve their purposes.
4177
4178*** If the value of the variable %load-hook is a procedure,
4179`primitive-load' applies its value to the name of the file being
4180loaded (without the load path directory name prepended). If its value
4181is #f, it is ignored. Otherwise, an error occurs.
4182
4183This is mostly useful for printing load notification messages.
4184
4185
4186** The function `eval!' is no longer accessible from the scheme level.
4187We can't allow operations which introduce glocs into the scheme level,
4188because Guile's type system can't handle these as data. Use `eval' or
4189`read-and-eval!' (see below) as replacement.
4190
4191** The new function read-and-eval! reads an expression from PORT,
4192evaluates it, and returns the result. This is more efficient than
4193simply calling `read' and `eval', since it is not necessary to make a
4194copy of the expression for the evaluator to munge.
4195
4196Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
4197for the `read' function.
4198
4199
4200** The function `int?' has been removed; its definition was identical
4201to that of `integer?'.
4202
4203** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
4204use the R4RS names for these functions.
4205
4206** The function object-properties no longer returns the hash handle;
4207it simply returns the object's property list.
4208
4209** Many functions have been changed to throw errors, instead of
4210returning #f on failure. The point of providing exception handling in
4211the language is to simplify the logic of user code, but this is less
4212useful if Guile's primitives don't throw exceptions.
4213
4214** The function `fileno' has been renamed from `%fileno'.
4215
4216** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
4217
4218
4219* Changes to Guile's C interface:
4220
4221** The library's initialization procedure has been simplified.
4222scm_boot_guile now has the prototype:
4223
4224void scm_boot_guile (int ARGC,
4225 char **ARGV,
4226 void (*main_func) (),
4227 void *closure);
4228
4229scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
4230MAIN_FUNC should do all the work of the program (initializing other
4231packages, reading user input, etc.) before returning. When MAIN_FUNC
4232returns, call exit (0); this function never returns. If you want some
4233other exit value, MAIN_FUNC may call exit itself.
4234
4235scm_boot_guile arranges for program-arguments to return the strings
4236given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
4237scm_set_program_arguments with the final list, so Scheme code will
4238know which arguments have been processed.
4239
4240scm_boot_guile establishes a catch-all catch handler which prints an
4241error message and exits the process. This means that Guile exits in a
4242coherent way when system errors occur and the user isn't prepared to
4243handle it. If the user doesn't like this behavior, they can establish
4244their own universal catcher in MAIN_FUNC to shadow this one.
4245
4246Why must the caller do all the real work from MAIN_FUNC? The garbage
4247collector assumes that all local variables of type SCM will be above
4248scm_boot_guile's stack frame on the stack. If you try to manipulate
4249SCM values after this function returns, it's the luck of the draw
4250whether the GC will be able to find the objects you allocate. So,
4251scm_boot_guile function exits, rather than returning, to discourage
4252people from making that mistake.
4253
4254The IN, OUT, and ERR arguments were removed; there are other
4255convenient ways to override these when desired.
4256
4257The RESULT argument was deleted; this function should never return.
4258
4259The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
4260general.
4261
4262
4263** Guile's header files should no longer conflict with your system's
4264header files.
4265
4266In order to compile code which #included <libguile.h>, previous
4267versions of Guile required you to add a directory containing all the
4268Guile header files to your #include path. This was a problem, since
4269Guile's header files have names which conflict with many systems'
4270header files.
4271
4272Now only <libguile.h> need appear in your #include path; you must
4273refer to all Guile's other header files as <libguile/mumble.h>.
4274Guile's installation procedure puts libguile.h in $(includedir), and
4275the rest in $(includedir)/libguile.
4276
4277
4278** Two new C functions, scm_protect_object and scm_unprotect_object,
4279have been added to the Guile library.
4280
4281scm_protect_object (OBJ) protects OBJ from the garbage collector.
4282OBJ will not be freed, even if all other references are dropped,
4283until someone does scm_unprotect_object (OBJ). Both functions
4284return OBJ.
4285
4286Note that calls to scm_protect_object do not nest. You can call
4287scm_protect_object any number of times on a given object, and the
4288next call to scm_unprotect_object will unprotect it completely.
4289
4290Basically, scm_protect_object and scm_unprotect_object just
4291maintain a list of references to things. Since the GC knows about
4292this list, all objects it mentions stay alive. scm_protect_object
4293adds its argument to the list; scm_unprotect_object remove its
4294argument from the list.
4295
4296
4297** scm_eval_0str now returns the value of the last expression
4298evaluated.
4299
4300** The new function scm_read_0str reads an s-expression from a
4301null-terminated string, and returns it.
4302
4303** The new function `scm_stdio_to_port' converts a STDIO file pointer
4304to a Scheme port object.
4305
4306** The new function `scm_set_program_arguments' allows C code to set
e80c8fea 4307the value returned by the Scheme `program-arguments' function.
6685dc83 4308
6685dc83 4309\f
1a1945be
JB
4310Older changes:
4311
4312* Guile no longer includes sophisticated Tcl/Tk support.
4313
4314The old Tcl/Tk support was unsatisfying to us, because it required the
4315user to link against the Tcl library, as well as Tk and Guile. The
4316interface was also un-lispy, in that it preserved Tcl/Tk's practice of
4317referring to widgets by names, rather than exporting widgets to Scheme
4318code as a special datatype.
4319
4320In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
4321maintainers described some very interesting changes in progress to the
4322Tcl/Tk internals, which would facilitate clean interfaces between lone
4323Tk and other interpreters --- even for garbage-collected languages
4324like Scheme. They expected the new Tk to be publicly available in the
4325fall of 1996.
4326
4327Since it seems that Guile might soon have a new, cleaner interface to
4328lone Tk, and that the old Guile/Tk glue code would probably need to be
4329completely rewritten, we (Jim Blandy and Richard Stallman) have
4330decided not to support the old code. We'll spend the time instead on
4331a good interface to the newer Tk, as soon as it is available.
5c54da76 4332
8512dea6 4333Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 4334
5c54da76
JB
4335\f
4336Copyright information:
4337
ea00ecba 4338Copyright (C) 1996,1997 Free Software Foundation, Inc.
5c54da76
JB
4339
4340 Permission is granted to anyone to make or distribute verbatim copies
4341 of this document as received, in any medium, provided that the
4342 copyright notice and this permission notice are preserved,
4343 thus giving the recipient permission to redistribute in turn.
4344
4345 Permission is granted to distribute modified versions
4346 of this document, or of portions of it,
4347 under the above conditions, provided also that they
4348 carry prominent notices stating who last changed them.
4349
48d224d7
JB
4350\f
4351Local variables:
4352mode: outline
4353paragraph-separate: "[ \f]*$"
4354end:
4355