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