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