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