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