* scmsigs.h, async.h: updated.
[bpt/guile.git] / NEWS
CommitLineData
f7b47737
JB
1Guile NEWS --- history of user-visible changes. -*- text -*-
2Copyright (C) 1996, 1997 Free Software Foundation, Inc.
5c54da76
JB
3See the end for copying conditions.
4
16f2ebea 5Please send Guile bug reports to bug-guile@prep.ai.mit.edu.
5c54da76 6\f
737c9113 7Changes in Guile 1.2:
cf78e9e8 8
737c9113
JB
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
b83b8bee
JB
15* Changes to Scheme functions and syntax
16
17** Guile now supports a new R4RS-compliant syntax for keywords. A
18token of the form #:NAME, where NAME has the same syntax as a Scheme
19symbol, is the external representation of the keyword named NAME.
20Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
21keyword objects can be read back into Guile. When used in an
22expression, keywords are self-quoting objects.
b83b8bee
JB
23
24Guile suports this read syntax, and uses this print syntax, regardless
25of the current setting of the `keyword' read option. The `keyword'
26read option only controls whether Guile recognizes the `:NAME' syntax,
27which is incompatible with R4RS. (R4RS says such token represent
28symbols.)
737c9113
JB
29
30** Guile has regular expression support again. Guile 1.0 included
31functions for matching regular expressions, based on the Rx library.
32In Guile 1.1, the Guile/Rx interface was removed to simplify the
33distribution, and thus Guile had no regular expression support. Guile
341.2 now adds back the most commonly used functions, and supports all
35of 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
cf78e9e8 42
e1a191a8
GH
43* Changes to system call interfaces:
44
45** The value returned by `raise' is now unspecified. It throws an exception
46if an error occurs.
47
48** A new procedure `sigaction' can be used to install signal handlers
49(documentation to be provided).
50
cf78e9e8
JB
51\f
52Changes in Guile 1.1 (Fri May 16 1997):
f3b1485f
JB
53
54* Changes to the distribution.
55
56The Guile 1.0 distribution has been split up into several smaller
57pieces:
58guile-core --- the Guile interpreter itself.
59guile-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.
62guile-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
095936d2
JB
67This NEWS file describes the changes made to guile-core since the 1.0
68release.
69
48d224d7
JB
70We no longer distribute the documentation, since it was either out of
71date, or incomplete. As soon as we have current documentation, we
72will distribute it.
73
f3b1485f
JB
74* Changes to the stand-alone interpreter
75
48d224d7
JB
76** guile now accepts command-line arguments compatible with SCSH, Olin
77Shivers' Scheme Shell.
78
79In general, arguments are evaluated from left to right, but there are
80exceptions. The following switches stop argument processing, and
81stash all remaining command-line arguments as the value returned by
82the (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
87The 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
97So, for example, here is a Guile script named `ekko' (thanks, Olin)
98which 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
109Suppose we invoke this script as follows:
110
111 ekko a speckled gecko
112
113Through the magic of Unix script processing (triggered by the `#!'
114token at the top of the file), /usr/local/bin/guile receives the
115following list of command-line arguments:
116
117 ("-s" "./ekko" "a" "speckled" "gecko")
118
119Unix inserts the name of the script after the argument specified on
120the first line of the file (in this case, "-s"), and then follows that
121with the arguments given to the script. Guile loads the script, which
122defines the `main' function, and then applies it to the list of
123remaining command-line arguments, ("a" "speckled" "gecko").
124
095936d2
JB
125In Unix, the first line of a script file must take the following form:
126
127#!INTERPRETER ARGUMENT
128
129where INTERPRETER is the absolute filename of the interpreter
130executable, and ARGUMENT is a single command-line argument to pass to
131the interpreter.
132
133You may only pass one argument to the interpreter, and its length is
134limited. These restrictions can be annoying to work around, so Guile
135provides a general mechanism (borrowed from, and compatible with,
136SCSH) for circumventing them.
137
138If the ARGUMENT in a Guile script is a single backslash character,
139`\', Guile will open the script file, parse arguments from its second
140and subsequent lines, and replace the `\' with them. So, for example,
141here 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
151If the user invokes this script as follows:
152
153 ekko a speckled gecko
154
155Unix expands this into
156
157 /usr/local/bin/guile \ ekko a speckled gecko
158
159When Guile sees the `\' argument, it replaces it with the arguments
160read from the second line of the script, producing:
161
162 /usr/local/bin/guile -e main -s ekko a speckled gecko
163
164This tells Guile to load the `ekko' script, and apply the function
165`main' to the argument list ("a" "speckled" "gecko").
166
167Here 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
48d224d7
JB
185* Changes to the procedure for linking libguile with your programs
186
187** Guile now builds and installs a shared guile library, if your
188system support shared libraries. (It still builds a static library on
189all systems.) Guile automatically detects whether your system
190supports shared libraries. To prevent Guile from buildisg shared
191libraries, pass the `--disable-shared' flag to the configure script.
192
193Guile takes longer to compile when it builds shared libraries, because
194it must compile every file twice --- once to produce position-
195independent object code, and once to produce normal object code.
196
197** The libthreads library has been merged into libguile.
198
199To link a program against Guile, you now need only link against
200-lguile and -lqt; -lthreads is no longer needed. If you are using
201autoconf to generate configuration scripts for your application, the
202following lines should suffice to add the appropriate libraries to
203your link command:
204
205### Find quickthreads and libguile.
206AC_CHECK_LIB(qt, main)
207AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
208
209* Changes to Scheme functions
210
095936d2
JB
211** Guile Scheme's special syntax for keyword objects is now optional,
212and disabled by default.
213
214The syntax variation from R4RS made it difficult to port some
215interesting packages to Guile. The routines which accepted keyword
216arguments (mostly in the module system) have been modified to also
217accept symbols whose names begin with `:'.
218
219To change the keyword syntax, you must first import the (ice-9 debug)
220module:
221 (use-modules (ice-9 debug))
222
223Then you can enable the keyword syntax as follows:
224 (read-set! keywords 'prefix)
225
226To disable keyword syntax, do this:
227 (read-set! keywords #f)
228
229** Many more primitive functions accept shared substrings as
230arguments. In the past, these functions required normal, mutable
231strings as arguments, although they never made use of this
232restriction.
233
234** The uniform array functions now operate on byte vectors. These
235functions 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
240support for Scheme functions.
241
242The `trace' function accepts any number of procedures as arguments,
243and tells the Guile interpreter to display each procedure's name and
244arguments each time the procedure is invoked. When invoked with no
245arguments, `trace' returns the list of procedures currently being
246traced.
247
248The `untrace' function accepts any number of procedures as arguments,
249and tells the Guile interpreter not to trace them any more. When
250invoked with no arguments, `untrace' untraces all curretly traced
251procedures.
252
253The tracing in Guile has an advantage over most other systems: we
254don't create new procedure objects, but mark the procedure objects
255themselves. This means that anonymous and internal procedures can be
256traced.
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
267string and evaluates them, returning the value of the last expression
268in the string. If the string contains no expressions, it returns an
269unspecified value.
270
271** The new function `thunk?' returns true iff its argument is a
272procedure of zero arguments.
273
274** `defined?' is now a builtin function, instead of syntax. This
275means that its argument should be quoted. It returns #t iff its
276argument is bound in the current module.
277
278** The new syntax `use-modules' allows you to add new modules to your
279environment without re-typing a complete `define-module' form. It
280accepts any number of module names as arguments, and imports their
281public bindings into the current module.
282
283** The new function (module-defined? NAME MODULE) returns true iff
284NAME, a symbol, is defined in MODULE, a module object.
285
286** The new function `builtin-bindings' creates and returns a hash
287table 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
293equivalent if they have the same name and the same value.
294
295** The new function `command-line' returns the command-line arguments
296given to Guile, as a list of strings.
297
298When using guile as a script interpreter, `command-line' returns the
299script's arguments; those processed by the interpreter (like `-s' or
300`-c') are omitted. (In other words, you get the normal, expected
301behavior.) Any application that uses scm_shell to process its
302command-line arguments gets this behavior as well.
303
304** The new function `load-user-init' looks for a file called `.guile'
305in the user's home directory, and loads it if it exists. This is
306mostly for use by the code generated by scm_compile_shell_switches,
307but we thought it might also be useful in other circumstances.
308
309** The new function `log10' returns the base-10 logarithm of its
310argument.
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
316case insensitivity and a `#' parser.
317
318Case 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
323syntax 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
333general 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
368manual, 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
375This 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
382If the read is successfully terminated by reading a delimiter
383character, then the gobble? parameter determines what to do with the
384terminating character. If true, the character is removed from the
385input stream; if false, the character is left in the input stream
386where a subsequent read operation will retrieve it. In either case,
387the character is also the first value returned by the procedure call.
388
389(The descriptions of this function was borrowed from the SCSH manual,
390by Olin Shivers and Brian Carlstrom.)
391
392*** The `read-line' and `read-line!' functions have changed; they now
393trim the terminator by default; previously they appended it to the
394returned string. For the old behavior, use (read-line PORT 'concat).
395
396*** The functions `uniform-array-read!' and `uniform-array-write!' now
397take new optional START and END arguments, specifying the region of
398the array to read and write.
399
f348c807
JB
400*** The `ungetc-char-ready?' function has been removed. We feel it's
401inappropriate for an interface to expose implementation details this
402way.
095936d2
JB
403
404** Changes to the Unix library and system call interface
405
406*** The new fcntl function provides access to the Unix `fcntl' system
407call.
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
422For details, see the documentation for the fcntl system call.
423
424*** The arguments to `select' have changed, for compatibility with
425SCSH. The TIMEOUT parameter may now be non-integral, yielding the
426expected behavior. The MILLISECONDS parameter has been changed to
427MICROSECONDS, to more closely resemble the underlying system call.
428The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
429corresponding return set will be the same.
430
431*** The arguments to the `mknod' system call have changed. They are
432now:
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
444clashing with various SCSH forks.
445
446*** The `recv' and `recvfrom' functions have been renamed to `recv!'
447and `recvfrom!'. They no longer accept a size for a second argument;
448you must pass a string to hold the received value. They no longer
449return the buffer. Instead, `recv' returns the length of the message
450received, and `recvfrom' returns a pair containing the packet's length
451and originating address.
452
453*** The file descriptor datatype has been removed, as have the
454`read-fd', `write-fd', `close', `lseek', and `dup' functions.
455We plan to replace these functions with a SCSH-compatible interface.
456
457*** The `create' function has been removed; it's just a special case
458of `open'.
459
460*** There are new functions to break down process termination status
461values. 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
480POSIX promises that exactly one of these functions will return true on
481a valid STATUS value.
482
483These functions are compatible with SCSH.
484
485*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
486returned 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
095936d2
JB
502*** There are new accessors for the vectors returned by `uname',
503describing the host system:
48d224d7
JB
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
095936d2
JB
513*** There are new accessors for the vectors returned by `getpw',
514`getpwnam', `getpwuid', and `getpwent', describing entries from the
515system'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
529system'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
540internet 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
552networks:
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
563internet 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
573internet 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
594the user database. (They used to throw an exception.)
595
596Note that calling MUMBLEent function is equivalent to calling the
597corresponding 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
603provide 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,
610giving the time zone to use for the conversion. ZONE should be a
611string, in the same format as expected for the "TZ" environment variable.
612
613*** The `strptime' function now returns a pair (TIME . COUNT), where
614TIME is the parsed time as a vector, and COUNT is the number of
615characters from the string left unparsed. This function used to
616return the remaining characters as a string.
617
618*** The `gettimeofday' function has replaced the old `time+ticks' function.
619The return value is now (SECONDS . MICROSECONDS); the fractional
620component is no longer expressed in "ticks".
621
622*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 623
ea00ecba
MG
624* Changes to the gh_ interface
625
626** gh_eval_str() now returns an SCM object which is the result of the
627evaluation
628
aaef0d2a
MG
629** gh_scm2str() now copies the Scheme data to a caller-provided C
630array
631
632** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
633and returns the array
634
635** gh_scm2str0() is gone: there is no need to distinguish
636null-terminated from non-null-terminated, since gh_scm2newstr() allows
637the user to interpret the data both ways.
638
f3b1485f
JB
639* Changes to the scm_ interface
640
095936d2
JB
641** The new function scm_symbol_value0 provides an easy way to get a
642symbol's value from C code:
643
644SCM 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,
650without assigning them a value.
651
652SCM 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
657all the mechanics of setting up a catch target, invoking the catch
658body, and perhaps invoking the handler if the body does a throw.
659
660The function is designed to be usable from C code, but is general
661enough to implement all the semantics Guile Scheme expects from throw.
662
663TAG is the catch tag. Typically, this is a symbol, but this function
664doesn't actually care about that.
665
666BODY is a pointer to a C function which runs the body of the catch;
667this is the code you can throw from. We call it like this:
668 BODY (BODY_DATA, JMPBUF)
669where:
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
676HANDLER is a pointer to a C function to deal with a throw to TAG,
677should one occur. We call it like this:
678 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
679where
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
688BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
689is just a pointer we pass through to HANDLER. We don't actually
690use either of those pointers otherwise ourselves. The idea is
691that, if our caller wants to communicate something to BODY or
692HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
693HANDLER can then use. Think of it as a way to make BODY and
694HANDLER closures, not just functions; MUMBLE_DATA points to the
695enclosed variables.
696
697Of course, it's up to the caller to make sure that any data a
698MUMBLE_DATA needs is protected from GC. A common way to do this is
699to make MUMBLE_DATA a pointer to data stored in an automatic
700structure variable; since the collector must scan the stack for
701references anyway, this assures that any references in MUMBLE_DATA
702will be found.
703
704** The new function scm_internal_lazy_catch is exactly like
705scm_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
714scm_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
717BODY_DATA is a pointer to a scm_body_thunk_data structure, which
718contains the Scheme procedure to invoke as the body, and the tag
719we're catching. If the tag is #f, then we pass JMPBUF (created by
720scm_internal_catch) to the body procedure; otherwise, the body gets
721no arguments.
722
723** scm_handle_by_proc is a new handler function you can pass to
724scm_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
727If the user does a throw to this catch, this function runs a handler
728procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
729variable holding the Scheme procedure object to invoke. It ought to
730be a pointer to an automatic variable (i.e., one living on the stack),
731or 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.
735It's useful for dealing with throws to uncaught keys at the top level.
736
737HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
738message header to print; if zero, we use "guile" instead. That
739text 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
742not return a value, and indeed, never returns at all.
743
f3b1485f
JB
744** The new function scm_shell makes it easy for user applications to
745process command-line arguments in a way that is compatible with the
746stand-alone guile interpreter (which is in turn compatible with SCSH,
747the Scheme shell).
748
749To use the scm_shell function, first initialize any guile modules
750linked into your application, and then call scm_shell with the values
751of ARGC and ARGV your `main' function received. scm_shell will adding
752any SCSH-style meta-arguments from the top of the script file to the
753argument vector, and then process the command-line arguments. This
754generally means loading a script file or starting up an interactive
755command interpreter. For details, see "Changes to the stand-alone
756interpreter" above.
757
095936d2
JB
758** The new functions scm_get_meta_args and scm_count_argv help you
759implement the SCSH-style meta-argument, `\'.
760
761char **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
771int scm_count_argv (char **ARGV)
772 Count the arguments in ARGV, assuming it is terminated by a null
773 pointer.
774
775For an example of how these functions might be used, see the source
776code for the function scm_shell in libguile/script.c.
777
778You will usually want to use scm_shell instead of calling this
779function yourself.
780
781** The new function scm_compile_shell_switches turns an array of
782command-line arguments into Scheme code to carry out the actions they
783describe. Given ARGC and ARGV, it returns a Scheme expression to
784evaluate, and calls scm_set_program_arguments to make any remaining
785command-line arguments available to the Scheme code. For example,
786given the following arguments:
787
788 -e main -s ekko a speckled gecko
789
790scm_set_program_arguments will return the following expression:
791
792 (begin (load "ekko") (main (command-line)) (quit))
793
794You will usually want to use scm_shell instead of calling this
795function yourself.
796
797** The function scm_shell_usage prints a usage message appropriate for
798an interpreter that uses scm_compile_shell_switches to handle its
799command-line arguments.
800
801void 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
809You will usually want to use scm_shell instead of calling this
810function yourself.
48d224d7
JB
811
812** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
813expressions. It used to return SCM_EOL. Earth-shattering.
814
815** The macros for declaring scheme objects in C code have been
816rearranged slightly. They are now:
817
818SCM_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
823SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
824 Just like SCM_SYMBOL, but make C_NAME globally visible.
825
826SCM_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
831SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
832 Just like SCM_VCELL, but make C_NAME globally visible.
833
834The `guile-snarf' script writes initialization code for these macros
835to its standard output, given C source code as input.
836
837The SCM_GLOBAL macro is gone.
838
839** The scm_read_line and scm_read_line_x functions have been replaced
840by Scheme code based on the %read-delimited! procedure (known to C
841code as scm_read_delimited_x). See its description above for more
842information.
48d224d7 843
095936d2
JB
844** The function scm_sys_open has been renamed to scm_open. It now
845returns a port instead of an FD object.
ea00ecba 846
095936d2
JB
847* The dynamic linking support has changed. For more information, see
848libguile/DYNAMIC-LINKING.
ea00ecba 849
f7b47737
JB
850\f
851Guile 1.0b3
3065a62a 852
f3b1485f
JB
853User-visible changes from Thursday, September 5, 1996 until Guile 1.0
854(Sun 5 Jan 1997):
3065a62a 855
4b521edb 856* Changes to the 'guile' program:
3065a62a 857
4b521edb
JB
858** Guile now loads some new files when it starts up. Guile first
859searches the load path for init.scm, and loads it if found. Then, if
860Guile is not being used to execute a script, and the user's home
861directory contains a file named `.guile', Guile loads that.
c6486f8a 862
4b521edb 863** You can now use Guile as a shell script interpreter.
3065a62a
JB
864
865To 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
1a1945be
JB
878Now you can use Guile as an interpreter, using a mechanism which is a
879compatible subset of that provided by SCSH.
880
3065a62a
JB
881Guile now recognizes a '-s' command line switch, whose argument is the
882name of a file of Scheme code to load. It also treats the two
883characters `#!' as the start of a comment, terminated by `!#'. Thus,
884to make a file of Scheme code directly executable by Unix, insert the
885following two lines at the top of the file:
886
887#!/usr/local/bin/guile -s
888!#
889
890Guile treats the argument of the `-s' command-line switch as the name
891of a file of Scheme code to load, and treats the sequence `#!' as the
892start of a block comment, terminated by `!#'.
893
894For 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
907Why does `#!' start a block comment terminated by `!#', instead of the
908end of the line? That is the notation SCSH uses, and although we
909don't yet support the other SCSH features that motivate that choice,
910we would like to be backward-compatible with any existing Guile
3763761c
JB
911scripts once we do. Furthermore, if the path to Guile on your system
912is too long for your kernel, you can start the script with this
913horrible hack:
914
915#!/bin/sh
916exec /really/long/path/to/guile -s "$0" ${1+"$@"}
917!#
3065a62a
JB
918
919Note that some very old Unix systems don't support the `#!' syntax.
920
c6486f8a 921
4b521edb 922** You can now run Guile without installing it.
6685dc83
JB
923
924Previous versions of the interactive Guile interpreter (`guile')
925couldn't start up unless Guile's Scheme library had been installed;
926they used the value of the environment variable `SCHEME_LOAD_PATH'
927later on in the startup process, but not to find the startup code
928itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
929code.
930
931To run Guile without installing it, build it in the normal way, and
932then set the environment variable `SCHEME_LOAD_PATH' to a
933colon-separated list of directories, including the top-level directory
934of the Guile sources. For example, if you unpacked Guile so that the
935full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
936you might say
937
938 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
939
c6486f8a 940
4b521edb
JB
941** Guile's read-eval-print loop no longer prints #<unspecified>
942results. If the user wants to see this, she can evaluate the
943expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 944file.
6685dc83 945
4b521edb
JB
946** Guile no longer shows backtraces by default when an error occurs;
947however, it does display a message saying how to get one, and how to
948request that they be displayed by default. After an error, evaluate
949 (backtrace)
950to see a backtrace, and
951 (debug-enable 'backtrace)
952to see them by default.
6685dc83 953
6685dc83 954
d9fb83d9 955
4b521edb
JB
956* Changes to Guile Scheme:
957
958** Guile now distinguishes between #f and the empty list.
959
960This is for compatibility with the IEEE standard, the (possibly)
961upcoming Revised^5 Report on Scheme, and many extant Scheme
962implementations.
963
964Guile used to have #f and '() denote the same object, to make Scheme's
965type system more compatible with Emacs Lisp's. However, the change
966caused too much trouble for Scheme programmers, and we found another
967way to reconcile Emacs Lisp with Scheme that didn't require this.
968
969
970** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
971counterparts, delq!, delv!, and delete!, now remove all matching
972elements from the list, not just the first. This matches the behavior
973of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
974functions which inspired them.
975
976I recognize that this change may break code in subtle ways, but it
977seems best to make the change before the FSF's first Guile release,
978rather than after.
979
980
4b521edb 981** The compiled-library-path function has been deleted from libguile.
6685dc83 982
4b521edb 983** The facilities for loading Scheme source files have changed.
c6486f8a 984
4b521edb 985*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
986for Scheme code. Its value is a list of strings, each of which names
987a directory.
988
4b521edb
JB
989*** The variable %load-extensions now tells Guile which extensions to
990try appending to a filename when searching the load path. Its value
991is a list of strings. Its default value is ("" ".scm").
992
993*** (%search-load-path FILENAME) searches the directories listed in the
994value of the %load-path variable for a Scheme file named FILENAME,
995with all the extensions listed in %load-extensions. If it finds a
996match, then it returns its full filename. If FILENAME is absolute, it
997returns it unchanged. Otherwise, it returns #f.
6685dc83 998
4b521edb
JB
999%search-load-path will not return matches that refer to directories.
1000
1001*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
1002uses %seach-load-path to find a file named FILENAME, and loads it if
1003it finds it. If it can't read FILENAME for any reason, it throws an
1004error.
6685dc83
JB
1005
1006The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
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,
1012basic-try-load-with-path, basic-load-with-path, try-load-module-with-
1013path, and load-module-with-path have been deleted. The functions
1014above 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
1018loaded (without the load path directory name prepended). If its value
1019is #f, it is ignored. Otherwise, an error occurs.
1020
1021This is mostly useful for printing load notification messages.
1022
1023
1024** The function `eval!' is no longer accessible from the scheme level.
1025We can't allow operations which introduce glocs into the scheme level,
1026because 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,
1030evaluates it, and returns the result. This is more efficient than
1031simply calling `read' and `eval', since it is not necessary to make a
1032copy of the expression for the evaluator to munge.
1033
1034Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
1035for the `read' function.
1036
1037
1038** The function `int?' has been removed; its definition was identical
1039to that of `integer?'.
1040
1041** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
1042use the R4RS names for these functions.
1043
1044** The function object-properties no longer returns the hash handle;
1045it simply returns the object's property list.
1046
1047** Many functions have been changed to throw errors, instead of
1048returning #f on failure. The point of providing exception handling in
1049the language is to simplify the logic of user code, but this is less
1050useful 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.
1060scm_boot_guile now has the prototype:
1061
1062void scm_boot_guile (int ARGC,
1063 char **ARGV,
1064 void (*main_func) (),
1065 void *closure);
1066
1067scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
1068MAIN_FUNC should do all the work of the program (initializing other
1069packages, reading user input, etc.) before returning. When MAIN_FUNC
1070returns, call exit (0); this function never returns. If you want some
1071other exit value, MAIN_FUNC may call exit itself.
1072
1073scm_boot_guile arranges for program-arguments to return the strings
1074given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
1075scm_set_program_arguments with the final list, so Scheme code will
1076know which arguments have been processed.
1077
1078scm_boot_guile establishes a catch-all catch handler which prints an
1079error message and exits the process. This means that Guile exits in a
1080coherent way when system errors occur and the user isn't prepared to
1081handle it. If the user doesn't like this behavior, they can establish
1082their own universal catcher in MAIN_FUNC to shadow this one.
1083
1084Why must the caller do all the real work from MAIN_FUNC? The garbage
1085collector assumes that all local variables of type SCM will be above
1086scm_boot_guile's stack frame on the stack. If you try to manipulate
1087SCM values after this function returns, it's the luck of the draw
1088whether the GC will be able to find the objects you allocate. So,
1089scm_boot_guile function exits, rather than returning, to discourage
1090people from making that mistake.
1091
1092The IN, OUT, and ERR arguments were removed; there are other
1093convenient ways to override these when desired.
1094
1095The RESULT argument was deleted; this function should never return.
1096
1097The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
1098general.
1099
1100
1101** Guile's header files should no longer conflict with your system's
1102header files.
1103
1104In order to compile code which #included <libguile.h>, previous
1105versions of Guile required you to add a directory containing all the
1106Guile header files to your #include path. This was a problem, since
1107Guile's header files have names which conflict with many systems'
1108header files.
1109
1110Now only <libguile.h> need appear in your #include path; you must
1111refer to all Guile's other header files as <libguile/mumble.h>.
1112Guile's installation procedure puts libguile.h in $(includedir), and
1113the rest in $(includedir)/libguile.
1114
1115
1116** Two new C functions, scm_protect_object and scm_unprotect_object,
1117have been added to the Guile library.
1118
1119scm_protect_object (OBJ) protects OBJ from the garbage collector.
1120OBJ will not be freed, even if all other references are dropped,
1121until someone does scm_unprotect_object (OBJ). Both functions
1122return OBJ.
1123
1124Note that calls to scm_protect_object do not nest. You can call
1125scm_protect_object any number of times on a given object, and the
1126next call to scm_unprotect_object will unprotect it completely.
1127
1128Basically, scm_protect_object and scm_unprotect_object just
1129maintain a list of references to things. Since the GC knows about
1130this list, all objects it mentions stay alive. scm_protect_object
1131adds its argument to the list; scm_unprotect_object remove its
1132argument from the list.
1133
1134
1135** scm_eval_0str now returns the value of the last expression
1136evaluated.
1137
1138** The new function scm_read_0str reads an s-expression from a
1139null-terminated string, and returns it.
1140
1141** The new function `scm_stdio_to_port' converts a STDIO file pointer
1142to a Scheme port object.
1143
1144** The new function `scm_set_program_arguments' allows C code to set
1145the value teruturned by the Scheme `program-arguments' function.
6685dc83 1146
6685dc83 1147\f
1a1945be
JB
1148Older changes:
1149
1150* Guile no longer includes sophisticated Tcl/Tk support.
1151
1152The old Tcl/Tk support was unsatisfying to us, because it required the
1153user to link against the Tcl library, as well as Tk and Guile. The
1154interface was also un-lispy, in that it preserved Tcl/Tk's practice of
1155referring to widgets by names, rather than exporting widgets to Scheme
1156code as a special datatype.
1157
1158In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
1159maintainers described some very interesting changes in progress to the
1160Tcl/Tk internals, which would facilitate clean interfaces between lone
1161Tk and other interpreters --- even for garbage-collected languages
1162like Scheme. They expected the new Tk to be publicly available in the
1163fall of 1996.
1164
1165Since it seems that Guile might soon have a new, cleaner interface to
1166lone Tk, and that the old Guile/Tk glue code would probably need to be
1167completely rewritten, we (Jim Blandy and Richard Stallman) have
1168decided not to support the old code. We'll spend the time instead on
1169a good interface to the newer Tk, as soon as it is available.
5c54da76 1170
8512dea6 1171Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 1172
5c54da76
JB
1173\f
1174Copyright information:
1175
ea00ecba 1176Copyright (C) 1996,1997 Free Software Foundation, Inc.
5c54da76
JB
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
48d224d7
JB
1188\f
1189Local variables:
1190mode: outline
1191paragraph-separate: "[ \f]*$"
1192end:
1193