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