Document `guile-tools compile'.
[bpt/guile.git] / NEWS
CommitLineData
b2cbe8d8 1Guile NEWS --- history of user-visible changes.
4a457691 2Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5c54da76
JB
3See the end for copying conditions.
4
1e457544 5Please send Guile bug reports to bug-guile@gnu.org.
5ebbe4ef 6
5c54da76 7\f
ef283979
AW
8(During the 1.9 series, we will keep an incremental NEWS for the latest
9prerelease, and a full NEWS corresponding to 1.8 -> 2.0.)
10
211a5b04
NJ
11Changes in 1.9.7 (since the 1.9.6 prerelease):
12
cf8ec359
AW
13** Complete support for version information in Guile's `module' form
14
15Guile modules now have a `#:version' field. They may be loaded by
16version as well. See "R6RS Version References", "General Information
17about Modules", "Using Guile Modules", and "Creating Guile Modules" in
18the manual for more information.
19
20** Support for renaming bindings on module export
21
22Wherever Guile accepts a symbol as an argument to specify a binding to
23export, it now also accepts a pair of symbols, indicating that a binding
24should be renamed on export. See "Creating Guile Modules" in the manual
25for more information.
26
27** Imported statprof, SSAX, and texinfo modules from Guile-Lib
28
29The statprof statistical profiler, the SSAX XML toolkit, and the texinfo
30toolkit from Guile-Lib have been imported into Guile proper. See
31"Standard Library" in the manual for more details.
32
33** Function profiling and tracing at the REPL
34
35The `,profile FORM' REPL meta-command can now be used to statistically
36profile execution of a form, to see which functions are taking the most
37time. See `,help profile' for more information.
38
39Similarly, `,trace FORM' traces all function applications that occur
40during the execution of `FORM'. See `,help trace' for more information.
41
42** New debugger
43
44By default, if an exception is raised at the REPL and not caught by user
45code, Guile will drop the user into a debugger. The user may request a
46backtrace, inspect frames, or continue raising the exception. Full
47documentation is available from within the debugger.
48
49** New function, `truncated-print', with `format' support
50
51`(ice-9 pretty-print)' now exports `truncated-print', a printer that
52will ensure that the output stays within a certain width, truncating the
53output in what is hopefully an intelligent manner. See the manual for
54more details.
55
56There is a new `format' specifier, `~@y', for doing a truncated
57print (as opposed to `~y', which does a pretty-print). See the `format'
58documentation for more details.
59
60** Primitive procedures are now VM trampoline procedures
61
62Guile's old evaluator used to have special cases for applying "gsubrs",
63primitive procedures with specified numbers of required, optional, and
64rest arguments. Now, however, Guile represents gsubrs as normal VM
65procedures, with appropriate bytecode to parse out the correct number of
66arguments, including optional and rest arguments, and then with a
67special bytecode to apply the gsubr.
68
69This allows primitive procedures to appear on the VM stack, allowing
70them to be accurately counted in profiles. Also they now have more
71debugging information attached to them -- their number of arguments, for
72example. In addition, the VM can completely inline the application
73mechanics, allowing for faster primitive calls.
74
75However there are some changes on the C level. There is no more
76`scm_tc7_gsubr' or `scm_tcs_subrs' typecode for primitive procedures, as
77they are just VM procedures. Likewise the macros `SCM_GSUBR_TYPE',
78`SCM_GSUBR_MAKTYPE', `SCM_GSUBR_REQ', `SCM_GSUBR_OPT', and
79`SCM_GSUBR_REST' are gone, as are `SCM_SUBR_META_INFO', `SCM_SUBR_PROPS'
80`SCM_SET_SUBR_GENERIC_LOC', and `SCM_SUBR_ARITY_TO_TYPE'.
81
82Perhaps more significantly, `scm_c_make_subr',
83`scm_c_make_subr_with_generic', `scm_c_define_subr', and
84`scm_c_define_subr_with_generic'. They all operated on subr typecodes,
85and there are no more subr typecodes. Use the scm_c_make_gsubr family
86instead.
87
88Normal users of gsubrs should not be affected, though, as the
89scm_c_make_gsubr family still is the correct way to create primitive
90procedures.
91
92** SRFI-4 vectors reimplemented in terms of R6RS bytevectors
93
94Guile now implements SRFI-4 vectors using bytevectors. Often when you
95have a numeric vector, you end up wanting to write its bytes somewhere,
96or have access to the underlying bytes, or read in bytes from somewhere
97else. Bytevectors are very good at this sort of thing. But the SRFI-4
98APIs are nicer to use when doing number-crunching, because they are
99addressed by element and not by byte.
100
101So as a compromise, Guile allows all bytevector functions to operate on
102numeric vectors. They address the underlying bytes in the native
103endianness, as one would expect.
104
105Following the same reasoning, that it's just bytes underneath, Guile
106also allows uniform vectors of a given type to be accessed as if they
107were of any type. One can fill a u32vector, and access its elements with
108u8vector-ref. One can use f64vector-ref on bytevectors. It's all the
109same to Guile.
110
111In this way, uniform numeric vectors may be written to and read from
112input/output ports using the procedures that operate on bytevectors.
113
114Calls to SRFI-4 accessors (ref and set functions) from Scheme are now
115inlined to the VM instructions for bytevector access.
116
117See "SRFI-4" in the manual, for more information.
118
119** Nonstandard SRFI-4 procedures now available from `(srfi srfi-4 gnu)'
120
121Guile's `(srfi srfi-4)' now only exports those srfi-4 procedures that
122are part of the standard. Complex uniform vectors and the
123`any->FOOvector' family are now available only from `(srfi srfi-4 gnu)'.
124
125Guile's default environment imports `(srfi srfi-4)', and probably should
126import `(srfi srfi-4 gnu)' as well.
127
128See "SRFI-4 Extensions" in the manual, for more information.
129
130** Unicode: String normalization, general categories, title case
131
132Guile now exports the Unicode string normalization functions
133`string-normalize-nfc', `string-normalize-nfd', `string-normalize-nfkc',
134and `string-normalize-nfkd'. See "String Comparison" in the manual for
135more information. See "Characters" for information on the new
136`char-general-category', and "Character Case Mapping" for
137`char-titlecase', `char-locale-titlecase', and
138`string-locale-titlecase'.
139
140** Faster access to the free variables of a closure
141
142Guile's old garbage collector limited the size of Scheme objects to be 2
143or 4 words. Now with the BDW collector, Guile can allocate
144variable-sized objects, allowing storage of the free variables of a
145closure inline to the closure itself.
146
211a5b04
NJ
147** New primitive `getsid'
148
149Scheme binding for the `getsid' C library call.
150
cf8ec359
AW
151** Changed invocation mechanics of applicable SMOBs
152
153Guile's old evaluator used to have special cases for applying SMOB
154objects. Now, with the VM, when Guile sees a SMOB, it looks up a VM
155trampoline procedure for it, and use the normal mechanics to apply the
156trampoline. This simplifies procedure application in the normal,
157non-SMOB case.
158
159The upshot is that the mechanics used to apply a SMOB are different from
1601.8. Descriptors no longer have `apply_0', `apply_1', `apply_2', and
161`apply_3' functions, and the macros SCM_SMOB_APPLY_0 and friends are now
162deprecated. Just use the scm_call_0 family of procedures.
163
164** Remove deprecated array C interfaces
165
166Removed the deprecated array functions `scm_i_arrayp',
167`scm_i_array_ndim', `scm_i_array_mem', `scm_i_array_v',
168`scm_i_array_base', `scm_i_array_dims', and the deprecated macros
169`SCM_ARRAYP', `SCM_ARRAY_NDIM', `SCM_ARRAY_CONTP', `SCM_ARRAY_MEM',
170`SCM_ARRAY_V', `SCM_ARRAY_BASE', and `SCM_ARRAY_DIMS'.
171
172** String encoding errors throw to `encoding-error' instead of `misc-error'
173
174** Keyword argument errors uniformly throw to `keyword-argument-error'
175
176** Remove unused snarf macros
177
178`SCM_DEFINE1', `SCM_PRIMITIVE_GENERIC_1', `SCM_PROC1, and `SCM_GPROC1'
179are no more. Use SCM_DEFINE or SCM_PRIMITIVE_GENERIC instead.
180
181** Add foreign value wrapper
182
183Guile now has a datatype for aliasing "foreign" values, such as native
184long values. This should be useful for making a proper foreign function
185interface. Interested hackers should see libguile/foreign.h.
186
187** New functions: `scm_call_n', `scm_c_run_hookn'
188
189`scm_call_n' applies to apply a function to an array of arguments.
190`scm_c_run_hookn' runs a hook with an array of arguments.
191
192** Load path change: search in version-specific paths before site paths
193
194When looking for a module, Guile now searches first in Guile's
195version-specific path (the library path), *then* in the site dir. This
196allows Guile's copy of SSAX to override any Guile-Lib copy the user has
197installed. Also it should cut the number of `stat' system calls by half,
198in the common case.
199
acf04ab4
AW
200** And of course, the usual collection of bugfixes
201
19fef497
AW
202Interested users should see the ChangeLog for more information.
203
acf04ab4 204
7b96f3dd 205\f
ef283979 206Changes in 1.9.x (since the 1.8.x series):
96b73e84
AW
207
208* New modules (see the manual for details)
209
210** `(srfi srfi-18)', more sophisticated multithreading support
211** `(ice-9 i18n)', internationalization support
212** `(rnrs bytevector)', the R6RS bytevector API
93617170 213** `(rnrs io ports)', a subset of the R6RS I/O port API
96b73e84
AW
214** `(system xref)', a cross-referencing facility (FIXME undocumented)
215
cf8ec359
AW
216** Imported statprof, SSAX, and texinfo modules from Guile-Lib
217
218The statprof statistical profiler, the SSAX XML toolkit, and the texinfo
219toolkit from Guile-Lib have been imported into Guile proper. See
220"Standard Library" in the manual for more details.
221
96b73e84
AW
222* Changes to the stand-alone interpreter
223
224** Guile now can compile Scheme to bytecode for a custom virtual machine.
225
226Compiled code loads much faster than Scheme source code, and runs around
2273 or 4 times as fast, generating much less garbage in the process.
fa1804e9
AW
228
229** The stack limit is now initialized from the environment.
230
231If getrlimit(2) is available and a stack limit is set, Guile will set
232its stack limit to 80% of the rlimit. Otherwise the limit is 160000
233words, a four-fold increase from the earlier default limit.
234
96b73e84
AW
235** New environment variables: GUILE_LOAD_COMPILED_PATH,
236 GUILE_SYSTEM_LOAD_COMPILED_PATH
fa1804e9 237
96b73e84
AW
238GUILE_LOAD_COMPILED_PATH is for compiled files what GUILE_LOAD_PATH is
239for source files. It is a different path, however, because compiled
240files are architecture-specific. GUILE_SYSTEM_LOAD_COMPILED_PATH is like
241GUILE_SYSTEM_PATH.
242
243** New read-eval-print loop (REPL) implementation
244
245Running Guile with no arguments drops the user into the new REPL. While
246it is self-documenting to an extent, the new REPL has not yet been
247documented in the manual. This will be fixed before 2.0.
248
cf8ec359
AW
249** Function profiling and tracing at the REPL
250
251The `,profile FORM' REPL meta-command can now be used to statistically
252profile execution of a form, to see which functions are taking the most
253time. See `,help profile' for more information.
254
255Similarly, `,trace FORM' traces all function applications that occur
256during the execution of `FORM'. See `,help trace' for more information.
257
258** New debugger
259
260By default, if an exception is raised at the REPL and not caught by user
261code, Guile will drop the user into a debugger. The user may request a
262backtrace, inspect frames, or continue raising the exception. Full
263documentation is available from within the debugger.
264
96b73e84
AW
265** New `guile-tools' commands: `compile', `disassemble'
266
93617170 267Pass the `--help' command-line option to these commands for more
96b73e84
AW
268information.
269
b0217d17
AW
270** Guile now adds its install prefix to the LTDL_LIBRARY_PATH
271
272Users may now install Guile to nonstandard prefixes and just run
273`/path/to/bin/guile', instead of also having to set LTDL_LIBRARY_PATH to
274include `/path/to/lib'.
275
276** Guile's Emacs integration is now more keyboard-friendly
277
278Backtraces may now be disclosed with the keyboard in addition to the
279mouse.
280
cf8ec359
AW
281** Load path change: search in version-specific paths before site paths
282
283When looking for a module, Guile now searches first in Guile's
284version-specific path (the library path), *then* in the site dir. This
285allows Guile's copy of SSAX to override any Guile-Lib copy the user has
286installed. Also it should cut the number of `stat' system calls by half,
287in the common case.
288
289
96b73e84
AW
290* Changes to Scheme functions and syntax
291
4a457691
AW
292** New implementation of `primitive-eval'
293
294Guile's `primitive-eval' is now implemented in Scheme. Actually there is
295still a C evaluator, used when building a fresh Guile to interpret the
296compiler, so we can compile eval.scm. Thereafter all calls to
297primitive-eval are implemented by VM-compiled code.
298
299This allows all of Guile's procedures, be they interpreted or compiled,
300to execute on the same stack, unifying multiple-value return semantics,
301providing for proper tail recursion between interpreted and compiled
302code, and simplifying debugging.
303
304As part of this change, the evaluator no longer mutates the internal
305representation of the code being evaluated in a thread-unsafe manner.
306
307There are two negative aspects of this change, however. First, Guile
308takes a lot longer to compile now. Also, there is less debugging
309information available for debugging interpreted code. We hope to improve
310both of these situations.
311
312There are many changes to the internal C evalator interface, but all
313public interfaces should be the same. See the ChangeLog for details. If
314we have inadvertantly changed an interface that you were using, please
315contact bug-guile@gnu.org.
316
96b73e84
AW
317** Procedure removed: `the-environment'
318
319This procedure was part of the interpreter's execution model, and does
320not apply to the compiler.
fa1804e9 321
4a457691
AW
322** No more `local-eval'
323
324`local-eval' used to exist so that one could evaluate code in the
325lexical context of a function. Since there is no way to get the lexical
326environment any more, as that concept has no meaning for the compiler,
327and a different meaning for the interpreter, we have removed the
328function.
329
330If you think you need `local-eval', you should probably implement your
331own metacircular evaluator. It will probably be as fast as Guile's
332anyway.
333
93617170 334** Files loaded with `primitive-load-path' will now be compiled
fa1804e9
AW
335 automatically.
336
337If a compiled .go file corresponding to a .scm file is not found or is
338not fresh, the .scm file will be compiled on the fly, and the resulting
339.go file stored away. An advisory note will be printed on the console.
340
341Note that this mechanism depends on preservation of the .scm and .go
342modification times; if the .scm or .go files are moved after
343installation, care should be taken to preserve their original
344timestamps.
345
19fef497
AW
346Autocompiled files will be stored in the $XDG_CACHE_HOME/guile/ccache
347directory, where $XDG_CACHE_HOME defaults to ~/.cache. This directory
348will be created if needed.
fa1804e9
AW
349
350To inhibit autocompilation, set the GUILE_AUTO_COMPILE environment
351variable to 0, or pass --no-autocompile on the Guile command line.
352
96b73e84
AW
353Note that there is currently a bug here: automatic compilation will
354sometimes be attempted when it shouldn't.
fa1804e9 355
96b73e84
AW
356For example, the old (lang elisp) modules are meant to be interpreted,
357not compiled. This bug will be fixed before 2.0. FIXME 2.0: Should say
358something here about module-transformer called for compile.
fa1804e9 359
99e31c32
AW
360** Files loaded with `load' will now be compiled automatically.
361
362As with files loaded via `primitive-load-path', `load' will also compile
363its target if autocompilation is enabled, and a fresh compiled file is
364not found.
365
366There are two points of difference to note, however. First, `load' does
367not search `GUILE_LOAD_COMPILED_PATH' for the file; it only looks in the
368autocompilation directory, normally a subdirectory of ~/.cache/guile.
369
370Secondly, autocompilation also applies to files loaded via the -l
371command-line argument -- so the user may experience a slight slowdown
372the first time they run a Guile script, as the script is autocompiled.
373
96b73e84 374** New POSIX procedures: `getrlimit' and `setrlimit'
fa1804e9 375
96b73e84
AW
376Note however that the interface of these functions is likely to change
377in the next prerelease.
fa1804e9 378
4a457691
AW
379** New POSIX procedure: `getsid'
380
381Scheme binding for the `getsid' C library call.
382
96b73e84 383** New procedure in `(oops goops)': `method-formals'
fa1804e9 384
96b73e84
AW
385** BUG: (procedure-property func 'arity) does not work on compiled
386 procedures
fa1804e9 387
96b73e84 388This will be fixed one way or another before 2.0.
fa1804e9 389
96b73e84
AW
390** New procedures in (ice-9 session): `add-value-help-handler!',
391 `remove-value-help-handler!', `add-name-help-handler!'
392 `remove-name-help-handler!', `procedure-arguments',
fa1804e9 393
96b73e84
AW
394The value and name help handlers provide some minimal extensibility to
395the help interface. Guile-lib's `(texinfo reflection)' uses them, for
396example, to make stexinfo help documentation available. See those
397procedures' docstrings for more information.
398
399`procedure-arguments' describes the arguments that a procedure can take,
400combining arity and formals. For example:
401
402 (procedure-arguments resolve-interface)
403 => ((required . (name)) (rest . args))
fa1804e9 404
96b73e84
AW
405Additionally, `module-commentary' is now publically exported from
406`(ice-9 session).
407
cf8ec359 408** Removed: `procedure->memoizing-macro', `procedure->syntax'
96b73e84 409
cf8ec359
AW
410These procedures created primitive fexprs for the old evaluator, and are
411no longer supported. If you feel that you need these functions, you
412probably need to write your own metacircular evaluator (which will
413probably be as fast as Guile's, anyway).
96b73e84
AW
414
415** New language: ECMAScript
416
417Guile now ships with one other high-level language supported,
418ECMAScript. The goal is to support all of version 3.1 of the standard,
419but not all of the libraries are there yet. This support is not yet
420documented; ask on the mailing list if you are interested.
421
19fef497
AW
422** New language: Brainfuck
423
424Brainfuck is a toy language that closely models Turing machines. Guile's
425brainfuck compiler is meant to be an example of implementing other
426languages. See the manual for details, or
427http://en.wikipedia.org/wiki/Brainfuck for more information about the
428Brainfuck language itself.
429
4a457691
AW
430** New language: Elisp
431
432Guile now has an experimental Emacs Lisp compiler and runtime. You can
433now switch to Elisp at the repl: `,language elisp'. All kudos to Daniel
434Kraft, and all bugs to bug-guile@gnu.org.
435
96b73e84
AW
436** Defmacros may now have docstrings.
437
438Indeed, any macro may have a docstring. `object-documentation' from
439`(ice-9 documentation)' may be used to retrieve the docstring, once you
440have a macro value -- but see the above note about first-class macros.
441Docstrings are associated with the syntax transformer procedures.
442
443** The psyntax expander now knows how to interpret the @ and @@ special
444 forms.
445
446** The psyntax expander is now hygienic with respect to modules.
447
448Free variables in a macro are scoped in the module that the macro was
449defined in, not in the module the macro is used in. For example, code
450like this works now:
451
452 (define-module (foo) #:export (bar))
453 (define (helper x) ...)
454 (define-syntax bar
455 (syntax-rules () ((_ x) (helper x))))
456
457 (define-module (baz) #:use-module (foo))
458 (bar qux)
459
460It used to be you had to export `helper' from `(foo)' as well.
461Thankfully, this has been fixed.
462
cf8ec359
AW
463** Complete support for version information in Guile's `module' form
464
465Guile modules now have a `#:version' field. They may be loaded by
466version as well. See "R6RS Version References", "General Information
467about Modules", "Using Guile Modules", and "Creating Guile Modules" in
468the manual for more information.
96b73e84 469
cf8ec359
AW
470** Support for renaming bindings on module export
471
472Wherever Guile accepts a symbol as an argument to specify a binding to
473export, it now also accepts a pair of symbols, indicating that a binding
474should be renamed on export. See "Creating Guile Modules" in the manual
475for more information.
96b73e84
AW
476
477** `eval-case' has been deprecated, and replaced by `eval-when'.
478
479The semantics of `eval-when' are easier to understand. It is still
480missing documentation, however.
481
482** Guile is now more strict about prohibiting definitions in expression
483 contexts.
484
485Although previous versions of Guile accepted it, the following
486expression is not valid, in R5RS or R6RS:
487
488 (if test (define foo 'bar) (define foo 'baz))
489
490In this specific case, it would be better to do:
491
492 (define foo (if test 'bar 'baz))
493
494It is certainly possible to circumvent this resriction with e.g.
495`(module-define! (current-module) 'foo 'baz)'. We would appreciate
496feedback about this change (a consequence of using psyntax as the
497default expander), and may choose to revisit this situation before 2.0
498in response to user feedback.
499
500** Defmacros must now produce valid Scheme expressions.
501
502It used to be that defmacros could unquote in Scheme values, as a way of
503supporting partial evaluation, and avoiding some hygiene issues. For
504example:
505
506 (define (helper x) ...)
507 (define-macro (foo bar)
508 `(,helper ,bar))
509
510Assuming this macro is in the `(baz)' module, the direct translation of
511this code would be:
512
513 (define (helper x) ...)
514 (define-macro (foo bar)
515 `((@@ (baz) helper) ,bar))
516
517Of course, one could just use a hygienic macro instead:
518
519 (define-syntax foo
520 (syntax-rules ()
521 ((_ bar) (helper bar))))
522
523** Guile's psyntax now supports docstrings and internal definitions.
524
525The following Scheme is not strictly legal:
526
527 (define (foo)
528 "bar"
529 (define (baz) ...)
530 (baz))
531
532However its intent is fairly clear. Guile interprets "bar" to be the
533docstring of `foo', and the definition of `baz' is still in definition
534context.
535
536** Macros need to be defined before their first use.
537
538It used to be that with lazy memoization, this might work:
539
540 (define (foo x)
541 (ref x))
542 (define-macro (ref x) x)
543 (foo 1) => 1
544
545But now, the body of `foo' is interpreted to mean a call to the toplevel
546`ref' function, instead of a macro expansion. The solution is to define
547macros before code that uses them.
548
549** Functions needed by macros at expand-time need to be present at
550 expand-time.
551
552For example, this code will work at the REPL:
553
554 (define (double-helper x) (* x x))
555 (define-macro (double-literal x) (double-helper x))
556 (double-literal 2) => 4
557
558But it will not work when a file is compiled, because the definition of
559`double-helper' is not present at expand-time. The solution is to wrap
560the definition of `double-helper' in `eval-when':
561
562 (eval-when (load compile eval)
563 (define (double-helper x) (* x x)))
564 (define-macro (double-literal x) (double-helper x))
565 (double-literal 2) => 4
566
567See the (currently missing) documentation for eval-when for more
568information.
569
570** New variable, %pre-modules-transformer
571
572Need to document this one some more.
573
574** Temporarily removed functions: `macroexpand', `macroexpand-1'
575
576`macroexpand' will be added back before 2.0. It is unclear how to
577implement `macroexpand-1' with syntax-case, though PLT Scheme does prove
578that it is possible.
fa1804e9
AW
579
580** New reader macros: #' #` #, #,@
581
582These macros translate, respectively, to `syntax', `quasisyntax',
583`unsyntax', and `unsyntax-splicing'. See the R6RS for more information.
584These reader macros may be overridden by `read-hash-extend'.
585
586** Incompatible change to #'
587
588Guile did have a #' hash-extension, by default, which just returned the
589subsequent datum: #'foo => foo. In the unlikely event that anyone
590actually used this, this behavior may be reinstated via the
591`read-hash-extend' mechanism.
592
593** Scheme expresssions may be commented out with #;
594
93617170
LC
595#; comments out an entire expression. See SRFI-62 or the R6RS for more
596information.
fa1804e9 597
93617170 598** `make-stack' with a tail-called procedural narrowing argument no longer
fa1804e9
AW
599 works (with compiled procedures)
600
601It used to be the case that a captured stack could be narrowed to select
602calls only up to or from a certain procedure, even if that procedure
603already tail-called another procedure. This was because the debug
604information from the original procedure was kept on the stack.
605
606Now with the new compiler, the stack only contains active frames from
607the current continuation. A narrow to a procedure that is not in the
608stack will result in an empty stack. To fix this, narrow to a procedure
609that is active in the current continuation, or narrow to a specific
610number of stack frames.
611
612** backtraces through compiled procedures only show procedures that are
613 active in the current continuation
614
615Similarly to the previous issue, backtraces in compiled code may be
616different from backtraces in interpreted code. There are no semantic
617differences, however. Please mail bug-guile@gnu.org if you see any
618deficiencies with Guile's backtraces.
619
620** syntax-rules and syntax-case macros now propagate source information
621 through to the expanded code
622
623This should result in better backtraces.
624
625** The currying behavior of `define' has been removed.
626
627Before, `(define ((f a) b) (* a b))' would translate to
628
629 (define f (lambda (a) (lambda (b) (* a b))))
630
93617170 631Now a syntax error is signaled, as this syntax is not supported by
fa1804e9
AW
632default. If there is sufficient demand, this syntax can be supported
633again by default.
634
4a457691
AW
635** New procedure, `define!'
636
637`define!' is a procedure that takes two arguments, a symbol and a value,
638and binds the value to the symbol in the current module. It's useful to
639programmatically make definitions in the current module, and is slightly
640less verbose than `module-define!'.
641
fa1804e9
AW
642** All modules have names now
643
644Before, you could have anonymous modules: modules without names. Now,
645because of hygiene and macros, all modules have names. If a module was
646created without a name, the first time `module-name' is called on it, a
647fresh name will be lazily generated for it.
648
649** Many syntax errors have different texts now
650
651Syntax errors still throw to the `syntax-error' key, but the arguments
652are often different now. Perhaps in the future, Guile will switch to
93617170 653using standard SRFI-35 conditions.
fa1804e9
AW
654
655** Returning multiple values to compiled code will silently truncate the
656 values to the expected number
657
658For example, the interpreter would raise an error evaluating the form,
659`(+ (values 1 2) (values 3 4))', because it would see the operands as
660being two compound "values" objects, to which `+' does not apply.
661
662The compiler, on the other hand, receives multiple values on the stack,
663not as a compound object. Given that it must check the number of values
664anyway, if too many values are provided for a continuation, it chooses
665to truncate those values, effectively evaluating `(+ 1 3)' instead.
666
667The idea is that the semantics that the compiler implements is more
668intuitive, and the use of the interpreter will fade out with time.
669This behavior is allowed both by the R5RS and the R6RS.
670
671** Multiple values in compiled code are not represented by compound
672 objects
673
674This change may manifest itself in the following situation:
675
676 (let ((val (foo))) (do-something) val)
677
678In the interpreter, if `foo' returns multiple values, multiple values
679are produced from the `let' expression. In the compiler, those values
680are truncated to the first value, and that first value is returned. In
681the compiler, if `foo' returns no values, an error will be raised, while
682the interpreter would proceed.
683
684Both of these behaviors are allowed by R5RS and R6RS. The compiler's
685behavior is more correct, however. If you wish to preserve a potentially
686multiply-valued return, you will need to set up a multiple-value
687continuation, using `call-with-values'.
688
689** Defmacros are now implemented in terms of syntax-case.
690
691The practical ramification of this is that the `defmacro?' predicate has
692been removed, along with `defmacro-transformer', `macro-table',
693`xformer-table', `assert-defmacro?!', `set-defmacro-transformer!' and
694`defmacro:transformer'. This is because defmacros are simply macros. If
695any of these procedures provided useful facilities to you, we encourage
696you to contact the Guile developers.
697
698** psyntax is now the default expander
699
700Scheme code is now expanded by default by the psyntax hygienic macro
701expander. Expansion is performed completely before compilation or
702interpretation.
703
704Notably, syntax errors will be signalled before interpretation begins.
705In the past, many syntax errors were only detected at runtime if the
706code in question was memoized.
707
708As part of its expansion, psyntax renames all lexically-bound
709identifiers. Original identifier names are preserved and given to the
710compiler, but the interpreter will see the renamed variables, e.g.,
711`x432' instead of `x'.
712
713Note that the psyntax that Guile uses is a fork, as Guile already had
714modules before incompatible modules were added to psyntax -- about 10
715years ago! Thus there are surely a number of bugs that have been fixed
716in psyntax since then. If you find one, please notify bug-guile@gnu.org.
717
718** syntax-rules and syntax-case are available by default.
719
720There is no longer any need to import the `(ice-9 syncase)' module
721(which is now deprecated). The expander may be invoked directly via
722`sc-expand', though it is normally searched for via the current module
723transformer.
724
725Also, the helper routines for syntax-case are available in the default
726environment as well: `syntax->datum', `datum->syntax',
727`bound-identifier=?', `free-identifier=?', `generate-temporaries',
728`identifier?', and `syntax-violation'. See the R6RS for documentation.
729
4a457691
AW
730** Tail patterns in syntax-case
731
732Guile has pulled in some more recent changes from the psyntax portable
733syntax expander, to implement support for "tail patterns". Such patterns
734are supported by syntax-rules and syntax-case. This allows a syntax-case
735match clause to have ellipses, then a pattern at the end. For example:
736
737 (define-syntax case
738 (syntax-rules (else)
739 ((_ val match-clause ... (else e e* ...))
740 [...])))
741
742Note how there is MATCH-CLAUSE, which is ellipsized, then there is a
743tail pattern for the else clause. Thanks to Andreas Rottmann for the
744patch, and Kent Dybvig for the code.
745
fa1804e9
AW
746** Lexical bindings introduced by hygienic macros may not be referenced
747 by nonhygienic macros.
748
749If a lexical binding is introduced by a hygienic macro, it may not be
750referenced by a nonhygienic macro. For example, this works:
751
752 (let ()
753 (define-macro (bind-x val body)
754 `(let ((x ,val)) ,body))
755 (define-macro (ref x)
756 x)
757 (bind-x 10 (ref x)))
758
759But this does not:
760
761 (let ()
762 (define-syntax bind-x
763 (syntax-rules ()
764 ((_ val body) (let ((x val)) body))))
765 (define-macro (ref x)
766 x)
767 (bind-x 10 (ref x)))
768
769It is not normal to run into this situation with existing code. However,
770as code is ported over from defmacros to syntax-case, it is possible to
771run into situations like this. In the future, Guile will probably port
772its `while' macro to syntax-case, which makes this issue one to know
773about.
774
775** Macros may no longer be referenced as first-class values.
776
777In the past, you could evaluate e.g. `if', and get its macro value. Now,
778expanding this form raises a syntax error.
779
780Macros still /exist/ as first-class values, but they must be
781/referenced/ via the module system, e.g. `(module-ref (current-module)
782'if)'.
783
784This decision may be revisited before the 2.0 release. Feedback welcome
785to guile-devel@gnu.org (subscription required) or bug-guile@gnu.org (no
786subscription required).
787
e614d375
AW
788** `case-lambda' is now available in the default environment.
789
790The binding in the default environment is equivalent to the one from the
791`(srfi srfi-16)' module. Use the srfi-16 module explicitly if you wish
792to maintain compatibility with Guile 1.8 and earlier.
793
5bb408cc
AW
794** Compiled procedures may now have more than one arity.
795
796This can be the case, for example, in case-lambda procedures. The
797arities of compiled procedures may be accessed via procedures from the
798`(system vm program)' module; see "Compiled Procedures", "Optional
799Arguments", and "Case-lambda" in the manual.
800
e614d375
AW
801** `lambda*' and `define*' are now available in the default environment
802
803As with `case-lambda', `(ice-9 optargs)' continues to be supported, for
804compatibility purposes. No semantic change has been made (we hope).
805Optional and keyword arguments now dispatch via special VM operations,
806without the need to cons rest arguments, making them very fast.
807
cf8ec359
AW
808** New function, `truncated-print', with `format' support
809
810`(ice-9 pretty-print)' now exports `truncated-print', a printer that
811will ensure that the output stays within a certain width, truncating the
812output in what is hopefully an intelligent manner. See the manual for
813more details.
814
815There is a new `format' specifier, `~@y', for doing a truncated
816print (as opposed to `~y', which does a pretty-print). See the `format'
817documentation for more details.
818
819** SRFI-4 vectors reimplemented in terms of R6RS bytevectors
820
821Guile now implements SRFI-4 vectors using bytevectors. Often when you
822have a numeric vector, you end up wanting to write its bytes somewhere,
823or have access to the underlying bytes, or read in bytes from somewhere
824else. Bytevectors are very good at this sort of thing. But the SRFI-4
825APIs are nicer to use when doing number-crunching, because they are
826addressed by element and not by byte.
827
828So as a compromise, Guile allows all bytevector functions to operate on
829numeric vectors. They address the underlying bytes in the native
830endianness, as one would expect.
831
832Following the same reasoning, that it's just bytes underneath, Guile
833also allows uniform vectors of a given type to be accessed as if they
834were of any type. One can fill a u32vector, and access its elements with
835u8vector-ref. One can use f64vector-ref on bytevectors. It's all the
836same to Guile.
837
838In this way, uniform numeric vectors may be written to and read from
839input/output ports using the procedures that operate on bytevectors.
840
841Calls to SRFI-4 accessors (ref and set functions) from Scheme are now
842inlined to the VM instructions for bytevector access.
843
844See "SRFI-4" in the manual, for more information.
845
846** Nonstandard SRFI-4 procedures now available from `(srfi srfi-4 gnu)'
847
848Guile's `(srfi srfi-4)' now only exports those srfi-4 procedures that
849are part of the standard. Complex uniform vectors and the
850`any->FOOvector' family are now available only from `(srfi srfi-4 gnu)'.
851
852Guile's default environment imports `(srfi srfi-4)', and probably should
853import `(srfi srfi-4 gnu)' as well.
854
855See "SRFI-4 Extensions" in the manual, for more information.
856
e614d375
AW
857** New syntax: include-from-path.
858
859`include-from-path' is like `include', except it looks for its file in
860the load path. It can be used to compile other files into a file.
861
862** New syntax: quasisyntax.
863
864`quasisyntax' is to `syntax' as `quasiquote' is to `quote'. See the R6RS
865documentation for more information. Thanks to Andre van Tonder for the
866implementation.
867
108e18b1
AW
868** Unicode characters
869
870Unicode characters may be entered in octal format via e.g. `#\454', or
871created via (integer->char 300). A hex external representation will
872probably be introduced at some point.
873
874** Unicode strings
875
876Internally, strings are now represented either in the `latin-1'
877encoding, one byte per character, or in UTF-32, with four bytes per
878character. Strings manage their own allocation, switching if needed.
879
99e31c32
AW
880Extended characters may be written in a literal string using the
881hexadecimal escapes `\xXX', `\uXXXX', or `\UXXXXXX', for 8-bit, 16-bit,
882or 24-bit codepoints, respectively, or entered directly in the native
883encoding of the port on which the string is read.
884
56664c08
AW
885** Unicode symbols
886
887One may now use U+03BB (GREEK SMALL LETTER LAMBDA) as an identifier.
888
99e31c32
AW
889** Support for non-ASCII source code files
890
891The default reader now handles source code files for some of the
892non-ASCII character encodings, such as UTF-8. A non-ASCII source file
893should have an encoding declaration near the top of the file. Also,
894there is a new function, `file-encoding', that scans a port for a coding
895declaration. See the section of the manual entitled, "Character Encoding
896of Source Files".
897
898The pre-1.9.3 reader handled 8-bit clean but otherwise unspecified source
899code. This use is now discouraged.
900
901** Support for locale transcoding when reading from and writing to ports
902
903Ports now have an associated character encoding, and port read and write
904operations do conversion to and from locales automatically. Ports also
905have an associated strategy for how to deal with locale conversion
906failures.
907
908See the documentation in the manual for the four new support functions,
909`set-port-encoding!', `port-encoding', `set-port-conversion-strategy!',
910and `port-conversion-strategy'.
911
912** String and SRFI-13 functions can operate on Unicode strings
913
914** Unicode support for SRFI-14 character sets
915
916The default character sets are no longer locale dependent and contain
917characters from the whole Unicode range. There is a new predefined
918character set, `char-set:designated', which contains all assigned
919Unicode characters. There is a new debugging function, `%char-set-dump'.
920
921** Character functions operate on Unicode characters
922
923`char-upcase' and `char-downcase' use default Unicode casing rules.
924Character comparisons such as `char<?' and `char-ci<?' now sort based on
925Unicode code points.
108e18b1
AW
926
927** Global variables `scm_charnames' and `scm_charnums' are removed
928
929These variables contained the names of control characters and were
930used when writing characters. While these were global, they were
931never intended to be public API. They have been replaced with private
932functions.
933
934** EBCDIC support is removed
935
936There was an EBCDIC compile flag that altered some of the character
937processing. It appeared that full EBCDIC support was never completed
938and was unmaintained.
939
6cf43047 940** Compile-time warnings: -Wunbound-variable, -Warity-mismatch.
b0217d17
AW
941
942Guile can warn about potentially unbound free variables. Pass the
943-Wunbound-variable on the `guile-tools compile' command line, or add
944`#:warnings '(unbound-variable)' to your `compile' or `compile-file'
945invocation.
946
6cf43047
AW
947Guile can also warn when you pass the wrong number of arguments to a
948procedure, with -Warity-mismatch, or `arity-mismatch' in the
949`#:warnings' as above.
950
93617170
LC
951** A new `memoize-symbol' evaluator trap has been added.
952
953This trap can be used for efficiently implementing a Scheme code
954coverage.
fa1804e9 955
96b73e84 956** Duplicate bindings among used modules are resolved lazily.
93617170 957
96b73e84 958This slightly improves program startup times.
fa1804e9 959
96b73e84 960** New thread cancellation and thread cleanup API
93617170 961
96b73e84 962See `cancel-thread', `set-thread-cleanup!', and `thread-cleanup'.
fa1804e9 963
4a457691
AW
964** GOOPS dispatch in scheme
965
966As an implementation detail, GOOPS dispatch is no longer implemented by
967special evaluator bytecodes, but rather directly via a Scheme function
968associated with an applicable struct. There is some VM support for the
969underlying primitives, like `class-of'.
970
971This change will in the future allow users to customize generic function
972dispatch without incurring a performance penalty, and allow us to
973implement method combinations.
974
e614d375
AW
975** GOOPS cleanups.
976
977GOOPS had a number of concepts that were relevant to the days of Tcl,
978but not any more: operators and entities, mainly. These objects were
979never documented, and it is unlikely that they were ever used. Operators
980were a kind of generic specific to the Tcl support. Entities were
981applicable structures, but were unusable; entities will come back in the
982next alpha release, but with a less stupid name.
983
4a457691
AW
984** Applicable struct support
985
986One may now make structs from Scheme that may be applied as procedures.
987To do so, make a struct whose vtable is `<applicable-struct-vtable>'.
988That struct will be the vtable of your applicable structs; instances of
989that new struct are assumed to have the procedure in their first slot.
990`<applicable-struct-vtable>' is like Common Lisp's
991`funcallable-standard-class'. Likewise there is
992`<applicable-struct-with-setter-vtable>', which looks for the setter in
993the second slot. This needs to be better documented.
994
995** New struct slot allocation: "hidden"
996
997A hidden slot is readable and writable, but will not be initialized by a
998call to make-struct. For example in your layout you would say "ph"
999instead of "pw". Hidden slots are useful for adding new slots to a
1000vtable without breaking existing invocations to make-struct.
1001
1002** eqv? not a generic
1003
1004One used to be able to extend `eqv?' as a primitive-generic, but no
1005more. Because `eqv?' is in the expansion of `case' (via `memv'), which
1006should be able to compile to static dispatch tables, it doesn't make
1007sense to allow extensions that would subvert this optimization.
1008
e614d375
AW
1009** `inet-ntop' and `inet-pton' are always available.
1010
1011Guile now use a portable implementation of `inet_pton'/`inet_ntop', so
1012there is no more need to use `inet-aton'/`inet-ntoa'. The latter
1013functions are deprecated.
1014
5bb408cc
AW
1015** Fast bit operations.
1016
1017The bit-twiddling operations `ash', `logand', `logior', and `logxor' now
1018have dedicated bytecodes. Guile is not just for symbolic computation,
1019it's for number crunching too.
1020
4a457691
AW
1021** Faster SRFI-9 record access
1022
1023SRFI-9 records are now implemented directly on top of Guile's structs,
1024and their accessors are defined in such a way that normal call-sites
1025inline to special VM opcodes, while still allowing for the general case
1026(e.g. passing a record accessor to `apply').
1027
e614d375
AW
1028** R6RS block comment support
1029
1030Guile now supports R6RS nested block comments. The start of a comment is
1031marked with `#|', and the end with `|#'.
1032
1033** `guile-2' cond-expand feature
1034
1035To test if your code is running under Guile 2.0 (or its alpha releases),
1036test for the `guile-2' cond-expand feature. Like this:
1037
1038 (cond-expand (guile-2 (eval-when (compile)
1039 ;; This must be evaluated at compile time.
1040 (fluid-set! current-reader my-reader)))
1041 (guile
1042 ;; Earlier versions of Guile do not have a
1043 ;; separate compilation phase.
1044 (fluid-set! current-reader my-reader)))
1045
96b73e84 1046** Fix bad interaction between `false-if-exception' and stack-call.
fa1804e9 1047
96b73e84
AW
1048Exceptions thrown by `false-if-exception' were erronously causing the
1049stack to be saved, causing later errors to show the incorrectly-saved
1050backtrace. This has been fixed.
fa1804e9 1051
96b73e84 1052** New global variables: %load-compiled-path, %load-compiled-extensions
fa1804e9 1053
96b73e84 1054These are analogous to %load-path and %load-extensions.
fa1804e9 1055
96b73e84 1056** New procedure, `make-promise'
fa1804e9 1057
96b73e84 1058`(make-promise (lambda () foo))' is equivalent to `(delay foo)'.
fa1804e9 1059
108e18b1
AW
1060** `defined?' may accept a module as its second argument
1061
1062Previously it only accepted internal structures from the evaluator.
1063
96b73e84 1064** New entry into %guile-build-info: `ccachedir'
fa1804e9 1065
96b73e84 1066** Fix bug in `module-bound?'.
fa1804e9 1067
96b73e84
AW
1068`module-bound?' was returning true if a module did have a local
1069variable, but one that was unbound, but another imported module bound
1070the variable. This was an error, and was fixed.
fa1804e9 1071
96b73e84 1072** `(ice-9 syncase)' has been deprecated.
fa1804e9 1073
96b73e84
AW
1074As syntax-case is available by default, importing `(ice-9 syncase)' has
1075no effect, and will trigger a deprecation warning.
fa1804e9 1076
b0217d17
AW
1077** New readline history functions
1078
1079The (ice-9 readline) module now provides add-history, read-history,
1080write-history and clear-history, which wrap the corresponding GNU
1081History library functions.
1082
86d88a22
AW
1083** Removed deprecated uniform array procedures:
1084 dimensions->uniform-array, list->uniform-array, array-prototype
1085
1086Instead, use make-typed-array, list->typed-array, or array-type,
1087respectively.
1088
87e00370
LC
1089** Last but not least, the `λ' macro can be used in lieu of `lambda'
1090
96b73e84 1091* Changes to the C interface
fa1804e9 1092
7b96f3dd
LC
1093** Guile now uses libgc, the Boehm-Demers-Weiser garbage collector
1094
1095The semantics of `scm_gc_malloc ()' have been changed, in a
1096backward-compatible way. A new allocation routine,
1097`scm_gc_malloc_pointerless ()', was added.
1098
1099Libgc is a conservative GC, which we hope will make interaction with C
1100code easier and less error-prone.
1101
4a457691
AW
1102** New type definitions for `scm_t_intptr' and friends.
1103
1104`SCM_T_UINTPTR_MAX', `SCM_T_INTPTR_MIN', `SCM_T_INTPTR_MAX',
1105`SIZEOF_SCM_T_BITS', `scm_t_intptr' and `scm_t_uintptr' are now
1106available to C. Have fun!
1107
96b73e84 1108** The GH interface (deprecated in version 1.6, 2001) was removed.
fa1804e9 1109
96b73e84 1110** Internal `scm_i_' functions now have "hidden" linkage with GCC/ELF
fa1804e9 1111
96b73e84
AW
1112This makes these internal functions technically not callable from
1113application code.
fa1804e9 1114
96b73e84
AW
1115** Functions for handling `scm_option' now no longer require an argument
1116indicating length of the `scm_t_option' array.
fa1804e9 1117
4a457691
AW
1118** Procedures-with-setters are now implemented using applicable structs
1119
1120From a user's perspective this doesn't mean very much. But if, for some
1121odd reason, you used the SCM_PROCEDURE_WITH_SETTER_P, SCM_PROCEDURE, or
1122SCM_SETTER macros, know that they're deprecated now. Also, scm_tc7_pws
1123is gone.
1124
1125** Remove old evaluator closures
1126
1127There used to be ranges of typecodes allocated to interpreted data
1128structures, but that it no longer the case, given that interpreted
1129procedure are now just regular VM closures. As a result, there is a
1130newly free tc3, and a number of removed macros. See the ChangeLog for
1131details.
1132
cf8ec359 1133** Primitive procedures are now VM trampoline procedures
4a457691
AW
1134
1135It used to be that there were something like 12 different typecodes
1136allocated to primitive procedures, each with its own calling convention.
1137Now there is only one, the gsubr. This may affect user code if you were
1138defining a procedure using scm_c_make_subr rather scm_c_make_gsubr. The
1139solution is to switch to use scm_c_make_gsubr. This solution works well
1140both with the old 1.8 and and with the current 1.9 branch.
1141
cf8ec359
AW
1142Guile's old evaluator used to have special cases for applying "gsubrs",
1143primitive procedures with specified numbers of required, optional, and
1144rest arguments. Now, however, Guile represents gsubrs as normal VM
1145procedures, with appropriate bytecode to parse out the correct number of
1146arguments, including optional and rest arguments, and then with a
1147special bytecode to apply the gsubr.
1148
1149This allows primitive procedures to appear on the VM stack, allowing
1150them to be accurately counted in profiles. Also they now have more
1151debugging information attached to them -- their number of arguments, for
1152example. In addition, the VM can completely inline the application
1153mechanics, allowing for faster primitive calls.
1154
1155However there are some changes on the C level. There is no more
1156`scm_tc7_gsubr' or `scm_tcs_subrs' typecode for primitive procedures, as
1157they are just VM procedures. Likewise the macros `SCM_GSUBR_TYPE',
1158`SCM_GSUBR_MAKTYPE', `SCM_GSUBR_REQ', `SCM_GSUBR_OPT', and
1159`SCM_GSUBR_REST' are gone, as are `SCM_SUBR_META_INFO', `SCM_SUBR_PROPS'
1160`SCM_SET_SUBR_GENERIC_LOC', and `SCM_SUBR_ARITY_TO_TYPE'.
1161
1162Perhaps more significantly, `scm_c_make_subr',
1163`scm_c_make_subr_with_generic', `scm_c_define_subr', and
1164`scm_c_define_subr_with_generic'. They all operated on subr typecodes,
1165and there are no more subr typecodes. Use the scm_c_make_gsubr family
1166instead.
1167
1168Normal users of gsubrs should not be affected, though, as the
1169scm_c_make_gsubr family still is the correct way to create primitive
1170procedures.
1171
1172** Remove deprecated array C interfaces
1173
1174Removed the deprecated array functions `scm_i_arrayp',
1175`scm_i_array_ndim', `scm_i_array_mem', `scm_i_array_v',
1176`scm_i_array_base', `scm_i_array_dims', and the deprecated macros
1177`SCM_ARRAYP', `SCM_ARRAY_NDIM', `SCM_ARRAY_CONTP', `SCM_ARRAY_MEM',
1178`SCM_ARRAY_V', `SCM_ARRAY_BASE', and `SCM_ARRAY_DIMS'.
1179
1180** Remove unused snarf macros
1181
1182`SCM_DEFINE1', `SCM_PRIMITIVE_GENERIC_1', `SCM_PROC1, and `SCM_GPROC1'
1183are no more. Use SCM_DEFINE or SCM_PRIMITIVE_GENERIC instead.
1184
1185** Add foreign value wrapper
1186
1187Guile now has a datatype for aliasing "foreign" values, such as native
1188long values. This should be useful for making a proper foreign function
1189interface. Interested hackers should see libguile/foreign.h.
1190
1191** New functions: `scm_call_n', `scm_c_run_hookn'
1192
1193`scm_call_n' applies to apply a function to an array of arguments.
1194`scm_c_run_hookn' runs a hook with an array of arguments.
1195
4a457691
AW
1196** Some SMOB types changed to have static typecodes
1197
1198Fluids, dynamic states, and hash tables used to be SMOB objects, but now
1199they have statically allocated tc7 typecodes.
1200
1201** Preparations for changing SMOB representation
1202
1203If things go right, we'll be changing the SMOB representation soon. To
1204that end, we did a lot of cleanups to calls to e.g. SCM_CELL_WORD_2(x) when
1205the code meant SCM_SMOB_DATA_2(x); user code will need similar changes
1206in the future. Code accessing SMOBs using SCM_CELL macros was never
1207correct, but until now things still worked. Users should be aware of
1208such changes.
fa1804e9 1209
cf8ec359
AW
1210** Changed invocation mechanics of applicable SMOBs
1211
1212Guile's old evaluator used to have special cases for applying SMOB
1213objects. Now, with the VM, when Guile sees a SMOB, it looks up a VM
1214trampoline procedure for it, and use the normal mechanics to apply the
1215trampoline. This simplifies procedure application in the normal,
1216non-SMOB case.
1217
1218The upshot is that the mechanics used to apply a SMOB are different from
12191.8. Descriptors no longer have `apply_0', `apply_1', `apply_2', and
1220`apply_3' functions, and the macros SCM_SMOB_APPLY_0 and friends are now
1221deprecated. Just use the scm_call_0 family of procedures.
1222
96b73e84 1223** New C function: scm_module_public_interface
a4f1c77d 1224
96b73e84 1225This procedure corresponds to Scheme's `module-public-interface'.
24d6fae8 1226
4a457691
AW
1227** Undeprecate `scm_the_root_module ()'
1228
1229It's useful to be able to get the root module from C without doing a
1230full module lookup.
1231
e614d375
AW
1232** Inline vector allocation
1233
1234Instead of having vectors point out into the heap for their data, their
1235data is now allocated inline to the vector object itself. The same is
1236true for bytevectors, by default, though there is an indirection
1237available which should allow for making a bytevector from an existing
1238memory region.
1239
4a457691
AW
1240** New struct constructors that don't involve making lists
1241
1242`scm_c_make_struct' and `scm_c_make_structv' are new varargs and array
1243constructors, respectively, for structs. You might find them useful.
1244
1245** Stack refactor
1246
1247In Guile 1.8, there were debugging frames on the C stack. Now there is
1248no more need to explicitly mark the stack in this way, because Guile has
1249a VM stack that it knows how to walk, which simplifies the C API
1250considerably. See the ChangeLog for details; the relevant interface is
1251in libguile/stacks.h. The Scheme API has not been changed significantly.
1252
e614d375
AW
1253** Removal of Guile's primitive object system.
1254
1255There were a number of pieces in `objects.[ch]' that tried to be a
1256minimal object system, but were never documented, and were quickly
1257obseleted by GOOPS' merge into Guile proper. So `scm_make_class_object',
1258`scm_make_subclass_object', `scm_metaclass_standard', and like symbols
1259from objects.h are no more. In the very unlikely case in which these
1260were useful to you, we urge you to contact guile-devel.
1261
1262** No future.
1263
1264Actually the future is still in the state that it was, is, and ever
1265shall be, Amen, except that `futures.c' and `futures.h' are no longer a
1266part of it. These files were experimental, never compiled, and would be
1267better implemented in Scheme anyway. In the future, that is.
1268
4a457691
AW
1269** Deprecate trampolines
1270
1271There used to be C functions `scm_trampoline_0', `scm_trampoline_1', and
1272so on. The point was to do some precomputation on the type of the
1273procedure, then return a specialized "call" procedure. However this
1274optimization wasn't actually an optimization, so it is now deprecated.
1275Just use `scm_call_0', etc instead.
1276
5bb408cc
AW
1277** Better support for Lisp `nil'.
1278
1279The bit representation of `nil' has been tweaked so that it is now very
1280efficient to check e.g. if a value is equal to Scheme's end-of-list or
1281Lisp's nil. Additionally there are a heap of new, specific predicates
1282like scm_is_null_or_nil. Probably in the future we will #define
1283scm_is_null to scm_is_null_or_nil.
1284
e614d375
AW
1285** Support for static allocation of strings, symbols, and subrs.
1286
1287Calls to snarfing CPP macros like SCM_DEFINE macro will now allocate
1288much of their associated data as static variables, reducing Guile's
1289memory footprint.
1290
93617170
LC
1291** `scm_stat' has an additional argument, `exception_on_error'
1292** `scm_primitive_load_path' has an additional argument `exception_on_not_found'
24d6fae8 1293
f1ce9199
LC
1294** `scm_set_port_seek' and `scm_set_port_truncate' use the `scm_t_off' type
1295
1296Previously they would use the `off_t' type, which is fragile since its
1297definition depends on the application's value for `_FILE_OFFSET_BITS'.
1298
ba4c43dc
LC
1299** The `long_long' C type, deprecated in 1.8, has been removed
1300
86d88a22
AW
1301** Removed deprecated uniform array procedures: scm_make_uve,
1302 scm_array_prototype, scm_list_to_uniform_array,
1303 scm_dimensions_to_uniform_array, scm_make_ra, scm_shap2ra, scm_cvref,
1304 scm_ra_set_contp, scm_aind, scm_raprin1
1305
1306These functions have been deprecated since early 2005.
1307
a4f1c77d 1308* Changes to the distribution
6caac03c 1309
53befeb7
NJ
1310** Guile's license is now LGPLv3+
1311
1312In other words the GNU Lesser General Public License, version 3 or
1313later (at the discretion of each person that chooses to redistribute
1314part of Guile).
1315
56664c08
AW
1316** GOOPS documentation folded into Guile reference manual
1317
1318GOOPS, Guile's object system, used to be documented in separate manuals.
1319This content is now included in Guile's manual directly.
1320
96b73e84 1321** `guile-config' will be deprecated in favor of `pkg-config'
8a9faebc 1322
96b73e84 1323`guile-config' has been rewritten to get its information from
93617170 1324`pkg-config', so this should be a transparent change. Note however that
96b73e84
AW
1325guile.m4 has yet to be modified to call pkg-config instead of
1326guile-config.
2e77f720 1327
54dd0ca5
LC
1328** Guile now provides `guile-2.0.pc' instead of `guile-1.8.pc'
1329
1330Programs that use `pkg-config' to find Guile or one of its Autoconf
1331macros should now require `guile-2.0' instead of `guile-1.8'.
1332
96b73e84 1333** New installation directory: $(pkglibdir)/1.9/ccache
62560650 1334
96b73e84
AW
1335If $(libdir) is /usr/lib, for example, Guile will install its .go files
1336to /usr/lib/guile/1.9/ccache. These files are architecture-specific.
89bc270d 1337
b0217d17
AW
1338** Dynamically loadable extensions may be placed in a Guile-specific path
1339
1340Before, Guile only searched the system library paths for extensions
1341(e.g. /usr/lib), which meant that the names of Guile extensions had to
1342be globally unique. Installing them to a Guile-specific extensions
1343directory is cleaner. Use `pkg-config --variable=extensionsdir
1344guile-2.0' to get the location of the extensions directory.
1345
7b96f3dd
LC
1346** New dependency: libgc
1347
1348See http://www.hpl.hp.com/personal/Hans_Boehm/gc/, for more information.
1349
1350** New dependency: GNU libunistring
32e29e24 1351
108e18b1 1352See http://www.gnu.org/software/libunistring/, for more information. Our
7b96f3dd 1353Unicode support uses routines from libunistring.
32e29e24 1354
a4f1c77d 1355
dc686d7b 1356\f
9957b1c7
LC
1357Changes in 1.8.8 (since 1.8.7)
1358
1359* Bugs fixed
1360
1361** Fix possible buffer overruns when parsing numbers
c15d8e6a 1362** Avoid clash with system setjmp/longjmp on IA64
1ff4da65 1363** Fix `wrong type arg' exceptions with IPv6 addresses
9957b1c7
LC
1364
1365\f
dc686d7b
NJ
1366Changes in 1.8.7 (since 1.8.6)
1367
922d417b
JG
1368* New modules (see the manual for details)
1369
1370** `(srfi srfi-98)', an interface to access environment variables
1371
dc686d7b
NJ
1372* Bugs fixed
1373
f5851b89 1374** Fix compilation with `--disable-deprecated'
dc686d7b 1375** Fix %fast-slot-ref/set!, to avoid possible segmentation fault
cbee5075 1376** Fix MinGW build problem caused by HAVE_STRUCT_TIMESPEC confusion
ab878b0f 1377** Fix build problem when scm_t_timespec is different from struct timespec
95a040cd 1378** Fix build when compiled with -Wundef -Werror
1bcf7993 1379** More build fixes for `alphaev56-dec-osf5.1b' (Tru64)
5374ec9c 1380** Build fixes for `powerpc-ibm-aix5.3.0.0' (AIX 5.3)
5c006c3f
LC
1381** With GCC, always compile with `-mieee' on `alpha*' and `sh*'
1382** Better diagnose broken `(strftime "%z" ...)' in `time.test' (bug #24130)
fc76c08d 1383** Fix parsing of SRFI-88/postfix keywords longer than 128 characters
40f89215 1384** Fix reading of complex numbers where both parts are inexact decimals
d41668fa 1385
ad5f5ada
NJ
1386** Allow @ macro to work with (ice-9 syncase)
1387
1388Previously, use of the @ macro in a module whose code is being
1389transformed by (ice-9 syncase) would cause an "Invalid syntax" error.
1390Now it works as you would expect (giving the value of the specified
1391module binding).
1392
05588a1a
LC
1393** Have `scm_take_locale_symbol ()' return an interned symbol (bug #25865)
1394
d41668fa 1395\f
8c40b75d
LC
1396Changes in 1.8.6 (since 1.8.5)
1397
071bb6a8
LC
1398* New features (see the manual for details)
1399
1400** New convenience function `scm_c_symbol_length ()'
1401
091baf9e
NJ
1402** Single stepping through code from Emacs
1403
1404When you use GDS to evaluate Scheme code from Emacs, you can now use
1405`C-u' to indicate that you want to single step through that code. See
1406`Evaluating Scheme Code' in the manual for more details.
1407
9e4db0ef
LC
1408** New "guile(1)" man page!
1409
242ebeaf
LC
1410* Changes to the distribution
1411
1412** Automake's `AM_MAINTAINER_MODE' is no longer used
1413
1414Thus, the `--enable-maintainer-mode' configure option is no longer
1415available: Guile is now always configured in "maintainer mode".
1416
e0063477
LC
1417** `ChangeLog' files are no longer updated
1418
1419Instead, changes are detailed in the version control system's logs. See
1420the top-level `ChangeLog' files for details.
1421
1422
8c40b75d
LC
1423* Bugs fixed
1424
fd2b17b9 1425** `symbol->string' now returns a read-only string, as per R5RS
c6333102 1426** Fix incorrect handling of the FLAGS argument of `fold-matches'
589d9eb8 1427** `guile-config link' now prints `-L$libdir' before `-lguile'
4a1db3a9 1428** Fix memory corruption involving GOOPS' `class-redefinition'
191e7165 1429** Fix possible deadlock in `mutex-lock'
95c6523b 1430** Fix build issue on Tru64 and ia64-hp-hpux11.23 (`SCM_UNPACK' macro)
4696a666 1431** Fix build issue on mips, mipsel, powerpc and ia64 (stack direction)
450be18d 1432** Fix build issue on hppa2.0w-hp-hpux11.11 (`dirent64' and `readdir64_r')
88cefbc7 1433** Fix build issue on i386-unknown-freebsd7.0 ("break strict-aliasing rules")
76dae881 1434** Fix misleading output from `(help rationalize)'
5ea8e76e 1435** Fix build failure on Debian hppa architecture (bad stack growth detection)
1dd79792 1436** Fix `gcd' when called with a single, negative argument.
d8b6e191 1437** Fix `Stack overflow' errors seen when building on some platforms
ccf1ca4a
LC
1438** Fix bug when `scm_with_guile ()' was called several times from the
1439 same thread
76350432
LC
1440** The handler of SRFI-34 `with-exception-handler' is now invoked in the
1441 dynamic environment of the call to `raise'
cb823e63 1442** Fix potential deadlock in `make-struct'
691343ea 1443** Fix compilation problem with libltdl from Libtool 2.2.x
3ae3166b 1444** Fix sloppy bound checking in `string-{ref,set!}' with the empty string
6eadcdab 1445
8c40b75d 1446\f
5305df84
LC
1447Changes in 1.8.5 (since 1.8.4)
1448
4b824aae
LC
1449* Infrastructure changes
1450
1451** Guile repository switched from CVS to Git
1452
1453The new repository can be accessed using
1454"git-clone git://git.sv.gnu.org/guile.git", or can be browsed on-line at
1455http://git.sv.gnu.org/gitweb/?p=guile.git . See `README' for details.
1456
92826dd0
LC
1457** Add support for `pkg-config'
1458
1459See "Autoconf Support" in the manual for details.
1460
189681f5
LC
1461* New modules (see the manual for details)
1462
1463** `(srfi srfi-88)'
1464
ef4cbc08
LC
1465* New features (see the manual for details)
1466
1467** New `postfix' read option, for SRFI-88 keyword syntax
f5c2af4b 1468** Some I/O primitives have been inlined, which improves I/O performance
b20ef3a6 1469** New object-based traps infrastructure
ef4cbc08 1470
b20ef3a6
NJ
1471This is a GOOPS-based infrastructure that builds on Guile's low-level
1472evaluator trap calls and facilitates the development of debugging
1473features like single-stepping, breakpoints, tracing and profiling.
1474See the `Traps' node of the manual for details.
1475
1476** New support for working on Guile code from within Emacs
1477
1478Guile now incorporates the `GDS' library (previously distributed
1479separately) for working on Guile code from within Emacs. See the
1480`Using Guile In Emacs' node of the manual for details.
1481
5305df84
LC
1482* Bugs fixed
1483
e27d2495
LC
1484** `scm_add_slot ()' no longer segfaults (fixes bug #22369)
1485** Fixed `(ice-9 match)' for patterns like `((_ ...) ...)'
1486
1487Previously, expressions like `(match '((foo) (bar)) (((_ ...) ...) #t))'
1488would trigger an unbound variable error for `match:andmap'.
1489
62c5382b
LC
1490** `(oop goops describe)' now properly provides the `describe' feature
1491** Fixed `args-fold' from `(srfi srfi-37)'
1492
1493Previously, parsing short option names of argument-less options would
1494lead to a stack overflow.
1495
816e3edf 1496** `(srfi srfi-35)' is now visible through `cond-expand'
61b6542a 1497** Fixed type-checking for the second argument of `eval'
0fb11ae4 1498** Fixed type-checking for SRFI-1 `partition'
f1c212b1
LC
1499** Fixed `struct-ref' and `struct-set!' on "light structs"
1500** Honor struct field access rights in GOOPS
be10cba8 1501** Changed the storage strategy of source properties, which fixes a deadlock
979eade6 1502** Allow compilation of Guile-using programs in C99 mode with GCC 4.3 and later
bfb64eb4 1503** Fixed build issue for GNU/Linux on IA64
fa80e280 1504** Fixed build issues on NetBSD 1.6
a2c25234 1505** Fixed build issue on Solaris 2.10 x86_64
3f520967 1506** Fixed build issue with DEC/Compaq/HP's compiler
c2ad98ad
LC
1507** Fixed `scm_from_complex_double' build issue on FreeBSD
1508** Fixed `alloca' build issue on FreeBSD 6
a7286720 1509** Removed use of non-portable makefile constructs
535b3592 1510** Fixed shadowing of libc's <random.h> on Tru64, which broke compilation
eedcb08a 1511** Make sure all tests honor `$TMPDIR'
5305df84
LC
1512
1513\f
d41668fa
LC
1514Changes in 1.8.4 (since 1.8.3)
1515
1516* Bugs fixed
1517
1518** CR (ASCII 0x0d) is (again) recognized as a token delimiter by the reader
6e14de7d
NJ
1519** Fixed a segmentation fault which occurred when displaying the
1520backtrace of a stack with a promise object (made by `delay') in it.
7d1fc872 1521** Make `accept' leave guile mode while blocking
693758d5 1522** `scm_c_read ()' and `scm_c_write ()' now type-check their port argument
378cc645 1523** Fixed a build problem on AIX (use of func_data identifier)
15bd90ea
NJ
1524** Fixed a segmentation fault which occurred when hashx-ref or hashx-set! was
1525called with an associator proc that returns neither a pair nor #f.
3ac8359a 1526** Secondary threads now always return a valid module for (current-module).
d05bcb2e
NJ
1527** Avoid MacOS build problems caused by incorrect combination of "64"
1528system and library calls.
9a6fac59 1529** `guile-snarf' now honors `$TMPDIR'
25a640ca 1530** `guile-config compile' now reports CPPFLAGS used at compile-time
7f74cf9a 1531** Fixed build with Sun Studio (Solaris 9)
4a19ed04
NJ
1532** Fixed wrong-type-arg errors when creating zero length SRFI-4
1533uniform vectors on AIX.
86a597f8 1534** Fixed a deadlock that occurs upon GC with multiple threads.
4b26c03e 1535** Fixed compile problem with GCC on Solaris and AIX (use of _Complex_I)
d4a00708 1536** Fixed autotool-derived build problems on AIX 6.1.
9a6fac59 1537** Fixed NetBSD/alpha support
b226295a 1538** Fixed MacOS build problem caused by use of rl_get_keymap(_name)
7d1fc872
LC
1539
1540* New modules (see the manual for details)
1541
1542** `(srfi srfi-69)'
d41668fa 1543
b226295a
NJ
1544* Documentation fixes and improvements
1545
1546** Removed premature breakpoint documentation
1547
1548The features described are not available in the series of 1.8.x
1549releases, so the documentation was misleading and has been removed.
1550
1551** More about Guile's default *random-state* variable
1552
1553** GOOPS: more about how to use `next-method'
1554
d3cf93bc
NJ
1555* Changes to the distribution
1556
1557** Corrected a few files that referred incorrectly to the old GPL + special exception licence
1558
1559In fact Guile since 1.8.0 has been licensed with the GNU Lesser
1560General Public License, and the few incorrect files have now been
1561fixed to agree with the rest of the Guile distribution.
1562
5e42b8e7
NJ
1563** Removed unnecessary extra copies of COPYING*
1564
1565The distribution now contains a single COPYING.LESSER at its top level.
1566
a4f1c77d 1567\f
d4c38221
LC
1568Changes in 1.8.3 (since 1.8.2)
1569
1570* New modules (see the manual for details)
1571
f50ca8da 1572** `(srfi srfi-35)'
d4c38221
LC
1573** `(srfi srfi-37)'
1574
e08f3f7a
LC
1575* Bugs fixed
1576
dc061a74 1577** The `(ice-9 slib)' module now works as expected
e08f3f7a 1578** Expressions like "(set! 'x #t)" no longer yield a crash
d7c0c26d 1579** Warnings about duplicate bindings now go to stderr
1ac5fb45 1580** A memory leak in `make-socket-address' was fixed
f43f3620 1581** Alignment issues (e.g., on SPARC) in network routines were fixed
29776e85 1582** A threading issue that showed up at least on NetBSD was fixed
66302618 1583** Build problems on Solaris and IRIX fixed
e08f3f7a 1584
1fdd8ffa
LC
1585* Implementation improvements
1586
7ff6c169 1587** The reader is now faster, which reduces startup time
1fdd8ffa
LC
1588** Procedures returned by `record-accessor' and `record-modifier' are faster
1589
d4c38221 1590\f
45c0ff10
KR
1591Changes in 1.8.2 (since 1.8.1):
1592
1593* New procedures (see the manual for details)
1594
1595** set-program-arguments
b3aa4626 1596** make-vtable
45c0ff10 1597
9320e933
LC
1598* Incompatible changes
1599
1600** The body of a top-level `define' no longer sees the binding being created
1601
1602In a top-level `define', the binding being created is no longer visible
1603from the `define' body. This breaks code like
1604"(define foo (begin (set! foo 1) (+ foo 1)))", where `foo' is now
1605unbound in the body. However, such code was not R5RS-compliant anyway,
1606per Section 5.2.1.
1607
45c0ff10
KR
1608* Bugs fixed
1609
1610** Fractions were not `equal?' if stored in unreduced form.
1611(A subtle problem, since printing a value reduced it, making it work.)
1612** srfi-60 `copy-bit' failed on 64-bit systems
1613** "guile --use-srfi" option at the REPL can replace core functions
1614(Programs run with that option were ok, but in the interactive REPL
1615the core bindings got priority, preventing SRFI replacements or
1616extensions.)
1617** `regexp-exec' doesn't abort() on #\nul in the input or bad flags arg
df449722 1618** `kill' on mingw throws an error for a PID other than oneself
45c0ff10
KR
1619** Procedure names are attached to procedure-with-setters
1620** Array read syntax works with negative lower bound
1621** `array-in-bounds?' fix if an array has different lower bounds on each index
1622** `*' returns exact 0 for "(* inexact 0)"
1623This follows what it always did for "(* 0 inexact)".
c122500a 1624** SRFI-19: Value returned by `(current-time time-process)' was incorrect
0867f7ba 1625** SRFI-19: `date->julian-day' did not account for timezone offset
a1ef7406 1626** `ttyname' no longer crashes when passed a non-tty argument
27782696 1627** `inet-ntop' no longer crashes on SPARC when passed an `AF_INET' address
0867f7ba 1628** Small memory leaks have been fixed in `make-fluid' and `add-history'
b1f57ea4 1629** GOOPS: Fixed a bug in `method-more-specific?'
45c0ff10 1630** Build problems on Solaris fixed
df449722
LC
1631** Build problems on HP-UX IA64 fixed
1632** Build problems on MinGW fixed
45c0ff10
KR
1633
1634\f
a4f1c77d
KR
1635Changes in 1.8.1 (since 1.8.0):
1636
8ab3d8a0 1637* LFS functions are now used to access 64-bit files on 32-bit systems.
a4f1c77d 1638
8ab3d8a0 1639* New procedures (see the manual for details)
4f416616 1640
8ab3d8a0
KR
1641** primitive-_exit - [Scheme] the-root-module
1642** scm_primitive__exit - [C]
1643** make-completion-function - [Scheme] (ice-9 readline)
1644** scm_c_locale_stringn_to_number - [C]
1645** scm_srfi1_append_reverse [C]
1646** scm_srfi1_append_reverse_x [C]
1647** scm_log - [C]
1648** scm_log10 - [C]
1649** scm_exp - [C]
1650** scm_sqrt - [C]
1651
1652* Bugs fixed
1653
1654** Build problems have been fixed on MacOS, SunOS, and QNX.
af4f8612 1655
b3aa4626
KR
1656** `strftime' fix sign of %z timezone offset.
1657
534cd148 1658** A one-dimensional array can now be 'equal?' to a vector.
8ab3d8a0 1659
ad97642e 1660** Structures, records, and SRFI-9 records can now be compared with `equal?'.
af4f8612 1661
8ab3d8a0
KR
1662** SRFI-14 standard char sets are recomputed upon a successful `setlocale'.
1663
1664** `record-accessor' and `record-modifier' now have strict type checks.
1665
1666Record accessor and modifier procedures now throw an error if the
1667record type of the record they're given is not the type expected.
1668(Previously accessors returned #f and modifiers silently did nothing).
1669
1670** It is now OK to use both autoload and use-modules on a given module.
1671
1672** `apply' checks the number of arguments more carefully on "0 or 1" funcs.
1673
1674Previously there was no checking on primatives like make-vector that
1675accept "one or two" arguments. Now there is.
1676
1677** The srfi-1 assoc function now calls its equality predicate properly.
1678
1679Previously srfi-1 assoc would call the equality predicate with the key
1680last. According to the SRFI, the key should be first.
1681
1682** A bug in n-par-for-each and n-for-each-par-map has been fixed.
1683
1684** The array-set! procedure no longer segfaults when given a bit vector.
1685
1686** Bugs in make-shared-array have been fixed.
1687
1688** string<? and friends now follow char<? etc order on 8-bit chars.
1689
1690** The format procedure now handles inf and nan values for ~f correctly.
1691
1692** exact->inexact should no longer overflow when given certain large fractions.
1693
1694** srfi-9 accessor and modifier procedures now have strict record type checks.
a4f1c77d 1695
8ab3d8a0 1696This matches the srfi-9 specification.
a4f1c77d 1697
8ab3d8a0 1698** (ice-9 ftw) procedures won't ignore different files with same inode number.
a4f1c77d 1699
8ab3d8a0
KR
1700Previously the (ice-9 ftw) procedures would ignore any file that had
1701the same inode number as a file they had already seen, even if that
1702file was on a different device.
4f416616
KR
1703
1704\f
8ab3d8a0 1705Changes in 1.8.0 (changes since the 1.6.x series):
ee0c7345 1706
4e250ded
MV
1707* Changes to the distribution
1708
eff2965e
MV
1709** Guile is now licensed with the GNU Lesser General Public License.
1710
77e51fd6
MV
1711** The manual is now licensed with the GNU Free Documentation License.
1712
e2d0a649
RB
1713** Guile now requires GNU MP (http://swox.com/gmp).
1714
1715Guile now uses the GNU MP library for arbitrary precision arithmetic.
e2d0a649 1716
5ebbe4ef
RB
1717** Guile now has separate private and public configuration headers.
1718
b0d10ba6
MV
1719That is, things like HAVE_STRING_H no longer leak from Guile's
1720headers.
5ebbe4ef
RB
1721
1722** Guile now provides and uses an "effective" version number.
b2cbe8d8
RB
1723
1724Guile now provides scm_effective_version and effective-version
1725functions which return the "effective" version number. This is just
1726the normal full version string without the final micro-version number,
a4f1c77d 1727so the current effective-version is "1.8". The effective version
b2cbe8d8
RB
1728should remain unchanged during a stable series, and should be used for
1729items like the versioned share directory name
a4f1c77d 1730i.e. /usr/share/guile/1.8.
b2cbe8d8
RB
1731
1732Providing an unchanging version number during a stable release for
1733things like the versioned share directory can be particularly
1734important for Guile "add-on" packages, since it provides a directory
1735that they can install to that won't be changed out from under them
1736with each micro release during a stable series.
1737
8d54e73a 1738** Thread implementation has changed.
f0b4d944
MV
1739
1740When you configure "--with-threads=null", you will get the usual
1741threading API (call-with-new-thread, make-mutex, etc), but you can't
429d88d4
MV
1742actually create new threads. Also, "--with-threads=no" is now
1743equivalent to "--with-threads=null". This means that the thread API
1744is always present, although you might not be able to create new
1745threads.
f0b4d944 1746
8d54e73a
MV
1747When you configure "--with-threads=pthreads" or "--with-threads=yes",
1748you will get threads that are implemented with the portable POSIX
1749threads. These threads can run concurrently (unlike the previous
1750"coop" thread implementation), but need to cooperate for things like
a558cc63 1751the GC.
f0b4d944 1752
8d54e73a
MV
1753The default is "pthreads", unless your platform doesn't have pthreads,
1754in which case "null" threads are used.
2902a459 1755
a6d75e53
MV
1756See the manual for details, nodes "Initialization", "Multi-Threading",
1757"Blocking", and others.
a558cc63 1758
f74bdbd3
MV
1759** There is the new notion of 'discouraged' features.
1760
1761This is a milder form of deprecation.
1762
1763Things that are discouraged should not be used in new code, but it is
1764OK to leave them in old code for now. When a discouraged feature is
1765used, no warning message is printed like there is for 'deprecated'
1766features. Also, things that are merely discouraged are nevertheless
1767implemented efficiently, while deprecated features can be very slow.
1768
1769You can omit discouraged features from libguile by configuring it with
1770the '--disable-discouraged' option.
1771
1772** Deprecation warnings can be controlled at run-time.
1773
1774(debug-enable 'warn-deprecated) switches them on and (debug-disable
1775'warn-deprecated) switches them off.
1776
0f24e75b 1777** Support for SRFI 61, extended cond syntax for multiple values has
a81d0de1
MV
1778 been added.
1779
1780This SRFI is always available.
1781
f7fb2f39 1782** Support for require-extension, SRFI-55, has been added.
9a5fc8c2 1783
f7fb2f39
RB
1784The SRFI-55 special form `require-extension' has been added. It is
1785available at startup, and provides a portable way to load Scheme
1786extensions. SRFI-55 only requires support for one type of extension,
1787"srfi"; so a set of SRFIs may be loaded via (require-extension (srfi 1
178813 14)).
1789
1790** New module (srfi srfi-26) provides support for `cut' and `cute'.
1791
1792The (srfi srfi-26) module is an implementation of SRFI-26 which
1793provides the `cut' and `cute' syntax. These may be used to specialize
1794parameters without currying.
9a5fc8c2 1795
f5d54eb7
RB
1796** New module (srfi srfi-31)
1797
1798This is an implementation of SRFI-31 which provides a special form
1799`rec' for recursive evaluation.
1800
7b1574ed
MV
1801** The modules (srfi srfi-13), (srfi srfi-14) and (srfi srfi-4) have
1802 been merged with the core, making their functionality always
1803 available.
c5080b51 1804
ce7c0293
MV
1805The modules are still available, tho, and you could use them together
1806with a renaming import, for example.
c5080b51 1807
6191ccec 1808** Guile no longer includes its own version of libltdl.
4e250ded 1809
6191ccec 1810The official version is good enough now.
4e250ded 1811
ae7ded56
MV
1812** The --enable-htmldoc option has been removed from 'configure'.
1813
1814Support for translating the documentation into HTML is now always
1815provided. Use 'make html'.
1816
0f24e75b
MV
1817** New module (ice-9 serialize):
1818
1819(serialize FORM1 ...) and (parallelize FORM1 ...) are useful when you
1820don't trust the thread safety of most of your program, but where you
1821have some section(s) of code which you consider can run in parallel to
1822other sections. See ice-9/serialize.scm for more information.
1823
c34e5780
MV
1824** The configure option '--disable-arrays' has been removed.
1825
1826Support for arrays and uniform numeric arrays is now always included
1827in Guile.
1828
328dc9a3 1829* Changes to the stand-alone interpreter
f12ef3fd 1830
3ece39d6
MV
1831** New command line option `-L'.
1832
1833This option adds a directory to the front of the load path.
1834
f12ef3fd
MV
1835** New command line option `--no-debug'.
1836
1837Specifying `--no-debug' on the command line will keep the debugging
1838evaluator turned off, even for interactive sessions.
1839
1840** User-init file ~/.guile is now loaded with the debugging evaluator.
1841
1842Previously, the normal evaluator would have been used. Using the
1843debugging evaluator gives better error messages.
1844
aff7e166
MV
1845** The '-e' option now 'read's its argument.
1846
1847This is to allow the new '(@ MODULE-NAME VARIABLE-NAME)' construct to
1848be used with '-e'. For example, you can now write a script like
1849
1850 #! /bin/sh
1851 exec guile -e '(@ (demo) main)' -s "$0" "$@"
1852 !#
1853
1854 (define-module (demo)
1855 :export (main))
1856
1857 (define (main args)
1858 (format #t "Demo: ~a~%" args))
1859
1860
f12ef3fd
MV
1861* Changes to Scheme functions and syntax
1862
930888e8
MV
1863** Guardians have changed back to their original semantics
1864
1865Guardians now behave like described in the paper by Dybvig et al. In
1866particular, they no longer make guarantees about the order in which
1867they return objects, and they can no longer be greedy.
1868
1869They no longer drop cyclic data structures.
1870
1871The C function scm_make_guardian has been changed incompatibly and no
1872longer takes the 'greedy_p' argument.
1873
87bdbdbc
MV
1874** New function hashx-remove!
1875
1876This function completes the set of 'hashx' functions.
1877
a558cc63
MV
1878** The concept of dynamic roots has been factored into continuation
1879 barriers and dynamic states.
1880
1881Each thread has a current dynamic state that carries the values of the
1882fluids. You can create and copy dynamic states and use them as the
1883second argument for 'eval'. See "Fluids and Dynamic States" in the
1884manual.
1885
1886To restrict the influence that captured continuations can have on the
1887control flow, you can errect continuation barriers. See "Continuation
1888Barriers" in the manual.
1889
1890The function call-with-dynamic-root now essentially temporarily
1891installs a new dynamic state and errects a continuation barrier.
1892
a2b6a0e7
MV
1893** The default load path no longer includes "." at the end.
1894
1895Automatically loading modules from the current directory should not
1896happen by default. If you want to allow it in a more controlled
1897manner, set the environment variable GUILE_LOAD_PATH or the Scheme
1898variable %load-path.
1899
7b1574ed
MV
1900** The uniform vector and array support has been overhauled.
1901
1902It now complies with SRFI-4 and the weird prototype based uniform
1903array creation has been deprecated. See the manual for more details.
1904
d233b123
MV
1905Some non-compatible changes have been made:
1906 - characters can no longer be stored into byte arrays.
0f24e75b
MV
1907 - strings and bit vectors are no longer considered to be uniform numeric
1908 vectors.
3167d5e4
MV
1909 - array-rank throws an error for non-arrays instead of returning zero.
1910 - array-ref does no longer accept non-arrays when no indices are given.
d233b123
MV
1911
1912There is the new notion of 'generalized vectors' and corresponding
1913procedures like 'generalized-vector-ref'. Generalized vectors include
c34e5780 1914strings, bitvectors, ordinary vectors, and uniform numeric vectors.
d233b123 1915
a558cc63
MV
1916Arrays use generalized vectors as their storage, so that you still
1917have arrays of characters, bits, etc. However, uniform-array-read!
1918and uniform-array-write can no longer read/write strings and
1919bitvectors.
bb9f50ae 1920
ce7c0293
MV
1921** There is now support for copy-on-write substrings, mutation-sharing
1922 substrings and read-only strings.
3ff9283d 1923
ce7c0293
MV
1924Three new procedures are related to this: substring/shared,
1925substring/copy, and substring/read-only. See the manual for more
1926information.
1927
6a1d27ea
MV
1928** Backtraces will now highlight the value that caused the error.
1929
1930By default, these values are enclosed in "{...}", such as in this
1931example:
1932
1933 guile> (car 'a)
1934
1935 Backtrace:
1936 In current input:
1937 1: 0* [car {a}]
1938
1939 <unnamed port>:1:1: In procedure car in expression (car (quote a)):
1940 <unnamed port>:1:1: Wrong type (expecting pair): a
1941 ABORT: (wrong-type-arg)
1942
1943The prefix and suffix used for highlighting can be set via the two new
1944printer options 'highlight-prefix' and 'highlight-suffix'. For
1945example, putting this into ~/.guile will output the bad value in bold
1946on an ANSI terminal:
1947
1948 (print-set! highlight-prefix "\x1b[1m")
1949 (print-set! highlight-suffix "\x1b[22m")
1950
1951
8dbafacd
MV
1952** 'gettext' support for internationalization has been added.
1953
1954See the manual for details.
1955
aff7e166
MV
1956** New syntax '@' and '@@':
1957
1958You can now directly refer to variables exported from a module by
1959writing
1960
1961 (@ MODULE-NAME VARIABLE-NAME)
1962
1963For example (@ (ice-9 pretty-print) pretty-print) will directly access
1964the pretty-print variable exported from the (ice-9 pretty-print)
1965module. You don't need to 'use' that module first. You can also use
b0d10ba6 1966'@' as a target of 'set!', as in (set! (@ mod var) val).
aff7e166
MV
1967
1968The related syntax (@@ MODULE-NAME VARIABLE-NAME) works just like '@',
1969but it can also access variables that have not been exported. It is
1970intended only for kluges and temporary fixes and for debugging, not
1971for ordinary code.
1972
aef0bdb4
MV
1973** Keyword syntax has been made more disciplined.
1974
1975Previously, the name of a keyword was read as a 'token' but printed as
1976a symbol. Now, it is read as a general Scheme datum which must be a
1977symbol.
1978
1979Previously:
1980
1981 guile> #:12
1982 #:#{12}#
1983 guile> #:#{12}#
1984 #:#{\#{12}\#}#
1985 guile> #:(a b c)
1986 #:#{}#
1987 ERROR: In expression (a b c):
1988 Unbound variable: a
1989 guile> #: foo
1990 #:#{}#
1991 ERROR: Unbound variable: foo
1992
1993Now:
1994
1995 guile> #:12
1996 ERROR: Wrong type (expecting symbol): 12
1997 guile> #:#{12}#
1998 #:#{12}#
1999 guile> #:(a b c)
2000 ERROR: Wrong type (expecting symbol): (a b c)
2001 guile> #: foo
2002 #:foo
2003
227eafdb
MV
2004** The printing of symbols that might look like keywords can be
2005 controlled.
2006
2007The new printer option 'quote-keywordish-symbols' controls how symbols
2008are printed that have a colon as their first or last character. The
2009default now is to only quote a symbol with #{...}# when the read
2010option 'keywords' is not '#f'. Thus:
2011
2012 guile> (define foo (string->symbol ":foo"))
2013 guile> (read-set! keywords #f)
2014 guile> foo
2015 :foo
2016 guile> (read-set! keywords 'prefix)
2017 guile> foo
2018 #{:foo}#
2019 guile> (print-set! quote-keywordish-symbols #f)
2020 guile> foo
2021 :foo
2022
1363e3e7
KR
2023** 'while' now provides 'break' and 'continue'
2024
2025break and continue were previously bound in a while loop, but not
2026documented, and continue didn't quite work properly. The undocumented
2027parameter to break which gave a return value for the while has been
2028dropped.
2029
570b5b14
MV
2030** 'call-with-current-continuation' is now also available under the name
2031 'call/cc'.
2032
b0d10ba6 2033** The module system now checks for duplicate bindings.
7b07e5ef 2034
fe6ee052
MD
2035The module system now can check for name conflicts among imported
2036bindings.
f595ccfe 2037
b0d10ba6 2038The behavior can be controlled by specifying one or more 'duplicates'
fe6ee052
MD
2039handlers. For example, to make Guile return an error for every name
2040collision, write:
7b07e5ef
MD
2041
2042(define-module (foo)
2043 :use-module (bar)
2044 :use-module (baz)
fe6ee052 2045 :duplicates check)
f595ccfe 2046
fe6ee052
MD
2047The new default behavior of the module system when a name collision
2048has been detected is to
2049
2050 1. Give priority to bindings marked as a replacement.
6496a663 2051 2. Issue a warning (different warning if overriding core binding).
fe6ee052
MD
2052 3. Give priority to the last encountered binding (this corresponds to
2053 the old behavior).
2054
2055If you want the old behavior back without replacements or warnings you
2056can add the line:
f595ccfe 2057
70a9dc9c 2058 (default-duplicate-binding-handler 'last)
7b07e5ef 2059
fe6ee052 2060to your .guile init file.
7b07e5ef 2061
f595ccfe
MD
2062** New define-module option: :replace
2063
2064:replace works as :export, but, in addition, marks the binding as a
2065replacement.
2066
2067A typical example is `format' in (ice-9 format) which is a replacement
2068for the core binding `format'.
7b07e5ef 2069
70da0033
MD
2070** Adding prefixes to imported bindings in the module system
2071
2072There is now a new :use-module option :prefix. It can be used to add
2073a prefix to all imported bindings.
2074
2075 (define-module (foo)
2076 :use-module ((bar) :prefix bar:))
2077
2078will import all bindings exported from bar, but rename them by adding
2079the prefix `bar:'.
2080
b0d10ba6
MV
2081** Conflicting generic functions can be automatically merged.
2082
2083When two imported bindings conflict and they are both generic
2084functions, the two functions can now be merged automatically. This is
2085activated with the 'duplicates' handler 'merge-generics'.
2086
b2cbe8d8
RB
2087** New function: effective-version
2088
2089Returns the "effective" version number. This is just the normal full
2090version string without the final micro-version number. See "Changes
2091to the distribution" above.
2092
382053e9 2093** New threading functions: parallel, letpar, par-map, and friends
dbe30084 2094
382053e9
KR
2095These are convenient ways to run calculations in parallel in new
2096threads. See "Parallel forms" in the manual for details.
359aab24 2097
e2d820a1
MV
2098** New function 'try-mutex'.
2099
2100This function will attempt to lock a mutex but will return immediately
0f24e75b 2101instead of blocking and indicate failure.
e2d820a1
MV
2102
2103** Waiting on a condition variable can have a timeout.
2104
0f24e75b 2105The function 'wait-condition-variable' now takes a third, optional
e2d820a1
MV
2106argument that specifies the point in time where the waiting should be
2107aborted.
2108
2109** New function 'broadcast-condition-variable'.
2110
5e405a60
MV
2111** New functions 'all-threads' and 'current-thread'.
2112
2113** Signals and system asyncs work better with threads.
2114
2115The function 'sigaction' now takes a fourth, optional, argument that
2116specifies the thread that the handler should run in. When the
2117argument is omitted, the handler will run in the thread that called
2118'sigaction'.
2119
2120Likewise, 'system-async-mark' takes a second, optional, argument that
2121specifies the thread that the async should run in. When it is
2122omitted, the async will run in the thread that called
2123'system-async-mark'.
2124
2125C code can use the new functions scm_sigaction_for_thread and
2126scm_system_async_mark_for_thread to pass the new thread argument.
2127
a558cc63
MV
2128When a thread blocks on a mutex, a condition variable or is waiting
2129for IO to be possible, it will still execute system asyncs. This can
2130be used to interrupt such a thread by making it execute a 'throw', for
2131example.
2132
5e405a60
MV
2133** The function 'system-async' is deprecated.
2134
2135You can now pass any zero-argument procedure to 'system-async-mark'.
2136The function 'system-async' will just return its argument unchanged
2137now.
2138
acfa1f52
MV
2139** New functions 'call-with-blocked-asyncs' and
2140 'call-with-unblocked-asyncs'
2141
2142The expression (call-with-blocked-asyncs PROC) will call PROC and will
2143block execution of system asyncs for the current thread by one level
2144while PROC runs. Likewise, call-with-unblocked-asyncs will call a
2145procedure and will unblock the execution of system asyncs by one
2146level for the current thread.
2147
2148Only system asyncs are affected by these functions.
2149
2150** The functions 'mask-signals' and 'unmask-signals' are deprecated.
2151
2152Use 'call-with-blocked-asyncs' or 'call-with-unblocked-asyncs'
2153instead. Those functions are easier to use correctly and can be
2154nested.
2155
7b232758
MV
2156** New function 'unsetenv'.
2157
f30482f3
MV
2158** New macro 'define-syntax-public'.
2159
2160It works like 'define-syntax' and also exports the defined macro (but
2161only on top-level).
2162
1ee34062
MV
2163** There is support for Infinity and NaNs.
2164
2165Following PLT Scheme, Guile can now work with infinite numbers, and
2166'not-a-numbers'.
2167
2168There is new syntax for numbers: "+inf.0" (infinity), "-inf.0"
2169(negative infinity), "+nan.0" (not-a-number), and "-nan.0" (same as
2170"+nan.0"). These numbers are inexact and have no exact counterpart.
2171
2172Dividing by an inexact zero returns +inf.0 or -inf.0, depending on the
2173sign of the dividend. The infinities are integers, and they answer #t
2174for both 'even?' and 'odd?'. The +nan.0 value is not an integer and is
2175not '=' to itself, but '+nan.0' is 'eqv?' to itself.
2176
2177For example
2178
2179 (/ 1 0.0)
2180 => +inf.0
2181
2182 (/ 0 0.0)
2183 => +nan.0
2184
2185 (/ 0)
2186 ERROR: Numerical overflow
2187
7b232758
MV
2188Two new predicates 'inf?' and 'nan?' can be used to test for the
2189special values.
2190
ba1b077b
MV
2191** Inexact zero can have a sign.
2192
2193Guile can now distinguish between plus and minus inexact zero, if your
2194platform supports this, too. The two zeros are equal according to
2195'=', but not according to 'eqv?'. For example
2196
2197 (- 0.0)
2198 => -0.0
2199
2200 (= 0.0 (- 0.0))
2201 => #t
2202
2203 (eqv? 0.0 (- 0.0))
2204 => #f
2205
bdf26b60
MV
2206** Guile now has exact rationals.
2207
2208Guile can now represent fractions such as 1/3 exactly. Computing with
2209them is also done exactly, of course:
2210
2211 (* 1/3 3/2)
2212 => 1/2
2213
2214** 'floor', 'ceiling', 'round' and 'truncate' now return exact numbers
2215 for exact arguments.
2216
2217For example: (floor 2) now returns an exact 2 where in the past it
2218returned an inexact 2.0. Likewise, (floor 5/4) returns an exact 1.
2219
2220** inexact->exact no longer returns only integers.
2221
2222Without exact rationals, the closest exact number was always an
2223integer, but now inexact->exact returns the fraction that is exactly
2224equal to a floating point number. For example:
2225
2226 (inexact->exact 1.234)
2227 => 694680242521899/562949953421312
2228
e299cee2 2229When you want the old behavior, use 'round' explicitly:
bdf26b60
MV
2230
2231 (inexact->exact (round 1.234))
2232 => 1
2233
2234** New function 'rationalize'.
2235
2236This function finds a simple fraction that is close to a given real
2237number. For example (and compare with inexact->exact above):
2238
fb16d26e 2239 (rationalize (inexact->exact 1.234) 1/2000)
bdf26b60
MV
2240 => 58/47
2241
fb16d26e
MV
2242Note that, as required by R5RS, rationalize returns only then an exact
2243result when both its arguments are exact.
2244
bdf26b60
MV
2245** 'odd?' and 'even?' work also for inexact integers.
2246
2247Previously, (odd? 1.0) would signal an error since only exact integers
2248were recognized as integers. Now (odd? 1.0) returns #t, (odd? 2.0)
2249returns #f and (odd? 1.5) signals an error.
2250
b0d10ba6 2251** Guile now has uninterned symbols.
610922b2 2252
b0d10ba6 2253The new function 'make-symbol' will return an uninterned symbol. This
610922b2
MV
2254is a symbol that is unique and is guaranteed to remain unique.
2255However, uninterned symbols can not yet be read back in.
2256
2257Use the new function 'symbol-interned?' to check whether a symbol is
2258interned or not.
2259
0e6f7775
MV
2260** pretty-print has more options.
2261
2262The function pretty-print from the (ice-9 pretty-print) module can now
2263also be invoked with keyword arguments that control things like
71f271b2 2264maximum output width. See the manual for details.
0e6f7775 2265
8c84b81e 2266** Variables have no longer a special behavior for `equal?'.
ee0c7345
MV
2267
2268Previously, comparing two variables with `equal?' would recursivly
2269compare their values. This is no longer done. Variables are now only
2270`equal?' if they are `eq?'.
2271
4e21fa60
MV
2272** `(begin)' is now valid.
2273
2274You can now use an empty `begin' form. It will yield #<unspecified>
2275when evaluated and simply be ignored in a definition context.
2276
3063e30a
DH
2277** Deprecated: procedure->macro
2278
b0d10ba6
MV
2279Change your code to use 'define-macro' or r5rs macros. Also, be aware
2280that macro expansion will not be done during evaluation, but prior to
2281evaluation.
3063e30a 2282
0a50eeaa
NJ
2283** Soft ports now allow a `char-ready?' procedure
2284
2285The vector argument to `make-soft-port' can now have a length of
2286either 5 or 6. (Previously the length had to be 5.) The optional 6th
2287element is interpreted as an `input-waiting' thunk -- i.e. a thunk
2288that returns the number of characters that can be read immediately
2289without the soft port blocking.
2290
63dd3413
DH
2291** Deprecated: undefine
2292
2293There is no replacement for undefine.
2294
9abd541e
NJ
2295** The functions make-keyword-from-dash-symbol and keyword-dash-symbol
2296 have been discouraged.
aef0bdb4
MV
2297
2298They are relics from a time where a keyword like #:foo was used
2299directly as a Tcl option "-foo" and thus keywords were internally
2300stored as a symbol with a starting dash. We now store a symbol
2301without the dash.
2302
2303Use symbol->keyword and keyword->symbol instead.
2304
9abd541e
NJ
2305** The `cheap' debug option is now obsolete
2306
2307Evaluator trap calls are now unconditionally "cheap" - in other words,
2308they pass a debug object to the trap handler rather than a full
2309continuation. The trap handler code can capture a full continuation
2310by using `call-with-current-continuation' in the usual way, if it so
2311desires.
2312
2313The `cheap' option is retained for now so as not to break existing
2314code which gets or sets it, but setting it now has no effect. It will
2315be removed in the next major Guile release.
2316
2317** Evaluator trap calls now support `tweaking'
2318
2319`Tweaking' means that the trap handler code can modify the Scheme
2320expression that is about to be evaluated (in the case of an
2321enter-frame trap) or the value that is being returned (in the case of
2322an exit-frame trap). The trap handler code indicates that it wants to
2323do this by returning a pair whose car is the symbol 'instead and whose
2324cdr is the modified expression or return value.
36a9b236 2325
b00418df
DH
2326* Changes to the C interface
2327
87bdbdbc
MV
2328** The functions scm_hash_fn_remove_x and scm_hashx_remove_x no longer
2329 take a 'delete' function argument.
2330
2331This argument makes no sense since the delete function is used to
2332remove a pair from an alist, and this must not be configurable.
2333
2334This is an incompatible change.
2335
1cf1bb95
MV
2336** The GH interface is now subject to the deprecation mechanism
2337
2338The GH interface has been deprecated for quite some time but now it is
2339actually removed from Guile when it is configured with
2340--disable-deprecated.
2341
2342See the manual "Transitioning away from GH" for more information.
2343
f7f3964e
MV
2344** A new family of functions for converting between C values and
2345 Scheme values has been added.
2346
2347These functions follow a common naming scheme and are designed to be
2348easier to use, thread-safe and more future-proof than the older
2349alternatives.
2350
2351 - int scm_is_* (...)
2352
2353 These are predicates that return a C boolean: 1 or 0. Instead of
2354 SCM_NFALSEP, you can now use scm_is_true, for example.
2355
2356 - <type> scm_to_<type> (SCM val, ...)
2357
2358 These are functions that convert a Scheme value into an appropriate
2359 C value. For example, you can use scm_to_int to safely convert from
2360 a SCM to an int.
2361
a2b6a0e7 2362 - SCM scm_from_<type> (<type> val, ...)
f7f3964e
MV
2363
2364 These functions convert from a C type to a SCM value; for example,
2365 scm_from_int for ints.
2366
2367There is a huge number of these functions, for numbers, strings,
2368symbols, vectors, etc. They are documented in the reference manual in
2369the API section together with the types that they apply to.
2370
96d8c217
MV
2371** New functions for dealing with complex numbers in C have been added.
2372
2373The new functions are scm_c_make_rectangular, scm_c_make_polar,
2374scm_c_real_part, scm_c_imag_part, scm_c_magnitude and scm_c_angle.
2375They work like scm_make_rectangular etc but take or return doubles
2376directly.
2377
2378** The function scm_make_complex has been discouraged.
2379
2380Use scm_c_make_rectangular instead.
2381
f7f3964e
MV
2382** The INUM macros have been deprecated.
2383
2384A lot of code uses these macros to do general integer conversions,
b0d10ba6
MV
2385although the macros only work correctly with fixnums. Use the
2386following alternatives.
f7f3964e
MV
2387
2388 SCM_INUMP -> scm_is_integer or similar
2389 SCM_NINUMP -> !scm_is_integer or similar
2390 SCM_MAKINUM -> scm_from_int or similar
2391 SCM_INUM -> scm_to_int or similar
2392
b0d10ba6 2393 SCM_VALIDATE_INUM_* -> Do not use these; scm_to_int, etc. will
f7f3964e
MV
2394 do the validating for you.
2395
f9656a9f
MV
2396** The scm_num2<type> and scm_<type>2num functions and scm_make_real
2397 have been discouraged.
f7f3964e
MV
2398
2399Use the newer scm_to_<type> and scm_from_<type> functions instead for
2400new code. The functions have been discouraged since they don't fit
2401the naming scheme.
2402
2403** The 'boolean' macros SCM_FALSEP etc have been discouraged.
2404
2405They have strange names, especially SCM_NFALSEP, and SCM_BOOLP
2406evaluates its argument twice. Use scm_is_true, etc. instead for new
2407code.
2408
2409** The macro SCM_EQ_P has been discouraged.
2410
2411Use scm_is_eq for new code, which fits better into the naming
2412conventions.
d5b203a6 2413
d5ac9b2a
MV
2414** The macros SCM_CONSP, SCM_NCONSP, SCM_NULLP, and SCM_NNULLP have
2415 been discouraged.
2416
2417Use the function scm_is_pair or scm_is_null instead.
2418
409eb4e5
MV
2419** The functions scm_round and scm_truncate have been deprecated and
2420 are now available as scm_c_round and scm_c_truncate, respectively.
2421
2422These functions occupy the names that scm_round_number and
2423scm_truncate_number should have.
2424
3ff9283d
MV
2425** The functions scm_c_string2str, scm_c_substring2str, and
2426 scm_c_symbol2str have been deprecated.
c41acab3
MV
2427
2428Use scm_to_locale_stringbuf or similar instead, maybe together with
2429scm_substring.
2430
3ff9283d
MV
2431** New functions scm_c_make_string, scm_c_string_length,
2432 scm_c_string_ref, scm_c_string_set_x, scm_c_substring,
2433 scm_c_substring_shared, scm_c_substring_copy.
2434
2435These are like scm_make_string, scm_length, etc. but are slightly
2436easier to use from C.
2437
2438** The macros SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_LENGTH,
2439 SCM_SYMBOL_CHARS, and SCM_SYMBOL_LENGTH have been deprecated.
2440
2441They export too many assumptions about the implementation of strings
2442and symbols that are no longer true in the presence of
b0d10ba6
MV
2443mutation-sharing substrings and when Guile switches to some form of
2444Unicode.
3ff9283d
MV
2445
2446When working with strings, it is often best to use the normal string
2447functions provided by Guile, such as scm_c_string_ref,
b0d10ba6
MV
2448scm_c_string_set_x, scm_string_append, etc. Be sure to look in the
2449manual since many more such functions are now provided than
2450previously.
3ff9283d
MV
2451
2452When you want to convert a SCM string to a C string, use the
2453scm_to_locale_string function or similar instead. For symbols, use
2454scm_symbol_to_string and then work with that string. Because of the
2455new string representation, scm_symbol_to_string does not need to copy
2456and is thus quite efficient.
2457
aef0bdb4 2458** Some string, symbol and keyword functions have been discouraged.
3ff9283d 2459
b0d10ba6 2460They don't fit into the uniform naming scheme and are not explicit
3ff9283d
MV
2461about the character encoding.
2462
2463Replace according to the following table:
2464
2465 scm_allocate_string -> scm_c_make_string
2466 scm_take_str -> scm_take_locale_stringn
2467 scm_take0str -> scm_take_locale_string
2468 scm_mem2string -> scm_from_locale_stringn
2469 scm_str2string -> scm_from_locale_string
2470 scm_makfrom0str -> scm_from_locale_string
2471 scm_mem2symbol -> scm_from_locale_symboln
b0d10ba6 2472 scm_mem2uninterned_symbol -> scm_from_locale_stringn + scm_make_symbol
3ff9283d
MV
2473 scm_str2symbol -> scm_from_locale_symbol
2474
2475 SCM_SYMBOL_HASH -> scm_hashq
2476 SCM_SYMBOL_INTERNED_P -> scm_symbol_interned_p
2477
aef0bdb4
MV
2478 scm_c_make_keyword -> scm_from_locale_keyword
2479
2480** The functions scm_keyword_to_symbol and sym_symbol_to_keyword are
2481 now also available to C code.
2482
2483** SCM_KEYWORDP and SCM_KEYWORDSYM have been deprecated.
2484
2485Use scm_is_keyword and scm_keyword_to_symbol instead, but note that
2486the latter returns the true name of the keyword, not the 'dash name',
2487as SCM_KEYWORDSYM used to do.
2488
dc91d8de
MV
2489** A new way to access arrays in a thread-safe and efficient way has
2490 been added.
2491
2492See the manual, node "Accessing Arrays From C".
2493
3167d5e4
MV
2494** The old uniform vector and bitvector implementations have been
2495 unceremoniously removed.
d4ea47c8 2496
a558cc63 2497This implementation exposed the details of the tagging system of
d4ea47c8 2498Guile. Use the new C API explained in the manual in node "Uniform
c34e5780 2499Numeric Vectors" and "Bit Vectors", respectively.
d4ea47c8
MV
2500
2501The following macros are gone: SCM_UVECTOR_BASE, SCM_SET_UVECTOR_BASE,
2502SCM_UVECTOR_MAXLENGTH, SCM_UVECTOR_LENGTH, SCM_MAKE_UVECTOR_TAG,
3167d5e4
MV
2503SCM_SET_UVECTOR_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
2504SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
2505SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
0b63c1ee
MV
2506SCM_SET_BITVECTOR_LENGTH, SCM_BITVEC_REF, SCM_BITVEC_SET,
2507SCM_BITVEC_CLR.
d4ea47c8 2508
c34e5780
MV
2509** The macros dealing with vectors have been deprecated.
2510
2511Use the new functions scm_is_vector, scm_vector_elements,
0b63c1ee
MV
2512scm_vector_writable_elements, etc, or scm_is_simple_vector,
2513SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, etc instead. See the
2514manual for more details.
c34e5780
MV
2515
2516Deprecated are SCM_VECTORP, SCM_VELTS, SCM_VECTOR_MAX_LENGTH,
2517SCM_VECTOR_LENGTH, SCM_VECTOR_REF, SCM_VECTOR_SET, SCM_WRITABLE_VELTS.
2518
2519The following macros have been removed: SCM_VECTOR_BASE,
2520SCM_SET_VECTOR_BASE, SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH,
2521SCM_VELTS_AS_STACKITEMS, SCM_SETVELTS, SCM_GC_WRITABLE_VELTS.
2522
0c7a5cab 2523** Some C functions and macros related to arrays have been deprecated.
dc91d8de
MV
2524
2525Migrate according to the following table:
2526
e94d0be2 2527 scm_make_uve -> scm_make_typed_array, scm_make_u8vector etc.
dc91d8de
MV
2528 scm_make_ra -> scm_make_array
2529 scm_shap2ra -> scm_make_array
2530 scm_cvref -> scm_c_generalized_vector_ref
2531 scm_ra_set_contp -> do not use
2532 scm_aind -> scm_array_handle_pos
2533 scm_raprin1 -> scm_display or scm_write
2534
0c7a5cab
MV
2535 SCM_ARRAYP -> scm_is_array
2536 SCM_ARRAY_NDIM -> scm_c_array_rank
2537 SCM_ARRAY_DIMS -> scm_array_handle_dims
2538 SCM_ARRAY_CONTP -> do not use
2539 SCM_ARRAY_MEM -> do not use
2540 SCM_ARRAY_V -> scm_array_handle_elements or similar
2541 SCM_ARRAY_BASE -> do not use
2542
c1e7caf7
MV
2543** SCM_CELL_WORD_LOC has been deprecated.
2544
b0d10ba6 2545Use the new macro SCM_CELL_OBJECT_LOC instead, which returns a pointer
c1e7caf7
MV
2546to a SCM, as opposed to a pointer to a scm_t_bits.
2547
2548This was done to allow the correct use of pointers into the Scheme
2549heap. Previously, the heap words were of type scm_t_bits and local
2550variables and function arguments were of type SCM, making it
2551non-standards-conformant to have a pointer that can point to both.
2552
3ff9283d 2553** New macros SCM_SMOB_DATA_2, SCM_SMOB_DATA_3, etc.
27968825
MV
2554
2555These macros should be used instead of SCM_CELL_WORD_2/3 to access the
2556second and third words of double smobs. Likewise for
2557SCM_SET_SMOB_DATA_2 and SCM_SET_SMOB_DATA_3.
2558
2559Also, there is SCM_SMOB_FLAGS and SCM_SET_SMOB_FLAGS that should be
2560used to get and set the 16 exra bits in the zeroth word of a smob.
2561
2562And finally, there is SCM_SMOB_OBJECT and SCM_SMOB_SET_OBJECT for
2563accesing the first immediate word of a smob as a SCM value, and there
2564is SCM_SMOB_OBJECT_LOC for getting a pointer to the first immediate
b0d10ba6 2565smob word. Like wise for SCM_SMOB_OBJECT_2, etc.
27968825 2566
b0d10ba6 2567** New way to deal with non-local exits and re-entries.
9879d390
MV
2568
2569There is a new set of functions that essentially do what
fc6bb283
MV
2570scm_internal_dynamic_wind does, but in a way that is more convenient
2571for C code in some situations. Here is a quick example of how to
2572prevent a potential memory leak:
9879d390
MV
2573
2574 void
2575 foo ()
2576 {
2577 char *mem;
2578
661ae7ab 2579 scm_dynwind_begin (0);
9879d390
MV
2580
2581 mem = scm_malloc (100);
661ae7ab 2582 scm_dynwind_unwind_handler (free, mem, SCM_F_WIND_EXPLICITLY);
f1da8e4e
MV
2583
2584 /* MEM would leak if BAR throws an error.
661ae7ab 2585 SCM_DYNWIND_UNWIND_HANDLER frees it nevertheless.
c41acab3 2586 */
9879d390 2587
9879d390
MV
2588 bar ();
2589
661ae7ab 2590 scm_dynwind_end ();
9879d390 2591
e299cee2 2592 /* Because of SCM_F_WIND_EXPLICITLY, MEM will be freed by
661ae7ab 2593 SCM_DYNWIND_END as well.
9879d390
MV
2594 */
2595 }
2596
661ae7ab 2597For full documentation, see the node "Dynamic Wind" in the manual.
9879d390 2598
661ae7ab 2599** New function scm_dynwind_free
c41acab3 2600
661ae7ab
MV
2601This function calls 'free' on a given pointer when a dynwind context
2602is left. Thus the call to scm_dynwind_unwind_handler above could be
2603replaced with simply scm_dynwind_free (mem).
c41acab3 2604
a6d75e53
MV
2605** New functions scm_c_call_with_blocked_asyncs and
2606 scm_c_call_with_unblocked_asyncs
2607
2608Like scm_call_with_blocked_asyncs etc. but for C functions.
2609
661ae7ab 2610** New functions scm_dynwind_block_asyncs and scm_dynwind_unblock_asyncs
49c00ecc
MV
2611
2612In addition to scm_c_call_with_blocked_asyncs you can now also use
661ae7ab
MV
2613scm_dynwind_block_asyncs in a 'dynwind context' (see above). Likewise for
2614scm_c_call_with_unblocked_asyncs and scm_dynwind_unblock_asyncs.
49c00ecc 2615
a558cc63
MV
2616** The macros SCM_DEFER_INTS, SCM_ALLOW_INTS, SCM_REDEFER_INTS,
2617 SCM_REALLOW_INTS have been deprecated.
2618
2619They do no longer fulfill their original role of blocking signal
2620delivery. Depending on what you want to achieve, replace a pair of
661ae7ab
MV
2621SCM_DEFER_INTS and SCM_ALLOW_INTS with a dynwind context that locks a
2622mutex, blocks asyncs, or both. See node "Critical Sections" in the
2623manual.
a6d75e53
MV
2624
2625** The value 'scm_mask_ints' is no longer writable.
2626
2627Previously, you could set scm_mask_ints directly. This is no longer
2628possible. Use scm_c_call_with_blocked_asyncs and
2629scm_c_call_with_unblocked_asyncs instead.
a558cc63 2630
49c00ecc
MV
2631** New way to temporarily set the current input, output or error ports
2632
661ae7ab 2633C code can now use scm_dynwind_current_<foo>_port in a 'dynwind
0f24e75b 2634context' (see above). <foo> is one of "input", "output" or "error".
49c00ecc 2635
fc6bb283
MV
2636** New way to temporarily set fluids
2637
661ae7ab 2638C code can now use scm_dynwind_fluid in a 'dynwind context' (see
fc6bb283
MV
2639above) to temporarily set the value of a fluid.
2640
89fcf1b4
MV
2641** New types scm_t_intmax and scm_t_uintmax.
2642
2643On platforms that have them, these types are identical to intmax_t and
2644uintmax_t, respectively. On other platforms, they are identical to
2645the largest integer types that Guile knows about.
2646
b0d10ba6 2647** The functions scm_unmemocopy and scm_unmemoize have been removed.
9fcf3cbb 2648
b0d10ba6 2649You should not have used them.
9fcf3cbb 2650
5ebbe4ef
RB
2651** Many public #defines with generic names have been made private.
2652
2653#defines with generic names like HAVE_FOO or SIZEOF_FOO have been made
b0d10ba6 2654private or renamed with a more suitable public name.
f03314f9
DH
2655
2656** The macro SCM_TYP16S has been deprecated.
2657
b0d10ba6 2658This macro is not intended for public use.
f03314f9 2659
0d5e3480
DH
2660** The macro SCM_SLOPPY_INEXACTP has been deprecated.
2661
b0d10ba6 2662Use scm_is_true (scm_inexact_p (...)) instead.
0d5e3480
DH
2663
2664** The macro SCM_SLOPPY_REALP has been deprecated.
2665
b0d10ba6 2666Use scm_is_real instead.
0d5e3480
DH
2667
2668** The macro SCM_SLOPPY_COMPLEXP has been deprecated.
2669
b0d10ba6 2670Use scm_is_complex instead.
5ebbe4ef 2671
b0d10ba6 2672** Some preprocessor defines have been deprecated.
5ebbe4ef 2673
b0d10ba6
MV
2674These defines indicated whether a certain feature was present in Guile
2675or not. Going forward, assume that the features are always present.
5ebbe4ef 2676
b0d10ba6
MV
2677The macros are: USE_THREADS, GUILE_ISELECT, READER_EXTENSIONS,
2678DEBUG_EXTENSIONS, DYNAMIC_LINKING.
5ebbe4ef 2679
b0d10ba6
MV
2680The following macros have been removed completely: MEMOIZE_LOCALS,
2681SCM_RECKLESS, SCM_CAUTIOUS.
5ebbe4ef
RB
2682
2683** The preprocessor define STACK_DIRECTION has been deprecated.
2684
2685There should be no need to know about the stack direction for ordinary
b0d10ba6 2686programs.
5ebbe4ef 2687
b2cbe8d8
RB
2688** New function: scm_effective_version
2689
2690Returns the "effective" version number. This is just the normal full
2691version string without the final micro-version number. See "Changes
2692to the distribution" above.
2693
2902a459
MV
2694** The function scm_call_with_new_thread has a new prototype.
2695
2696Instead of taking a list with the thunk and handler, these two
2697arguments are now passed directly:
2698
2699 SCM scm_call_with_new_thread (SCM thunk, SCM handler);
2700
2701This is an incompatible change.
2702
ffd0ef3b
MV
2703** New snarfer macro SCM_DEFINE_PUBLIC.
2704
2705This is like SCM_DEFINE, but also calls scm_c_export for the defined
2706function in the init section.
2707
8734ce02
MV
2708** The snarfer macro SCM_SNARF_INIT is now officially supported.
2709
39e8f371
HWN
2710** Garbage collector rewrite.
2711
2712The garbage collector is cleaned up a lot, and now uses lazy
2713sweeping. This is reflected in the output of (gc-stats); since cells
2714are being freed when they are allocated, the cells-allocated field
2715stays roughly constant.
2716
2717For malloc related triggers, the behavior is changed. It uses the same
2718heuristic as the cell-triggered collections. It may be tuned with the
2719environment variables GUILE_MIN_YIELD_MALLOC. This is the percentage
2720for minimum yield of malloc related triggers. The default is 40.
2721GUILE_INIT_MALLOC_LIMIT sets the initial trigger for doing a GC. The
2722default is 200 kb.
2723
2724Debugging operations for the freelist have been deprecated, along with
2725the C variables that control garbage collection. The environment
2726variables GUILE_MAX_SEGMENT_SIZE, GUILE_INIT_SEGMENT_SIZE_2,
2727GUILE_INIT_SEGMENT_SIZE_1, and GUILE_MIN_YIELD_2 should be used.
2728
1367aa5e
HWN
2729For understanding the memory usage of a GUILE program, the routine
2730gc-live-object-stats returns an alist containing the number of live
2731objects for every type.
2732
2733
5ec1d2c8
DH
2734** The function scm_definedp has been renamed to scm_defined_p
2735
2736The name scm_definedp is deprecated.
2737
b0d10ba6 2738** The struct scm_cell type has been renamed to scm_t_cell
228a24ef
DH
2739
2740This is in accordance to Guile's naming scheme for types. Note that
2741the name scm_cell is now used for a function that allocates and
2742initializes a new cell (see below).
2743
0906625f
MV
2744** New functions for memory management
2745
2746A new set of functions for memory management has been added since the
2747old way (scm_must_malloc, scm_must_free, etc) was error prone and
2748indeed, Guile itself contained some long standing bugs that could
2749cause aborts in long running programs.
2750
2751The new functions are more symmetrical and do not need cooperation
2752from smob free routines, among other improvements.
2753
eab1b259
HWN
2754The new functions are scm_malloc, scm_realloc, scm_calloc, scm_strdup,
2755scm_strndup, scm_gc_malloc, scm_gc_calloc, scm_gc_realloc,
2756scm_gc_free, scm_gc_register_collectable_memory, and
0906625f
MV
2757scm_gc_unregister_collectable_memory. Refer to the manual for more
2758details and for upgrading instructions.
2759
2760The old functions for memory management have been deprecated. They
2761are: scm_must_malloc, scm_must_realloc, scm_must_free,
2762scm_must_strdup, scm_must_strndup, scm_done_malloc, scm_done_free.
2763
4aa104a4
MV
2764** Declarations of exported features are marked with SCM_API.
2765
2766Every declaration of a feature that belongs to the exported Guile API
2767has been marked by adding the macro "SCM_API" to the start of the
2768declaration. This macro can expand into different things, the most
2769common of which is just "extern" for Unix platforms. On Win32, it can
2770be used to control which symbols are exported from a DLL.
2771
8f99e3f3 2772If you `#define SCM_IMPORT' before including <libguile.h>, SCM_API
4aa104a4
MV
2773will expand into "__declspec (dllimport) extern", which is needed for
2774linking to the Guile DLL in Windows.
2775
b0d10ba6 2776There are also SCM_RL_IMPORT, SCM_SRFI1314_IMPORT, and
8f99e3f3 2777SCM_SRFI4_IMPORT, for the corresponding libraries.
4aa104a4 2778
a9930d22
MV
2779** SCM_NEWCELL and SCM_NEWCELL2 have been deprecated.
2780
b0d10ba6
MV
2781Use the new functions scm_cell and scm_double_cell instead. The old
2782macros had problems because with them allocation and initialization
2783was separated and the GC could sometimes observe half initialized
2784cells. Only careful coding by the user of SCM_NEWCELL and
2785SCM_NEWCELL2 could make this safe and efficient.
a9930d22 2786
5132eef0
DH
2787** CHECK_ENTRY, CHECK_APPLY and CHECK_EXIT have been deprecated.
2788
2789Use the variables scm_check_entry_p, scm_check_apply_p and scm_check_exit_p
2790instead.
2791
bc76d628
DH
2792** SRCBRKP has been deprecated.
2793
2794Use scm_c_source_property_breakpoint_p instead.
2795
3063e30a
DH
2796** Deprecated: scm_makmacro
2797
b0d10ba6
MV
2798Change your code to use either scm_makmmacro or to define macros in
2799Scheme, using 'define-macro'.
1e5f92ce 2800
1a61d41b
MV
2801** New function scm_c_port_for_each.
2802
2803This function is like scm_port_for_each but takes a pointer to a C
2804function as the callback instead of a SCM value.
2805
1f834c95
MV
2806** The names scm_internal_select, scm_thread_sleep, and
2807 scm_thread_usleep have been discouraged.
2808
2809Use scm_std_select, scm_std_sleep, scm_std_usleep instead.
2810
aa9200e5
MV
2811** The GC can no longer be blocked.
2812
2813The global flags scm_gc_heap_lock and scm_block_gc have been removed.
2814The GC can now run (partially) concurrently with other code and thus
2815blocking it is not well defined.
2816
b0d10ba6
MV
2817** Many definitions have been removed that were previously deprecated.
2818
2819scm_lisp_nil, scm_lisp_t, s_nil_ify, scm_m_nil_ify, s_t_ify,
2820scm_m_t_ify, s_0_cond, scm_m_0_cond, s_0_ify, scm_m_0_ify, s_1_ify,
2821scm_m_1_ify, scm_debug_newcell, scm_debug_newcell2,
2822scm_tc16_allocated, SCM_SET_SYMBOL_HASH, SCM_IM_NIL_IFY, SCM_IM_T_IFY,
2823SCM_IM_0_COND, SCM_IM_0_IFY, SCM_IM_1_IFY, SCM_GC_SET_ALLOCATED,
2824scm_debug_newcell, scm_debug_newcell2, SCM_HUP_SIGNAL, SCM_INT_SIGNAL,
2825SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL, SCM_ALRM_SIGNAL,
2826SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD, SCM_ORD_SIG,
2827SCM_NUM_SIGS, scm_top_level_lookup_closure_var,
2828*top-level-lookup-closure*, scm_system_transformer, scm_eval_3,
2829scm_eval2, root_module_lookup_closure, SCM_SLOPPY_STRINGP,
2830SCM_RWSTRINGP, scm_read_only_string_p, scm_make_shared_substring,
2831scm_tc7_substring, sym_huh, SCM_VARVCELL, SCM_UDVARIABLEP,
2832SCM_DEFVARIABLEP, scm_mkbig, scm_big2inum, scm_adjbig, scm_normbig,
2833scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl, SCM_FIXNUM_BIT,
2834SCM_SETCHARS, SCM_SLOPPY_SUBSTRP, SCM_SUBSTR_STR, SCM_SUBSTR_OFFSET,
2835SCM_LENGTH_MAX, SCM_SETLENGTH, SCM_ROSTRINGP, SCM_ROLENGTH,
2836SCM_ROCHARS, SCM_ROUCHARS, SCM_SUBSTRP, SCM_COERCE_SUBSTR,
2837scm_sym2vcell, scm_intern, scm_intern0, scm_sysintern, scm_sysintern0,
66c8ded2 2838scm_sysintern0_no_module_lookup, scm_init_symbols_deprecated,
2109da78 2839scm_vector_set_length_x, scm_contregs, scm_debug_info,
983e697d
MV
2840scm_debug_frame, SCM_DSIDEVAL, SCM_CONST_LONG, SCM_VCELL,
2841SCM_GLOBAL_VCELL, SCM_VCELL_INIT, SCM_GLOBAL_VCELL_INIT,
2842SCM_HUGE_LENGTH, SCM_VALIDATE_STRINGORSUBSTR, SCM_VALIDATE_ROSTRING,
2843SCM_VALIDATE_ROSTRING_COPY, SCM_VALIDATE_NULLORROSTRING_COPY,
2844SCM_VALIDATE_RWSTRING, DIGITS, scm_small_istr2int, scm_istr2int,
2109da78
MV
2845scm_istr2flo, scm_istring2number, scm_istr2int, scm_istr2flo,
2846scm_istring2number, scm_vtable_index_vcell, scm_si_vcell, SCM_ECONSP,
2847SCM_NECONSP, SCM_GLOC_VAR, SCM_GLOC_VAL, SCM_GLOC_SET_VAL,
c41acab3
MV
2848SCM_GLOC_VAL_LOC, scm_make_gloc, scm_gloc_p, scm_tc16_variable,
2849SCM_CHARS, SCM_LENGTH, SCM_SET_STRING_CHARS, SCM_SET_STRING_LENGTH.
b51bad08 2850
09172f9c
NJ
2851* Changes to bundled modules
2852
2853** (ice-9 debug)
2854
2855Using the (ice-9 debug) module no longer automatically switches Guile
2856to use the debugging evaluator. If you want to switch to the
2857debugging evaluator (which is needed for backtrace information if you
2858hit an error), please add an explicit "(debug-enable 'debug)" to your
2859code just after the code to use (ice-9 debug).
2860
328dc9a3 2861\f
c299f186
MD
2862Changes since Guile 1.4:
2863
2864* Changes to the distribution
2865
32d6f999
TTN
2866** A top-level TODO file is included.
2867
311b6a3c 2868** Guile now uses a versioning scheme similar to that of the Linux kernel.
c81ea65d
RB
2869
2870Guile now always uses three numbers to represent the version,
2871i.e. "1.6.5". The first number, 1, is the major version number, the
2872second number, 6, is the minor version number, and the third number,
28735, is the micro version number. Changes in major version number
2874indicate major changes in Guile.
2875
2876Minor version numbers that are even denote stable releases, and odd
2877minor version numbers denote development versions (which may be
2878unstable). The micro version number indicates a minor sub-revision of
2879a given MAJOR.MINOR release.
2880
2881In keeping with the new scheme, (minor-version) and scm_minor_version
2882no longer return everything but the major version number. They now
2883just return the minor version number. Two new functions
2884(micro-version) and scm_micro_version have been added to report the
2885micro version number.
2886
2887In addition, ./GUILE-VERSION now defines GUILE_MICRO_VERSION.
2888
5c790b44
RB
2889** New preprocessor definitions are available for checking versions.
2890
2891version.h now #defines SCM_MAJOR_VERSION, SCM_MINOR_VERSION, and
2892SCM_MICRO_VERSION to the appropriate integer values.
2893
311b6a3c
MV
2894** Guile now actively warns about deprecated features.
2895
2896The new configure option `--enable-deprecated=LEVEL' and the
2897environment variable GUILE_WARN_DEPRECATED control this mechanism.
2898See INSTALL and README for more information.
2899
0b073f0f
RB
2900** Guile is much more likely to work on 64-bit architectures.
2901
2902Guile now compiles and passes "make check" with only two UNRESOLVED GC
5e137c65
RB
2903cases on Alpha and ia64 based machines now. Thanks to John Goerzen
2904for the use of a test machine, and thanks to Stefan Jahn for ia64
2905patches.
0b073f0f 2906
e658215a
RB
2907** New functions: setitimer and getitimer.
2908
2909These implement a fairly direct interface to the libc functions of the
2910same name.
2911
8630fdfc
RB
2912** The #. reader extension is now disabled by default.
2913
2914For safety reasons, #. evaluation is disabled by default. To
2915re-enable it, set the fluid read-eval? to #t. For example:
2916
67b7dd9e 2917 (fluid-set! read-eval? #t)
8630fdfc
RB
2918
2919but make sure you realize the potential security risks involved. With
2920read-eval? enabled, reading a data file from an untrusted source can
2921be dangerous.
2922
f2a75d81 2923** New SRFI modules have been added:
4df36934 2924
dfdf5826
MG
2925SRFI-0 `cond-expand' is now supported in Guile, without requiring
2926using a module.
2927
e8bb0476
MG
2928(srfi srfi-1) is a library containing many useful pair- and list-processing
2929 procedures.
2930
7adc2c58 2931(srfi srfi-2) exports and-let*.
4df36934 2932
b74a7ec8
MG
2933(srfi srfi-4) implements homogeneous numeric vector datatypes.
2934
7adc2c58
RB
2935(srfi srfi-6) is a dummy module for now, since guile already provides
2936 all of the srfi-6 procedures by default: open-input-string,
2937 open-output-string, get-output-string.
4df36934 2938
7adc2c58 2939(srfi srfi-8) exports receive.
4df36934 2940
7adc2c58 2941(srfi srfi-9) exports define-record-type.
4df36934 2942
dfdf5826
MG
2943(srfi srfi-10) exports define-reader-ctor and implements the reader
2944 extension #,().
2945
7adc2c58 2946(srfi srfi-11) exports let-values and let*-values.
4df36934 2947
7adc2c58 2948(srfi srfi-13) implements the SRFI String Library.
53e29a1e 2949
7adc2c58 2950(srfi srfi-14) implements the SRFI Character-Set Library.
53e29a1e 2951
dfdf5826
MG
2952(srfi srfi-17) implements setter and getter-with-setter and redefines
2953 some accessor procedures as procedures with getters. (such as car,
2954 cdr, vector-ref etc.)
2955
2956(srfi srfi-19) implements the SRFI Time/Date Library.
2b60bc95 2957
466bb4b3
TTN
2958** New scripts / "executable modules"
2959
2960Subdirectory "scripts" contains Scheme modules that are packaged to
2961also be executable as scripts. At this time, these scripts are available:
2962
2963 display-commentary
2964 doc-snarf
2965 generate-autoload
2966 punify
58e5b910 2967 read-scheme-source
466bb4b3
TTN
2968 use2dot
2969
2970See README there for more info.
2971
54c17ccb
TTN
2972These scripts can be invoked from the shell with the new program
2973"guile-tools", which keeps track of installation directory for you.
2974For example:
2975
2976 $ guile-tools display-commentary srfi/*.scm
2977
2978guile-tools is copied to the standard $bindir on "make install".
2979
0109c4bf
MD
2980** New module (ice-9 stack-catch):
2981
2982stack-catch is like catch, but saves the current state of the stack in
3c1d1301
RB
2983the fluid the-last-stack. This fluid can be useful when using the
2984debugger and when re-throwing an error.
0109c4bf 2985
fbf0c8c7
MV
2986** The module (ice-9 and-let*) has been renamed to (ice-9 and-let-star)
2987
2988This has been done to prevent problems on lesser operating systems
2989that can't tolerate `*'s in file names. The exported macro continues
2990to be named `and-let*', of course.
2991
4f60cc33 2992On systems that support it, there is also a compatibility module named
fbf0c8c7 2993(ice-9 and-let*). It will go away in the next release.
6c0201ad 2994
9d774814 2995** New modules (oop goops) etc.:
14f1d9fe
MD
2996
2997 (oop goops)
2998 (oop goops describe)
2999 (oop goops save)
3000 (oop goops active-slot)
3001 (oop goops composite-slot)
3002
9d774814 3003The Guile Object Oriented Programming System (GOOPS) has been
311b6a3c
MV
3004integrated into Guile. For further information, consult the GOOPS
3005manual and tutorial in the `doc' directory.
14f1d9fe 3006
9d774814
GH
3007** New module (ice-9 rdelim).
3008
3009This exports the following procedures which were previously defined
1c8cbd62 3010in the default environment:
9d774814 3011
1c8cbd62
GH
3012read-line read-line! read-delimited read-delimited! %read-delimited!
3013%read-line write-line
9d774814 3014
1c8cbd62
GH
3015For backwards compatibility the definitions are still imported into the
3016default environment in this version of Guile. However you should add:
9d774814
GH
3017
3018(use-modules (ice-9 rdelim))
3019
1c8cbd62
GH
3020to any program which uses the definitions, since this may change in
3021future.
9d774814
GH
3022
3023Alternatively, if guile-scsh is installed, the (scsh rdelim) module
3024can be used for similar functionality.
3025
7e267da1
GH
3026** New module (ice-9 rw)
3027
3028This is a subset of the (scsh rw) module from guile-scsh. Currently
373f4948 3029it defines two procedures:
7e267da1 3030
311b6a3c 3031*** New function: read-string!/partial str [port_or_fdes [start [end]]]
7e267da1 3032
4bcdfe46
GH
3033 Read characters from a port or file descriptor into a string STR.
3034 A port must have an underlying file descriptor -- a so-called
3035 fport. This procedure is scsh-compatible and can efficiently read
311b6a3c 3036 large strings.
7e267da1 3037
4bcdfe46
GH
3038*** New function: write-string/partial str [port_or_fdes [start [end]]]
3039
3040 Write characters from a string STR to a port or file descriptor.
3041 A port must have an underlying file descriptor -- a so-called
3042 fport. This procedure is mostly compatible and can efficiently
3043 write large strings.
3044
e5005373
KN
3045** New module (ice-9 match)
3046
311b6a3c
MV
3047This module includes Andrew K. Wright's pattern matcher. See
3048ice-9/match.scm for brief description or
e5005373 3049
311b6a3c 3050 http://www.star-lab.com/wright/code.html
e5005373 3051
311b6a3c 3052for complete documentation.
e5005373 3053
4f60cc33
NJ
3054** New module (ice-9 buffered-input)
3055
3056This module provides procedures to construct an input port from an
3057underlying source of input that reads and returns its input in chunks.
3058The underlying input source is a Scheme procedure, specified by the
3059caller, which the port invokes whenever it needs more input.
3060
3061This is useful when building an input port whose back end is Readline
3062or a UI element such as the GtkEntry widget.
3063
3064** Documentation
3065
3066The reference and tutorial documentation that was previously
3067distributed separately, as `guile-doc', is now included in the core
3068Guile distribution. The documentation consists of the following
3069manuals.
3070
3071- The Guile Tutorial (guile-tut.texi) contains a tutorial introduction
3072 to using Guile.
3073
3074- The Guile Reference Manual (guile.texi) contains (or is intended to
3075 contain) reference documentation on all aspects of Guile.
3076
3077- The GOOPS Manual (goops.texi) contains both tutorial-style and
3078 reference documentation for using GOOPS, Guile's Object Oriented
3079 Programming System.
3080
c3e62877
NJ
3081- The Revised^5 Report on the Algorithmic Language Scheme
3082 (r5rs.texi).
4f60cc33
NJ
3083
3084See the README file in the `doc' directory for more details.
3085
094a67bb
MV
3086** There are a couple of examples in the examples/ directory now.
3087
9d774814
GH
3088* Changes to the stand-alone interpreter
3089
e7e58018
MG
3090** New command line option `--use-srfi'
3091
3092Using this option, SRFI modules can be loaded on startup and be
3093available right from the beginning. This makes programming portable
3094Scheme programs easier.
3095
3096The option `--use-srfi' expects a comma-separated list of numbers,
3097each representing a SRFI number to be loaded into the interpreter
3098before starting evaluating a script file or the REPL. Additionally,
3099the feature identifier for the loaded SRFIs is recognized by
3100`cond-expand' when using this option.
3101
3102Example:
3103$ guile --use-srfi=8,13
3104guile> (receive (x z) (values 1 2) (+ 1 2))
31053
58e5b910 3106guile> (string-pad "bla" 20)
e7e58018
MG
3107" bla"
3108
094a67bb
MV
3109** Guile now always starts up in the `(guile-user)' module.
3110
6e9382f1 3111Previously, scripts executed via the `-s' option would run in the
094a67bb
MV
3112`(guile)' module and the repl would run in the `(guile-user)' module.
3113Now every user action takes place in the `(guile-user)' module by
3114default.
e7e58018 3115
c299f186
MD
3116* Changes to Scheme functions and syntax
3117
720e1c30
MV
3118** Character classifiers work for non-ASCII characters.
3119
3120The predicates `char-alphabetic?', `char-numeric?',
3121`char-whitespace?', `char-lower?', `char-upper?' and `char-is-both?'
3122no longer check whether their arguments are ASCII characters.
3123Previously, a character would only be considered alphabetic when it
3124was also ASCII, for example.
3125
311b6a3c
MV
3126** Previously deprecated Scheme functions have been removed:
3127
3128 tag - no replacement.
3129 fseek - replaced by seek.
3130 list* - replaced by cons*.
3131
3132** It's now possible to create modules with controlled environments
3133
3134Example:
3135
3136(use-modules (ice-9 safe))
3137(define m (make-safe-module))
3138;;; m will now be a module containing only a safe subset of R5RS
3139(eval '(+ 1 2) m) --> 3
3140(eval 'load m) --> ERROR: Unbound variable: load
3141
3142** Evaluation of "()", the empty list, is now an error.
8c2c9967
MV
3143
3144Previously, the expression "()" evaluated to the empty list. This has
3145been changed to signal a "missing expression" error. The correct way
3146to write the empty list as a literal constant is to use quote: "'()".
3147
311b6a3c
MV
3148** New concept of `Guile Extensions'.
3149
3150A Guile Extension is just a ordinary shared library that can be linked
3151at run-time. We found it advantageous to give this simple concept a
3152dedicated name to distinguish the issues related to shared libraries
3153from the issues related to the module system.
3154
3155*** New function: load-extension
3156
3157Executing (load-extension lib init) is mostly equivalent to
3158
3159 (dynamic-call init (dynamic-link lib))
3160
3161except when scm_register_extension has been called previously.
3162Whenever appropriate, you should use `load-extension' instead of
3163dynamic-link and dynamic-call.
3164
3165*** New C function: scm_c_register_extension
3166
3167This function registers a initialization function for use by
3168`load-extension'. Use it when you don't want specific extensions to
3169be loaded as shared libraries (for example on platforms that don't
3170support dynamic linking).
3171
8c2c9967
MV
3172** Auto-loading of compiled-code modules is deprecated.
3173
3174Guile used to be able to automatically find and link a shared
c10ecc4c 3175library to satisfy requests for a module. For example, the module
8c2c9967
MV
3176`(foo bar)' could be implemented by placing a shared library named
3177"foo/libbar.so" (or with a different extension) in a directory on the
3178load path of Guile.
3179
311b6a3c
MV
3180This has been found to be too tricky, and is no longer supported. The
3181shared libraries are now called "extensions". You should now write a
3182small Scheme file that calls `load-extension' to load the shared
e299cee2 3183library and initialize it explicitly.
8c2c9967
MV
3184
3185The shared libraries themselves should be installed in the usual
3186places for shared libraries, with names like "libguile-foo-bar".
3187
3188For example, place this into a file "foo/bar.scm"
3189
3190 (define-module (foo bar))
3191
311b6a3c
MV
3192 (load-extension "libguile-foo-bar" "foobar_init")
3193
3194** Backward incompatible change: eval EXP ENVIRONMENT-SPECIFIER
3195
3196`eval' is now R5RS, that is it takes two arguments.
3197The second argument is an environment specifier, i.e. either
3198
3199 (scheme-report-environment 5)
3200 (null-environment 5)
3201 (interaction-environment)
3202
3203or
8c2c9967 3204
311b6a3c 3205 any module.
8c2c9967 3206
6f76852b
MV
3207** The module system has been made more disciplined.
3208
311b6a3c
MV
3209The function `eval' will save and restore the current module around
3210the evaluation of the specified expression. While this expression is
3211evaluated, `(current-module)' will now return the right module, which
3212is the module specified as the second argument to `eval'.
6f76852b 3213
311b6a3c 3214A consequence of this change is that `eval' is not particularly
6f76852b
MV
3215useful when you want allow the evaluated code to change what module is
3216designated as the current module and have this change persist from one
3217call to `eval' to the next. The read-eval-print-loop is an example
3218where `eval' is now inadequate. To compensate, there is a new
3219function `primitive-eval' that does not take a module specifier and
3220that does not save/restore the current module. You should use this
3221function together with `set-current-module', `current-module', etc
3222when you want to have more control over the state that is carried from
3223one eval to the next.
3224
3225Additionally, it has been made sure that forms that are evaluated at
3226the top level are always evaluated with respect to the current module.
3227Previously, subforms of top-level forms such as `begin', `case',
3228etc. did not respect changes to the current module although these
3229subforms are at the top-level as well.
3230
311b6a3c 3231To prevent strange behavior, the forms `define-module',
6f76852b
MV
3232`use-modules', `use-syntax', and `export' have been restricted to only
3233work on the top level. The forms `define-public' and
3234`defmacro-public' only export the new binding on the top level. They
3235behave just like `define' and `defmacro', respectively, when they are
3236used in a lexical environment.
3237
0a892a2c
MV
3238Also, `export' will no longer silently re-export bindings imported
3239from a used module. It will emit a `deprecation' warning and will
3240cease to perform any re-export in the next version. If you actually
3241want to re-export bindings, use the new `re-export' in place of
3242`export'. The new `re-export' will not make copies of variables when
3243rexporting them, as `export' did wrongly.
3244
047dc3ae
TTN
3245** Module system now allows selection and renaming of imported bindings
3246
3247Previously, when using `use-modules' or the `#:use-module' clause in
3248the `define-module' form, all the bindings (association of symbols to
3249values) for imported modules were added to the "current module" on an
3250as-is basis. This has been changed to allow finer control through two
3251new facilities: selection and renaming.
3252
3253You can now select which of the imported module's bindings are to be
3254visible in the current module by using the `:select' clause. This
3255clause also can be used to rename individual bindings. For example:
3256
3257 ;; import all bindings no questions asked
3258 (use-modules (ice-9 common-list))
3259
3260 ;; import four bindings, renaming two of them;
3261 ;; the current module sees: every some zonk-y zonk-n
3262 (use-modules ((ice-9 common-list)
3263 :select (every some
3264 (remove-if . zonk-y)
3265 (remove-if-not . zonk-n))))
3266
3267You can also programmatically rename all selected bindings using the
3268`:renamer' clause, which specifies a proc that takes a symbol and
3269returns another symbol. Because it is common practice to use a prefix,
3270we now provide the convenience procedure `symbol-prefix-proc'. For
3271example:
3272
3273 ;; import four bindings, renaming two of them specifically,
3274 ;; and all four w/ prefix "CL:";
3275 ;; the current module sees: CL:every CL:some CL:zonk-y CL:zonk-n
3276 (use-modules ((ice-9 common-list)
3277 :select (every some
3278 (remove-if . zonk-y)
3279 (remove-if-not . zonk-n))
3280 :renamer (symbol-prefix-proc 'CL:)))
3281
3282 ;; import four bindings, renaming two of them specifically,
3283 ;; and all four by upcasing.
3284 ;; the current module sees: EVERY SOME ZONK-Y ZONK-N
3285 (define (upcase-symbol sym)
3286 (string->symbol (string-upcase (symbol->string sym))))
3287
3288 (use-modules ((ice-9 common-list)
3289 :select (every some
3290 (remove-if . zonk-y)
3291 (remove-if-not . zonk-n))
3292 :renamer upcase-symbol))
3293
3294Note that programmatic renaming is done *after* individual renaming.
3295Also, the above examples show `use-modules', but the same facilities are
3296available for the `#:use-module' clause of `define-module'.
3297
3298See manual for more info.
3299
b7d69200 3300** The semantics of guardians have changed.
56495472 3301
b7d69200 3302The changes are for the most part compatible. An important criterion
6c0201ad 3303was to keep the typical usage of guardians as simple as before, but to
c0a5d888 3304make the semantics safer and (as a result) more useful.
56495472 3305
c0a5d888 3306*** All objects returned from guardians are now properly alive.
56495472 3307
c0a5d888
ML
3308It is now guaranteed that any object referenced by an object returned
3309from a guardian is alive. It's now impossible for a guardian to
3310return a "contained" object before its "containing" object.
56495472
ML
3311
3312One incompatible (but probably not very important) change resulting
3313from this is that it is no longer possible to guard objects that
3314indirectly reference themselves (i.e. are parts of cycles). If you do
3315so accidentally, you'll get a warning.
3316
c0a5d888
ML
3317*** There are now two types of guardians: greedy and sharing.
3318
3319If you call (make-guardian #t) or just (make-guardian), you'll get a
3320greedy guardian, and for (make-guardian #f) a sharing guardian.
3321
3322Greedy guardians are the default because they are more "defensive".
3323You can only greedily guard an object once. If you guard an object
3324more than once, once in a greedy guardian and the rest of times in
3325sharing guardians, then it is guaranteed that the object won't be
3326returned from sharing guardians as long as it is greedily guarded
3327and/or alive.
3328
3329Guardians returned by calls to `make-guardian' can now take one more
3330optional parameter, which says whether to throw an error in case an
3331attempt is made to greedily guard an object that is already greedily
3332guarded. The default is true, i.e. throw an error. If the parameter
3333is false, the guardian invocation returns #t if guarding was
3334successful and #f if it wasn't.
3335
3336Also, since greedy guarding is, in effect, a side-effecting operation
3337on objects, a new function is introduced: `destroy-guardian!'.
3338Invoking this function on a guardian renders it unoperative and, if
3339the guardian is greedy, clears the "greedily guarded" property of the
3340objects that were guarded by it, thus undoing the side effect.
3341
3342Note that all this hair is hardly very important, since guardian
3343objects are usually permanent.
3344
311b6a3c
MV
3345** Continuations created by call-with-current-continuation now accept
3346any number of arguments, as required by R5RS.
818febc0 3347
c10ecc4c 3348** New function `issue-deprecation-warning'
56426fdb 3349
311b6a3c 3350This function is used to display the deprecation messages that are
c10ecc4c 3351controlled by GUILE_WARN_DEPRECATION as explained in the README.
56426fdb
KN
3352
3353 (define (id x)
c10ecc4c
MV
3354 (issue-deprecation-warning "`id' is deprecated. Use `identity' instead.")
3355 (identity x))
56426fdb
KN
3356
3357 guile> (id 1)
3358 ;; `id' is deprecated. Use `identity' instead.
3359 1
3360 guile> (id 1)
3361 1
3362
c10ecc4c
MV
3363** New syntax `begin-deprecated'
3364
3365When deprecated features are included (as determined by the configure
3366option --enable-deprecated), `begin-deprecated' is identical to
3367`begin'. When deprecated features are excluded, it always evaluates
3368to `#f', ignoring the body forms.
3369
17f367e0
MV
3370** New function `make-object-property'
3371
3372This function returns a new `procedure with setter' P that can be used
3373to attach a property to objects. When calling P as
3374
3375 (set! (P obj) val)
3376
3377where `obj' is any kind of object, it attaches `val' to `obj' in such
3378a way that it can be retrieved by calling P as
3379
3380 (P obj)
3381
3382This function will replace procedure properties, symbol properties and
3383source properties eventually.
3384
76ef92f3
MV
3385** Module (ice-9 optargs) now uses keywords instead of `#&'.
3386
3387Instead of #&optional, #&key, etc you should now use #:optional,
3388#:key, etc. Since #:optional is a keyword, you can write it as just
3389:optional when (read-set! keywords 'prefix) is active.
3390
3391The old reader syntax `#&' is still supported, but deprecated. It
3392will be removed in the next release.
3393
c0997079
MD
3394** New define-module option: pure
3395
3396Tells the module system not to include any bindings from the root
3397module.
3398
3399Example:
3400
3401(define-module (totally-empty-module)
3402 :pure)
3403
3404** New define-module option: export NAME1 ...
3405
3406Export names NAME1 ...
3407
3408This option is required if you want to be able to export bindings from
3409a module which doesn't import one of `define-public' or `export'.
3410
3411Example:
3412
311b6a3c
MV
3413 (define-module (foo)
3414 :pure
3415 :use-module (ice-9 r5rs)
3416 :export (bar))
69b5f65a 3417
311b6a3c 3418 ;;; Note that we're pure R5RS below this point!
69b5f65a 3419
311b6a3c
MV
3420 (define (bar)
3421 ...)
daa6ba18 3422
1f3908c4
KN
3423** New function: object->string OBJ
3424
3425Return a Scheme string obtained by printing a given object.
3426
eb5c0a2a
GH
3427** New function: port? X
3428
3429Returns a boolean indicating whether X is a port. Equivalent to
3430`(or (input-port? X) (output-port? X))'.
3431
efa40607
DH
3432** New function: file-port?
3433
3434Determines whether a given object is a port that is related to a file.
3435
34b56ec4
GH
3436** New function: port-for-each proc
3437
311b6a3c
MV
3438Apply PROC to each port in the Guile port table in turn. The return
3439value is unspecified. More specifically, PROC is applied exactly once
3440to every port that exists in the system at the time PORT-FOR-EACH is
3441invoked. Changes to the port table while PORT-FOR-EACH is running
3442have no effect as far as PORT-FOR-EACH is concerned.
34b56ec4
GH
3443
3444** New function: dup2 oldfd newfd
3445
3446A simple wrapper for the `dup2' system call. Copies the file
3447descriptor OLDFD to descriptor number NEWFD, replacing the
3448previous meaning of NEWFD. Both OLDFD and NEWFD must be integers.
3449Unlike for dup->fdes or primitive-move->fdes, no attempt is made
264e9cbc 3450to move away ports which are using NEWFD. The return value is
34b56ec4
GH
3451unspecified.
3452
3453** New function: close-fdes fd
3454
3455A simple wrapper for the `close' system call. Close file
3456descriptor FD, which must be an integer. Unlike close (*note
3457close: Ports and File Descriptors.), the file descriptor will be
3458closed even if a port is using it. The return value is
3459unspecified.
3460
94e6d793
MG
3461** New function: crypt password salt
3462
3463Encrypts `password' using the standard unix password encryption
3464algorithm.
3465
3466** New function: chroot path
3467
3468Change the root directory of the running process to `path'.
3469
3470** New functions: getlogin, cuserid
3471
3472Return the login name or the user name of the current effective user
3473id, respectively.
3474
3475** New functions: getpriority which who, setpriority which who prio
3476
3477Get or set the priority of the running process.
3478
3479** New function: getpass prompt
3480
3481Read a password from the terminal, first displaying `prompt' and
3482disabling echoing.
3483
3484** New function: flock file operation
3485
3486Set/remove an advisory shared or exclusive lock on `file'.
3487
3488** New functions: sethostname name, gethostname
3489
3490Set or get the hostname of the machine the current process is running
3491on.
3492
6d163216 3493** New function: mkstemp! tmpl
4f60cc33 3494
6d163216
GH
3495mkstemp creates a new unique file in the file system and returns a
3496new buffered port open for reading and writing to the file. TMPL
3497is a string specifying where the file should be created: it must
3498end with `XXXXXX' and will be changed in place to return the name
3499of the temporary file.
3500
62e63ba9
MG
3501** New function: open-input-string string
3502
3503Return an input string port which delivers the characters from
4f60cc33 3504`string'. This procedure, together with `open-output-string' and
62e63ba9
MG
3505`get-output-string' implements SRFI-6.
3506
3507** New function: open-output-string
3508
3509Return an output string port which collects all data written to it.
3510The data can then be retrieved by `get-output-string'.
3511
3512** New function: get-output-string
3513
3514Return the contents of an output string port.
3515
56426fdb
KN
3516** New function: identity
3517
3518Return the argument.
3519
5bef627d
GH
3520** socket, connect, accept etc., now have support for IPv6. IPv6 addresses
3521 are represented in Scheme as integers with normal host byte ordering.
3522
3523** New function: inet-pton family address
3524
311b6a3c
MV
3525Convert a printable string network address into an integer. Note that
3526unlike the C version of this function, the result is an integer with
3527normal host byte ordering. FAMILY can be `AF_INET' or `AF_INET6'.
3528e.g.,
3529
3530 (inet-pton AF_INET "127.0.0.1") => 2130706433
3531 (inet-pton AF_INET6 "::1") => 1
5bef627d
GH
3532
3533** New function: inet-ntop family address
3534
311b6a3c
MV
3535Convert an integer network address into a printable string. Note that
3536unlike the C version of this function, the input is an integer with
3537normal host byte ordering. FAMILY can be `AF_INET' or `AF_INET6'.
3538e.g.,
3539
3540 (inet-ntop AF_INET 2130706433) => "127.0.0.1"
3541 (inet-ntop AF_INET6 (- (expt 2 128) 1)) =>
5bef627d
GH
3542 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
3543
56426fdb
KN
3544** Deprecated: id
3545
3546Use `identity' instead.
3547
5cd06d5e
DH
3548** Deprecated: -1+
3549
3550Use `1-' instead.
3551
3552** Deprecated: return-it
3553
311b6a3c 3554Do without it.
5cd06d5e
DH
3555
3556** Deprecated: string-character-length
3557
3558Use `string-length' instead.
3559
3560** Deprecated: flags
3561
3562Use `logior' instead.
3563
4f60cc33
NJ
3564** Deprecated: close-all-ports-except.
3565
3566This was intended for closing ports in a child process after a fork,
3567but it has the undesirable side effect of flushing buffers.
3568port-for-each is more flexible.
34b56ec4
GH
3569
3570** The (ice-9 popen) module now attempts to set up file descriptors in
3571the child process from the current Scheme ports, instead of using the
3572current values of file descriptors 0, 1, and 2 in the parent process.
3573
b52e071b
DH
3574** Removed function: builtin-weak-bindings
3575
3576There is no such concept as a weak binding any more.
3577
9d774814 3578** Removed constants: bignum-radix, scm-line-incrementors
0f979f3f 3579
7d435120
MD
3580** define-method: New syntax mandatory.
3581
3582The new method syntax is now mandatory:
3583
3584(define-method (NAME ARG-SPEC ...) BODY ...)
3585(define-method (NAME ARG-SPEC ... . REST-ARG) BODY ...)
3586
3587 ARG-SPEC ::= ARG-NAME | (ARG-NAME TYPE)
3588 REST-ARG ::= ARG-NAME
3589
3590If you have old code using the old syntax, import
3591(oop goops old-define-method) before (oop goops) as in:
3592
3593 (use-modules (oop goops old-define-method) (oop goops))
3594
f3f9dcbc
MV
3595** Deprecated function: builtin-variable
3596 Removed function: builtin-bindings
3597
3598There is no longer a distinction between builtin or other variables.
3599Use module system operations for all variables.
3600
311b6a3c
MV
3601** Lazy-catch handlers are no longer allowed to return.
3602
3603That is, a call to `throw', `error', etc is now guaranteed to not
3604return.
3605
a583bf1e 3606** Bugfixes for (ice-9 getopt-long)
8c84b81e 3607
a583bf1e
TTN
3608This module is now tested using test-suite/tests/getopt-long.test.
3609The following bugs have been fixed:
3610
3611*** Parsing for options that are specified to have `optional' args now checks
3612if the next element is an option instead of unconditionally taking it as the
8c84b81e
TTN
3613option arg.
3614
a583bf1e
TTN
3615*** An error is now thrown for `--opt=val' when the option description
3616does not specify `(value #t)' or `(value optional)'. This condition used to
3617be accepted w/o error, contrary to the documentation.
3618
3619*** The error message for unrecognized options is now more informative.
3620It used to be "not a record", an artifact of the implementation.
3621
3622*** The error message for `--opt' terminating the arg list (no value), when
3623`(value #t)' is specified, is now more informative. It used to be "not enough
3624args".
3625
3626*** "Clumped" single-char args now preserve trailing string, use it as arg.
3627The expansion used to be like so:
3628
3629 ("-abc5d" "--xyz") => ("-a" "-b" "-c" "--xyz")
3630
3631Note that the "5d" is dropped. Now it is like so:
3632
3633 ("-abc5d" "--xyz") => ("-a" "-b" "-c" "5d" "--xyz")
3634
3635This enables single-char options to have adjoining arguments as long as their
3636constituent characters are not potential single-char options.
8c84b81e 3637
998bfc70
TTN
3638** (ice-9 session) procedure `arity' now works with (ice-9 optargs) `lambda*'
3639
3640The `lambda*' and derivative forms in (ice-9 optargs) now set a procedure
3641property `arglist', which can be retrieved by `arity'. The result is that
3642`arity' can give more detailed information than before:
3643
3644Before:
3645
3646 guile> (use-modules (ice-9 optargs))
3647 guile> (define* (foo #:optional a b c) a)
3648 guile> (arity foo)
3649 0 or more arguments in `lambda*:G0'.
3650
3651After:
3652
3653 guile> (arity foo)
3654 3 optional arguments: `a', `b' and `c'.
3655 guile> (define* (bar a b #:key c d #:allow-other-keys) a)
3656 guile> (arity bar)
3657 2 required arguments: `a' and `b', 2 keyword arguments: `c'
3658 and `d', other keywords allowed.
3659 guile> (define* (baz a b #:optional c #:rest r) a)
3660 guile> (arity baz)
3661 2 required arguments: `a' and `b', 1 optional argument: `c',
3662 the rest in `r'.
3663
311b6a3c
MV
3664* Changes to the C interface
3665
c81c130e
MV
3666** Types have been renamed from scm_*_t to scm_t_*.
3667
3668This has been done for POSIX sake. It reserves identifiers ending
3669with "_t". What a concept.
3670
3671The old names are still available with status `deprecated'.
3672
3673** scm_t_bits (former scm_bits_t) is now a unsigned type.
3674
6e9382f1 3675** Deprecated features have been removed.
e6c9e497
MV
3676
3677*** Macros removed
3678
3679 SCM_INPORTP, SCM_OUTPORTP SCM_ICHRP, SCM_ICHR, SCM_MAKICHR
3680 SCM_SETJMPBUF SCM_NSTRINGP SCM_NRWSTRINGP SCM_NVECTORP SCM_DOUBLE_CELLP
3681
3682*** C Functions removed
3683
3684 scm_sysmissing scm_tag scm_tc16_flo scm_tc_flo
3685 scm_fseek - replaced by scm_seek.
3686 gc-thunk - replaced by after-gc-hook.
3687 gh_int2scmb - replaced by gh_bool2scm.
3688 scm_tc_dblr - replaced by scm_tc16_real.
3689 scm_tc_dblc - replaced by scm_tc16_complex.
3690 scm_list_star - replaced by scm_cons_star.
3691
36284627
DH
3692** Deprecated: scm_makfromstr
3693
3694Use scm_mem2string instead.
3695
311b6a3c
MV
3696** Deprecated: scm_make_shared_substring
3697
3698Explicit shared substrings will disappear from Guile.
3699
3700Instead, "normal" strings will be implemented using sharing
3701internally, combined with a copy-on-write strategy.
3702
3703** Deprecated: scm_read_only_string_p
3704
3705The concept of read-only strings will disappear in next release of
3706Guile.
3707
3708** Deprecated: scm_sloppy_memq, scm_sloppy_memv, scm_sloppy_member
c299f186 3709
311b6a3c 3710Instead, use scm_c_memq or scm_memq, scm_memv, scm_member.
c299f186 3711
dd0e04ed
KN
3712** New functions: scm_call_0, scm_call_1, scm_call_2, scm_call_3
3713
83dbedcc
KR
3714Call a procedure with the indicated number of arguments. See "Fly
3715Evaluation" in the manual.
dd0e04ed
KN
3716
3717** New functions: scm_apply_0, scm_apply_1, scm_apply_2, scm_apply_3
3718
83dbedcc
KR
3719Call a procedure with the indicated number of arguments and a list of
3720further arguments. See "Fly Evaluation" in the manual.
dd0e04ed 3721
e235f2a6
KN
3722** New functions: scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5
3723
83dbedcc
KR
3724Create a list of the given number of elements. See "List
3725Constructors" in the manual.
e235f2a6
KN
3726
3727** Renamed function: scm_listify has been replaced by scm_list_n.
3728
3729** Deprecated macros: SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4,
3730SCM_LIST5, SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9.
3731
3732Use functions scm_list_N instead.
3733
6fe692e9
MD
3734** New function: scm_c_read (SCM port, void *buffer, scm_sizet size)
3735
3736Used by an application to read arbitrary number of bytes from a port.
3737Same semantics as libc read, except that scm_c_read only returns less
3738than SIZE bytes if at end-of-file.
3739
3740Warning: Doesn't update port line and column counts!
3741
3742** New function: scm_c_write (SCM port, const void *ptr, scm_sizet size)
3743
3744Used by an application to write arbitrary number of bytes to an SCM
3745port. Similar semantics as libc write. However, unlike libc
3746write, scm_c_write writes the requested number of bytes and has no
3747return value.
3748
3749Warning: Doesn't update port line and column counts!
3750
17f367e0
MV
3751** New function: scm_init_guile ()
3752
3753In contrast to scm_boot_guile, scm_init_guile will return normally
3754after initializing Guile. It is not available on all systems, tho.
3755
23ade5e7
DH
3756** New functions: scm_str2symbol, scm_mem2symbol
3757
3758The function scm_str2symbol takes a const char* pointing to a zero-terminated
3759field of characters and creates a scheme symbol object from that C string.
3760The function scm_mem2symbol takes a const char* and a number of characters and
3761creates a symbol from the characters in that memory area.
3762
17f367e0
MV
3763** New functions: scm_primitive_make_property
3764 scm_primitive_property_ref
3765 scm_primitive_property_set_x
3766 scm_primitive_property_del_x
3767
3768These functions implement a new way to deal with object properties.
3769See libguile/properties.c for their documentation.
3770
9d47a1e6
ML
3771** New function: scm_done_free (long size)
3772
3773This function is the inverse of scm_done_malloc. Use it to report the
3774amount of smob memory you free. The previous method, which involved
3775calling scm_done_malloc with negative argument, was somewhat
3776unintuitive (and is still available, of course).
3777
79a3dafe
DH
3778** New function: scm_c_memq (SCM obj, SCM list)
3779
3780This function provides a fast C level alternative for scm_memq for the case
3781that the list parameter is known to be a proper list. The function is a
3782replacement for scm_sloppy_memq, but is stricter in its requirements on its
3783list input parameter, since for anything else but a proper list the function's
3784behaviour is undefined - it may even crash or loop endlessly. Further, for
3785the case that the object is not found in the list, scm_c_memq returns #f which
3786is similar to scm_memq, but different from scm_sloppy_memq's behaviour.
3787
6c0201ad 3788** New functions: scm_remember_upto_here_1, scm_remember_upto_here_2,
5d2b97cd
DH
3789scm_remember_upto_here
3790
3791These functions replace the function scm_remember.
3792
3793** Deprecated function: scm_remember
3794
3795Use one of the new functions scm_remember_upto_here_1,
3796scm_remember_upto_here_2 or scm_remember_upto_here instead.
3797
be54b15d
DH
3798** New function: scm_allocate_string
3799
3800This function replaces the function scm_makstr.
3801
3802** Deprecated function: scm_makstr
3803
3804Use the new function scm_allocate_string instead.
3805
32d0d4b1
DH
3806** New global variable scm_gc_running_p introduced.
3807
3808Use this variable to find out if garbage collection is being executed. Up to
3809now applications have used scm_gc_heap_lock to test if garbage collection was
3810running, which also works because of the fact that up to know only the garbage
3811collector has set this variable. But, this is an implementation detail that
3812may change. Further, scm_gc_heap_lock is not set throughout gc, thus the use
3813of this variable is (and has been) not fully safe anyway.
3814
5b9eb8ae
DH
3815** New macros: SCM_BITVECTOR_MAX_LENGTH, SCM_UVECTOR_MAX_LENGTH
3816
3817Use these instead of SCM_LENGTH_MAX.
3818
6c0201ad 3819** New macros: SCM_CONTINUATION_LENGTH, SCM_CCLO_LENGTH, SCM_STACK_LENGTH,
a6d9e5ab
DH
3820SCM_STRING_LENGTH, SCM_SYMBOL_LENGTH, SCM_UVECTOR_LENGTH,
3821SCM_BITVECTOR_LENGTH, SCM_VECTOR_LENGTH.
3822
3823Use these instead of SCM_LENGTH.
3824
6c0201ad 3825** New macros: SCM_SET_CONTINUATION_LENGTH, SCM_SET_STRING_LENGTH,
93778877
DH
3826SCM_SET_SYMBOL_LENGTH, SCM_SET_VECTOR_LENGTH, SCM_SET_UVECTOR_LENGTH,
3827SCM_SET_BITVECTOR_LENGTH
bc0eaf7b
DH
3828
3829Use these instead of SCM_SETLENGTH
3830
6c0201ad 3831** New macros: SCM_STRING_CHARS, SCM_SYMBOL_CHARS, SCM_CCLO_BASE,
a6d9e5ab
DH
3832SCM_VECTOR_BASE, SCM_UVECTOR_BASE, SCM_BITVECTOR_BASE, SCM_COMPLEX_MEM,
3833SCM_ARRAY_MEM
3834
e51fe79c
DH
3835Use these instead of SCM_CHARS, SCM_UCHARS, SCM_ROCHARS, SCM_ROUCHARS or
3836SCM_VELTS.
a6d9e5ab 3837
6c0201ad 3838** New macros: SCM_SET_BIGNUM_BASE, SCM_SET_STRING_CHARS,
6a0476fd
DH
3839SCM_SET_SYMBOL_CHARS, SCM_SET_UVECTOR_BASE, SCM_SET_BITVECTOR_BASE,
3840SCM_SET_VECTOR_BASE
3841
3842Use these instead of SCM_SETCHARS.
3843
a6d9e5ab
DH
3844** New macro: SCM_BITVECTOR_P
3845
3846** New macro: SCM_STRING_COERCE_0TERMINATION_X
3847
3848Use instead of SCM_COERCE_SUBSTR.
3849
30ea841d
DH
3850** New macros: SCM_DIR_OPEN_P, SCM_DIR_FLAG_OPEN
3851
3852For directory objects, use these instead of SCM_OPDIRP and SCM_OPN.
3853
6c0201ad
TTN
3854** Deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,
3855SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL,
3856SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD,
d1ca2c64 3857SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SYMBOL_SLOTS, SCM_SLOTS, SCM_SLOPPY_STRINGP,
a6d9e5ab
DH
3858SCM_VALIDATE_STRINGORSUBSTR, SCM_FREEP, SCM_NFREEP, SCM_CHARS, SCM_UCHARS,
3859SCM_VALIDATE_ROSTRING, SCM_VALIDATE_ROSTRING_COPY,
3860SCM_VALIDATE_NULLORROSTRING_COPY, SCM_ROLENGTH, SCM_LENGTH, SCM_HUGE_LENGTH,
b24b5e13 3861SCM_SUBSTRP, SCM_SUBSTR_STR, SCM_SUBSTR_OFFSET, SCM_COERCE_SUBSTR,
34f0f2b8 3862SCM_ROSTRINGP, SCM_RWSTRINGP, SCM_VALIDATE_RWSTRING, SCM_ROCHARS,
fd336365 3863SCM_ROUCHARS, SCM_SETLENGTH, SCM_SETCHARS, SCM_LENGTH_MAX, SCM_GC8MARKP,
30ea841d 3864SCM_SETGC8MARK, SCM_CLRGC8MARK, SCM_GCTYP16, SCM_GCCDR, SCM_SUBR_DOC,
b3fcac34
DH
3865SCM_OPDIRP, SCM_VALIDATE_OPDIR, SCM_WTA, RETURN_SCM_WTA, SCM_CONST_LONG,
3866SCM_WNA, SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
61045190 3867SCM_VALIDATE_NUMBER_DEF_COPY, SCM_SLOPPY_CONSP, SCM_SLOPPY_NCONSP,
e038c042 3868SCM_SETAND_CDR, SCM_SETOR_CDR, SCM_SETAND_CAR, SCM_SETOR_CAR
b63a956d
DH
3869
3870Use SCM_ASSERT_RANGE or SCM_VALIDATE_XXX_RANGE instead of SCM_OUTOFRANGE.
3871Use scm_memory_error instead of SCM_NALLOC.
c1aef037 3872Use SCM_STRINGP instead of SCM_SLOPPY_STRINGP.
d1ca2c64
DH
3873Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_STRINGORSUBSTR.
3874Use SCM_FREE_CELL_P instead of SCM_FREEP/SCM_NFREEP
a6d9e5ab 3875Use a type specific accessor macro instead of SCM_CHARS/SCM_UCHARS.
6c0201ad 3876Use a type specific accessor instead of SCM(_|_RO|_HUGE_)LENGTH.
a6d9e5ab
DH
3877Use SCM_VALIDATE_(SYMBOL|STRING) instead of SCM_VALIDATE_ROSTRING.
3878Use SCM_STRING_COERCE_0TERMINATION_X instead of SCM_COERCE_SUBSTR.
b24b5e13 3879Use SCM_STRINGP or SCM_SYMBOLP instead of SCM_ROSTRINGP.
f0942910
DH
3880Use SCM_STRINGP instead of SCM_RWSTRINGP.
3881Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_RWSTRING.
34f0f2b8
DH
3882Use SCM_STRING_CHARS instead of SCM_ROCHARS.
3883Use SCM_STRING_UCHARS instead of SCM_ROUCHARS.
93778877 3884Use a type specific setter macro instead of SCM_SETLENGTH.
6a0476fd 3885Use a type specific setter macro instead of SCM_SETCHARS.
5b9eb8ae 3886Use a type specific length macro instead of SCM_LENGTH_MAX.
fd336365
DH
3887Use SCM_GCMARKP instead of SCM_GC8MARKP.
3888Use SCM_SETGCMARK instead of SCM_SETGC8MARK.
3889Use SCM_CLRGCMARK instead of SCM_CLRGC8MARK.
3890Use SCM_TYP16 instead of SCM_GCTYP16.
3891Use SCM_CDR instead of SCM_GCCDR.
30ea841d 3892Use SCM_DIR_OPEN_P instead of SCM_OPDIRP.
276dd677
DH
3893Use SCM_MISC_ERROR or SCM_WRONG_TYPE_ARG instead of SCM_WTA.
3894Use SCM_MISC_ERROR or SCM_WRONG_TYPE_ARG instead of RETURN_SCM_WTA.
8dea8611 3895Use SCM_VCELL_INIT instead of SCM_CONST_LONG.
b3fcac34 3896Use SCM_WRONG_NUM_ARGS instead of SCM_WNA.
ced99e92
DH
3897Use SCM_CONSP instead of SCM_SLOPPY_CONSP.
3898Use !SCM_CONSP instead of SCM_SLOPPY_NCONSP.
b63a956d 3899
f7620510
DH
3900** Removed function: scm_struct_init
3901
93d40df2
DH
3902** Removed variable: scm_symhash_dim
3903
818febc0
GH
3904** Renamed function: scm_make_cont has been replaced by
3905scm_make_continuation, which has a different interface.
3906
cc4feeca
DH
3907** Deprecated function: scm_call_catching_errors
3908
3909Use scm_catch or scm_lazy_catch from throw.[ch] instead.
3910
28b06554
DH
3911** Deprecated function: scm_strhash
3912
3913Use scm_string_hash instead.
3914
1b9be268
DH
3915** Deprecated function: scm_vector_set_length_x
3916
3917Instead, create a fresh vector of the desired size and copy the contents.
3918
302f229e
MD
3919** scm_gensym has changed prototype
3920
3921scm_gensym now only takes one argument.
3922
1660782e
DH
3923** Deprecated type tags: scm_tc7_ssymbol, scm_tc7_msymbol, scm_tcs_symbols,
3924scm_tc7_lvector
28b06554
DH
3925
3926There is now only a single symbol type scm_tc7_symbol.
1660782e 3927The tag scm_tc7_lvector was not used anyway.
28b06554 3928
2f6fb7c5
KN
3929** Deprecated function: scm_make_smob_type_mfpe, scm_set_smob_mfpe.
3930
3931Use scm_make_smob_type and scm_set_smob_XXX instead.
3932
3933** New function scm_set_smob_apply.
3934
3935This can be used to set an apply function to a smob type.
3936
1f3908c4
KN
3937** Deprecated function: scm_strprint_obj
3938
3939Use scm_object_to_string instead.
3940
b3fcac34
DH
3941** Deprecated function: scm_wta
3942
3943Use scm_wrong_type_arg, or another appropriate error signalling function
3944instead.
3945
f3f9dcbc
MV
3946** Explicit support for obarrays has been deprecated.
3947
3948Use `scm_str2symbol' and the generic hashtable functions instead.
3949
3950** The concept of `vcells' has been deprecated.
3951
3952The data type `variable' is now used exclusively. `Vcells' have been
3953a low-level concept so you are likely not affected by this change.
3954
3955*** Deprecated functions: scm_sym2vcell, scm_sysintern,
3956 scm_sysintern0, scm_symbol_value0, scm_intern, scm_intern0.
3957
3958Use scm_c_define or scm_c_lookup instead, as appropriate.
3959
3960*** New functions: scm_c_module_lookup, scm_c_lookup,
3961 scm_c_module_define, scm_c_define, scm_module_lookup, scm_lookup,
3962 scm_module_define, scm_define.
3963
3964These functions work with variables instead of with vcells.
3965
311b6a3c
MV
3966** New functions for creating and defining `subr's and `gsubr's.
3967
3968The new functions more clearly distinguish between creating a subr (or
3969gsubr) object and adding it to the current module.
3970
3971These new functions are available: scm_c_make_subr, scm_c_define_subr,
3972scm_c_make_subr_with_generic, scm_c_define_subr_with_generic,
3973scm_c_make_gsubr, scm_c_define_gsubr, scm_c_make_gsubr_with_generic,
3974scm_c_define_gsubr_with_generic.
3975
3976** Deprecated functions: scm_make_subr, scm_make_subr_opt,
3977 scm_make_subr_with_generic, scm_make_gsubr,
3978 scm_make_gsubr_with_generic.
3979
3980Use the new ones from above instead.
3981
3982** C interface to the module system has changed.
3983
3984While we suggest that you avoid as many explicit module system
3985operations from C as possible for the time being, the C interface has
3986been made more similar to the high-level Scheme module system.
3987
3988*** New functions: scm_c_define_module, scm_c_use_module,
3989 scm_c_export, scm_c_resolve_module.
3990
3991They mostly work like their Scheme namesakes. scm_c_define_module
3992takes a function that is called a context where the new module is
3993current.
3994
3995*** Deprecated functions: scm_the_root_module, scm_make_module,
3996 scm_ensure_user_module, scm_load_scheme_module.
3997
3998Use the new functions instead.
3999
4000** Renamed function: scm_internal_with_fluids becomes
4001 scm_c_with_fluids.
4002
4003scm_internal_with_fluids is available as a deprecated function.
4004
4005** New function: scm_c_with_fluid.
4006
4007Just like scm_c_with_fluids, but takes one fluid and one value instead
4008of lists of same.
4009
1be6b49c
ML
4010** Deprecated typedefs: long_long, ulong_long.
4011
4012They are of questionable utility and they pollute the global
4013namespace.
4014
1be6b49c
ML
4015** Deprecated typedef: scm_sizet
4016
4017It is of questionable utility now that Guile requires ANSI C, and is
4018oddly named.
4019
4020** Deprecated typedefs: scm_port_rw_active, scm_port,
4021 scm_ptob_descriptor, scm_debug_info, scm_debug_frame, scm_fport,
4022 scm_option, scm_rstate, scm_rng, scm_array, scm_array_dim.
4023
4024Made more compliant with the naming policy by adding a _t at the end.
4025
4026** Deprecated functions: scm_mkbig, scm_big2num, scm_adjbig,
4027 scm_normbig, scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl
4028
373f4948 4029With the exception of the mysterious scm_2ulong2big, they are still
1be6b49c
ML
4030available under new names (scm_i_mkbig etc). These functions are not
4031intended to be used in user code. You should avoid dealing with
4032bignums directly, and should deal with numbers in general (which can
4033be bignums).
4034
147c18a0
MD
4035** Change in behavior: scm_num2long, scm_num2ulong
4036
4037The scm_num2[u]long functions don't any longer accept an inexact
4038argument. This change in behavior is motivated by concordance with
4039R5RS: It is more common that a primitive doesn't want to accept an
4040inexact for an exact.
4041
1be6b49c 4042** New functions: scm_short2num, scm_ushort2num, scm_int2num,
f3f70257
ML
4043 scm_uint2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
4044 scm_num2ushort, scm_num2int, scm_num2uint, scm_num2ptrdiff,
1be6b49c
ML
4045 scm_num2size.
4046
4047These are conversion functions between the various ANSI C integral
147c18a0
MD
4048types and Scheme numbers. NOTE: The scm_num2xxx functions don't
4049accept an inexact argument.
1be6b49c 4050
5437598b
MD
4051** New functions: scm_float2num, scm_double2num,
4052 scm_num2float, scm_num2double.
4053
4054These are conversion functions between the two ANSI C float types and
4055Scheme numbers.
4056
1be6b49c 4057** New number validation macros:
f3f70257 4058 SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,INT,UINT}[_DEF]
1be6b49c
ML
4059
4060See above.
4061
fc62c86a
ML
4062** New functions: scm_gc_protect_object, scm_gc_unprotect_object
4063
4064These are just nicer-named old scm_protect_object and
4065scm_unprotect_object.
4066
4067** Deprecated functions: scm_protect_object, scm_unprotect_object
4068
4069** New functions: scm_gc_[un]register_root, scm_gc_[un]register_roots
4070
4071These functions can be used to register pointers to locations that
4072hold SCM values.
4073
5b2ad23b
ML
4074** Deprecated function: scm_create_hook.
4075
4076Its sins are: misleading name, non-modularity and lack of general
4077usefulness.
4078
c299f186 4079\f
cc36e791
JB
4080Changes since Guile 1.3.4:
4081
80f27102
JB
4082* Changes to the distribution
4083
ce358662
JB
4084** Trees from nightly snapshots and CVS now require you to run autogen.sh.
4085
4086We've changed the way we handle generated files in the Guile source
4087repository. As a result, the procedure for building trees obtained
4088from the nightly FTP snapshots or via CVS has changed:
4089- You must have appropriate versions of autoconf, automake, and
4090 libtool installed on your system. See README for info on how to
4091 obtain these programs.
4092- Before configuring the tree, you must first run the script
4093 `autogen.sh' at the top of the source tree.
4094
4095The Guile repository used to contain not only source files, written by
4096humans, but also some generated files, like configure scripts and
4097Makefile.in files. Even though the contents of these files could be
4098derived mechanically from other files present, we thought it would
4099make the tree easier to build if we checked them into CVS.
4100
4101However, this approach means that minor differences between
4102developer's installed tools and habits affected the whole team.
4103So we have removed the generated files from the repository, and
4104added the autogen.sh script, which will reconstruct them
4105appropriately.
4106
4107
dc914156
GH
4108** configure now has experimental options to remove support for certain
4109features:
52cfc69b 4110
dc914156
GH
4111--disable-arrays omit array and uniform array support
4112--disable-posix omit posix interfaces
4113--disable-networking omit networking interfaces
4114--disable-regex omit regular expression interfaces
52cfc69b
GH
4115
4116These are likely to become separate modules some day.
4117
9764c29b 4118** New configure option --enable-debug-freelist
e1b0d0ac 4119
38a15cfd
GB
4120This enables a debugging version of SCM_NEWCELL(), and also registers
4121an extra primitive, the setter `gc-set-debug-check-freelist!'.
4122
4123Configure with the --enable-debug-freelist option to enable
4124the gc-set-debug-check-freelist! primitive, and then use:
4125
4126(gc-set-debug-check-freelist! #t) # turn on checking of the freelist
4127(gc-set-debug-check-freelist! #f) # turn off checking
4128
4129Checking of the freelist forces a traversal of the freelist and
4130a garbage collection before each allocation of a cell. This can
4131slow down the interpreter dramatically, so the setter should be used to
4132turn on this extra processing only when necessary.
e1b0d0ac 4133
9764c29b
MD
4134** New configure option --enable-debug-malloc
4135
4136Include code for debugging of calls to scm_must_malloc/realloc/free.
4137
4138Checks that
4139
41401. objects freed by scm_must_free has been mallocated by scm_must_malloc
41412. objects reallocated by scm_must_realloc has been allocated by
4142 scm_must_malloc
41433. reallocated objects are reallocated with the same what string
4144
4145But, most importantly, it records the number of allocated objects of
4146each kind. This is useful when searching for memory leaks.
4147
4148A Guile compiled with this option provides the primitive
4149`malloc-stats' which returns an alist with pairs of kind and the
4150number of objects of that kind.
4151
e415cb06
MD
4152** All includes are now referenced relative to the root directory
4153
4154Since some users have had problems with mixups between Guile and
4155system headers, we have decided to always refer to Guile headers via
4156their parent directories. This essentially creates a "private name
4157space" for Guile headers. This means that the compiler only is given
4158-I options for the root build and root source directory.
4159
341f78c9
MD
4160** Header files kw.h and genio.h have been removed.
4161
4162** The module (ice-9 getopt-gnu-style) has been removed.
4163
e8855f8d
MD
4164** New module (ice-9 documentation)
4165
4166Implements the interface to documentation strings associated with
4167objects.
4168
0c0ffe09
KN
4169** New module (ice-9 time)
4170
4171Provides a macro `time', which displays execution time of a given form.
4172
cf7a5ee5
KN
4173** New module (ice-9 history)
4174
4175Loading this module enables value history in the repl.
4176
0af43c4a 4177* Changes to the stand-alone interpreter
bd9e24b3 4178
67ef2dca
MD
4179** New command line option --debug
4180
4181Start Guile with debugging evaluator and backtraces enabled.
4182
4183This is useful when debugging your .guile init file or scripts.
4184
aa4bb95d
MD
4185** New help facility
4186
341f78c9
MD
4187Usage: (help NAME) gives documentation about objects named NAME (a symbol)
4188 (help REGEXP) ditto for objects with names matching REGEXP (a string)
58e5b910 4189 (help 'NAME) gives documentation for NAME, even if it is not an object
341f78c9 4190 (help ,EXPR) gives documentation for object returned by EXPR
6c0201ad 4191 (help (my module)) gives module commentary for `(my module)'
341f78c9
MD
4192 (help) gives this text
4193
4194`help' searches among bindings exported from loaded modules, while
4195`apropos' searches among bindings visible from the "current" module.
4196
4197Examples: (help help)
4198 (help cons)
4199 (help "output-string")
aa4bb95d 4200
e8855f8d
MD
4201** `help' and `apropos' now prints full module names
4202
0af43c4a 4203** Dynamic linking now uses libltdl from the libtool package.
bd9e24b3 4204
0af43c4a
MD
4205The old system dependent code for doing dynamic linking has been
4206replaced with calls to the libltdl functions which do all the hairy
4207details for us.
bd9e24b3 4208
0af43c4a
MD
4209The major improvement is that you can now directly pass libtool
4210library names like "libfoo.la" to `dynamic-link' and `dynamic-link'
4211will be able to do the best shared library job you can get, via
4212libltdl.
bd9e24b3 4213
0af43c4a
MD
4214The way dynamic libraries are found has changed and is not really
4215portable across platforms, probably. It is therefore recommended to
4216use absolute filenames when possible.
4217
4218If you pass a filename without an extension to `dynamic-link', it will
4219try a few appropriate ones. Thus, the most platform ignorant way is
4220to specify a name like "libfoo", without any directories and
4221extensions.
0573ddae 4222
91163914
MD
4223** Guile COOP threads are now compatible with LinuxThreads
4224
4225Previously, COOP threading wasn't possible in applications linked with
4226Linux POSIX threads due to their use of the stack pointer to find the
4227thread context. This has now been fixed with a workaround which uses
4228the pthreads to allocate the stack.
4229
6c0201ad 4230** New primitives: `pkgdata-dir', `site-dir', `library-dir'
62b82274 4231
9770d235
MD
4232** Positions of erring expression in scripts
4233
4234With version 1.3.4, the location of the erring expression in Guile
4235scipts is no longer automatically reported. (This should have been
4236documented before the 1.3.4 release.)
4237
4238You can get this information by enabling recording of positions of
4239source expressions and running the debugging evaluator. Put this at
4240the top of your script (or in your "site" file):
4241
4242 (read-enable 'positions)
4243 (debug-enable 'debug)
4244
0573ddae
MD
4245** Backtraces in scripts
4246
4247It is now possible to get backtraces in scripts.
4248
4249Put
4250
4251 (debug-enable 'debug 'backtrace)
4252
4253at the top of the script.
4254
4255(The first options enables the debugging evaluator.
4256 The second enables backtraces.)
4257
e8855f8d
MD
4258** Part of module system symbol lookup now implemented in C
4259
4260The eval closure of most modules is now implemented in C. Since this
4261was one of the bottlenecks for loading speed, Guile now loads code
4262substantially faster than before.
4263
f25f761d
GH
4264** Attempting to get the value of an unbound variable now produces
4265an exception with a key of 'unbound-variable instead of 'misc-error.
4266
1a35eadc
GH
4267** The initial default output port is now unbuffered if it's using a
4268tty device. Previously in this situation it was line-buffered.
4269
820920e6
MD
4270** New hook: after-gc-hook
4271
4272after-gc-hook takes over the role of gc-thunk. This hook is run at
4273the first SCM_TICK after a GC. (Thus, the code is run at the same
4274point during evaluation as signal handlers.)
4275
4276Note that this hook should be used only for diagnostic and debugging
4277purposes. It is not certain that it will continue to be well-defined
4278when this hook is run in the future.
4279
4280C programmers: Note the new C level hooks scm_before_gc_c_hook,
4281scm_before_sweep_c_hook, scm_after_gc_c_hook.
4282
b5074b23
MD
4283** Improvements to garbage collector
4284
4285Guile 1.4 has a new policy for triggering heap allocation and
4286determining the sizes of heap segments. It fixes a number of problems
4287in the old GC.
4288
42891. The new policy can handle two separate pools of cells
4290 (2-word/4-word) better. (The old policy would run wild, allocating
4291 more and more memory for certain programs.)
4292
42932. The old code would sometimes allocate far too much heap so that the
4294 Guile process became gigantic. The new code avoids this.
4295
42963. The old code would sometimes allocate too little so that few cells
4297 were freed at GC so that, in turn, too much time was spent in GC.
4298
42994. The old code would often trigger heap allocation several times in a
4300 row. (The new scheme predicts how large the segments needs to be
4301 in order not to need further allocation.)
4302
e8855f8d
MD
4303All in all, the new GC policy will make larger applications more
4304efficient.
4305
b5074b23
MD
4306The new GC scheme also is prepared for POSIX threading. Threads can
4307allocate private pools of cells ("clusters") with just a single
4308function call. Allocation of single cells from such a cluster can
4309then proceed without any need of inter-thread synchronization.
4310
4311** New environment variables controlling GC parameters
4312
4313GUILE_MAX_SEGMENT_SIZE Maximal segment size
4314 (default = 2097000)
4315
4316Allocation of 2-word cell heaps:
4317
4318GUILE_INIT_SEGMENT_SIZE_1 Size of initial heap segment in bytes
4319 (default = 360000)
4320
4321GUILE_MIN_YIELD_1 Minimum number of freed cells at each
4322 GC in percent of total heap size
4323 (default = 40)
4324
4325Allocation of 4-word cell heaps
4326(used for real numbers and misc other objects):
4327
4328GUILE_INIT_SEGMENT_SIZE_2, GUILE_MIN_YIELD_2
4329
4330(See entry "Way for application to customize GC parameters" under
4331 section "Changes to the scm_ interface" below.)
4332
67ef2dca
MD
4333** Guile now implements reals using 4-word cells
4334
4335This speeds up computation with reals. (They were earlier allocated
4336with `malloc'.) There is still some room for optimizations, however.
4337
4338** Some further steps toward POSIX thread support have been taken
4339
4340*** Guile's critical sections (SCM_DEFER/ALLOW_INTS)
4341don't have much effect any longer, and many of them will be removed in
4342next release.
4343
4344*** Signals
4345are only handled at the top of the evaluator loop, immediately after
4346I/O, and in scm_equalp.
4347
4348*** The GC can allocate thread private pools of pairs.
4349
0af43c4a
MD
4350* Changes to Scheme functions and syntax
4351
a0128ebe 4352** close-input-port and close-output-port are now R5RS
7c1e0b12 4353
a0128ebe 4354These procedures have been turned into primitives and have R5RS behaviour.
7c1e0b12 4355
0af43c4a
MD
4356** New procedure: simple-format PORT MESSAGE ARG1 ...
4357
4358(ice-9 boot) makes `format' an alias for `simple-format' until possibly
4359extended by the more sophisticated version in (ice-9 format)
4360
4361(simple-format port message . args)
4362Write MESSAGE to DESTINATION, defaulting to `current-output-port'.
4363MESSAGE can contain ~A (was %s) and ~S (was %S) escapes. When printed,
4364the escapes are replaced with corresponding members of ARGS:
4365~A formats using `display' and ~S formats using `write'.
4366If DESTINATION is #t, then use the `current-output-port',
4367if DESTINATION is #f, then return a string containing the formatted text.
4368Does not add a trailing newline."
4369
4370** string-ref: the second argument is no longer optional.
4371
4372** string, list->string: no longer accept strings in their arguments,
4373only characters, for compatibility with R5RS.
4374
4375** New procedure: port-closed? PORT
4376Returns #t if PORT is closed or #f if it is open.
4377
0a9e521f
MD
4378** Deprecated: list*
4379
4380The list* functionality is now provided by cons* (SRFI-1 compliant)
4381
b5074b23
MD
4382** New procedure: cons* ARG1 ARG2 ... ARGn
4383
4384Like `list', but the last arg provides the tail of the constructed list,
4385returning (cons ARG1 (cons ARG2 (cons ... ARGn))).
4386
4387Requires at least one argument. If given one argument, that argument
4388is returned as result.
4389
4390This function is called `list*' in some other Schemes and in Common LISP.
4391
341f78c9
MD
4392** Removed deprecated: serial-map, serial-array-copy!, serial-array-map!
4393
e8855f8d
MD
4394** New procedure: object-documentation OBJECT
4395
4396Returns the documentation string associated with OBJECT. The
4397procedure uses a caching mechanism so that subsequent lookups are
4398faster.
4399
4400Exported by (ice-9 documentation).
4401
4402** module-name now returns full names of modules
4403
4404Previously, only the last part of the name was returned (`session' for
4405`(ice-9 session)'). Ex: `(ice-9 session)'.
4406
894a712b
DH
4407* Changes to the gh_ interface
4408
4409** Deprecated: gh_int2scmb
4410
4411Use gh_bool2scm instead.
4412
a2349a28
GH
4413* Changes to the scm_ interface
4414
810e1aec
MD
4415** Guile primitives now carry docstrings!
4416
4417Thanks to Greg Badros!
4418
0a9e521f 4419** Guile primitives are defined in a new way: SCM_DEFINE/SCM_DEFINE1/SCM_PROC
0af43c4a 4420
0a9e521f
MD
4421Now Guile primitives are defined using the SCM_DEFINE/SCM_DEFINE1/SCM_PROC
4422macros and must contain a docstring that is extracted into foo.doc using a new
0af43c4a
MD
4423guile-doc-snarf script (that uses guile-doc-snarf.awk).
4424
0a9e521f
MD
4425However, a major overhaul of these macros is scheduled for the next release of
4426guile.
4427
0af43c4a
MD
4428** Guile primitives use a new technique for validation of arguments
4429
4430SCM_VALIDATE_* macros are defined to ease the redundancy and improve
4431the readability of argument checking.
4432
4433** All (nearly?) K&R prototypes for functions replaced with ANSI C equivalents.
4434
894a712b 4435** New macros: SCM_PACK, SCM_UNPACK
f8a72ca4
MD
4436
4437Compose/decompose an SCM value.
4438
894a712b
DH
4439The SCM type is now treated as an abstract data type and may be defined as a
4440long, a void* or as a struct, depending on the architecture and compile time
4441options. This makes it easier to find several types of bugs, for example when
4442SCM values are treated as integers without conversion. Values of the SCM type
4443should be treated as "atomic" values. These macros are used when
f8a72ca4
MD
4444composing/decomposing an SCM value, either because you want to access
4445individual bits, or because you want to treat it as an integer value.
4446
4447E.g., in order to set bit 7 in an SCM value x, use the expression
4448
4449 SCM_PACK (SCM_UNPACK (x) | 0x80)
4450
e11f8b42
DH
4451** The name property of hooks is deprecated.
4452Thus, the use of SCM_HOOK_NAME and scm_make_hook_with_name is deprecated.
4453
4454You can emulate this feature by using object properties.
4455
6c0201ad 4456** Deprecated macros: SCM_INPORTP, SCM_OUTPORTP, SCM_CRDY, SCM_ICHRP,
894a712b
DH
4457SCM_ICHR, SCM_MAKICHR, SCM_SETJMPBUF, SCM_NSTRINGP, SCM_NRWSTRINGP,
4458SCM_NVECTORP
f8a72ca4 4459
894a712b 4460These macros will be removed in a future release of Guile.
7c1e0b12 4461
6c0201ad 4462** The following types, functions and macros from numbers.h are deprecated:
0a9e521f
MD
4463scm_dblproc, SCM_UNEGFIXABLE, SCM_FLOBUFLEN, SCM_INEXP, SCM_CPLXP, SCM_REAL,
4464SCM_IMAG, SCM_REALPART, scm_makdbl, SCM_SINGP, SCM_NUM2DBL, SCM_NO_BIGDIG
4465
a2349a28
GH
4466** Port internals: the rw_random variable in the scm_port structure
4467must be set to non-zero in any random access port. In recent Guile
4468releases it was only set for bidirectional random-access ports.
4469
7dcb364d
GH
4470** Port internals: the seek ptob procedure is now responsible for
4471resetting the buffers if required. The change was made so that in the
4472special case of reading the current position (i.e., seek p 0 SEEK_CUR)
4473the fport and strport ptobs can avoid resetting the buffers,
4474in particular to avoid discarding unread chars. An existing port
4475type can be fixed by adding something like the following to the
4476beginning of the ptob seek procedure:
4477
4478 if (pt->rw_active == SCM_PORT_READ)
4479 scm_end_input (object);
4480 else if (pt->rw_active == SCM_PORT_WRITE)
4481 ptob->flush (object);
4482
4483although to actually avoid resetting the buffers and discard unread
4484chars requires further hacking that depends on the characteristics
4485of the ptob.
4486
894a712b
DH
4487** Deprecated functions: scm_fseek, scm_tag
4488
4489These functions are no longer used and will be removed in a future version.
4490
f25f761d
GH
4491** The scm_sysmissing procedure is no longer used in libguile.
4492Unless it turns out to be unexpectedly useful to somebody, it will be
4493removed in a future version.
4494
0af43c4a
MD
4495** The format of error message strings has changed
4496
4497The two C procedures: scm_display_error and scm_error, as well as the
4498primitive `scm-error', now use scm_simple_format to do their work.
4499This means that the message strings of all code must be updated to use
4500~A where %s was used before, and ~S where %S was used before.
4501
4502During the period when there still are a lot of old Guiles out there,
4503you might want to support both old and new versions of Guile.
4504
4505There are basically two methods to achieve this. Both methods use
4506autoconf. Put
4507
4508 AC_CHECK_FUNCS(scm_simple_format)
4509
4510in your configure.in.
4511
4512Method 1: Use the string concatenation features of ANSI C's
4513 preprocessor.
4514
4515In C:
4516
4517#ifdef HAVE_SCM_SIMPLE_FORMAT
4518#define FMT_S "~S"
4519#else
4520#define FMT_S "%S"
4521#endif
4522
4523Then represent each of your error messages using a preprocessor macro:
4524
4525#define E_SPIDER_ERROR "There's a spider in your " ## FMT_S ## "!!!"
4526
4527In Scheme:
4528
4529(define fmt-s (if (defined? 'simple-format) "~S" "%S"))
4530(define make-message string-append)
4531
4532(define e-spider-error (make-message "There's a spider in your " fmt-s "!!!"))
4533
4534Method 2: Use the oldfmt function found in doc/oldfmt.c.
4535
4536In C:
4537
4538scm_misc_error ("picnic", scm_c_oldfmt0 ("There's a spider in your ~S!!!"),
4539 ...);
4540
4541In Scheme:
4542
4543(scm-error 'misc-error "picnic" (oldfmt "There's a spider in your ~S!!!")
4544 ...)
4545
4546
f3b5e185
MD
4547** Deprecated: coop_mutex_init, coop_condition_variable_init
4548
4549Don't use the functions coop_mutex_init and
4550coop_condition_variable_init. They will change.
4551
4552Use scm_mutex_init and scm_cond_init instead.
4553
f3b5e185
MD
4554** New function: int scm_cond_timedwait (scm_cond_t *COND, scm_mutex_t *MUTEX, const struct timespec *ABSTIME)
4555 `scm_cond_timedwait' atomically unlocks MUTEX and waits on
4556 COND, as `scm_cond_wait' does, but it also bounds the duration
4557 of the wait. If COND has not been signaled before time ABSTIME,
4558 the mutex MUTEX is re-acquired and `scm_cond_timedwait'
4559 returns the error code `ETIMEDOUT'.
4560
4561 The ABSTIME parameter specifies an absolute time, with the same
4562 origin as `time' and `gettimeofday': an ABSTIME of 0 corresponds
4563 to 00:00:00 GMT, January 1, 1970.
4564
4565** New function: scm_cond_broadcast (scm_cond_t *COND)
4566 `scm_cond_broadcast' restarts all the threads that are waiting
4567 on the condition variable COND. Nothing happens if no threads are
4568 waiting on COND.
4569
4570** New function: scm_key_create (scm_key_t *KEY, void (*destr_function) (void *))
4571 `scm_key_create' allocates a new TSD key. The key is stored in
4572 the location pointed to by KEY. There is no limit on the number
4573 of keys allocated at a given time. The value initially associated
4574 with the returned key is `NULL' in all currently executing threads.
4575
4576 The DESTR_FUNCTION argument, if not `NULL', specifies a destructor
4577 function associated with the key. When a thread terminates,
4578 DESTR_FUNCTION is called on the value associated with the key in
4579 that thread. The DESTR_FUNCTION is not called if a key is deleted
4580 with `scm_key_delete' or a value is changed with
4581 `scm_setspecific'. The order in which destructor functions are
4582 called at thread termination time is unspecified.
4583
4584 Destructors are not yet implemented.
4585
4586** New function: scm_setspecific (scm_key_t KEY, const void *POINTER)
4587 `scm_setspecific' changes the value associated with KEY in the
4588 calling thread, storing the given POINTER instead.
4589
4590** New function: scm_getspecific (scm_key_t KEY)
4591 `scm_getspecific' returns the value currently associated with
4592 KEY in the calling thread.
4593
4594** New function: scm_key_delete (scm_key_t KEY)
4595 `scm_key_delete' deallocates a TSD key. It does not check
4596 whether non-`NULL' values are associated with that key in the
4597 currently executing threads, nor call the destructor function
4598 associated with the key.
4599
820920e6
MD
4600** New function: scm_c_hook_init (scm_c_hook_t *HOOK, void *HOOK_DATA, scm_c_hook_type_t TYPE)
4601
4602Initialize a C level hook HOOK with associated HOOK_DATA and type
4603TYPE. (See scm_c_hook_run ().)
4604
4605** New function: scm_c_hook_add (scm_c_hook_t *HOOK, scm_c_hook_function_t FUNC, void *FUNC_DATA, int APPENDP)
4606
4607Add hook function FUNC with associated FUNC_DATA to HOOK. If APPENDP
4608is true, add it last, otherwise first. The same FUNC can be added
4609multiple times if FUNC_DATA differ and vice versa.
4610
4611** New function: scm_c_hook_remove (scm_c_hook_t *HOOK, scm_c_hook_function_t FUNC, void *FUNC_DATA)
4612
4613Remove hook function FUNC with associated FUNC_DATA from HOOK. A
4614function is only removed if both FUNC and FUNC_DATA matches.
4615
4616** New function: void *scm_c_hook_run (scm_c_hook_t *HOOK, void *DATA)
4617
4618Run hook HOOK passing DATA to the hook functions.
4619
4620If TYPE is SCM_C_HOOK_NORMAL, all hook functions are run. The value
4621returned is undefined.
4622
4623If TYPE is SCM_C_HOOK_OR, hook functions are run until a function
4624returns a non-NULL value. This value is returned as the result of
4625scm_c_hook_run. If all functions return NULL, NULL is returned.
4626
4627If TYPE is SCM_C_HOOK_AND, hook functions are run until a function
4628returns a NULL value, and NULL is returned. If all functions returns
4629a non-NULL value, the last value is returned.
4630
4631** New C level GC hooks
4632
4633Five new C level hooks has been added to the garbage collector.
4634
4635 scm_before_gc_c_hook
4636 scm_after_gc_c_hook
4637
4638are run before locking and after unlocking the heap. The system is
4639thus in a mode where evaluation can take place. (Except that
4640scm_before_gc_c_hook must not allocate new cells.)
4641
4642 scm_before_mark_c_hook
4643 scm_before_sweep_c_hook
4644 scm_after_sweep_c_hook
4645
4646are run when the heap is locked. These are intended for extension of
4647the GC in a modular fashion. Examples are the weaks and guardians
4648modules.
4649
b5074b23
MD
4650** Way for application to customize GC parameters
4651
4652The application can set up other default values for the GC heap
4653allocation parameters
4654
4655 GUILE_INIT_HEAP_SIZE_1, GUILE_MIN_YIELD_1,
4656 GUILE_INIT_HEAP_SIZE_2, GUILE_MIN_YIELD_2,
4657 GUILE_MAX_SEGMENT_SIZE,
4658
4659by setting
4660
4661 scm_default_init_heap_size_1, scm_default_min_yield_1,
4662 scm_default_init_heap_size_2, scm_default_min_yield_2,
4663 scm_default_max_segment_size
4664
4665respectively before callong scm_boot_guile.
4666
4667(See entry "New environment variables ..." in section
4668"Changes to the stand-alone interpreter" above.)
4669
9704841c
MD
4670** scm_protect_object/scm_unprotect_object now nest
4671
67ef2dca
MD
4672This means that you can call scm_protect_object multiple times on an
4673object and count on the object being protected until
4674scm_unprotect_object has been call the same number of times.
4675
4676The functions also have better time complexity.
4677
4678Still, it is usually possible to structure the application in a way
4679that you don't need to use these functions. For example, if you use a
4680protected standard Guile list to keep track of live objects rather
4681than some custom data type, objects will die a natural death when they
4682are no longer needed.
4683
0a9e521f
MD
4684** Deprecated type tags: scm_tc16_flo, scm_tc_flo, scm_tc_dblr, scm_tc_dblc
4685
4686Guile does not provide the float representation for inexact real numbers any
4687more. Now, only doubles are used to represent inexact real numbers. Further,
4688the tag names scm_tc_dblr and scm_tc_dblc have been changed to scm_tc16_real
4689and scm_tc16_complex, respectively.
4690
341f78c9
MD
4691** Removed deprecated type scm_smobfuns
4692
4693** Removed deprecated function scm_newsmob
4694
b5074b23
MD
4695** Warning: scm_make_smob_type_mfpe might become deprecated in a future release
4696
4697There is an ongoing discussion among the developers whether to
4698deprecate `scm_make_smob_type_mfpe' or not. Please use the current
4699standard interface (scm_make_smob_type, scm_set_smob_XXX) in new code
4700until this issue has been settled.
4701
341f78c9
MD
4702** Removed deprecated type tag scm_tc16_kw
4703
2728d7f4
MD
4704** Added type tag scm_tc16_keyword
4705
4706(This was introduced already in release 1.3.4 but was not documented
4707 until now.)
4708
67ef2dca
MD
4709** gdb_print now prints "*** Guile not initialized ***" until Guile initialized
4710
f25f761d
GH
4711* Changes to system call interfaces:
4712
28d77376
GH
4713** The "select" procedure now tests port buffers for the ability to
4714provide input or accept output. Previously only the underlying file
4715descriptors were checked.
4716
bd9e24b3
GH
4717** New variable PIPE_BUF: the maximum number of bytes that can be
4718atomically written to a pipe.
4719
f25f761d
GH
4720** If a facility is not available on the system when Guile is
4721compiled, the corresponding primitive procedure will not be defined.
4722Previously it would have been defined but would throw a system-error
4723exception if called. Exception handlers which catch this case may
4724need minor modification: an error will be thrown with key
4725'unbound-variable instead of 'system-error. Alternatively it's
4726now possible to use `defined?' to check whether the facility is
4727available.
4728
38c1d3c4 4729** Procedures which depend on the timezone should now give the correct
6c0201ad 4730result on systems which cache the TZ environment variable, even if TZ
38c1d3c4
GH
4731is changed without calling tzset.
4732
5c11cc9d
GH
4733* Changes to the networking interfaces:
4734
4735** New functions: htons, ntohs, htonl, ntohl: for converting short and
4736long integers between network and host format. For now, it's not
4737particularly convenient to do this kind of thing, but consider:
4738
4739(define write-network-long
4740 (lambda (value port)
4741 (let ((v (make-uniform-vector 1 1 0)))
4742 (uniform-vector-set! v 0 (htonl value))
4743 (uniform-vector-write v port))))
4744
4745(define read-network-long
4746 (lambda (port)
4747 (let ((v (make-uniform-vector 1 1 0)))
4748 (uniform-vector-read! v port)
4749 (ntohl (uniform-vector-ref v 0)))))
4750
4751** If inet-aton fails, it now throws an error with key 'misc-error
4752instead of 'system-error, since errno is not relevant.
4753
4754** Certain gethostbyname/gethostbyaddr failures now throw errors with
4755specific keys instead of 'system-error. The latter is inappropriate
4756since errno will not have been set. The keys are:
afe5177e 4757'host-not-found, 'try-again, 'no-recovery and 'no-data.
5c11cc9d
GH
4758
4759** sethostent, setnetent, setprotoent, setservent: now take an
4760optional argument STAYOPEN, which specifies whether the database
4761remains open after a database entry is accessed randomly (e.g., using
4762gethostbyname for the hosts database.) The default is #f. Previously
4763#t was always used.
4764
cc36e791 4765\f
43fa9a05
JB
4766Changes since Guile 1.3.2:
4767
0fdcbcaa
MD
4768* Changes to the stand-alone interpreter
4769
4770** Debugger
4771
4772An initial version of the Guile debugger written by Chris Hanson has
4773been added. The debugger is still under development but is included
4774in the distribution anyway since it is already quite useful.
4775
4776Type
4777
4778 (debug)
4779
4780after an error to enter the debugger. Type `help' inside the debugger
4781for a description of available commands.
4782
4783If you prefer to have stack frames numbered and printed in
4784anti-chronological order and prefer up in the stack to be down on the
4785screen as is the case in gdb, you can put
4786
4787 (debug-enable 'backwards)
4788
4789in your .guile startup file. (However, this means that Guile can't
4790use indentation to indicate stack level.)
4791
4792The debugger is autoloaded into Guile at the first use.
4793
4794** Further enhancements to backtraces
4795
4796There is a new debug option `width' which controls the maximum width
4797on the screen of printed stack frames. Fancy printing parameters
4798("level" and "length" as in Common LISP) are adaptively adjusted for
4799each stack frame to give maximum information while still fitting
4800within the bounds. If the stack frame can't be made to fit by
4801adjusting parameters, it is simply cut off at the end. This is marked
4802with a `$'.
4803
4804** Some modules are now only loaded when the repl is started
4805
4806The modules (ice-9 debug), (ice-9 session), (ice-9 threads) and (ice-9
4807regex) are now loaded into (guile-user) only if the repl has been
4808started. The effect is that the startup time for scripts has been
4809reduced to 30% of what it was previously.
4810
4811Correctly written scripts load the modules they require at the top of
4812the file and should not be affected by this change.
4813
ece41168
MD
4814** Hooks are now represented as smobs
4815
6822fe53
MD
4816* Changes to Scheme functions and syntax
4817
0ce204b0
MV
4818** Readline support has changed again.
4819
4820The old (readline-activator) module is gone. Use (ice-9 readline)
4821instead, which now contains all readline functionality. So the code
4822to activate readline is now
4823
4824 (use-modules (ice-9 readline))
4825 (activate-readline)
4826
4827This should work at any time, including from the guile prompt.
4828
5d195868
JB
4829To avoid confusion about the terms of Guile's license, please only
4830enable readline for your personal use; please don't make it the
4831default for others. Here is why we make this rather odd-sounding
4832request:
4833
4834Guile is normally licensed under a weakened form of the GNU General
4835Public License, which allows you to link code with Guile without
4836placing that code under the GPL. This exception is important to some
4837people.
4838
4839However, since readline is distributed under the GNU General Public
4840License, when you link Guile with readline, either statically or
4841dynamically, you effectively change Guile's license to the strict GPL.
4842Whenever you link any strictly GPL'd code into Guile, uses of Guile
4843which are normally permitted become forbidden. This is a rather
4844non-obvious consequence of the licensing terms.
4845
4846So, to make sure things remain clear, please let people choose for
4847themselves whether to link GPL'd libraries like readline with Guile.
4848
25b0654e
JB
4849** regexp-substitute/global has changed slightly, but incompatibly.
4850
4851If you include a function in the item list, the string of the match
4852object it receives is the same string passed to
4853regexp-substitute/global, not some suffix of that string.
4854Correspondingly, the match's positions are relative to the entire
4855string, not the suffix.
4856
4857If the regexp can match the empty string, the way matches are chosen
4858from the string has changed. regexp-substitute/global recognizes the
4859same set of matches that list-matches does; see below.
4860
4861** New function: list-matches REGEXP STRING [FLAGS]
4862
4863Return a list of match objects, one for every non-overlapping, maximal
4864match of REGEXP in STRING. The matches appear in left-to-right order.
4865list-matches only reports matches of the empty string if there are no
4866other matches which begin on, end at, or include the empty match's
4867position.
4868
4869If present, FLAGS is passed as the FLAGS argument to regexp-exec.
4870
4871** New function: fold-matches REGEXP STRING INIT PROC [FLAGS]
4872
4873For each match of REGEXP in STRING, apply PROC to the match object,
4874and the last value PROC returned, or INIT for the first call. Return
4875the last value returned by PROC. We apply PROC to the matches as they
4876appear from left to right.
4877
4878This function recognizes matches according to the same criteria as
4879list-matches.
4880
4881Thus, you could define list-matches like this:
4882
4883 (define (list-matches regexp string . flags)
4884 (reverse! (apply fold-matches regexp string '() cons flags)))
4885
4886If present, FLAGS is passed as the FLAGS argument to regexp-exec.
4887
bc848f7f
MD
4888** Hooks
4889
4890*** New function: hook? OBJ
4891
4892Return #t if OBJ is a hook, otherwise #f.
4893
ece41168
MD
4894*** New function: make-hook-with-name NAME [ARITY]
4895
4896Return a hook with name NAME and arity ARITY. The default value for
4897ARITY is 0. The only effect of NAME is that it will appear when the
4898hook object is printed to ease debugging.
4899
bc848f7f
MD
4900*** New function: hook-empty? HOOK
4901
4902Return #t if HOOK doesn't contain any procedures, otherwise #f.
4903
4904*** New function: hook->list HOOK
4905
4906Return a list of the procedures that are called when run-hook is
4907applied to HOOK.
4908
b074884f
JB
4909** `map' signals an error if its argument lists are not all the same length.
4910
4911This is the behavior required by R5RS, so this change is really a bug
4912fix. But it seems to affect a lot of people's code, so we're
4913mentioning it here anyway.
4914
6822fe53
MD
4915** Print-state handling has been made more transparent
4916
4917Under certain circumstances, ports are represented as a port with an
4918associated print state. Earlier, this pair was represented as a pair
4919(see "Some magic has been added to the printer" below). It is now
4920indistinguishable (almost; see `get-print-state') from a port on the
4921user level.
4922
4923*** New function: port-with-print-state OUTPUT-PORT PRINT-STATE
4924
4925Return a new port with the associated print state PRINT-STATE.
4926
4927*** New function: get-print-state OUTPUT-PORT
4928
4929Return the print state associated with this port if it exists,
4930otherwise return #f.
4931
340a8770 4932*** New function: directory-stream? OBJECT
77242ff9 4933
340a8770 4934Returns true iff OBJECT is a directory stream --- the sort of object
77242ff9
GH
4935returned by `opendir'.
4936
0fdcbcaa
MD
4937** New function: using-readline?
4938
4939Return #t if readline is in use in the current repl.
4940
26405bc1
MD
4941** structs will be removed in 1.4
4942
4943Structs will be replaced in Guile 1.4. We will merge GOOPS into Guile
4944and use GOOPS objects as the fundamental record type.
4945
49199eaa
MD
4946* Changes to the scm_ interface
4947
26405bc1
MD
4948** structs will be removed in 1.4
4949
4950The entire current struct interface (struct.c, struct.h) will be
4951replaced in Guile 1.4. We will merge GOOPS into libguile and use
4952GOOPS objects as the fundamental record type.
4953
49199eaa
MD
4954** The internal representation of subr's has changed
4955
4956Instead of giving a hint to the subr name, the CAR field of the subr
4957now contains an index to a subr entry in scm_subr_table.
4958
4959*** New variable: scm_subr_table
4960
4961An array of subr entries. A subr entry contains the name, properties
4962and documentation associated with the subr. The properties and
4963documentation slots are not yet used.
4964
4965** A new scheme for "forwarding" calls to a builtin to a generic function
4966
4967It is now possible to extend the functionality of some Guile
4968primitives by letting them defer a call to a GOOPS generic function on
240ed66f 4969argument mismatch. This means that there is no loss of efficiency in
daf516d6 4970normal evaluation.
49199eaa
MD
4971
4972Example:
4973
daf516d6 4974 (use-modules (oop goops)) ; Must be GOOPS version 0.2.
49199eaa
MD
4975 (define-method + ((x <string>) (y <string>))
4976 (string-append x y))
4977
86a4d62e
MD
4978+ will still be as efficient as usual in numerical calculations, but
4979can also be used for concatenating strings.
49199eaa 4980
86a4d62e 4981Who will be the first one to extend Guile's numerical tower to
daf516d6
MD
4982rationals? :) [OK, there a few other things to fix before this can
4983be made in a clean way.]
49199eaa
MD
4984
4985*** New snarf macros for defining primitives: SCM_GPROC, SCM_GPROC1
4986
4987 New macro: SCM_GPROC (CNAME, SNAME, REQ, OPT, VAR, CFUNC, GENERIC)
4988
4989 New macro: SCM_GPROC1 (CNAME, SNAME, TYPE, CFUNC, GENERIC)
4990
d02cafe7 4991These do the same job as SCM_PROC and SCM_PROC1, but they also define
49199eaa
MD
4992a variable GENERIC which can be used by the dispatch macros below.
4993
4994[This is experimental code which may change soon.]
4995
4996*** New macros for forwarding control to a generic on arg type error
4997
4998 New macro: SCM_WTA_DISPATCH_1 (GENERIC, ARG1, POS, SUBR)
4999
5000 New macro: SCM_WTA_DISPATCH_2 (GENERIC, ARG1, ARG2, POS, SUBR)
5001
5002These correspond to the scm_wta function call, and have the same
5003behaviour until the user has called the GOOPS primitive
5004`enable-primitive-generic!'. After that, these macros will apply the
5005generic function GENERIC to the argument(s) instead of calling
5006scm_wta.
5007
5008[This is experimental code which may change soon.]
5009
5010*** New macros for argument testing with generic dispatch
5011
5012 New macro: SCM_GASSERT1 (COND, GENERIC, ARG1, POS, SUBR)
5013
5014 New macro: SCM_GASSERT2 (COND, GENERIC, ARG1, ARG2, POS, SUBR)
5015
5016These correspond to the SCM_ASSERT macro, but will defer control to
5017GENERIC on error after `enable-primitive-generic!' has been called.
5018
5019[This is experimental code which may change soon.]
5020
5021** New function: SCM scm_eval_body (SCM body, SCM env)
5022
5023Evaluates the body of a special form.
5024
5025** The internal representation of struct's has changed
5026
5027Previously, four slots were allocated for the procedure(s) of entities
5028and operators. The motivation for this representation had to do with
5029the structure of the evaluator, the wish to support tail-recursive
5030generic functions, and efficiency. Since the generic function
5031dispatch mechanism has changed, there is no longer a need for such an
5032expensive representation, and the representation has been simplified.
5033
5034This should not make any difference for most users.
5035
5036** GOOPS support has been cleaned up.
5037
5038Some code has been moved from eval.c to objects.c and code in both of
5039these compilation units has been cleaned up and better structured.
5040
5041*** New functions for applying generic functions
5042
5043 New function: SCM scm_apply_generic (GENERIC, ARGS)
5044 New function: SCM scm_call_generic_0 (GENERIC)
5045 New function: SCM scm_call_generic_1 (GENERIC, ARG1)
5046 New function: SCM scm_call_generic_2 (GENERIC, ARG1, ARG2)
5047 New function: SCM scm_call_generic_3 (GENERIC, ARG1, ARG2, ARG3)
5048
ece41168
MD
5049** Deprecated function: scm_make_named_hook
5050
5051It is now replaced by:
5052
5053** New function: SCM scm_create_hook (const char *name, int arity)
5054
5055Creates a hook in the same way as make-hook above but also
5056binds a variable named NAME to it.
5057
5058This is the typical way of creating a hook from C code.
5059
5060Currently, the variable is created in the "current" module.
5061This might change when we get the new module system.
5062
5063[The behaviour is identical to scm_make_named_hook.]
5064
5065
43fa9a05 5066\f
f3227c7a
JB
5067Changes since Guile 1.3:
5068
6ca345f3
JB
5069* Changes to mailing lists
5070
5071** Some of the Guile mailing lists have moved to sourceware.cygnus.com.
5072
5073See the README file to find current addresses for all the Guile
5074mailing lists.
5075
d77fb593
JB
5076* Changes to the distribution
5077
1d335863
JB
5078** Readline support is no longer included with Guile by default.
5079
5080Based on the different license terms of Guile and Readline, we
5081concluded that Guile should not *by default* cause the linking of
5082Readline into an application program. Readline support is now offered
5083as a separate module, which is linked into an application only when
5084you explicitly specify it.
5085
5086Although Guile is GNU software, its distribution terms add a special
5087exception to the usual GNU General Public License (GPL). Guile's
5088license includes a clause that allows you to link Guile with non-free
5089programs. We add this exception so as not to put Guile at a
5090disadvantage vis-a-vis other extensibility packages that support other
5091languages.
5092
5093In contrast, the GNU Readline library is distributed under the GNU
5094General Public License pure and simple. This means that you may not
5095link Readline, even dynamically, into an application unless it is
5096distributed under a free software license that is compatible the GPL.
5097
5098Because of this difference in distribution terms, an application that
5099can use Guile may not be able to use Readline. Now users will be
5100explicitly offered two independent decisions about the use of these
5101two packages.
d77fb593 5102
0e8a8468
MV
5103You can activate the readline support by issuing
5104
5105 (use-modules (readline-activator))
5106 (activate-readline)
5107
5108from your ".guile" file, for example.
5109
e4eae9b1
MD
5110* Changes to the stand-alone interpreter
5111
67ad463a
MD
5112** All builtins now print as primitives.
5113Previously builtin procedures not belonging to the fundamental subr
5114types printed as #<compiled closure #<primitive-procedure gsubr-apply>>.
5115Now, they print as #<primitive-procedure NAME>.
5116
5117** Backtraces slightly more intelligible.
5118gsubr-apply and macro transformer application frames no longer appear
5119in backtraces.
5120
69c6acbb
JB
5121* Changes to Scheme functions and syntax
5122
2a52b429
MD
5123** Guile now correctly handles internal defines by rewriting them into
5124their equivalent letrec. Previously, internal defines would
5125incrementally add to the innermost environment, without checking
5126whether the restrictions specified in RnRS were met. This lead to the
5127correct behaviour when these restriction actually were met, but didn't
5128catch all illegal uses. Such an illegal use could lead to crashes of
5129the Guile interpreter or or other unwanted results. An example of
5130incorrect internal defines that made Guile behave erratically:
5131
5132 (let ()
5133 (define a 1)
5134 (define (b) a)
5135 (define c (1+ (b)))
5136 (define d 3)
5137
5138 (b))
5139
5140 => 2
5141
5142The problem with this example is that the definition of `c' uses the
5143value of `b' directly. This confuses the meoization machine of Guile
5144so that the second call of `b' (this time in a larger environment that
5145also contains bindings for `c' and `d') refers to the binding of `c'
5146instead of `a'. You could also make Guile crash with a variation on
5147this theme:
5148
5149 (define (foo flag)
5150 (define a 1)
5151 (define (b flag) (if flag a 1))
5152 (define c (1+ (b flag)))
5153 (define d 3)
5154
5155 (b #t))
5156
5157 (foo #f)
5158 (foo #t)
5159
5160From now on, Guile will issue an `Unbound variable: b' error message
5161for both examples.
5162
36d3d540
MD
5163** Hooks
5164
5165A hook contains a list of functions which should be called on
5166particular occasions in an existing program. Hooks are used for
5167customization.
5168
5169A window manager might have a hook before-window-map-hook. The window
5170manager uses the function run-hooks to call all functions stored in
5171before-window-map-hook each time a window is mapped. The user can
5172store functions in the hook using add-hook!.
5173
5174In Guile, hooks are first class objects.
5175
5176*** New function: make-hook [N_ARGS]
5177
5178Return a hook for hook functions which can take N_ARGS arguments.
5179The default value for N_ARGS is 0.
5180
ad91d6c3
MD
5181(See also scm_make_named_hook below.)
5182
36d3d540
MD
5183*** New function: add-hook! HOOK PROC [APPEND_P]
5184
5185Put PROC at the beginning of the list of functions stored in HOOK.
5186If APPEND_P is supplied, and non-false, put PROC at the end instead.
5187
5188PROC must be able to take the number of arguments specified when the
5189hook was created.
5190
5191If PROC already exists in HOOK, then remove it first.
5192
5193*** New function: remove-hook! HOOK PROC
5194
5195Remove PROC from the list of functions in HOOK.
5196
5197*** New function: reset-hook! HOOK
5198
5199Clear the list of hook functions stored in HOOK.
5200
5201*** New function: run-hook HOOK ARG1 ...
5202
5203Run all hook functions stored in HOOK with arguments ARG1 ... .
5204The number of arguments supplied must correspond to the number given
5205when the hook was created.
5206
56a19408
MV
5207** The function `dynamic-link' now takes optional keyword arguments.
5208 The only keyword argument that is currently defined is `:global
5209 BOOL'. With it, you can control whether the shared library will be
5210 linked in global mode or not. In global mode, the symbols from the
5211 linked library can be used to resolve references from other
5212 dynamically linked libraries. In non-global mode, the linked
5213 library is essentially invisible and can only be accessed via
5214 `dynamic-func', etc. The default is now to link in global mode.
5215 Previously, the default has been non-global mode.
5216
5217 The `#:global' keyword is only effective on platforms that support
5218 the dlopen family of functions.
5219
ad226f25 5220** New function `provided?'
b7e13f65
JB
5221
5222 - Function: provided? FEATURE
5223 Return true iff FEATURE is supported by this installation of
5224 Guile. FEATURE must be a symbol naming a feature; the global
5225 variable `*features*' is a list of available features.
5226
ad226f25
JB
5227** Changes to the module (ice-9 expect):
5228
5229*** The expect-strings macro now matches `$' in a regular expression
5230 only at a line-break or end-of-file by default. Previously it would
ab711359
JB
5231 match the end of the string accumulated so far. The old behaviour
5232 can be obtained by setting the variable `expect-strings-exec-flags'
5233 to 0.
ad226f25
JB
5234
5235*** The expect-strings macro now uses a variable `expect-strings-exec-flags'
5236 for the regexp-exec flags. If `regexp/noteol' is included, then `$'
5237 in a regular expression will still match before a line-break or
5238 end-of-file. The default is `regexp/noteol'.
5239
6c0201ad 5240*** The expect-strings macro now uses a variable
ad226f25
JB
5241 `expect-strings-compile-flags' for the flags to be supplied to
5242 `make-regexp'. The default is `regexp/newline', which was previously
5243 hard-coded.
5244
5245*** The expect macro now supplies two arguments to a match procedure:
ab711359
JB
5246 the current accumulated string and a flag to indicate whether
5247 end-of-file has been reached. Previously only the string was supplied.
5248 If end-of-file is reached, the match procedure will be called an
5249 additional time with the same accumulated string as the previous call
5250 but with the flag set.
ad226f25 5251
b7e13f65
JB
5252** New module (ice-9 format), implementing the Common Lisp `format' function.
5253
5254This code, and the documentation for it that appears here, was
5255borrowed from SLIB, with minor adaptations for Guile.
5256
5257 - Function: format DESTINATION FORMAT-STRING . ARGUMENTS
5258 An almost complete implementation of Common LISP format description
5259 according to the CL reference book `Common LISP' from Guy L.
5260 Steele, Digital Press. Backward compatible to most of the
5261 available Scheme format implementations.
5262
5263 Returns `#t', `#f' or a string; has side effect of printing
5264 according to FORMAT-STRING. If DESTINATION is `#t', the output is
5265 to the current output port and `#t' is returned. If DESTINATION
5266 is `#f', a formatted string is returned as the result of the call.
5267 NEW: If DESTINATION is a string, DESTINATION is regarded as the
5268 format string; FORMAT-STRING is then the first argument and the
5269 output is returned as a string. If DESTINATION is a number, the
5270 output is to the current error port if available by the
5271 implementation. Otherwise DESTINATION must be an output port and
5272 `#t' is returned.
5273
5274 FORMAT-STRING must be a string. In case of a formatting error
5275 format returns `#f' and prints a message on the current output or
5276 error port. Characters are output as if the string were output by
5277 the `display' function with the exception of those prefixed by a
5278 tilde (~). For a detailed description of the FORMAT-STRING syntax
5279 please consult a Common LISP format reference manual. For a test
5280 suite to verify this format implementation load `formatst.scm'.
5281 Please send bug reports to `lutzeb@cs.tu-berlin.de'.
5282
5283 Note: `format' is not reentrant, i.e. only one `format'-call may
5284 be executed at a time.
5285
5286
5287*** Format Specification (Format version 3.0)
5288
5289 Please consult a Common LISP format reference manual for a detailed
5290description of the format string syntax. For a demonstration of the
5291implemented directives see `formatst.scm'.
5292
5293 This implementation supports directive parameters and modifiers (`:'
5294and `@' characters). Multiple parameters must be separated by a comma
5295(`,'). Parameters can be numerical parameters (positive or negative),
5296character parameters (prefixed by a quote character (`''), variable
5297parameters (`v'), number of rest arguments parameter (`#'), empty and
5298default parameters. Directive characters are case independent. The
5299general form of a directive is:
5300
5301DIRECTIVE ::= ~{DIRECTIVE-PARAMETER,}[:][@]DIRECTIVE-CHARACTER
5302
5303DIRECTIVE-PARAMETER ::= [ [-|+]{0-9}+ | 'CHARACTER | v | # ]
5304
5305*** Implemented CL Format Control Directives
5306
5307 Documentation syntax: Uppercase characters represent the
5308corresponding control directive characters. Lowercase characters
5309represent control directive parameter descriptions.
5310
5311`~A'
5312 Any (print as `display' does).
5313 `~@A'
5314 left pad.
5315
5316 `~MINCOL,COLINC,MINPAD,PADCHARA'
5317 full padding.
5318
5319`~S'
5320 S-expression (print as `write' does).
5321 `~@S'
5322 left pad.
5323
5324 `~MINCOL,COLINC,MINPAD,PADCHARS'
5325 full padding.
5326
5327`~D'
5328 Decimal.
5329 `~@D'
5330 print number sign always.
5331
5332 `~:D'
5333 print comma separated.
5334
5335 `~MINCOL,PADCHAR,COMMACHARD'
5336 padding.
5337
5338`~X'
5339 Hexadecimal.
5340 `~@X'
5341 print number sign always.
5342
5343 `~:X'
5344 print comma separated.
5345
5346 `~MINCOL,PADCHAR,COMMACHARX'
5347 padding.
5348
5349`~O'
5350 Octal.
5351 `~@O'
5352 print number sign always.
5353
5354 `~:O'
5355 print comma separated.
5356
5357 `~MINCOL,PADCHAR,COMMACHARO'
5358 padding.
5359
5360`~B'
5361 Binary.
5362 `~@B'
5363 print number sign always.
5364
5365 `~:B'
5366 print comma separated.
5367
5368 `~MINCOL,PADCHAR,COMMACHARB'
5369 padding.
5370
5371`~NR'
5372 Radix N.
5373 `~N,MINCOL,PADCHAR,COMMACHARR'
5374 padding.
5375
5376`~@R'
5377 print a number as a Roman numeral.
5378
5379`~:@R'
5380 print a number as an "old fashioned" Roman numeral.
5381
5382`~:R'
5383 print a number as an ordinal English number.
5384
5385`~:@R'
5386 print a number as a cardinal English number.
5387
5388`~P'
5389 Plural.
5390 `~@P'
5391 prints `y' and `ies'.
5392
5393 `~:P'
5394 as `~P but jumps 1 argument backward.'
5395
5396 `~:@P'
5397 as `~@P but jumps 1 argument backward.'
5398
5399`~C'
5400 Character.
5401 `~@C'
5402 prints a character as the reader can understand it (i.e. `#\'
5403 prefixing).
5404
5405 `~:C'
5406 prints a character as emacs does (eg. `^C' for ASCII 03).
5407
5408`~F'
5409 Fixed-format floating-point (prints a flonum like MMM.NNN).
5410 `~WIDTH,DIGITS,SCALE,OVERFLOWCHAR,PADCHARF'
5411 `~@F'
5412 If the number is positive a plus sign is printed.
5413
5414`~E'
5415 Exponential floating-point (prints a flonum like MMM.NNN`E'EE).
5416 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARE'
5417 `~@E'
5418 If the number is positive a plus sign is printed.
5419
5420`~G'
5421 General floating-point (prints a flonum either fixed or
5422 exponential).
5423 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARG'
5424 `~@G'
5425 If the number is positive a plus sign is printed.
5426
5427`~$'
5428 Dollars floating-point (prints a flonum in fixed with signs
5429 separated).
5430 `~DIGITS,SCALE,WIDTH,PADCHAR$'
5431 `~@$'
5432 If the number is positive a plus sign is printed.
5433
5434 `~:@$'
5435 A sign is always printed and appears before the padding.
5436
5437 `~:$'
5438 The sign appears before the padding.
5439
5440`~%'
5441 Newline.
5442 `~N%'
5443 print N newlines.
5444
5445`~&'
5446 print newline if not at the beginning of the output line.
5447 `~N&'
5448 prints `~&' and then N-1 newlines.
5449
5450`~|'
5451 Page Separator.
5452 `~N|'
5453 print N page separators.
5454
5455`~~'
5456 Tilde.
5457 `~N~'
5458 print N tildes.
5459
5460`~'<newline>
5461 Continuation Line.
5462 `~:'<newline>
5463 newline is ignored, white space left.
5464
5465 `~@'<newline>
5466 newline is left, white space ignored.
5467
5468`~T'
5469 Tabulation.
5470 `~@T'
5471 relative tabulation.
5472
5473 `~COLNUM,COLINCT'
5474 full tabulation.
5475
5476`~?'
5477 Indirection (expects indirect arguments as a list).
5478 `~@?'
5479 extracts indirect arguments from format arguments.
5480
5481`~(STR~)'
5482 Case conversion (converts by `string-downcase').
5483 `~:(STR~)'
5484 converts by `string-capitalize'.
5485
5486 `~@(STR~)'
5487 converts by `string-capitalize-first'.
5488
5489 `~:@(STR~)'
5490 converts by `string-upcase'.
5491
5492`~*'
5493 Argument Jumping (jumps 1 argument forward).
5494 `~N*'
5495 jumps N arguments forward.
5496
5497 `~:*'
5498 jumps 1 argument backward.
5499
5500 `~N:*'
5501 jumps N arguments backward.
5502
5503 `~@*'
5504 jumps to the 0th argument.
5505
5506 `~N@*'
5507 jumps to the Nth argument (beginning from 0)
5508
5509`~[STR0~;STR1~;...~;STRN~]'
5510 Conditional Expression (numerical clause conditional).
5511 `~N['
5512 take argument from N.
5513
5514 `~@['
5515 true test conditional.
5516
5517 `~:['
5518 if-else-then conditional.
5519
5520 `~;'
5521 clause separator.
5522
5523 `~:;'
5524 default clause follows.
5525
5526`~{STR~}'
5527 Iteration (args come from the next argument (a list)).
5528 `~N{'
5529 at most N iterations.
5530
5531 `~:{'
5532 args from next arg (a list of lists).
5533
5534 `~@{'
5535 args from the rest of arguments.
5536
5537 `~:@{'
5538 args from the rest args (lists).
5539
5540`~^'
5541 Up and out.
5542 `~N^'
5543 aborts if N = 0
5544
5545 `~N,M^'
5546 aborts if N = M
5547
5548 `~N,M,K^'
5549 aborts if N <= M <= K
5550
5551*** Not Implemented CL Format Control Directives
5552
5553`~:A'
5554 print `#f' as an empty list (see below).
5555
5556`~:S'
5557 print `#f' as an empty list (see below).
5558
5559`~<~>'
5560 Justification.
5561
5562`~:^'
5563 (sorry I don't understand its semantics completely)
5564
5565*** Extended, Replaced and Additional Control Directives
5566
5567`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHD'
5568`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHX'
5569`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHO'
5570`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHB'
5571`~N,MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHR'
5572 COMMAWIDTH is the number of characters between two comma
5573 characters.
5574
5575`~I'
5576 print a R4RS complex number as `~F~@Fi' with passed parameters for
5577 `~F'.
5578
5579`~Y'
5580 Pretty print formatting of an argument for scheme code lists.
5581
5582`~K'
5583 Same as `~?.'
5584
5585`~!'
5586 Flushes the output if format DESTINATION is a port.
5587
5588`~_'
5589 Print a `#\space' character
5590 `~N_'
5591 print N `#\space' characters.
5592
5593`~/'
5594 Print a `#\tab' character
5595 `~N/'
5596 print N `#\tab' characters.
5597
5598`~NC'
5599 Takes N as an integer representation for a character. No arguments
5600 are consumed. N is converted to a character by `integer->char'. N
5601 must be a positive decimal number.
5602
5603`~:S'
5604 Print out readproof. Prints out internal objects represented as
5605 `#<...>' as strings `"#<...>"' so that the format output can always
5606 be processed by `read'.
5607
5608`~:A'
5609 Print out readproof. Prints out internal objects represented as
5610 `#<...>' as strings `"#<...>"' so that the format output can always
5611 be processed by `read'.
5612
5613`~Q'
5614 Prints information and a copyright notice on the format
5615 implementation.
5616 `~:Q'
5617 prints format version.
5618
5619`~F, ~E, ~G, ~$'
5620 may also print number strings, i.e. passing a number as a string
5621 and format it accordingly.
5622
5623*** Configuration Variables
5624
5625 The format module exports some configuration variables to suit the
5626systems and users needs. There should be no modification necessary for
5627the configuration that comes with Guile. Format detects automatically
5628if the running scheme system implements floating point numbers and
5629complex numbers.
5630
5631format:symbol-case-conv
5632 Symbols are converted by `symbol->string' so the case type of the
5633 printed symbols is implementation dependent.
5634 `format:symbol-case-conv' is a one arg closure which is either
5635 `#f' (no conversion), `string-upcase', `string-downcase' or
5636 `string-capitalize'. (default `#f')
5637
5638format:iobj-case-conv
5639 As FORMAT:SYMBOL-CASE-CONV but applies for the representation of
5640 implementation internal objects. (default `#f')
5641
5642format:expch
5643 The character prefixing the exponent value in `~E' printing.
5644 (default `#\E')
5645
5646*** Compatibility With Other Format Implementations
5647
5648SLIB format 2.x:
5649 See `format.doc'.
5650
5651SLIB format 1.4:
5652 Downward compatible except for padding support and `~A', `~S',
5653 `~P', `~X' uppercase printing. SLIB format 1.4 uses C-style
5654 `printf' padding support which is completely replaced by the CL
5655 `format' padding style.
5656
5657MIT C-Scheme 7.1:
5658 Downward compatible except for `~', which is not documented
5659 (ignores all characters inside the format string up to a newline
5660 character). (7.1 implements `~a', `~s', ~NEWLINE, `~~', `~%',
5661 numerical and variable parameters and `:/@' modifiers in the CL
5662 sense).
5663
5664Elk 1.5/2.0:
5665 Downward compatible except for `~A' and `~S' which print in
5666 uppercase. (Elk implements `~a', `~s', `~~', and `~%' (no
5667 directive parameters or modifiers)).
5668
5669Scheme->C 01nov91:
5670 Downward compatible except for an optional destination parameter:
5671 S2C accepts a format call without a destination which returns a
5672 formatted string. This is equivalent to a #f destination in S2C.
5673 (S2C implements `~a', `~s', `~c', `~%', and `~~' (no directive
5674 parameters or modifiers)).
5675
5676
e7d37b0a 5677** Changes to string-handling functions.
b7e13f65 5678
e7d37b0a 5679These functions were added to support the (ice-9 format) module, above.
b7e13f65 5680
e7d37b0a
JB
5681*** New function: string-upcase STRING
5682*** New function: string-downcase STRING
b7e13f65 5683
e7d37b0a
JB
5684These are non-destructive versions of the existing string-upcase! and
5685string-downcase! functions.
b7e13f65 5686
e7d37b0a
JB
5687*** New function: string-capitalize! STRING
5688*** New function: string-capitalize STRING
5689
5690These functions convert the first letter of each word in the string to
5691upper case. Thus:
5692
5693 (string-capitalize "howdy there")
5694 => "Howdy There"
5695
5696As with the other functions, string-capitalize! modifies the string in
5697place, while string-capitalize returns a modified copy of its argument.
5698
5699*** New function: string-ci->symbol STRING
5700
5701Return a symbol whose name is STRING, but having the same case as if
5702the symbol had be read by `read'.
5703
5704Guile can be configured to be sensitive or insensitive to case
5705differences in Scheme identifiers. If Guile is case-insensitive, all
5706symbols are converted to lower case on input. The `string-ci->symbol'
5707function returns a symbol whose name in STRING, transformed as Guile
5708would if STRING were input.
5709
5710*** New function: substring-move! STRING1 START END STRING2 START
5711
5712Copy the substring of STRING1 from START (inclusive) to END
5713(exclusive) to STRING2 at START. STRING1 and STRING2 may be the same
5714string, and the source and destination areas may overlap; in all
5715cases, the function behaves as if all the characters were copied
5716simultanously.
5717
6c0201ad 5718*** Extended functions: substring-move-left! substring-move-right!
e7d37b0a
JB
5719
5720These functions now correctly copy arbitrarily overlapping substrings;
5721they are both synonyms for substring-move!.
b7e13f65 5722
b7e13f65 5723
deaceb4e
JB
5724** New module (ice-9 getopt-long), with the function `getopt-long'.
5725
5726getopt-long is a function for parsing command-line arguments in a
5727manner consistent with other GNU programs.
5728
5729(getopt-long ARGS GRAMMAR)
5730Parse the arguments ARGS according to the argument list grammar GRAMMAR.
5731
5732ARGS should be a list of strings. Its first element should be the
5733name of the program; subsequent elements should be the arguments
5734that were passed to the program on the command line. The
5735`program-arguments' procedure returns a list of this form.
5736
5737GRAMMAR is a list of the form:
5738((OPTION (PROPERTY VALUE) ...) ...)
5739
5740Each OPTION should be a symbol. `getopt-long' will accept a
5741command-line option named `--OPTION'.
5742Each option can have the following (PROPERTY VALUE) pairs:
5743
5744 (single-char CHAR) --- Accept `-CHAR' as a single-character
5745 equivalent to `--OPTION'. This is how to specify traditional
5746 Unix-style flags.
5747 (required? BOOL) --- If BOOL is true, the option is required.
5748 getopt-long will raise an error if it is not found in ARGS.
5749 (value BOOL) --- If BOOL is #t, the option accepts a value; if
5750 it is #f, it does not; and if it is the symbol
5751 `optional', the option may appear in ARGS with or
6c0201ad 5752 without a value.
deaceb4e
JB
5753 (predicate FUNC) --- If the option accepts a value (i.e. you
5754 specified `(value #t)' for this option), then getopt
5755 will apply FUNC to the value, and throw an exception
5756 if it returns #f. FUNC should be a procedure which
5757 accepts a string and returns a boolean value; you may
5758 need to use quasiquotes to get it into GRAMMAR.
5759
5760The (PROPERTY VALUE) pairs may occur in any order, but each
5761property may occur only once. By default, options do not have
5762single-character equivalents, are not required, and do not take
5763values.
5764
5765In ARGS, single-character options may be combined, in the usual
5766Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option
5767accepts values, then it must be the last option in the
5768combination; the value is the next argument. So, for example, using
5769the following grammar:
5770 ((apples (single-char #\a))
5771 (blimps (single-char #\b) (value #t))
5772 (catalexis (single-char #\c) (value #t)))
5773the following argument lists would be acceptable:
5774 ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values
5775 for "blimps" and "catalexis")
5776 ("-ab" "bang" "-c" "couth") (same)
5777 ("-ac" "couth" "-b" "bang") (same)
5778 ("-abc" "couth" "bang") (an error, since `-b' is not the
5779 last option in its combination)
5780
5781If an option's value is optional, then `getopt-long' decides
5782whether it has a value by looking at what follows it in ARGS. If
5783the next element is a string, and it does not appear to be an
5784option itself, then that string is the option's value.
5785
5786The value of a long option can appear as the next element in ARGS,
5787or it can follow the option name, separated by an `=' character.
5788Thus, using the same grammar as above, the following argument lists
5789are equivalent:
5790 ("--apples" "Braeburn" "--blimps" "Goodyear")
5791 ("--apples=Braeburn" "--blimps" "Goodyear")
5792 ("--blimps" "Goodyear" "--apples=Braeburn")
5793
5794If the option "--" appears in ARGS, argument parsing stops there;
5795subsequent arguments are returned as ordinary arguments, even if
5796they resemble options. So, in the argument list:
5797 ("--apples" "Granny Smith" "--" "--blimp" "Goodyear")
5798`getopt-long' will recognize the `apples' option as having the
5799value "Granny Smith", but it will not recognize the `blimp'
5800option; it will return the strings "--blimp" and "Goodyear" as
5801ordinary argument strings.
5802
5803The `getopt-long' function returns the parsed argument list as an
5804assocation list, mapping option names --- the symbols from GRAMMAR
5805--- onto their values, or #t if the option does not accept a value.
5806Unused options do not appear in the alist.
5807
5808All arguments that are not the value of any option are returned
5809as a list, associated with the empty list.
5810
5811`getopt-long' throws an exception if:
5812- it finds an unrecognized option in ARGS
5813- a required option is omitted
5814- an option that requires an argument doesn't get one
5815- an option that doesn't accept an argument does get one (this can
5816 only happen using the long option `--opt=value' syntax)
5817- an option predicate fails
5818
5819So, for example:
5820
5821(define grammar
5822 `((lockfile-dir (required? #t)
5823 (value #t)
5824 (single-char #\k)
5825 (predicate ,file-is-directory?))
5826 (verbose (required? #f)
5827 (single-char #\v)
5828 (value #f))
5829 (x-includes (single-char #\x))
6c0201ad 5830 (rnet-server (single-char #\y)
deaceb4e
JB
5831 (predicate ,string?))))
5832
6c0201ad 5833(getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include"
deaceb4e
JB
5834 "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3")
5835 grammar)
5836=> ((() "foo1" "-fred" "foo2" "foo3")
5837 (rnet-server . "lamprod")
5838 (x-includes . "/usr/include")
5839 (lockfile-dir . "/tmp")
5840 (verbose . #t))
5841
5842** The (ice-9 getopt-gnu-style) module is obsolete; use (ice-9 getopt-long).
5843
5844It will be removed in a few releases.
5845
08394899
MS
5846** New syntax: lambda*
5847** New syntax: define*
6c0201ad 5848** New syntax: define*-public
08394899
MS
5849** New syntax: defmacro*
5850** New syntax: defmacro*-public
6c0201ad 5851Guile now supports optional arguments.
08394899
MS
5852
5853`lambda*', `define*', `define*-public', `defmacro*' and
5854`defmacro*-public' are identical to the non-* versions except that
5855they use an extended type of parameter list that has the following BNF
5856syntax (parentheses are literal, square brackets indicate grouping,
5857and `*', `+' and `?' have the usual meaning):
5858
5859 ext-param-list ::= ( [identifier]* [#&optional [ext-var-decl]+]?
6c0201ad 5860 [#&key [ext-var-decl]+ [#&allow-other-keys]?]?
08394899
MS
5861 [[#&rest identifier]|[. identifier]]? ) | [identifier]
5862
6c0201ad 5863 ext-var-decl ::= identifier | ( identifier expression )
08394899
MS
5864
5865The semantics are best illustrated with the following documentation
5866and examples for `lambda*':
5867
5868 lambda* args . body
5869 lambda extended for optional and keyword arguments
6c0201ad 5870
08394899
MS
5871 lambda* creates a procedure that takes optional arguments. These
5872 are specified by putting them inside brackets at the end of the
5873 paramater list, but before any dotted rest argument. For example,
5874 (lambda* (a b #&optional c d . e) '())
5875 creates a procedure with fixed arguments a and b, optional arguments c
5876 and d, and rest argument e. If the optional arguments are omitted
5877 in a call, the variables for them are unbound in the procedure. This
5878 can be checked with the bound? macro.
5879
5880 lambda* can also take keyword arguments. For example, a procedure
5881 defined like this:
5882 (lambda* (#&key xyzzy larch) '())
5883 can be called with any of the argument lists (#:xyzzy 11)
5884 (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments
5885 are given as keywords are bound to values.
5886
5887 Optional and keyword arguments can also be given default values
5888 which they take on when they are not present in a call, by giving a
5889 two-item list in place of an optional argument, for example in:
6c0201ad 5890 (lambda* (foo #&optional (bar 42) #&key (baz 73)) (list foo bar baz))
08394899
MS
5891 foo is a fixed argument, bar is an optional argument with default
5892 value 42, and baz is a keyword argument with default value 73.
5893 Default value expressions are not evaluated unless they are needed
6c0201ad 5894 and until the procedure is called.
08394899
MS
5895
5896 lambda* now supports two more special parameter list keywords.
5897
5898 lambda*-defined procedures now throw an error by default if a
5899 keyword other than one of those specified is found in the actual
5900 passed arguments. However, specifying #&allow-other-keys
5901 immediately after the kyword argument declarations restores the
5902 previous behavior of ignoring unknown keywords. lambda* also now
5903 guarantees that if the same keyword is passed more than once, the
5904 last one passed is the one that takes effect. For example,
5905 ((lambda* (#&key (heads 0) (tails 0)) (display (list heads tails)))
5906 #:heads 37 #:tails 42 #:heads 99)
5907 would result in (99 47) being displayed.
5908
5909 #&rest is also now provided as a synonym for the dotted syntax rest
5910 argument. The argument lists (a . b) and (a #&rest b) are equivalent in
5911 all respects to lambda*. This is provided for more similarity to DSSSL,
5912 MIT-Scheme and Kawa among others, as well as for refugees from other
5913 Lisp dialects.
5914
5915Further documentation may be found in the optargs.scm file itself.
5916
5917The optional argument module also exports the macros `let-optional',
5918`let-optional*', `let-keywords', `let-keywords*' and `bound?'. These
5919are not documented here because they may be removed in the future, but
5920full documentation is still available in optargs.scm.
5921
2e132553
JB
5922** New syntax: and-let*
5923Guile now supports the `and-let*' form, described in the draft SRFI-2.
5924
5925Syntax: (land* (<clause> ...) <body> ...)
5926Each <clause> should have one of the following forms:
5927 (<variable> <expression>)
5928 (<expression>)
5929 <bound-variable>
5930Each <variable> or <bound-variable> should be an identifier. Each
5931<expression> should be a valid expression. The <body> should be a
5932possibly empty sequence of expressions, like the <body> of a
5933lambda form.
5934
5935Semantics: A LAND* expression is evaluated by evaluating the
5936<expression> or <bound-variable> of each of the <clause>s from
5937left to right. The value of the first <expression> or
5938<bound-variable> that evaluates to a false value is returned; the
5939remaining <expression>s and <bound-variable>s are not evaluated.
5940The <body> forms are evaluated iff all the <expression>s and
5941<bound-variable>s evaluate to true values.
5942
5943The <expression>s and the <body> are evaluated in an environment
5944binding each <variable> of the preceding (<variable> <expression>)
5945clauses to the value of the <expression>. Later bindings
5946shadow earlier bindings.
5947
5948Guile's and-let* macro was contributed by Michael Livshin.
5949
36d3d540
MD
5950** New sorting functions
5951
5952*** New function: sorted? SEQUENCE LESS?
ed8c8636
MD
5953Returns `#t' when the sequence argument is in non-decreasing order
5954according to LESS? (that is, there is no adjacent pair `... x y
5955...' for which `(less? y x)').
5956
5957Returns `#f' when the sequence contains at least one out-of-order
5958pair. It is an error if the sequence is neither a list nor a
5959vector.
5960
36d3d540 5961*** New function: merge LIST1 LIST2 LESS?
ed8c8636
MD
5962LIST1 and LIST2 are sorted lists.
5963Returns the sorted list of all elements in LIST1 and LIST2.
5964
5965Assume that the elements a and b1 in LIST1 and b2 in LIST2 are "equal"
5966in the sense that (LESS? x y) --> #f for x, y in {a, b1, b2},
5967and that a < b1 in LIST1. Then a < b1 < b2 in the result.
5968(Here "<" should read "comes before".)
5969
36d3d540 5970*** New procedure: merge! LIST1 LIST2 LESS?
ed8c8636
MD
5971Merges two lists, re-using the pairs of LIST1 and LIST2 to build
5972the result. If the code is compiled, and LESS? constructs no new
5973pairs, no pairs at all will be allocated. The first pair of the
5974result will be either the first pair of LIST1 or the first pair of
5975LIST2.
5976
36d3d540 5977*** New function: sort SEQUENCE LESS?
ed8c8636
MD
5978Accepts either a list or a vector, and returns a new sequence
5979which is sorted. The new sequence is the same type as the input.
5980Always `(sorted? (sort sequence less?) less?)'. The original
5981sequence is not altered in any way. The new sequence shares its
5982elements with the old one; no elements are copied.
5983
36d3d540 5984*** New procedure: sort! SEQUENCE LESS
ed8c8636
MD
5985Returns its sorted result in the original boxes. No new storage is
5986allocated at all. Proper usage: (set! slist (sort! slist <))
5987
36d3d540 5988*** New function: stable-sort SEQUENCE LESS?
ed8c8636
MD
5989Similar to `sort' but stable. That is, if "equal" elements are
5990ordered a < b in the original sequence, they will have the same order
5991in the result.
5992
36d3d540 5993*** New function: stable-sort! SEQUENCE LESS?
ed8c8636
MD
5994Similar to `sort!' but stable.
5995Uses temporary storage when sorting vectors.
5996
36d3d540 5997*** New functions: sort-list, sort-list!
ed8c8636
MD
5998Added for compatibility with scsh.
5999
36d3d540
MD
6000** New built-in random number support
6001
6002*** New function: random N [STATE]
3e8370c3
MD
6003Accepts a positive integer or real N and returns a number of the
6004same type between zero (inclusive) and N (exclusive). The values
6005returned have a uniform distribution.
6006
6007The optional argument STATE must be of the type produced by
416075f1
MD
6008`copy-random-state' or `seed->random-state'. It defaults to the value
6009of the variable `*random-state*'. This object is used to maintain the
6010state of the pseudo-random-number generator and is altered as a side
6011effect of the `random' operation.
3e8370c3 6012
36d3d540 6013*** New variable: *random-state*
3e8370c3
MD
6014Holds a data structure that encodes the internal state of the
6015random-number generator that `random' uses by default. The nature
6016of this data structure is implementation-dependent. It may be
6017printed out and successfully read back in, but may or may not
6018function correctly as a random-number state object in another
6019implementation.
6020
36d3d540 6021*** New function: copy-random-state [STATE]
3e8370c3
MD
6022Returns a new object of type suitable for use as the value of the
6023variable `*random-state*' and as a second argument to `random'.
6024If argument STATE is given, a copy of it is returned. Otherwise a
6025copy of `*random-state*' is returned.
416075f1 6026
36d3d540 6027*** New function: seed->random-state SEED
416075f1
MD
6028Returns a new object of type suitable for use as the value of the
6029variable `*random-state*' and as a second argument to `random'.
6030SEED is a string or a number. A new state is generated and
6031initialized using SEED.
3e8370c3 6032
36d3d540 6033*** New function: random:uniform [STATE]
3e8370c3
MD
6034Returns an uniformly distributed inexact real random number in the
6035range between 0 and 1.
6036
36d3d540 6037*** New procedure: random:solid-sphere! VECT [STATE]
3e8370c3
MD
6038Fills VECT with inexact real random numbers the sum of whose
6039squares is less than 1.0. Thinking of VECT as coordinates in
6040space of dimension N = `(vector-length VECT)', the coordinates are
6041uniformly distributed within the unit N-shere. The sum of the
6042squares of the numbers is returned. VECT can be either a vector
6043or a uniform vector of doubles.
6044
36d3d540 6045*** New procedure: random:hollow-sphere! VECT [STATE]
3e8370c3
MD
6046Fills VECT with inexact real random numbers the sum of whose squares
6047is equal to 1.0. Thinking of VECT as coordinates in space of
6048dimension n = `(vector-length VECT)', the coordinates are uniformly
6049distributed over the surface of the unit n-shere. VECT can be either
6050a vector or a uniform vector of doubles.
6051
36d3d540 6052*** New function: random:normal [STATE]
3e8370c3
MD
6053Returns an inexact real in a normal distribution with mean 0 and
6054standard deviation 1. For a normal distribution with mean M and
6055standard deviation D use `(+ M (* D (random:normal)))'.
6056
36d3d540 6057*** New procedure: random:normal-vector! VECT [STATE]
3e8370c3
MD
6058Fills VECT with inexact real random numbers which are independent and
6059standard normally distributed (i.e., with mean 0 and variance 1).
6060VECT can be either a vector or a uniform vector of doubles.
6061
36d3d540 6062*** New function: random:exp STATE
3e8370c3
MD
6063Returns an inexact real in an exponential distribution with mean 1.
6064For an exponential distribution with mean U use (* U (random:exp)).
6065
69c6acbb
JB
6066** The range of logand, logior, logxor, logtest, and logbit? have changed.
6067
6068These functions now operate on numbers in the range of a C unsigned
6069long.
6070
6071These functions used to operate on numbers in the range of a C signed
6072long; however, this seems inappropriate, because Guile integers don't
6073overflow.
6074
ba4ee0d6
MD
6075** New function: make-guardian
6076This is an implementation of guardians as described in
6077R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a
6078Generation-Based Garbage Collector" ACM SIGPLAN Conference on
6079Programming Language Design and Implementation, June 1993
6080ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz
6081
88ceea5c
MD
6082** New functions: delq1!, delv1!, delete1!
6083These procedures behave similar to delq! and friends but delete only
6084one object if at all.
6085
55254a6a
MD
6086** New function: unread-string STRING PORT
6087Unread STRING to PORT, that is, push it back onto the port so that
6088next read operation will work on the pushed back characters.
6089
6090** unread-char can now be called multiple times
6091If unread-char is called multiple times, the unread characters will be
6092read again in last-in first-out order.
6093
9e97c52d
GH
6094** the procedures uniform-array-read! and uniform-array-write! now
6095work on any kind of port, not just ports which are open on a file.
6096
b074884f 6097** Now 'l' in a port mode requests line buffering.
9e97c52d 6098
69bc9ff3
GH
6099** The procedure truncate-file now works on string ports as well
6100as file ports. If the size argument is omitted, the current
1b9c3dae 6101file position is used.
9e97c52d 6102
c94577b4 6103** new procedure: seek PORT/FDES OFFSET WHENCE
9e97c52d
GH
6104The arguments are the same as for the old fseek procedure, but it
6105works on string ports as well as random-access file ports.
6106
6107** the fseek procedure now works on string ports, since it has been
c94577b4 6108redefined using seek.
9e97c52d
GH
6109
6110** the setvbuf procedure now uses a default size if mode is _IOFBF and
6111size is not supplied.
6112
6113** the newline procedure no longer flushes the port if it's not
6114line-buffered: previously it did if it was the current output port.
6115
6116** open-pipe and close-pipe are no longer primitive procedures, but
6117an emulation can be obtained using `(use-modules (ice-9 popen))'.
6118
6119** the freopen procedure has been removed.
6120
6121** new procedure: drain-input PORT
6122Drains PORT's read buffers (including any pushed-back characters)
6123and returns the contents as a single string.
6124
67ad463a 6125** New function: map-in-order PROC LIST1 LIST2 ...
d41b3904
MD
6126Version of `map' which guarantees that the procedure is applied to the
6127lists in serial order.
6128
67ad463a
MD
6129** Renamed `serial-array-copy!' and `serial-array-map!' to
6130`array-copy-in-order!' and `array-map-in-order!'. The old names are
6131now obsolete and will go away in release 1.5.
6132
cf7132b3 6133** New syntax: collect BODY1 ...
d41b3904
MD
6134Version of `begin' which returns a list of the results of the body
6135forms instead of the result of the last body form. In contrast to
cf7132b3 6136`begin', `collect' allows an empty body.
d41b3904 6137
e4eae9b1
MD
6138** New functions: read-history FILENAME, write-history FILENAME
6139Read/write command line history from/to file. Returns #t on success
6140and #f if an error occured.
6141
d21ffe26
JB
6142** `ls' and `lls' in module (ice-9 ls) now handle no arguments.
6143
6144These procedures return a list of definitions available in the specified
6145argument, a relative module reference. In the case of no argument,
6146`(current-module)' is now consulted for definitions to return, instead
6147of simply returning #f, the former behavior.
6148
f8c9d497
JB
6149** The #/ syntax for lists is no longer supported.
6150
6151Earlier versions of Scheme accepted this syntax, but printed a
6152warning.
6153
6154** Guile no longer consults the SCHEME_LOAD_PATH environment variable.
6155
6156Instead, you should set GUILE_LOAD_PATH to tell Guile where to find
6157modules.
6158
3ffc7a36
MD
6159* Changes to the gh_ interface
6160
6161** gh_scm2doubles
6162
6163Now takes a second argument which is the result array. If this
6164pointer is NULL, a new array is malloced (the old behaviour).
6165
6166** gh_chars2byvect, gh_shorts2svect, gh_floats2fvect, gh_scm2chars,
6167 gh_scm2shorts, gh_scm2longs, gh_scm2floats
6168
6169New functions.
6170
3e8370c3
MD
6171* Changes to the scm_ interface
6172
ad91d6c3
MD
6173** Function: scm_make_named_hook (char* name, int n_args)
6174
6175Creates a hook in the same way as make-hook above but also
6176binds a variable named NAME to it.
6177
6178This is the typical way of creating a hook from C code.
6179
ece41168
MD
6180Currently, the variable is created in the "current" module. This
6181might change when we get the new module system.
ad91d6c3 6182
16a5a9a4
MD
6183** The smob interface
6184
6185The interface for creating smobs has changed. For documentation, see
6186data-rep.info (made from guile-core/doc/data-rep.texi).
6187
6188*** Deprecated function: SCM scm_newsmob (scm_smobfuns *)
6189
6190>>> This function will be removed in 1.3.4. <<<
6191
6192It is replaced by:
6193
6194*** Function: SCM scm_make_smob_type (const char *name, scm_sizet size)
6195This function adds a new smob type, named NAME, with instance size
6196SIZE to the system. The return value is a tag that is used in
6197creating instances of the type. If SIZE is 0, then no memory will
6198be allocated when instances of the smob are created, and nothing
6199will be freed by the default free function.
6c0201ad 6200
16a5a9a4
MD
6201*** Function: void scm_set_smob_mark (long tc, SCM (*mark) (SCM))
6202This function sets the smob marking procedure for the smob type
6203specified by the tag TC. TC is the tag returned by
6204`scm_make_smob_type'.
6205
6206*** Function: void scm_set_smob_free (long tc, SCM (*mark) (SCM))
6207This function sets the smob freeing procedure for the smob type
6208specified by the tag TC. TC is the tag returned by
6209`scm_make_smob_type'.
6210
6211*** Function: void scm_set_smob_print (tc, print)
6212
6213 - Function: void scm_set_smob_print (long tc,
6214 scm_sizet (*print) (SCM,
6215 SCM,
6216 scm_print_state *))
6217
6218This function sets the smob printing procedure for the smob type
6219specified by the tag TC. TC is the tag returned by
6220`scm_make_smob_type'.
6221
6222*** Function: void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM))
6223This function sets the smob equality-testing predicate for the
6224smob type specified by the tag TC. TC is the tag returned by
6225`scm_make_smob_type'.
6226
6227*** Macro: void SCM_NEWSMOB (SCM var, long tc, void *data)
6228Make VALUE contain a smob instance of the type with type code TC and
6229smob data DATA. VALUE must be previously declared as C type `SCM'.
6230
6231*** Macro: fn_returns SCM_RETURN_NEWSMOB (long tc, void *data)
6232This macro expands to a block of code that creates a smob instance
6233of the type with type code TC and smob data DATA, and returns that
6234`SCM' value. It should be the last piece of code in a block.
6235
9e97c52d
GH
6236** The interfaces for using I/O ports and implementing port types
6237(ptobs) have changed significantly. The new interface is based on
6238shared access to buffers and a new set of ptob procedures.
6239
16a5a9a4
MD
6240*** scm_newptob has been removed
6241
6242It is replaced by:
6243
6244*** Function: SCM scm_make_port_type (type_name, fill_buffer, write_flush)
6245
6246- Function: SCM scm_make_port_type (char *type_name,
6247 int (*fill_buffer) (SCM port),
6248 void (*write_flush) (SCM port));
6249
6250Similarly to the new smob interface, there is a set of function
6251setters by which the user can customize the behaviour of his port
544e9093 6252type. See ports.h (scm_set_port_XXX).
16a5a9a4 6253
9e97c52d
GH
6254** scm_strport_to_string: New function: creates a new string from
6255a string port's buffer.
6256
3e8370c3
MD
6257** Plug in interface for random number generators
6258The variable `scm_the_rng' in random.c contains a value and three
6259function pointers which together define the current random number
6260generator being used by the Scheme level interface and the random
6261number library functions.
6262
6263The user is free to replace the default generator with the generator
6264of his own choice.
6265
6266*** Variable: size_t scm_the_rng.rstate_size
6267The size of the random state type used by the current RNG
6268measured in chars.
6269
6270*** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE)
6271Given the random STATE, return 32 random bits.
6272
6273*** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N)
6274Seed random state STATE using string S of length N.
6275
6276*** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE)
6277Given random state STATE, return a malloced copy.
6278
6279** Default RNG
6280The default RNG is the MWC (Multiply With Carry) random number
6281generator described by George Marsaglia at the Department of
6282Statistics and Supercomputer Computations Research Institute, The
6283Florida State University (http://stat.fsu.edu/~geo).
6284
6285It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and
6286passes all tests in the DIEHARD test suite
6287(http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits
6288costs one multiply and one add on platforms which either supports long
6289longs (gcc does this on most systems) or have 64 bit longs. The cost
6290is four multiply on other systems but this can be optimized by writing
6291scm_i_uniform32 in assembler.
6292
6293These functions are provided through the scm_the_rng interface for use
6294by libguile and the application.
6295
6296*** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE)
6297Given the random STATE, return 32 random bits.
6298Don't use this function directly. Instead go through the plugin
6299interface (see "Plug in interface" above).
6300
6301*** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N)
6302Initialize STATE using SEED of length N.
6303
6304*** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE)
6305Return a malloc:ed copy of STATE. This function can easily be re-used
6306in the interfaces to other RNGs.
6307
6308** Random number library functions
6309These functions use the current RNG through the scm_the_rng interface.
6310It might be a good idea to use these functions from your C code so
6311that only one random generator is used by all code in your program.
6312
259529f2 6313The default random state is stored in:
3e8370c3
MD
6314
6315*** Variable: SCM scm_var_random_state
6316Contains the vcell of the Scheme variable "*random-state*" which is
6317used as default state by all random number functions in the Scheme
6318level interface.
6319
6320Example:
6321
259529f2 6322 double x = scm_c_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state)));
3e8370c3 6323
259529f2
MD
6324*** Function: scm_rstate *scm_c_default_rstate (void)
6325This is a convenience function which returns the value of
6326scm_var_random_state. An error message is generated if this value
6327isn't a random state.
6328
6329*** Function: scm_rstate *scm_c_make_rstate (char *SEED, int LENGTH)
6330Make a new random state from the string SEED of length LENGTH.
6331
6332It is generally not a good idea to use multiple random states in a
6333program. While subsequent random numbers generated from one random
6334state are guaranteed to be reasonably independent, there is no such
6335guarantee for numbers generated from different random states.
6336
6337*** Macro: unsigned long scm_c_uniform32 (scm_rstate *STATE)
6338Return 32 random bits.
6339
6340*** Function: double scm_c_uniform01 (scm_rstate *STATE)
3e8370c3
MD
6341Return a sample from the uniform(0,1) distribution.
6342
259529f2 6343*** Function: double scm_c_normal01 (scm_rstate *STATE)
3e8370c3
MD
6344Return a sample from the normal(0,1) distribution.
6345
259529f2 6346*** Function: double scm_c_exp1 (scm_rstate *STATE)
3e8370c3
MD
6347Return a sample from the exp(1) distribution.
6348
259529f2
MD
6349*** Function: unsigned long scm_c_random (scm_rstate *STATE, unsigned long M)
6350Return a sample from the discrete uniform(0,M) distribution.
6351
6352*** Function: SCM scm_c_random_bignum (scm_rstate *STATE, SCM M)
3e8370c3 6353Return a sample from the discrete uniform(0,M) distribution.
259529f2 6354M must be a bignum object. The returned value may be an INUM.
3e8370c3 6355
9e97c52d 6356
f3227c7a 6357\f
d23bbf3e 6358Changes in Guile 1.3 (released Monday, October 19, 1998):
c484bf7f
JB
6359
6360* Changes to the distribution
6361
e2d6569c
JB
6362** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
6363To avoid conflicts, programs should name environment variables after
6364themselves, except when there's a common practice establishing some
6365other convention.
6366
6367For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
6368giving the former precedence, and printing a warning message if the
6369latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
6370
6371** The header files related to multi-byte characters have been removed.
6372They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
6373which referred to these explicitly will probably need to be rewritten,
6374since the support for the variant string types has been removed; see
6375below.
6376
6377** The header files append.h and sequences.h have been removed. These
6378files implemented non-R4RS operations which would encourage
6379non-portable programming style and less easy-to-read code.
3a97e020 6380
c484bf7f
JB
6381* Changes to the stand-alone interpreter
6382
2e368582 6383** New procedures have been added to implement a "batch mode":
ec4ab4fd 6384
2e368582 6385*** Function: batch-mode?
ec4ab4fd
GH
6386
6387 Returns a boolean indicating whether the interpreter is in batch
6388 mode.
6389
2e368582 6390*** Function: set-batch-mode?! ARG
ec4ab4fd
GH
6391
6392 If ARG is true, switches the interpreter to batch mode. The `#f'
6393 case has not been implemented.
6394
2e368582
JB
6395** Guile now provides full command-line editing, when run interactively.
6396To use this feature, you must have the readline library installed.
6397The Guile build process will notice it, and automatically include
6398support for it.
6399
6400The readline library is available via anonymous FTP from any GNU
6401mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
6402
a5d6d578
MD
6403** the-last-stack is now a fluid.
6404
c484bf7f
JB
6405* Changes to the procedure for linking libguile with your programs
6406
71f20534 6407** You can now use the `guile-config' utility to build programs that use Guile.
2e368582 6408
2adfe1c0 6409Guile now includes a command-line utility called `guile-config', which
71f20534
JB
6410can provide information about how to compile and link programs that
6411use Guile.
6412
6413*** `guile-config compile' prints any C compiler flags needed to use Guile.
6414You should include this command's output on the command line you use
6415to compile C or C++ code that #includes the Guile header files. It's
6416usually just a `-I' flag to help the compiler find the Guile headers.
6417
6418
6419*** `guile-config link' prints any linker flags necessary to link with Guile.
8aa5c148 6420
71f20534 6421This command writes to its standard output a list of flags which you
8aa5c148
JB
6422must pass to the linker to link your code against the Guile library.
6423The flags include '-lguile' itself, any other libraries the Guile
6424library depends upon, and any `-L' flags needed to help the linker
6425find those libraries.
2e368582
JB
6426
6427For example, here is a Makefile rule that builds a program named 'foo'
6428from the object files ${FOO_OBJECTS}, and links them against Guile:
6429
6430 foo: ${FOO_OBJECTS}
2adfe1c0 6431 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
2e368582 6432
e2d6569c
JB
6433Previous Guile releases recommended that you use autoconf to detect
6434which of a predefined set of libraries were present on your system.
2adfe1c0 6435It is more robust to use `guile-config', since it records exactly which
e2d6569c
JB
6436libraries the installed Guile library requires.
6437
2adfe1c0
JB
6438This was originally called `build-guile', but was renamed to
6439`guile-config' before Guile 1.3 was released, to be consistent with
6440the analogous script for the GTK+ GUI toolkit, which is called
6441`gtk-config'.
6442
2e368582 6443
8aa5c148
JB
6444** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
6445
6446If you are using the GNU autoconf package to configure your program,
6447you can use the GUILE_FLAGS autoconf macro to call `guile-config'
6448(described above) and gather the necessary values for use in your
6449Makefiles.
6450
6451The GUILE_FLAGS macro expands to configure script code which runs the
6452`guile-config' script, to find out where Guile's header files and
6453libraries are installed. It sets two variables, marked for
6454substitution, as by AC_SUBST.
6455
6456 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
6457 code that uses Guile header files. This is almost always just a
6458 -I flag.
6459
6460 GUILE_LDFLAGS --- flags to pass to the linker to link a
6461 program against Guile. This includes `-lguile' for the Guile
6462 library itself, any libraries that Guile itself requires (like
6463 -lqthreads), and so on. It may also include a -L flag to tell the
6464 compiler where to find the libraries.
6465
6466GUILE_FLAGS is defined in the file guile.m4, in the top-level
6467directory of the Guile distribution. You can copy it into your
6468package's aclocal.m4 file, and then use it in your configure.in file.
6469
6470If you are using the `aclocal' program, distributed with GNU automake,
6471to maintain your aclocal.m4 file, the Guile installation process
6472installs guile.m4 where aclocal will find it. All you need to do is
6473use GUILE_FLAGS in your configure.in file, and then run `aclocal';
6474this will copy the definition of GUILE_FLAGS into your aclocal.m4
6475file.
6476
6477
c484bf7f 6478* Changes to Scheme functions and syntax
7ad3c1e7 6479
02755d59 6480** Multi-byte strings have been removed, as have multi-byte and wide
e2d6569c
JB
6481ports. We felt that these were the wrong approach to
6482internationalization support.
02755d59 6483
2e368582
JB
6484** New function: readline [PROMPT]
6485Read a line from the terminal, and allow the user to edit it,
6486prompting with PROMPT. READLINE provides a large set of Emacs-like
6487editing commands, lets the user recall previously typed lines, and
6488works on almost every kind of terminal, including dumb terminals.
6489
6490READLINE assumes that the cursor is at the beginning of the line when
6491it is invoked. Thus, you can't print a prompt yourself, and then call
6492READLINE; you need to package up your prompt as a string, pass it to
6493the function, and let READLINE print the prompt itself. This is
6494because READLINE needs to know the prompt's screen width.
6495
8cd57bd0
JB
6496For Guile to provide this function, you must have the readline
6497library, version 2.1 or later, installed on your system. Readline is
6498available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
6499any GNU mirror site.
2e368582
JB
6500
6501See also ADD-HISTORY function.
6502
6503** New function: add-history STRING
6504Add STRING as the most recent line in the history used by the READLINE
6505command. READLINE does not add lines to the history itself; you must
6506call ADD-HISTORY to make previous input available to the user.
6507
8cd57bd0
JB
6508** The behavior of the read-line function has changed.
6509
6510This function now uses standard C library functions to read the line,
6511for speed. This means that it doesn not respect the value of
6512scm-line-incrementors; it assumes that lines are delimited with
6513#\newline.
6514
6515(Note that this is read-line, the function that reads a line of text
6516from a port, not readline, the function that reads a line from a
6517terminal, providing full editing capabilities.)
6518
1a0106ef
JB
6519** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
6520
6521This module provides some simple argument parsing. It exports one
6522function:
6523
6524Function: getopt-gnu-style ARG-LS
6525 Parse a list of program arguments into an alist of option
6526 descriptions.
6527
6528 Each item in the list of program arguments is examined to see if
6529 it meets the syntax of a GNU long-named option. An argument like
6530 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
6531 returned alist, where MUMBLE is a keyword object with the same
6532 name as the argument. An argument like `--MUMBLE=FROB' produces
6533 an element of the form (MUMBLE . FROB), where FROB is a string.
6534
6535 As a special case, the returned alist also contains a pair whose
6536 car is the symbol `rest'. The cdr of this pair is a list
6537 containing all the items in the argument list that are not options
6538 of the form mentioned above.
6539
6540 The argument `--' is treated specially: all items in the argument
6541 list appearing after such an argument are not examined, and are
6542 returned in the special `rest' list.
6543
6544 This function does not parse normal single-character switches.
6545 You will need to parse them out of the `rest' list yourself.
6546
8cd57bd0
JB
6547** The read syntax for byte vectors and short vectors has changed.
6548
6549Instead of #bytes(...), write #y(...).
6550
6551Instead of #short(...), write #h(...).
6552
6553This may seem nutty, but, like the other uniform vectors, byte vectors
6554and short vectors want to have the same print and read syntax (and,
6555more basic, want to have read syntax!). Changing the read syntax to
6556use multiple characters after the hash sign breaks with the
6557conventions used in R5RS and the conventions used for the other
6558uniform vectors. It also introduces complexity in the current reader,
6559both on the C and Scheme levels. (The Right solution is probably to
6560change the syntax and prototypes for uniform vectors entirely.)
6561
6562
6563** The new module (ice-9 session) provides useful interactive functions.
6564
6565*** New procedure: (apropos REGEXP OPTION ...)
6566
6567Display a list of top-level variables whose names match REGEXP, and
6568the modules they are imported from. Each OPTION should be one of the
6569following symbols:
6570
6571 value --- Show the value of each matching variable.
6572 shadow --- Show bindings shadowed by subsequently imported modules.
6573 full --- Same as both `shadow' and `value'.
6574
6575For example:
6576
6577 guile> (apropos "trace" 'full)
6578 debug: trace #<procedure trace args>
6579 debug: untrace #<procedure untrace args>
6580 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
6581 the-scm-module: before-backtrace-hook ()
6582 the-scm-module: backtrace #<primitive-procedure backtrace>
6583 the-scm-module: after-backtrace-hook ()
6584 the-scm-module: has-shown-backtrace-hint? #f
6c0201ad 6585 guile>
8cd57bd0
JB
6586
6587** There are new functions and syntax for working with macros.
6588
6589Guile implements macros as a special object type. Any variable whose
6590top-level binding is a macro object acts as a macro. The macro object
6591specifies how the expression should be transformed before evaluation.
6592
6593*** Macro objects now print in a reasonable way, resembling procedures.
6594
6595*** New function: (macro? OBJ)
6596True iff OBJ is a macro object.
6597
6598*** New function: (primitive-macro? OBJ)
6599Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
6600macro transformers, implemented in eval.c rather than Scheme code.
6601
dbdd0c16
JB
6602Why do we have this function?
6603- For symmetry with procedure? and primitive-procedure?,
6604- to allow custom print procedures to tell whether a macro is
6605 primitive, and display it differently, and
6606- to allow compilers and user-written evaluators to distinguish
6607 builtin special forms from user-defined ones, which could be
6608 compiled.
6609
8cd57bd0
JB
6610*** New function: (macro-type OBJ)
6611Return a value indicating what kind of macro OBJ is. Possible return
6612values are:
6613
6614 The symbol `syntax' --- a macro created by procedure->syntax.
6615 The symbol `macro' --- a macro created by procedure->macro.
6616 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
6c0201ad 6617 The boolean #f --- if OBJ is not a macro object.
8cd57bd0
JB
6618
6619*** New function: (macro-name MACRO)
6620Return the name of the macro object MACRO's procedure, as returned by
6621procedure-name.
6622
6623*** New function: (macro-transformer MACRO)
6624Return the transformer procedure for MACRO.
6625
6626*** New syntax: (use-syntax MODULE ... TRANSFORMER)
6627
6628Specify a new macro expander to use in the current module. Each
6629MODULE is a module name, with the same meaning as in the `use-modules'
6630form; each named module's exported bindings are added to the current
6631top-level environment. TRANSFORMER is an expression evaluated in the
6632resulting environment which must yield a procedure to use as the
6633module's eval transformer: every expression evaluated in this module
6634is passed to this function, and the result passed to the Guile
6c0201ad 6635interpreter.
8cd57bd0
JB
6636
6637*** macro-eval! is removed. Use local-eval instead.
29521173 6638
8d9dcb3c
MV
6639** Some magic has been added to the printer to better handle user
6640written printing routines (like record printers, closure printers).
6641
6642The problem is that these user written routines must have access to
7fbd77df 6643the current `print-state' to be able to handle fancy things like
8d9dcb3c
MV
6644detection of circular references. These print-states have to be
6645passed to the builtin printing routines (display, write, etc) to
6646properly continue the print chain.
6647
6648We didn't want to change all existing print code so that it
8cd57bd0 6649explicitly passes thru a print state in addition to a port. Instead,
8d9dcb3c
MV
6650we extented the possible values that the builtin printing routines
6651accept as a `port'. In addition to a normal port, they now also take
6652a pair of a normal port and a print-state. Printing will go to the
6653port and the print-state will be used to control the detection of
6654circular references, etc. If the builtin function does not care for a
6655print-state, it is simply ignored.
6656
6657User written callbacks are now called with such a pair as their
6658`port', but because every function now accepts this pair as a PORT
6659argument, you don't have to worry about that. In fact, it is probably
6660safest to not check for these pairs.
6661
6662However, it is sometimes necessary to continue a print chain on a
6663different port, for example to get a intermediate string
6664representation of the printed value, mangle that string somehow, and
6665then to finally print the mangled string. Use the new function
6666
6667 inherit-print-state OLD-PORT NEW-PORT
6668
6669for this. It constructs a new `port' that prints to NEW-PORT but
6670inherits the print-state of OLD-PORT.
6671
ef1ea498
MD
6672** struct-vtable-offset renamed to vtable-offset-user
6673
6674** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
6675
e478dffa
MD
6676** There is now a third optional argument to make-vtable-vtable
6677 (and fourth to make-struct) when constructing new types (vtables).
6678 This argument initializes field vtable-index-printer of the vtable.
ef1ea498 6679
4851dc57
MV
6680** The detection of circular references has been extended to structs.
6681That is, a structure that -- in the process of being printed -- prints
6682itself does not lead to infinite recursion.
6683
6684** There is now some basic support for fluids. Please read
6685"libguile/fluid.h" to find out more. It is accessible from Scheme with
6686the following functions and macros:
6687
9c3fb66f
MV
6688Function: make-fluid
6689
6690 Create a new fluid object. Fluids are not special variables or
6691 some other extension to the semantics of Scheme, but rather
6692 ordinary Scheme objects. You can store them into variables (that
6693 are still lexically scoped, of course) or into any other place you
6694 like. Every fluid has a initial value of `#f'.
04c76b58 6695
9c3fb66f 6696Function: fluid? OBJ
04c76b58 6697
9c3fb66f 6698 Test whether OBJ is a fluid.
04c76b58 6699
9c3fb66f
MV
6700Function: fluid-ref FLUID
6701Function: fluid-set! FLUID VAL
04c76b58
MV
6702
6703 Access/modify the fluid FLUID. Modifications are only visible
6704 within the current dynamic root (that includes threads).
6705
9c3fb66f
MV
6706Function: with-fluids* FLUIDS VALUES THUNK
6707
6708 FLUIDS is a list of fluids and VALUES a corresponding list of
6709 values for these fluids. Before THUNK gets called the values are
6c0201ad 6710 installed in the fluids and the old values of the fluids are
9c3fb66f
MV
6711 saved in the VALUES list. When the flow of control leaves THUNK
6712 or reenters it, the values get swapped again. You might think of
6713 this as a `safe-fluid-excursion'. Note that the VALUES list is
6714 modified by `with-fluids*'.
6715
6716Macro: with-fluids ((FLUID VALUE) ...) FORM ...
6717
6718 The same as `with-fluids*' but with a different syntax. It looks
6719 just like `let', but both FLUID and VALUE are evaluated. Remember,
6720 fluids are not special variables but ordinary objects. FLUID
6721 should evaluate to a fluid.
04c76b58 6722
e2d6569c 6723** Changes to system call interfaces:
64d01d13 6724
e2d6569c 6725*** close-port, close-input-port and close-output-port now return a
64d01d13
GH
6726boolean instead of an `unspecified' object. #t means that the port
6727was successfully closed, while #f means it was already closed. It is
6728also now possible for these procedures to raise an exception if an
6729error occurs (some errors from write can be delayed until close.)
6730
e2d6569c 6731*** the first argument to chmod, fcntl, ftell and fseek can now be a
6afcd3b2
GH
6732file descriptor.
6733
e2d6569c 6734*** the third argument to fcntl is now optional.
6afcd3b2 6735
e2d6569c 6736*** the first argument to chown can now be a file descriptor or a port.
6afcd3b2 6737
e2d6569c 6738*** the argument to stat can now be a port.
6afcd3b2 6739
e2d6569c 6740*** The following new procedures have been added (most use scsh
64d01d13
GH
6741interfaces):
6742
e2d6569c 6743*** procedure: close PORT/FD
ec4ab4fd
GH
6744 Similar to close-port (*note close-port: Closing Ports.), but also
6745 works on file descriptors. A side effect of closing a file
6746 descriptor is that any ports using that file descriptor are moved
6747 to a different file descriptor and have their revealed counts set
6748 to zero.
6749
e2d6569c 6750*** procedure: port->fdes PORT
ec4ab4fd
GH
6751 Returns the integer file descriptor underlying PORT. As a side
6752 effect the revealed count of PORT is incremented.
6753
e2d6569c 6754*** procedure: fdes->ports FDES
ec4ab4fd
GH
6755 Returns a list of existing ports which have FDES as an underlying
6756 file descriptor, without changing their revealed counts.
6757
e2d6569c 6758*** procedure: fdes->inport FDES
ec4ab4fd
GH
6759 Returns an existing input port which has FDES as its underlying
6760 file descriptor, if one exists, and increments its revealed count.
6761 Otherwise, returns a new input port with a revealed count of 1.
6762
e2d6569c 6763*** procedure: fdes->outport FDES
ec4ab4fd
GH
6764 Returns an existing output port which has FDES as its underlying
6765 file descriptor, if one exists, and increments its revealed count.
6766 Otherwise, returns a new output port with a revealed count of 1.
6767
6768 The next group of procedures perform a `dup2' system call, if NEWFD
6769(an integer) is supplied, otherwise a `dup'. The file descriptor to be
6770duplicated can be supplied as an integer or contained in a port. The
64d01d13
GH
6771type of value returned varies depending on which procedure is used.
6772
ec4ab4fd
GH
6773 All procedures also have the side effect when performing `dup2' that
6774any ports using NEWFD are moved to a different file descriptor and have
64d01d13
GH
6775their revealed counts set to zero.
6776
e2d6569c 6777*** procedure: dup->fdes PORT/FD [NEWFD]
ec4ab4fd 6778 Returns an integer file descriptor.
64d01d13 6779
e2d6569c 6780*** procedure: dup->inport PORT/FD [NEWFD]
ec4ab4fd 6781 Returns a new input port using the new file descriptor.
64d01d13 6782
e2d6569c 6783*** procedure: dup->outport PORT/FD [NEWFD]
ec4ab4fd 6784 Returns a new output port using the new file descriptor.
64d01d13 6785
e2d6569c 6786*** procedure: dup PORT/FD [NEWFD]
ec4ab4fd
GH
6787 Returns a new port if PORT/FD is a port, with the same mode as the
6788 supplied port, otherwise returns an integer file descriptor.
64d01d13 6789
e2d6569c 6790*** procedure: dup->port PORT/FD MODE [NEWFD]
ec4ab4fd
GH
6791 Returns a new port using the new file descriptor. MODE supplies a
6792 mode string for the port (*note open-file: File Ports.).
64d01d13 6793
e2d6569c 6794*** procedure: setenv NAME VALUE
ec4ab4fd
GH
6795 Modifies the environment of the current process, which is also the
6796 default environment inherited by child processes.
64d01d13 6797
ec4ab4fd
GH
6798 If VALUE is `#f', then NAME is removed from the environment.
6799 Otherwise, the string NAME=VALUE is added to the environment,
6800 replacing any existing string with name matching NAME.
64d01d13 6801
ec4ab4fd 6802 The return value is unspecified.
956055a9 6803
e2d6569c 6804*** procedure: truncate-file OBJ SIZE
6afcd3b2
GH
6805 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
6806 can be a string containing a file name or an integer file
6807 descriptor or port open for output on the file. The underlying
6808 system calls are `truncate' and `ftruncate'.
6809
6810 The return value is unspecified.
6811
e2d6569c 6812*** procedure: setvbuf PORT MODE [SIZE]
7a6f1ffa
GH
6813 Set the buffering mode for PORT. MODE can be:
6814 `_IONBF'
6815 non-buffered
6816
6817 `_IOLBF'
6818 line buffered
6819
6820 `_IOFBF'
6821 block buffered, using a newly allocated buffer of SIZE bytes.
6822 However if SIZE is zero or unspecified, the port will be made
6823 non-buffered.
6824
6825 This procedure should not be used after I/O has been performed with
6826 the port.
6827
6828 Ports are usually block buffered by default, with a default buffer
6829 size. Procedures e.g., *Note open-file: File Ports, which accept a
6830 mode string allow `0' to be added to request an unbuffered port.
6831
e2d6569c 6832*** procedure: fsync PORT/FD
6afcd3b2
GH
6833 Copies any unwritten data for the specified output file descriptor
6834 to disk. If PORT/FD is a port, its buffer is flushed before the
6835 underlying file descriptor is fsync'd. The return value is
6836 unspecified.
6837
e2d6569c 6838*** procedure: open-fdes PATH FLAGS [MODES]
6afcd3b2
GH
6839 Similar to `open' but returns a file descriptor instead of a port.
6840
e2d6569c 6841*** procedure: execle PATH ENV [ARG] ...
6afcd3b2
GH
6842 Similar to `execl', but the environment of the new process is
6843 specified by ENV, which must be a list of strings as returned by
6844 the `environ' procedure.
6845
6846 This procedure is currently implemented using the `execve' system
6847 call, but we call it `execle' because of its Scheme calling
6848 interface.
6849
e2d6569c 6850*** procedure: strerror ERRNO
ec4ab4fd
GH
6851 Returns the Unix error message corresponding to ERRNO, an integer.
6852
e2d6569c 6853*** procedure: primitive-exit [STATUS]
6afcd3b2
GH
6854 Terminate the current process without unwinding the Scheme stack.
6855 This is would typically be useful after a fork. The exit status
6856 is STATUS if supplied, otherwise zero.
6857
e2d6569c 6858*** procedure: times
6afcd3b2
GH
6859 Returns an object with information about real and processor time.
6860 The following procedures accept such an object as an argument and
6861 return a selected component:
6862
6863 `tms:clock'
6864 The current real time, expressed as time units relative to an
6865 arbitrary base.
6866
6867 `tms:utime'
6868 The CPU time units used by the calling process.
6869
6870 `tms:stime'
6871 The CPU time units used by the system on behalf of the
6872 calling process.
6873
6874 `tms:cutime'
6875 The CPU time units used by terminated child processes of the
6876 calling process, whose status has been collected (e.g., using
6877 `waitpid').
6878
6879 `tms:cstime'
6880 Similarly, the CPU times units used by the system on behalf of
6881 terminated child processes.
7ad3c1e7 6882
e2d6569c
JB
6883** Removed: list-length
6884** Removed: list-append, list-append!
6885** Removed: list-reverse, list-reverse!
6886
6887** array-map renamed to array-map!
6888
6889** serial-array-map renamed to serial-array-map!
6890
660f41fa
MD
6891** catch doesn't take #f as first argument any longer
6892
6893Previously, it was possible to pass #f instead of a key to `catch'.
6894That would cause `catch' to pass a jump buffer object to the procedure
6895passed as second argument. The procedure could then use this jump
6896buffer objekt as an argument to throw.
6897
6898This mechanism has been removed since its utility doesn't motivate the
6899extra complexity it introduces.
6900
332d00f6
JB
6901** The `#/' notation for lists now provokes a warning message from Guile.
6902This syntax will be removed from Guile in the near future.
6903
6904To disable the warning message, set the GUILE_HUSH environment
6905variable to any non-empty value.
6906
8cd57bd0
JB
6907** The newline character now prints as `#\newline', following the
6908normal Scheme notation, not `#\nl'.
6909
c484bf7f
JB
6910* Changes to the gh_ interface
6911
8986901b
JB
6912** The gh_enter function now takes care of loading the Guile startup files.
6913gh_enter works by calling scm_boot_guile; see the remarks below.
6914
5424b4f7
MD
6915** Function: void gh_write (SCM x)
6916
6917Write the printed representation of the scheme object x to the current
6918output port. Corresponds to the scheme level `write'.
6919
3a97e020
MD
6920** gh_list_length renamed to gh_length.
6921
8d6787b6
MG
6922** vector handling routines
6923
6924Several major changes. In particular, gh_vector() now resembles
6925(vector ...) (with a caveat -- see manual), and gh_make_vector() now
956328d2
MG
6926exists and behaves like (make-vector ...). gh_vset() and gh_vref()
6927have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
8d6787b6
MG
6928vector-related gh_ functions have been implemented.
6929
7fee59bd
MG
6930** pair and list routines
6931
6932Implemented several of the R4RS pair and list functions that were
6933missing.
6934
171422a9
MD
6935** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
6936
6937New function. Converts double arrays back and forth between Scheme
6938and C.
6939
c484bf7f
JB
6940* Changes to the scm_ interface
6941
8986901b
JB
6942** The function scm_boot_guile now takes care of loading the startup files.
6943
6944Guile's primary initialization function, scm_boot_guile, now takes
6945care of loading `boot-9.scm', in the `ice-9' module, to initialize
6946Guile, define the module system, and put together some standard
6947bindings. It also loads `init.scm', which is intended to hold
6948site-specific initialization code.
6949
6950Since Guile cannot operate properly until boot-9.scm is loaded, there
6951is no reason to separate loading boot-9.scm from Guile's other
6952initialization processes.
6953
6954This job used to be done by scm_compile_shell_switches, which didn't
6955make much sense; in particular, it meant that people using Guile for
6956non-shell-like applications had to jump through hoops to get Guile
6957initialized properly.
6958
6959** The function scm_compile_shell_switches no longer loads the startup files.
6960Now, Guile always loads the startup files, whenever it is initialized;
6961see the notes above for scm_boot_guile and scm_load_startup_files.
6962
6963** Function: scm_load_startup_files
6964This new function takes care of loading Guile's initialization file
6965(`boot-9.scm'), and the site initialization file, `init.scm'. Since
6966this is always called by the Guile initialization process, it's
6967probably not too useful to call this yourself, but it's there anyway.
6968
87148d9e
JB
6969** The semantics of smob marking have changed slightly.
6970
6971The smob marking function (the `mark' member of the scm_smobfuns
6972structure) is no longer responsible for setting the mark bit on the
6973smob. The generic smob handling code in the garbage collector will
6974set this bit. The mark function need only ensure that any other
6975objects the smob refers to get marked.
6976
6977Note that this change means that the smob's GC8MARK bit is typically
6978already set upon entry to the mark function. Thus, marking functions
6979which look like this:
6980
6981 {
6982 if (SCM_GC8MARKP (ptr))
6983 return SCM_BOOL_F;
6984 SCM_SETGC8MARK (ptr);
6985 ... mark objects to which the smob refers ...
6986 }
6987
6988are now incorrect, since they will return early, and fail to mark any
6989other objects the smob refers to. Some code in the Guile library used
6990to work this way.
6991
1cf84ea5
JB
6992** The semantics of the I/O port functions in scm_ptobfuns have changed.
6993
6994If you have implemented your own I/O port type, by writing the
6995functions required by the scm_ptobfuns and then calling scm_newptob,
6996you will need to change your functions slightly.
6997
6998The functions in a scm_ptobfuns structure now expect the port itself
6999as their argument; they used to expect the `stream' member of the
7000port's scm_port_table structure. This allows functions in an
7001scm_ptobfuns structure to easily access the port's cell (and any flags
7002it its CAR), and the port's scm_port_table structure.
7003
7004Guile now passes the I/O port itself as the `port' argument in the
7005following scm_ptobfuns functions:
7006
7007 int (*free) (SCM port);
7008 int (*fputc) (int, SCM port);
7009 int (*fputs) (char *, SCM port);
7010 scm_sizet (*fwrite) SCM_P ((char *ptr,
7011 scm_sizet size,
7012 scm_sizet nitems,
7013 SCM port));
7014 int (*fflush) (SCM port);
7015 int (*fgetc) (SCM port);
7016 int (*fclose) (SCM port);
7017
7018The interfaces to the `mark', `print', `equalp', and `fgets' methods
7019are unchanged.
7020
7021If you have existing code which defines its own port types, it is easy
7022to convert your code to the new interface; simply apply SCM_STREAM to
7023the port argument to yield the value you code used to expect.
7024
7025Note that since both the port and the stream have the same type in the
7026C code --- they are both SCM values --- the C compiler will not remind
7027you if you forget to update your scm_ptobfuns functions.
7028
7029
933a7411
MD
7030** Function: int scm_internal_select (int fds,
7031 SELECT_TYPE *rfds,
7032 SELECT_TYPE *wfds,
7033 SELECT_TYPE *efds,
7034 struct timeval *timeout);
7035
7036This is a replacement for the `select' function provided by the OS.
7037It enables I/O blocking and sleeping to happen for one cooperative
7038thread without blocking other threads. It also avoids busy-loops in
7039these situations. It is intended that all I/O blocking and sleeping
7040will finally go through this function. Currently, this function is
7041only available on systems providing `gettimeofday' and `select'.
7042
5424b4f7
MD
7043** Function: SCM scm_internal_stack_catch (SCM tag,
7044 scm_catch_body_t body,
7045 void *body_data,
7046 scm_catch_handler_t handler,
7047 void *handler_data)
7048
7049A new sibling to the other two C level `catch' functions
7050scm_internal_catch and scm_internal_lazy_catch. Use it if you want
7051the stack to be saved automatically into the variable `the-last-stack'
7052(scm_the_last_stack_var) on error. This is necessary if you want to
7053use advanced error reporting, such as calling scm_display_error and
7054scm_display_backtrace. (They both take a stack object as argument.)
7055
df366c26
MD
7056** Function: SCM scm_spawn_thread (scm_catch_body_t body,
7057 void *body_data,
7058 scm_catch_handler_t handler,
7059 void *handler_data)
7060
7061Spawns a new thread. It does a job similar to
7062scm_call_with_new_thread but takes arguments more suitable when
7063spawning threads from application C code.
7064
88482b31
MD
7065** The hook scm_error_callback has been removed. It was originally
7066intended as a way for the user to install his own error handler. But
7067that method works badly since it intervenes between throw and catch,
7068thereby changing the semantics of expressions like (catch #t ...).
7069The correct way to do it is to use one of the C level catch functions
7070in throw.c: scm_internal_catch/lazy_catch/stack_catch.
7071
3a97e020
MD
7072** Removed functions:
7073
7074scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
7075scm_list_reverse, scm_list_reverse_x
7076
7077** New macros: SCM_LISTn where n is one of the integers 0-9.
7078
7079These can be used for pretty list creation from C. The idea is taken
7080from Erick Gallesio's STk.
7081
298aa6e3
MD
7082** scm_array_map renamed to scm_array_map_x
7083
527da704
MD
7084** mbstrings are now removed
7085
7086This means that the type codes scm_tc7_mb_string and
7087scm_tc7_mb_substring has been removed.
7088
8cd57bd0
JB
7089** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
7090
7091Since we no longer support multi-byte strings, these I/O functions
7092have been simplified, and renamed. Here are their old names, and
7093their new names and arguments:
7094
7095scm_gen_putc -> void scm_putc (int c, SCM port);
7096scm_gen_puts -> void scm_puts (char *s, SCM port);
7097scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
7098scm_gen_getc -> void scm_getc (SCM port);
7099
7100
527da704
MD
7101** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
7102
7103** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
7104
7105SCM_TYP7S now masks away the bit which distinguishes substrings from
7106strings.
7107
660f41fa
MD
7108** scm_catch_body_t: Backward incompatible change!
7109
7110Body functions to scm_internal_catch and friends do not any longer
7111take a second argument. This is because it is no longer possible to
7112pass a #f arg to catch.
7113
a8e05009
JB
7114** Calls to scm_protect_object and scm_unprotect now nest properly.
7115
7116The function scm_protect_object protects its argument from being freed
7117by the garbage collector. scm_unprotect_object removes that
7118protection.
7119
7120These functions now nest properly. That is, for every object O, there
7121is a counter which scm_protect_object(O) increments and
7122scm_unprotect_object(O) decrements, if the counter is greater than
7123zero. Every object's counter is zero when it is first created. If an
7124object's counter is greater than zero, the garbage collector will not
7125reclaim its storage.
7126
7127This allows you to use scm_protect_object in your code without
7128worrying that some other function you call will call
7129scm_unprotect_object, and allow it to be freed. Assuming that the
7130functions you call are well-behaved, and unprotect only those objects
7131they protect, you can follow the same rule and have confidence that
7132objects will be freed only at appropriate times.
7133
c484bf7f
JB
7134\f
7135Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 7136
737c9113
JB
7137* Changes to the distribution
7138
832b09ed
JB
7139** Nightly snapshots are now available from ftp.red-bean.com.
7140The old server, ftp.cyclic.com, has been relinquished to its rightful
7141owner.
7142
7143Nightly snapshots of the Guile development sources are now available via
7144anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
7145
7146Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
7147For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
7148
0fcab5ed
JB
7149** To run Guile without installing it, the procedure has changed a bit.
7150
7151If you used a separate build directory to compile Guile, you'll need
7152to include the build directory in SCHEME_LOAD_PATH, as well as the
7153source directory. See the `INSTALL' file for examples.
7154
737c9113
JB
7155* Changes to the procedure for linking libguile with your programs
7156
94982a4e
JB
7157** The standard Guile load path for Scheme code now includes
7158$(datadir)/guile (usually /usr/local/share/guile). This means that
7159you can install your own Scheme files there, and Guile will find them.
7160(Previous versions of Guile only checked a directory whose name
7161contained the Guile version number, so you had to re-install or move
7162your Scheme sources each time you installed a fresh version of Guile.)
7163
7164The load path also includes $(datadir)/guile/site; we recommend
7165putting individual Scheme files there. If you want to install a
7166package with multiple source files, create a directory for them under
7167$(datadir)/guile.
7168
7169** Guile 1.2 will now use the Rx regular expression library, if it is
7170installed on your system. When you are linking libguile into your own
7171programs, this means you will have to link against -lguile, -lqt (if
7172you configured Guile with thread support), and -lrx.
27590f82
JB
7173
7174If you are using autoconf to generate configuration scripts for your
7175application, the following lines should suffice to add the appropriate
7176libraries to your link command:
7177
7178### Find Rx, quickthreads and libguile.
7179AC_CHECK_LIB(rx, main)
7180AC_CHECK_LIB(qt, main)
7181AC_CHECK_LIB(guile, scm_shell)
7182
94982a4e
JB
7183The Guile 1.2 distribution does not contain sources for the Rx
7184library, as Guile 1.0 did. If you want to use Rx, you'll need to
7185retrieve it from a GNU FTP site and install it separately.
7186
b83b8bee
JB
7187* Changes to Scheme functions and syntax
7188
e035e7e6
MV
7189** The dynamic linking features of Guile are now enabled by default.
7190You can disable them by giving the `--disable-dynamic-linking' option
7191to configure.
7192
e035e7e6
MV
7193 (dynamic-link FILENAME)
7194
7195 Find the object file denoted by FILENAME (a string) and link it
7196 into the running Guile application. When everything works out,
7197 return a Scheme object suitable for representing the linked object
7198 file. Otherwise an error is thrown. How object files are
7199 searched is system dependent.
7200
7201 (dynamic-object? VAL)
7202
7203 Determine whether VAL represents a dynamically linked object file.
7204
7205 (dynamic-unlink DYNOBJ)
7206
7207 Unlink the indicated object file from the application. DYNOBJ
7208 should be one of the values returned by `dynamic-link'.
7209
7210 (dynamic-func FUNCTION DYNOBJ)
7211
7212 Search the C function indicated by FUNCTION (a string or symbol)
7213 in DYNOBJ and return some Scheme object that can later be used
7214 with `dynamic-call' to actually call this function. Right now,
7215 these Scheme objects are formed by casting the address of the
7216 function to `long' and converting this number to its Scheme
7217 representation.
7218
7219 (dynamic-call FUNCTION DYNOBJ)
7220
7221 Call the C function indicated by FUNCTION and DYNOBJ. The
7222 function is passed no arguments and its return value is ignored.
7223 When FUNCTION is something returned by `dynamic-func', call that
7224 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
7225 etc.), look it up in DYNOBJ; this is equivalent to
7226
7227 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
7228
7229 Interrupts are deferred while the C function is executing (with
7230 SCM_DEFER_INTS/SCM_ALLOW_INTS).
7231
7232 (dynamic-args-call FUNCTION DYNOBJ ARGS)
7233
7234 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
7235 some arguments and return its return value. The C function is
7236 expected to take two arguments and return an `int', just like
7237 `main':
7238
7239 int c_func (int argc, char **argv);
7240
7241 ARGS must be a list of strings and is converted into an array of
7242 `char *'. The array is passed in ARGV and its size in ARGC. The
7243 return value is converted to a Scheme number and returned from the
7244 call to `dynamic-args-call'.
7245
0fcab5ed
JB
7246When dynamic linking is disabled or not supported on your system,
7247the above functions throw errors, but they are still available.
7248
e035e7e6
MV
7249Here is a small example that works on GNU/Linux:
7250
7251 (define libc-obj (dynamic-link "libc.so"))
7252 (dynamic-args-call 'rand libc-obj '())
7253
7254See the file `libguile/DYNAMIC-LINKING' for additional comments.
7255
27590f82 7256** The #/ syntax for module names is depreciated, and will be removed
6c0201ad 7257in a future version of Guile. Instead of
27590f82
JB
7258
7259 #/foo/bar/baz
7260
7261instead write
7262
7263 (foo bar baz)
7264
7265The latter syntax is more consistent with existing Lisp practice.
7266
5dade857
MV
7267** Guile now does fancier printing of structures. Structures are the
7268underlying implementation for records, which in turn are used to
7269implement modules, so all of these object now print differently and in
7270a more informative way.
7271
161029df
JB
7272The Scheme printer will examine the builtin variable *struct-printer*
7273whenever it needs to print a structure object. When this variable is
7274not `#f' it is deemed to be a procedure and will be applied to the
7275structure object and the output port. When *struct-printer* is `#f'
7276or the procedure return `#f' the structure object will be printed in
7277the boring #<struct 80458270> form.
5dade857
MV
7278
7279This hook is used by some routines in ice-9/boot-9.scm to implement
7280type specific printing routines. Please read the comments there about
7281"printing structs".
7282
7283One of the more specific uses of structs are records. The printing
7284procedure that could be passed to MAKE-RECORD-TYPE is now actually
7285called. It should behave like a *struct-printer* procedure (described
7286above).
7287
b83b8bee
JB
7288** Guile now supports a new R4RS-compliant syntax for keywords. A
7289token of the form #:NAME, where NAME has the same syntax as a Scheme
7290symbol, is the external representation of the keyword named NAME.
7291Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
7292keyword objects can be read back into Guile. When used in an
7293expression, keywords are self-quoting objects.
b83b8bee
JB
7294
7295Guile suports this read syntax, and uses this print syntax, regardless
7296of the current setting of the `keyword' read option. The `keyword'
7297read option only controls whether Guile recognizes the `:NAME' syntax,
7298which is incompatible with R4RS. (R4RS says such token represent
7299symbols.)
737c9113
JB
7300
7301** Guile has regular expression support again. Guile 1.0 included
7302functions for matching regular expressions, based on the Rx library.
7303In Guile 1.1, the Guile/Rx interface was removed to simplify the
7304distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
73051.2 again supports the most commonly used functions, and supports all
7306of SCSH's regular expression functions.
2409cdfa 7307
94982a4e
JB
7308If your system does not include a POSIX regular expression library,
7309and you have not linked Guile with a third-party regexp library such as
7310Rx, these functions will not be available. You can tell whether your
7311Guile installation includes regular expression support by checking
7312whether the `*features*' list includes the `regex' symbol.
737c9113 7313
94982a4e 7314*** regexp functions
161029df 7315
94982a4e
JB
7316By default, Guile supports POSIX extended regular expressions. That
7317means that the characters `(', `)', `+' and `?' are special, and must
7318be escaped if you wish to match the literal characters.
e1a191a8 7319
94982a4e
JB
7320This regular expression interface was modeled after that implemented
7321by SCSH, the Scheme Shell. It is intended to be upwardly compatible
7322with SCSH regular expressions.
7323
7324**** Function: string-match PATTERN STR [START]
7325 Compile the string PATTERN into a regular expression and compare
7326 it with STR. The optional numeric argument START specifies the
7327 position of STR at which to begin matching.
7328
7329 `string-match' returns a "match structure" which describes what,
7330 if anything, was matched by the regular expression. *Note Match
7331 Structures::. If STR does not match PATTERN at all,
7332 `string-match' returns `#f'.
7333
7334 Each time `string-match' is called, it must compile its PATTERN
7335argument into a regular expression structure. This operation is
7336expensive, which makes `string-match' inefficient if the same regular
7337expression is used several times (for example, in a loop). For better
7338performance, you can compile a regular expression in advance and then
7339match strings against the compiled regexp.
7340
7341**** Function: make-regexp STR [FLAGS]
7342 Compile the regular expression described by STR, and return the
7343 compiled regexp structure. If STR does not describe a legal
7344 regular expression, `make-regexp' throws a
7345 `regular-expression-syntax' error.
7346
7347 FLAGS may be the bitwise-or of one or more of the following:
7348
7349**** Constant: regexp/extended
7350 Use POSIX Extended Regular Expression syntax when interpreting
7351 STR. If not set, POSIX Basic Regular Expression syntax is used.
7352 If the FLAGS argument is omitted, we assume regexp/extended.
7353
7354**** Constant: regexp/icase
7355 Do not differentiate case. Subsequent searches using the
7356 returned regular expression will be case insensitive.
7357
7358**** Constant: regexp/newline
7359 Match-any-character operators don't match a newline.
7360
7361 A non-matching list ([^...]) not containing a newline matches a
7362 newline.
7363
7364 Match-beginning-of-line operator (^) matches the empty string
7365 immediately after a newline, regardless of whether the FLAGS
7366 passed to regexp-exec contain regexp/notbol.
7367
7368 Match-end-of-line operator ($) matches the empty string
7369 immediately before a newline, regardless of whether the FLAGS
7370 passed to regexp-exec contain regexp/noteol.
7371
7372**** Function: regexp-exec REGEXP STR [START [FLAGS]]
7373 Match the compiled regular expression REGEXP against `str'. If
7374 the optional integer START argument is provided, begin matching
7375 from that position in the string. Return a match structure
7376 describing the results of the match, or `#f' if no match could be
7377 found.
7378
7379 FLAGS may be the bitwise-or of one or more of the following:
7380
7381**** Constant: regexp/notbol
7382 The match-beginning-of-line operator always fails to match (but
7383 see the compilation flag regexp/newline above) This flag may be
7384 used when different portions of a string are passed to
7385 regexp-exec and the beginning of the string should not be
7386 interpreted as the beginning of the line.
7387
7388**** Constant: regexp/noteol
7389 The match-end-of-line operator always fails to match (but see the
7390 compilation flag regexp/newline above)
7391
7392**** Function: regexp? OBJ
7393 Return `#t' if OBJ is a compiled regular expression, or `#f'
7394 otherwise.
7395
7396 Regular expressions are commonly used to find patterns in one string
7397and replace them with the contents of another string.
7398
7399**** Function: regexp-substitute PORT MATCH [ITEM...]
7400 Write to the output port PORT selected contents of the match
7401 structure MATCH. Each ITEM specifies what should be written, and
7402 may be one of the following arguments:
7403
7404 * A string. String arguments are written out verbatim.
7405
7406 * An integer. The submatch with that number is written.
7407
7408 * The symbol `pre'. The portion of the matched string preceding
7409 the regexp match is written.
7410
7411 * The symbol `post'. The portion of the matched string
7412 following the regexp match is written.
7413
7414 PORT may be `#f', in which case nothing is written; instead,
7415 `regexp-substitute' constructs a string from the specified ITEMs
7416 and returns that.
7417
7418**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
7419 Similar to `regexp-substitute', but can be used to perform global
7420 substitutions on STR. Instead of taking a match structure as an
7421 argument, `regexp-substitute/global' takes two string arguments: a
7422 REGEXP string describing a regular expression, and a TARGET string
7423 which should be matched against this regular expression.
7424
7425 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
7426 exceptions:
7427
7428 * A function may be supplied. When this function is called, it
7429 will be passed one argument: a match structure for a given
7430 regular expression match. It should return a string to be
7431 written out to PORT.
7432
7433 * The `post' symbol causes `regexp-substitute/global' to recurse
7434 on the unmatched portion of STR. This *must* be supplied in
7435 order to perform global search-and-replace on STR; if it is
7436 not present among the ITEMs, then `regexp-substitute/global'
7437 will return after processing a single match.
7438
7439*** Match Structures
7440
7441 A "match structure" is the object returned by `string-match' and
7442`regexp-exec'. It describes which portion of a string, if any, matched
7443the given regular expression. Match structures include: a reference to
7444the string that was checked for matches; the starting and ending
7445positions of the regexp match; and, if the regexp included any
7446parenthesized subexpressions, the starting and ending positions of each
7447submatch.
7448
7449 In each of the regexp match functions described below, the `match'
7450argument must be a match structure returned by a previous call to
7451`string-match' or `regexp-exec'. Most of these functions return some
7452information about the original target string that was matched against a
7453regular expression; we will call that string TARGET for easy reference.
7454
7455**** Function: regexp-match? OBJ
7456 Return `#t' if OBJ is a match structure returned by a previous
7457 call to `regexp-exec', or `#f' otherwise.
7458
7459**** Function: match:substring MATCH [N]
7460 Return the portion of TARGET matched by subexpression number N.
7461 Submatch 0 (the default) represents the entire regexp match. If
7462 the regular expression as a whole matched, but the subexpression
7463 number N did not match, return `#f'.
7464
7465**** Function: match:start MATCH [N]
7466 Return the starting position of submatch number N.
7467
7468**** Function: match:end MATCH [N]
7469 Return the ending position of submatch number N.
7470
7471**** Function: match:prefix MATCH
7472 Return the unmatched portion of TARGET preceding the regexp match.
7473
7474**** Function: match:suffix MATCH
7475 Return the unmatched portion of TARGET following the regexp match.
7476
7477**** Function: match:count MATCH
7478 Return the number of parenthesized subexpressions from MATCH.
7479 Note that the entire regular expression match itself counts as a
7480 subexpression, and failed submatches are included in the count.
7481
7482**** Function: match:string MATCH
7483 Return the original TARGET string.
7484
7485*** Backslash Escapes
7486
7487 Sometimes you will want a regexp to match characters like `*' or `$'
7488exactly. For example, to check whether a particular string represents
7489a menu entry from an Info node, it would be useful to match it against
7490a regexp like `^* [^:]*::'. However, this won't work; because the
7491asterisk is a metacharacter, it won't match the `*' at the beginning of
7492the string. In this case, we want to make the first asterisk un-magic.
7493
7494 You can do this by preceding the metacharacter with a backslash
7495character `\'. (This is also called "quoting" the metacharacter, and
7496is known as a "backslash escape".) When Guile sees a backslash in a
7497regular expression, it considers the following glyph to be an ordinary
7498character, no matter what special meaning it would ordinarily have.
7499Therefore, we can make the above example work by changing the regexp to
7500`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
7501to match only a single asterisk in the target string.
7502
7503 Since the backslash is itself a metacharacter, you may force a
7504regexp to match a backslash in the target string by preceding the
7505backslash with itself. For example, to find variable references in a
7506TeX program, you might want to find occurrences of the string `\let\'
7507followed by any number of alphabetic characters. The regular expression
7508`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
7509each match a single backslash in the target string.
7510
7511**** Function: regexp-quote STR
7512 Quote each special character found in STR with a backslash, and
7513 return the resulting string.
7514
7515 *Very important:* Using backslash escapes in Guile source code (as
7516in Emacs Lisp or C) can be tricky, because the backslash character has
7517special meaning for the Guile reader. For example, if Guile encounters
7518the character sequence `\n' in the middle of a string while processing
7519Scheme code, it replaces those characters with a newline character.
7520Similarly, the character sequence `\t' is replaced by a horizontal tab.
7521Several of these "escape sequences" are processed by the Guile reader
7522before your code is executed. Unrecognized escape sequences are
7523ignored: if the characters `\*' appear in a string, they will be
7524translated to the single character `*'.
7525
7526 This translation is obviously undesirable for regular expressions,
7527since we want to be able to include backslashes in a string in order to
7528escape regexp metacharacters. Therefore, to make sure that a backslash
7529is preserved in a string in your Guile program, you must use *two*
7530consecutive backslashes:
7531
7532 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
7533
7534 The string in this example is preprocessed by the Guile reader before
7535any code is executed. The resulting argument to `make-regexp' is the
7536string `^\* [^:]*', which is what we really want.
7537
7538 This also means that in order to write a regular expression that
7539matches a single backslash character, the regular expression string in
7540the source code must include *four* backslashes. Each consecutive pair
7541of backslashes gets translated by the Guile reader to a single
7542backslash, and the resulting double-backslash is interpreted by the
7543regexp engine as matching a single backslash character. Hence:
7544
7545 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
7546
7547 The reason for the unwieldiness of this syntax is historical. Both
7548regular expression pattern matchers and Unix string processing systems
7549have traditionally used backslashes with the special meanings described
7550above. The POSIX regular expression specification and ANSI C standard
7551both require these semantics. Attempting to abandon either convention
7552would cause other kinds of compatibility problems, possibly more severe
7553ones. Therefore, without extending the Scheme reader to support
7554strings with different quoting conventions (an ungainly and confusing
7555extension when implemented in other languages), we must adhere to this
7556cumbersome escape syntax.
7557
7ad3c1e7
GH
7558* Changes to the gh_ interface
7559
7560* Changes to the scm_ interface
7561
7562* Changes to system call interfaces:
94982a4e 7563
7ad3c1e7 7564** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
7565if an error occurs.
7566
94982a4e 7567*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
7568
7569(sigaction signum [action] [flags])
7570
7571signum is the signal number, which can be specified using the value
7572of SIGINT etc.
7573
7574If action is omitted, sigaction returns a pair: the CAR is the current
7575signal hander, which will be either an integer with the value SIG_DFL
7576(default action) or SIG_IGN (ignore), or the Scheme procedure which
7577handles the signal, or #f if a non-Scheme procedure handles the
7578signal. The CDR contains the current sigaction flags for the handler.
7579
7580If action is provided, it is installed as the new handler for signum.
7581action can be a Scheme procedure taking one argument, or the value of
7582SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
7583whatever signal handler was installed before sigaction was first used.
7584Flags can optionally be specified for the new handler (SA_RESTART is
7585always used if the system provides it, so need not be specified.) The
7586return value is a pair with information about the old handler as
7587described above.
7588
7589This interface does not provide access to the "signal blocking"
7590facility. Maybe this is not needed, since the thread support may
7591provide solutions to the problem of consistent access to data
7592structures.
e1a191a8 7593
94982a4e 7594*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
7595`force-output' on every port open for output.
7596
94982a4e
JB
7597** Guile now provides information on how it was built, via the new
7598global variable, %guile-build-info. This variable records the values
7599of the standard GNU makefile directory variables as an assocation
7600list, mapping variable names (symbols) onto directory paths (strings).
7601For example, to find out where the Guile link libraries were
7602installed, you can say:
7603
7604guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
7605
7606
7607* Changes to the scm_ interface
7608
7609** The new function scm_handle_by_message_noexit is just like the
7610existing scm_handle_by_message function, except that it doesn't call
7611exit to terminate the process. Instead, it prints a message and just
7612returns #f. This might be a more appropriate catch-all handler for
7613new dynamic roots and threads.
7614
cf78e9e8 7615\f
c484bf7f 7616Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
7617
7618* Changes to the distribution.
7619
7620The Guile 1.0 distribution has been split up into several smaller
7621pieces:
7622guile-core --- the Guile interpreter itself.
7623guile-tcltk --- the interface between the Guile interpreter and
7624 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
7625 is a toolkit for building graphical user interfaces.
7626guile-rgx-ctax --- the interface between Guile and the Rx regular
7627 expression matcher, and the translator for the Ctax
7628 programming language. These are packaged together because the
7629 Ctax translator uses Rx to parse Ctax source code.
7630
095936d2
JB
7631This NEWS file describes the changes made to guile-core since the 1.0
7632release.
7633
48d224d7
JB
7634We no longer distribute the documentation, since it was either out of
7635date, or incomplete. As soon as we have current documentation, we
7636will distribute it.
7637
0fcab5ed
JB
7638
7639
f3b1485f
JB
7640* Changes to the stand-alone interpreter
7641
48d224d7
JB
7642** guile now accepts command-line arguments compatible with SCSH, Olin
7643Shivers' Scheme Shell.
7644
7645In general, arguments are evaluated from left to right, but there are
7646exceptions. The following switches stop argument processing, and
7647stash all remaining command-line arguments as the value returned by
7648the (command-line) function.
7649 -s SCRIPT load Scheme source code from FILE, and exit
7650 -c EXPR evalute Scheme expression EXPR, and exit
7651 -- stop scanning arguments; run interactively
7652
7653The switches below are processed as they are encountered.
7654 -l FILE load Scheme source code from FILE
7655 -e FUNCTION after reading script, apply FUNCTION to
7656 command line arguments
7657 -ds do -s script at this point
7658 --emacs enable Emacs protocol (experimental)
7659 -h, --help display this help and exit
7660 -v, --version display version information and exit
7661 \ read arguments from following script lines
7662
7663So, for example, here is a Guile script named `ekko' (thanks, Olin)
7664which re-implements the traditional "echo" command:
7665
7666#!/usr/local/bin/guile -s
7667!#
7668(define (main args)
7669 (map (lambda (arg) (display arg) (display " "))
7670 (cdr args))
7671 (newline))
7672
7673(main (command-line))
7674
7675Suppose we invoke this script as follows:
7676
7677 ekko a speckled gecko
7678
7679Through the magic of Unix script processing (triggered by the `#!'
7680token at the top of the file), /usr/local/bin/guile receives the
7681following list of command-line arguments:
7682
7683 ("-s" "./ekko" "a" "speckled" "gecko")
7684
7685Unix inserts the name of the script after the argument specified on
7686the first line of the file (in this case, "-s"), and then follows that
7687with the arguments given to the script. Guile loads the script, which
7688defines the `main' function, and then applies it to the list of
7689remaining command-line arguments, ("a" "speckled" "gecko").
7690
095936d2
JB
7691In Unix, the first line of a script file must take the following form:
7692
7693#!INTERPRETER ARGUMENT
7694
7695where INTERPRETER is the absolute filename of the interpreter
7696executable, and ARGUMENT is a single command-line argument to pass to
7697the interpreter.
7698
7699You may only pass one argument to the interpreter, and its length is
7700limited. These restrictions can be annoying to work around, so Guile
7701provides a general mechanism (borrowed from, and compatible with,
7702SCSH) for circumventing them.
7703
7704If the ARGUMENT in a Guile script is a single backslash character,
7705`\', Guile will open the script file, parse arguments from its second
7706and subsequent lines, and replace the `\' with them. So, for example,
7707here is another implementation of the `ekko' script:
7708
7709#!/usr/local/bin/guile \
7710-e main -s
7711!#
7712(define (main args)
7713 (for-each (lambda (arg) (display arg) (display " "))
7714 (cdr args))
7715 (newline))
7716
7717If the user invokes this script as follows:
7718
7719 ekko a speckled gecko
7720
7721Unix expands this into
7722
7723 /usr/local/bin/guile \ ekko a speckled gecko
7724
7725When Guile sees the `\' argument, it replaces it with the arguments
7726read from the second line of the script, producing:
7727
7728 /usr/local/bin/guile -e main -s ekko a speckled gecko
7729
7730This tells Guile to load the `ekko' script, and apply the function
7731`main' to the argument list ("a" "speckled" "gecko").
7732
7733Here is how Guile parses the command-line arguments:
7734- Each space character terminates an argument. This means that two
7735 spaces in a row introduce an empty-string argument.
7736- The tab character is not permitted (unless you quote it with the
7737 backslash character, as described below), to avoid confusion.
7738- The newline character terminates the sequence of arguments, and will
7739 also terminate a final non-empty argument. (However, a newline
7740 following a space will not introduce a final empty-string argument;
7741 it only terminates the argument list.)
7742- The backslash character is the escape character. It escapes
7743 backslash, space, tab, and newline. The ANSI C escape sequences
7744 like \n and \t are also supported. These produce argument
7745 constituents; the two-character combination \n doesn't act like a
7746 terminating newline. The escape sequence \NNN for exactly three
7747 octal digits reads as the character whose ASCII code is NNN. As
7748 above, characters produced this way are argument constituents.
7749 Backslash followed by other characters is not allowed.
7750
48d224d7
JB
7751* Changes to the procedure for linking libguile with your programs
7752
7753** Guile now builds and installs a shared guile library, if your
7754system support shared libraries. (It still builds a static library on
7755all systems.) Guile automatically detects whether your system
7756supports shared libraries. To prevent Guile from buildisg shared
7757libraries, pass the `--disable-shared' flag to the configure script.
7758
7759Guile takes longer to compile when it builds shared libraries, because
7760it must compile every file twice --- once to produce position-
7761independent object code, and once to produce normal object code.
7762
7763** The libthreads library has been merged into libguile.
7764
7765To link a program against Guile, you now need only link against
7766-lguile and -lqt; -lthreads is no longer needed. If you are using
7767autoconf to generate configuration scripts for your application, the
7768following lines should suffice to add the appropriate libraries to
7769your link command:
7770
7771### Find quickthreads and libguile.
7772AC_CHECK_LIB(qt, main)
7773AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
7774
7775* Changes to Scheme functions
7776
095936d2
JB
7777** Guile Scheme's special syntax for keyword objects is now optional,
7778and disabled by default.
7779
7780The syntax variation from R4RS made it difficult to port some
7781interesting packages to Guile. The routines which accepted keyword
7782arguments (mostly in the module system) have been modified to also
7783accept symbols whose names begin with `:'.
7784
7785To change the keyword syntax, you must first import the (ice-9 debug)
7786module:
7787 (use-modules (ice-9 debug))
7788
7789Then you can enable the keyword syntax as follows:
7790 (read-set! keywords 'prefix)
7791
7792To disable keyword syntax, do this:
7793 (read-set! keywords #f)
7794
7795** Many more primitive functions accept shared substrings as
7796arguments. In the past, these functions required normal, mutable
7797strings as arguments, although they never made use of this
7798restriction.
7799
7800** The uniform array functions now operate on byte vectors. These
7801functions are `array-fill!', `serial-array-copy!', `array-copy!',
7802`serial-array-map', `array-map', `array-for-each', and
7803`array-index-map!'.
7804
7805** The new functions `trace' and `untrace' implement simple debugging
7806support for Scheme functions.
7807
7808The `trace' function accepts any number of procedures as arguments,
7809and tells the Guile interpreter to display each procedure's name and
7810arguments each time the procedure is invoked. When invoked with no
7811arguments, `trace' returns the list of procedures currently being
7812traced.
7813
7814The `untrace' function accepts any number of procedures as arguments,
7815and tells the Guile interpreter not to trace them any more. When
7816invoked with no arguments, `untrace' untraces all curretly traced
7817procedures.
7818
7819The tracing in Guile has an advantage over most other systems: we
7820don't create new procedure objects, but mark the procedure objects
7821themselves. This means that anonymous and internal procedures can be
7822traced.
7823
7824** The function `assert-repl-prompt' has been renamed to
7825`set-repl-prompt!'. It takes one argument, PROMPT.
7826- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
7827- If PROMPT is a string, we use it as a prompt.
7828- If PROMPT is a procedure accepting no arguments, we call it, and
7829 display the result as a prompt.
7830- Otherwise, we display "> ".
7831
7832** The new function `eval-string' reads Scheme expressions from a
7833string and evaluates them, returning the value of the last expression
7834in the string. If the string contains no expressions, it returns an
7835unspecified value.
7836
7837** The new function `thunk?' returns true iff its argument is a
7838procedure of zero arguments.
7839
7840** `defined?' is now a builtin function, instead of syntax. This
7841means that its argument should be quoted. It returns #t iff its
7842argument is bound in the current module.
7843
7844** The new syntax `use-modules' allows you to add new modules to your
7845environment without re-typing a complete `define-module' form. It
7846accepts any number of module names as arguments, and imports their
7847public bindings into the current module.
7848
7849** The new function (module-defined? NAME MODULE) returns true iff
7850NAME, a symbol, is defined in MODULE, a module object.
7851
7852** The new function `builtin-bindings' creates and returns a hash
7853table containing copies of all the root module's bindings.
7854
7855** The new function `builtin-weak-bindings' does the same as
7856`builtin-bindings', but creates a doubly-weak hash table.
7857
7858** The `equal?' function now considers variable objects to be
7859equivalent if they have the same name and the same value.
7860
7861** The new function `command-line' returns the command-line arguments
7862given to Guile, as a list of strings.
7863
7864When using guile as a script interpreter, `command-line' returns the
7865script's arguments; those processed by the interpreter (like `-s' or
7866`-c') are omitted. (In other words, you get the normal, expected
7867behavior.) Any application that uses scm_shell to process its
7868command-line arguments gets this behavior as well.
7869
7870** The new function `load-user-init' looks for a file called `.guile'
7871in the user's home directory, and loads it if it exists. This is
7872mostly for use by the code generated by scm_compile_shell_switches,
7873but we thought it might also be useful in other circumstances.
7874
7875** The new function `log10' returns the base-10 logarithm of its
7876argument.
7877
7878** Changes to I/O functions
7879
6c0201ad 7880*** The functions `read', `primitive-load', `read-and-eval!', and
095936d2
JB
7881`primitive-load-path' no longer take optional arguments controlling
7882case insensitivity and a `#' parser.
7883
7884Case sensitivity is now controlled by a read option called
7885`case-insensitive'. The user can add new `#' syntaxes with the
7886`read-hash-extend' function (see below).
7887
7888*** The new function `read-hash-extend' allows the user to change the
7889syntax of Guile Scheme in a somewhat controlled way.
7890
7891(read-hash-extend CHAR PROC)
7892 When parsing S-expressions, if we read a `#' character followed by
7893 the character CHAR, use PROC to parse an object from the stream.
7894 If PROC is #f, remove any parsing procedure registered for CHAR.
7895
7896 The reader applies PROC to two arguments: CHAR and an input port.
7897
6c0201ad 7898*** The new functions read-delimited and read-delimited! provide a
095936d2
JB
7899general mechanism for doing delimited input on streams.
7900
7901(read-delimited DELIMS [PORT HANDLE-DELIM])
7902 Read until we encounter one of the characters in DELIMS (a string),
7903 or end-of-file. PORT is the input port to read from; it defaults to
7904 the current input port. The HANDLE-DELIM parameter determines how
7905 the terminating character is handled; it should be one of the
7906 following symbols:
7907
7908 'trim omit delimiter from result
7909 'peek leave delimiter character in input stream
7910 'concat append delimiter character to returned value
7911 'split return a pair: (RESULT . TERMINATOR)
7912
7913 HANDLE-DELIM defaults to 'peek.
7914
7915(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
7916 A side-effecting variant of `read-delimited'.
7917
7918 The data is written into the string BUF at the indices in the
7919 half-open interval [START, END); the default interval is the whole
7920 string: START = 0 and END = (string-length BUF). The values of
7921 START and END must specify a well-defined interval in BUF, i.e.
7922 0 <= START <= END <= (string-length BUF).
7923
7924 It returns NBYTES, the number of bytes read. If the buffer filled
7925 up without a delimiter character being found, it returns #f. If the
7926 port is at EOF when the read starts, it returns the EOF object.
7927
7928 If an integer is returned (i.e., the read is successfully terminated
7929 by reading a delimiter character), then the HANDLE-DELIM parameter
7930 determines how to handle the terminating character. It is described
7931 above, and defaults to 'peek.
7932
7933(The descriptions of these functions were borrowed from the SCSH
7934manual, by Olin Shivers and Brian Carlstrom.)
7935
7936*** The `%read-delimited!' function is the primitive used to implement
7937`read-delimited' and `read-delimited!'.
7938
7939(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
7940
7941This returns a pair of values: (TERMINATOR . NUM-READ).
7942- TERMINATOR describes why the read was terminated. If it is a
7943 character or the eof object, then that is the value that terminated
7944 the read. If it is #f, the function filled the buffer without finding
7945 a delimiting character.
7946- NUM-READ is the number of characters read into BUF.
7947
7948If the read is successfully terminated by reading a delimiter
7949character, then the gobble? parameter determines what to do with the
7950terminating character. If true, the character is removed from the
7951input stream; if false, the character is left in the input stream
7952where a subsequent read operation will retrieve it. In either case,
7953the character is also the first value returned by the procedure call.
7954
7955(The descriptions of this function was borrowed from the SCSH manual,
7956by Olin Shivers and Brian Carlstrom.)
7957
7958*** The `read-line' and `read-line!' functions have changed; they now
7959trim the terminator by default; previously they appended it to the
7960returned string. For the old behavior, use (read-line PORT 'concat).
7961
7962*** The functions `uniform-array-read!' and `uniform-array-write!' now
7963take new optional START and END arguments, specifying the region of
7964the array to read and write.
7965
f348c807
JB
7966*** The `ungetc-char-ready?' function has been removed. We feel it's
7967inappropriate for an interface to expose implementation details this
7968way.
095936d2
JB
7969
7970** Changes to the Unix library and system call interface
7971
7972*** The new fcntl function provides access to the Unix `fcntl' system
7973call.
7974
7975(fcntl PORT COMMAND VALUE)
7976 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
7977 Values for COMMAND are:
7978
7979 F_DUPFD duplicate a file descriptor
7980 F_GETFD read the descriptor's close-on-exec flag
7981 F_SETFD set the descriptor's close-on-exec flag to VALUE
7982 F_GETFL read the descriptor's flags, as set on open
7983 F_SETFL set the descriptor's flags, as set on open to VALUE
7984 F_GETOWN return the process ID of a socket's owner, for SIGIO
7985 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
7986 FD_CLOEXEC not sure what this is
7987
7988For details, see the documentation for the fcntl system call.
7989
7990*** The arguments to `select' have changed, for compatibility with
7991SCSH. The TIMEOUT parameter may now be non-integral, yielding the
7992expected behavior. The MILLISECONDS parameter has been changed to
7993MICROSECONDS, to more closely resemble the underlying system call.
7994The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
7995corresponding return set will be the same.
7996
7997*** The arguments to the `mknod' system call have changed. They are
7998now:
7999
8000(mknod PATH TYPE PERMS DEV)
8001 Create a new file (`node') in the file system. PATH is the name of
8002 the file to create. TYPE is the kind of file to create; it should
8003 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
8004 permission bits to give the newly created file. If TYPE is
8005 'block-special or 'char-special, DEV specifies which device the
8006 special file refers to; its interpretation depends on the kind of
8007 special file being created.
8008
8009*** The `fork' function has been renamed to `primitive-fork', to avoid
8010clashing with various SCSH forks.
8011
8012*** The `recv' and `recvfrom' functions have been renamed to `recv!'
8013and `recvfrom!'. They no longer accept a size for a second argument;
8014you must pass a string to hold the received value. They no longer
8015return the buffer. Instead, `recv' returns the length of the message
8016received, and `recvfrom' returns a pair containing the packet's length
6c0201ad 8017and originating address.
095936d2
JB
8018
8019*** The file descriptor datatype has been removed, as have the
8020`read-fd', `write-fd', `close', `lseek', and `dup' functions.
8021We plan to replace these functions with a SCSH-compatible interface.
8022
8023*** The `create' function has been removed; it's just a special case
8024of `open'.
8025
8026*** There are new functions to break down process termination status
8027values. In the descriptions below, STATUS is a value returned by
8028`waitpid'.
8029
8030(status:exit-val STATUS)
8031 If the child process exited normally, this function returns the exit
8032 code for the child process (i.e., the value passed to exit, or
8033 returned from main). If the child process did not exit normally,
8034 this function returns #f.
8035
8036(status:stop-sig STATUS)
8037 If the child process was suspended by a signal, this function
8038 returns the signal that suspended the child. Otherwise, it returns
8039 #f.
8040
8041(status:term-sig STATUS)
8042 If the child process terminated abnormally, this function returns
8043 the signal that terminated the child. Otherwise, this function
8044 returns false.
8045
8046POSIX promises that exactly one of these functions will return true on
8047a valid STATUS value.
8048
8049These functions are compatible with SCSH.
8050
8051*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
8052returned by `localtime', `gmtime', and that ilk. They are:
8053
8054 Component Accessor Setter
8055 ========================= ============ ============
8056 seconds tm:sec set-tm:sec
8057 minutes tm:min set-tm:min
8058 hours tm:hour set-tm:hour
8059 day of the month tm:mday set-tm:mday
8060 month tm:mon set-tm:mon
8061 year tm:year set-tm:year
8062 day of the week tm:wday set-tm:wday
8063 day in the year tm:yday set-tm:yday
8064 daylight saving time tm:isdst set-tm:isdst
8065 GMT offset, seconds tm:gmtoff set-tm:gmtoff
8066 name of time zone tm:zone set-tm:zone
8067
095936d2
JB
8068*** There are new accessors for the vectors returned by `uname',
8069describing the host system:
48d224d7
JB
8070
8071 Component Accessor
8072 ============================================== ================
8073 name of the operating system implementation utsname:sysname
8074 network name of this machine utsname:nodename
8075 release level of the operating system utsname:release
8076 version level of the operating system utsname:version
8077 machine hardware platform utsname:machine
8078
095936d2
JB
8079*** There are new accessors for the vectors returned by `getpw',
8080`getpwnam', `getpwuid', and `getpwent', describing entries from the
8081system's user database:
8082
8083 Component Accessor
8084 ====================== =================
8085 user name passwd:name
8086 user password passwd:passwd
8087 user id passwd:uid
8088 group id passwd:gid
8089 real name passwd:gecos
8090 home directory passwd:dir
8091 shell program passwd:shell
8092
8093*** There are new accessors for the vectors returned by `getgr',
8094`getgrnam', `getgrgid', and `getgrent', describing entries from the
8095system's group database:
8096
8097 Component Accessor
8098 ======================= ============
8099 group name group:name
8100 group password group:passwd
8101 group id group:gid
8102 group members group:mem
8103
8104*** There are new accessors for the vectors returned by `gethost',
8105`gethostbyaddr', `gethostbyname', and `gethostent', describing
8106internet hosts:
8107
8108 Component Accessor
8109 ========================= ===============
8110 official name of host hostent:name
8111 alias list hostent:aliases
8112 host address type hostent:addrtype
8113 length of address hostent:length
8114 list of addresses hostent:addr-list
8115
8116*** There are new accessors for the vectors returned by `getnet',
8117`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
8118networks:
8119
8120 Component Accessor
8121 ========================= ===============
8122 official name of net netent:name
8123 alias list netent:aliases
8124 net number type netent:addrtype
8125 net number netent:net
8126
8127*** There are new accessors for the vectors returned by `getproto',
8128`getprotobyname', `getprotobynumber', and `getprotoent', describing
8129internet protocols:
8130
8131 Component Accessor
8132 ========================= ===============
8133 official protocol name protoent:name
8134 alias list protoent:aliases
8135 protocol number protoent:proto
8136
8137*** There are new accessors for the vectors returned by `getserv',
8138`getservbyname', `getservbyport', and `getservent', describing
8139internet protocols:
8140
8141 Component Accessor
8142 ========================= ===============
6c0201ad 8143 official service name servent:name
095936d2 8144 alias list servent:aliases
6c0201ad
TTN
8145 port number servent:port
8146 protocol to use servent:proto
095936d2
JB
8147
8148*** There are new accessors for the sockaddr structures returned by
8149`accept', `getsockname', `getpeername', `recvfrom!':
8150
8151 Component Accessor
8152 ======================================== ===============
6c0201ad 8153 address format (`family') sockaddr:fam
095936d2
JB
8154 path, for file domain addresses sockaddr:path
8155 address, for internet domain addresses sockaddr:addr
8156 TCP or UDP port, for internet sockaddr:port
8157
8158*** The `getpwent', `getgrent', `gethostent', `getnetent',
8159`getprotoent', and `getservent' functions now return #f at the end of
8160the user database. (They used to throw an exception.)
8161
8162Note that calling MUMBLEent function is equivalent to calling the
8163corresponding MUMBLE function with no arguments.
8164
8165*** The `setpwent', `setgrent', `sethostent', `setnetent',
8166`setprotoent', and `setservent' routines now take no arguments.
8167
8168*** The `gethost', `getproto', `getnet', and `getserv' functions now
8169provide more useful information when they throw an exception.
8170
8171*** The `lnaof' function has been renamed to `inet-lnaof'.
8172
8173*** Guile now claims to have the `current-time' feature.
8174
8175*** The `mktime' function now takes an optional second argument ZONE,
8176giving the time zone to use for the conversion. ZONE should be a
8177string, in the same format as expected for the "TZ" environment variable.
8178
8179*** The `strptime' function now returns a pair (TIME . COUNT), where
8180TIME is the parsed time as a vector, and COUNT is the number of
8181characters from the string left unparsed. This function used to
8182return the remaining characters as a string.
8183
8184*** The `gettimeofday' function has replaced the old `time+ticks' function.
8185The return value is now (SECONDS . MICROSECONDS); the fractional
8186component is no longer expressed in "ticks".
8187
8188*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 8189
ea00ecba
MG
8190* Changes to the gh_ interface
8191
8192** gh_eval_str() now returns an SCM object which is the result of the
8193evaluation
8194
aaef0d2a
MG
8195** gh_scm2str() now copies the Scheme data to a caller-provided C
8196array
8197
8198** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
8199and returns the array
8200
8201** gh_scm2str0() is gone: there is no need to distinguish
8202null-terminated from non-null-terminated, since gh_scm2newstr() allows
8203the user to interpret the data both ways.
8204
f3b1485f
JB
8205* Changes to the scm_ interface
8206
095936d2
JB
8207** The new function scm_symbol_value0 provides an easy way to get a
8208symbol's value from C code:
8209
8210SCM scm_symbol_value0 (char *NAME)
8211 Return the value of the symbol named by the null-terminated string
8212 NAME in the current module. If the symbol named NAME is unbound in
8213 the current module, return SCM_UNDEFINED.
8214
8215** The new function scm_sysintern0 creates new top-level variables,
8216without assigning them a value.
8217
8218SCM scm_sysintern0 (char *NAME)
8219 Create a new Scheme top-level variable named NAME. NAME is a
8220 null-terminated string. Return the variable's value cell.
8221
8222** The function scm_internal_catch is the guts of catch. It handles
8223all the mechanics of setting up a catch target, invoking the catch
8224body, and perhaps invoking the handler if the body does a throw.
8225
8226The function is designed to be usable from C code, but is general
8227enough to implement all the semantics Guile Scheme expects from throw.
8228
8229TAG is the catch tag. Typically, this is a symbol, but this function
8230doesn't actually care about that.
8231
8232BODY is a pointer to a C function which runs the body of the catch;
8233this is the code you can throw from. We call it like this:
8234 BODY (BODY_DATA, JMPBUF)
8235where:
8236 BODY_DATA is just the BODY_DATA argument we received; we pass it
8237 through to BODY as its first argument. The caller can make
8238 BODY_DATA point to anything useful that BODY might need.
8239 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
8240 which we have just created and initialized.
8241
8242HANDLER is a pointer to a C function to deal with a throw to TAG,
8243should one occur. We call it like this:
8244 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
8245where
8246 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
8247 same idea as BODY_DATA above.
8248 THROWN_TAG is the tag that the user threw to; usually this is
8249 TAG, but it could be something else if TAG was #t (i.e., a
8250 catch-all), or the user threw to a jmpbuf.
8251 THROW_ARGS is the list of arguments the user passed to the THROW
8252 function.
8253
8254BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
8255is just a pointer we pass through to HANDLER. We don't actually
8256use either of those pointers otherwise ourselves. The idea is
8257that, if our caller wants to communicate something to BODY or
8258HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
8259HANDLER can then use. Think of it as a way to make BODY and
8260HANDLER closures, not just functions; MUMBLE_DATA points to the
8261enclosed variables.
8262
8263Of course, it's up to the caller to make sure that any data a
8264MUMBLE_DATA needs is protected from GC. A common way to do this is
8265to make MUMBLE_DATA a pointer to data stored in an automatic
8266structure variable; since the collector must scan the stack for
8267references anyway, this assures that any references in MUMBLE_DATA
8268will be found.
8269
8270** The new function scm_internal_lazy_catch is exactly like
8271scm_internal_catch, except:
8272
8273- It does not unwind the stack (this is the major difference).
8274- If handler returns, its value is returned from the throw.
8275- BODY always receives #f as its JMPBUF argument (since there's no
8276 jmpbuf associated with a lazy catch, because we don't unwind the
8277 stack.)
8278
8279** scm_body_thunk is a new body function you can pass to
8280scm_internal_catch if you want the body to be like Scheme's `catch'
8281--- a thunk, or a function of one argument if the tag is #f.
8282
8283BODY_DATA is a pointer to a scm_body_thunk_data structure, which
8284contains the Scheme procedure to invoke as the body, and the tag
8285we're catching. If the tag is #f, then we pass JMPBUF (created by
8286scm_internal_catch) to the body procedure; otherwise, the body gets
8287no arguments.
8288
8289** scm_handle_by_proc is a new handler function you can pass to
8290scm_internal_catch if you want the handler to act like Scheme's catch
8291--- call a procedure with the tag and the throw arguments.
8292
8293If the user does a throw to this catch, this function runs a handler
8294procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
8295variable holding the Scheme procedure object to invoke. It ought to
8296be a pointer to an automatic variable (i.e., one living on the stack),
8297or the procedure object should be otherwise protected from GC.
8298
8299** scm_handle_by_message is a new handler function to use with
8300`scm_internal_catch' if you want Guile to print a message and die.
8301It's useful for dealing with throws to uncaught keys at the top level.
8302
8303HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
8304message header to print; if zero, we use "guile" instead. That
8305text is followed by a colon, then the message described by ARGS.
8306
8307** The return type of scm_boot_guile is now void; the function does
8308not return a value, and indeed, never returns at all.
8309
f3b1485f
JB
8310** The new function scm_shell makes it easy for user applications to
8311process command-line arguments in a way that is compatible with the
8312stand-alone guile interpreter (which is in turn compatible with SCSH,
8313the Scheme shell).
8314
8315To use the scm_shell function, first initialize any guile modules
8316linked into your application, and then call scm_shell with the values
7ed46dc8 8317of ARGC and ARGV your `main' function received. scm_shell will add
f3b1485f
JB
8318any SCSH-style meta-arguments from the top of the script file to the
8319argument vector, and then process the command-line arguments. This
8320generally means loading a script file or starting up an interactive
8321command interpreter. For details, see "Changes to the stand-alone
8322interpreter" above.
8323
095936d2 8324** The new functions scm_get_meta_args and scm_count_argv help you
6c0201ad 8325implement the SCSH-style meta-argument, `\'.
095936d2
JB
8326
8327char **scm_get_meta_args (int ARGC, char **ARGV)
8328 If the second element of ARGV is a string consisting of a single
8329 backslash character (i.e. "\\" in Scheme notation), open the file
8330 named by the following argument, parse arguments from it, and return
8331 the spliced command line. The returned array is terminated by a
8332 null pointer.
6c0201ad 8333
095936d2
JB
8334 For details of argument parsing, see above, under "guile now accepts
8335 command-line arguments compatible with SCSH..."
8336
8337int scm_count_argv (char **ARGV)
8338 Count the arguments in ARGV, assuming it is terminated by a null
8339 pointer.
8340
8341For an example of how these functions might be used, see the source
8342code for the function scm_shell in libguile/script.c.
8343
8344You will usually want to use scm_shell instead of calling this
8345function yourself.
8346
8347** The new function scm_compile_shell_switches turns an array of
8348command-line arguments into Scheme code to carry out the actions they
8349describe. Given ARGC and ARGV, it returns a Scheme expression to
8350evaluate, and calls scm_set_program_arguments to make any remaining
8351command-line arguments available to the Scheme code. For example,
8352given the following arguments:
8353
8354 -e main -s ekko a speckled gecko
8355
8356scm_set_program_arguments will return the following expression:
8357
8358 (begin (load "ekko") (main (command-line)) (quit))
8359
8360You will usually want to use scm_shell instead of calling this
8361function yourself.
8362
8363** The function scm_shell_usage prints a usage message appropriate for
8364an interpreter that uses scm_compile_shell_switches to handle its
8365command-line arguments.
8366
8367void scm_shell_usage (int FATAL, char *MESSAGE)
8368 Print a usage message to the standard error output. If MESSAGE is
8369 non-zero, write it before the usage message, followed by a newline.
8370 If FATAL is non-zero, exit the process, using FATAL as the
8371 termination status. (If you want to be compatible with Guile,
8372 always use 1 as the exit status when terminating due to command-line
8373 usage problems.)
8374
8375You will usually want to use scm_shell instead of calling this
8376function yourself.
48d224d7
JB
8377
8378** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
8379expressions. It used to return SCM_EOL. Earth-shattering.
8380
8381** The macros for declaring scheme objects in C code have been
8382rearranged slightly. They are now:
8383
8384SCM_SYMBOL (C_NAME, SCHEME_NAME)
8385 Declare a static SCM variable named C_NAME, and initialize it to
8386 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
8387 be a C identifier, and SCHEME_NAME should be a C string.
8388
8389SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
8390 Just like SCM_SYMBOL, but make C_NAME globally visible.
8391
8392SCM_VCELL (C_NAME, SCHEME_NAME)
8393 Create a global variable at the Scheme level named SCHEME_NAME.
8394 Declare a static SCM variable named C_NAME, and initialize it to
8395 point to the Scheme variable's value cell.
8396
8397SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
8398 Just like SCM_VCELL, but make C_NAME globally visible.
8399
8400The `guile-snarf' script writes initialization code for these macros
8401to its standard output, given C source code as input.
8402
8403The SCM_GLOBAL macro is gone.
8404
8405** The scm_read_line and scm_read_line_x functions have been replaced
8406by Scheme code based on the %read-delimited! procedure (known to C
8407code as scm_read_delimited_x). See its description above for more
8408information.
48d224d7 8409
095936d2
JB
8410** The function scm_sys_open has been renamed to scm_open. It now
8411returns a port instead of an FD object.
ea00ecba 8412
095936d2
JB
8413* The dynamic linking support has changed. For more information, see
8414libguile/DYNAMIC-LINKING.
ea00ecba 8415
f7b47737
JB
8416\f
8417Guile 1.0b3
3065a62a 8418
f3b1485f
JB
8419User-visible changes from Thursday, September 5, 1996 until Guile 1.0
8420(Sun 5 Jan 1997):
3065a62a 8421
4b521edb 8422* Changes to the 'guile' program:
3065a62a 8423
4b521edb
JB
8424** Guile now loads some new files when it starts up. Guile first
8425searches the load path for init.scm, and loads it if found. Then, if
8426Guile is not being used to execute a script, and the user's home
8427directory contains a file named `.guile', Guile loads that.
c6486f8a 8428
4b521edb 8429** You can now use Guile as a shell script interpreter.
3065a62a
JB
8430
8431To paraphrase the SCSH manual:
8432
8433 When Unix tries to execute an executable file whose first two
8434 characters are the `#!', it treats the file not as machine code to
8435 be directly executed by the native processor, but as source code
8436 to be executed by some interpreter. The interpreter to use is
8437 specified immediately after the #! sequence on the first line of
8438 the source file. The kernel reads in the name of the interpreter,
8439 and executes that instead. It passes the interpreter the source
8440 filename as its first argument, with the original arguments
8441 following. Consult the Unix man page for the `exec' system call
8442 for more information.
8443
1a1945be
JB
8444Now you can use Guile as an interpreter, using a mechanism which is a
8445compatible subset of that provided by SCSH.
8446
3065a62a
JB
8447Guile now recognizes a '-s' command line switch, whose argument is the
8448name of a file of Scheme code to load. It also treats the two
8449characters `#!' as the start of a comment, terminated by `!#'. Thus,
8450to make a file of Scheme code directly executable by Unix, insert the
8451following two lines at the top of the file:
8452
8453#!/usr/local/bin/guile -s
8454!#
8455
8456Guile treats the argument of the `-s' command-line switch as the name
8457of a file of Scheme code to load, and treats the sequence `#!' as the
8458start of a block comment, terminated by `!#'.
8459
8460For example, here's a version of 'echo' written in Scheme:
8461
8462#!/usr/local/bin/guile -s
8463!#
8464(let loop ((args (cdr (program-arguments))))
8465 (if (pair? args)
8466 (begin
8467 (display (car args))
8468 (if (pair? (cdr args))
8469 (display " "))
8470 (loop (cdr args)))))
8471(newline)
8472
8473Why does `#!' start a block comment terminated by `!#', instead of the
8474end of the line? That is the notation SCSH uses, and although we
8475don't yet support the other SCSH features that motivate that choice,
8476we would like to be backward-compatible with any existing Guile
3763761c
JB
8477scripts once we do. Furthermore, if the path to Guile on your system
8478is too long for your kernel, you can start the script with this
8479horrible hack:
8480
8481#!/bin/sh
8482exec /really/long/path/to/guile -s "$0" ${1+"$@"}
8483!#
3065a62a
JB
8484
8485Note that some very old Unix systems don't support the `#!' syntax.
8486
c6486f8a 8487
4b521edb 8488** You can now run Guile without installing it.
6685dc83
JB
8489
8490Previous versions of the interactive Guile interpreter (`guile')
8491couldn't start up unless Guile's Scheme library had been installed;
8492they used the value of the environment variable `SCHEME_LOAD_PATH'
8493later on in the startup process, but not to find the startup code
8494itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
8495code.
8496
8497To run Guile without installing it, build it in the normal way, and
8498then set the environment variable `SCHEME_LOAD_PATH' to a
8499colon-separated list of directories, including the top-level directory
8500of the Guile sources. For example, if you unpacked Guile so that the
8501full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
8502you might say
8503
8504 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
8505
c6486f8a 8506
4b521edb
JB
8507** Guile's read-eval-print loop no longer prints #<unspecified>
8508results. If the user wants to see this, she can evaluate the
8509expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 8510file.
6685dc83 8511
4b521edb
JB
8512** Guile no longer shows backtraces by default when an error occurs;
8513however, it does display a message saying how to get one, and how to
8514request that they be displayed by default. After an error, evaluate
8515 (backtrace)
8516to see a backtrace, and
8517 (debug-enable 'backtrace)
8518to see them by default.
6685dc83 8519
6685dc83 8520
d9fb83d9 8521
4b521edb
JB
8522* Changes to Guile Scheme:
8523
8524** Guile now distinguishes between #f and the empty list.
8525
8526This is for compatibility with the IEEE standard, the (possibly)
8527upcoming Revised^5 Report on Scheme, and many extant Scheme
8528implementations.
8529
8530Guile used to have #f and '() denote the same object, to make Scheme's
8531type system more compatible with Emacs Lisp's. However, the change
8532caused too much trouble for Scheme programmers, and we found another
8533way to reconcile Emacs Lisp with Scheme that didn't require this.
8534
8535
8536** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
8537counterparts, delq!, delv!, and delete!, now remove all matching
8538elements from the list, not just the first. This matches the behavior
8539of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
8540functions which inspired them.
8541
8542I recognize that this change may break code in subtle ways, but it
8543seems best to make the change before the FSF's first Guile release,
8544rather than after.
8545
8546
4b521edb 8547** The compiled-library-path function has been deleted from libguile.
6685dc83 8548
4b521edb 8549** The facilities for loading Scheme source files have changed.
c6486f8a 8550
4b521edb 8551*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
8552for Scheme code. Its value is a list of strings, each of which names
8553a directory.
8554
4b521edb
JB
8555*** The variable %load-extensions now tells Guile which extensions to
8556try appending to a filename when searching the load path. Its value
8557is a list of strings. Its default value is ("" ".scm").
8558
8559*** (%search-load-path FILENAME) searches the directories listed in the
8560value of the %load-path variable for a Scheme file named FILENAME,
8561with all the extensions listed in %load-extensions. If it finds a
8562match, then it returns its full filename. If FILENAME is absolute, it
8563returns it unchanged. Otherwise, it returns #f.
6685dc83 8564
4b521edb
JB
8565%search-load-path will not return matches that refer to directories.
8566
8567*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
8568uses %seach-load-path to find a file named FILENAME, and loads it if
8569it finds it. If it can't read FILENAME for any reason, it throws an
8570error.
6685dc83
JB
8571
8572The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
8573`read' function.
8574
8575*** load uses the same searching semantics as primitive-load.
8576
8577*** The functions %try-load, try-load-with-path, %load, load-with-path,
8578basic-try-load-with-path, basic-load-with-path, try-load-module-with-
8579path, and load-module-with-path have been deleted. The functions
8580above should serve their purposes.
8581
8582*** If the value of the variable %load-hook is a procedure,
8583`primitive-load' applies its value to the name of the file being
8584loaded (without the load path directory name prepended). If its value
8585is #f, it is ignored. Otherwise, an error occurs.
8586
8587This is mostly useful for printing load notification messages.
8588
8589
8590** The function `eval!' is no longer accessible from the scheme level.
8591We can't allow operations which introduce glocs into the scheme level,
8592because Guile's type system can't handle these as data. Use `eval' or
8593`read-and-eval!' (see below) as replacement.
8594
8595** The new function read-and-eval! reads an expression from PORT,
8596evaluates it, and returns the result. This is more efficient than
8597simply calling `read' and `eval', since it is not necessary to make a
8598copy of the expression for the evaluator to munge.
8599
8600Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
8601for the `read' function.
8602
8603
8604** The function `int?' has been removed; its definition was identical
8605to that of `integer?'.
8606
8607** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
8608use the R4RS names for these functions.
8609
8610** The function object-properties no longer returns the hash handle;
8611it simply returns the object's property list.
8612
8613** Many functions have been changed to throw errors, instead of
8614returning #f on failure. The point of providing exception handling in
8615the language is to simplify the logic of user code, but this is less
8616useful if Guile's primitives don't throw exceptions.
8617
8618** The function `fileno' has been renamed from `%fileno'.
8619
8620** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
8621
8622
8623* Changes to Guile's C interface:
8624
8625** The library's initialization procedure has been simplified.
8626scm_boot_guile now has the prototype:
8627
8628void scm_boot_guile (int ARGC,
8629 char **ARGV,
8630 void (*main_func) (),
8631 void *closure);
8632
8633scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
8634MAIN_FUNC should do all the work of the program (initializing other
8635packages, reading user input, etc.) before returning. When MAIN_FUNC
8636returns, call exit (0); this function never returns. If you want some
8637other exit value, MAIN_FUNC may call exit itself.
8638
8639scm_boot_guile arranges for program-arguments to return the strings
8640given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
8641scm_set_program_arguments with the final list, so Scheme code will
8642know which arguments have been processed.
8643
8644scm_boot_guile establishes a catch-all catch handler which prints an
8645error message and exits the process. This means that Guile exits in a
8646coherent way when system errors occur and the user isn't prepared to
8647handle it. If the user doesn't like this behavior, they can establish
8648their own universal catcher in MAIN_FUNC to shadow this one.
8649
8650Why must the caller do all the real work from MAIN_FUNC? The garbage
8651collector assumes that all local variables of type SCM will be above
8652scm_boot_guile's stack frame on the stack. If you try to manipulate
8653SCM values after this function returns, it's the luck of the draw
8654whether the GC will be able to find the objects you allocate. So,
8655scm_boot_guile function exits, rather than returning, to discourage
8656people from making that mistake.
8657
8658The IN, OUT, and ERR arguments were removed; there are other
8659convenient ways to override these when desired.
8660
8661The RESULT argument was deleted; this function should never return.
8662
8663The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
8664general.
8665
8666
8667** Guile's header files should no longer conflict with your system's
8668header files.
8669
8670In order to compile code which #included <libguile.h>, previous
8671versions of Guile required you to add a directory containing all the
8672Guile header files to your #include path. This was a problem, since
8673Guile's header files have names which conflict with many systems'
8674header files.
8675
8676Now only <libguile.h> need appear in your #include path; you must
8677refer to all Guile's other header files as <libguile/mumble.h>.
8678Guile's installation procedure puts libguile.h in $(includedir), and
8679the rest in $(includedir)/libguile.
8680
8681
8682** Two new C functions, scm_protect_object and scm_unprotect_object,
8683have been added to the Guile library.
8684
8685scm_protect_object (OBJ) protects OBJ from the garbage collector.
8686OBJ will not be freed, even if all other references are dropped,
8687until someone does scm_unprotect_object (OBJ). Both functions
8688return OBJ.
8689
8690Note that calls to scm_protect_object do not nest. You can call
8691scm_protect_object any number of times on a given object, and the
8692next call to scm_unprotect_object will unprotect it completely.
8693
8694Basically, scm_protect_object and scm_unprotect_object just
8695maintain a list of references to things. Since the GC knows about
8696this list, all objects it mentions stay alive. scm_protect_object
8697adds its argument to the list; scm_unprotect_object remove its
8698argument from the list.
8699
8700
8701** scm_eval_0str now returns the value of the last expression
8702evaluated.
8703
8704** The new function scm_read_0str reads an s-expression from a
8705null-terminated string, and returns it.
8706
8707** The new function `scm_stdio_to_port' converts a STDIO file pointer
8708to a Scheme port object.
8709
8710** The new function `scm_set_program_arguments' allows C code to set
e80c8fea 8711the value returned by the Scheme `program-arguments' function.
6685dc83 8712
6685dc83 8713\f
1a1945be
JB
8714Older changes:
8715
8716* Guile no longer includes sophisticated Tcl/Tk support.
8717
8718The old Tcl/Tk support was unsatisfying to us, because it required the
8719user to link against the Tcl library, as well as Tk and Guile. The
8720interface was also un-lispy, in that it preserved Tcl/Tk's practice of
8721referring to widgets by names, rather than exporting widgets to Scheme
8722code as a special datatype.
8723
8724In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
8725maintainers described some very interesting changes in progress to the
8726Tcl/Tk internals, which would facilitate clean interfaces between lone
8727Tk and other interpreters --- even for garbage-collected languages
8728like Scheme. They expected the new Tk to be publicly available in the
8729fall of 1996.
8730
8731Since it seems that Guile might soon have a new, cleaner interface to
8732lone Tk, and that the old Guile/Tk glue code would probably need to be
8733completely rewritten, we (Jim Blandy and Richard Stallman) have
8734decided not to support the old code. We'll spend the time instead on
8735a good interface to the newer Tk, as soon as it is available.
5c54da76 8736
8512dea6 8737Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 8738
5c54da76
JB
8739\f
8740Copyright information:
8741
4f416616 8742Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
5c54da76
JB
8743
8744 Permission is granted to anyone to make or distribute verbatim copies
8745 of this document as received, in any medium, provided that the
8746 copyright notice and this permission notice are preserved,
8747 thus giving the recipient permission to redistribute in turn.
8748
8749 Permission is granted to distribute modified versions
8750 of this document, or of portions of it,
8751 under the above conditions, provided also that they
8752 carry prominent notices stating who last changed them.
8753
48d224d7
JB
8754\f
8755Local variables:
8756mode: outline
8757paragraph-separate: "[ \f]*$"
8758end: