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