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