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