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