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