Commit | Line | Data |
---|---|---|
f7b47737 JB |
1 | Guile NEWS --- history of user-visible changes. -*- text -*- |
2 | Copyright (C) 1996, 1997 Free Software Foundation, Inc. | |
5c54da76 JB |
3 | See the end for copying conditions. |
4 | ||
16f2ebea | 5 | Please send Guile bug reports to bug-guile@prep.ai.mit.edu. |
5c54da76 | 6 | \f |
c484bf7f JB |
7 | Changes since Guile 1.2: |
8 | ||
9 | * Changes to the distribution | |
10 | ||
11 | * Changes to the stand-alone interpreter | |
12 | ||
13 | * Changes to the procedure for linking libguile with your programs | |
14 | ||
15 | * Changes to Scheme functions and syntax | |
7ad3c1e7 | 16 | |
04c76b58 MV |
17 | ** There is now some basic support for fluids. Please read |
18 | "libguile/fluid.h" to find out more. It is accessible from Scheme with | |
19 | the following builtin procedures: | |
20 | ||
21 | (make-fluid) | |
22 | ||
23 | Create a new fluid object. | |
24 | ||
25 | (fluid-ref FLUID) | |
26 | (fluid-set! FLUID VAL) | |
27 | ||
28 | Access/modify the fluid FLUID. Modifications are only visible | |
29 | within the current dynamic root (that includes threads). | |
30 | ||
31 | There is no `fluid-let' yet. | |
32 | ||
64d01d13 GH |
33 | * Changes to system call interfaces: |
34 | ||
35 | ** close-port, close-input-port and close-output-port now return a | |
36 | boolean instead of an `unspecified' object. #t means that the port | |
37 | was successfully closed, while #f means it was already closed. It is | |
38 | also now possible for these procedures to raise an exception if an | |
39 | error occurs (some errors from write can be delayed until close.) | |
40 | ||
41 | ** The following new procedures have been added (most use scsh | |
42 | interfaces): | |
43 | ||
44 | ** close PORT/FD | |
45 | Similar to close-port, but also works on file descriptors. A side | |
46 | effect of closing a file descriptor is that any ports using that file | |
47 | descriptor are moved to a different file descriptor and have | |
48 | their revealed counts set to zero. | |
49 | ||
50 | The next five procedures perform a dup2 system call, if NEWFD (an | |
51 | integer) is supplied, otherwise a dup. The file descriptor to be | |
52 | duplicated can be supplied as an integer or wrapped in a port. The | |
53 | type of value returned varies depending on which procedure is used. | |
54 | ||
55 | All procedures also have the side effect when performing dup2 that any | |
56 | ports using NEWFD are moved to a different file descriptor and have | |
57 | their revealed counts set to zero. | |
58 | ||
59 | ** dup->fdes PORT/FD [NEWFD] | |
60 | Returns an integer file descriptor. | |
61 | ||
62 | ** dup->inport PORT/FD [NEWFD] | |
63 | Returns a new input port using the new file descriptor. | |
64 | ||
65 | ** dup->outport PORT/FD [NEWFD] | |
66 | Returns a new output port using the new file descriptor. | |
67 | ||
68 | ** dup PORT/FD [NEWFD] | |
69 | Returns a new port if PORT/FD is a port, with the same mode as the | |
70 | supplied port, otherwise returns an integer file descriptor. | |
71 | ||
72 | ** dup->port PORT/FD MODE [NEWFD] | |
73 | Returns a new port using the new file descriptor. MODE supplies a | |
74 | mode string for the port (as for `open-file'). | |
75 | ||
76 | ** primitive-dup PORT/FD | |
77 | Performs a dup system call on the file descriptor FD, or the file | |
78 | descriptor underlying PORT and returns a new integer file descriptor. | |
79 | ||
80 | ** primitive-dup2 PORT/FD NEWFD | |
81 | ||
82 | Performs a dup2 system call on the file descriptor FD, or the file | |
83 | descriptor underlying PORT, using NEWFD (an integer) as the target | |
84 | file descriptor. Any ports using NEWFD are moved to a different file | |
85 | descriptor and have their revealed counts set to zero. The value | |
86 | returned is NEWFD. | |
87 | ||
88 | ** port->fdes PORT | |
89 | Returns the integer file descriptor underlying PORT. As a | |
90 | side effect the revealed count of PORT is incremented. | |
91 | ||
92 | ** fdes->inport FDES | |
93 | Returns an existing input port which has FDES as its underlying file | |
94 | descriptor, if one exists, and increments its revealed count. | |
95 | Otherwise, returns a new input port with a revealed count of 1. | |
96 | ||
97 | ** fdes->outport FDES | |
98 | Returns an existing output port which has FDES as its underlying file | |
99 | descriptor, if one exists, and increments its revealed count. | |
100 | Otherwise, returns a new output port with a revealed count of 1. | |
101 | ||
956055a9 GH |
102 | ** setenv [NAME] [VALUE] |
103 | If VALUE is `#f', removes NAME from the environment. Otherwise | |
104 | adds the string NAME=VALUE to the environment, replacing any previous | |
105 | value for NAME. | |
106 | ||
64d01d13 GH |
107 | ** primitive-exit [STATUS] |
108 | Terminates the current process without unwinding the Scheme stack. | |
109 | This would usually be used after a fork. | |
7ad3c1e7 | 110 | |
c484bf7f JB |
111 | * Changes to the gh_ interface |
112 | ||
113 | * Changes to the scm_ interface | |
114 | ||
115 | \f | |
116 | Changes in Guile 1.2 (released Tuesday, June 24 1997): | |
cf78e9e8 | 117 | |
737c9113 JB |
118 | * Changes to the distribution |
119 | ||
832b09ed JB |
120 | ** Nightly snapshots are now available from ftp.red-bean.com. |
121 | The old server, ftp.cyclic.com, has been relinquished to its rightful | |
122 | owner. | |
123 | ||
124 | Nightly snapshots of the Guile development sources are now available via | |
125 | anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz. | |
126 | ||
127 | Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz | |
128 | For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz | |
129 | ||
0fcab5ed JB |
130 | ** To run Guile without installing it, the procedure has changed a bit. |
131 | ||
132 | If you used a separate build directory to compile Guile, you'll need | |
133 | to include the build directory in SCHEME_LOAD_PATH, as well as the | |
134 | source directory. See the `INSTALL' file for examples. | |
135 | ||
737c9113 JB |
136 | * Changes to the procedure for linking libguile with your programs |
137 | ||
94982a4e JB |
138 | ** The standard Guile load path for Scheme code now includes |
139 | $(datadir)/guile (usually /usr/local/share/guile). This means that | |
140 | you can install your own Scheme files there, and Guile will find them. | |
141 | (Previous versions of Guile only checked a directory whose name | |
142 | contained the Guile version number, so you had to re-install or move | |
143 | your Scheme sources each time you installed a fresh version of Guile.) | |
144 | ||
145 | The load path also includes $(datadir)/guile/site; we recommend | |
146 | putting individual Scheme files there. If you want to install a | |
147 | package with multiple source files, create a directory for them under | |
148 | $(datadir)/guile. | |
149 | ||
150 | ** Guile 1.2 will now use the Rx regular expression library, if it is | |
151 | installed on your system. When you are linking libguile into your own | |
152 | programs, this means you will have to link against -lguile, -lqt (if | |
153 | you configured Guile with thread support), and -lrx. | |
27590f82 JB |
154 | |
155 | If you are using autoconf to generate configuration scripts for your | |
156 | application, the following lines should suffice to add the appropriate | |
157 | libraries to your link command: | |
158 | ||
159 | ### Find Rx, quickthreads and libguile. | |
160 | AC_CHECK_LIB(rx, main) | |
161 | AC_CHECK_LIB(qt, main) | |
162 | AC_CHECK_LIB(guile, scm_shell) | |
163 | ||
94982a4e JB |
164 | The Guile 1.2 distribution does not contain sources for the Rx |
165 | library, as Guile 1.0 did. If you want to use Rx, you'll need to | |
166 | retrieve it from a GNU FTP site and install it separately. | |
167 | ||
b83b8bee JB |
168 | * Changes to Scheme functions and syntax |
169 | ||
e035e7e6 MV |
170 | ** The dynamic linking features of Guile are now enabled by default. |
171 | You can disable them by giving the `--disable-dynamic-linking' option | |
172 | to configure. | |
173 | ||
e035e7e6 MV |
174 | (dynamic-link FILENAME) |
175 | ||
176 | Find the object file denoted by FILENAME (a string) and link it | |
177 | into the running Guile application. When everything works out, | |
178 | return a Scheme object suitable for representing the linked object | |
179 | file. Otherwise an error is thrown. How object files are | |
180 | searched is system dependent. | |
181 | ||
182 | (dynamic-object? VAL) | |
183 | ||
184 | Determine whether VAL represents a dynamically linked object file. | |
185 | ||
186 | (dynamic-unlink DYNOBJ) | |
187 | ||
188 | Unlink the indicated object file from the application. DYNOBJ | |
189 | should be one of the values returned by `dynamic-link'. | |
190 | ||
191 | (dynamic-func FUNCTION DYNOBJ) | |
192 | ||
193 | Search the C function indicated by FUNCTION (a string or symbol) | |
194 | in DYNOBJ and return some Scheme object that can later be used | |
195 | with `dynamic-call' to actually call this function. Right now, | |
196 | these Scheme objects are formed by casting the address of the | |
197 | function to `long' and converting this number to its Scheme | |
198 | representation. | |
199 | ||
200 | (dynamic-call FUNCTION DYNOBJ) | |
201 | ||
202 | Call the C function indicated by FUNCTION and DYNOBJ. The | |
203 | function is passed no arguments and its return value is ignored. | |
204 | When FUNCTION is something returned by `dynamic-func', call that | |
205 | function and ignore DYNOBJ. When FUNCTION is a string (or symbol, | |
206 | etc.), look it up in DYNOBJ; this is equivalent to | |
207 | ||
208 | (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f) | |
209 | ||
210 | Interrupts are deferred while the C function is executing (with | |
211 | SCM_DEFER_INTS/SCM_ALLOW_INTS). | |
212 | ||
213 | (dynamic-args-call FUNCTION DYNOBJ ARGS) | |
214 | ||
215 | Call the C function indicated by FUNCTION and DYNOBJ, but pass it | |
216 | some arguments and return its return value. The C function is | |
217 | expected to take two arguments and return an `int', just like | |
218 | `main': | |
219 | ||
220 | int c_func (int argc, char **argv); | |
221 | ||
222 | ARGS must be a list of strings and is converted into an array of | |
223 | `char *'. The array is passed in ARGV and its size in ARGC. The | |
224 | return value is converted to a Scheme number and returned from the | |
225 | call to `dynamic-args-call'. | |
226 | ||
0fcab5ed JB |
227 | When dynamic linking is disabled or not supported on your system, |
228 | the above functions throw errors, but they are still available. | |
229 | ||
e035e7e6 MV |
230 | Here is a small example that works on GNU/Linux: |
231 | ||
232 | (define libc-obj (dynamic-link "libc.so")) | |
233 | (dynamic-args-call 'rand libc-obj '()) | |
234 | ||
235 | See the file `libguile/DYNAMIC-LINKING' for additional comments. | |
236 | ||
27590f82 JB |
237 | ** The #/ syntax for module names is depreciated, and will be removed |
238 | in a future version of Guile. Instead of | |
239 | ||
240 | #/foo/bar/baz | |
241 | ||
242 | instead write | |
243 | ||
244 | (foo bar baz) | |
245 | ||
246 | The latter syntax is more consistent with existing Lisp practice. | |
247 | ||
5dade857 MV |
248 | ** Guile now does fancier printing of structures. Structures are the |
249 | underlying implementation for records, which in turn are used to | |
250 | implement modules, so all of these object now print differently and in | |
251 | a more informative way. | |
252 | ||
161029df JB |
253 | The Scheme printer will examine the builtin variable *struct-printer* |
254 | whenever it needs to print a structure object. When this variable is | |
255 | not `#f' it is deemed to be a procedure and will be applied to the | |
256 | structure object and the output port. When *struct-printer* is `#f' | |
257 | or the procedure return `#f' the structure object will be printed in | |
258 | the boring #<struct 80458270> form. | |
5dade857 MV |
259 | |
260 | This hook is used by some routines in ice-9/boot-9.scm to implement | |
261 | type specific printing routines. Please read the comments there about | |
262 | "printing structs". | |
263 | ||
264 | One of the more specific uses of structs are records. The printing | |
265 | procedure that could be passed to MAKE-RECORD-TYPE is now actually | |
266 | called. It should behave like a *struct-printer* procedure (described | |
267 | above). | |
268 | ||
b83b8bee JB |
269 | ** Guile now supports a new R4RS-compliant syntax for keywords. A |
270 | token of the form #:NAME, where NAME has the same syntax as a Scheme | |
271 | symbol, is the external representation of the keyword named NAME. | |
272 | Keyword objects print using this syntax as well, so values containing | |
1e5afba0 JB |
273 | keyword objects can be read back into Guile. When used in an |
274 | expression, keywords are self-quoting objects. | |
b83b8bee JB |
275 | |
276 | Guile suports this read syntax, and uses this print syntax, regardless | |
277 | of the current setting of the `keyword' read option. The `keyword' | |
278 | read option only controls whether Guile recognizes the `:NAME' syntax, | |
279 | which is incompatible with R4RS. (R4RS says such token represent | |
280 | symbols.) | |
737c9113 JB |
281 | |
282 | ** Guile has regular expression support again. Guile 1.0 included | |
283 | functions for matching regular expressions, based on the Rx library. | |
284 | In Guile 1.1, the Guile/Rx interface was removed to simplify the | |
285 | distribution, and thus Guile had no regular expression support. Guile | |
94982a4e JB |
286 | 1.2 again supports the most commonly used functions, and supports all |
287 | of SCSH's regular expression functions. | |
2409cdfa | 288 | |
94982a4e JB |
289 | If your system does not include a POSIX regular expression library, |
290 | and you have not linked Guile with a third-party regexp library such as | |
291 | Rx, these functions will not be available. You can tell whether your | |
292 | Guile installation includes regular expression support by checking | |
293 | whether the `*features*' list includes the `regex' symbol. | |
737c9113 | 294 | |
94982a4e | 295 | *** regexp functions |
161029df | 296 | |
94982a4e JB |
297 | By default, Guile supports POSIX extended regular expressions. That |
298 | means that the characters `(', `)', `+' and `?' are special, and must | |
299 | be escaped if you wish to match the literal characters. | |
e1a191a8 | 300 | |
94982a4e JB |
301 | This regular expression interface was modeled after that implemented |
302 | by SCSH, the Scheme Shell. It is intended to be upwardly compatible | |
303 | with SCSH regular expressions. | |
304 | ||
305 | **** Function: string-match PATTERN STR [START] | |
306 | Compile the string PATTERN into a regular expression and compare | |
307 | it with STR. The optional numeric argument START specifies the | |
308 | position of STR at which to begin matching. | |
309 | ||
310 | `string-match' returns a "match structure" which describes what, | |
311 | if anything, was matched by the regular expression. *Note Match | |
312 | Structures::. If STR does not match PATTERN at all, | |
313 | `string-match' returns `#f'. | |
314 | ||
315 | Each time `string-match' is called, it must compile its PATTERN | |
316 | argument into a regular expression structure. This operation is | |
317 | expensive, which makes `string-match' inefficient if the same regular | |
318 | expression is used several times (for example, in a loop). For better | |
319 | performance, you can compile a regular expression in advance and then | |
320 | match strings against the compiled regexp. | |
321 | ||
322 | **** Function: make-regexp STR [FLAGS] | |
323 | Compile the regular expression described by STR, and return the | |
324 | compiled regexp structure. If STR does not describe a legal | |
325 | regular expression, `make-regexp' throws a | |
326 | `regular-expression-syntax' error. | |
327 | ||
328 | FLAGS may be the bitwise-or of one or more of the following: | |
329 | ||
330 | **** Constant: regexp/extended | |
331 | Use POSIX Extended Regular Expression syntax when interpreting | |
332 | STR. If not set, POSIX Basic Regular Expression syntax is used. | |
333 | If the FLAGS argument is omitted, we assume regexp/extended. | |
334 | ||
335 | **** Constant: regexp/icase | |
336 | Do not differentiate case. Subsequent searches using the | |
337 | returned regular expression will be case insensitive. | |
338 | ||
339 | **** Constant: regexp/newline | |
340 | Match-any-character operators don't match a newline. | |
341 | ||
342 | A non-matching list ([^...]) not containing a newline matches a | |
343 | newline. | |
344 | ||
345 | Match-beginning-of-line operator (^) matches the empty string | |
346 | immediately after a newline, regardless of whether the FLAGS | |
347 | passed to regexp-exec contain regexp/notbol. | |
348 | ||
349 | Match-end-of-line operator ($) matches the empty string | |
350 | immediately before a newline, regardless of whether the FLAGS | |
351 | passed to regexp-exec contain regexp/noteol. | |
352 | ||
353 | **** Function: regexp-exec REGEXP STR [START [FLAGS]] | |
354 | Match the compiled regular expression REGEXP against `str'. If | |
355 | the optional integer START argument is provided, begin matching | |
356 | from that position in the string. Return a match structure | |
357 | describing the results of the match, or `#f' if no match could be | |
358 | found. | |
359 | ||
360 | FLAGS may be the bitwise-or of one or more of the following: | |
361 | ||
362 | **** Constant: regexp/notbol | |
363 | The match-beginning-of-line operator always fails to match (but | |
364 | see the compilation flag regexp/newline above) This flag may be | |
365 | used when different portions of a string are passed to | |
366 | regexp-exec and the beginning of the string should not be | |
367 | interpreted as the beginning of the line. | |
368 | ||
369 | **** Constant: regexp/noteol | |
370 | The match-end-of-line operator always fails to match (but see the | |
371 | compilation flag regexp/newline above) | |
372 | ||
373 | **** Function: regexp? OBJ | |
374 | Return `#t' if OBJ is a compiled regular expression, or `#f' | |
375 | otherwise. | |
376 | ||
377 | Regular expressions are commonly used to find patterns in one string | |
378 | and replace them with the contents of another string. | |
379 | ||
380 | **** Function: regexp-substitute PORT MATCH [ITEM...] | |
381 | Write to the output port PORT selected contents of the match | |
382 | structure MATCH. Each ITEM specifies what should be written, and | |
383 | may be one of the following arguments: | |
384 | ||
385 | * A string. String arguments are written out verbatim. | |
386 | ||
387 | * An integer. The submatch with that number is written. | |
388 | ||
389 | * The symbol `pre'. The portion of the matched string preceding | |
390 | the regexp match is written. | |
391 | ||
392 | * The symbol `post'. The portion of the matched string | |
393 | following the regexp match is written. | |
394 | ||
395 | PORT may be `#f', in which case nothing is written; instead, | |
396 | `regexp-substitute' constructs a string from the specified ITEMs | |
397 | and returns that. | |
398 | ||
399 | **** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...] | |
400 | Similar to `regexp-substitute', but can be used to perform global | |
401 | substitutions on STR. Instead of taking a match structure as an | |
402 | argument, `regexp-substitute/global' takes two string arguments: a | |
403 | REGEXP string describing a regular expression, and a TARGET string | |
404 | which should be matched against this regular expression. | |
405 | ||
406 | Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following | |
407 | exceptions: | |
408 | ||
409 | * A function may be supplied. When this function is called, it | |
410 | will be passed one argument: a match structure for a given | |
411 | regular expression match. It should return a string to be | |
412 | written out to PORT. | |
413 | ||
414 | * The `post' symbol causes `regexp-substitute/global' to recurse | |
415 | on the unmatched portion of STR. This *must* be supplied in | |
416 | order to perform global search-and-replace on STR; if it is | |
417 | not present among the ITEMs, then `regexp-substitute/global' | |
418 | will return after processing a single match. | |
419 | ||
420 | *** Match Structures | |
421 | ||
422 | A "match structure" is the object returned by `string-match' and | |
423 | `regexp-exec'. It describes which portion of a string, if any, matched | |
424 | the given regular expression. Match structures include: a reference to | |
425 | the string that was checked for matches; the starting and ending | |
426 | positions of the regexp match; and, if the regexp included any | |
427 | parenthesized subexpressions, the starting and ending positions of each | |
428 | submatch. | |
429 | ||
430 | In each of the regexp match functions described below, the `match' | |
431 | argument must be a match structure returned by a previous call to | |
432 | `string-match' or `regexp-exec'. Most of these functions return some | |
433 | information about the original target string that was matched against a | |
434 | regular expression; we will call that string TARGET for easy reference. | |
435 | ||
436 | **** Function: regexp-match? OBJ | |
437 | Return `#t' if OBJ is a match structure returned by a previous | |
438 | call to `regexp-exec', or `#f' otherwise. | |
439 | ||
440 | **** Function: match:substring MATCH [N] | |
441 | Return the portion of TARGET matched by subexpression number N. | |
442 | Submatch 0 (the default) represents the entire regexp match. If | |
443 | the regular expression as a whole matched, but the subexpression | |
444 | number N did not match, return `#f'. | |
445 | ||
446 | **** Function: match:start MATCH [N] | |
447 | Return the starting position of submatch number N. | |
448 | ||
449 | **** Function: match:end MATCH [N] | |
450 | Return the ending position of submatch number N. | |
451 | ||
452 | **** Function: match:prefix MATCH | |
453 | Return the unmatched portion of TARGET preceding the regexp match. | |
454 | ||
455 | **** Function: match:suffix MATCH | |
456 | Return the unmatched portion of TARGET following the regexp match. | |
457 | ||
458 | **** Function: match:count MATCH | |
459 | Return the number of parenthesized subexpressions from MATCH. | |
460 | Note that the entire regular expression match itself counts as a | |
461 | subexpression, and failed submatches are included in the count. | |
462 | ||
463 | **** Function: match:string MATCH | |
464 | Return the original TARGET string. | |
465 | ||
466 | *** Backslash Escapes | |
467 | ||
468 | Sometimes you will want a regexp to match characters like `*' or `$' | |
469 | exactly. For example, to check whether a particular string represents | |
470 | a menu entry from an Info node, it would be useful to match it against | |
471 | a regexp like `^* [^:]*::'. However, this won't work; because the | |
472 | asterisk is a metacharacter, it won't match the `*' at the beginning of | |
473 | the string. In this case, we want to make the first asterisk un-magic. | |
474 | ||
475 | You can do this by preceding the metacharacter with a backslash | |
476 | character `\'. (This is also called "quoting" the metacharacter, and | |
477 | is known as a "backslash escape".) When Guile sees a backslash in a | |
478 | regular expression, it considers the following glyph to be an ordinary | |
479 | character, no matter what special meaning it would ordinarily have. | |
480 | Therefore, we can make the above example work by changing the regexp to | |
481 | `^\* [^:]*::'. The `\*' sequence tells the regular expression engine | |
482 | to match only a single asterisk in the target string. | |
483 | ||
484 | Since the backslash is itself a metacharacter, you may force a | |
485 | regexp to match a backslash in the target string by preceding the | |
486 | backslash with itself. For example, to find variable references in a | |
487 | TeX program, you might want to find occurrences of the string `\let\' | |
488 | followed by any number of alphabetic characters. The regular expression | |
489 | `\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp | |
490 | each match a single backslash in the target string. | |
491 | ||
492 | **** Function: regexp-quote STR | |
493 | Quote each special character found in STR with a backslash, and | |
494 | return the resulting string. | |
495 | ||
496 | *Very important:* Using backslash escapes in Guile source code (as | |
497 | in Emacs Lisp or C) can be tricky, because the backslash character has | |
498 | special meaning for the Guile reader. For example, if Guile encounters | |
499 | the character sequence `\n' in the middle of a string while processing | |
500 | Scheme code, it replaces those characters with a newline character. | |
501 | Similarly, the character sequence `\t' is replaced by a horizontal tab. | |
502 | Several of these "escape sequences" are processed by the Guile reader | |
503 | before your code is executed. Unrecognized escape sequences are | |
504 | ignored: if the characters `\*' appear in a string, they will be | |
505 | translated to the single character `*'. | |
506 | ||
507 | This translation is obviously undesirable for regular expressions, | |
508 | since we want to be able to include backslashes in a string in order to | |
509 | escape regexp metacharacters. Therefore, to make sure that a backslash | |
510 | is preserved in a string in your Guile program, you must use *two* | |
511 | consecutive backslashes: | |
512 | ||
513 | (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*")) | |
514 | ||
515 | The string in this example is preprocessed by the Guile reader before | |
516 | any code is executed. The resulting argument to `make-regexp' is the | |
517 | string `^\* [^:]*', which is what we really want. | |
518 | ||
519 | This also means that in order to write a regular expression that | |
520 | matches a single backslash character, the regular expression string in | |
521 | the source code must include *four* backslashes. Each consecutive pair | |
522 | of backslashes gets translated by the Guile reader to a single | |
523 | backslash, and the resulting double-backslash is interpreted by the | |
524 | regexp engine as matching a single backslash character. Hence: | |
525 | ||
526 | (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*")) | |
527 | ||
528 | The reason for the unwieldiness of this syntax is historical. Both | |
529 | regular expression pattern matchers and Unix string processing systems | |
530 | have traditionally used backslashes with the special meanings described | |
531 | above. The POSIX regular expression specification and ANSI C standard | |
532 | both require these semantics. Attempting to abandon either convention | |
533 | would cause other kinds of compatibility problems, possibly more severe | |
534 | ones. Therefore, without extending the Scheme reader to support | |
535 | strings with different quoting conventions (an ungainly and confusing | |
536 | extension when implemented in other languages), we must adhere to this | |
537 | cumbersome escape syntax. | |
538 | ||
7ad3c1e7 GH |
539 | * Changes to the gh_ interface |
540 | ||
541 | * Changes to the scm_ interface | |
542 | ||
543 | * Changes to system call interfaces: | |
94982a4e | 544 | |
7ad3c1e7 | 545 | ** The value returned by `raise' is now unspecified. It throws an exception |
e1a191a8 GH |
546 | if an error occurs. |
547 | ||
94982a4e | 548 | *** A new procedure `sigaction' can be used to install signal handlers |
115b09a5 GH |
549 | |
550 | (sigaction signum [action] [flags]) | |
551 | ||
552 | signum is the signal number, which can be specified using the value | |
553 | of SIGINT etc. | |
554 | ||
555 | If action is omitted, sigaction returns a pair: the CAR is the current | |
556 | signal hander, which will be either an integer with the value SIG_DFL | |
557 | (default action) or SIG_IGN (ignore), or the Scheme procedure which | |
558 | handles the signal, or #f if a non-Scheme procedure handles the | |
559 | signal. The CDR contains the current sigaction flags for the handler. | |
560 | ||
561 | If action is provided, it is installed as the new handler for signum. | |
562 | action can be a Scheme procedure taking one argument, or the value of | |
563 | SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore | |
564 | whatever signal handler was installed before sigaction was first used. | |
565 | Flags can optionally be specified for the new handler (SA_RESTART is | |
566 | always used if the system provides it, so need not be specified.) The | |
567 | return value is a pair with information about the old handler as | |
568 | described above. | |
569 | ||
570 | This interface does not provide access to the "signal blocking" | |
571 | facility. Maybe this is not needed, since the thread support may | |
572 | provide solutions to the problem of consistent access to data | |
573 | structures. | |
e1a191a8 | 574 | |
94982a4e | 575 | *** A new procedure `flush-all-ports' is equivalent to running |
89ea5b7c GH |
576 | `force-output' on every port open for output. |
577 | ||
94982a4e JB |
578 | ** Guile now provides information on how it was built, via the new |
579 | global variable, %guile-build-info. This variable records the values | |
580 | of the standard GNU makefile directory variables as an assocation | |
581 | list, mapping variable names (symbols) onto directory paths (strings). | |
582 | For example, to find out where the Guile link libraries were | |
583 | installed, you can say: | |
584 | ||
585 | guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)" | |
586 | ||
587 | ||
588 | * Changes to the scm_ interface | |
589 | ||
590 | ** The new function scm_handle_by_message_noexit is just like the | |
591 | existing scm_handle_by_message function, except that it doesn't call | |
592 | exit to terminate the process. Instead, it prints a message and just | |
593 | returns #f. This might be a more appropriate catch-all handler for | |
594 | new dynamic roots and threads. | |
595 | ||
cf78e9e8 | 596 | \f |
c484bf7f | 597 | Changes in Guile 1.1 (released Friday, May 16 1997): |
f3b1485f JB |
598 | |
599 | * Changes to the distribution. | |
600 | ||
601 | The Guile 1.0 distribution has been split up into several smaller | |
602 | pieces: | |
603 | guile-core --- the Guile interpreter itself. | |
604 | guile-tcltk --- the interface between the Guile interpreter and | |
605 | Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk | |
606 | is a toolkit for building graphical user interfaces. | |
607 | guile-rgx-ctax --- the interface between Guile and the Rx regular | |
608 | expression matcher, and the translator for the Ctax | |
609 | programming language. These are packaged together because the | |
610 | Ctax translator uses Rx to parse Ctax source code. | |
611 | ||
095936d2 JB |
612 | This NEWS file describes the changes made to guile-core since the 1.0 |
613 | release. | |
614 | ||
48d224d7 JB |
615 | We no longer distribute the documentation, since it was either out of |
616 | date, or incomplete. As soon as we have current documentation, we | |
617 | will distribute it. | |
618 | ||
0fcab5ed JB |
619 | |
620 | ||
f3b1485f JB |
621 | * Changes to the stand-alone interpreter |
622 | ||
48d224d7 JB |
623 | ** guile now accepts command-line arguments compatible with SCSH, Olin |
624 | Shivers' Scheme Shell. | |
625 | ||
626 | In general, arguments are evaluated from left to right, but there are | |
627 | exceptions. The following switches stop argument processing, and | |
628 | stash all remaining command-line arguments as the value returned by | |
629 | the (command-line) function. | |
630 | -s SCRIPT load Scheme source code from FILE, and exit | |
631 | -c EXPR evalute Scheme expression EXPR, and exit | |
632 | -- stop scanning arguments; run interactively | |
633 | ||
634 | The switches below are processed as they are encountered. | |
635 | -l FILE load Scheme source code from FILE | |
636 | -e FUNCTION after reading script, apply FUNCTION to | |
637 | command line arguments | |
638 | -ds do -s script at this point | |
639 | --emacs enable Emacs protocol (experimental) | |
640 | -h, --help display this help and exit | |
641 | -v, --version display version information and exit | |
642 | \ read arguments from following script lines | |
643 | ||
644 | So, for example, here is a Guile script named `ekko' (thanks, Olin) | |
645 | which re-implements the traditional "echo" command: | |
646 | ||
647 | #!/usr/local/bin/guile -s | |
648 | !# | |
649 | (define (main args) | |
650 | (map (lambda (arg) (display arg) (display " ")) | |
651 | (cdr args)) | |
652 | (newline)) | |
653 | ||
654 | (main (command-line)) | |
655 | ||
656 | Suppose we invoke this script as follows: | |
657 | ||
658 | ekko a speckled gecko | |
659 | ||
660 | Through the magic of Unix script processing (triggered by the `#!' | |
661 | token at the top of the file), /usr/local/bin/guile receives the | |
662 | following list of command-line arguments: | |
663 | ||
664 | ("-s" "./ekko" "a" "speckled" "gecko") | |
665 | ||
666 | Unix inserts the name of the script after the argument specified on | |
667 | the first line of the file (in this case, "-s"), and then follows that | |
668 | with the arguments given to the script. Guile loads the script, which | |
669 | defines the `main' function, and then applies it to the list of | |
670 | remaining command-line arguments, ("a" "speckled" "gecko"). | |
671 | ||
095936d2 JB |
672 | In Unix, the first line of a script file must take the following form: |
673 | ||
674 | #!INTERPRETER ARGUMENT | |
675 | ||
676 | where INTERPRETER is the absolute filename of the interpreter | |
677 | executable, and ARGUMENT is a single command-line argument to pass to | |
678 | the interpreter. | |
679 | ||
680 | You may only pass one argument to the interpreter, and its length is | |
681 | limited. These restrictions can be annoying to work around, so Guile | |
682 | provides a general mechanism (borrowed from, and compatible with, | |
683 | SCSH) for circumventing them. | |
684 | ||
685 | If the ARGUMENT in a Guile script is a single backslash character, | |
686 | `\', Guile will open the script file, parse arguments from its second | |
687 | and subsequent lines, and replace the `\' with them. So, for example, | |
688 | here is another implementation of the `ekko' script: | |
689 | ||
690 | #!/usr/local/bin/guile \ | |
691 | -e main -s | |
692 | !# | |
693 | (define (main args) | |
694 | (for-each (lambda (arg) (display arg) (display " ")) | |
695 | (cdr args)) | |
696 | (newline)) | |
697 | ||
698 | If the user invokes this script as follows: | |
699 | ||
700 | ekko a speckled gecko | |
701 | ||
702 | Unix expands this into | |
703 | ||
704 | /usr/local/bin/guile \ ekko a speckled gecko | |
705 | ||
706 | When Guile sees the `\' argument, it replaces it with the arguments | |
707 | read from the second line of the script, producing: | |
708 | ||
709 | /usr/local/bin/guile -e main -s ekko a speckled gecko | |
710 | ||
711 | This tells Guile to load the `ekko' script, and apply the function | |
712 | `main' to the argument list ("a" "speckled" "gecko"). | |
713 | ||
714 | Here is how Guile parses the command-line arguments: | |
715 | - Each space character terminates an argument. This means that two | |
716 | spaces in a row introduce an empty-string argument. | |
717 | - The tab character is not permitted (unless you quote it with the | |
718 | backslash character, as described below), to avoid confusion. | |
719 | - The newline character terminates the sequence of arguments, and will | |
720 | also terminate a final non-empty argument. (However, a newline | |
721 | following a space will not introduce a final empty-string argument; | |
722 | it only terminates the argument list.) | |
723 | - The backslash character is the escape character. It escapes | |
724 | backslash, space, tab, and newline. The ANSI C escape sequences | |
725 | like \n and \t are also supported. These produce argument | |
726 | constituents; the two-character combination \n doesn't act like a | |
727 | terminating newline. The escape sequence \NNN for exactly three | |
728 | octal digits reads as the character whose ASCII code is NNN. As | |
729 | above, characters produced this way are argument constituents. | |
730 | Backslash followed by other characters is not allowed. | |
731 | ||
48d224d7 JB |
732 | * Changes to the procedure for linking libguile with your programs |
733 | ||
734 | ** Guile now builds and installs a shared guile library, if your | |
735 | system support shared libraries. (It still builds a static library on | |
736 | all systems.) Guile automatically detects whether your system | |
737 | supports shared libraries. To prevent Guile from buildisg shared | |
738 | libraries, pass the `--disable-shared' flag to the configure script. | |
739 | ||
740 | Guile takes longer to compile when it builds shared libraries, because | |
741 | it must compile every file twice --- once to produce position- | |
742 | independent object code, and once to produce normal object code. | |
743 | ||
744 | ** The libthreads library has been merged into libguile. | |
745 | ||
746 | To link a program against Guile, you now need only link against | |
747 | -lguile and -lqt; -lthreads is no longer needed. If you are using | |
748 | autoconf to generate configuration scripts for your application, the | |
749 | following lines should suffice to add the appropriate libraries to | |
750 | your link command: | |
751 | ||
752 | ### Find quickthreads and libguile. | |
753 | AC_CHECK_LIB(qt, main) | |
754 | AC_CHECK_LIB(guile, scm_shell) | |
f3b1485f JB |
755 | |
756 | * Changes to Scheme functions | |
757 | ||
095936d2 JB |
758 | ** Guile Scheme's special syntax for keyword objects is now optional, |
759 | and disabled by default. | |
760 | ||
761 | The syntax variation from R4RS made it difficult to port some | |
762 | interesting packages to Guile. The routines which accepted keyword | |
763 | arguments (mostly in the module system) have been modified to also | |
764 | accept symbols whose names begin with `:'. | |
765 | ||
766 | To change the keyword syntax, you must first import the (ice-9 debug) | |
767 | module: | |
768 | (use-modules (ice-9 debug)) | |
769 | ||
770 | Then you can enable the keyword syntax as follows: | |
771 | (read-set! keywords 'prefix) | |
772 | ||
773 | To disable keyword syntax, do this: | |
774 | (read-set! keywords #f) | |
775 | ||
776 | ** Many more primitive functions accept shared substrings as | |
777 | arguments. In the past, these functions required normal, mutable | |
778 | strings as arguments, although they never made use of this | |
779 | restriction. | |
780 | ||
781 | ** The uniform array functions now operate on byte vectors. These | |
782 | functions are `array-fill!', `serial-array-copy!', `array-copy!', | |
783 | `serial-array-map', `array-map', `array-for-each', and | |
784 | `array-index-map!'. | |
785 | ||
786 | ** The new functions `trace' and `untrace' implement simple debugging | |
787 | support for Scheme functions. | |
788 | ||
789 | The `trace' function accepts any number of procedures as arguments, | |
790 | and tells the Guile interpreter to display each procedure's name and | |
791 | arguments each time the procedure is invoked. When invoked with no | |
792 | arguments, `trace' returns the list of procedures currently being | |
793 | traced. | |
794 | ||
795 | The `untrace' function accepts any number of procedures as arguments, | |
796 | and tells the Guile interpreter not to trace them any more. When | |
797 | invoked with no arguments, `untrace' untraces all curretly traced | |
798 | procedures. | |
799 | ||
800 | The tracing in Guile has an advantage over most other systems: we | |
801 | don't create new procedure objects, but mark the procedure objects | |
802 | themselves. This means that anonymous and internal procedures can be | |
803 | traced. | |
804 | ||
805 | ** The function `assert-repl-prompt' has been renamed to | |
806 | `set-repl-prompt!'. It takes one argument, PROMPT. | |
807 | - If PROMPT is #f, the Guile read-eval-print loop will not prompt. | |
808 | - If PROMPT is a string, we use it as a prompt. | |
809 | - If PROMPT is a procedure accepting no arguments, we call it, and | |
810 | display the result as a prompt. | |
811 | - Otherwise, we display "> ". | |
812 | ||
813 | ** The new function `eval-string' reads Scheme expressions from a | |
814 | string and evaluates them, returning the value of the last expression | |
815 | in the string. If the string contains no expressions, it returns an | |
816 | unspecified value. | |
817 | ||
818 | ** The new function `thunk?' returns true iff its argument is a | |
819 | procedure of zero arguments. | |
820 | ||
821 | ** `defined?' is now a builtin function, instead of syntax. This | |
822 | means that its argument should be quoted. It returns #t iff its | |
823 | argument is bound in the current module. | |
824 | ||
825 | ** The new syntax `use-modules' allows you to add new modules to your | |
826 | environment without re-typing a complete `define-module' form. It | |
827 | accepts any number of module names as arguments, and imports their | |
828 | public bindings into the current module. | |
829 | ||
830 | ** The new function (module-defined? NAME MODULE) returns true iff | |
831 | NAME, a symbol, is defined in MODULE, a module object. | |
832 | ||
833 | ** The new function `builtin-bindings' creates and returns a hash | |
834 | table containing copies of all the root module's bindings. | |
835 | ||
836 | ** The new function `builtin-weak-bindings' does the same as | |
837 | `builtin-bindings', but creates a doubly-weak hash table. | |
838 | ||
839 | ** The `equal?' function now considers variable objects to be | |
840 | equivalent if they have the same name and the same value. | |
841 | ||
842 | ** The new function `command-line' returns the command-line arguments | |
843 | given to Guile, as a list of strings. | |
844 | ||
845 | When using guile as a script interpreter, `command-line' returns the | |
846 | script's arguments; those processed by the interpreter (like `-s' or | |
847 | `-c') are omitted. (In other words, you get the normal, expected | |
848 | behavior.) Any application that uses scm_shell to process its | |
849 | command-line arguments gets this behavior as well. | |
850 | ||
851 | ** The new function `load-user-init' looks for a file called `.guile' | |
852 | in the user's home directory, and loads it if it exists. This is | |
853 | mostly for use by the code generated by scm_compile_shell_switches, | |
854 | but we thought it might also be useful in other circumstances. | |
855 | ||
856 | ** The new function `log10' returns the base-10 logarithm of its | |
857 | argument. | |
858 | ||
859 | ** Changes to I/O functions | |
860 | ||
861 | *** The functions `read', `primitive-load', `read-and-eval!', and | |
862 | `primitive-load-path' no longer take optional arguments controlling | |
863 | case insensitivity and a `#' parser. | |
864 | ||
865 | Case sensitivity is now controlled by a read option called | |
866 | `case-insensitive'. The user can add new `#' syntaxes with the | |
867 | `read-hash-extend' function (see below). | |
868 | ||
869 | *** The new function `read-hash-extend' allows the user to change the | |
870 | syntax of Guile Scheme in a somewhat controlled way. | |
871 | ||
872 | (read-hash-extend CHAR PROC) | |
873 | When parsing S-expressions, if we read a `#' character followed by | |
874 | the character CHAR, use PROC to parse an object from the stream. | |
875 | If PROC is #f, remove any parsing procedure registered for CHAR. | |
876 | ||
877 | The reader applies PROC to two arguments: CHAR and an input port. | |
878 | ||
879 | *** The new functions read-delimited and read-delimited! provide a | |
880 | general mechanism for doing delimited input on streams. | |
881 | ||
882 | (read-delimited DELIMS [PORT HANDLE-DELIM]) | |
883 | Read until we encounter one of the characters in DELIMS (a string), | |
884 | or end-of-file. PORT is the input port to read from; it defaults to | |
885 | the current input port. The HANDLE-DELIM parameter determines how | |
886 | the terminating character is handled; it should be one of the | |
887 | following symbols: | |
888 | ||
889 | 'trim omit delimiter from result | |
890 | 'peek leave delimiter character in input stream | |
891 | 'concat append delimiter character to returned value | |
892 | 'split return a pair: (RESULT . TERMINATOR) | |
893 | ||
894 | HANDLE-DELIM defaults to 'peek. | |
895 | ||
896 | (read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END]) | |
897 | A side-effecting variant of `read-delimited'. | |
898 | ||
899 | The data is written into the string BUF at the indices in the | |
900 | half-open interval [START, END); the default interval is the whole | |
901 | string: START = 0 and END = (string-length BUF). The values of | |
902 | START and END must specify a well-defined interval in BUF, i.e. | |
903 | 0 <= START <= END <= (string-length BUF). | |
904 | ||
905 | It returns NBYTES, the number of bytes read. If the buffer filled | |
906 | up without a delimiter character being found, it returns #f. If the | |
907 | port is at EOF when the read starts, it returns the EOF object. | |
908 | ||
909 | If an integer is returned (i.e., the read is successfully terminated | |
910 | by reading a delimiter character), then the HANDLE-DELIM parameter | |
911 | determines how to handle the terminating character. It is described | |
912 | above, and defaults to 'peek. | |
913 | ||
914 | (The descriptions of these functions were borrowed from the SCSH | |
915 | manual, by Olin Shivers and Brian Carlstrom.) | |
916 | ||
917 | *** The `%read-delimited!' function is the primitive used to implement | |
918 | `read-delimited' and `read-delimited!'. | |
919 | ||
920 | (%read-delimited! DELIMS BUF GOBBLE? [PORT START END]) | |
921 | ||
922 | This returns a pair of values: (TERMINATOR . NUM-READ). | |
923 | - TERMINATOR describes why the read was terminated. If it is a | |
924 | character or the eof object, then that is the value that terminated | |
925 | the read. If it is #f, the function filled the buffer without finding | |
926 | a delimiting character. | |
927 | - NUM-READ is the number of characters read into BUF. | |
928 | ||
929 | If the read is successfully terminated by reading a delimiter | |
930 | character, then the gobble? parameter determines what to do with the | |
931 | terminating character. If true, the character is removed from the | |
932 | input stream; if false, the character is left in the input stream | |
933 | where a subsequent read operation will retrieve it. In either case, | |
934 | the character is also the first value returned by the procedure call. | |
935 | ||
936 | (The descriptions of this function was borrowed from the SCSH manual, | |
937 | by Olin Shivers and Brian Carlstrom.) | |
938 | ||
939 | *** The `read-line' and `read-line!' functions have changed; they now | |
940 | trim the terminator by default; previously they appended it to the | |
941 | returned string. For the old behavior, use (read-line PORT 'concat). | |
942 | ||
943 | *** The functions `uniform-array-read!' and `uniform-array-write!' now | |
944 | take new optional START and END arguments, specifying the region of | |
945 | the array to read and write. | |
946 | ||
f348c807 JB |
947 | *** The `ungetc-char-ready?' function has been removed. We feel it's |
948 | inappropriate for an interface to expose implementation details this | |
949 | way. | |
095936d2 JB |
950 | |
951 | ** Changes to the Unix library and system call interface | |
952 | ||
953 | *** The new fcntl function provides access to the Unix `fcntl' system | |
954 | call. | |
955 | ||
956 | (fcntl PORT COMMAND VALUE) | |
957 | Apply COMMAND to PORT's file descriptor, with VALUE as an argument. | |
958 | Values for COMMAND are: | |
959 | ||
960 | F_DUPFD duplicate a file descriptor | |
961 | F_GETFD read the descriptor's close-on-exec flag | |
962 | F_SETFD set the descriptor's close-on-exec flag to VALUE | |
963 | F_GETFL read the descriptor's flags, as set on open | |
964 | F_SETFL set the descriptor's flags, as set on open to VALUE | |
965 | F_GETOWN return the process ID of a socket's owner, for SIGIO | |
966 | F_SETOWN set the process that owns a socket to VALUE, for SIGIO | |
967 | FD_CLOEXEC not sure what this is | |
968 | ||
969 | For details, see the documentation for the fcntl system call. | |
970 | ||
971 | *** The arguments to `select' have changed, for compatibility with | |
972 | SCSH. The TIMEOUT parameter may now be non-integral, yielding the | |
973 | expected behavior. The MILLISECONDS parameter has been changed to | |
974 | MICROSECONDS, to more closely resemble the underlying system call. | |
975 | The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the | |
976 | corresponding return set will be the same. | |
977 | ||
978 | *** The arguments to the `mknod' system call have changed. They are | |
979 | now: | |
980 | ||
981 | (mknod PATH TYPE PERMS DEV) | |
982 | Create a new file (`node') in the file system. PATH is the name of | |
983 | the file to create. TYPE is the kind of file to create; it should | |
984 | be 'fifo, 'block-special, or 'char-special. PERMS specifies the | |
985 | permission bits to give the newly created file. If TYPE is | |
986 | 'block-special or 'char-special, DEV specifies which device the | |
987 | special file refers to; its interpretation depends on the kind of | |
988 | special file being created. | |
989 | ||
990 | *** The `fork' function has been renamed to `primitive-fork', to avoid | |
991 | clashing with various SCSH forks. | |
992 | ||
993 | *** The `recv' and `recvfrom' functions have been renamed to `recv!' | |
994 | and `recvfrom!'. They no longer accept a size for a second argument; | |
995 | you must pass a string to hold the received value. They no longer | |
996 | return the buffer. Instead, `recv' returns the length of the message | |
997 | received, and `recvfrom' returns a pair containing the packet's length | |
998 | and originating address. | |
999 | ||
1000 | *** The file descriptor datatype has been removed, as have the | |
1001 | `read-fd', `write-fd', `close', `lseek', and `dup' functions. | |
1002 | We plan to replace these functions with a SCSH-compatible interface. | |
1003 | ||
1004 | *** The `create' function has been removed; it's just a special case | |
1005 | of `open'. | |
1006 | ||
1007 | *** There are new functions to break down process termination status | |
1008 | values. In the descriptions below, STATUS is a value returned by | |
1009 | `waitpid'. | |
1010 | ||
1011 | (status:exit-val STATUS) | |
1012 | If the child process exited normally, this function returns the exit | |
1013 | code for the child process (i.e., the value passed to exit, or | |
1014 | returned from main). If the child process did not exit normally, | |
1015 | this function returns #f. | |
1016 | ||
1017 | (status:stop-sig STATUS) | |
1018 | If the child process was suspended by a signal, this function | |
1019 | returns the signal that suspended the child. Otherwise, it returns | |
1020 | #f. | |
1021 | ||
1022 | (status:term-sig STATUS) | |
1023 | If the child process terminated abnormally, this function returns | |
1024 | the signal that terminated the child. Otherwise, this function | |
1025 | returns false. | |
1026 | ||
1027 | POSIX promises that exactly one of these functions will return true on | |
1028 | a valid STATUS value. | |
1029 | ||
1030 | These functions are compatible with SCSH. | |
1031 | ||
1032 | *** There are new accessors and setters for the broken-out time vectors | |
48d224d7 JB |
1033 | returned by `localtime', `gmtime', and that ilk. They are: |
1034 | ||
1035 | Component Accessor Setter | |
1036 | ========================= ============ ============ | |
1037 | seconds tm:sec set-tm:sec | |
1038 | minutes tm:min set-tm:min | |
1039 | hours tm:hour set-tm:hour | |
1040 | day of the month tm:mday set-tm:mday | |
1041 | month tm:mon set-tm:mon | |
1042 | year tm:year set-tm:year | |
1043 | day of the week tm:wday set-tm:wday | |
1044 | day in the year tm:yday set-tm:yday | |
1045 | daylight saving time tm:isdst set-tm:isdst | |
1046 | GMT offset, seconds tm:gmtoff set-tm:gmtoff | |
1047 | name of time zone tm:zone set-tm:zone | |
1048 | ||
095936d2 JB |
1049 | *** There are new accessors for the vectors returned by `uname', |
1050 | describing the host system: | |
48d224d7 JB |
1051 | |
1052 | Component Accessor | |
1053 | ============================================== ================ | |
1054 | name of the operating system implementation utsname:sysname | |
1055 | network name of this machine utsname:nodename | |
1056 | release level of the operating system utsname:release | |
1057 | version level of the operating system utsname:version | |
1058 | machine hardware platform utsname:machine | |
1059 | ||
095936d2 JB |
1060 | *** There are new accessors for the vectors returned by `getpw', |
1061 | `getpwnam', `getpwuid', and `getpwent', describing entries from the | |
1062 | system's user database: | |
1063 | ||
1064 | Component Accessor | |
1065 | ====================== ================= | |
1066 | user name passwd:name | |
1067 | user password passwd:passwd | |
1068 | user id passwd:uid | |
1069 | group id passwd:gid | |
1070 | real name passwd:gecos | |
1071 | home directory passwd:dir | |
1072 | shell program passwd:shell | |
1073 | ||
1074 | *** There are new accessors for the vectors returned by `getgr', | |
1075 | `getgrnam', `getgrgid', and `getgrent', describing entries from the | |
1076 | system's group database: | |
1077 | ||
1078 | Component Accessor | |
1079 | ======================= ============ | |
1080 | group name group:name | |
1081 | group password group:passwd | |
1082 | group id group:gid | |
1083 | group members group:mem | |
1084 | ||
1085 | *** There are new accessors for the vectors returned by `gethost', | |
1086 | `gethostbyaddr', `gethostbyname', and `gethostent', describing | |
1087 | internet hosts: | |
1088 | ||
1089 | Component Accessor | |
1090 | ========================= =============== | |
1091 | official name of host hostent:name | |
1092 | alias list hostent:aliases | |
1093 | host address type hostent:addrtype | |
1094 | length of address hostent:length | |
1095 | list of addresses hostent:addr-list | |
1096 | ||
1097 | *** There are new accessors for the vectors returned by `getnet', | |
1098 | `getnetbyaddr', `getnetbyname', and `getnetent', describing internet | |
1099 | networks: | |
1100 | ||
1101 | Component Accessor | |
1102 | ========================= =============== | |
1103 | official name of net netent:name | |
1104 | alias list netent:aliases | |
1105 | net number type netent:addrtype | |
1106 | net number netent:net | |
1107 | ||
1108 | *** There are new accessors for the vectors returned by `getproto', | |
1109 | `getprotobyname', `getprotobynumber', and `getprotoent', describing | |
1110 | internet protocols: | |
1111 | ||
1112 | Component Accessor | |
1113 | ========================= =============== | |
1114 | official protocol name protoent:name | |
1115 | alias list protoent:aliases | |
1116 | protocol number protoent:proto | |
1117 | ||
1118 | *** There are new accessors for the vectors returned by `getserv', | |
1119 | `getservbyname', `getservbyport', and `getservent', describing | |
1120 | internet protocols: | |
1121 | ||
1122 | Component Accessor | |
1123 | ========================= =============== | |
1124 | official service name servent:name | |
1125 | alias list servent:aliases | |
1126 | port number servent:port | |
1127 | protocol to use servent:proto | |
1128 | ||
1129 | *** There are new accessors for the sockaddr structures returned by | |
1130 | `accept', `getsockname', `getpeername', `recvfrom!': | |
1131 | ||
1132 | Component Accessor | |
1133 | ======================================== =============== | |
1134 | address format (`family') sockaddr:fam | |
1135 | path, for file domain addresses sockaddr:path | |
1136 | address, for internet domain addresses sockaddr:addr | |
1137 | TCP or UDP port, for internet sockaddr:port | |
1138 | ||
1139 | *** The `getpwent', `getgrent', `gethostent', `getnetent', | |
1140 | `getprotoent', and `getservent' functions now return #f at the end of | |
1141 | the user database. (They used to throw an exception.) | |
1142 | ||
1143 | Note that calling MUMBLEent function is equivalent to calling the | |
1144 | corresponding MUMBLE function with no arguments. | |
1145 | ||
1146 | *** The `setpwent', `setgrent', `sethostent', `setnetent', | |
1147 | `setprotoent', and `setservent' routines now take no arguments. | |
1148 | ||
1149 | *** The `gethost', `getproto', `getnet', and `getserv' functions now | |
1150 | provide more useful information when they throw an exception. | |
1151 | ||
1152 | *** The `lnaof' function has been renamed to `inet-lnaof'. | |
1153 | ||
1154 | *** Guile now claims to have the `current-time' feature. | |
1155 | ||
1156 | *** The `mktime' function now takes an optional second argument ZONE, | |
1157 | giving the time zone to use for the conversion. ZONE should be a | |
1158 | string, in the same format as expected for the "TZ" environment variable. | |
1159 | ||
1160 | *** The `strptime' function now returns a pair (TIME . COUNT), where | |
1161 | TIME is the parsed time as a vector, and COUNT is the number of | |
1162 | characters from the string left unparsed. This function used to | |
1163 | return the remaining characters as a string. | |
1164 | ||
1165 | *** The `gettimeofday' function has replaced the old `time+ticks' function. | |
1166 | The return value is now (SECONDS . MICROSECONDS); the fractional | |
1167 | component is no longer expressed in "ticks". | |
1168 | ||
1169 | *** The `ticks/sec' constant has been removed, in light of the above change. | |
6685dc83 | 1170 | |
ea00ecba MG |
1171 | * Changes to the gh_ interface |
1172 | ||
1173 | ** gh_eval_str() now returns an SCM object which is the result of the | |
1174 | evaluation | |
1175 | ||
aaef0d2a MG |
1176 | ** gh_scm2str() now copies the Scheme data to a caller-provided C |
1177 | array | |
1178 | ||
1179 | ** gh_scm2newstr() now makes a C array, copies the Scheme data to it, | |
1180 | and returns the array | |
1181 | ||
1182 | ** gh_scm2str0() is gone: there is no need to distinguish | |
1183 | null-terminated from non-null-terminated, since gh_scm2newstr() allows | |
1184 | the user to interpret the data both ways. | |
1185 | ||
f3b1485f JB |
1186 | * Changes to the scm_ interface |
1187 | ||
095936d2 JB |
1188 | ** The new function scm_symbol_value0 provides an easy way to get a |
1189 | symbol's value from C code: | |
1190 | ||
1191 | SCM scm_symbol_value0 (char *NAME) | |
1192 | Return the value of the symbol named by the null-terminated string | |
1193 | NAME in the current module. If the symbol named NAME is unbound in | |
1194 | the current module, return SCM_UNDEFINED. | |
1195 | ||
1196 | ** The new function scm_sysintern0 creates new top-level variables, | |
1197 | without assigning them a value. | |
1198 | ||
1199 | SCM scm_sysintern0 (char *NAME) | |
1200 | Create a new Scheme top-level variable named NAME. NAME is a | |
1201 | null-terminated string. Return the variable's value cell. | |
1202 | ||
1203 | ** The function scm_internal_catch is the guts of catch. It handles | |
1204 | all the mechanics of setting up a catch target, invoking the catch | |
1205 | body, and perhaps invoking the handler if the body does a throw. | |
1206 | ||
1207 | The function is designed to be usable from C code, but is general | |
1208 | enough to implement all the semantics Guile Scheme expects from throw. | |
1209 | ||
1210 | TAG is the catch tag. Typically, this is a symbol, but this function | |
1211 | doesn't actually care about that. | |
1212 | ||
1213 | BODY is a pointer to a C function which runs the body of the catch; | |
1214 | this is the code you can throw from. We call it like this: | |
1215 | BODY (BODY_DATA, JMPBUF) | |
1216 | where: | |
1217 | BODY_DATA is just the BODY_DATA argument we received; we pass it | |
1218 | through to BODY as its first argument. The caller can make | |
1219 | BODY_DATA point to anything useful that BODY might need. | |
1220 | JMPBUF is the Scheme jmpbuf object corresponding to this catch, | |
1221 | which we have just created and initialized. | |
1222 | ||
1223 | HANDLER is a pointer to a C function to deal with a throw to TAG, | |
1224 | should one occur. We call it like this: | |
1225 | HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS) | |
1226 | where | |
1227 | HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the | |
1228 | same idea as BODY_DATA above. | |
1229 | THROWN_TAG is the tag that the user threw to; usually this is | |
1230 | TAG, but it could be something else if TAG was #t (i.e., a | |
1231 | catch-all), or the user threw to a jmpbuf. | |
1232 | THROW_ARGS is the list of arguments the user passed to the THROW | |
1233 | function. | |
1234 | ||
1235 | BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA | |
1236 | is just a pointer we pass through to HANDLER. We don't actually | |
1237 | use either of those pointers otherwise ourselves. The idea is | |
1238 | that, if our caller wants to communicate something to BODY or | |
1239 | HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and | |
1240 | HANDLER can then use. Think of it as a way to make BODY and | |
1241 | HANDLER closures, not just functions; MUMBLE_DATA points to the | |
1242 | enclosed variables. | |
1243 | ||
1244 | Of course, it's up to the caller to make sure that any data a | |
1245 | MUMBLE_DATA needs is protected from GC. A common way to do this is | |
1246 | to make MUMBLE_DATA a pointer to data stored in an automatic | |
1247 | structure variable; since the collector must scan the stack for | |
1248 | references anyway, this assures that any references in MUMBLE_DATA | |
1249 | will be found. | |
1250 | ||
1251 | ** The new function scm_internal_lazy_catch is exactly like | |
1252 | scm_internal_catch, except: | |
1253 | ||
1254 | - It does not unwind the stack (this is the major difference). | |
1255 | - If handler returns, its value is returned from the throw. | |
1256 | - BODY always receives #f as its JMPBUF argument (since there's no | |
1257 | jmpbuf associated with a lazy catch, because we don't unwind the | |
1258 | stack.) | |
1259 | ||
1260 | ** scm_body_thunk is a new body function you can pass to | |
1261 | scm_internal_catch if you want the body to be like Scheme's `catch' | |
1262 | --- a thunk, or a function of one argument if the tag is #f. | |
1263 | ||
1264 | BODY_DATA is a pointer to a scm_body_thunk_data structure, which | |
1265 | contains the Scheme procedure to invoke as the body, and the tag | |
1266 | we're catching. If the tag is #f, then we pass JMPBUF (created by | |
1267 | scm_internal_catch) to the body procedure; otherwise, the body gets | |
1268 | no arguments. | |
1269 | ||
1270 | ** scm_handle_by_proc is a new handler function you can pass to | |
1271 | scm_internal_catch if you want the handler to act like Scheme's catch | |
1272 | --- call a procedure with the tag and the throw arguments. | |
1273 | ||
1274 | If the user does a throw to this catch, this function runs a handler | |
1275 | procedure written in Scheme. HANDLER_DATA is a pointer to an SCM | |
1276 | variable holding the Scheme procedure object to invoke. It ought to | |
1277 | be a pointer to an automatic variable (i.e., one living on the stack), | |
1278 | or the procedure object should be otherwise protected from GC. | |
1279 | ||
1280 | ** scm_handle_by_message is a new handler function to use with | |
1281 | `scm_internal_catch' if you want Guile to print a message and die. | |
1282 | It's useful for dealing with throws to uncaught keys at the top level. | |
1283 | ||
1284 | HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a | |
1285 | message header to print; if zero, we use "guile" instead. That | |
1286 | text is followed by a colon, then the message described by ARGS. | |
1287 | ||
1288 | ** The return type of scm_boot_guile is now void; the function does | |
1289 | not return a value, and indeed, never returns at all. | |
1290 | ||
f3b1485f JB |
1291 | ** The new function scm_shell makes it easy for user applications to |
1292 | process command-line arguments in a way that is compatible with the | |
1293 | stand-alone guile interpreter (which is in turn compatible with SCSH, | |
1294 | the Scheme shell). | |
1295 | ||
1296 | To use the scm_shell function, first initialize any guile modules | |
1297 | linked into your application, and then call scm_shell with the values | |
1298 | of ARGC and ARGV your `main' function received. scm_shell will adding | |
1299 | any SCSH-style meta-arguments from the top of the script file to the | |
1300 | argument vector, and then process the command-line arguments. This | |
1301 | generally means loading a script file or starting up an interactive | |
1302 | command interpreter. For details, see "Changes to the stand-alone | |
1303 | interpreter" above. | |
1304 | ||
095936d2 JB |
1305 | ** The new functions scm_get_meta_args and scm_count_argv help you |
1306 | implement the SCSH-style meta-argument, `\'. | |
1307 | ||
1308 | char **scm_get_meta_args (int ARGC, char **ARGV) | |
1309 | If the second element of ARGV is a string consisting of a single | |
1310 | backslash character (i.e. "\\" in Scheme notation), open the file | |
1311 | named by the following argument, parse arguments from it, and return | |
1312 | the spliced command line. The returned array is terminated by a | |
1313 | null pointer. | |
1314 | ||
1315 | For details of argument parsing, see above, under "guile now accepts | |
1316 | command-line arguments compatible with SCSH..." | |
1317 | ||
1318 | int scm_count_argv (char **ARGV) | |
1319 | Count the arguments in ARGV, assuming it is terminated by a null | |
1320 | pointer. | |
1321 | ||
1322 | For an example of how these functions might be used, see the source | |
1323 | code for the function scm_shell in libguile/script.c. | |
1324 | ||
1325 | You will usually want to use scm_shell instead of calling this | |
1326 | function yourself. | |
1327 | ||
1328 | ** The new function scm_compile_shell_switches turns an array of | |
1329 | command-line arguments into Scheme code to carry out the actions they | |
1330 | describe. Given ARGC and ARGV, it returns a Scheme expression to | |
1331 | evaluate, and calls scm_set_program_arguments to make any remaining | |
1332 | command-line arguments available to the Scheme code. For example, | |
1333 | given the following arguments: | |
1334 | ||
1335 | -e main -s ekko a speckled gecko | |
1336 | ||
1337 | scm_set_program_arguments will return the following expression: | |
1338 | ||
1339 | (begin (load "ekko") (main (command-line)) (quit)) | |
1340 | ||
1341 | You will usually want to use scm_shell instead of calling this | |
1342 | function yourself. | |
1343 | ||
1344 | ** The function scm_shell_usage prints a usage message appropriate for | |
1345 | an interpreter that uses scm_compile_shell_switches to handle its | |
1346 | command-line arguments. | |
1347 | ||
1348 | void scm_shell_usage (int FATAL, char *MESSAGE) | |
1349 | Print a usage message to the standard error output. If MESSAGE is | |
1350 | non-zero, write it before the usage message, followed by a newline. | |
1351 | If FATAL is non-zero, exit the process, using FATAL as the | |
1352 | termination status. (If you want to be compatible with Guile, | |
1353 | always use 1 as the exit status when terminating due to command-line | |
1354 | usage problems.) | |
1355 | ||
1356 | You will usually want to use scm_shell instead of calling this | |
1357 | function yourself. | |
48d224d7 JB |
1358 | |
1359 | ** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no | |
095936d2 JB |
1360 | expressions. It used to return SCM_EOL. Earth-shattering. |
1361 | ||
1362 | ** The macros for declaring scheme objects in C code have been | |
1363 | rearranged slightly. They are now: | |
1364 | ||
1365 | SCM_SYMBOL (C_NAME, SCHEME_NAME) | |
1366 | Declare a static SCM variable named C_NAME, and initialize it to | |
1367 | point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should | |
1368 | be a C identifier, and SCHEME_NAME should be a C string. | |
1369 | ||
1370 | SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME) | |
1371 | Just like SCM_SYMBOL, but make C_NAME globally visible. | |
1372 | ||
1373 | SCM_VCELL (C_NAME, SCHEME_NAME) | |
1374 | Create a global variable at the Scheme level named SCHEME_NAME. | |
1375 | Declare a static SCM variable named C_NAME, and initialize it to | |
1376 | point to the Scheme variable's value cell. | |
1377 | ||
1378 | SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME) | |
1379 | Just like SCM_VCELL, but make C_NAME globally visible. | |
1380 | ||
1381 | The `guile-snarf' script writes initialization code for these macros | |
1382 | to its standard output, given C source code as input. | |
1383 | ||
1384 | The SCM_GLOBAL macro is gone. | |
1385 | ||
1386 | ** The scm_read_line and scm_read_line_x functions have been replaced | |
1387 | by Scheme code based on the %read-delimited! procedure (known to C | |
1388 | code as scm_read_delimited_x). See its description above for more | |
1389 | information. | |
48d224d7 | 1390 | |
095936d2 JB |
1391 | ** The function scm_sys_open has been renamed to scm_open. It now |
1392 | returns a port instead of an FD object. | |
ea00ecba | 1393 | |
095936d2 JB |
1394 | * The dynamic linking support has changed. For more information, see |
1395 | libguile/DYNAMIC-LINKING. | |
ea00ecba | 1396 | |
f7b47737 JB |
1397 | \f |
1398 | Guile 1.0b3 | |
3065a62a | 1399 | |
f3b1485f JB |
1400 | User-visible changes from Thursday, September 5, 1996 until Guile 1.0 |
1401 | (Sun 5 Jan 1997): | |
3065a62a | 1402 | |
4b521edb | 1403 | * Changes to the 'guile' program: |
3065a62a | 1404 | |
4b521edb JB |
1405 | ** Guile now loads some new files when it starts up. Guile first |
1406 | searches the load path for init.scm, and loads it if found. Then, if | |
1407 | Guile is not being used to execute a script, and the user's home | |
1408 | directory contains a file named `.guile', Guile loads that. | |
c6486f8a | 1409 | |
4b521edb | 1410 | ** You can now use Guile as a shell script interpreter. |
3065a62a JB |
1411 | |
1412 | To paraphrase the SCSH manual: | |
1413 | ||
1414 | When Unix tries to execute an executable file whose first two | |
1415 | characters are the `#!', it treats the file not as machine code to | |
1416 | be directly executed by the native processor, but as source code | |
1417 | to be executed by some interpreter. The interpreter to use is | |
1418 | specified immediately after the #! sequence on the first line of | |
1419 | the source file. The kernel reads in the name of the interpreter, | |
1420 | and executes that instead. It passes the interpreter the source | |
1421 | filename as its first argument, with the original arguments | |
1422 | following. Consult the Unix man page for the `exec' system call | |
1423 | for more information. | |
1424 | ||
1a1945be JB |
1425 | Now you can use Guile as an interpreter, using a mechanism which is a |
1426 | compatible subset of that provided by SCSH. | |
1427 | ||
3065a62a JB |
1428 | Guile now recognizes a '-s' command line switch, whose argument is the |
1429 | name of a file of Scheme code to load. It also treats the two | |
1430 | characters `#!' as the start of a comment, terminated by `!#'. Thus, | |
1431 | to make a file of Scheme code directly executable by Unix, insert the | |
1432 | following two lines at the top of the file: | |
1433 | ||
1434 | #!/usr/local/bin/guile -s | |
1435 | !# | |
1436 | ||
1437 | Guile treats the argument of the `-s' command-line switch as the name | |
1438 | of a file of Scheme code to load, and treats the sequence `#!' as the | |
1439 | start of a block comment, terminated by `!#'. | |
1440 | ||
1441 | For example, here's a version of 'echo' written in Scheme: | |
1442 | ||
1443 | #!/usr/local/bin/guile -s | |
1444 | !# | |
1445 | (let loop ((args (cdr (program-arguments)))) | |
1446 | (if (pair? args) | |
1447 | (begin | |
1448 | (display (car args)) | |
1449 | (if (pair? (cdr args)) | |
1450 | (display " ")) | |
1451 | (loop (cdr args))))) | |
1452 | (newline) | |
1453 | ||
1454 | Why does `#!' start a block comment terminated by `!#', instead of the | |
1455 | end of the line? That is the notation SCSH uses, and although we | |
1456 | don't yet support the other SCSH features that motivate that choice, | |
1457 | we would like to be backward-compatible with any existing Guile | |
3763761c JB |
1458 | scripts once we do. Furthermore, if the path to Guile on your system |
1459 | is too long for your kernel, you can start the script with this | |
1460 | horrible hack: | |
1461 | ||
1462 | #!/bin/sh | |
1463 | exec /really/long/path/to/guile -s "$0" ${1+"$@"} | |
1464 | !# | |
3065a62a JB |
1465 | |
1466 | Note that some very old Unix systems don't support the `#!' syntax. | |
1467 | ||
c6486f8a | 1468 | |
4b521edb | 1469 | ** You can now run Guile without installing it. |
6685dc83 JB |
1470 | |
1471 | Previous versions of the interactive Guile interpreter (`guile') | |
1472 | couldn't start up unless Guile's Scheme library had been installed; | |
1473 | they used the value of the environment variable `SCHEME_LOAD_PATH' | |
1474 | later on in the startup process, but not to find the startup code | |
1475 | itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme | |
1476 | code. | |
1477 | ||
1478 | To run Guile without installing it, build it in the normal way, and | |
1479 | then set the environment variable `SCHEME_LOAD_PATH' to a | |
1480 | colon-separated list of directories, including the top-level directory | |
1481 | of the Guile sources. For example, if you unpacked Guile so that the | |
1482 | full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then | |
1483 | you might say | |
1484 | ||
1485 | export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3 | |
1486 | ||
c6486f8a | 1487 | |
4b521edb JB |
1488 | ** Guile's read-eval-print loop no longer prints #<unspecified> |
1489 | results. If the user wants to see this, she can evaluate the | |
1490 | expression (assert-repl-print-unspecified #t), perhaps in her startup | |
48d224d7 | 1491 | file. |
6685dc83 | 1492 | |
4b521edb JB |
1493 | ** Guile no longer shows backtraces by default when an error occurs; |
1494 | however, it does display a message saying how to get one, and how to | |
1495 | request that they be displayed by default. After an error, evaluate | |
1496 | (backtrace) | |
1497 | to see a backtrace, and | |
1498 | (debug-enable 'backtrace) | |
1499 | to see them by default. | |
6685dc83 | 1500 | |
6685dc83 | 1501 | |
d9fb83d9 | 1502 | |
4b521edb JB |
1503 | * Changes to Guile Scheme: |
1504 | ||
1505 | ** Guile now distinguishes between #f and the empty list. | |
1506 | ||
1507 | This is for compatibility with the IEEE standard, the (possibly) | |
1508 | upcoming Revised^5 Report on Scheme, and many extant Scheme | |
1509 | implementations. | |
1510 | ||
1511 | Guile used to have #f and '() denote the same object, to make Scheme's | |
1512 | type system more compatible with Emacs Lisp's. However, the change | |
1513 | caused too much trouble for Scheme programmers, and we found another | |
1514 | way to reconcile Emacs Lisp with Scheme that didn't require this. | |
1515 | ||
1516 | ||
1517 | ** Guile's delq, delv, delete functions, and their destructive | |
c6486f8a JB |
1518 | counterparts, delq!, delv!, and delete!, now remove all matching |
1519 | elements from the list, not just the first. This matches the behavior | |
1520 | of the corresponding Emacs Lisp functions, and (I believe) the Maclisp | |
1521 | functions which inspired them. | |
1522 | ||
1523 | I recognize that this change may break code in subtle ways, but it | |
1524 | seems best to make the change before the FSF's first Guile release, | |
1525 | rather than after. | |
1526 | ||
1527 | ||
4b521edb | 1528 | ** The compiled-library-path function has been deleted from libguile. |
6685dc83 | 1529 | |
4b521edb | 1530 | ** The facilities for loading Scheme source files have changed. |
c6486f8a | 1531 | |
4b521edb | 1532 | *** The variable %load-path now tells Guile which directories to search |
6685dc83 JB |
1533 | for Scheme code. Its value is a list of strings, each of which names |
1534 | a directory. | |
1535 | ||
4b521edb JB |
1536 | *** The variable %load-extensions now tells Guile which extensions to |
1537 | try appending to a filename when searching the load path. Its value | |
1538 | is a list of strings. Its default value is ("" ".scm"). | |
1539 | ||
1540 | *** (%search-load-path FILENAME) searches the directories listed in the | |
1541 | value of the %load-path variable for a Scheme file named FILENAME, | |
1542 | with all the extensions listed in %load-extensions. If it finds a | |
1543 | match, then it returns its full filename. If FILENAME is absolute, it | |
1544 | returns it unchanged. Otherwise, it returns #f. | |
6685dc83 | 1545 | |
4b521edb JB |
1546 | %search-load-path will not return matches that refer to directories. |
1547 | ||
1548 | *** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP) | |
1549 | uses %seach-load-path to find a file named FILENAME, and loads it if | |
1550 | it finds it. If it can't read FILENAME for any reason, it throws an | |
1551 | error. | |
6685dc83 JB |
1552 | |
1553 | The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the | |
4b521edb JB |
1554 | `read' function. |
1555 | ||
1556 | *** load uses the same searching semantics as primitive-load. | |
1557 | ||
1558 | *** The functions %try-load, try-load-with-path, %load, load-with-path, | |
1559 | basic-try-load-with-path, basic-load-with-path, try-load-module-with- | |
1560 | path, and load-module-with-path have been deleted. The functions | |
1561 | above should serve their purposes. | |
1562 | ||
1563 | *** If the value of the variable %load-hook is a procedure, | |
1564 | `primitive-load' applies its value to the name of the file being | |
1565 | loaded (without the load path directory name prepended). If its value | |
1566 | is #f, it is ignored. Otherwise, an error occurs. | |
1567 | ||
1568 | This is mostly useful for printing load notification messages. | |
1569 | ||
1570 | ||
1571 | ** The function `eval!' is no longer accessible from the scheme level. | |
1572 | We can't allow operations which introduce glocs into the scheme level, | |
1573 | because Guile's type system can't handle these as data. Use `eval' or | |
1574 | `read-and-eval!' (see below) as replacement. | |
1575 | ||
1576 | ** The new function read-and-eval! reads an expression from PORT, | |
1577 | evaluates it, and returns the result. This is more efficient than | |
1578 | simply calling `read' and `eval', since it is not necessary to make a | |
1579 | copy of the expression for the evaluator to munge. | |
1580 | ||
1581 | Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as | |
1582 | for the `read' function. | |
1583 | ||
1584 | ||
1585 | ** The function `int?' has been removed; its definition was identical | |
1586 | to that of `integer?'. | |
1587 | ||
1588 | ** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should | |
1589 | use the R4RS names for these functions. | |
1590 | ||
1591 | ** The function object-properties no longer returns the hash handle; | |
1592 | it simply returns the object's property list. | |
1593 | ||
1594 | ** Many functions have been changed to throw errors, instead of | |
1595 | returning #f on failure. The point of providing exception handling in | |
1596 | the language is to simplify the logic of user code, but this is less | |
1597 | useful if Guile's primitives don't throw exceptions. | |
1598 | ||
1599 | ** The function `fileno' has been renamed from `%fileno'. | |
1600 | ||
1601 | ** The function primitive-mode->fdes returns #t or #f now, not 1 or 0. | |
1602 | ||
1603 | ||
1604 | * Changes to Guile's C interface: | |
1605 | ||
1606 | ** The library's initialization procedure has been simplified. | |
1607 | scm_boot_guile now has the prototype: | |
1608 | ||
1609 | void scm_boot_guile (int ARGC, | |
1610 | char **ARGV, | |
1611 | void (*main_func) (), | |
1612 | void *closure); | |
1613 | ||
1614 | scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV. | |
1615 | MAIN_FUNC should do all the work of the program (initializing other | |
1616 | packages, reading user input, etc.) before returning. When MAIN_FUNC | |
1617 | returns, call exit (0); this function never returns. If you want some | |
1618 | other exit value, MAIN_FUNC may call exit itself. | |
1619 | ||
1620 | scm_boot_guile arranges for program-arguments to return the strings | |
1621 | given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call | |
1622 | scm_set_program_arguments with the final list, so Scheme code will | |
1623 | know which arguments have been processed. | |
1624 | ||
1625 | scm_boot_guile establishes a catch-all catch handler which prints an | |
1626 | error message and exits the process. This means that Guile exits in a | |
1627 | coherent way when system errors occur and the user isn't prepared to | |
1628 | handle it. If the user doesn't like this behavior, they can establish | |
1629 | their own universal catcher in MAIN_FUNC to shadow this one. | |
1630 | ||
1631 | Why must the caller do all the real work from MAIN_FUNC? The garbage | |
1632 | collector assumes that all local variables of type SCM will be above | |
1633 | scm_boot_guile's stack frame on the stack. If you try to manipulate | |
1634 | SCM values after this function returns, it's the luck of the draw | |
1635 | whether the GC will be able to find the objects you allocate. So, | |
1636 | scm_boot_guile function exits, rather than returning, to discourage | |
1637 | people from making that mistake. | |
1638 | ||
1639 | The IN, OUT, and ERR arguments were removed; there are other | |
1640 | convenient ways to override these when desired. | |
1641 | ||
1642 | The RESULT argument was deleted; this function should never return. | |
1643 | ||
1644 | The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more | |
1645 | general. | |
1646 | ||
1647 | ||
1648 | ** Guile's header files should no longer conflict with your system's | |
1649 | header files. | |
1650 | ||
1651 | In order to compile code which #included <libguile.h>, previous | |
1652 | versions of Guile required you to add a directory containing all the | |
1653 | Guile header files to your #include path. This was a problem, since | |
1654 | Guile's header files have names which conflict with many systems' | |
1655 | header files. | |
1656 | ||
1657 | Now only <libguile.h> need appear in your #include path; you must | |
1658 | refer to all Guile's other header files as <libguile/mumble.h>. | |
1659 | Guile's installation procedure puts libguile.h in $(includedir), and | |
1660 | the rest in $(includedir)/libguile. | |
1661 | ||
1662 | ||
1663 | ** Two new C functions, scm_protect_object and scm_unprotect_object, | |
1664 | have been added to the Guile library. | |
1665 | ||
1666 | scm_protect_object (OBJ) protects OBJ from the garbage collector. | |
1667 | OBJ will not be freed, even if all other references are dropped, | |
1668 | until someone does scm_unprotect_object (OBJ). Both functions | |
1669 | return OBJ. | |
1670 | ||
1671 | Note that calls to scm_protect_object do not nest. You can call | |
1672 | scm_protect_object any number of times on a given object, and the | |
1673 | next call to scm_unprotect_object will unprotect it completely. | |
1674 | ||
1675 | Basically, scm_protect_object and scm_unprotect_object just | |
1676 | maintain a list of references to things. Since the GC knows about | |
1677 | this list, all objects it mentions stay alive. scm_protect_object | |
1678 | adds its argument to the list; scm_unprotect_object remove its | |
1679 | argument from the list. | |
1680 | ||
1681 | ||
1682 | ** scm_eval_0str now returns the value of the last expression | |
1683 | evaluated. | |
1684 | ||
1685 | ** The new function scm_read_0str reads an s-expression from a | |
1686 | null-terminated string, and returns it. | |
1687 | ||
1688 | ** The new function `scm_stdio_to_port' converts a STDIO file pointer | |
1689 | to a Scheme port object. | |
1690 | ||
1691 | ** The new function `scm_set_program_arguments' allows C code to set | |
1692 | the value teruturned by the Scheme `program-arguments' function. | |
6685dc83 | 1693 | |
6685dc83 | 1694 | \f |
1a1945be JB |
1695 | Older changes: |
1696 | ||
1697 | * Guile no longer includes sophisticated Tcl/Tk support. | |
1698 | ||
1699 | The old Tcl/Tk support was unsatisfying to us, because it required the | |
1700 | user to link against the Tcl library, as well as Tk and Guile. The | |
1701 | interface was also un-lispy, in that it preserved Tcl/Tk's practice of | |
1702 | referring to widgets by names, rather than exporting widgets to Scheme | |
1703 | code as a special datatype. | |
1704 | ||
1705 | In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk | |
1706 | maintainers described some very interesting changes in progress to the | |
1707 | Tcl/Tk internals, which would facilitate clean interfaces between lone | |
1708 | Tk and other interpreters --- even for garbage-collected languages | |
1709 | like Scheme. They expected the new Tk to be publicly available in the | |
1710 | fall of 1996. | |
1711 | ||
1712 | Since it seems that Guile might soon have a new, cleaner interface to | |
1713 | lone Tk, and that the old Guile/Tk glue code would probably need to be | |
1714 | completely rewritten, we (Jim Blandy and Richard Stallman) have | |
1715 | decided not to support the old code. We'll spend the time instead on | |
1716 | a good interface to the newer Tk, as soon as it is available. | |
5c54da76 | 1717 | |
8512dea6 | 1718 | Until then, gtcltk-lib provides trivial, low-maintenance functionality. |
deb95d71 | 1719 | |
5c54da76 JB |
1720 | \f |
1721 | Copyright information: | |
1722 | ||
ea00ecba | 1723 | Copyright (C) 1996,1997 Free Software Foundation, Inc. |
5c54da76 JB |
1724 | |
1725 | Permission is granted to anyone to make or distribute verbatim copies | |
1726 | of this document as received, in any medium, provided that the | |
1727 | copyright notice and this permission notice are preserved, | |
1728 | thus giving the recipient permission to redistribute in turn. | |
1729 | ||
1730 | Permission is granted to distribute modified versions | |
1731 | of this document, or of portions of it, | |
1732 | under the above conditions, provided also that they | |
1733 | carry prominent notices stating who last changed them. | |
1734 | ||
48d224d7 JB |
1735 | \f |
1736 | Local variables: | |
1737 | mode: outline | |
1738 | paragraph-separate: "[ \f]*$" | |
1739 | end: | |
1740 |