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