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