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