* md/axp.s, md/axp_b.s: Changed comments from C-style to # to
[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
c484bf7f
JB
7Changes since Guile 1.2:
8
9* Changes to the distribution
10
11* Changes to the stand-alone interpreter
12
13* Changes to the procedure for linking libguile with your programs
14
15* Changes to Scheme functions and syntax
7ad3c1e7 16
04c76b58
MV
17** There is now some basic support for fluids. Please read
18"libguile/fluid.h" to find out more. It is accessible from Scheme with
19the following builtin procedures:
20
21 (make-fluid)
22
23 Create a new fluid object.
24
25 (fluid-ref FLUID)
26 (fluid-set! FLUID VAL)
27
28 Access/modify the fluid FLUID. Modifications are only visible
29 within the current dynamic root (that includes threads).
30
31There is no `fluid-let' yet.
32
7ad3c1e7
GH
33** A new procedure primitive-exit can be used to terminate the current
34process without unwinding the Scheme stack. This would usually be used
35after a fork.
36
c484bf7f
JB
37* Changes to the gh_ interface
38
39* Changes to the scm_ interface
40
41\f
42Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 43
737c9113
JB
44* Changes to the distribution
45
832b09ed
JB
46** Nightly snapshots are now available from ftp.red-bean.com.
47The old server, ftp.cyclic.com, has been relinquished to its rightful
48owner.
49
50Nightly snapshots of the Guile development sources are now available via
51anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
52
53Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
54For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
55
0fcab5ed
JB
56** To run Guile without installing it, the procedure has changed a bit.
57
58If you used a separate build directory to compile Guile, you'll need
59to include the build directory in SCHEME_LOAD_PATH, as well as the
60source directory. See the `INSTALL' file for examples.
61
737c9113
JB
62* Changes to the procedure for linking libguile with your programs
63
94982a4e
JB
64** The standard Guile load path for Scheme code now includes
65$(datadir)/guile (usually /usr/local/share/guile). This means that
66you can install your own Scheme files there, and Guile will find them.
67(Previous versions of Guile only checked a directory whose name
68contained the Guile version number, so you had to re-install or move
69your Scheme sources each time you installed a fresh version of Guile.)
70
71The load path also includes $(datadir)/guile/site; we recommend
72putting individual Scheme files there. If you want to install a
73package with multiple source files, create a directory for them under
74$(datadir)/guile.
75
76** Guile 1.2 will now use the Rx regular expression library, if it is
77installed on your system. When you are linking libguile into your own
78programs, this means you will have to link against -lguile, -lqt (if
79you configured Guile with thread support), and -lrx.
27590f82
JB
80
81If you are using autoconf to generate configuration scripts for your
82application, the following lines should suffice to add the appropriate
83libraries to your link command:
84
85### Find Rx, quickthreads and libguile.
86AC_CHECK_LIB(rx, main)
87AC_CHECK_LIB(qt, main)
88AC_CHECK_LIB(guile, scm_shell)
89
94982a4e
JB
90The Guile 1.2 distribution does not contain sources for the Rx
91library, as Guile 1.0 did. If you want to use Rx, you'll need to
92retrieve it from a GNU FTP site and install it separately.
93
b83b8bee
JB
94* Changes to Scheme functions and syntax
95
e035e7e6
MV
96** The dynamic linking features of Guile are now enabled by default.
97You can disable them by giving the `--disable-dynamic-linking' option
98to configure.
99
e035e7e6
MV
100 (dynamic-link FILENAME)
101
102 Find the object file denoted by FILENAME (a string) and link it
103 into the running Guile application. When everything works out,
104 return a Scheme object suitable for representing the linked object
105 file. Otherwise an error is thrown. How object files are
106 searched is system dependent.
107
108 (dynamic-object? VAL)
109
110 Determine whether VAL represents a dynamically linked object file.
111
112 (dynamic-unlink DYNOBJ)
113
114 Unlink the indicated object file from the application. DYNOBJ
115 should be one of the values returned by `dynamic-link'.
116
117 (dynamic-func FUNCTION DYNOBJ)
118
119 Search the C function indicated by FUNCTION (a string or symbol)
120 in DYNOBJ and return some Scheme object that can later be used
121 with `dynamic-call' to actually call this function. Right now,
122 these Scheme objects are formed by casting the address of the
123 function to `long' and converting this number to its Scheme
124 representation.
125
126 (dynamic-call FUNCTION DYNOBJ)
127
128 Call the C function indicated by FUNCTION and DYNOBJ. The
129 function is passed no arguments and its return value is ignored.
130 When FUNCTION is something returned by `dynamic-func', call that
131 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
132 etc.), look it up in DYNOBJ; this is equivalent to
133
134 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
135
136 Interrupts are deferred while the C function is executing (with
137 SCM_DEFER_INTS/SCM_ALLOW_INTS).
138
139 (dynamic-args-call FUNCTION DYNOBJ ARGS)
140
141 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
142 some arguments and return its return value. The C function is
143 expected to take two arguments and return an `int', just like
144 `main':
145
146 int c_func (int argc, char **argv);
147
148 ARGS must be a list of strings and is converted into an array of
149 `char *'. The array is passed in ARGV and its size in ARGC. The
150 return value is converted to a Scheme number and returned from the
151 call to `dynamic-args-call'.
152
0fcab5ed
JB
153When dynamic linking is disabled or not supported on your system,
154the above functions throw errors, but they are still available.
155
e035e7e6
MV
156Here is a small example that works on GNU/Linux:
157
158 (define libc-obj (dynamic-link "libc.so"))
159 (dynamic-args-call 'rand libc-obj '())
160
161See the file `libguile/DYNAMIC-LINKING' for additional comments.
162
27590f82
JB
163** The #/ syntax for module names is depreciated, and will be removed
164in a future version of Guile. Instead of
165
166 #/foo/bar/baz
167
168instead write
169
170 (foo bar baz)
171
172The latter syntax is more consistent with existing Lisp practice.
173
5dade857
MV
174** Guile now does fancier printing of structures. Structures are the
175underlying implementation for records, which in turn are used to
176implement modules, so all of these object now print differently and in
177a more informative way.
178
161029df
JB
179The Scheme printer will examine the builtin variable *struct-printer*
180whenever it needs to print a structure object. When this variable is
181not `#f' it is deemed to be a procedure and will be applied to the
182structure object and the output port. When *struct-printer* is `#f'
183or the procedure return `#f' the structure object will be printed in
184the boring #<struct 80458270> form.
5dade857
MV
185
186This hook is used by some routines in ice-9/boot-9.scm to implement
187type specific printing routines. Please read the comments there about
188"printing structs".
189
190One of the more specific uses of structs are records. The printing
191procedure that could be passed to MAKE-RECORD-TYPE is now actually
192called. It should behave like a *struct-printer* procedure (described
193above).
194
b83b8bee
JB
195** Guile now supports a new R4RS-compliant syntax for keywords. A
196token of the form #:NAME, where NAME has the same syntax as a Scheme
197symbol, is the external representation of the keyword named NAME.
198Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
199keyword objects can be read back into Guile. When used in an
200expression, keywords are self-quoting objects.
b83b8bee
JB
201
202Guile suports this read syntax, and uses this print syntax, regardless
203of the current setting of the `keyword' read option. The `keyword'
204read option only controls whether Guile recognizes the `:NAME' syntax,
205which is incompatible with R4RS. (R4RS says such token represent
206symbols.)
737c9113
JB
207
208** Guile has regular expression support again. Guile 1.0 included
209functions for matching regular expressions, based on the Rx library.
210In Guile 1.1, the Guile/Rx interface was removed to simplify the
211distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
2121.2 again supports the most commonly used functions, and supports all
213of SCSH's regular expression functions.
2409cdfa 214
94982a4e
JB
215If your system does not include a POSIX regular expression library,
216and you have not linked Guile with a third-party regexp library such as
217Rx, these functions will not be available. You can tell whether your
218Guile installation includes regular expression support by checking
219whether the `*features*' list includes the `regex' symbol.
737c9113 220
94982a4e 221*** regexp functions
161029df 222
94982a4e
JB
223By default, Guile supports POSIX extended regular expressions. That
224means that the characters `(', `)', `+' and `?' are special, and must
225be escaped if you wish to match the literal characters.
e1a191a8 226
94982a4e
JB
227This regular expression interface was modeled after that implemented
228by SCSH, the Scheme Shell. It is intended to be upwardly compatible
229with SCSH regular expressions.
230
231**** Function: string-match PATTERN STR [START]
232 Compile the string PATTERN into a regular expression and compare
233 it with STR. The optional numeric argument START specifies the
234 position of STR at which to begin matching.
235
236 `string-match' returns a "match structure" which describes what,
237 if anything, was matched by the regular expression. *Note Match
238 Structures::. If STR does not match PATTERN at all,
239 `string-match' returns `#f'.
240
241 Each time `string-match' is called, it must compile its PATTERN
242argument into a regular expression structure. This operation is
243expensive, which makes `string-match' inefficient if the same regular
244expression is used several times (for example, in a loop). For better
245performance, you can compile a regular expression in advance and then
246match strings against the compiled regexp.
247
248**** Function: make-regexp STR [FLAGS]
249 Compile the regular expression described by STR, and return the
250 compiled regexp structure. If STR does not describe a legal
251 regular expression, `make-regexp' throws a
252 `regular-expression-syntax' error.
253
254 FLAGS may be the bitwise-or of one or more of the following:
255
256**** Constant: regexp/extended
257 Use POSIX Extended Regular Expression syntax when interpreting
258 STR. If not set, POSIX Basic Regular Expression syntax is used.
259 If the FLAGS argument is omitted, we assume regexp/extended.
260
261**** Constant: regexp/icase
262 Do not differentiate case. Subsequent searches using the
263 returned regular expression will be case insensitive.
264
265**** Constant: regexp/newline
266 Match-any-character operators don't match a newline.
267
268 A non-matching list ([^...]) not containing a newline matches a
269 newline.
270
271 Match-beginning-of-line operator (^) matches the empty string
272 immediately after a newline, regardless of whether the FLAGS
273 passed to regexp-exec contain regexp/notbol.
274
275 Match-end-of-line operator ($) matches the empty string
276 immediately before a newline, regardless of whether the FLAGS
277 passed to regexp-exec contain regexp/noteol.
278
279**** Function: regexp-exec REGEXP STR [START [FLAGS]]
280 Match the compiled regular expression REGEXP against `str'. If
281 the optional integer START argument is provided, begin matching
282 from that position in the string. Return a match structure
283 describing the results of the match, or `#f' if no match could be
284 found.
285
286 FLAGS may be the bitwise-or of one or more of the following:
287
288**** Constant: regexp/notbol
289 The match-beginning-of-line operator always fails to match (but
290 see the compilation flag regexp/newline above) This flag may be
291 used when different portions of a string are passed to
292 regexp-exec and the beginning of the string should not be
293 interpreted as the beginning of the line.
294
295**** Constant: regexp/noteol
296 The match-end-of-line operator always fails to match (but see the
297 compilation flag regexp/newline above)
298
299**** Function: regexp? OBJ
300 Return `#t' if OBJ is a compiled regular expression, or `#f'
301 otherwise.
302
303 Regular expressions are commonly used to find patterns in one string
304and replace them with the contents of another string.
305
306**** Function: regexp-substitute PORT MATCH [ITEM...]
307 Write to the output port PORT selected contents of the match
308 structure MATCH. Each ITEM specifies what should be written, and
309 may be one of the following arguments:
310
311 * A string. String arguments are written out verbatim.
312
313 * An integer. The submatch with that number is written.
314
315 * The symbol `pre'. The portion of the matched string preceding
316 the regexp match is written.
317
318 * The symbol `post'. The portion of the matched string
319 following the regexp match is written.
320
321 PORT may be `#f', in which case nothing is written; instead,
322 `regexp-substitute' constructs a string from the specified ITEMs
323 and returns that.
324
325**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
326 Similar to `regexp-substitute', but can be used to perform global
327 substitutions on STR. Instead of taking a match structure as an
328 argument, `regexp-substitute/global' takes two string arguments: a
329 REGEXP string describing a regular expression, and a TARGET string
330 which should be matched against this regular expression.
331
332 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
333 exceptions:
334
335 * A function may be supplied. When this function is called, it
336 will be passed one argument: a match structure for a given
337 regular expression match. It should return a string to be
338 written out to PORT.
339
340 * The `post' symbol causes `regexp-substitute/global' to recurse
341 on the unmatched portion of STR. This *must* be supplied in
342 order to perform global search-and-replace on STR; if it is
343 not present among the ITEMs, then `regexp-substitute/global'
344 will return after processing a single match.
345
346*** Match Structures
347
348 A "match structure" is the object returned by `string-match' and
349`regexp-exec'. It describes which portion of a string, if any, matched
350the given regular expression. Match structures include: a reference to
351the string that was checked for matches; the starting and ending
352positions of the regexp match; and, if the regexp included any
353parenthesized subexpressions, the starting and ending positions of each
354submatch.
355
356 In each of the regexp match functions described below, the `match'
357argument must be a match structure returned by a previous call to
358`string-match' or `regexp-exec'. Most of these functions return some
359information about the original target string that was matched against a
360regular expression; we will call that string TARGET for easy reference.
361
362**** Function: regexp-match? OBJ
363 Return `#t' if OBJ is a match structure returned by a previous
364 call to `regexp-exec', or `#f' otherwise.
365
366**** Function: match:substring MATCH [N]
367 Return the portion of TARGET matched by subexpression number N.
368 Submatch 0 (the default) represents the entire regexp match. If
369 the regular expression as a whole matched, but the subexpression
370 number N did not match, return `#f'.
371
372**** Function: match:start MATCH [N]
373 Return the starting position of submatch number N.
374
375**** Function: match:end MATCH [N]
376 Return the ending position of submatch number N.
377
378**** Function: match:prefix MATCH
379 Return the unmatched portion of TARGET preceding the regexp match.
380
381**** Function: match:suffix MATCH
382 Return the unmatched portion of TARGET following the regexp match.
383
384**** Function: match:count MATCH
385 Return the number of parenthesized subexpressions from MATCH.
386 Note that the entire regular expression match itself counts as a
387 subexpression, and failed submatches are included in the count.
388
389**** Function: match:string MATCH
390 Return the original TARGET string.
391
392*** Backslash Escapes
393
394 Sometimes you will want a regexp to match characters like `*' or `$'
395exactly. For example, to check whether a particular string represents
396a menu entry from an Info node, it would be useful to match it against
397a regexp like `^* [^:]*::'. However, this won't work; because the
398asterisk is a metacharacter, it won't match the `*' at the beginning of
399the string. In this case, we want to make the first asterisk un-magic.
400
401 You can do this by preceding the metacharacter with a backslash
402character `\'. (This is also called "quoting" the metacharacter, and
403is known as a "backslash escape".) When Guile sees a backslash in a
404regular expression, it considers the following glyph to be an ordinary
405character, no matter what special meaning it would ordinarily have.
406Therefore, we can make the above example work by changing the regexp to
407`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
408to match only a single asterisk in the target string.
409
410 Since the backslash is itself a metacharacter, you may force a
411regexp to match a backslash in the target string by preceding the
412backslash with itself. For example, to find variable references in a
413TeX program, you might want to find occurrences of the string `\let\'
414followed by any number of alphabetic characters. The regular expression
415`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
416each match a single backslash in the target string.
417
418**** Function: regexp-quote STR
419 Quote each special character found in STR with a backslash, and
420 return the resulting string.
421
422 *Very important:* Using backslash escapes in Guile source code (as
423in Emacs Lisp or C) can be tricky, because the backslash character has
424special meaning for the Guile reader. For example, if Guile encounters
425the character sequence `\n' in the middle of a string while processing
426Scheme code, it replaces those characters with a newline character.
427Similarly, the character sequence `\t' is replaced by a horizontal tab.
428Several of these "escape sequences" are processed by the Guile reader
429before your code is executed. Unrecognized escape sequences are
430ignored: if the characters `\*' appear in a string, they will be
431translated to the single character `*'.
432
433 This translation is obviously undesirable for regular expressions,
434since we want to be able to include backslashes in a string in order to
435escape regexp metacharacters. Therefore, to make sure that a backslash
436is preserved in a string in your Guile program, you must use *two*
437consecutive backslashes:
438
439 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
440
441 The string in this example is preprocessed by the Guile reader before
442any code is executed. The resulting argument to `make-regexp' is the
443string `^\* [^:]*', which is what we really want.
444
445 This also means that in order to write a regular expression that
446matches a single backslash character, the regular expression string in
447the source code must include *four* backslashes. Each consecutive pair
448of backslashes gets translated by the Guile reader to a single
449backslash, and the resulting double-backslash is interpreted by the
450regexp engine as matching a single backslash character. Hence:
451
452 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
453
454 The reason for the unwieldiness of this syntax is historical. Both
455regular expression pattern matchers and Unix string processing systems
456have traditionally used backslashes with the special meanings described
457above. The POSIX regular expression specification and ANSI C standard
458both require these semantics. Attempting to abandon either convention
459would cause other kinds of compatibility problems, possibly more severe
460ones. Therefore, without extending the Scheme reader to support
461strings with different quoting conventions (an ungainly and confusing
462extension when implemented in other languages), we must adhere to this
463cumbersome escape syntax.
464
7ad3c1e7
GH
465* Changes to the gh_ interface
466
467* Changes to the scm_ interface
468
469* Changes to system call interfaces:
94982a4e 470
7ad3c1e7 471** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
472if an error occurs.
473
94982a4e 474*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
475
476(sigaction signum [action] [flags])
477
478signum is the signal number, which can be specified using the value
479of SIGINT etc.
480
481If action is omitted, sigaction returns a pair: the CAR is the current
482signal hander, which will be either an integer with the value SIG_DFL
483(default action) or SIG_IGN (ignore), or the Scheme procedure which
484handles the signal, or #f if a non-Scheme procedure handles the
485signal. The CDR contains the current sigaction flags for the handler.
486
487If action is provided, it is installed as the new handler for signum.
488action can be a Scheme procedure taking one argument, or the value of
489SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
490whatever signal handler was installed before sigaction was first used.
491Flags can optionally be specified for the new handler (SA_RESTART is
492always used if the system provides it, so need not be specified.) The
493return value is a pair with information about the old handler as
494described above.
495
496This interface does not provide access to the "signal blocking"
497facility. Maybe this is not needed, since the thread support may
498provide solutions to the problem of consistent access to data
499structures.
e1a191a8 500
94982a4e 501*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
502`force-output' on every port open for output.
503
94982a4e
JB
504** Guile now provides information on how it was built, via the new
505global variable, %guile-build-info. This variable records the values
506of the standard GNU makefile directory variables as an assocation
507list, mapping variable names (symbols) onto directory paths (strings).
508For example, to find out where the Guile link libraries were
509installed, you can say:
510
511guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
512
513
514* Changes to the scm_ interface
515
516** The new function scm_handle_by_message_noexit is just like the
517existing scm_handle_by_message function, except that it doesn't call
518exit to terminate the process. Instead, it prints a message and just
519returns #f. This might be a more appropriate catch-all handler for
520new dynamic roots and threads.
521
cf78e9e8 522\f
c484bf7f 523Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
524
525* Changes to the distribution.
526
527The Guile 1.0 distribution has been split up into several smaller
528pieces:
529guile-core --- the Guile interpreter itself.
530guile-tcltk --- the interface between the Guile interpreter and
531 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
532 is a toolkit for building graphical user interfaces.
533guile-rgx-ctax --- the interface between Guile and the Rx regular
534 expression matcher, and the translator for the Ctax
535 programming language. These are packaged together because the
536 Ctax translator uses Rx to parse Ctax source code.
537
095936d2
JB
538This NEWS file describes the changes made to guile-core since the 1.0
539release.
540
48d224d7
JB
541We no longer distribute the documentation, since it was either out of
542date, or incomplete. As soon as we have current documentation, we
543will distribute it.
544
0fcab5ed
JB
545
546
f3b1485f
JB
547* Changes to the stand-alone interpreter
548
48d224d7
JB
549** guile now accepts command-line arguments compatible with SCSH, Olin
550Shivers' Scheme Shell.
551
552In general, arguments are evaluated from left to right, but there are
553exceptions. The following switches stop argument processing, and
554stash all remaining command-line arguments as the value returned by
555the (command-line) function.
556 -s SCRIPT load Scheme source code from FILE, and exit
557 -c EXPR evalute Scheme expression EXPR, and exit
558 -- stop scanning arguments; run interactively
559
560The switches below are processed as they are encountered.
561 -l FILE load Scheme source code from FILE
562 -e FUNCTION after reading script, apply FUNCTION to
563 command line arguments
564 -ds do -s script at this point
565 --emacs enable Emacs protocol (experimental)
566 -h, --help display this help and exit
567 -v, --version display version information and exit
568 \ read arguments from following script lines
569
570So, for example, here is a Guile script named `ekko' (thanks, Olin)
571which re-implements the traditional "echo" command:
572
573#!/usr/local/bin/guile -s
574!#
575(define (main args)
576 (map (lambda (arg) (display arg) (display " "))
577 (cdr args))
578 (newline))
579
580(main (command-line))
581
582Suppose we invoke this script as follows:
583
584 ekko a speckled gecko
585
586Through the magic of Unix script processing (triggered by the `#!'
587token at the top of the file), /usr/local/bin/guile receives the
588following list of command-line arguments:
589
590 ("-s" "./ekko" "a" "speckled" "gecko")
591
592Unix inserts the name of the script after the argument specified on
593the first line of the file (in this case, "-s"), and then follows that
594with the arguments given to the script. Guile loads the script, which
595defines the `main' function, and then applies it to the list of
596remaining command-line arguments, ("a" "speckled" "gecko").
597
095936d2
JB
598In Unix, the first line of a script file must take the following form:
599
600#!INTERPRETER ARGUMENT
601
602where INTERPRETER is the absolute filename of the interpreter
603executable, and ARGUMENT is a single command-line argument to pass to
604the interpreter.
605
606You may only pass one argument to the interpreter, and its length is
607limited. These restrictions can be annoying to work around, so Guile
608provides a general mechanism (borrowed from, and compatible with,
609SCSH) for circumventing them.
610
611If the ARGUMENT in a Guile script is a single backslash character,
612`\', Guile will open the script file, parse arguments from its second
613and subsequent lines, and replace the `\' with them. So, for example,
614here is another implementation of the `ekko' script:
615
616#!/usr/local/bin/guile \
617-e main -s
618!#
619(define (main args)
620 (for-each (lambda (arg) (display arg) (display " "))
621 (cdr args))
622 (newline))
623
624If the user invokes this script as follows:
625
626 ekko a speckled gecko
627
628Unix expands this into
629
630 /usr/local/bin/guile \ ekko a speckled gecko
631
632When Guile sees the `\' argument, it replaces it with the arguments
633read from the second line of the script, producing:
634
635 /usr/local/bin/guile -e main -s ekko a speckled gecko
636
637This tells Guile to load the `ekko' script, and apply the function
638`main' to the argument list ("a" "speckled" "gecko").
639
640Here is how Guile parses the command-line arguments:
641- Each space character terminates an argument. This means that two
642 spaces in a row introduce an empty-string argument.
643- The tab character is not permitted (unless you quote it with the
644 backslash character, as described below), to avoid confusion.
645- The newline character terminates the sequence of arguments, and will
646 also terminate a final non-empty argument. (However, a newline
647 following a space will not introduce a final empty-string argument;
648 it only terminates the argument list.)
649- The backslash character is the escape character. It escapes
650 backslash, space, tab, and newline. The ANSI C escape sequences
651 like \n and \t are also supported. These produce argument
652 constituents; the two-character combination \n doesn't act like a
653 terminating newline. The escape sequence \NNN for exactly three
654 octal digits reads as the character whose ASCII code is NNN. As
655 above, characters produced this way are argument constituents.
656 Backslash followed by other characters is not allowed.
657
48d224d7
JB
658* Changes to the procedure for linking libguile with your programs
659
660** Guile now builds and installs a shared guile library, if your
661system support shared libraries. (It still builds a static library on
662all systems.) Guile automatically detects whether your system
663supports shared libraries. To prevent Guile from buildisg shared
664libraries, pass the `--disable-shared' flag to the configure script.
665
666Guile takes longer to compile when it builds shared libraries, because
667it must compile every file twice --- once to produce position-
668independent object code, and once to produce normal object code.
669
670** The libthreads library has been merged into libguile.
671
672To link a program against Guile, you now need only link against
673-lguile and -lqt; -lthreads is no longer needed. If you are using
674autoconf to generate configuration scripts for your application, the
675following lines should suffice to add the appropriate libraries to
676your link command:
677
678### Find quickthreads and libguile.
679AC_CHECK_LIB(qt, main)
680AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
681
682* Changes to Scheme functions
683
095936d2
JB
684** Guile Scheme's special syntax for keyword objects is now optional,
685and disabled by default.
686
687The syntax variation from R4RS made it difficult to port some
688interesting packages to Guile. The routines which accepted keyword
689arguments (mostly in the module system) have been modified to also
690accept symbols whose names begin with `:'.
691
692To change the keyword syntax, you must first import the (ice-9 debug)
693module:
694 (use-modules (ice-9 debug))
695
696Then you can enable the keyword syntax as follows:
697 (read-set! keywords 'prefix)
698
699To disable keyword syntax, do this:
700 (read-set! keywords #f)
701
702** Many more primitive functions accept shared substrings as
703arguments. In the past, these functions required normal, mutable
704strings as arguments, although they never made use of this
705restriction.
706
707** The uniform array functions now operate on byte vectors. These
708functions are `array-fill!', `serial-array-copy!', `array-copy!',
709`serial-array-map', `array-map', `array-for-each', and
710`array-index-map!'.
711
712** The new functions `trace' and `untrace' implement simple debugging
713support for Scheme functions.
714
715The `trace' function accepts any number of procedures as arguments,
716and tells the Guile interpreter to display each procedure's name and
717arguments each time the procedure is invoked. When invoked with no
718arguments, `trace' returns the list of procedures currently being
719traced.
720
721The `untrace' function accepts any number of procedures as arguments,
722and tells the Guile interpreter not to trace them any more. When
723invoked with no arguments, `untrace' untraces all curretly traced
724procedures.
725
726The tracing in Guile has an advantage over most other systems: we
727don't create new procedure objects, but mark the procedure objects
728themselves. This means that anonymous and internal procedures can be
729traced.
730
731** The function `assert-repl-prompt' has been renamed to
732`set-repl-prompt!'. It takes one argument, PROMPT.
733- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
734- If PROMPT is a string, we use it as a prompt.
735- If PROMPT is a procedure accepting no arguments, we call it, and
736 display the result as a prompt.
737- Otherwise, we display "> ".
738
739** The new function `eval-string' reads Scheme expressions from a
740string and evaluates them, returning the value of the last expression
741in the string. If the string contains no expressions, it returns an
742unspecified value.
743
744** The new function `thunk?' returns true iff its argument is a
745procedure of zero arguments.
746
747** `defined?' is now a builtin function, instead of syntax. This
748means that its argument should be quoted. It returns #t iff its
749argument is bound in the current module.
750
751** The new syntax `use-modules' allows you to add new modules to your
752environment without re-typing a complete `define-module' form. It
753accepts any number of module names as arguments, and imports their
754public bindings into the current module.
755
756** The new function (module-defined? NAME MODULE) returns true iff
757NAME, a symbol, is defined in MODULE, a module object.
758
759** The new function `builtin-bindings' creates and returns a hash
760table containing copies of all the root module's bindings.
761
762** The new function `builtin-weak-bindings' does the same as
763`builtin-bindings', but creates a doubly-weak hash table.
764
765** The `equal?' function now considers variable objects to be
766equivalent if they have the same name and the same value.
767
768** The new function `command-line' returns the command-line arguments
769given to Guile, as a list of strings.
770
771When using guile as a script interpreter, `command-line' returns the
772script's arguments; those processed by the interpreter (like `-s' or
773`-c') are omitted. (In other words, you get the normal, expected
774behavior.) Any application that uses scm_shell to process its
775command-line arguments gets this behavior as well.
776
777** The new function `load-user-init' looks for a file called `.guile'
778in the user's home directory, and loads it if it exists. This is
779mostly for use by the code generated by scm_compile_shell_switches,
780but we thought it might also be useful in other circumstances.
781
782** The new function `log10' returns the base-10 logarithm of its
783argument.
784
785** Changes to I/O functions
786
787*** The functions `read', `primitive-load', `read-and-eval!', and
788`primitive-load-path' no longer take optional arguments controlling
789case insensitivity and a `#' parser.
790
791Case sensitivity is now controlled by a read option called
792`case-insensitive'. The user can add new `#' syntaxes with the
793`read-hash-extend' function (see below).
794
795*** The new function `read-hash-extend' allows the user to change the
796syntax of Guile Scheme in a somewhat controlled way.
797
798(read-hash-extend CHAR PROC)
799 When parsing S-expressions, if we read a `#' character followed by
800 the character CHAR, use PROC to parse an object from the stream.
801 If PROC is #f, remove any parsing procedure registered for CHAR.
802
803 The reader applies PROC to two arguments: CHAR and an input port.
804
805*** The new functions read-delimited and read-delimited! provide a
806general mechanism for doing delimited input on streams.
807
808(read-delimited DELIMS [PORT HANDLE-DELIM])
809 Read until we encounter one of the characters in DELIMS (a string),
810 or end-of-file. PORT is the input port to read from; it defaults to
811 the current input port. The HANDLE-DELIM parameter determines how
812 the terminating character is handled; it should be one of the
813 following symbols:
814
815 'trim omit delimiter from result
816 'peek leave delimiter character in input stream
817 'concat append delimiter character to returned value
818 'split return a pair: (RESULT . TERMINATOR)
819
820 HANDLE-DELIM defaults to 'peek.
821
822(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
823 A side-effecting variant of `read-delimited'.
824
825 The data is written into the string BUF at the indices in the
826 half-open interval [START, END); the default interval is the whole
827 string: START = 0 and END = (string-length BUF). The values of
828 START and END must specify a well-defined interval in BUF, i.e.
829 0 <= START <= END <= (string-length BUF).
830
831 It returns NBYTES, the number of bytes read. If the buffer filled
832 up without a delimiter character being found, it returns #f. If the
833 port is at EOF when the read starts, it returns the EOF object.
834
835 If an integer is returned (i.e., the read is successfully terminated
836 by reading a delimiter character), then the HANDLE-DELIM parameter
837 determines how to handle the terminating character. It is described
838 above, and defaults to 'peek.
839
840(The descriptions of these functions were borrowed from the SCSH
841manual, by Olin Shivers and Brian Carlstrom.)
842
843*** The `%read-delimited!' function is the primitive used to implement
844`read-delimited' and `read-delimited!'.
845
846(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
847
848This returns a pair of values: (TERMINATOR . NUM-READ).
849- TERMINATOR describes why the read was terminated. If it is a
850 character or the eof object, then that is the value that terminated
851 the read. If it is #f, the function filled the buffer without finding
852 a delimiting character.
853- NUM-READ is the number of characters read into BUF.
854
855If the read is successfully terminated by reading a delimiter
856character, then the gobble? parameter determines what to do with the
857terminating character. If true, the character is removed from the
858input stream; if false, the character is left in the input stream
859where a subsequent read operation will retrieve it. In either case,
860the character is also the first value returned by the procedure call.
861
862(The descriptions of this function was borrowed from the SCSH manual,
863by Olin Shivers and Brian Carlstrom.)
864
865*** The `read-line' and `read-line!' functions have changed; they now
866trim the terminator by default; previously they appended it to the
867returned string. For the old behavior, use (read-line PORT 'concat).
868
869*** The functions `uniform-array-read!' and `uniform-array-write!' now
870take new optional START and END arguments, specifying the region of
871the array to read and write.
872
f348c807
JB
873*** The `ungetc-char-ready?' function has been removed. We feel it's
874inappropriate for an interface to expose implementation details this
875way.
095936d2
JB
876
877** Changes to the Unix library and system call interface
878
879*** The new fcntl function provides access to the Unix `fcntl' system
880call.
881
882(fcntl PORT COMMAND VALUE)
883 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
884 Values for COMMAND are:
885
886 F_DUPFD duplicate a file descriptor
887 F_GETFD read the descriptor's close-on-exec flag
888 F_SETFD set the descriptor's close-on-exec flag to VALUE
889 F_GETFL read the descriptor's flags, as set on open
890 F_SETFL set the descriptor's flags, as set on open to VALUE
891 F_GETOWN return the process ID of a socket's owner, for SIGIO
892 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
893 FD_CLOEXEC not sure what this is
894
895For details, see the documentation for the fcntl system call.
896
897*** The arguments to `select' have changed, for compatibility with
898SCSH. The TIMEOUT parameter may now be non-integral, yielding the
899expected behavior. The MILLISECONDS parameter has been changed to
900MICROSECONDS, to more closely resemble the underlying system call.
901The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
902corresponding return set will be the same.
903
904*** The arguments to the `mknod' system call have changed. They are
905now:
906
907(mknod PATH TYPE PERMS DEV)
908 Create a new file (`node') in the file system. PATH is the name of
909 the file to create. TYPE is the kind of file to create; it should
910 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
911 permission bits to give the newly created file. If TYPE is
912 'block-special or 'char-special, DEV specifies which device the
913 special file refers to; its interpretation depends on the kind of
914 special file being created.
915
916*** The `fork' function has been renamed to `primitive-fork', to avoid
917clashing with various SCSH forks.
918
919*** The `recv' and `recvfrom' functions have been renamed to `recv!'
920and `recvfrom!'. They no longer accept a size for a second argument;
921you must pass a string to hold the received value. They no longer
922return the buffer. Instead, `recv' returns the length of the message
923received, and `recvfrom' returns a pair containing the packet's length
924and originating address.
925
926*** The file descriptor datatype has been removed, as have the
927`read-fd', `write-fd', `close', `lseek', and `dup' functions.
928We plan to replace these functions with a SCSH-compatible interface.
929
930*** The `create' function has been removed; it's just a special case
931of `open'.
932
933*** There are new functions to break down process termination status
934values. In the descriptions below, STATUS is a value returned by
935`waitpid'.
936
937(status:exit-val STATUS)
938 If the child process exited normally, this function returns the exit
939 code for the child process (i.e., the value passed to exit, or
940 returned from main). If the child process did not exit normally,
941 this function returns #f.
942
943(status:stop-sig STATUS)
944 If the child process was suspended by a signal, this function
945 returns the signal that suspended the child. Otherwise, it returns
946 #f.
947
948(status:term-sig STATUS)
949 If the child process terminated abnormally, this function returns
950 the signal that terminated the child. Otherwise, this function
951 returns false.
952
953POSIX promises that exactly one of these functions will return true on
954a valid STATUS value.
955
956These functions are compatible with SCSH.
957
958*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
959returned by `localtime', `gmtime', and that ilk. They are:
960
961 Component Accessor Setter
962 ========================= ============ ============
963 seconds tm:sec set-tm:sec
964 minutes tm:min set-tm:min
965 hours tm:hour set-tm:hour
966 day of the month tm:mday set-tm:mday
967 month tm:mon set-tm:mon
968 year tm:year set-tm:year
969 day of the week tm:wday set-tm:wday
970 day in the year tm:yday set-tm:yday
971 daylight saving time tm:isdst set-tm:isdst
972 GMT offset, seconds tm:gmtoff set-tm:gmtoff
973 name of time zone tm:zone set-tm:zone
974
095936d2
JB
975*** There are new accessors for the vectors returned by `uname',
976describing the host system:
48d224d7
JB
977
978 Component Accessor
979 ============================================== ================
980 name of the operating system implementation utsname:sysname
981 network name of this machine utsname:nodename
982 release level of the operating system utsname:release
983 version level of the operating system utsname:version
984 machine hardware platform utsname:machine
985
095936d2
JB
986*** There are new accessors for the vectors returned by `getpw',
987`getpwnam', `getpwuid', and `getpwent', describing entries from the
988system's user database:
989
990 Component Accessor
991 ====================== =================
992 user name passwd:name
993 user password passwd:passwd
994 user id passwd:uid
995 group id passwd:gid
996 real name passwd:gecos
997 home directory passwd:dir
998 shell program passwd:shell
999
1000*** There are new accessors for the vectors returned by `getgr',
1001`getgrnam', `getgrgid', and `getgrent', describing entries from the
1002system's group database:
1003
1004 Component Accessor
1005 ======================= ============
1006 group name group:name
1007 group password group:passwd
1008 group id group:gid
1009 group members group:mem
1010
1011*** There are new accessors for the vectors returned by `gethost',
1012`gethostbyaddr', `gethostbyname', and `gethostent', describing
1013internet hosts:
1014
1015 Component Accessor
1016 ========================= ===============
1017 official name of host hostent:name
1018 alias list hostent:aliases
1019 host address type hostent:addrtype
1020 length of address hostent:length
1021 list of addresses hostent:addr-list
1022
1023*** There are new accessors for the vectors returned by `getnet',
1024`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
1025networks:
1026
1027 Component Accessor
1028 ========================= ===============
1029 official name of net netent:name
1030 alias list netent:aliases
1031 net number type netent:addrtype
1032 net number netent:net
1033
1034*** There are new accessors for the vectors returned by `getproto',
1035`getprotobyname', `getprotobynumber', and `getprotoent', describing
1036internet protocols:
1037
1038 Component Accessor
1039 ========================= ===============
1040 official protocol name protoent:name
1041 alias list protoent:aliases
1042 protocol number protoent:proto
1043
1044*** There are new accessors for the vectors returned by `getserv',
1045`getservbyname', `getservbyport', and `getservent', describing
1046internet protocols:
1047
1048 Component Accessor
1049 ========================= ===============
1050 official service name servent:name
1051 alias list servent:aliases
1052 port number servent:port
1053 protocol to use servent:proto
1054
1055*** There are new accessors for the sockaddr structures returned by
1056`accept', `getsockname', `getpeername', `recvfrom!':
1057
1058 Component Accessor
1059 ======================================== ===============
1060 address format (`family') sockaddr:fam
1061 path, for file domain addresses sockaddr:path
1062 address, for internet domain addresses sockaddr:addr
1063 TCP or UDP port, for internet sockaddr:port
1064
1065*** The `getpwent', `getgrent', `gethostent', `getnetent',
1066`getprotoent', and `getservent' functions now return #f at the end of
1067the user database. (They used to throw an exception.)
1068
1069Note that calling MUMBLEent function is equivalent to calling the
1070corresponding MUMBLE function with no arguments.
1071
1072*** The `setpwent', `setgrent', `sethostent', `setnetent',
1073`setprotoent', and `setservent' routines now take no arguments.
1074
1075*** The `gethost', `getproto', `getnet', and `getserv' functions now
1076provide more useful information when they throw an exception.
1077
1078*** The `lnaof' function has been renamed to `inet-lnaof'.
1079
1080*** Guile now claims to have the `current-time' feature.
1081
1082*** The `mktime' function now takes an optional second argument ZONE,
1083giving the time zone to use for the conversion. ZONE should be a
1084string, in the same format as expected for the "TZ" environment variable.
1085
1086*** The `strptime' function now returns a pair (TIME . COUNT), where
1087TIME is the parsed time as a vector, and COUNT is the number of
1088characters from the string left unparsed. This function used to
1089return the remaining characters as a string.
1090
1091*** The `gettimeofday' function has replaced the old `time+ticks' function.
1092The return value is now (SECONDS . MICROSECONDS); the fractional
1093component is no longer expressed in "ticks".
1094
1095*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 1096
ea00ecba
MG
1097* Changes to the gh_ interface
1098
1099** gh_eval_str() now returns an SCM object which is the result of the
1100evaluation
1101
aaef0d2a
MG
1102** gh_scm2str() now copies the Scheme data to a caller-provided C
1103array
1104
1105** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
1106and returns the array
1107
1108** gh_scm2str0() is gone: there is no need to distinguish
1109null-terminated from non-null-terminated, since gh_scm2newstr() allows
1110the user to interpret the data both ways.
1111
f3b1485f
JB
1112* Changes to the scm_ interface
1113
095936d2
JB
1114** The new function scm_symbol_value0 provides an easy way to get a
1115symbol's value from C code:
1116
1117SCM scm_symbol_value0 (char *NAME)
1118 Return the value of the symbol named by the null-terminated string
1119 NAME in the current module. If the symbol named NAME is unbound in
1120 the current module, return SCM_UNDEFINED.
1121
1122** The new function scm_sysintern0 creates new top-level variables,
1123without assigning them a value.
1124
1125SCM scm_sysintern0 (char *NAME)
1126 Create a new Scheme top-level variable named NAME. NAME is a
1127 null-terminated string. Return the variable's value cell.
1128
1129** The function scm_internal_catch is the guts of catch. It handles
1130all the mechanics of setting up a catch target, invoking the catch
1131body, and perhaps invoking the handler if the body does a throw.
1132
1133The function is designed to be usable from C code, but is general
1134enough to implement all the semantics Guile Scheme expects from throw.
1135
1136TAG is the catch tag. Typically, this is a symbol, but this function
1137doesn't actually care about that.
1138
1139BODY is a pointer to a C function which runs the body of the catch;
1140this is the code you can throw from. We call it like this:
1141 BODY (BODY_DATA, JMPBUF)
1142where:
1143 BODY_DATA is just the BODY_DATA argument we received; we pass it
1144 through to BODY as its first argument. The caller can make
1145 BODY_DATA point to anything useful that BODY might need.
1146 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
1147 which we have just created and initialized.
1148
1149HANDLER is a pointer to a C function to deal with a throw to TAG,
1150should one occur. We call it like this:
1151 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
1152where
1153 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
1154 same idea as BODY_DATA above.
1155 THROWN_TAG is the tag that the user threw to; usually this is
1156 TAG, but it could be something else if TAG was #t (i.e., a
1157 catch-all), or the user threw to a jmpbuf.
1158 THROW_ARGS is the list of arguments the user passed to the THROW
1159 function.
1160
1161BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
1162is just a pointer we pass through to HANDLER. We don't actually
1163use either of those pointers otherwise ourselves. The idea is
1164that, if our caller wants to communicate something to BODY or
1165HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
1166HANDLER can then use. Think of it as a way to make BODY and
1167HANDLER closures, not just functions; MUMBLE_DATA points to the
1168enclosed variables.
1169
1170Of course, it's up to the caller to make sure that any data a
1171MUMBLE_DATA needs is protected from GC. A common way to do this is
1172to make MUMBLE_DATA a pointer to data stored in an automatic
1173structure variable; since the collector must scan the stack for
1174references anyway, this assures that any references in MUMBLE_DATA
1175will be found.
1176
1177** The new function scm_internal_lazy_catch is exactly like
1178scm_internal_catch, except:
1179
1180- It does not unwind the stack (this is the major difference).
1181- If handler returns, its value is returned from the throw.
1182- BODY always receives #f as its JMPBUF argument (since there's no
1183 jmpbuf associated with a lazy catch, because we don't unwind the
1184 stack.)
1185
1186** scm_body_thunk is a new body function you can pass to
1187scm_internal_catch if you want the body to be like Scheme's `catch'
1188--- a thunk, or a function of one argument if the tag is #f.
1189
1190BODY_DATA is a pointer to a scm_body_thunk_data structure, which
1191contains the Scheme procedure to invoke as the body, and the tag
1192we're catching. If the tag is #f, then we pass JMPBUF (created by
1193scm_internal_catch) to the body procedure; otherwise, the body gets
1194no arguments.
1195
1196** scm_handle_by_proc is a new handler function you can pass to
1197scm_internal_catch if you want the handler to act like Scheme's catch
1198--- call a procedure with the tag and the throw arguments.
1199
1200If the user does a throw to this catch, this function runs a handler
1201procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
1202variable holding the Scheme procedure object to invoke. It ought to
1203be a pointer to an automatic variable (i.e., one living on the stack),
1204or the procedure object should be otherwise protected from GC.
1205
1206** scm_handle_by_message is a new handler function to use with
1207`scm_internal_catch' if you want Guile to print a message and die.
1208It's useful for dealing with throws to uncaught keys at the top level.
1209
1210HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
1211message header to print; if zero, we use "guile" instead. That
1212text is followed by a colon, then the message described by ARGS.
1213
1214** The return type of scm_boot_guile is now void; the function does
1215not return a value, and indeed, never returns at all.
1216
f3b1485f
JB
1217** The new function scm_shell makes it easy for user applications to
1218process command-line arguments in a way that is compatible with the
1219stand-alone guile interpreter (which is in turn compatible with SCSH,
1220the Scheme shell).
1221
1222To use the scm_shell function, first initialize any guile modules
1223linked into your application, and then call scm_shell with the values
1224of ARGC and ARGV your `main' function received. scm_shell will adding
1225any SCSH-style meta-arguments from the top of the script file to the
1226argument vector, and then process the command-line arguments. This
1227generally means loading a script file or starting up an interactive
1228command interpreter. For details, see "Changes to the stand-alone
1229interpreter" above.
1230
095936d2
JB
1231** The new functions scm_get_meta_args and scm_count_argv help you
1232implement the SCSH-style meta-argument, `\'.
1233
1234char **scm_get_meta_args (int ARGC, char **ARGV)
1235 If the second element of ARGV is a string consisting of a single
1236 backslash character (i.e. "\\" in Scheme notation), open the file
1237 named by the following argument, parse arguments from it, and return
1238 the spliced command line. The returned array is terminated by a
1239 null pointer.
1240
1241 For details of argument parsing, see above, under "guile now accepts
1242 command-line arguments compatible with SCSH..."
1243
1244int scm_count_argv (char **ARGV)
1245 Count the arguments in ARGV, assuming it is terminated by a null
1246 pointer.
1247
1248For an example of how these functions might be used, see the source
1249code for the function scm_shell in libguile/script.c.
1250
1251You will usually want to use scm_shell instead of calling this
1252function yourself.
1253
1254** The new function scm_compile_shell_switches turns an array of
1255command-line arguments into Scheme code to carry out the actions they
1256describe. Given ARGC and ARGV, it returns a Scheme expression to
1257evaluate, and calls scm_set_program_arguments to make any remaining
1258command-line arguments available to the Scheme code. For example,
1259given the following arguments:
1260
1261 -e main -s ekko a speckled gecko
1262
1263scm_set_program_arguments will return the following expression:
1264
1265 (begin (load "ekko") (main (command-line)) (quit))
1266
1267You will usually want to use scm_shell instead of calling this
1268function yourself.
1269
1270** The function scm_shell_usage prints a usage message appropriate for
1271an interpreter that uses scm_compile_shell_switches to handle its
1272command-line arguments.
1273
1274void scm_shell_usage (int FATAL, char *MESSAGE)
1275 Print a usage message to the standard error output. If MESSAGE is
1276 non-zero, write it before the usage message, followed by a newline.
1277 If FATAL is non-zero, exit the process, using FATAL as the
1278 termination status. (If you want to be compatible with Guile,
1279 always use 1 as the exit status when terminating due to command-line
1280 usage problems.)
1281
1282You will usually want to use scm_shell instead of calling this
1283function yourself.
48d224d7
JB
1284
1285** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
1286expressions. It used to return SCM_EOL. Earth-shattering.
1287
1288** The macros for declaring scheme objects in C code have been
1289rearranged slightly. They are now:
1290
1291SCM_SYMBOL (C_NAME, SCHEME_NAME)
1292 Declare a static SCM variable named C_NAME, and initialize it to
1293 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
1294 be a C identifier, and SCHEME_NAME should be a C string.
1295
1296SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
1297 Just like SCM_SYMBOL, but make C_NAME globally visible.
1298
1299SCM_VCELL (C_NAME, SCHEME_NAME)
1300 Create a global variable at the Scheme level named SCHEME_NAME.
1301 Declare a static SCM variable named C_NAME, and initialize it to
1302 point to the Scheme variable's value cell.
1303
1304SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
1305 Just like SCM_VCELL, but make C_NAME globally visible.
1306
1307The `guile-snarf' script writes initialization code for these macros
1308to its standard output, given C source code as input.
1309
1310The SCM_GLOBAL macro is gone.
1311
1312** The scm_read_line and scm_read_line_x functions have been replaced
1313by Scheme code based on the %read-delimited! procedure (known to C
1314code as scm_read_delimited_x). See its description above for more
1315information.
48d224d7 1316
095936d2
JB
1317** The function scm_sys_open has been renamed to scm_open. It now
1318returns a port instead of an FD object.
ea00ecba 1319
095936d2
JB
1320* The dynamic linking support has changed. For more information, see
1321libguile/DYNAMIC-LINKING.
ea00ecba 1322
f7b47737
JB
1323\f
1324Guile 1.0b3
3065a62a 1325
f3b1485f
JB
1326User-visible changes from Thursday, September 5, 1996 until Guile 1.0
1327(Sun 5 Jan 1997):
3065a62a 1328
4b521edb 1329* Changes to the 'guile' program:
3065a62a 1330
4b521edb
JB
1331** Guile now loads some new files when it starts up. Guile first
1332searches the load path for init.scm, and loads it if found. Then, if
1333Guile is not being used to execute a script, and the user's home
1334directory contains a file named `.guile', Guile loads that.
c6486f8a 1335
4b521edb 1336** You can now use Guile as a shell script interpreter.
3065a62a
JB
1337
1338To paraphrase the SCSH manual:
1339
1340 When Unix tries to execute an executable file whose first two
1341 characters are the `#!', it treats the file not as machine code to
1342 be directly executed by the native processor, but as source code
1343 to be executed by some interpreter. The interpreter to use is
1344 specified immediately after the #! sequence on the first line of
1345 the source file. The kernel reads in the name of the interpreter,
1346 and executes that instead. It passes the interpreter the source
1347 filename as its first argument, with the original arguments
1348 following. Consult the Unix man page for the `exec' system call
1349 for more information.
1350
1a1945be
JB
1351Now you can use Guile as an interpreter, using a mechanism which is a
1352compatible subset of that provided by SCSH.
1353
3065a62a
JB
1354Guile now recognizes a '-s' command line switch, whose argument is the
1355name of a file of Scheme code to load. It also treats the two
1356characters `#!' as the start of a comment, terminated by `!#'. Thus,
1357to make a file of Scheme code directly executable by Unix, insert the
1358following two lines at the top of the file:
1359
1360#!/usr/local/bin/guile -s
1361!#
1362
1363Guile treats the argument of the `-s' command-line switch as the name
1364of a file of Scheme code to load, and treats the sequence `#!' as the
1365start of a block comment, terminated by `!#'.
1366
1367For example, here's a version of 'echo' written in Scheme:
1368
1369#!/usr/local/bin/guile -s
1370!#
1371(let loop ((args (cdr (program-arguments))))
1372 (if (pair? args)
1373 (begin
1374 (display (car args))
1375 (if (pair? (cdr args))
1376 (display " "))
1377 (loop (cdr args)))))
1378(newline)
1379
1380Why does `#!' start a block comment terminated by `!#', instead of the
1381end of the line? That is the notation SCSH uses, and although we
1382don't yet support the other SCSH features that motivate that choice,
1383we would like to be backward-compatible with any existing Guile
3763761c
JB
1384scripts once we do. Furthermore, if the path to Guile on your system
1385is too long for your kernel, you can start the script with this
1386horrible hack:
1387
1388#!/bin/sh
1389exec /really/long/path/to/guile -s "$0" ${1+"$@"}
1390!#
3065a62a
JB
1391
1392Note that some very old Unix systems don't support the `#!' syntax.
1393
c6486f8a 1394
4b521edb 1395** You can now run Guile without installing it.
6685dc83
JB
1396
1397Previous versions of the interactive Guile interpreter (`guile')
1398couldn't start up unless Guile's Scheme library had been installed;
1399they used the value of the environment variable `SCHEME_LOAD_PATH'
1400later on in the startup process, but not to find the startup code
1401itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
1402code.
1403
1404To run Guile without installing it, build it in the normal way, and
1405then set the environment variable `SCHEME_LOAD_PATH' to a
1406colon-separated list of directories, including the top-level directory
1407of the Guile sources. For example, if you unpacked Guile so that the
1408full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
1409you might say
1410
1411 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
1412
c6486f8a 1413
4b521edb
JB
1414** Guile's read-eval-print loop no longer prints #<unspecified>
1415results. If the user wants to see this, she can evaluate the
1416expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 1417file.
6685dc83 1418
4b521edb
JB
1419** Guile no longer shows backtraces by default when an error occurs;
1420however, it does display a message saying how to get one, and how to
1421request that they be displayed by default. After an error, evaluate
1422 (backtrace)
1423to see a backtrace, and
1424 (debug-enable 'backtrace)
1425to see them by default.
6685dc83 1426
6685dc83 1427
d9fb83d9 1428
4b521edb
JB
1429* Changes to Guile Scheme:
1430
1431** Guile now distinguishes between #f and the empty list.
1432
1433This is for compatibility with the IEEE standard, the (possibly)
1434upcoming Revised^5 Report on Scheme, and many extant Scheme
1435implementations.
1436
1437Guile used to have #f and '() denote the same object, to make Scheme's
1438type system more compatible with Emacs Lisp's. However, the change
1439caused too much trouble for Scheme programmers, and we found another
1440way to reconcile Emacs Lisp with Scheme that didn't require this.
1441
1442
1443** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
1444counterparts, delq!, delv!, and delete!, now remove all matching
1445elements from the list, not just the first. This matches the behavior
1446of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
1447functions which inspired them.
1448
1449I recognize that this change may break code in subtle ways, but it
1450seems best to make the change before the FSF's first Guile release,
1451rather than after.
1452
1453
4b521edb 1454** The compiled-library-path function has been deleted from libguile.
6685dc83 1455
4b521edb 1456** The facilities for loading Scheme source files have changed.
c6486f8a 1457
4b521edb 1458*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
1459for Scheme code. Its value is a list of strings, each of which names
1460a directory.
1461
4b521edb
JB
1462*** The variable %load-extensions now tells Guile which extensions to
1463try appending to a filename when searching the load path. Its value
1464is a list of strings. Its default value is ("" ".scm").
1465
1466*** (%search-load-path FILENAME) searches the directories listed in the
1467value of the %load-path variable for a Scheme file named FILENAME,
1468with all the extensions listed in %load-extensions. If it finds a
1469match, then it returns its full filename. If FILENAME is absolute, it
1470returns it unchanged. Otherwise, it returns #f.
6685dc83 1471
4b521edb
JB
1472%search-load-path will not return matches that refer to directories.
1473
1474*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
1475uses %seach-load-path to find a file named FILENAME, and loads it if
1476it finds it. If it can't read FILENAME for any reason, it throws an
1477error.
6685dc83
JB
1478
1479The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
1480`read' function.
1481
1482*** load uses the same searching semantics as primitive-load.
1483
1484*** The functions %try-load, try-load-with-path, %load, load-with-path,
1485basic-try-load-with-path, basic-load-with-path, try-load-module-with-
1486path, and load-module-with-path have been deleted. The functions
1487above should serve their purposes.
1488
1489*** If the value of the variable %load-hook is a procedure,
1490`primitive-load' applies its value to the name of the file being
1491loaded (without the load path directory name prepended). If its value
1492is #f, it is ignored. Otherwise, an error occurs.
1493
1494This is mostly useful for printing load notification messages.
1495
1496
1497** The function `eval!' is no longer accessible from the scheme level.
1498We can't allow operations which introduce glocs into the scheme level,
1499because Guile's type system can't handle these as data. Use `eval' or
1500`read-and-eval!' (see below) as replacement.
1501
1502** The new function read-and-eval! reads an expression from PORT,
1503evaluates it, and returns the result. This is more efficient than
1504simply calling `read' and `eval', since it is not necessary to make a
1505copy of the expression for the evaluator to munge.
1506
1507Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
1508for the `read' function.
1509
1510
1511** The function `int?' has been removed; its definition was identical
1512to that of `integer?'.
1513
1514** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
1515use the R4RS names for these functions.
1516
1517** The function object-properties no longer returns the hash handle;
1518it simply returns the object's property list.
1519
1520** Many functions have been changed to throw errors, instead of
1521returning #f on failure. The point of providing exception handling in
1522the language is to simplify the logic of user code, but this is less
1523useful if Guile's primitives don't throw exceptions.
1524
1525** The function `fileno' has been renamed from `%fileno'.
1526
1527** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
1528
1529
1530* Changes to Guile's C interface:
1531
1532** The library's initialization procedure has been simplified.
1533scm_boot_guile now has the prototype:
1534
1535void scm_boot_guile (int ARGC,
1536 char **ARGV,
1537 void (*main_func) (),
1538 void *closure);
1539
1540scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
1541MAIN_FUNC should do all the work of the program (initializing other
1542packages, reading user input, etc.) before returning. When MAIN_FUNC
1543returns, call exit (0); this function never returns. If you want some
1544other exit value, MAIN_FUNC may call exit itself.
1545
1546scm_boot_guile arranges for program-arguments to return the strings
1547given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
1548scm_set_program_arguments with the final list, so Scheme code will
1549know which arguments have been processed.
1550
1551scm_boot_guile establishes a catch-all catch handler which prints an
1552error message and exits the process. This means that Guile exits in a
1553coherent way when system errors occur and the user isn't prepared to
1554handle it. If the user doesn't like this behavior, they can establish
1555their own universal catcher in MAIN_FUNC to shadow this one.
1556
1557Why must the caller do all the real work from MAIN_FUNC? The garbage
1558collector assumes that all local variables of type SCM will be above
1559scm_boot_guile's stack frame on the stack. If you try to manipulate
1560SCM values after this function returns, it's the luck of the draw
1561whether the GC will be able to find the objects you allocate. So,
1562scm_boot_guile function exits, rather than returning, to discourage
1563people from making that mistake.
1564
1565The IN, OUT, and ERR arguments were removed; there are other
1566convenient ways to override these when desired.
1567
1568The RESULT argument was deleted; this function should never return.
1569
1570The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
1571general.
1572
1573
1574** Guile's header files should no longer conflict with your system's
1575header files.
1576
1577In order to compile code which #included <libguile.h>, previous
1578versions of Guile required you to add a directory containing all the
1579Guile header files to your #include path. This was a problem, since
1580Guile's header files have names which conflict with many systems'
1581header files.
1582
1583Now only <libguile.h> need appear in your #include path; you must
1584refer to all Guile's other header files as <libguile/mumble.h>.
1585Guile's installation procedure puts libguile.h in $(includedir), and
1586the rest in $(includedir)/libguile.
1587
1588
1589** Two new C functions, scm_protect_object and scm_unprotect_object,
1590have been added to the Guile library.
1591
1592scm_protect_object (OBJ) protects OBJ from the garbage collector.
1593OBJ will not be freed, even if all other references are dropped,
1594until someone does scm_unprotect_object (OBJ). Both functions
1595return OBJ.
1596
1597Note that calls to scm_protect_object do not nest. You can call
1598scm_protect_object any number of times on a given object, and the
1599next call to scm_unprotect_object will unprotect it completely.
1600
1601Basically, scm_protect_object and scm_unprotect_object just
1602maintain a list of references to things. Since the GC knows about
1603this list, all objects it mentions stay alive. scm_protect_object
1604adds its argument to the list; scm_unprotect_object remove its
1605argument from the list.
1606
1607
1608** scm_eval_0str now returns the value of the last expression
1609evaluated.
1610
1611** The new function scm_read_0str reads an s-expression from a
1612null-terminated string, and returns it.
1613
1614** The new function `scm_stdio_to_port' converts a STDIO file pointer
1615to a Scheme port object.
1616
1617** The new function `scm_set_program_arguments' allows C code to set
1618the value teruturned by the Scheme `program-arguments' function.
6685dc83 1619
6685dc83 1620\f
1a1945be
JB
1621Older changes:
1622
1623* Guile no longer includes sophisticated Tcl/Tk support.
1624
1625The old Tcl/Tk support was unsatisfying to us, because it required the
1626user to link against the Tcl library, as well as Tk and Guile. The
1627interface was also un-lispy, in that it preserved Tcl/Tk's practice of
1628referring to widgets by names, rather than exporting widgets to Scheme
1629code as a special datatype.
1630
1631In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
1632maintainers described some very interesting changes in progress to the
1633Tcl/Tk internals, which would facilitate clean interfaces between lone
1634Tk and other interpreters --- even for garbage-collected languages
1635like Scheme. They expected the new Tk to be publicly available in the
1636fall of 1996.
1637
1638Since it seems that Guile might soon have a new, cleaner interface to
1639lone Tk, and that the old Guile/Tk glue code would probably need to be
1640completely rewritten, we (Jim Blandy and Richard Stallman) have
1641decided not to support the old code. We'll spend the time instead on
1642a good interface to the newer Tk, as soon as it is available.
5c54da76 1643
8512dea6 1644Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 1645
5c54da76
JB
1646\f
1647Copyright information:
1648
ea00ecba 1649Copyright (C) 1996,1997 Free Software Foundation, Inc.
5c54da76
JB
1650
1651 Permission is granted to anyone to make or distribute verbatim copies
1652 of this document as received, in any medium, provided that the
1653 copyright notice and this permission notice are preserved,
1654 thus giving the recipient permission to redistribute in turn.
1655
1656 Permission is granted to distribute modified versions
1657 of this document, or of portions of it,
1658 under the above conditions, provided also that they
1659 carry prominent notices stating who last changed them.
1660
48d224d7
JB
1661\f
1662Local variables:
1663mode: outline
1664paragraph-separate: "[ \f]*$"
1665end:
1666