* gc.h: Remove all uses of SCM_P. (Thanks to Richard Polton.)
[bpt/guile.git] / NEWS
CommitLineData
f7b47737 1Guile NEWS --- history of user-visible changes. -*- text -*-
d23bbf3e 2Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
5c54da76
JB
3See the end for copying conditions.
4
e1b6c710 5Please send Guile bug reports to bug-guile@gnu.org.
5c54da76 6\f
f3227c7a
JB
7Changes since Guile 1.3:
8
9\f
d23bbf3e 10Changes in Guile 1.3 (released Monday, October 19, 1998):
c484bf7f
JB
11
12* Changes to the distribution
13
e2d6569c
JB
14** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
15To avoid conflicts, programs should name environment variables after
16themselves, except when there's a common practice establishing some
17other convention.
18
19For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
20giving the former precedence, and printing a warning message if the
21latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
22
23** The header files related to multi-byte characters have been removed.
24They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
25which referred to these explicitly will probably need to be rewritten,
26since the support for the variant string types has been removed; see
27below.
28
29** The header files append.h and sequences.h have been removed. These
30files implemented non-R4RS operations which would encourage
31non-portable programming style and less easy-to-read code.
3a97e020 32
c484bf7f
JB
33* Changes to the stand-alone interpreter
34
2e368582 35** New procedures have been added to implement a "batch mode":
ec4ab4fd 36
2e368582 37*** Function: batch-mode?
ec4ab4fd
GH
38
39 Returns a boolean indicating whether the interpreter is in batch
40 mode.
41
2e368582 42*** Function: set-batch-mode?! ARG
ec4ab4fd
GH
43
44 If ARG is true, switches the interpreter to batch mode. The `#f'
45 case has not been implemented.
46
2e368582
JB
47** Guile now provides full command-line editing, when run interactively.
48To use this feature, you must have the readline library installed.
49The Guile build process will notice it, and automatically include
50support for it.
51
52The readline library is available via anonymous FTP from any GNU
53mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
54
a5d6d578
MD
55** the-last-stack is now a fluid.
56
c484bf7f
JB
57* Changes to the procedure for linking libguile with your programs
58
71f20534 59** You can now use the `guile-config' utility to build programs that use Guile.
2e368582 60
2adfe1c0 61Guile now includes a command-line utility called `guile-config', which
71f20534
JB
62can provide information about how to compile and link programs that
63use Guile.
64
65*** `guile-config compile' prints any C compiler flags needed to use Guile.
66You should include this command's output on the command line you use
67to compile C or C++ code that #includes the Guile header files. It's
68usually just a `-I' flag to help the compiler find the Guile headers.
69
70
71*** `guile-config link' prints any linker flags necessary to link with Guile.
8aa5c148 72
71f20534 73This command writes to its standard output a list of flags which you
8aa5c148
JB
74must pass to the linker to link your code against the Guile library.
75The flags include '-lguile' itself, any other libraries the Guile
76library depends upon, and any `-L' flags needed to help the linker
77find those libraries.
2e368582
JB
78
79For example, here is a Makefile rule that builds a program named 'foo'
80from the object files ${FOO_OBJECTS}, and links them against Guile:
81
82 foo: ${FOO_OBJECTS}
2adfe1c0 83 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
2e368582 84
e2d6569c
JB
85Previous Guile releases recommended that you use autoconf to detect
86which of a predefined set of libraries were present on your system.
2adfe1c0 87It is more robust to use `guile-config', since it records exactly which
e2d6569c
JB
88libraries the installed Guile library requires.
89
2adfe1c0
JB
90This was originally called `build-guile', but was renamed to
91`guile-config' before Guile 1.3 was released, to be consistent with
92the analogous script for the GTK+ GUI toolkit, which is called
93`gtk-config'.
94
2e368582 95
8aa5c148
JB
96** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
97
98If you are using the GNU autoconf package to configure your program,
99you can use the GUILE_FLAGS autoconf macro to call `guile-config'
100(described above) and gather the necessary values for use in your
101Makefiles.
102
103The GUILE_FLAGS macro expands to configure script code which runs the
104`guile-config' script, to find out where Guile's header files and
105libraries are installed. It sets two variables, marked for
106substitution, as by AC_SUBST.
107
108 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
109 code that uses Guile header files. This is almost always just a
110 -I flag.
111
112 GUILE_LDFLAGS --- flags to pass to the linker to link a
113 program against Guile. This includes `-lguile' for the Guile
114 library itself, any libraries that Guile itself requires (like
115 -lqthreads), and so on. It may also include a -L flag to tell the
116 compiler where to find the libraries.
117
118GUILE_FLAGS is defined in the file guile.m4, in the top-level
119directory of the Guile distribution. You can copy it into your
120package's aclocal.m4 file, and then use it in your configure.in file.
121
122If you are using the `aclocal' program, distributed with GNU automake,
123to maintain your aclocal.m4 file, the Guile installation process
124installs guile.m4 where aclocal will find it. All you need to do is
125use GUILE_FLAGS in your configure.in file, and then run `aclocal';
126this will copy the definition of GUILE_FLAGS into your aclocal.m4
127file.
128
129
c484bf7f 130* Changes to Scheme functions and syntax
7ad3c1e7 131
02755d59 132** Multi-byte strings have been removed, as have multi-byte and wide
e2d6569c
JB
133ports. We felt that these were the wrong approach to
134internationalization support.
02755d59 135
2e368582
JB
136** New function: readline [PROMPT]
137Read a line from the terminal, and allow the user to edit it,
138prompting with PROMPT. READLINE provides a large set of Emacs-like
139editing commands, lets the user recall previously typed lines, and
140works on almost every kind of terminal, including dumb terminals.
141
142READLINE assumes that the cursor is at the beginning of the line when
143it is invoked. Thus, you can't print a prompt yourself, and then call
144READLINE; you need to package up your prompt as a string, pass it to
145the function, and let READLINE print the prompt itself. This is
146because READLINE needs to know the prompt's screen width.
147
8cd57bd0
JB
148For Guile to provide this function, you must have the readline
149library, version 2.1 or later, installed on your system. Readline is
150available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
151any GNU mirror site.
2e368582
JB
152
153See also ADD-HISTORY function.
154
155** New function: add-history STRING
156Add STRING as the most recent line in the history used by the READLINE
157command. READLINE does not add lines to the history itself; you must
158call ADD-HISTORY to make previous input available to the user.
159
8cd57bd0
JB
160** The behavior of the read-line function has changed.
161
162This function now uses standard C library functions to read the line,
163for speed. This means that it doesn not respect the value of
164scm-line-incrementors; it assumes that lines are delimited with
165#\newline.
166
167(Note that this is read-line, the function that reads a line of text
168from a port, not readline, the function that reads a line from a
169terminal, providing full editing capabilities.)
170
1a0106ef
JB
171** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
172
173This module provides some simple argument parsing. It exports one
174function:
175
176Function: getopt-gnu-style ARG-LS
177 Parse a list of program arguments into an alist of option
178 descriptions.
179
180 Each item in the list of program arguments is examined to see if
181 it meets the syntax of a GNU long-named option. An argument like
182 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
183 returned alist, where MUMBLE is a keyword object with the same
184 name as the argument. An argument like `--MUMBLE=FROB' produces
185 an element of the form (MUMBLE . FROB), where FROB is a string.
186
187 As a special case, the returned alist also contains a pair whose
188 car is the symbol `rest'. The cdr of this pair is a list
189 containing all the items in the argument list that are not options
190 of the form mentioned above.
191
192 The argument `--' is treated specially: all items in the argument
193 list appearing after such an argument are not examined, and are
194 returned in the special `rest' list.
195
196 This function does not parse normal single-character switches.
197 You will need to parse them out of the `rest' list yourself.
198
8cd57bd0
JB
199** The read syntax for byte vectors and short vectors has changed.
200
201Instead of #bytes(...), write #y(...).
202
203Instead of #short(...), write #h(...).
204
205This may seem nutty, but, like the other uniform vectors, byte vectors
206and short vectors want to have the same print and read syntax (and,
207more basic, want to have read syntax!). Changing the read syntax to
208use multiple characters after the hash sign breaks with the
209conventions used in R5RS and the conventions used for the other
210uniform vectors. It also introduces complexity in the current reader,
211both on the C and Scheme levels. (The Right solution is probably to
212change the syntax and prototypes for uniform vectors entirely.)
213
214
215** The new module (ice-9 session) provides useful interactive functions.
216
217*** New procedure: (apropos REGEXP OPTION ...)
218
219Display a list of top-level variables whose names match REGEXP, and
220the modules they are imported from. Each OPTION should be one of the
221following symbols:
222
223 value --- Show the value of each matching variable.
224 shadow --- Show bindings shadowed by subsequently imported modules.
225 full --- Same as both `shadow' and `value'.
226
227For example:
228
229 guile> (apropos "trace" 'full)
230 debug: trace #<procedure trace args>
231 debug: untrace #<procedure untrace args>
232 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
233 the-scm-module: before-backtrace-hook ()
234 the-scm-module: backtrace #<primitive-procedure backtrace>
235 the-scm-module: after-backtrace-hook ()
236 the-scm-module: has-shown-backtrace-hint? #f
237 guile>
238
239** There are new functions and syntax for working with macros.
240
241Guile implements macros as a special object type. Any variable whose
242top-level binding is a macro object acts as a macro. The macro object
243specifies how the expression should be transformed before evaluation.
244
245*** Macro objects now print in a reasonable way, resembling procedures.
246
247*** New function: (macro? OBJ)
248True iff OBJ is a macro object.
249
250*** New function: (primitive-macro? OBJ)
251Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
252macro transformers, implemented in eval.c rather than Scheme code.
253
254*** New function: (macro-type OBJ)
255Return a value indicating what kind of macro OBJ is. Possible return
256values are:
257
258 The symbol `syntax' --- a macro created by procedure->syntax.
259 The symbol `macro' --- a macro created by procedure->macro.
260 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
261 The boolean #f --- if OBJ is not a macro object.
262
263*** New function: (macro-name MACRO)
264Return the name of the macro object MACRO's procedure, as returned by
265procedure-name.
266
267*** New function: (macro-transformer MACRO)
268Return the transformer procedure for MACRO.
269
270*** New syntax: (use-syntax MODULE ... TRANSFORMER)
271
272Specify a new macro expander to use in the current module. Each
273MODULE is a module name, with the same meaning as in the `use-modules'
274form; each named module's exported bindings are added to the current
275top-level environment. TRANSFORMER is an expression evaluated in the
276resulting environment which must yield a procedure to use as the
277module's eval transformer: every expression evaluated in this module
278is passed to this function, and the result passed to the Guile
279interpreter.
280
281*** macro-eval! is removed. Use local-eval instead.
29521173 282
8d9dcb3c
MV
283** Some magic has been added to the printer to better handle user
284written printing routines (like record printers, closure printers).
285
286The problem is that these user written routines must have access to
7fbd77df 287the current `print-state' to be able to handle fancy things like
8d9dcb3c
MV
288detection of circular references. These print-states have to be
289passed to the builtin printing routines (display, write, etc) to
290properly continue the print chain.
291
292We didn't want to change all existing print code so that it
8cd57bd0 293explicitly passes thru a print state in addition to a port. Instead,
8d9dcb3c
MV
294we extented the possible values that the builtin printing routines
295accept as a `port'. In addition to a normal port, they now also take
296a pair of a normal port and a print-state. Printing will go to the
297port and the print-state will be used to control the detection of
298circular references, etc. If the builtin function does not care for a
299print-state, it is simply ignored.
300
301User written callbacks are now called with such a pair as their
302`port', but because every function now accepts this pair as a PORT
303argument, you don't have to worry about that. In fact, it is probably
304safest to not check for these pairs.
305
306However, it is sometimes necessary to continue a print chain on a
307different port, for example to get a intermediate string
308representation of the printed value, mangle that string somehow, and
309then to finally print the mangled string. Use the new function
310
311 inherit-print-state OLD-PORT NEW-PORT
312
313for this. It constructs a new `port' that prints to NEW-PORT but
314inherits the print-state of OLD-PORT.
315
ef1ea498
MD
316** struct-vtable-offset renamed to vtable-offset-user
317
318** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
319
320** There is now a fourth (optional) argument to make-vtable-vtable and
321 make-struct when constructing new types (vtables). This argument
322 initializes field vtable-index-printer of the vtable.
323
4851dc57
MV
324** The detection of circular references has been extended to structs.
325That is, a structure that -- in the process of being printed -- prints
326itself does not lead to infinite recursion.
327
328** There is now some basic support for fluids. Please read
329"libguile/fluid.h" to find out more. It is accessible from Scheme with
330the following functions and macros:
331
9c3fb66f
MV
332Function: make-fluid
333
334 Create a new fluid object. Fluids are not special variables or
335 some other extension to the semantics of Scheme, but rather
336 ordinary Scheme objects. You can store them into variables (that
337 are still lexically scoped, of course) or into any other place you
338 like. Every fluid has a initial value of `#f'.
04c76b58 339
9c3fb66f 340Function: fluid? OBJ
04c76b58 341
9c3fb66f 342 Test whether OBJ is a fluid.
04c76b58 343
9c3fb66f
MV
344Function: fluid-ref FLUID
345Function: fluid-set! FLUID VAL
04c76b58
MV
346
347 Access/modify the fluid FLUID. Modifications are only visible
348 within the current dynamic root (that includes threads).
349
9c3fb66f
MV
350Function: with-fluids* FLUIDS VALUES THUNK
351
352 FLUIDS is a list of fluids and VALUES a corresponding list of
353 values for these fluids. Before THUNK gets called the values are
354 installed in the fluids and the old values of the fluids are
355 saved in the VALUES list. When the flow of control leaves THUNK
356 or reenters it, the values get swapped again. You might think of
357 this as a `safe-fluid-excursion'. Note that the VALUES list is
358 modified by `with-fluids*'.
359
360Macro: with-fluids ((FLUID VALUE) ...) FORM ...
361
362 The same as `with-fluids*' but with a different syntax. It looks
363 just like `let', but both FLUID and VALUE are evaluated. Remember,
364 fluids are not special variables but ordinary objects. FLUID
365 should evaluate to a fluid.
04c76b58 366
e2d6569c 367** Changes to system call interfaces:
64d01d13 368
e2d6569c 369*** close-port, close-input-port and close-output-port now return a
64d01d13
GH
370boolean instead of an `unspecified' object. #t means that the port
371was successfully closed, while #f means it was already closed. It is
372also now possible for these procedures to raise an exception if an
373error occurs (some errors from write can be delayed until close.)
374
e2d6569c 375*** the first argument to chmod, fcntl, ftell and fseek can now be a
6afcd3b2
GH
376file descriptor.
377
e2d6569c 378*** the third argument to fcntl is now optional.
6afcd3b2 379
e2d6569c 380*** the first argument to chown can now be a file descriptor or a port.
6afcd3b2 381
e2d6569c 382*** the argument to stat can now be a port.
6afcd3b2 383
e2d6569c 384*** The following new procedures have been added (most use scsh
64d01d13
GH
385interfaces):
386
e2d6569c 387*** procedure: close PORT/FD
ec4ab4fd
GH
388 Similar to close-port (*note close-port: Closing Ports.), but also
389 works on file descriptors. A side effect of closing a file
390 descriptor is that any ports using that file descriptor are moved
391 to a different file descriptor and have their revealed counts set
392 to zero.
393
e2d6569c 394*** procedure: port->fdes PORT
ec4ab4fd
GH
395 Returns the integer file descriptor underlying PORT. As a side
396 effect the revealed count of PORT is incremented.
397
e2d6569c 398*** procedure: fdes->ports FDES
ec4ab4fd
GH
399 Returns a list of existing ports which have FDES as an underlying
400 file descriptor, without changing their revealed counts.
401
e2d6569c 402*** procedure: fdes->inport FDES
ec4ab4fd
GH
403 Returns an existing input port which has FDES as its underlying
404 file descriptor, if one exists, and increments its revealed count.
405 Otherwise, returns a new input port with a revealed count of 1.
406
e2d6569c 407*** procedure: fdes->outport FDES
ec4ab4fd
GH
408 Returns an existing output port which has FDES as its underlying
409 file descriptor, if one exists, and increments its revealed count.
410 Otherwise, returns a new output port with a revealed count of 1.
411
412 The next group of procedures perform a `dup2' system call, if NEWFD
413(an integer) is supplied, otherwise a `dup'. The file descriptor to be
414duplicated can be supplied as an integer or contained in a port. The
64d01d13
GH
415type of value returned varies depending on which procedure is used.
416
ec4ab4fd
GH
417 All procedures also have the side effect when performing `dup2' that
418any ports using NEWFD are moved to a different file descriptor and have
64d01d13
GH
419their revealed counts set to zero.
420
e2d6569c 421*** procedure: dup->fdes PORT/FD [NEWFD]
ec4ab4fd 422 Returns an integer file descriptor.
64d01d13 423
e2d6569c 424*** procedure: dup->inport PORT/FD [NEWFD]
ec4ab4fd 425 Returns a new input port using the new file descriptor.
64d01d13 426
e2d6569c 427*** procedure: dup->outport PORT/FD [NEWFD]
ec4ab4fd 428 Returns a new output port using the new file descriptor.
64d01d13 429
e2d6569c 430*** procedure: dup PORT/FD [NEWFD]
ec4ab4fd
GH
431 Returns a new port if PORT/FD is a port, with the same mode as the
432 supplied port, otherwise returns an integer file descriptor.
64d01d13 433
e2d6569c 434*** procedure: dup->port PORT/FD MODE [NEWFD]
ec4ab4fd
GH
435 Returns a new port using the new file descriptor. MODE supplies a
436 mode string for the port (*note open-file: File Ports.).
64d01d13 437
e2d6569c 438*** procedure: setenv NAME VALUE
ec4ab4fd
GH
439 Modifies the environment of the current process, which is also the
440 default environment inherited by child processes.
64d01d13 441
ec4ab4fd
GH
442 If VALUE is `#f', then NAME is removed from the environment.
443 Otherwise, the string NAME=VALUE is added to the environment,
444 replacing any existing string with name matching NAME.
64d01d13 445
ec4ab4fd 446 The return value is unspecified.
956055a9 447
e2d6569c 448*** procedure: truncate-file OBJ SIZE
6afcd3b2
GH
449 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
450 can be a string containing a file name or an integer file
451 descriptor or port open for output on the file. The underlying
452 system calls are `truncate' and `ftruncate'.
453
454 The return value is unspecified.
455
e2d6569c 456*** procedure: setvbuf PORT MODE [SIZE]
7a6f1ffa
GH
457 Set the buffering mode for PORT. MODE can be:
458 `_IONBF'
459 non-buffered
460
461 `_IOLBF'
462 line buffered
463
464 `_IOFBF'
465 block buffered, using a newly allocated buffer of SIZE bytes.
466 However if SIZE is zero or unspecified, the port will be made
467 non-buffered.
468
469 This procedure should not be used after I/O has been performed with
470 the port.
471
472 Ports are usually block buffered by default, with a default buffer
473 size. Procedures e.g., *Note open-file: File Ports, which accept a
474 mode string allow `0' to be added to request an unbuffered port.
475
e2d6569c 476*** procedure: fsync PORT/FD
6afcd3b2
GH
477 Copies any unwritten data for the specified output file descriptor
478 to disk. If PORT/FD is a port, its buffer is flushed before the
479 underlying file descriptor is fsync'd. The return value is
480 unspecified.
481
e2d6569c 482*** procedure: open-fdes PATH FLAGS [MODES]
6afcd3b2
GH
483 Similar to `open' but returns a file descriptor instead of a port.
484
e2d6569c 485*** procedure: execle PATH ENV [ARG] ...
6afcd3b2
GH
486 Similar to `execl', but the environment of the new process is
487 specified by ENV, which must be a list of strings as returned by
488 the `environ' procedure.
489
490 This procedure is currently implemented using the `execve' system
491 call, but we call it `execle' because of its Scheme calling
492 interface.
493
e2d6569c 494*** procedure: strerror ERRNO
ec4ab4fd
GH
495 Returns the Unix error message corresponding to ERRNO, an integer.
496
e2d6569c 497*** procedure: primitive-exit [STATUS]
6afcd3b2
GH
498 Terminate the current process without unwinding the Scheme stack.
499 This is would typically be useful after a fork. The exit status
500 is STATUS if supplied, otherwise zero.
501
e2d6569c 502*** procedure: times
6afcd3b2
GH
503 Returns an object with information about real and processor time.
504 The following procedures accept such an object as an argument and
505 return a selected component:
506
507 `tms:clock'
508 The current real time, expressed as time units relative to an
509 arbitrary base.
510
511 `tms:utime'
512 The CPU time units used by the calling process.
513
514 `tms:stime'
515 The CPU time units used by the system on behalf of the
516 calling process.
517
518 `tms:cutime'
519 The CPU time units used by terminated child processes of the
520 calling process, whose status has been collected (e.g., using
521 `waitpid').
522
523 `tms:cstime'
524 Similarly, the CPU times units used by the system on behalf of
525 terminated child processes.
7ad3c1e7 526
e2d6569c
JB
527** Removed: list-length
528** Removed: list-append, list-append!
529** Removed: list-reverse, list-reverse!
530
531** array-map renamed to array-map!
532
533** serial-array-map renamed to serial-array-map!
534
660f41fa
MD
535** catch doesn't take #f as first argument any longer
536
537Previously, it was possible to pass #f instead of a key to `catch'.
538That would cause `catch' to pass a jump buffer object to the procedure
539passed as second argument. The procedure could then use this jump
540buffer objekt as an argument to throw.
541
542This mechanism has been removed since its utility doesn't motivate the
543extra complexity it introduces.
544
332d00f6
JB
545** The `#/' notation for lists now provokes a warning message from Guile.
546This syntax will be removed from Guile in the near future.
547
548To disable the warning message, set the GUILE_HUSH environment
549variable to any non-empty value.
550
8cd57bd0
JB
551** The newline character now prints as `#\newline', following the
552normal Scheme notation, not `#\nl'.
553
c484bf7f
JB
554* Changes to the gh_ interface
555
8986901b
JB
556** The gh_enter function now takes care of loading the Guile startup files.
557gh_enter works by calling scm_boot_guile; see the remarks below.
558
5424b4f7
MD
559** Function: void gh_write (SCM x)
560
561Write the printed representation of the scheme object x to the current
562output port. Corresponds to the scheme level `write'.
563
3a97e020
MD
564** gh_list_length renamed to gh_length.
565
8d6787b6
MG
566** vector handling routines
567
568Several major changes. In particular, gh_vector() now resembles
569(vector ...) (with a caveat -- see manual), and gh_make_vector() now
956328d2
MG
570exists and behaves like (make-vector ...). gh_vset() and gh_vref()
571have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
8d6787b6
MG
572vector-related gh_ functions have been implemented.
573
7fee59bd
MG
574** pair and list routines
575
576Implemented several of the R4RS pair and list functions that were
577missing.
578
171422a9
MD
579** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
580
581New function. Converts double arrays back and forth between Scheme
582and C.
583
c484bf7f
JB
584* Changes to the scm_ interface
585
8986901b
JB
586** The function scm_boot_guile now takes care of loading the startup files.
587
588Guile's primary initialization function, scm_boot_guile, now takes
589care of loading `boot-9.scm', in the `ice-9' module, to initialize
590Guile, define the module system, and put together some standard
591bindings. It also loads `init.scm', which is intended to hold
592site-specific initialization code.
593
594Since Guile cannot operate properly until boot-9.scm is loaded, there
595is no reason to separate loading boot-9.scm from Guile's other
596initialization processes.
597
598This job used to be done by scm_compile_shell_switches, which didn't
599make much sense; in particular, it meant that people using Guile for
600non-shell-like applications had to jump through hoops to get Guile
601initialized properly.
602
603** The function scm_compile_shell_switches no longer loads the startup files.
604Now, Guile always loads the startup files, whenever it is initialized;
605see the notes above for scm_boot_guile and scm_load_startup_files.
606
607** Function: scm_load_startup_files
608This new function takes care of loading Guile's initialization file
609(`boot-9.scm'), and the site initialization file, `init.scm'. Since
610this is always called by the Guile initialization process, it's
611probably not too useful to call this yourself, but it's there anyway.
612
87148d9e
JB
613** The semantics of smob marking have changed slightly.
614
615The smob marking function (the `mark' member of the scm_smobfuns
616structure) is no longer responsible for setting the mark bit on the
617smob. The generic smob handling code in the garbage collector will
618set this bit. The mark function need only ensure that any other
619objects the smob refers to get marked.
620
621Note that this change means that the smob's GC8MARK bit is typically
622already set upon entry to the mark function. Thus, marking functions
623which look like this:
624
625 {
626 if (SCM_GC8MARKP (ptr))
627 return SCM_BOOL_F;
628 SCM_SETGC8MARK (ptr);
629 ... mark objects to which the smob refers ...
630 }
631
632are now incorrect, since they will return early, and fail to mark any
633other objects the smob refers to. Some code in the Guile library used
634to work this way.
635
1cf84ea5
JB
636** The semantics of the I/O port functions in scm_ptobfuns have changed.
637
638If you have implemented your own I/O port type, by writing the
639functions required by the scm_ptobfuns and then calling scm_newptob,
640you will need to change your functions slightly.
641
642The functions in a scm_ptobfuns structure now expect the port itself
643as their argument; they used to expect the `stream' member of the
644port's scm_port_table structure. This allows functions in an
645scm_ptobfuns structure to easily access the port's cell (and any flags
646it its CAR), and the port's scm_port_table structure.
647
648Guile now passes the I/O port itself as the `port' argument in the
649following scm_ptobfuns functions:
650
651 int (*free) (SCM port);
652 int (*fputc) (int, SCM port);
653 int (*fputs) (char *, SCM port);
654 scm_sizet (*fwrite) SCM_P ((char *ptr,
655 scm_sizet size,
656 scm_sizet nitems,
657 SCM port));
658 int (*fflush) (SCM port);
659 int (*fgetc) (SCM port);
660 int (*fclose) (SCM port);
661
662The interfaces to the `mark', `print', `equalp', and `fgets' methods
663are unchanged.
664
665If you have existing code which defines its own port types, it is easy
666to convert your code to the new interface; simply apply SCM_STREAM to
667the port argument to yield the value you code used to expect.
668
669Note that since both the port and the stream have the same type in the
670C code --- they are both SCM values --- the C compiler will not remind
671you if you forget to update your scm_ptobfuns functions.
672
673
933a7411
MD
674** Function: int scm_internal_select (int fds,
675 SELECT_TYPE *rfds,
676 SELECT_TYPE *wfds,
677 SELECT_TYPE *efds,
678 struct timeval *timeout);
679
680This is a replacement for the `select' function provided by the OS.
681It enables I/O blocking and sleeping to happen for one cooperative
682thread without blocking other threads. It also avoids busy-loops in
683these situations. It is intended that all I/O blocking and sleeping
684will finally go through this function. Currently, this function is
685only available on systems providing `gettimeofday' and `select'.
686
5424b4f7
MD
687** Function: SCM scm_internal_stack_catch (SCM tag,
688 scm_catch_body_t body,
689 void *body_data,
690 scm_catch_handler_t handler,
691 void *handler_data)
692
693A new sibling to the other two C level `catch' functions
694scm_internal_catch and scm_internal_lazy_catch. Use it if you want
695the stack to be saved automatically into the variable `the-last-stack'
696(scm_the_last_stack_var) on error. This is necessary if you want to
697use advanced error reporting, such as calling scm_display_error and
698scm_display_backtrace. (They both take a stack object as argument.)
699
df366c26
MD
700** Function: SCM scm_spawn_thread (scm_catch_body_t body,
701 void *body_data,
702 scm_catch_handler_t handler,
703 void *handler_data)
704
705Spawns a new thread. It does a job similar to
706scm_call_with_new_thread but takes arguments more suitable when
707spawning threads from application C code.
708
88482b31
MD
709** The hook scm_error_callback has been removed. It was originally
710intended as a way for the user to install his own error handler. But
711that method works badly since it intervenes between throw and catch,
712thereby changing the semantics of expressions like (catch #t ...).
713The correct way to do it is to use one of the C level catch functions
714in throw.c: scm_internal_catch/lazy_catch/stack_catch.
715
3a97e020
MD
716** Removed functions:
717
718scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
719scm_list_reverse, scm_list_reverse_x
720
721** New macros: SCM_LISTn where n is one of the integers 0-9.
722
723These can be used for pretty list creation from C. The idea is taken
724from Erick Gallesio's STk.
725
298aa6e3
MD
726** scm_array_map renamed to scm_array_map_x
727
527da704
MD
728** mbstrings are now removed
729
730This means that the type codes scm_tc7_mb_string and
731scm_tc7_mb_substring has been removed.
732
8cd57bd0
JB
733** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
734
735Since we no longer support multi-byte strings, these I/O functions
736have been simplified, and renamed. Here are their old names, and
737their new names and arguments:
738
739scm_gen_putc -> void scm_putc (int c, SCM port);
740scm_gen_puts -> void scm_puts (char *s, SCM port);
741scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
742scm_gen_getc -> void scm_getc (SCM port);
743
744
527da704
MD
745** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
746
747** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
748
749SCM_TYP7S now masks away the bit which distinguishes substrings from
750strings.
751
660f41fa
MD
752** scm_catch_body_t: Backward incompatible change!
753
754Body functions to scm_internal_catch and friends do not any longer
755take a second argument. This is because it is no longer possible to
756pass a #f arg to catch.
757
a8e05009
JB
758** Calls to scm_protect_object and scm_unprotect now nest properly.
759
760The function scm_protect_object protects its argument from being freed
761by the garbage collector. scm_unprotect_object removes that
762protection.
763
764These functions now nest properly. That is, for every object O, there
765is a counter which scm_protect_object(O) increments and
766scm_unprotect_object(O) decrements, if the counter is greater than
767zero. Every object's counter is zero when it is first created. If an
768object's counter is greater than zero, the garbage collector will not
769reclaim its storage.
770
771This allows you to use scm_protect_object in your code without
772worrying that some other function you call will call
773scm_unprotect_object, and allow it to be freed. Assuming that the
774functions you call are well-behaved, and unprotect only those objects
775they protect, you can follow the same rule and have confidence that
776objects will be freed only at appropriate times.
777
c484bf7f
JB
778\f
779Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 780
737c9113
JB
781* Changes to the distribution
782
832b09ed
JB
783** Nightly snapshots are now available from ftp.red-bean.com.
784The old server, ftp.cyclic.com, has been relinquished to its rightful
785owner.
786
787Nightly snapshots of the Guile development sources are now available via
788anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
789
790Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
791For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
792
0fcab5ed
JB
793** To run Guile without installing it, the procedure has changed a bit.
794
795If you used a separate build directory to compile Guile, you'll need
796to include the build directory in SCHEME_LOAD_PATH, as well as the
797source directory. See the `INSTALL' file for examples.
798
737c9113
JB
799* Changes to the procedure for linking libguile with your programs
800
94982a4e
JB
801** The standard Guile load path for Scheme code now includes
802$(datadir)/guile (usually /usr/local/share/guile). This means that
803you can install your own Scheme files there, and Guile will find them.
804(Previous versions of Guile only checked a directory whose name
805contained the Guile version number, so you had to re-install or move
806your Scheme sources each time you installed a fresh version of Guile.)
807
808The load path also includes $(datadir)/guile/site; we recommend
809putting individual Scheme files there. If you want to install a
810package with multiple source files, create a directory for them under
811$(datadir)/guile.
812
813** Guile 1.2 will now use the Rx regular expression library, if it is
814installed on your system. When you are linking libguile into your own
815programs, this means you will have to link against -lguile, -lqt (if
816you configured Guile with thread support), and -lrx.
27590f82
JB
817
818If you are using autoconf to generate configuration scripts for your
819application, the following lines should suffice to add the appropriate
820libraries to your link command:
821
822### Find Rx, quickthreads and libguile.
823AC_CHECK_LIB(rx, main)
824AC_CHECK_LIB(qt, main)
825AC_CHECK_LIB(guile, scm_shell)
826
94982a4e
JB
827The Guile 1.2 distribution does not contain sources for the Rx
828library, as Guile 1.0 did. If you want to use Rx, you'll need to
829retrieve it from a GNU FTP site and install it separately.
830
b83b8bee
JB
831* Changes to Scheme functions and syntax
832
e035e7e6
MV
833** The dynamic linking features of Guile are now enabled by default.
834You can disable them by giving the `--disable-dynamic-linking' option
835to configure.
836
e035e7e6
MV
837 (dynamic-link FILENAME)
838
839 Find the object file denoted by FILENAME (a string) and link it
840 into the running Guile application. When everything works out,
841 return a Scheme object suitable for representing the linked object
842 file. Otherwise an error is thrown. How object files are
843 searched is system dependent.
844
845 (dynamic-object? VAL)
846
847 Determine whether VAL represents a dynamically linked object file.
848
849 (dynamic-unlink DYNOBJ)
850
851 Unlink the indicated object file from the application. DYNOBJ
852 should be one of the values returned by `dynamic-link'.
853
854 (dynamic-func FUNCTION DYNOBJ)
855
856 Search the C function indicated by FUNCTION (a string or symbol)
857 in DYNOBJ and return some Scheme object that can later be used
858 with `dynamic-call' to actually call this function. Right now,
859 these Scheme objects are formed by casting the address of the
860 function to `long' and converting this number to its Scheme
861 representation.
862
863 (dynamic-call FUNCTION DYNOBJ)
864
865 Call the C function indicated by FUNCTION and DYNOBJ. The
866 function is passed no arguments and its return value is ignored.
867 When FUNCTION is something returned by `dynamic-func', call that
868 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
869 etc.), look it up in DYNOBJ; this is equivalent to
870
871 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
872
873 Interrupts are deferred while the C function is executing (with
874 SCM_DEFER_INTS/SCM_ALLOW_INTS).
875
876 (dynamic-args-call FUNCTION DYNOBJ ARGS)
877
878 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
879 some arguments and return its return value. The C function is
880 expected to take two arguments and return an `int', just like
881 `main':
882
883 int c_func (int argc, char **argv);
884
885 ARGS must be a list of strings and is converted into an array of
886 `char *'. The array is passed in ARGV and its size in ARGC. The
887 return value is converted to a Scheme number and returned from the
888 call to `dynamic-args-call'.
889
0fcab5ed
JB
890When dynamic linking is disabled or not supported on your system,
891the above functions throw errors, but they are still available.
892
e035e7e6
MV
893Here is a small example that works on GNU/Linux:
894
895 (define libc-obj (dynamic-link "libc.so"))
896 (dynamic-args-call 'rand libc-obj '())
897
898See the file `libguile/DYNAMIC-LINKING' for additional comments.
899
27590f82
JB
900** The #/ syntax for module names is depreciated, and will be removed
901in a future version of Guile. Instead of
902
903 #/foo/bar/baz
904
905instead write
906
907 (foo bar baz)
908
909The latter syntax is more consistent with existing Lisp practice.
910
5dade857
MV
911** Guile now does fancier printing of structures. Structures are the
912underlying implementation for records, which in turn are used to
913implement modules, so all of these object now print differently and in
914a more informative way.
915
161029df
JB
916The Scheme printer will examine the builtin variable *struct-printer*
917whenever it needs to print a structure object. When this variable is
918not `#f' it is deemed to be a procedure and will be applied to the
919structure object and the output port. When *struct-printer* is `#f'
920or the procedure return `#f' the structure object will be printed in
921the boring #<struct 80458270> form.
5dade857
MV
922
923This hook is used by some routines in ice-9/boot-9.scm to implement
924type specific printing routines. Please read the comments there about
925"printing structs".
926
927One of the more specific uses of structs are records. The printing
928procedure that could be passed to MAKE-RECORD-TYPE is now actually
929called. It should behave like a *struct-printer* procedure (described
930above).
931
b83b8bee
JB
932** Guile now supports a new R4RS-compliant syntax for keywords. A
933token of the form #:NAME, where NAME has the same syntax as a Scheme
934symbol, is the external representation of the keyword named NAME.
935Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
936keyword objects can be read back into Guile. When used in an
937expression, keywords are self-quoting objects.
b83b8bee
JB
938
939Guile suports this read syntax, and uses this print syntax, regardless
940of the current setting of the `keyword' read option. The `keyword'
941read option only controls whether Guile recognizes the `:NAME' syntax,
942which is incompatible with R4RS. (R4RS says such token represent
943symbols.)
737c9113
JB
944
945** Guile has regular expression support again. Guile 1.0 included
946functions for matching regular expressions, based on the Rx library.
947In Guile 1.1, the Guile/Rx interface was removed to simplify the
948distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
9491.2 again supports the most commonly used functions, and supports all
950of SCSH's regular expression functions.
2409cdfa 951
94982a4e
JB
952If your system does not include a POSIX regular expression library,
953and you have not linked Guile with a third-party regexp library such as
954Rx, these functions will not be available. You can tell whether your
955Guile installation includes regular expression support by checking
956whether the `*features*' list includes the `regex' symbol.
737c9113 957
94982a4e 958*** regexp functions
161029df 959
94982a4e
JB
960By default, Guile supports POSIX extended regular expressions. That
961means that the characters `(', `)', `+' and `?' are special, and must
962be escaped if you wish to match the literal characters.
e1a191a8 963
94982a4e
JB
964This regular expression interface was modeled after that implemented
965by SCSH, the Scheme Shell. It is intended to be upwardly compatible
966with SCSH regular expressions.
967
968**** Function: string-match PATTERN STR [START]
969 Compile the string PATTERN into a regular expression and compare
970 it with STR. The optional numeric argument START specifies the
971 position of STR at which to begin matching.
972
973 `string-match' returns a "match structure" which describes what,
974 if anything, was matched by the regular expression. *Note Match
975 Structures::. If STR does not match PATTERN at all,
976 `string-match' returns `#f'.
977
978 Each time `string-match' is called, it must compile its PATTERN
979argument into a regular expression structure. This operation is
980expensive, which makes `string-match' inefficient if the same regular
981expression is used several times (for example, in a loop). For better
982performance, you can compile a regular expression in advance and then
983match strings against the compiled regexp.
984
985**** Function: make-regexp STR [FLAGS]
986 Compile the regular expression described by STR, and return the
987 compiled regexp structure. If STR does not describe a legal
988 regular expression, `make-regexp' throws a
989 `regular-expression-syntax' error.
990
991 FLAGS may be the bitwise-or of one or more of the following:
992
993**** Constant: regexp/extended
994 Use POSIX Extended Regular Expression syntax when interpreting
995 STR. If not set, POSIX Basic Regular Expression syntax is used.
996 If the FLAGS argument is omitted, we assume regexp/extended.
997
998**** Constant: regexp/icase
999 Do not differentiate case. Subsequent searches using the
1000 returned regular expression will be case insensitive.
1001
1002**** Constant: regexp/newline
1003 Match-any-character operators don't match a newline.
1004
1005 A non-matching list ([^...]) not containing a newline matches a
1006 newline.
1007
1008 Match-beginning-of-line operator (^) matches the empty string
1009 immediately after a newline, regardless of whether the FLAGS
1010 passed to regexp-exec contain regexp/notbol.
1011
1012 Match-end-of-line operator ($) matches the empty string
1013 immediately before a newline, regardless of whether the FLAGS
1014 passed to regexp-exec contain regexp/noteol.
1015
1016**** Function: regexp-exec REGEXP STR [START [FLAGS]]
1017 Match the compiled regular expression REGEXP against `str'. If
1018 the optional integer START argument is provided, begin matching
1019 from that position in the string. Return a match structure
1020 describing the results of the match, or `#f' if no match could be
1021 found.
1022
1023 FLAGS may be the bitwise-or of one or more of the following:
1024
1025**** Constant: regexp/notbol
1026 The match-beginning-of-line operator always fails to match (but
1027 see the compilation flag regexp/newline above) This flag may be
1028 used when different portions of a string are passed to
1029 regexp-exec and the beginning of the string should not be
1030 interpreted as the beginning of the line.
1031
1032**** Constant: regexp/noteol
1033 The match-end-of-line operator always fails to match (but see the
1034 compilation flag regexp/newline above)
1035
1036**** Function: regexp? OBJ
1037 Return `#t' if OBJ is a compiled regular expression, or `#f'
1038 otherwise.
1039
1040 Regular expressions are commonly used to find patterns in one string
1041and replace them with the contents of another string.
1042
1043**** Function: regexp-substitute PORT MATCH [ITEM...]
1044 Write to the output port PORT selected contents of the match
1045 structure MATCH. Each ITEM specifies what should be written, and
1046 may be one of the following arguments:
1047
1048 * A string. String arguments are written out verbatim.
1049
1050 * An integer. The submatch with that number is written.
1051
1052 * The symbol `pre'. The portion of the matched string preceding
1053 the regexp match is written.
1054
1055 * The symbol `post'. The portion of the matched string
1056 following the regexp match is written.
1057
1058 PORT may be `#f', in which case nothing is written; instead,
1059 `regexp-substitute' constructs a string from the specified ITEMs
1060 and returns that.
1061
1062**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
1063 Similar to `regexp-substitute', but can be used to perform global
1064 substitutions on STR. Instead of taking a match structure as an
1065 argument, `regexp-substitute/global' takes two string arguments: a
1066 REGEXP string describing a regular expression, and a TARGET string
1067 which should be matched against this regular expression.
1068
1069 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
1070 exceptions:
1071
1072 * A function may be supplied. When this function is called, it
1073 will be passed one argument: a match structure for a given
1074 regular expression match. It should return a string to be
1075 written out to PORT.
1076
1077 * The `post' symbol causes `regexp-substitute/global' to recurse
1078 on the unmatched portion of STR. This *must* be supplied in
1079 order to perform global search-and-replace on STR; if it is
1080 not present among the ITEMs, then `regexp-substitute/global'
1081 will return after processing a single match.
1082
1083*** Match Structures
1084
1085 A "match structure" is the object returned by `string-match' and
1086`regexp-exec'. It describes which portion of a string, if any, matched
1087the given regular expression. Match structures include: a reference to
1088the string that was checked for matches; the starting and ending
1089positions of the regexp match; and, if the regexp included any
1090parenthesized subexpressions, the starting and ending positions of each
1091submatch.
1092
1093 In each of the regexp match functions described below, the `match'
1094argument must be a match structure returned by a previous call to
1095`string-match' or `regexp-exec'. Most of these functions return some
1096information about the original target string that was matched against a
1097regular expression; we will call that string TARGET for easy reference.
1098
1099**** Function: regexp-match? OBJ
1100 Return `#t' if OBJ is a match structure returned by a previous
1101 call to `regexp-exec', or `#f' otherwise.
1102
1103**** Function: match:substring MATCH [N]
1104 Return the portion of TARGET matched by subexpression number N.
1105 Submatch 0 (the default) represents the entire regexp match. If
1106 the regular expression as a whole matched, but the subexpression
1107 number N did not match, return `#f'.
1108
1109**** Function: match:start MATCH [N]
1110 Return the starting position of submatch number N.
1111
1112**** Function: match:end MATCH [N]
1113 Return the ending position of submatch number N.
1114
1115**** Function: match:prefix MATCH
1116 Return the unmatched portion of TARGET preceding the regexp match.
1117
1118**** Function: match:suffix MATCH
1119 Return the unmatched portion of TARGET following the regexp match.
1120
1121**** Function: match:count MATCH
1122 Return the number of parenthesized subexpressions from MATCH.
1123 Note that the entire regular expression match itself counts as a
1124 subexpression, and failed submatches are included in the count.
1125
1126**** Function: match:string MATCH
1127 Return the original TARGET string.
1128
1129*** Backslash Escapes
1130
1131 Sometimes you will want a regexp to match characters like `*' or `$'
1132exactly. For example, to check whether a particular string represents
1133a menu entry from an Info node, it would be useful to match it against
1134a regexp like `^* [^:]*::'. However, this won't work; because the
1135asterisk is a metacharacter, it won't match the `*' at the beginning of
1136the string. In this case, we want to make the first asterisk un-magic.
1137
1138 You can do this by preceding the metacharacter with a backslash
1139character `\'. (This is also called "quoting" the metacharacter, and
1140is known as a "backslash escape".) When Guile sees a backslash in a
1141regular expression, it considers the following glyph to be an ordinary
1142character, no matter what special meaning it would ordinarily have.
1143Therefore, we can make the above example work by changing the regexp to
1144`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
1145to match only a single asterisk in the target string.
1146
1147 Since the backslash is itself a metacharacter, you may force a
1148regexp to match a backslash in the target string by preceding the
1149backslash with itself. For example, to find variable references in a
1150TeX program, you might want to find occurrences of the string `\let\'
1151followed by any number of alphabetic characters. The regular expression
1152`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
1153each match a single backslash in the target string.
1154
1155**** Function: regexp-quote STR
1156 Quote each special character found in STR with a backslash, and
1157 return the resulting string.
1158
1159 *Very important:* Using backslash escapes in Guile source code (as
1160in Emacs Lisp or C) can be tricky, because the backslash character has
1161special meaning for the Guile reader. For example, if Guile encounters
1162the character sequence `\n' in the middle of a string while processing
1163Scheme code, it replaces those characters with a newline character.
1164Similarly, the character sequence `\t' is replaced by a horizontal tab.
1165Several of these "escape sequences" are processed by the Guile reader
1166before your code is executed. Unrecognized escape sequences are
1167ignored: if the characters `\*' appear in a string, they will be
1168translated to the single character `*'.
1169
1170 This translation is obviously undesirable for regular expressions,
1171since we want to be able to include backslashes in a string in order to
1172escape regexp metacharacters. Therefore, to make sure that a backslash
1173is preserved in a string in your Guile program, you must use *two*
1174consecutive backslashes:
1175
1176 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
1177
1178 The string in this example is preprocessed by the Guile reader before
1179any code is executed. The resulting argument to `make-regexp' is the
1180string `^\* [^:]*', which is what we really want.
1181
1182 This also means that in order to write a regular expression that
1183matches a single backslash character, the regular expression string in
1184the source code must include *four* backslashes. Each consecutive pair
1185of backslashes gets translated by the Guile reader to a single
1186backslash, and the resulting double-backslash is interpreted by the
1187regexp engine as matching a single backslash character. Hence:
1188
1189 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
1190
1191 The reason for the unwieldiness of this syntax is historical. Both
1192regular expression pattern matchers and Unix string processing systems
1193have traditionally used backslashes with the special meanings described
1194above. The POSIX regular expression specification and ANSI C standard
1195both require these semantics. Attempting to abandon either convention
1196would cause other kinds of compatibility problems, possibly more severe
1197ones. Therefore, without extending the Scheme reader to support
1198strings with different quoting conventions (an ungainly and confusing
1199extension when implemented in other languages), we must adhere to this
1200cumbersome escape syntax.
1201
7ad3c1e7
GH
1202* Changes to the gh_ interface
1203
1204* Changes to the scm_ interface
1205
1206* Changes to system call interfaces:
94982a4e 1207
7ad3c1e7 1208** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
1209if an error occurs.
1210
94982a4e 1211*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
1212
1213(sigaction signum [action] [flags])
1214
1215signum is the signal number, which can be specified using the value
1216of SIGINT etc.
1217
1218If action is omitted, sigaction returns a pair: the CAR is the current
1219signal hander, which will be either an integer with the value SIG_DFL
1220(default action) or SIG_IGN (ignore), or the Scheme procedure which
1221handles the signal, or #f if a non-Scheme procedure handles the
1222signal. The CDR contains the current sigaction flags for the handler.
1223
1224If action is provided, it is installed as the new handler for signum.
1225action can be a Scheme procedure taking one argument, or the value of
1226SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
1227whatever signal handler was installed before sigaction was first used.
1228Flags can optionally be specified for the new handler (SA_RESTART is
1229always used if the system provides it, so need not be specified.) The
1230return value is a pair with information about the old handler as
1231described above.
1232
1233This interface does not provide access to the "signal blocking"
1234facility. Maybe this is not needed, since the thread support may
1235provide solutions to the problem of consistent access to data
1236structures.
e1a191a8 1237
94982a4e 1238*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
1239`force-output' on every port open for output.
1240
94982a4e
JB
1241** Guile now provides information on how it was built, via the new
1242global variable, %guile-build-info. This variable records the values
1243of the standard GNU makefile directory variables as an assocation
1244list, mapping variable names (symbols) onto directory paths (strings).
1245For example, to find out where the Guile link libraries were
1246installed, you can say:
1247
1248guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
1249
1250
1251* Changes to the scm_ interface
1252
1253** The new function scm_handle_by_message_noexit is just like the
1254existing scm_handle_by_message function, except that it doesn't call
1255exit to terminate the process. Instead, it prints a message and just
1256returns #f. This might be a more appropriate catch-all handler for
1257new dynamic roots and threads.
1258
cf78e9e8 1259\f
c484bf7f 1260Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
1261
1262* Changes to the distribution.
1263
1264The Guile 1.0 distribution has been split up into several smaller
1265pieces:
1266guile-core --- the Guile interpreter itself.
1267guile-tcltk --- the interface between the Guile interpreter and
1268 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
1269 is a toolkit for building graphical user interfaces.
1270guile-rgx-ctax --- the interface between Guile and the Rx regular
1271 expression matcher, and the translator for the Ctax
1272 programming language. These are packaged together because the
1273 Ctax translator uses Rx to parse Ctax source code.
1274
095936d2
JB
1275This NEWS file describes the changes made to guile-core since the 1.0
1276release.
1277
48d224d7
JB
1278We no longer distribute the documentation, since it was either out of
1279date, or incomplete. As soon as we have current documentation, we
1280will distribute it.
1281
0fcab5ed
JB
1282
1283
f3b1485f
JB
1284* Changes to the stand-alone interpreter
1285
48d224d7
JB
1286** guile now accepts command-line arguments compatible with SCSH, Olin
1287Shivers' Scheme Shell.
1288
1289In general, arguments are evaluated from left to right, but there are
1290exceptions. The following switches stop argument processing, and
1291stash all remaining command-line arguments as the value returned by
1292the (command-line) function.
1293 -s SCRIPT load Scheme source code from FILE, and exit
1294 -c EXPR evalute Scheme expression EXPR, and exit
1295 -- stop scanning arguments; run interactively
1296
1297The switches below are processed as they are encountered.
1298 -l FILE load Scheme source code from FILE
1299 -e FUNCTION after reading script, apply FUNCTION to
1300 command line arguments
1301 -ds do -s script at this point
1302 --emacs enable Emacs protocol (experimental)
1303 -h, --help display this help and exit
1304 -v, --version display version information and exit
1305 \ read arguments from following script lines
1306
1307So, for example, here is a Guile script named `ekko' (thanks, Olin)
1308which re-implements the traditional "echo" command:
1309
1310#!/usr/local/bin/guile -s
1311!#
1312(define (main args)
1313 (map (lambda (arg) (display arg) (display " "))
1314 (cdr args))
1315 (newline))
1316
1317(main (command-line))
1318
1319Suppose we invoke this script as follows:
1320
1321 ekko a speckled gecko
1322
1323Through the magic of Unix script processing (triggered by the `#!'
1324token at the top of the file), /usr/local/bin/guile receives the
1325following list of command-line arguments:
1326
1327 ("-s" "./ekko" "a" "speckled" "gecko")
1328
1329Unix inserts the name of the script after the argument specified on
1330the first line of the file (in this case, "-s"), and then follows that
1331with the arguments given to the script. Guile loads the script, which
1332defines the `main' function, and then applies it to the list of
1333remaining command-line arguments, ("a" "speckled" "gecko").
1334
095936d2
JB
1335In Unix, the first line of a script file must take the following form:
1336
1337#!INTERPRETER ARGUMENT
1338
1339where INTERPRETER is the absolute filename of the interpreter
1340executable, and ARGUMENT is a single command-line argument to pass to
1341the interpreter.
1342
1343You may only pass one argument to the interpreter, and its length is
1344limited. These restrictions can be annoying to work around, so Guile
1345provides a general mechanism (borrowed from, and compatible with,
1346SCSH) for circumventing them.
1347
1348If the ARGUMENT in a Guile script is a single backslash character,
1349`\', Guile will open the script file, parse arguments from its second
1350and subsequent lines, and replace the `\' with them. So, for example,
1351here is another implementation of the `ekko' script:
1352
1353#!/usr/local/bin/guile \
1354-e main -s
1355!#
1356(define (main args)
1357 (for-each (lambda (arg) (display arg) (display " "))
1358 (cdr args))
1359 (newline))
1360
1361If the user invokes this script as follows:
1362
1363 ekko a speckled gecko
1364
1365Unix expands this into
1366
1367 /usr/local/bin/guile \ ekko a speckled gecko
1368
1369When Guile sees the `\' argument, it replaces it with the arguments
1370read from the second line of the script, producing:
1371
1372 /usr/local/bin/guile -e main -s ekko a speckled gecko
1373
1374This tells Guile to load the `ekko' script, and apply the function
1375`main' to the argument list ("a" "speckled" "gecko").
1376
1377Here is how Guile parses the command-line arguments:
1378- Each space character terminates an argument. This means that two
1379 spaces in a row introduce an empty-string argument.
1380- The tab character is not permitted (unless you quote it with the
1381 backslash character, as described below), to avoid confusion.
1382- The newline character terminates the sequence of arguments, and will
1383 also terminate a final non-empty argument. (However, a newline
1384 following a space will not introduce a final empty-string argument;
1385 it only terminates the argument list.)
1386- The backslash character is the escape character. It escapes
1387 backslash, space, tab, and newline. The ANSI C escape sequences
1388 like \n and \t are also supported. These produce argument
1389 constituents; the two-character combination \n doesn't act like a
1390 terminating newline. The escape sequence \NNN for exactly three
1391 octal digits reads as the character whose ASCII code is NNN. As
1392 above, characters produced this way are argument constituents.
1393 Backslash followed by other characters is not allowed.
1394
48d224d7
JB
1395* Changes to the procedure for linking libguile with your programs
1396
1397** Guile now builds and installs a shared guile library, if your
1398system support shared libraries. (It still builds a static library on
1399all systems.) Guile automatically detects whether your system
1400supports shared libraries. To prevent Guile from buildisg shared
1401libraries, pass the `--disable-shared' flag to the configure script.
1402
1403Guile takes longer to compile when it builds shared libraries, because
1404it must compile every file twice --- once to produce position-
1405independent object code, and once to produce normal object code.
1406
1407** The libthreads library has been merged into libguile.
1408
1409To link a program against Guile, you now need only link against
1410-lguile and -lqt; -lthreads is no longer needed. If you are using
1411autoconf to generate configuration scripts for your application, the
1412following lines should suffice to add the appropriate libraries to
1413your link command:
1414
1415### Find quickthreads and libguile.
1416AC_CHECK_LIB(qt, main)
1417AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
1418
1419* Changes to Scheme functions
1420
095936d2
JB
1421** Guile Scheme's special syntax for keyword objects is now optional,
1422and disabled by default.
1423
1424The syntax variation from R4RS made it difficult to port some
1425interesting packages to Guile. The routines which accepted keyword
1426arguments (mostly in the module system) have been modified to also
1427accept symbols whose names begin with `:'.
1428
1429To change the keyword syntax, you must first import the (ice-9 debug)
1430module:
1431 (use-modules (ice-9 debug))
1432
1433Then you can enable the keyword syntax as follows:
1434 (read-set! keywords 'prefix)
1435
1436To disable keyword syntax, do this:
1437 (read-set! keywords #f)
1438
1439** Many more primitive functions accept shared substrings as
1440arguments. In the past, these functions required normal, mutable
1441strings as arguments, although they never made use of this
1442restriction.
1443
1444** The uniform array functions now operate on byte vectors. These
1445functions are `array-fill!', `serial-array-copy!', `array-copy!',
1446`serial-array-map', `array-map', `array-for-each', and
1447`array-index-map!'.
1448
1449** The new functions `trace' and `untrace' implement simple debugging
1450support for Scheme functions.
1451
1452The `trace' function accepts any number of procedures as arguments,
1453and tells the Guile interpreter to display each procedure's name and
1454arguments each time the procedure is invoked. When invoked with no
1455arguments, `trace' returns the list of procedures currently being
1456traced.
1457
1458The `untrace' function accepts any number of procedures as arguments,
1459and tells the Guile interpreter not to trace them any more. When
1460invoked with no arguments, `untrace' untraces all curretly traced
1461procedures.
1462
1463The tracing in Guile has an advantage over most other systems: we
1464don't create new procedure objects, but mark the procedure objects
1465themselves. This means that anonymous and internal procedures can be
1466traced.
1467
1468** The function `assert-repl-prompt' has been renamed to
1469`set-repl-prompt!'. It takes one argument, PROMPT.
1470- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
1471- If PROMPT is a string, we use it as a prompt.
1472- If PROMPT is a procedure accepting no arguments, we call it, and
1473 display the result as a prompt.
1474- Otherwise, we display "> ".
1475
1476** The new function `eval-string' reads Scheme expressions from a
1477string and evaluates them, returning the value of the last expression
1478in the string. If the string contains no expressions, it returns an
1479unspecified value.
1480
1481** The new function `thunk?' returns true iff its argument is a
1482procedure of zero arguments.
1483
1484** `defined?' is now a builtin function, instead of syntax. This
1485means that its argument should be quoted. It returns #t iff its
1486argument is bound in the current module.
1487
1488** The new syntax `use-modules' allows you to add new modules to your
1489environment without re-typing a complete `define-module' form. It
1490accepts any number of module names as arguments, and imports their
1491public bindings into the current module.
1492
1493** The new function (module-defined? NAME MODULE) returns true iff
1494NAME, a symbol, is defined in MODULE, a module object.
1495
1496** The new function `builtin-bindings' creates and returns a hash
1497table containing copies of all the root module's bindings.
1498
1499** The new function `builtin-weak-bindings' does the same as
1500`builtin-bindings', but creates a doubly-weak hash table.
1501
1502** The `equal?' function now considers variable objects to be
1503equivalent if they have the same name and the same value.
1504
1505** The new function `command-line' returns the command-line arguments
1506given to Guile, as a list of strings.
1507
1508When using guile as a script interpreter, `command-line' returns the
1509script's arguments; those processed by the interpreter (like `-s' or
1510`-c') are omitted. (In other words, you get the normal, expected
1511behavior.) Any application that uses scm_shell to process its
1512command-line arguments gets this behavior as well.
1513
1514** The new function `load-user-init' looks for a file called `.guile'
1515in the user's home directory, and loads it if it exists. This is
1516mostly for use by the code generated by scm_compile_shell_switches,
1517but we thought it might also be useful in other circumstances.
1518
1519** The new function `log10' returns the base-10 logarithm of its
1520argument.
1521
1522** Changes to I/O functions
1523
1524*** The functions `read', `primitive-load', `read-and-eval!', and
1525`primitive-load-path' no longer take optional arguments controlling
1526case insensitivity and a `#' parser.
1527
1528Case sensitivity is now controlled by a read option called
1529`case-insensitive'. The user can add new `#' syntaxes with the
1530`read-hash-extend' function (see below).
1531
1532*** The new function `read-hash-extend' allows the user to change the
1533syntax of Guile Scheme in a somewhat controlled way.
1534
1535(read-hash-extend CHAR PROC)
1536 When parsing S-expressions, if we read a `#' character followed by
1537 the character CHAR, use PROC to parse an object from the stream.
1538 If PROC is #f, remove any parsing procedure registered for CHAR.
1539
1540 The reader applies PROC to two arguments: CHAR and an input port.
1541
1542*** The new functions read-delimited and read-delimited! provide a
1543general mechanism for doing delimited input on streams.
1544
1545(read-delimited DELIMS [PORT HANDLE-DELIM])
1546 Read until we encounter one of the characters in DELIMS (a string),
1547 or end-of-file. PORT is the input port to read from; it defaults to
1548 the current input port. The HANDLE-DELIM parameter determines how
1549 the terminating character is handled; it should be one of the
1550 following symbols:
1551
1552 'trim omit delimiter from result
1553 'peek leave delimiter character in input stream
1554 'concat append delimiter character to returned value
1555 'split return a pair: (RESULT . TERMINATOR)
1556
1557 HANDLE-DELIM defaults to 'peek.
1558
1559(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
1560 A side-effecting variant of `read-delimited'.
1561
1562 The data is written into the string BUF at the indices in the
1563 half-open interval [START, END); the default interval is the whole
1564 string: START = 0 and END = (string-length BUF). The values of
1565 START and END must specify a well-defined interval in BUF, i.e.
1566 0 <= START <= END <= (string-length BUF).
1567
1568 It returns NBYTES, the number of bytes read. If the buffer filled
1569 up without a delimiter character being found, it returns #f. If the
1570 port is at EOF when the read starts, it returns the EOF object.
1571
1572 If an integer is returned (i.e., the read is successfully terminated
1573 by reading a delimiter character), then the HANDLE-DELIM parameter
1574 determines how to handle the terminating character. It is described
1575 above, and defaults to 'peek.
1576
1577(The descriptions of these functions were borrowed from the SCSH
1578manual, by Olin Shivers and Brian Carlstrom.)
1579
1580*** The `%read-delimited!' function is the primitive used to implement
1581`read-delimited' and `read-delimited!'.
1582
1583(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
1584
1585This returns a pair of values: (TERMINATOR . NUM-READ).
1586- TERMINATOR describes why the read was terminated. If it is a
1587 character or the eof object, then that is the value that terminated
1588 the read. If it is #f, the function filled the buffer without finding
1589 a delimiting character.
1590- NUM-READ is the number of characters read into BUF.
1591
1592If the read is successfully terminated by reading a delimiter
1593character, then the gobble? parameter determines what to do with the
1594terminating character. If true, the character is removed from the
1595input stream; if false, the character is left in the input stream
1596where a subsequent read operation will retrieve it. In either case,
1597the character is also the first value returned by the procedure call.
1598
1599(The descriptions of this function was borrowed from the SCSH manual,
1600by Olin Shivers and Brian Carlstrom.)
1601
1602*** The `read-line' and `read-line!' functions have changed; they now
1603trim the terminator by default; previously they appended it to the
1604returned string. For the old behavior, use (read-line PORT 'concat).
1605
1606*** The functions `uniform-array-read!' and `uniform-array-write!' now
1607take new optional START and END arguments, specifying the region of
1608the array to read and write.
1609
f348c807
JB
1610*** The `ungetc-char-ready?' function has been removed. We feel it's
1611inappropriate for an interface to expose implementation details this
1612way.
095936d2
JB
1613
1614** Changes to the Unix library and system call interface
1615
1616*** The new fcntl function provides access to the Unix `fcntl' system
1617call.
1618
1619(fcntl PORT COMMAND VALUE)
1620 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
1621 Values for COMMAND are:
1622
1623 F_DUPFD duplicate a file descriptor
1624 F_GETFD read the descriptor's close-on-exec flag
1625 F_SETFD set the descriptor's close-on-exec flag to VALUE
1626 F_GETFL read the descriptor's flags, as set on open
1627 F_SETFL set the descriptor's flags, as set on open to VALUE
1628 F_GETOWN return the process ID of a socket's owner, for SIGIO
1629 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
1630 FD_CLOEXEC not sure what this is
1631
1632For details, see the documentation for the fcntl system call.
1633
1634*** The arguments to `select' have changed, for compatibility with
1635SCSH. The TIMEOUT parameter may now be non-integral, yielding the
1636expected behavior. The MILLISECONDS parameter has been changed to
1637MICROSECONDS, to more closely resemble the underlying system call.
1638The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
1639corresponding return set will be the same.
1640
1641*** The arguments to the `mknod' system call have changed. They are
1642now:
1643
1644(mknod PATH TYPE PERMS DEV)
1645 Create a new file (`node') in the file system. PATH is the name of
1646 the file to create. TYPE is the kind of file to create; it should
1647 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
1648 permission bits to give the newly created file. If TYPE is
1649 'block-special or 'char-special, DEV specifies which device the
1650 special file refers to; its interpretation depends on the kind of
1651 special file being created.
1652
1653*** The `fork' function has been renamed to `primitive-fork', to avoid
1654clashing with various SCSH forks.
1655
1656*** The `recv' and `recvfrom' functions have been renamed to `recv!'
1657and `recvfrom!'. They no longer accept a size for a second argument;
1658you must pass a string to hold the received value. They no longer
1659return the buffer. Instead, `recv' returns the length of the message
1660received, and `recvfrom' returns a pair containing the packet's length
1661and originating address.
1662
1663*** The file descriptor datatype has been removed, as have the
1664`read-fd', `write-fd', `close', `lseek', and `dup' functions.
1665We plan to replace these functions with a SCSH-compatible interface.
1666
1667*** The `create' function has been removed; it's just a special case
1668of `open'.
1669
1670*** There are new functions to break down process termination status
1671values. In the descriptions below, STATUS is a value returned by
1672`waitpid'.
1673
1674(status:exit-val STATUS)
1675 If the child process exited normally, this function returns the exit
1676 code for the child process (i.e., the value passed to exit, or
1677 returned from main). If the child process did not exit normally,
1678 this function returns #f.
1679
1680(status:stop-sig STATUS)
1681 If the child process was suspended by a signal, this function
1682 returns the signal that suspended the child. Otherwise, it returns
1683 #f.
1684
1685(status:term-sig STATUS)
1686 If the child process terminated abnormally, this function returns
1687 the signal that terminated the child. Otherwise, this function
1688 returns false.
1689
1690POSIX promises that exactly one of these functions will return true on
1691a valid STATUS value.
1692
1693These functions are compatible with SCSH.
1694
1695*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
1696returned by `localtime', `gmtime', and that ilk. They are:
1697
1698 Component Accessor Setter
1699 ========================= ============ ============
1700 seconds tm:sec set-tm:sec
1701 minutes tm:min set-tm:min
1702 hours tm:hour set-tm:hour
1703 day of the month tm:mday set-tm:mday
1704 month tm:mon set-tm:mon
1705 year tm:year set-tm:year
1706 day of the week tm:wday set-tm:wday
1707 day in the year tm:yday set-tm:yday
1708 daylight saving time tm:isdst set-tm:isdst
1709 GMT offset, seconds tm:gmtoff set-tm:gmtoff
1710 name of time zone tm:zone set-tm:zone
1711
095936d2
JB
1712*** There are new accessors for the vectors returned by `uname',
1713describing the host system:
48d224d7
JB
1714
1715 Component Accessor
1716 ============================================== ================
1717 name of the operating system implementation utsname:sysname
1718 network name of this machine utsname:nodename
1719 release level of the operating system utsname:release
1720 version level of the operating system utsname:version
1721 machine hardware platform utsname:machine
1722
095936d2
JB
1723*** There are new accessors for the vectors returned by `getpw',
1724`getpwnam', `getpwuid', and `getpwent', describing entries from the
1725system's user database:
1726
1727 Component Accessor
1728 ====================== =================
1729 user name passwd:name
1730 user password passwd:passwd
1731 user id passwd:uid
1732 group id passwd:gid
1733 real name passwd:gecos
1734 home directory passwd:dir
1735 shell program passwd:shell
1736
1737*** There are new accessors for the vectors returned by `getgr',
1738`getgrnam', `getgrgid', and `getgrent', describing entries from the
1739system's group database:
1740
1741 Component Accessor
1742 ======================= ============
1743 group name group:name
1744 group password group:passwd
1745 group id group:gid
1746 group members group:mem
1747
1748*** There are new accessors for the vectors returned by `gethost',
1749`gethostbyaddr', `gethostbyname', and `gethostent', describing
1750internet hosts:
1751
1752 Component Accessor
1753 ========================= ===============
1754 official name of host hostent:name
1755 alias list hostent:aliases
1756 host address type hostent:addrtype
1757 length of address hostent:length
1758 list of addresses hostent:addr-list
1759
1760*** There are new accessors for the vectors returned by `getnet',
1761`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
1762networks:
1763
1764 Component Accessor
1765 ========================= ===============
1766 official name of net netent:name
1767 alias list netent:aliases
1768 net number type netent:addrtype
1769 net number netent:net
1770
1771*** There are new accessors for the vectors returned by `getproto',
1772`getprotobyname', `getprotobynumber', and `getprotoent', describing
1773internet protocols:
1774
1775 Component Accessor
1776 ========================= ===============
1777 official protocol name protoent:name
1778 alias list protoent:aliases
1779 protocol number protoent:proto
1780
1781*** There are new accessors for the vectors returned by `getserv',
1782`getservbyname', `getservbyport', and `getservent', describing
1783internet protocols:
1784
1785 Component Accessor
1786 ========================= ===============
1787 official service name servent:name
1788 alias list servent:aliases
1789 port number servent:port
1790 protocol to use servent:proto
1791
1792*** There are new accessors for the sockaddr structures returned by
1793`accept', `getsockname', `getpeername', `recvfrom!':
1794
1795 Component Accessor
1796 ======================================== ===============
1797 address format (`family') sockaddr:fam
1798 path, for file domain addresses sockaddr:path
1799 address, for internet domain addresses sockaddr:addr
1800 TCP or UDP port, for internet sockaddr:port
1801
1802*** The `getpwent', `getgrent', `gethostent', `getnetent',
1803`getprotoent', and `getservent' functions now return #f at the end of
1804the user database. (They used to throw an exception.)
1805
1806Note that calling MUMBLEent function is equivalent to calling the
1807corresponding MUMBLE function with no arguments.
1808
1809*** The `setpwent', `setgrent', `sethostent', `setnetent',
1810`setprotoent', and `setservent' routines now take no arguments.
1811
1812*** The `gethost', `getproto', `getnet', and `getserv' functions now
1813provide more useful information when they throw an exception.
1814
1815*** The `lnaof' function has been renamed to `inet-lnaof'.
1816
1817*** Guile now claims to have the `current-time' feature.
1818
1819*** The `mktime' function now takes an optional second argument ZONE,
1820giving the time zone to use for the conversion. ZONE should be a
1821string, in the same format as expected for the "TZ" environment variable.
1822
1823*** The `strptime' function now returns a pair (TIME . COUNT), where
1824TIME is the parsed time as a vector, and COUNT is the number of
1825characters from the string left unparsed. This function used to
1826return the remaining characters as a string.
1827
1828*** The `gettimeofday' function has replaced the old `time+ticks' function.
1829The return value is now (SECONDS . MICROSECONDS); the fractional
1830component is no longer expressed in "ticks".
1831
1832*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 1833
ea00ecba
MG
1834* Changes to the gh_ interface
1835
1836** gh_eval_str() now returns an SCM object which is the result of the
1837evaluation
1838
aaef0d2a
MG
1839** gh_scm2str() now copies the Scheme data to a caller-provided C
1840array
1841
1842** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
1843and returns the array
1844
1845** gh_scm2str0() is gone: there is no need to distinguish
1846null-terminated from non-null-terminated, since gh_scm2newstr() allows
1847the user to interpret the data both ways.
1848
f3b1485f
JB
1849* Changes to the scm_ interface
1850
095936d2
JB
1851** The new function scm_symbol_value0 provides an easy way to get a
1852symbol's value from C code:
1853
1854SCM scm_symbol_value0 (char *NAME)
1855 Return the value of the symbol named by the null-terminated string
1856 NAME in the current module. If the symbol named NAME is unbound in
1857 the current module, return SCM_UNDEFINED.
1858
1859** The new function scm_sysintern0 creates new top-level variables,
1860without assigning them a value.
1861
1862SCM scm_sysintern0 (char *NAME)
1863 Create a new Scheme top-level variable named NAME. NAME is a
1864 null-terminated string. Return the variable's value cell.
1865
1866** The function scm_internal_catch is the guts of catch. It handles
1867all the mechanics of setting up a catch target, invoking the catch
1868body, and perhaps invoking the handler if the body does a throw.
1869
1870The function is designed to be usable from C code, but is general
1871enough to implement all the semantics Guile Scheme expects from throw.
1872
1873TAG is the catch tag. Typically, this is a symbol, but this function
1874doesn't actually care about that.
1875
1876BODY is a pointer to a C function which runs the body of the catch;
1877this is the code you can throw from. We call it like this:
1878 BODY (BODY_DATA, JMPBUF)
1879where:
1880 BODY_DATA is just the BODY_DATA argument we received; we pass it
1881 through to BODY as its first argument. The caller can make
1882 BODY_DATA point to anything useful that BODY might need.
1883 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
1884 which we have just created and initialized.
1885
1886HANDLER is a pointer to a C function to deal with a throw to TAG,
1887should one occur. We call it like this:
1888 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
1889where
1890 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
1891 same idea as BODY_DATA above.
1892 THROWN_TAG is the tag that the user threw to; usually this is
1893 TAG, but it could be something else if TAG was #t (i.e., a
1894 catch-all), or the user threw to a jmpbuf.
1895 THROW_ARGS is the list of arguments the user passed to the THROW
1896 function.
1897
1898BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
1899is just a pointer we pass through to HANDLER. We don't actually
1900use either of those pointers otherwise ourselves. The idea is
1901that, if our caller wants to communicate something to BODY or
1902HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
1903HANDLER can then use. Think of it as a way to make BODY and
1904HANDLER closures, not just functions; MUMBLE_DATA points to the
1905enclosed variables.
1906
1907Of course, it's up to the caller to make sure that any data a
1908MUMBLE_DATA needs is protected from GC. A common way to do this is
1909to make MUMBLE_DATA a pointer to data stored in an automatic
1910structure variable; since the collector must scan the stack for
1911references anyway, this assures that any references in MUMBLE_DATA
1912will be found.
1913
1914** The new function scm_internal_lazy_catch is exactly like
1915scm_internal_catch, except:
1916
1917- It does not unwind the stack (this is the major difference).
1918- If handler returns, its value is returned from the throw.
1919- BODY always receives #f as its JMPBUF argument (since there's no
1920 jmpbuf associated with a lazy catch, because we don't unwind the
1921 stack.)
1922
1923** scm_body_thunk is a new body function you can pass to
1924scm_internal_catch if you want the body to be like Scheme's `catch'
1925--- a thunk, or a function of one argument if the tag is #f.
1926
1927BODY_DATA is a pointer to a scm_body_thunk_data structure, which
1928contains the Scheme procedure to invoke as the body, and the tag
1929we're catching. If the tag is #f, then we pass JMPBUF (created by
1930scm_internal_catch) to the body procedure; otherwise, the body gets
1931no arguments.
1932
1933** scm_handle_by_proc is a new handler function you can pass to
1934scm_internal_catch if you want the handler to act like Scheme's catch
1935--- call a procedure with the tag and the throw arguments.
1936
1937If the user does a throw to this catch, this function runs a handler
1938procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
1939variable holding the Scheme procedure object to invoke. It ought to
1940be a pointer to an automatic variable (i.e., one living on the stack),
1941or the procedure object should be otherwise protected from GC.
1942
1943** scm_handle_by_message is a new handler function to use with
1944`scm_internal_catch' if you want Guile to print a message and die.
1945It's useful for dealing with throws to uncaught keys at the top level.
1946
1947HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
1948message header to print; if zero, we use "guile" instead. That
1949text is followed by a colon, then the message described by ARGS.
1950
1951** The return type of scm_boot_guile is now void; the function does
1952not return a value, and indeed, never returns at all.
1953
f3b1485f
JB
1954** The new function scm_shell makes it easy for user applications to
1955process command-line arguments in a way that is compatible with the
1956stand-alone guile interpreter (which is in turn compatible with SCSH,
1957the Scheme shell).
1958
1959To use the scm_shell function, first initialize any guile modules
1960linked into your application, and then call scm_shell with the values
7ed46dc8 1961of ARGC and ARGV your `main' function received. scm_shell will add
f3b1485f
JB
1962any SCSH-style meta-arguments from the top of the script file to the
1963argument vector, and then process the command-line arguments. This
1964generally means loading a script file or starting up an interactive
1965command interpreter. For details, see "Changes to the stand-alone
1966interpreter" above.
1967
095936d2
JB
1968** The new functions scm_get_meta_args and scm_count_argv help you
1969implement the SCSH-style meta-argument, `\'.
1970
1971char **scm_get_meta_args (int ARGC, char **ARGV)
1972 If the second element of ARGV is a string consisting of a single
1973 backslash character (i.e. "\\" in Scheme notation), open the file
1974 named by the following argument, parse arguments from it, and return
1975 the spliced command line. The returned array is terminated by a
1976 null pointer.
1977
1978 For details of argument parsing, see above, under "guile now accepts
1979 command-line arguments compatible with SCSH..."
1980
1981int scm_count_argv (char **ARGV)
1982 Count the arguments in ARGV, assuming it is terminated by a null
1983 pointer.
1984
1985For an example of how these functions might be used, see the source
1986code for the function scm_shell in libguile/script.c.
1987
1988You will usually want to use scm_shell instead of calling this
1989function yourself.
1990
1991** The new function scm_compile_shell_switches turns an array of
1992command-line arguments into Scheme code to carry out the actions they
1993describe. Given ARGC and ARGV, it returns a Scheme expression to
1994evaluate, and calls scm_set_program_arguments to make any remaining
1995command-line arguments available to the Scheme code. For example,
1996given the following arguments:
1997
1998 -e main -s ekko a speckled gecko
1999
2000scm_set_program_arguments will return the following expression:
2001
2002 (begin (load "ekko") (main (command-line)) (quit))
2003
2004You will usually want to use scm_shell instead of calling this
2005function yourself.
2006
2007** The function scm_shell_usage prints a usage message appropriate for
2008an interpreter that uses scm_compile_shell_switches to handle its
2009command-line arguments.
2010
2011void scm_shell_usage (int FATAL, char *MESSAGE)
2012 Print a usage message to the standard error output. If MESSAGE is
2013 non-zero, write it before the usage message, followed by a newline.
2014 If FATAL is non-zero, exit the process, using FATAL as the
2015 termination status. (If you want to be compatible with Guile,
2016 always use 1 as the exit status when terminating due to command-line
2017 usage problems.)
2018
2019You will usually want to use scm_shell instead of calling this
2020function yourself.
48d224d7
JB
2021
2022** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
2023expressions. It used to return SCM_EOL. Earth-shattering.
2024
2025** The macros for declaring scheme objects in C code have been
2026rearranged slightly. They are now:
2027
2028SCM_SYMBOL (C_NAME, SCHEME_NAME)
2029 Declare a static SCM variable named C_NAME, and initialize it to
2030 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
2031 be a C identifier, and SCHEME_NAME should be a C string.
2032
2033SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
2034 Just like SCM_SYMBOL, but make C_NAME globally visible.
2035
2036SCM_VCELL (C_NAME, SCHEME_NAME)
2037 Create a global variable at the Scheme level named SCHEME_NAME.
2038 Declare a static SCM variable named C_NAME, and initialize it to
2039 point to the Scheme variable's value cell.
2040
2041SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
2042 Just like SCM_VCELL, but make C_NAME globally visible.
2043
2044The `guile-snarf' script writes initialization code for these macros
2045to its standard output, given C source code as input.
2046
2047The SCM_GLOBAL macro is gone.
2048
2049** The scm_read_line and scm_read_line_x functions have been replaced
2050by Scheme code based on the %read-delimited! procedure (known to C
2051code as scm_read_delimited_x). See its description above for more
2052information.
48d224d7 2053
095936d2
JB
2054** The function scm_sys_open has been renamed to scm_open. It now
2055returns a port instead of an FD object.
ea00ecba 2056
095936d2
JB
2057* The dynamic linking support has changed. For more information, see
2058libguile/DYNAMIC-LINKING.
ea00ecba 2059
f7b47737
JB
2060\f
2061Guile 1.0b3
3065a62a 2062
f3b1485f
JB
2063User-visible changes from Thursday, September 5, 1996 until Guile 1.0
2064(Sun 5 Jan 1997):
3065a62a 2065
4b521edb 2066* Changes to the 'guile' program:
3065a62a 2067
4b521edb
JB
2068** Guile now loads some new files when it starts up. Guile first
2069searches the load path for init.scm, and loads it if found. Then, if
2070Guile is not being used to execute a script, and the user's home
2071directory contains a file named `.guile', Guile loads that.
c6486f8a 2072
4b521edb 2073** You can now use Guile as a shell script interpreter.
3065a62a
JB
2074
2075To paraphrase the SCSH manual:
2076
2077 When Unix tries to execute an executable file whose first two
2078 characters are the `#!', it treats the file not as machine code to
2079 be directly executed by the native processor, but as source code
2080 to be executed by some interpreter. The interpreter to use is
2081 specified immediately after the #! sequence on the first line of
2082 the source file. The kernel reads in the name of the interpreter,
2083 and executes that instead. It passes the interpreter the source
2084 filename as its first argument, with the original arguments
2085 following. Consult the Unix man page for the `exec' system call
2086 for more information.
2087
1a1945be
JB
2088Now you can use Guile as an interpreter, using a mechanism which is a
2089compatible subset of that provided by SCSH.
2090
3065a62a
JB
2091Guile now recognizes a '-s' command line switch, whose argument is the
2092name of a file of Scheme code to load. It also treats the two
2093characters `#!' as the start of a comment, terminated by `!#'. Thus,
2094to make a file of Scheme code directly executable by Unix, insert the
2095following two lines at the top of the file:
2096
2097#!/usr/local/bin/guile -s
2098!#
2099
2100Guile treats the argument of the `-s' command-line switch as the name
2101of a file of Scheme code to load, and treats the sequence `#!' as the
2102start of a block comment, terminated by `!#'.
2103
2104For example, here's a version of 'echo' written in Scheme:
2105
2106#!/usr/local/bin/guile -s
2107!#
2108(let loop ((args (cdr (program-arguments))))
2109 (if (pair? args)
2110 (begin
2111 (display (car args))
2112 (if (pair? (cdr args))
2113 (display " "))
2114 (loop (cdr args)))))
2115(newline)
2116
2117Why does `#!' start a block comment terminated by `!#', instead of the
2118end of the line? That is the notation SCSH uses, and although we
2119don't yet support the other SCSH features that motivate that choice,
2120we would like to be backward-compatible with any existing Guile
3763761c
JB
2121scripts once we do. Furthermore, if the path to Guile on your system
2122is too long for your kernel, you can start the script with this
2123horrible hack:
2124
2125#!/bin/sh
2126exec /really/long/path/to/guile -s "$0" ${1+"$@"}
2127!#
3065a62a
JB
2128
2129Note that some very old Unix systems don't support the `#!' syntax.
2130
c6486f8a 2131
4b521edb 2132** You can now run Guile without installing it.
6685dc83
JB
2133
2134Previous versions of the interactive Guile interpreter (`guile')
2135couldn't start up unless Guile's Scheme library had been installed;
2136they used the value of the environment variable `SCHEME_LOAD_PATH'
2137later on in the startup process, but not to find the startup code
2138itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
2139code.
2140
2141To run Guile without installing it, build it in the normal way, and
2142then set the environment variable `SCHEME_LOAD_PATH' to a
2143colon-separated list of directories, including the top-level directory
2144of the Guile sources. For example, if you unpacked Guile so that the
2145full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
2146you might say
2147
2148 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
2149
c6486f8a 2150
4b521edb
JB
2151** Guile's read-eval-print loop no longer prints #<unspecified>
2152results. If the user wants to see this, she can evaluate the
2153expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 2154file.
6685dc83 2155
4b521edb
JB
2156** Guile no longer shows backtraces by default when an error occurs;
2157however, it does display a message saying how to get one, and how to
2158request that they be displayed by default. After an error, evaluate
2159 (backtrace)
2160to see a backtrace, and
2161 (debug-enable 'backtrace)
2162to see them by default.
6685dc83 2163
6685dc83 2164
d9fb83d9 2165
4b521edb
JB
2166* Changes to Guile Scheme:
2167
2168** Guile now distinguishes between #f and the empty list.
2169
2170This is for compatibility with the IEEE standard, the (possibly)
2171upcoming Revised^5 Report on Scheme, and many extant Scheme
2172implementations.
2173
2174Guile used to have #f and '() denote the same object, to make Scheme's
2175type system more compatible with Emacs Lisp's. However, the change
2176caused too much trouble for Scheme programmers, and we found another
2177way to reconcile Emacs Lisp with Scheme that didn't require this.
2178
2179
2180** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
2181counterparts, delq!, delv!, and delete!, now remove all matching
2182elements from the list, not just the first. This matches the behavior
2183of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
2184functions which inspired them.
2185
2186I recognize that this change may break code in subtle ways, but it
2187seems best to make the change before the FSF's first Guile release,
2188rather than after.
2189
2190
4b521edb 2191** The compiled-library-path function has been deleted from libguile.
6685dc83 2192
4b521edb 2193** The facilities for loading Scheme source files have changed.
c6486f8a 2194
4b521edb 2195*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
2196for Scheme code. Its value is a list of strings, each of which names
2197a directory.
2198
4b521edb
JB
2199*** The variable %load-extensions now tells Guile which extensions to
2200try appending to a filename when searching the load path. Its value
2201is a list of strings. Its default value is ("" ".scm").
2202
2203*** (%search-load-path FILENAME) searches the directories listed in the
2204value of the %load-path variable for a Scheme file named FILENAME,
2205with all the extensions listed in %load-extensions. If it finds a
2206match, then it returns its full filename. If FILENAME is absolute, it
2207returns it unchanged. Otherwise, it returns #f.
6685dc83 2208
4b521edb
JB
2209%search-load-path will not return matches that refer to directories.
2210
2211*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
2212uses %seach-load-path to find a file named FILENAME, and loads it if
2213it finds it. If it can't read FILENAME for any reason, it throws an
2214error.
6685dc83
JB
2215
2216The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
2217`read' function.
2218
2219*** load uses the same searching semantics as primitive-load.
2220
2221*** The functions %try-load, try-load-with-path, %load, load-with-path,
2222basic-try-load-with-path, basic-load-with-path, try-load-module-with-
2223path, and load-module-with-path have been deleted. The functions
2224above should serve their purposes.
2225
2226*** If the value of the variable %load-hook is a procedure,
2227`primitive-load' applies its value to the name of the file being
2228loaded (without the load path directory name prepended). If its value
2229is #f, it is ignored. Otherwise, an error occurs.
2230
2231This is mostly useful for printing load notification messages.
2232
2233
2234** The function `eval!' is no longer accessible from the scheme level.
2235We can't allow operations which introduce glocs into the scheme level,
2236because Guile's type system can't handle these as data. Use `eval' or
2237`read-and-eval!' (see below) as replacement.
2238
2239** The new function read-and-eval! reads an expression from PORT,
2240evaluates it, and returns the result. This is more efficient than
2241simply calling `read' and `eval', since it is not necessary to make a
2242copy of the expression for the evaluator to munge.
2243
2244Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
2245for the `read' function.
2246
2247
2248** The function `int?' has been removed; its definition was identical
2249to that of `integer?'.
2250
2251** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
2252use the R4RS names for these functions.
2253
2254** The function object-properties no longer returns the hash handle;
2255it simply returns the object's property list.
2256
2257** Many functions have been changed to throw errors, instead of
2258returning #f on failure. The point of providing exception handling in
2259the language is to simplify the logic of user code, but this is less
2260useful if Guile's primitives don't throw exceptions.
2261
2262** The function `fileno' has been renamed from `%fileno'.
2263
2264** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
2265
2266
2267* Changes to Guile's C interface:
2268
2269** The library's initialization procedure has been simplified.
2270scm_boot_guile now has the prototype:
2271
2272void scm_boot_guile (int ARGC,
2273 char **ARGV,
2274 void (*main_func) (),
2275 void *closure);
2276
2277scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
2278MAIN_FUNC should do all the work of the program (initializing other
2279packages, reading user input, etc.) before returning. When MAIN_FUNC
2280returns, call exit (0); this function never returns. If you want some
2281other exit value, MAIN_FUNC may call exit itself.
2282
2283scm_boot_guile arranges for program-arguments to return the strings
2284given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
2285scm_set_program_arguments with the final list, so Scheme code will
2286know which arguments have been processed.
2287
2288scm_boot_guile establishes a catch-all catch handler which prints an
2289error message and exits the process. This means that Guile exits in a
2290coherent way when system errors occur and the user isn't prepared to
2291handle it. If the user doesn't like this behavior, they can establish
2292their own universal catcher in MAIN_FUNC to shadow this one.
2293
2294Why must the caller do all the real work from MAIN_FUNC? The garbage
2295collector assumes that all local variables of type SCM will be above
2296scm_boot_guile's stack frame on the stack. If you try to manipulate
2297SCM values after this function returns, it's the luck of the draw
2298whether the GC will be able to find the objects you allocate. So,
2299scm_boot_guile function exits, rather than returning, to discourage
2300people from making that mistake.
2301
2302The IN, OUT, and ERR arguments were removed; there are other
2303convenient ways to override these when desired.
2304
2305The RESULT argument was deleted; this function should never return.
2306
2307The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
2308general.
2309
2310
2311** Guile's header files should no longer conflict with your system's
2312header files.
2313
2314In order to compile code which #included <libguile.h>, previous
2315versions of Guile required you to add a directory containing all the
2316Guile header files to your #include path. This was a problem, since
2317Guile's header files have names which conflict with many systems'
2318header files.
2319
2320Now only <libguile.h> need appear in your #include path; you must
2321refer to all Guile's other header files as <libguile/mumble.h>.
2322Guile's installation procedure puts libguile.h in $(includedir), and
2323the rest in $(includedir)/libguile.
2324
2325
2326** Two new C functions, scm_protect_object and scm_unprotect_object,
2327have been added to the Guile library.
2328
2329scm_protect_object (OBJ) protects OBJ from the garbage collector.
2330OBJ will not be freed, even if all other references are dropped,
2331until someone does scm_unprotect_object (OBJ). Both functions
2332return OBJ.
2333
2334Note that calls to scm_protect_object do not nest. You can call
2335scm_protect_object any number of times on a given object, and the
2336next call to scm_unprotect_object will unprotect it completely.
2337
2338Basically, scm_protect_object and scm_unprotect_object just
2339maintain a list of references to things. Since the GC knows about
2340this list, all objects it mentions stay alive. scm_protect_object
2341adds its argument to the list; scm_unprotect_object remove its
2342argument from the list.
2343
2344
2345** scm_eval_0str now returns the value of the last expression
2346evaluated.
2347
2348** The new function scm_read_0str reads an s-expression from a
2349null-terminated string, and returns it.
2350
2351** The new function `scm_stdio_to_port' converts a STDIO file pointer
2352to a Scheme port object.
2353
2354** The new function `scm_set_program_arguments' allows C code to set
e80c8fea 2355the value returned by the Scheme `program-arguments' function.
6685dc83 2356
6685dc83 2357\f
1a1945be
JB
2358Older changes:
2359
2360* Guile no longer includes sophisticated Tcl/Tk support.
2361
2362The old Tcl/Tk support was unsatisfying to us, because it required the
2363user to link against the Tcl library, as well as Tk and Guile. The
2364interface was also un-lispy, in that it preserved Tcl/Tk's practice of
2365referring to widgets by names, rather than exporting widgets to Scheme
2366code as a special datatype.
2367
2368In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
2369maintainers described some very interesting changes in progress to the
2370Tcl/Tk internals, which would facilitate clean interfaces between lone
2371Tk and other interpreters --- even for garbage-collected languages
2372like Scheme. They expected the new Tk to be publicly available in the
2373fall of 1996.
2374
2375Since it seems that Guile might soon have a new, cleaner interface to
2376lone Tk, and that the old Guile/Tk glue code would probably need to be
2377completely rewritten, we (Jim Blandy and Richard Stallman) have
2378decided not to support the old code. We'll spend the time instead on
2379a good interface to the newer Tk, as soon as it is available.
5c54da76 2380
8512dea6 2381Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 2382
5c54da76
JB
2383\f
2384Copyright information:
2385
ea00ecba 2386Copyright (C) 1996,1997 Free Software Foundation, Inc.
5c54da76
JB
2387
2388 Permission is granted to anyone to make or distribute verbatim copies
2389 of this document as received, in any medium, provided that the
2390 copyright notice and this permission notice are preserved,
2391 thus giving the recipient permission to redistribute in turn.
2392
2393 Permission is granted to distribute modified versions
2394 of this document, or of portions of it,
2395 under the above conditions, provided also that they
2396 carry prominent notices stating who last changed them.
2397
48d224d7
JB
2398\f
2399Local variables:
2400mode: outline
2401paragraph-separate: "[ \f]*$"
2402end:
2403