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