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