56ac01d22b044c75b32f2dec812645b832b13371
[bpt/guile.git] / NEWS
1 Guile NEWS --- history of user-visible changes. -*- text -*-
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 See the end for copying conditions.
4
5 Please send Guile bug reports to bug-guile@prep.ai.mit.edu.
6 \f
7 Changes in Guile 1.1 (Sun 5 Jan 1997):
8
9 * Changes to the distribution.
10
11 The Guile 1.0 distribution has been split up into several smaller
12 pieces:
13 guile-core --- the Guile interpreter itself.
14 guile-tcltk --- the interface between the Guile interpreter and
15 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
16 is a toolkit for building graphical user interfaces.
17 guile-rgx-ctax --- the interface between Guile and the Rx regular
18 expression matcher, and the translator for the Ctax
19 programming language. These are packaged together because the
20 Ctax translator uses Rx to parse Ctax source code.
21
22 We no longer distribute the documentation, since it was either out of
23 date, or incomplete. As soon as we have current documentation, we
24 will distribute it.
25
26 * Changes to the stand-alone interpreter
27
28 ** guile now accepts command-line arguments compatible with SCSH, Olin
29 Shivers' Scheme Shell.
30
31 In general, arguments are evaluated from left to right, but there are
32 exceptions. The following switches stop argument processing, and
33 stash all remaining command-line arguments as the value returned by
34 the (command-line) function.
35 -s SCRIPT load Scheme source code from FILE, and exit
36 -c EXPR evalute Scheme expression EXPR, and exit
37 -- stop scanning arguments; run interactively
38
39 The switches below are processed as they are encountered.
40 -l FILE load Scheme source code from FILE
41 -e FUNCTION after reading script, apply FUNCTION to
42 command line arguments
43 -ds do -s script at this point
44 --emacs enable Emacs protocol (experimental)
45 -h, --help display this help and exit
46 -v, --version display version information and exit
47 \ read arguments from following script lines
48
49 So, for example, here is a Guile script named `ekko' (thanks, Olin)
50 which re-implements the traditional "echo" command:
51
52 #!/usr/local/bin/guile -s
53 !#
54 (define (main args)
55 (map (lambda (arg) (display arg) (display " "))
56 (cdr args))
57 (newline))
58
59 (main (command-line))
60
61 Suppose we invoke this script as follows:
62
63 ekko a speckled gecko
64
65 Through the magic of Unix script processing (triggered by the `#!'
66 token at the top of the file), /usr/local/bin/guile receives the
67 following list of command-line arguments:
68
69 ("-s" "./ekko" "a" "speckled" "gecko")
70
71 Unix inserts the name of the script after the argument specified on
72 the first line of the file (in this case, "-s"), and then follows that
73 with the arguments given to the script. Guile loads the script, which
74 defines the `main' function, and then applies it to the list of
75 remaining command-line arguments, ("a" "speckled" "gecko").
76
77 * Changes to the procedure for linking libguile with your programs
78
79 ** Guile now builds and installs a shared guile library, if your
80 system support shared libraries. (It still builds a static library on
81 all systems.) Guile automatically detects whether your system
82 supports shared libraries. To prevent Guile from buildisg shared
83 libraries, pass the `--disable-shared' flag to the configure script.
84
85 Guile takes longer to compile when it builds shared libraries, because
86 it must compile every file twice --- once to produce position-
87 independent object code, and once to produce normal object code.
88
89 ** The libthreads library has been merged into libguile.
90
91 To link a program against Guile, you now need only link against
92 -lguile and -lqt; -lthreads is no longer needed. If you are using
93 autoconf to generate configuration scripts for your application, the
94 following lines should suffice to add the appropriate libraries to
95 your link command:
96
97 ### Find quickthreads and libguile.
98 AC_CHECK_LIB(qt, main)
99 AC_CHECK_LIB(guile, scm_shell)
100
101 * Changes to Scheme functions
102
103 ** There are new accessors and setters for the broken-out time vectors
104 returned by `localtime', `gmtime', and that ilk. They are:
105
106 Component Accessor Setter
107 ========================= ============ ============
108 seconds tm:sec set-tm:sec
109 minutes tm:min set-tm:min
110 hours tm:hour set-tm:hour
111 day of the month tm:mday set-tm:mday
112 month tm:mon set-tm:mon
113 year tm:year set-tm:year
114 day of the week tm:wday set-tm:wday
115 day in the year tm:yday set-tm:yday
116 daylight saving time tm:isdst set-tm:isdst
117 GMT offset, seconds tm:gmtoff set-tm:gmtoff
118 name of time zone tm:zone set-tm:zone
119
120 ** There are new accessors for the vectors returned by `uname'.
121
122 Component Accessor
123 ============================================== ================
124 name of the operating system implementation utsname:sysname
125 network name of this machine utsname:nodename
126 release level of the operating system utsname:release
127 version level of the operating system utsname:version
128 machine hardware platform utsname:machine
129
130 ** There is now a complete set of accessors for the vectors returned
131 by the `getserv'
132
133 ** The new function `eval-string' reads Scheme expressions from a
134 string and evaluates them, returning the value of the last expression
135 in the string. If the string contains no expressions, it returns an
136 unspecified value.
137
138 ** The new function `command-line' returns the command-line arguments
139 given to Guile, as a list of strings.
140
141 When using guile as a script interpreter, `command-line' returns the
142 script's arguments; those processed by the interpreter (like `-s' or
143 `-c') are omitted. (In other words, you get the normal, expected
144 behavior.) Any application that uses scm_shell to process its
145 command-line arguments gets this behavior as well.
146
147 ** The new function `load-user-init' looks for a file called `.guile'
148 in the user's home directory, and loads it if it exists. This is
149 mostly for use by the code generated by scm_compile_shell_switches,
150 but we thought it might also be useful in other circumstances.
151
152 ** The new function `log10' returns the base-10 logarithm of its
153 argument.
154
155 ** gethost, getproto, and getnet, and getserv now return more helpful
156 error codes.
157
158 * Changes to the gh_ interface
159
160 ** gh_eval_str() now returns an SCM object which is the result of the
161 evaluation
162
163 ** gh_scm2str() now copies the Scheme data to a caller-provided C
164 array
165
166 ** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
167 and returns the array
168
169 ** gh_scm2str0() is gone: there is no need to distinguish
170 null-terminated from non-null-terminated, since gh_scm2newstr() allows
171 the user to interpret the data both ways.
172
173 * Changes to the scm_ interface
174
175 ** The new function scm_shell makes it easy for user applications to
176 process command-line arguments in a way that is compatible with the
177 stand-alone guile interpreter (which is in turn compatible with SCSH,
178 the Scheme shell).
179
180 To use the scm_shell function, first initialize any guile modules
181 linked into your application, and then call scm_shell with the values
182 of ARGC and ARGV your `main' function received. scm_shell will adding
183 any SCSH-style meta-arguments from the top of the script file to the
184 argument vector, and then process the command-line arguments. This
185 generally means loading a script file or starting up an interactive
186 command interpreter. For details, see "Changes to the stand-alone
187 interpreter" above.
188
189 ** [[new: scm_usage_name, scm_shell_usage, scm_compile_shell_switches]]
190
191 ** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
192 expressions. It used to return SCM_EOL.
193
194 * Changes to documentation
195
196 ** the $(srcdir)/newdoc hierarchy now contains a new approach to the
197 manuals. The approach, recommended by Jim Blandy, is to have: (*) a
198 tutorial with the pedagogical style of guile-user, and a non-dry
199 reference manual in the style of the most excellent GNU libc reference
200 manual: the reference manual should be complete, but at the same time
201 it should have an introductory screen for each major topic, which can
202 be referenced if the user goes "up" a level in the info documentation.
203
204 \f
205 Guile 1.0b3
206
207 User-visible changes from Thursday, September 5, 1996 until Guile 1.0
208 (Sun 5 Jan 1997):
209
210 * Changes to the 'guile' program:
211
212 ** Guile now loads some new files when it starts up. Guile first
213 searches the load path for init.scm, and loads it if found. Then, if
214 Guile is not being used to execute a script, and the user's home
215 directory contains a file named `.guile', Guile loads that.
216
217 ** You can now use Guile as a shell script interpreter.
218
219 To paraphrase the SCSH manual:
220
221 When Unix tries to execute an executable file whose first two
222 characters are the `#!', it treats the file not as machine code to
223 be directly executed by the native processor, but as source code
224 to be executed by some interpreter. The interpreter to use is
225 specified immediately after the #! sequence on the first line of
226 the source file. The kernel reads in the name of the interpreter,
227 and executes that instead. It passes the interpreter the source
228 filename as its first argument, with the original arguments
229 following. Consult the Unix man page for the `exec' system call
230 for more information.
231
232 Now you can use Guile as an interpreter, using a mechanism which is a
233 compatible subset of that provided by SCSH.
234
235 Guile now recognizes a '-s' command line switch, whose argument is the
236 name of a file of Scheme code to load. It also treats the two
237 characters `#!' as the start of a comment, terminated by `!#'. Thus,
238 to make a file of Scheme code directly executable by Unix, insert the
239 following two lines at the top of the file:
240
241 #!/usr/local/bin/guile -s
242 !#
243
244 Guile treats the argument of the `-s' command-line switch as the name
245 of a file of Scheme code to load, and treats the sequence `#!' as the
246 start of a block comment, terminated by `!#'.
247
248 For example, here's a version of 'echo' written in Scheme:
249
250 #!/usr/local/bin/guile -s
251 !#
252 (let loop ((args (cdr (program-arguments))))
253 (if (pair? args)
254 (begin
255 (display (car args))
256 (if (pair? (cdr args))
257 (display " "))
258 (loop (cdr args)))))
259 (newline)
260
261 Why does `#!' start a block comment terminated by `!#', instead of the
262 end of the line? That is the notation SCSH uses, and although we
263 don't yet support the other SCSH features that motivate that choice,
264 we would like to be backward-compatible with any existing Guile
265 scripts once we do. Furthermore, if the path to Guile on your system
266 is too long for your kernel, you can start the script with this
267 horrible hack:
268
269 #!/bin/sh
270 exec /really/long/path/to/guile -s "$0" ${1+"$@"}
271 !#
272
273 Note that some very old Unix systems don't support the `#!' syntax.
274
275
276 ** You can now run Guile without installing it.
277
278 Previous versions of the interactive Guile interpreter (`guile')
279 couldn't start up unless Guile's Scheme library had been installed;
280 they used the value of the environment variable `SCHEME_LOAD_PATH'
281 later on in the startup process, but not to find the startup code
282 itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
283 code.
284
285 To run Guile without installing it, build it in the normal way, and
286 then set the environment variable `SCHEME_LOAD_PATH' to a
287 colon-separated list of directories, including the top-level directory
288 of the Guile sources. For example, if you unpacked Guile so that the
289 full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
290 you might say
291
292 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
293
294
295 ** Guile's read-eval-print loop no longer prints #<unspecified>
296 results. If the user wants to see this, she can evaluate the
297 expression (assert-repl-print-unspecified #t), perhaps in her startup
298 file.
299
300 ** Guile no longer shows backtraces by default when an error occurs;
301 however, it does display a message saying how to get one, and how to
302 request that they be displayed by default. After an error, evaluate
303 (backtrace)
304 to see a backtrace, and
305 (debug-enable 'backtrace)
306 to see them by default.
307
308
309
310 * Changes to Guile Scheme:
311
312 ** Guile now distinguishes between #f and the empty list.
313
314 This is for compatibility with the IEEE standard, the (possibly)
315 upcoming Revised^5 Report on Scheme, and many extant Scheme
316 implementations.
317
318 Guile used to have #f and '() denote the same object, to make Scheme's
319 type system more compatible with Emacs Lisp's. However, the change
320 caused too much trouble for Scheme programmers, and we found another
321 way to reconcile Emacs Lisp with Scheme that didn't require this.
322
323
324 ** Guile's delq, delv, delete functions, and their destructive
325 counterparts, delq!, delv!, and delete!, now remove all matching
326 elements from the list, not just the first. This matches the behavior
327 of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
328 functions which inspired them.
329
330 I recognize that this change may break code in subtle ways, but it
331 seems best to make the change before the FSF's first Guile release,
332 rather than after.
333
334
335 ** The compiled-library-path function has been deleted from libguile.
336
337 ** The facilities for loading Scheme source files have changed.
338
339 *** The variable %load-path now tells Guile which directories to search
340 for Scheme code. Its value is a list of strings, each of which names
341 a directory.
342
343 *** The variable %load-extensions now tells Guile which extensions to
344 try appending to a filename when searching the load path. Its value
345 is a list of strings. Its default value is ("" ".scm").
346
347 *** (%search-load-path FILENAME) searches the directories listed in the
348 value of the %load-path variable for a Scheme file named FILENAME,
349 with all the extensions listed in %load-extensions. If it finds a
350 match, then it returns its full filename. If FILENAME is absolute, it
351 returns it unchanged. Otherwise, it returns #f.
352
353 %search-load-path will not return matches that refer to directories.
354
355 *** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
356 uses %seach-load-path to find a file named FILENAME, and loads it if
357 it finds it. If it can't read FILENAME for any reason, it throws an
358 error.
359
360 The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
361 `read' function.
362
363 *** load uses the same searching semantics as primitive-load.
364
365 *** The functions %try-load, try-load-with-path, %load, load-with-path,
366 basic-try-load-with-path, basic-load-with-path, try-load-module-with-
367 path, and load-module-with-path have been deleted. The functions
368 above should serve their purposes.
369
370 *** If the value of the variable %load-hook is a procedure,
371 `primitive-load' applies its value to the name of the file being
372 loaded (without the load path directory name prepended). If its value
373 is #f, it is ignored. Otherwise, an error occurs.
374
375 This is mostly useful for printing load notification messages.
376
377
378 ** The function `eval!' is no longer accessible from the scheme level.
379 We can't allow operations which introduce glocs into the scheme level,
380 because Guile's type system can't handle these as data. Use `eval' or
381 `read-and-eval!' (see below) as replacement.
382
383 ** The new function read-and-eval! reads an expression from PORT,
384 evaluates it, and returns the result. This is more efficient than
385 simply calling `read' and `eval', since it is not necessary to make a
386 copy of the expression for the evaluator to munge.
387
388 Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
389 for the `read' function.
390
391
392 ** The function `int?' has been removed; its definition was identical
393 to that of `integer?'.
394
395 ** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
396 use the R4RS names for these functions.
397
398 ** The function object-properties no longer returns the hash handle;
399 it simply returns the object's property list.
400
401 ** Many functions have been changed to throw errors, instead of
402 returning #f on failure. The point of providing exception handling in
403 the language is to simplify the logic of user code, but this is less
404 useful if Guile's primitives don't throw exceptions.
405
406 ** The function `fileno' has been renamed from `%fileno'.
407
408 ** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
409
410
411 * Changes to Guile's C interface:
412
413 ** The library's initialization procedure has been simplified.
414 scm_boot_guile now has the prototype:
415
416 void scm_boot_guile (int ARGC,
417 char **ARGV,
418 void (*main_func) (),
419 void *closure);
420
421 scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
422 MAIN_FUNC should do all the work of the program (initializing other
423 packages, reading user input, etc.) before returning. When MAIN_FUNC
424 returns, call exit (0); this function never returns. If you want some
425 other exit value, MAIN_FUNC may call exit itself.
426
427 scm_boot_guile arranges for program-arguments to return the strings
428 given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
429 scm_set_program_arguments with the final list, so Scheme code will
430 know which arguments have been processed.
431
432 scm_boot_guile establishes a catch-all catch handler which prints an
433 error message and exits the process. This means that Guile exits in a
434 coherent way when system errors occur and the user isn't prepared to
435 handle it. If the user doesn't like this behavior, they can establish
436 their own universal catcher in MAIN_FUNC to shadow this one.
437
438 Why must the caller do all the real work from MAIN_FUNC? The garbage
439 collector assumes that all local variables of type SCM will be above
440 scm_boot_guile's stack frame on the stack. If you try to manipulate
441 SCM values after this function returns, it's the luck of the draw
442 whether the GC will be able to find the objects you allocate. So,
443 scm_boot_guile function exits, rather than returning, to discourage
444 people from making that mistake.
445
446 The IN, OUT, and ERR arguments were removed; there are other
447 convenient ways to override these when desired.
448
449 The RESULT argument was deleted; this function should never return.
450
451 The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
452 general.
453
454
455 ** Guile's header files should no longer conflict with your system's
456 header files.
457
458 In order to compile code which #included <libguile.h>, previous
459 versions of Guile required you to add a directory containing all the
460 Guile header files to your #include path. This was a problem, since
461 Guile's header files have names which conflict with many systems'
462 header files.
463
464 Now only <libguile.h> need appear in your #include path; you must
465 refer to all Guile's other header files as <libguile/mumble.h>.
466 Guile's installation procedure puts libguile.h in $(includedir), and
467 the rest in $(includedir)/libguile.
468
469
470 ** Two new C functions, scm_protect_object and scm_unprotect_object,
471 have been added to the Guile library.
472
473 scm_protect_object (OBJ) protects OBJ from the garbage collector.
474 OBJ will not be freed, even if all other references are dropped,
475 until someone does scm_unprotect_object (OBJ). Both functions
476 return OBJ.
477
478 Note that calls to scm_protect_object do not nest. You can call
479 scm_protect_object any number of times on a given object, and the
480 next call to scm_unprotect_object will unprotect it completely.
481
482 Basically, scm_protect_object and scm_unprotect_object just
483 maintain a list of references to things. Since the GC knows about
484 this list, all objects it mentions stay alive. scm_protect_object
485 adds its argument to the list; scm_unprotect_object remove its
486 argument from the list.
487
488
489 ** scm_eval_0str now returns the value of the last expression
490 evaluated.
491
492 ** The new function scm_read_0str reads an s-expression from a
493 null-terminated string, and returns it.
494
495 ** The new function `scm_stdio_to_port' converts a STDIO file pointer
496 to a Scheme port object.
497
498 ** The new function `scm_set_program_arguments' allows C code to set
499 the value teruturned by the Scheme `program-arguments' function.
500
501 \f
502 Older changes:
503
504 * Guile no longer includes sophisticated Tcl/Tk support.
505
506 The old Tcl/Tk support was unsatisfying to us, because it required the
507 user to link against the Tcl library, as well as Tk and Guile. The
508 interface was also un-lispy, in that it preserved Tcl/Tk's practice of
509 referring to widgets by names, rather than exporting widgets to Scheme
510 code as a special datatype.
511
512 In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
513 maintainers described some very interesting changes in progress to the
514 Tcl/Tk internals, which would facilitate clean interfaces between lone
515 Tk and other interpreters --- even for garbage-collected languages
516 like Scheme. They expected the new Tk to be publicly available in the
517 fall of 1996.
518
519 Since it seems that Guile might soon have a new, cleaner interface to
520 lone Tk, and that the old Guile/Tk glue code would probably need to be
521 completely rewritten, we (Jim Blandy and Richard Stallman) have
522 decided not to support the old code. We'll spend the time instead on
523 a good interface to the newer Tk, as soon as it is available.
524
525 Until then, gtcltk-lib provides trivial, low-maintenance functionality.
526
527 \f
528 Copyright information:
529
530 Copyright (C) 1996,1997 Free Software Foundation, Inc.
531
532 Permission is granted to anyone to make or distribute verbatim copies
533 of this document as received, in any medium, provided that the
534 copyright notice and this permission notice are preserved,
535 thus giving the recipient permission to redistribute in turn.
536
537 Permission is granted to distribute modified versions
538 of this document, or of portions of it,
539 under the above conditions, provided also that they
540 carry prominent notices stating who last changed them.
541
542 \f
543 Local variables:
544 mode: outline
545 paragraph-separate: "[ \f]*$"
546 end:
547