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