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