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