* scmsigs.h, async.h: updated.
[bpt/guile.git] / NEWS
1 Guile NEWS --- history of user-visible changes. -*- text -*-
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 See the end for copying conditions.
4
5 Please send Guile bug reports to bug-guile@prep.ai.mit.edu.
6 \f
7 Changes in Guile 1.2:
8
9 [[trim out any sections we don't need]]
10
11 * Changes to the distribution
12
13 * Changes to the procedure for linking libguile with your programs
14
15 * Changes to Scheme functions and syntax
16
17 ** Guile now supports a new R4RS-compliant syntax for keywords. A
18 token of the form #:NAME, where NAME has the same syntax as a Scheme
19 symbol, is the external representation of the keyword named NAME.
20 Keyword objects print using this syntax as well, so values containing
21 keyword objects can be read back into Guile. When used in an
22 expression, keywords are self-quoting objects.
23
24 Guile suports this read syntax, and uses this print syntax, regardless
25 of the current setting of the `keyword' read option. The `keyword'
26 read option only controls whether Guile recognizes the `:NAME' syntax,
27 which is incompatible with R4RS. (R4RS says such token represent
28 symbols.)
29
30 ** Guile has regular expression support again. Guile 1.0 included
31 functions for matching regular expressions, based on the Rx library.
32 In Guile 1.1, the Guile/Rx interface was removed to simplify the
33 distribution, and thus Guile had no regular expression support. Guile
34 1.2 now adds back the most commonly used functions, and supports all
35 of SCSH's regular expression functions. They are:
36
37 *** [[get docs from Tim?]]
38
39 * Changes to the gh_ interface
40
41 * Changes to the scm_ interface
42
43 * Changes to system call interfaces:
44
45 ** The value returned by `raise' is now unspecified. It throws an exception
46 if an error occurs.
47
48 ** A new procedure `sigaction' can be used to install signal handlers
49 (documentation to be provided).
50
51 \f
52 Changes in Guile 1.1 (Fri May 16 1997):
53
54 * Changes to the distribution.
55
56 The Guile 1.0 distribution has been split up into several smaller
57 pieces:
58 guile-core --- the Guile interpreter itself.
59 guile-tcltk --- the interface between the Guile interpreter and
60 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
61 is a toolkit for building graphical user interfaces.
62 guile-rgx-ctax --- the interface between Guile and the Rx regular
63 expression matcher, and the translator for the Ctax
64 programming language. These are packaged together because the
65 Ctax translator uses Rx to parse Ctax source code.
66
67 This NEWS file describes the changes made to guile-core since the 1.0
68 release.
69
70 We no longer distribute the documentation, since it was either out of
71 date, or incomplete. As soon as we have current documentation, we
72 will distribute it.
73
74 * Changes to the stand-alone interpreter
75
76 ** guile now accepts command-line arguments compatible with SCSH, Olin
77 Shivers' Scheme Shell.
78
79 In general, arguments are evaluated from left to right, but there are
80 exceptions. The following switches stop argument processing, and
81 stash all remaining command-line arguments as the value returned by
82 the (command-line) function.
83 -s SCRIPT load Scheme source code from FILE, and exit
84 -c EXPR evalute Scheme expression EXPR, and exit
85 -- stop scanning arguments; run interactively
86
87 The switches below are processed as they are encountered.
88 -l FILE load Scheme source code from FILE
89 -e FUNCTION after reading script, apply FUNCTION to
90 command line arguments
91 -ds do -s script at this point
92 --emacs enable Emacs protocol (experimental)
93 -h, --help display this help and exit
94 -v, --version display version information and exit
95 \ read arguments from following script lines
96
97 So, for example, here is a Guile script named `ekko' (thanks, Olin)
98 which re-implements the traditional "echo" command:
99
100 #!/usr/local/bin/guile -s
101 !#
102 (define (main args)
103 (map (lambda (arg) (display arg) (display " "))
104 (cdr args))
105 (newline))
106
107 (main (command-line))
108
109 Suppose we invoke this script as follows:
110
111 ekko a speckled gecko
112
113 Through the magic of Unix script processing (triggered by the `#!'
114 token at the top of the file), /usr/local/bin/guile receives the
115 following list of command-line arguments:
116
117 ("-s" "./ekko" "a" "speckled" "gecko")
118
119 Unix inserts the name of the script after the argument specified on
120 the first line of the file (in this case, "-s"), and then follows that
121 with the arguments given to the script. Guile loads the script, which
122 defines the `main' function, and then applies it to the list of
123 remaining command-line arguments, ("a" "speckled" "gecko").
124
125 In Unix, the first line of a script file must take the following form:
126
127 #!INTERPRETER ARGUMENT
128
129 where INTERPRETER is the absolute filename of the interpreter
130 executable, and ARGUMENT is a single command-line argument to pass to
131 the interpreter.
132
133 You may only pass one argument to the interpreter, and its length is
134 limited. These restrictions can be annoying to work around, so Guile
135 provides a general mechanism (borrowed from, and compatible with,
136 SCSH) for circumventing them.
137
138 If the ARGUMENT in a Guile script is a single backslash character,
139 `\', Guile will open the script file, parse arguments from its second
140 and subsequent lines, and replace the `\' with them. So, for example,
141 here is another implementation of the `ekko' script:
142
143 #!/usr/local/bin/guile \
144 -e main -s
145 !#
146 (define (main args)
147 (for-each (lambda (arg) (display arg) (display " "))
148 (cdr args))
149 (newline))
150
151 If the user invokes this script as follows:
152
153 ekko a speckled gecko
154
155 Unix expands this into
156
157 /usr/local/bin/guile \ ekko a speckled gecko
158
159 When Guile sees the `\' argument, it replaces it with the arguments
160 read from the second line of the script, producing:
161
162 /usr/local/bin/guile -e main -s ekko a speckled gecko
163
164 This tells Guile to load the `ekko' script, and apply the function
165 `main' to the argument list ("a" "speckled" "gecko").
166
167 Here is how Guile parses the command-line arguments:
168 - Each space character terminates an argument. This means that two
169 spaces in a row introduce an empty-string argument.
170 - The tab character is not permitted (unless you quote it with the
171 backslash character, as described below), to avoid confusion.
172 - The newline character terminates the sequence of arguments, and will
173 also terminate a final non-empty argument. (However, a newline
174 following a space will not introduce a final empty-string argument;
175 it only terminates the argument list.)
176 - The backslash character is the escape character. It escapes
177 backslash, space, tab, and newline. The ANSI C escape sequences
178 like \n and \t are also supported. These produce argument
179 constituents; the two-character combination \n doesn't act like a
180 terminating newline. The escape sequence \NNN for exactly three
181 octal digits reads as the character whose ASCII code is NNN. As
182 above, characters produced this way are argument constituents.
183 Backslash followed by other characters is not allowed.
184
185 * Changes to the procedure for linking libguile with your programs
186
187 ** Guile now builds and installs a shared guile library, if your
188 system support shared libraries. (It still builds a static library on
189 all systems.) Guile automatically detects whether your system
190 supports shared libraries. To prevent Guile from buildisg shared
191 libraries, pass the `--disable-shared' flag to the configure script.
192
193 Guile takes longer to compile when it builds shared libraries, because
194 it must compile every file twice --- once to produce position-
195 independent object code, and once to produce normal object code.
196
197 ** The libthreads library has been merged into libguile.
198
199 To link a program against Guile, you now need only link against
200 -lguile and -lqt; -lthreads is no longer needed. If you are using
201 autoconf to generate configuration scripts for your application, the
202 following lines should suffice to add the appropriate libraries to
203 your link command:
204
205 ### Find quickthreads and libguile.
206 AC_CHECK_LIB(qt, main)
207 AC_CHECK_LIB(guile, scm_shell)
208
209 * Changes to Scheme functions
210
211 ** Guile Scheme's special syntax for keyword objects is now optional,
212 and disabled by default.
213
214 The syntax variation from R4RS made it difficult to port some
215 interesting packages to Guile. The routines which accepted keyword
216 arguments (mostly in the module system) have been modified to also
217 accept symbols whose names begin with `:'.
218
219 To change the keyword syntax, you must first import the (ice-9 debug)
220 module:
221 (use-modules (ice-9 debug))
222
223 Then you can enable the keyword syntax as follows:
224 (read-set! keywords 'prefix)
225
226 To disable keyword syntax, do this:
227 (read-set! keywords #f)
228
229 ** Many more primitive functions accept shared substrings as
230 arguments. In the past, these functions required normal, mutable
231 strings as arguments, although they never made use of this
232 restriction.
233
234 ** The uniform array functions now operate on byte vectors. These
235 functions are `array-fill!', `serial-array-copy!', `array-copy!',
236 `serial-array-map', `array-map', `array-for-each', and
237 `array-index-map!'.
238
239 ** The new functions `trace' and `untrace' implement simple debugging
240 support for Scheme functions.
241
242 The `trace' function accepts any number of procedures as arguments,
243 and tells the Guile interpreter to display each procedure's name and
244 arguments each time the procedure is invoked. When invoked with no
245 arguments, `trace' returns the list of procedures currently being
246 traced.
247
248 The `untrace' function accepts any number of procedures as arguments,
249 and tells the Guile interpreter not to trace them any more. When
250 invoked with no arguments, `untrace' untraces all curretly traced
251 procedures.
252
253 The tracing in Guile has an advantage over most other systems: we
254 don't create new procedure objects, but mark the procedure objects
255 themselves. This means that anonymous and internal procedures can be
256 traced.
257
258 ** The function `assert-repl-prompt' has been renamed to
259 `set-repl-prompt!'. It takes one argument, PROMPT.
260 - If PROMPT is #f, the Guile read-eval-print loop will not prompt.
261 - If PROMPT is a string, we use it as a prompt.
262 - If PROMPT is a procedure accepting no arguments, we call it, and
263 display the result as a prompt.
264 - Otherwise, we display "> ".
265
266 ** The new function `eval-string' reads Scheme expressions from a
267 string and evaluates them, returning the value of the last expression
268 in the string. If the string contains no expressions, it returns an
269 unspecified value.
270
271 ** The new function `thunk?' returns true iff its argument is a
272 procedure of zero arguments.
273
274 ** `defined?' is now a builtin function, instead of syntax. This
275 means that its argument should be quoted. It returns #t iff its
276 argument is bound in the current module.
277
278 ** The new syntax `use-modules' allows you to add new modules to your
279 environment without re-typing a complete `define-module' form. It
280 accepts any number of module names as arguments, and imports their
281 public bindings into the current module.
282
283 ** The new function (module-defined? NAME MODULE) returns true iff
284 NAME, a symbol, is defined in MODULE, a module object.
285
286 ** The new function `builtin-bindings' creates and returns a hash
287 table containing copies of all the root module's bindings.
288
289 ** The new function `builtin-weak-bindings' does the same as
290 `builtin-bindings', but creates a doubly-weak hash table.
291
292 ** The `equal?' function now considers variable objects to be
293 equivalent if they have the same name and the same value.
294
295 ** The new function `command-line' returns the command-line arguments
296 given to Guile, as a list of strings.
297
298 When using guile as a script interpreter, `command-line' returns the
299 script's arguments; those processed by the interpreter (like `-s' or
300 `-c') are omitted. (In other words, you get the normal, expected
301 behavior.) Any application that uses scm_shell to process its
302 command-line arguments gets this behavior as well.
303
304 ** The new function `load-user-init' looks for a file called `.guile'
305 in the user's home directory, and loads it if it exists. This is
306 mostly for use by the code generated by scm_compile_shell_switches,
307 but we thought it might also be useful in other circumstances.
308
309 ** The new function `log10' returns the base-10 logarithm of its
310 argument.
311
312 ** Changes to I/O functions
313
314 *** The functions `read', `primitive-load', `read-and-eval!', and
315 `primitive-load-path' no longer take optional arguments controlling
316 case insensitivity and a `#' parser.
317
318 Case sensitivity is now controlled by a read option called
319 `case-insensitive'. The user can add new `#' syntaxes with the
320 `read-hash-extend' function (see below).
321
322 *** The new function `read-hash-extend' allows the user to change the
323 syntax of Guile Scheme in a somewhat controlled way.
324
325 (read-hash-extend CHAR PROC)
326 When parsing S-expressions, if we read a `#' character followed by
327 the character CHAR, use PROC to parse an object from the stream.
328 If PROC is #f, remove any parsing procedure registered for CHAR.
329
330 The reader applies PROC to two arguments: CHAR and an input port.
331
332 *** The new functions read-delimited and read-delimited! provide a
333 general mechanism for doing delimited input on streams.
334
335 (read-delimited DELIMS [PORT HANDLE-DELIM])
336 Read until we encounter one of the characters in DELIMS (a string),
337 or end-of-file. PORT is the input port to read from; it defaults to
338 the current input port. The HANDLE-DELIM parameter determines how
339 the terminating character is handled; it should be one of the
340 following symbols:
341
342 'trim omit delimiter from result
343 'peek leave delimiter character in input stream
344 'concat append delimiter character to returned value
345 'split return a pair: (RESULT . TERMINATOR)
346
347 HANDLE-DELIM defaults to 'peek.
348
349 (read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
350 A side-effecting variant of `read-delimited'.
351
352 The data is written into the string BUF at the indices in the
353 half-open interval [START, END); the default interval is the whole
354 string: START = 0 and END = (string-length BUF). The values of
355 START and END must specify a well-defined interval in BUF, i.e.
356 0 <= START <= END <= (string-length BUF).
357
358 It returns NBYTES, the number of bytes read. If the buffer filled
359 up without a delimiter character being found, it returns #f. If the
360 port is at EOF when the read starts, it returns the EOF object.
361
362 If an integer is returned (i.e., the read is successfully terminated
363 by reading a delimiter character), then the HANDLE-DELIM parameter
364 determines how to handle the terminating character. It is described
365 above, and defaults to 'peek.
366
367 (The descriptions of these functions were borrowed from the SCSH
368 manual, by Olin Shivers and Brian Carlstrom.)
369
370 *** The `%read-delimited!' function is the primitive used to implement
371 `read-delimited' and `read-delimited!'.
372
373 (%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
374
375 This returns a pair of values: (TERMINATOR . NUM-READ).
376 - TERMINATOR describes why the read was terminated. If it is a
377 character or the eof object, then that is the value that terminated
378 the read. If it is #f, the function filled the buffer without finding
379 a delimiting character.
380 - NUM-READ is the number of characters read into BUF.
381
382 If the read is successfully terminated by reading a delimiter
383 character, then the gobble? parameter determines what to do with the
384 terminating character. If true, the character is removed from the
385 input stream; if false, the character is left in the input stream
386 where a subsequent read operation will retrieve it. In either case,
387 the character is also the first value returned by the procedure call.
388
389 (The descriptions of this function was borrowed from the SCSH manual,
390 by Olin Shivers and Brian Carlstrom.)
391
392 *** The `read-line' and `read-line!' functions have changed; they now
393 trim the terminator by default; previously they appended it to the
394 returned string. For the old behavior, use (read-line PORT 'concat).
395
396 *** The functions `uniform-array-read!' and `uniform-array-write!' now
397 take new optional START and END arguments, specifying the region of
398 the array to read and write.
399
400 *** The `ungetc-char-ready?' function has been removed. We feel it's
401 inappropriate for an interface to expose implementation details this
402 way.
403
404 ** Changes to the Unix library and system call interface
405
406 *** The new fcntl function provides access to the Unix `fcntl' system
407 call.
408
409 (fcntl PORT COMMAND VALUE)
410 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
411 Values for COMMAND are:
412
413 F_DUPFD duplicate a file descriptor
414 F_GETFD read the descriptor's close-on-exec flag
415 F_SETFD set the descriptor's close-on-exec flag to VALUE
416 F_GETFL read the descriptor's flags, as set on open
417 F_SETFL set the descriptor's flags, as set on open to VALUE
418 F_GETOWN return the process ID of a socket's owner, for SIGIO
419 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
420 FD_CLOEXEC not sure what this is
421
422 For details, see the documentation for the fcntl system call.
423
424 *** The arguments to `select' have changed, for compatibility with
425 SCSH. The TIMEOUT parameter may now be non-integral, yielding the
426 expected behavior. The MILLISECONDS parameter has been changed to
427 MICROSECONDS, to more closely resemble the underlying system call.
428 The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
429 corresponding return set will be the same.
430
431 *** The arguments to the `mknod' system call have changed. They are
432 now:
433
434 (mknod PATH TYPE PERMS DEV)
435 Create a new file (`node') in the file system. PATH is the name of
436 the file to create. TYPE is the kind of file to create; it should
437 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
438 permission bits to give the newly created file. If TYPE is
439 'block-special or 'char-special, DEV specifies which device the
440 special file refers to; its interpretation depends on the kind of
441 special file being created.
442
443 *** The `fork' function has been renamed to `primitive-fork', to avoid
444 clashing with various SCSH forks.
445
446 *** The `recv' and `recvfrom' functions have been renamed to `recv!'
447 and `recvfrom!'. They no longer accept a size for a second argument;
448 you must pass a string to hold the received value. They no longer
449 return the buffer. Instead, `recv' returns the length of the message
450 received, and `recvfrom' returns a pair containing the packet's length
451 and originating address.
452
453 *** The file descriptor datatype has been removed, as have the
454 `read-fd', `write-fd', `close', `lseek', and `dup' functions.
455 We plan to replace these functions with a SCSH-compatible interface.
456
457 *** The `create' function has been removed; it's just a special case
458 of `open'.
459
460 *** There are new functions to break down process termination status
461 values. In the descriptions below, STATUS is a value returned by
462 `waitpid'.
463
464 (status:exit-val STATUS)
465 If the child process exited normally, this function returns the exit
466 code for the child process (i.e., the value passed to exit, or
467 returned from main). If the child process did not exit normally,
468 this function returns #f.
469
470 (status:stop-sig STATUS)
471 If the child process was suspended by a signal, this function
472 returns the signal that suspended the child. Otherwise, it returns
473 #f.
474
475 (status:term-sig STATUS)
476 If the child process terminated abnormally, this function returns
477 the signal that terminated the child. Otherwise, this function
478 returns false.
479
480 POSIX promises that exactly one of these functions will return true on
481 a valid STATUS value.
482
483 These functions are compatible with SCSH.
484
485 *** There are new accessors and setters for the broken-out time vectors
486 returned by `localtime', `gmtime', and that ilk. They are:
487
488 Component Accessor Setter
489 ========================= ============ ============
490 seconds tm:sec set-tm:sec
491 minutes tm:min set-tm:min
492 hours tm:hour set-tm:hour
493 day of the month tm:mday set-tm:mday
494 month tm:mon set-tm:mon
495 year tm:year set-tm:year
496 day of the week tm:wday set-tm:wday
497 day in the year tm:yday set-tm:yday
498 daylight saving time tm:isdst set-tm:isdst
499 GMT offset, seconds tm:gmtoff set-tm:gmtoff
500 name of time zone tm:zone set-tm:zone
501
502 *** There are new accessors for the vectors returned by `uname',
503 describing the host system:
504
505 Component Accessor
506 ============================================== ================
507 name of the operating system implementation utsname:sysname
508 network name of this machine utsname:nodename
509 release level of the operating system utsname:release
510 version level of the operating system utsname:version
511 machine hardware platform utsname:machine
512
513 *** There are new accessors for the vectors returned by `getpw',
514 `getpwnam', `getpwuid', and `getpwent', describing entries from the
515 system's user database:
516
517 Component Accessor
518 ====================== =================
519 user name passwd:name
520 user password passwd:passwd
521 user id passwd:uid
522 group id passwd:gid
523 real name passwd:gecos
524 home directory passwd:dir
525 shell program passwd:shell
526
527 *** There are new accessors for the vectors returned by `getgr',
528 `getgrnam', `getgrgid', and `getgrent', describing entries from the
529 system's group database:
530
531 Component Accessor
532 ======================= ============
533 group name group:name
534 group password group:passwd
535 group id group:gid
536 group members group:mem
537
538 *** There are new accessors for the vectors returned by `gethost',
539 `gethostbyaddr', `gethostbyname', and `gethostent', describing
540 internet hosts:
541
542 Component Accessor
543 ========================= ===============
544 official name of host hostent:name
545 alias list hostent:aliases
546 host address type hostent:addrtype
547 length of address hostent:length
548 list of addresses hostent:addr-list
549
550 *** There are new accessors for the vectors returned by `getnet',
551 `getnetbyaddr', `getnetbyname', and `getnetent', describing internet
552 networks:
553
554 Component Accessor
555 ========================= ===============
556 official name of net netent:name
557 alias list netent:aliases
558 net number type netent:addrtype
559 net number netent:net
560
561 *** There are new accessors for the vectors returned by `getproto',
562 `getprotobyname', `getprotobynumber', and `getprotoent', describing
563 internet protocols:
564
565 Component Accessor
566 ========================= ===============
567 official protocol name protoent:name
568 alias list protoent:aliases
569 protocol number protoent:proto
570
571 *** There are new accessors for the vectors returned by `getserv',
572 `getservbyname', `getservbyport', and `getservent', describing
573 internet protocols:
574
575 Component Accessor
576 ========================= ===============
577 official service name servent:name
578 alias list servent:aliases
579 port number servent:port
580 protocol to use servent:proto
581
582 *** There are new accessors for the sockaddr structures returned by
583 `accept', `getsockname', `getpeername', `recvfrom!':
584
585 Component Accessor
586 ======================================== ===============
587 address format (`family') sockaddr:fam
588 path, for file domain addresses sockaddr:path
589 address, for internet domain addresses sockaddr:addr
590 TCP or UDP port, for internet sockaddr:port
591
592 *** The `getpwent', `getgrent', `gethostent', `getnetent',
593 `getprotoent', and `getservent' functions now return #f at the end of
594 the user database. (They used to throw an exception.)
595
596 Note that calling MUMBLEent function is equivalent to calling the
597 corresponding MUMBLE function with no arguments.
598
599 *** The `setpwent', `setgrent', `sethostent', `setnetent',
600 `setprotoent', and `setservent' routines now take no arguments.
601
602 *** The `gethost', `getproto', `getnet', and `getserv' functions now
603 provide more useful information when they throw an exception.
604
605 *** The `lnaof' function has been renamed to `inet-lnaof'.
606
607 *** Guile now claims to have the `current-time' feature.
608
609 *** The `mktime' function now takes an optional second argument ZONE,
610 giving the time zone to use for the conversion. ZONE should be a
611 string, in the same format as expected for the "TZ" environment variable.
612
613 *** The `strptime' function now returns a pair (TIME . COUNT), where
614 TIME is the parsed time as a vector, and COUNT is the number of
615 characters from the string left unparsed. This function used to
616 return the remaining characters as a string.
617
618 *** The `gettimeofday' function has replaced the old `time+ticks' function.
619 The return value is now (SECONDS . MICROSECONDS); the fractional
620 component is no longer expressed in "ticks".
621
622 *** The `ticks/sec' constant has been removed, in light of the above change.
623
624 * Changes to the gh_ interface
625
626 ** gh_eval_str() now returns an SCM object which is the result of the
627 evaluation
628
629 ** gh_scm2str() now copies the Scheme data to a caller-provided C
630 array
631
632 ** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
633 and returns the array
634
635 ** gh_scm2str0() is gone: there is no need to distinguish
636 null-terminated from non-null-terminated, since gh_scm2newstr() allows
637 the user to interpret the data both ways.
638
639 * Changes to the scm_ interface
640
641 ** The new function scm_symbol_value0 provides an easy way to get a
642 symbol's value from C code:
643
644 SCM scm_symbol_value0 (char *NAME)
645 Return the value of the symbol named by the null-terminated string
646 NAME in the current module. If the symbol named NAME is unbound in
647 the current module, return SCM_UNDEFINED.
648
649 ** The new function scm_sysintern0 creates new top-level variables,
650 without assigning them a value.
651
652 SCM scm_sysintern0 (char *NAME)
653 Create a new Scheme top-level variable named NAME. NAME is a
654 null-terminated string. Return the variable's value cell.
655
656 ** The function scm_internal_catch is the guts of catch. It handles
657 all the mechanics of setting up a catch target, invoking the catch
658 body, and perhaps invoking the handler if the body does a throw.
659
660 The function is designed to be usable from C code, but is general
661 enough to implement all the semantics Guile Scheme expects from throw.
662
663 TAG is the catch tag. Typically, this is a symbol, but this function
664 doesn't actually care about that.
665
666 BODY is a pointer to a C function which runs the body of the catch;
667 this is the code you can throw from. We call it like this:
668 BODY (BODY_DATA, JMPBUF)
669 where:
670 BODY_DATA is just the BODY_DATA argument we received; we pass it
671 through to BODY as its first argument. The caller can make
672 BODY_DATA point to anything useful that BODY might need.
673 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
674 which we have just created and initialized.
675
676 HANDLER is a pointer to a C function to deal with a throw to TAG,
677 should one occur. We call it like this:
678 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
679 where
680 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
681 same idea as BODY_DATA above.
682 THROWN_TAG is the tag that the user threw to; usually this is
683 TAG, but it could be something else if TAG was #t (i.e., a
684 catch-all), or the user threw to a jmpbuf.
685 THROW_ARGS is the list of arguments the user passed to the THROW
686 function.
687
688 BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
689 is just a pointer we pass through to HANDLER. We don't actually
690 use either of those pointers otherwise ourselves. The idea is
691 that, if our caller wants to communicate something to BODY or
692 HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
693 HANDLER can then use. Think of it as a way to make BODY and
694 HANDLER closures, not just functions; MUMBLE_DATA points to the
695 enclosed variables.
696
697 Of course, it's up to the caller to make sure that any data a
698 MUMBLE_DATA needs is protected from GC. A common way to do this is
699 to make MUMBLE_DATA a pointer to data stored in an automatic
700 structure variable; since the collector must scan the stack for
701 references anyway, this assures that any references in MUMBLE_DATA
702 will be found.
703
704 ** The new function scm_internal_lazy_catch is exactly like
705 scm_internal_catch, except:
706
707 - It does not unwind the stack (this is the major difference).
708 - If handler returns, its value is returned from the throw.
709 - BODY always receives #f as its JMPBUF argument (since there's no
710 jmpbuf associated with a lazy catch, because we don't unwind the
711 stack.)
712
713 ** scm_body_thunk is a new body function you can pass to
714 scm_internal_catch if you want the body to be like Scheme's `catch'
715 --- a thunk, or a function of one argument if the tag is #f.
716
717 BODY_DATA is a pointer to a scm_body_thunk_data structure, which
718 contains the Scheme procedure to invoke as the body, and the tag
719 we're catching. If the tag is #f, then we pass JMPBUF (created by
720 scm_internal_catch) to the body procedure; otherwise, the body gets
721 no arguments.
722
723 ** scm_handle_by_proc is a new handler function you can pass to
724 scm_internal_catch if you want the handler to act like Scheme's catch
725 --- call a procedure with the tag and the throw arguments.
726
727 If the user does a throw to this catch, this function runs a handler
728 procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
729 variable holding the Scheme procedure object to invoke. It ought to
730 be a pointer to an automatic variable (i.e., one living on the stack),
731 or the procedure object should be otherwise protected from GC.
732
733 ** scm_handle_by_message is a new handler function to use with
734 `scm_internal_catch' if you want Guile to print a message and die.
735 It's useful for dealing with throws to uncaught keys at the top level.
736
737 HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
738 message header to print; if zero, we use "guile" instead. That
739 text is followed by a colon, then the message described by ARGS.
740
741 ** The return type of scm_boot_guile is now void; the function does
742 not return a value, and indeed, never returns at all.
743
744 ** The new function scm_shell makes it easy for user applications to
745 process command-line arguments in a way that is compatible with the
746 stand-alone guile interpreter (which is in turn compatible with SCSH,
747 the Scheme shell).
748
749 To use the scm_shell function, first initialize any guile modules
750 linked into your application, and then call scm_shell with the values
751 of ARGC and ARGV your `main' function received. scm_shell will adding
752 any SCSH-style meta-arguments from the top of the script file to the
753 argument vector, and then process the command-line arguments. This
754 generally means loading a script file or starting up an interactive
755 command interpreter. For details, see "Changes to the stand-alone
756 interpreter" above.
757
758 ** The new functions scm_get_meta_args and scm_count_argv help you
759 implement the SCSH-style meta-argument, `\'.
760
761 char **scm_get_meta_args (int ARGC, char **ARGV)
762 If the second element of ARGV is a string consisting of a single
763 backslash character (i.e. "\\" in Scheme notation), open the file
764 named by the following argument, parse arguments from it, and return
765 the spliced command line. The returned array is terminated by a
766 null pointer.
767
768 For details of argument parsing, see above, under "guile now accepts
769 command-line arguments compatible with SCSH..."
770
771 int scm_count_argv (char **ARGV)
772 Count the arguments in ARGV, assuming it is terminated by a null
773 pointer.
774
775 For an example of how these functions might be used, see the source
776 code for the function scm_shell in libguile/script.c.
777
778 You will usually want to use scm_shell instead of calling this
779 function yourself.
780
781 ** The new function scm_compile_shell_switches turns an array of
782 command-line arguments into Scheme code to carry out the actions they
783 describe. Given ARGC and ARGV, it returns a Scheme expression to
784 evaluate, and calls scm_set_program_arguments to make any remaining
785 command-line arguments available to the Scheme code. For example,
786 given the following arguments:
787
788 -e main -s ekko a speckled gecko
789
790 scm_set_program_arguments will return the following expression:
791
792 (begin (load "ekko") (main (command-line)) (quit))
793
794 You will usually want to use scm_shell instead of calling this
795 function yourself.
796
797 ** The function scm_shell_usage prints a usage message appropriate for
798 an interpreter that uses scm_compile_shell_switches to handle its
799 command-line arguments.
800
801 void scm_shell_usage (int FATAL, char *MESSAGE)
802 Print a usage message to the standard error output. If MESSAGE is
803 non-zero, write it before the usage message, followed by a newline.
804 If FATAL is non-zero, exit the process, using FATAL as the
805 termination status. (If you want to be compatible with Guile,
806 always use 1 as the exit status when terminating due to command-line
807 usage problems.)
808
809 You will usually want to use scm_shell instead of calling this
810 function yourself.
811
812 ** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
813 expressions. It used to return SCM_EOL. Earth-shattering.
814
815 ** The macros for declaring scheme objects in C code have been
816 rearranged slightly. They are now:
817
818 SCM_SYMBOL (C_NAME, SCHEME_NAME)
819 Declare a static SCM variable named C_NAME, and initialize it to
820 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
821 be a C identifier, and SCHEME_NAME should be a C string.
822
823 SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
824 Just like SCM_SYMBOL, but make C_NAME globally visible.
825
826 SCM_VCELL (C_NAME, SCHEME_NAME)
827 Create a global variable at the Scheme level named SCHEME_NAME.
828 Declare a static SCM variable named C_NAME, and initialize it to
829 point to the Scheme variable's value cell.
830
831 SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
832 Just like SCM_VCELL, but make C_NAME globally visible.
833
834 The `guile-snarf' script writes initialization code for these macros
835 to its standard output, given C source code as input.
836
837 The SCM_GLOBAL macro is gone.
838
839 ** The scm_read_line and scm_read_line_x functions have been replaced
840 by Scheme code based on the %read-delimited! procedure (known to C
841 code as scm_read_delimited_x). See its description above for more
842 information.
843
844 ** The function scm_sys_open has been renamed to scm_open. It now
845 returns a port instead of an FD object.
846
847 * The dynamic linking support has changed. For more information, see
848 libguile/DYNAMIC-LINKING.
849
850 \f
851 Guile 1.0b3
852
853 User-visible changes from Thursday, September 5, 1996 until Guile 1.0
854 (Sun 5 Jan 1997):
855
856 * Changes to the 'guile' program:
857
858 ** Guile now loads some new files when it starts up. Guile first
859 searches the load path for init.scm, and loads it if found. Then, if
860 Guile is not being used to execute a script, and the user's home
861 directory contains a file named `.guile', Guile loads that.
862
863 ** You can now use Guile as a shell script interpreter.
864
865 To paraphrase the SCSH manual:
866
867 When Unix tries to execute an executable file whose first two
868 characters are the `#!', it treats the file not as machine code to
869 be directly executed by the native processor, but as source code
870 to be executed by some interpreter. The interpreter to use is
871 specified immediately after the #! sequence on the first line of
872 the source file. The kernel reads in the name of the interpreter,
873 and executes that instead. It passes the interpreter the source
874 filename as its first argument, with the original arguments
875 following. Consult the Unix man page for the `exec' system call
876 for more information.
877
878 Now you can use Guile as an interpreter, using a mechanism which is a
879 compatible subset of that provided by SCSH.
880
881 Guile now recognizes a '-s' command line switch, whose argument is the
882 name of a file of Scheme code to load. It also treats the two
883 characters `#!' as the start of a comment, terminated by `!#'. Thus,
884 to make a file of Scheme code directly executable by Unix, insert the
885 following two lines at the top of the file:
886
887 #!/usr/local/bin/guile -s
888 !#
889
890 Guile treats the argument of the `-s' command-line switch as the name
891 of a file of Scheme code to load, and treats the sequence `#!' as the
892 start of a block comment, terminated by `!#'.
893
894 For example, here's a version of 'echo' written in Scheme:
895
896 #!/usr/local/bin/guile -s
897 !#
898 (let loop ((args (cdr (program-arguments))))
899 (if (pair? args)
900 (begin
901 (display (car args))
902 (if (pair? (cdr args))
903 (display " "))
904 (loop (cdr args)))))
905 (newline)
906
907 Why does `#!' start a block comment terminated by `!#', instead of the
908 end of the line? That is the notation SCSH uses, and although we
909 don't yet support the other SCSH features that motivate that choice,
910 we would like to be backward-compatible with any existing Guile
911 scripts once we do. Furthermore, if the path to Guile on your system
912 is too long for your kernel, you can start the script with this
913 horrible hack:
914
915 #!/bin/sh
916 exec /really/long/path/to/guile -s "$0" ${1+"$@"}
917 !#
918
919 Note that some very old Unix systems don't support the `#!' syntax.
920
921
922 ** You can now run Guile without installing it.
923
924 Previous versions of the interactive Guile interpreter (`guile')
925 couldn't start up unless Guile's Scheme library had been installed;
926 they used the value of the environment variable `SCHEME_LOAD_PATH'
927 later on in the startup process, but not to find the startup code
928 itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
929 code.
930
931 To run Guile without installing it, build it in the normal way, and
932 then set the environment variable `SCHEME_LOAD_PATH' to a
933 colon-separated list of directories, including the top-level directory
934 of the Guile sources. For example, if you unpacked Guile so that the
935 full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
936 you might say
937
938 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
939
940
941 ** Guile's read-eval-print loop no longer prints #<unspecified>
942 results. If the user wants to see this, she can evaluate the
943 expression (assert-repl-print-unspecified #t), perhaps in her startup
944 file.
945
946 ** Guile no longer shows backtraces by default when an error occurs;
947 however, it does display a message saying how to get one, and how to
948 request that they be displayed by default. After an error, evaluate
949 (backtrace)
950 to see a backtrace, and
951 (debug-enable 'backtrace)
952 to see them by default.
953
954
955
956 * Changes to Guile Scheme:
957
958 ** Guile now distinguishes between #f and the empty list.
959
960 This is for compatibility with the IEEE standard, the (possibly)
961 upcoming Revised^5 Report on Scheme, and many extant Scheme
962 implementations.
963
964 Guile used to have #f and '() denote the same object, to make Scheme's
965 type system more compatible with Emacs Lisp's. However, the change
966 caused too much trouble for Scheme programmers, and we found another
967 way to reconcile Emacs Lisp with Scheme that didn't require this.
968
969
970 ** Guile's delq, delv, delete functions, and their destructive
971 counterparts, delq!, delv!, and delete!, now remove all matching
972 elements from the list, not just the first. This matches the behavior
973 of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
974 functions which inspired them.
975
976 I recognize that this change may break code in subtle ways, but it
977 seems best to make the change before the FSF's first Guile release,
978 rather than after.
979
980
981 ** The compiled-library-path function has been deleted from libguile.
982
983 ** The facilities for loading Scheme source files have changed.
984
985 *** The variable %load-path now tells Guile which directories to search
986 for Scheme code. Its value is a list of strings, each of which names
987 a directory.
988
989 *** The variable %load-extensions now tells Guile which extensions to
990 try appending to a filename when searching the load path. Its value
991 is a list of strings. Its default value is ("" ".scm").
992
993 *** (%search-load-path FILENAME) searches the directories listed in the
994 value of the %load-path variable for a Scheme file named FILENAME,
995 with all the extensions listed in %load-extensions. If it finds a
996 match, then it returns its full filename. If FILENAME is absolute, it
997 returns it unchanged. Otherwise, it returns #f.
998
999 %search-load-path will not return matches that refer to directories.
1000
1001 *** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
1002 uses %seach-load-path to find a file named FILENAME, and loads it if
1003 it finds it. If it can't read FILENAME for any reason, it throws an
1004 error.
1005
1006 The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
1007 `read' function.
1008
1009 *** load uses the same searching semantics as primitive-load.
1010
1011 *** The functions %try-load, try-load-with-path, %load, load-with-path,
1012 basic-try-load-with-path, basic-load-with-path, try-load-module-with-
1013 path, and load-module-with-path have been deleted. The functions
1014 above should serve their purposes.
1015
1016 *** If the value of the variable %load-hook is a procedure,
1017 `primitive-load' applies its value to the name of the file being
1018 loaded (without the load path directory name prepended). If its value
1019 is #f, it is ignored. Otherwise, an error occurs.
1020
1021 This is mostly useful for printing load notification messages.
1022
1023
1024 ** The function `eval!' is no longer accessible from the scheme level.
1025 We can't allow operations which introduce glocs into the scheme level,
1026 because Guile's type system can't handle these as data. Use `eval' or
1027 `read-and-eval!' (see below) as replacement.
1028
1029 ** The new function read-and-eval! reads an expression from PORT,
1030 evaluates it, and returns the result. This is more efficient than
1031 simply calling `read' and `eval', since it is not necessary to make a
1032 copy of the expression for the evaluator to munge.
1033
1034 Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
1035 for the `read' function.
1036
1037
1038 ** The function `int?' has been removed; its definition was identical
1039 to that of `integer?'.
1040
1041 ** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
1042 use the R4RS names for these functions.
1043
1044 ** The function object-properties no longer returns the hash handle;
1045 it simply returns the object's property list.
1046
1047 ** Many functions have been changed to throw errors, instead of
1048 returning #f on failure. The point of providing exception handling in
1049 the language is to simplify the logic of user code, but this is less
1050 useful if Guile's primitives don't throw exceptions.
1051
1052 ** The function `fileno' has been renamed from `%fileno'.
1053
1054 ** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
1055
1056
1057 * Changes to Guile's C interface:
1058
1059 ** The library's initialization procedure has been simplified.
1060 scm_boot_guile now has the prototype:
1061
1062 void scm_boot_guile (int ARGC,
1063 char **ARGV,
1064 void (*main_func) (),
1065 void *closure);
1066
1067 scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
1068 MAIN_FUNC should do all the work of the program (initializing other
1069 packages, reading user input, etc.) before returning. When MAIN_FUNC
1070 returns, call exit (0); this function never returns. If you want some
1071 other exit value, MAIN_FUNC may call exit itself.
1072
1073 scm_boot_guile arranges for program-arguments to return the strings
1074 given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
1075 scm_set_program_arguments with the final list, so Scheme code will
1076 know which arguments have been processed.
1077
1078 scm_boot_guile establishes a catch-all catch handler which prints an
1079 error message and exits the process. This means that Guile exits in a
1080 coherent way when system errors occur and the user isn't prepared to
1081 handle it. If the user doesn't like this behavior, they can establish
1082 their own universal catcher in MAIN_FUNC to shadow this one.
1083
1084 Why must the caller do all the real work from MAIN_FUNC? The garbage
1085 collector assumes that all local variables of type SCM will be above
1086 scm_boot_guile's stack frame on the stack. If you try to manipulate
1087 SCM values after this function returns, it's the luck of the draw
1088 whether the GC will be able to find the objects you allocate. So,
1089 scm_boot_guile function exits, rather than returning, to discourage
1090 people from making that mistake.
1091
1092 The IN, OUT, and ERR arguments were removed; there are other
1093 convenient ways to override these when desired.
1094
1095 The RESULT argument was deleted; this function should never return.
1096
1097 The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
1098 general.
1099
1100
1101 ** Guile's header files should no longer conflict with your system's
1102 header files.
1103
1104 In order to compile code which #included <libguile.h>, previous
1105 versions of Guile required you to add a directory containing all the
1106 Guile header files to your #include path. This was a problem, since
1107 Guile's header files have names which conflict with many systems'
1108 header files.
1109
1110 Now only <libguile.h> need appear in your #include path; you must
1111 refer to all Guile's other header files as <libguile/mumble.h>.
1112 Guile's installation procedure puts libguile.h in $(includedir), and
1113 the rest in $(includedir)/libguile.
1114
1115
1116 ** Two new C functions, scm_protect_object and scm_unprotect_object,
1117 have been added to the Guile library.
1118
1119 scm_protect_object (OBJ) protects OBJ from the garbage collector.
1120 OBJ will not be freed, even if all other references are dropped,
1121 until someone does scm_unprotect_object (OBJ). Both functions
1122 return OBJ.
1123
1124 Note that calls to scm_protect_object do not nest. You can call
1125 scm_protect_object any number of times on a given object, and the
1126 next call to scm_unprotect_object will unprotect it completely.
1127
1128 Basically, scm_protect_object and scm_unprotect_object just
1129 maintain a list of references to things. Since the GC knows about
1130 this list, all objects it mentions stay alive. scm_protect_object
1131 adds its argument to the list; scm_unprotect_object remove its
1132 argument from the list.
1133
1134
1135 ** scm_eval_0str now returns the value of the last expression
1136 evaluated.
1137
1138 ** The new function scm_read_0str reads an s-expression from a
1139 null-terminated string, and returns it.
1140
1141 ** The new function `scm_stdio_to_port' converts a STDIO file pointer
1142 to a Scheme port object.
1143
1144 ** The new function `scm_set_program_arguments' allows C code to set
1145 the value teruturned by the Scheme `program-arguments' function.
1146
1147 \f
1148 Older changes:
1149
1150 * Guile no longer includes sophisticated Tcl/Tk support.
1151
1152 The old Tcl/Tk support was unsatisfying to us, because it required the
1153 user to link against the Tcl library, as well as Tk and Guile. The
1154 interface was also un-lispy, in that it preserved Tcl/Tk's practice of
1155 referring to widgets by names, rather than exporting widgets to Scheme
1156 code as a special datatype.
1157
1158 In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
1159 maintainers described some very interesting changes in progress to the
1160 Tcl/Tk internals, which would facilitate clean interfaces between lone
1161 Tk and other interpreters --- even for garbage-collected languages
1162 like Scheme. They expected the new Tk to be publicly available in the
1163 fall of 1996.
1164
1165 Since it seems that Guile might soon have a new, cleaner interface to
1166 lone Tk, and that the old Guile/Tk glue code would probably need to be
1167 completely rewritten, we (Jim Blandy and Richard Stallman) have
1168 decided not to support the old code. We'll spend the time instead on
1169 a good interface to the newer Tk, as soon as it is available.
1170
1171 Until then, gtcltk-lib provides trivial, low-maintenance functionality.
1172
1173 \f
1174 Copyright information:
1175
1176 Copyright (C) 1996,1997 Free Software Foundation, Inc.
1177
1178 Permission is granted to anyone to make or distribute verbatim copies
1179 of this document as received, in any medium, provided that the
1180 copyright notice and this permission notice are preserved,
1181 thus giving the recipient permission to redistribute in turn.
1182
1183 Permission is granted to distribute modified versions
1184 of this document, or of portions of it,
1185 under the above conditions, provided also that they
1186 carry prominent notices stating who last changed them.
1187
1188 \f
1189 Local variables:
1190 mode: outline
1191 paragraph-separate: "[ \f]*$"
1192 end:
1193