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