*** empty log message ***
[bpt/guile.git] / NEWS
CommitLineData
f7b47737 1Guile NEWS --- history of user-visible changes. -*- text -*-
ffd0ef3b 2Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
5c54da76
JB
3See the end for copying conditions.
4
e1b6c710 5Please send Guile bug reports to bug-guile@gnu.org.
5c54da76 6\f
ee0c7345
MV
7Changes since the stable branch:
8
4e250ded
MV
9* Changes to the distribution
10
f0b4d944
MV
11** There is a new thread implementation option: "null".
12
13When you configure "--with-threads=null", you will get the usual
14threading API (call-with-new-thread, make-mutex, etc), but you can't
15actually create new threads.
16
17The short term plan is to remove the support for --with-threads=no
18completely so that one doesn't need to special case as much when
19writing code that needs to be thread-aware but should also work
20without threads.
21
22The long term plan is to make the selection of a thread implementation
23a run-time option, not a configure time option.
24
4e250ded
MV
25** Guile now includes its own version of libltdl.
26
27We now use a modified version of libltdl that allows us to make
28improvements to it without having to rely on libtool releases.
29
f12ef3fd
MV
30* Changes to the standalone interpreter
31
32** New command line option `--no-debug'.
33
34Specifying `--no-debug' on the command line will keep the debugging
35evaluator turned off, even for interactive sessions.
36
37** User-init file ~/.guile is now loaded with the debugging evaluator.
38
39Previously, the normal evaluator would have been used. Using the
40debugging evaluator gives better error messages.
41
42* Changes to Scheme functions and syntax
43
5e405a60
MV
44** New functions 'all-threads' and 'current-thread'.
45
46** Signals and system asyncs work better with threads.
47
48The function 'sigaction' now takes a fourth, optional, argument that
49specifies the thread that the handler should run in. When the
50argument is omitted, the handler will run in the thread that called
51'sigaction'.
52
53Likewise, 'system-async-mark' takes a second, optional, argument that
54specifies the thread that the async should run in. When it is
55omitted, the async will run in the thread that called
56'system-async-mark'.
57
58C code can use the new functions scm_sigaction_for_thread and
59scm_system_async_mark_for_thread to pass the new thread argument.
60
61** The function 'system-async' is deprecated.
62
63You can now pass any zero-argument procedure to 'system-async-mark'.
64The function 'system-async' will just return its argument unchanged
65now.
66
acfa1f52
MV
67** New functions 'call-with-blocked-asyncs' and
68 'call-with-unblocked-asyncs'
69
70The expression (call-with-blocked-asyncs PROC) will call PROC and will
71block execution of system asyncs for the current thread by one level
72while PROC runs. Likewise, call-with-unblocked-asyncs will call a
73procedure and will unblock the execution of system asyncs by one
74level for the current thread.
75
76Only system asyncs are affected by these functions.
77
78** The functions 'mask-signals' and 'unmask-signals' are deprecated.
79
80Use 'call-with-blocked-asyncs' or 'call-with-unblocked-asyncs'
81instead. Those functions are easier to use correctly and can be
82nested.
83
7b232758
MV
84** New function 'unsetenv'.
85
f30482f3
MV
86** New macro 'define-syntax-public'.
87
88It works like 'define-syntax' and also exports the defined macro (but
89only on top-level).
90
1ee34062
MV
91** There is support for Infinity and NaNs.
92
93Following PLT Scheme, Guile can now work with infinite numbers, and
94'not-a-numbers'.
95
96There is new syntax for numbers: "+inf.0" (infinity), "-inf.0"
97(negative infinity), "+nan.0" (not-a-number), and "-nan.0" (same as
98"+nan.0"). These numbers are inexact and have no exact counterpart.
99
100Dividing by an inexact zero returns +inf.0 or -inf.0, depending on the
101sign of the dividend. The infinities are integers, and they answer #t
102for both 'even?' and 'odd?'. The +nan.0 value is not an integer and is
103not '=' to itself, but '+nan.0' is 'eqv?' to itself.
104
105For example
106
107 (/ 1 0.0)
108 => +inf.0
109
110 (/ 0 0.0)
111 => +nan.0
112
113 (/ 0)
114 ERROR: Numerical overflow
115
7b232758
MV
116Two new predicates 'inf?' and 'nan?' can be used to test for the
117special values.
118
ba1b077b
MV
119** Inexact zero can have a sign.
120
121Guile can now distinguish between plus and minus inexact zero, if your
122platform supports this, too. The two zeros are equal according to
123'=', but not according to 'eqv?'. For example
124
125 (- 0.0)
126 => -0.0
127
128 (= 0.0 (- 0.0))
129 => #t
130
131 (eqv? 0.0 (- 0.0))
132 => #f
133
610922b2
MV
134** We now have uninterned symbols.
135
136The new function 'make-symbol' will return a uninterned symbol. This
137is a symbol that is unique and is guaranteed to remain unique.
138However, uninterned symbols can not yet be read back in.
139
140Use the new function 'symbol-interned?' to check whether a symbol is
141interned or not.
142
0e6f7775
MV
143** pretty-print has more options.
144
145The function pretty-print from the (ice-9 pretty-print) module can now
146also be invoked with keyword arguments that control things like
147maximum output width. See its online documentation.
148
8c84b81e 149** Variables have no longer a special behavior for `equal?'.
ee0c7345
MV
150
151Previously, comparing two variables with `equal?' would recursivly
152compare their values. This is no longer done. Variables are now only
153`equal?' if they are `eq?'.
154
4e21fa60
MV
155** `(begin)' is now valid.
156
157You can now use an empty `begin' form. It will yield #<unspecified>
158when evaluated and simply be ignored in a definition context.
159
adb8c0f2
MV
160** Removed: substring-move-left!, substring-move-right!
161
162Use `substring-move!' instead.
163
3063e30a
DH
164** Deprecated: procedure->macro
165
166Change your code to use either procedure->memoizing-macro or, probably better,
167to use r5rs macros. Also, be aware that macro expansion will not be done
168during evaluation, but prior to evaluation.
169
0a50eeaa
NJ
170** Soft ports now allow a `char-ready?' procedure
171
172The vector argument to `make-soft-port' can now have a length of
173either 5 or 6. (Previously the length had to be 5.) The optional 6th
174element is interpreted as an `input-waiting' thunk -- i.e. a thunk
175that returns the number of characters that can be read immediately
176without the soft port blocking.
177
b00418df
DH
178* Changes to the C interface
179
acfa1f52
MV
180** The value 'scm_mask_ints' is no longer writable.
181
182Previously, you could set scm_mask_ints directly. This is no longer
183possible. Use scm_c_call_with_blocked_asyncs and
184scm_c_call_with_unblocked_asyncs instead.
185
186** New functions scm_c_call_with_blocked_asyncs and
187 scm_c_call_with_unblocked_asyncs
188
189Like scm_call_with_blocked_asyncs etc. but for C functions.
190
ffd0ef3b
MV
191** New snarfer macro SCM_DEFINE_PUBLIC.
192
193This is like SCM_DEFINE, but also calls scm_c_export for the defined
194function in the init section.
195
8734ce02
MV
196** The snarfer macro SCM_SNARF_INIT is now officially supported.
197
f30482f3
MV
198** New macros SCM_VECTOR_REF and SCM_VECTOR_SET.
199
200Use these in preference to SCM_VELTS.
201
39e8f371 202** The SCM_VELTS macros now returns a read-only vector. For writing,
f30482f3 203use the new macros SCM_WRITABLE_VELTS or SCM_VECTOR_SET. The use of
ffd0ef3b 204SCM_WRITABLE_VELTS is discouraged, though.
39e8f371
HWN
205
206** Garbage collector rewrite.
207
208The garbage collector is cleaned up a lot, and now uses lazy
209sweeping. This is reflected in the output of (gc-stats); since cells
210are being freed when they are allocated, the cells-allocated field
211stays roughly constant.
212
213For malloc related triggers, the behavior is changed. It uses the same
214heuristic as the cell-triggered collections. It may be tuned with the
215environment variables GUILE_MIN_YIELD_MALLOC. This is the percentage
216for minimum yield of malloc related triggers. The default is 40.
217GUILE_INIT_MALLOC_LIMIT sets the initial trigger for doing a GC. The
218default is 200 kb.
219
220Debugging operations for the freelist have been deprecated, along with
221the C variables that control garbage collection. The environment
222variables GUILE_MAX_SEGMENT_SIZE, GUILE_INIT_SEGMENT_SIZE_2,
223GUILE_INIT_SEGMENT_SIZE_1, and GUILE_MIN_YIELD_2 should be used.
224
5ec1d2c8
DH
225** The function scm_definedp has been renamed to scm_defined_p
226
227The name scm_definedp is deprecated.
228
228a24ef
DH
229** The struct scm_cell has been renamed to scm_t_cell
230
231This is in accordance to Guile's naming scheme for types. Note that
232the name scm_cell is now used for a function that allocates and
233initializes a new cell (see below).
234
0906625f
MV
235** New functions for memory management
236
237A new set of functions for memory management has been added since the
238old way (scm_must_malloc, scm_must_free, etc) was error prone and
239indeed, Guile itself contained some long standing bugs that could
240cause aborts in long running programs.
241
242The new functions are more symmetrical and do not need cooperation
243from smob free routines, among other improvements.
244
eab1b259
HWN
245The new functions are scm_malloc, scm_realloc, scm_calloc, scm_strdup,
246scm_strndup, scm_gc_malloc, scm_gc_calloc, scm_gc_realloc,
247scm_gc_free, scm_gc_register_collectable_memory, and
0906625f
MV
248scm_gc_unregister_collectable_memory. Refer to the manual for more
249details and for upgrading instructions.
250
251The old functions for memory management have been deprecated. They
252are: scm_must_malloc, scm_must_realloc, scm_must_free,
253scm_must_strdup, scm_must_strndup, scm_done_malloc, scm_done_free.
254
b00418df
DH
255** New function: scm_str2string
256
257This function creates a scheme string from a 0-terminated C string. The input
258string is copied.
259
4aa104a4
MV
260** Declarations of exported features are marked with SCM_API.
261
262Every declaration of a feature that belongs to the exported Guile API
263has been marked by adding the macro "SCM_API" to the start of the
264declaration. This macro can expand into different things, the most
265common of which is just "extern" for Unix platforms. On Win32, it can
266be used to control which symbols are exported from a DLL.
267
8f99e3f3 268If you `#define SCM_IMPORT' before including <libguile.h>, SCM_API
4aa104a4
MV
269will expand into "__declspec (dllimport) extern", which is needed for
270linking to the Guile DLL in Windows.
271
8f99e3f3
SJ
272There are also SCM_RL_IMPORT, QT_IMPORT, SCM_SRFI1314_IMPORT, and
273SCM_SRFI4_IMPORT, for the corresponding libraries.
4aa104a4 274
a9930d22
MV
275** SCM_NEWCELL and SCM_NEWCELL2 have been deprecated.
276
228a24ef
DH
277Use the new functions scm_cell and scm_double_cell instead. The old macros
278had problems because with them allocation and initialization was separated and
279the GC could sometimes observe half initialized cells. Only careful coding by
280the user of SCM_NEWCELL and SCM_NEWCELL2 could make this safe and efficient.
a9930d22 281
5132eef0
DH
282** CHECK_ENTRY, CHECK_APPLY and CHECK_EXIT have been deprecated.
283
284Use the variables scm_check_entry_p, scm_check_apply_p and scm_check_exit_p
285instead.
286
bc76d628
DH
287** SRCBRKP has been deprecated.
288
289Use scm_c_source_property_breakpoint_p instead.
290
3063e30a
DH
291** Deprecated: scm_makmacro
292
293Change your code to use either scm_makmmacro or, probably better, to use r5rs
294macros. Also, be aware that macro expansion will not be done during
295evaluation, but prior to evaluation.
296
843fae71
GH
297** Removed from scm_root_state: def_inp, def_outp, def_errp, together
298with corresponding macros scm_def_inp, scm_def_outp and scm_def_errp.
299These were undocumented and unused copies of the standard ports at the
300time that Guile was initialised. Normally the current ports should be
301used instead, obtained from scm_current_input_port () etc. If an
302application needs to retain earlier ports, it should save them in a
303gc-protected location.
867cf9be 304
c136c920
DH
305** Removed compile time option MEMOIZE_LOCALS
306
307Now, caching of local variable positions during memoization is mandatory.
308However, the option to disable the caching has most probably not been used
309anyway.
310
8505e285
DH
311** Removed compile time option SCM_RECKLESS
312
313Full number of arguments checking of closures is mandatory now. However, the
314option to disable the checking has most probably not been used anyway.
315
bd987b8e
DH
316** Removed compile time option SCM_CAUTIOUS
317
318Full number of arguments checking of closures is mandatory now. However, the
319option to disable the checking has most probably not been used anyway.
320
b51bad08
DH
321** Removed definitions: scm_lisp_nil, scm_lisp_t, s_nil_ify, scm_m_nil_ify,
322s_t_ify, scm_m_t_ify, s_0_cond, scm_m_0_cond, s_0_ify, scm_m_0_ify, s_1_ify,
323scm_m_1_ify, scm_debug_newcell, scm_debug_newcell2, scm_tc16_allocated,
324SCM_SET_SYMBOL_HASH, SCM_IM_NIL_IFY, SCM_IM_T_IFY, SCM_IM_0_COND,
325SCM_IM_0_IFY, SCM_IM_1_IFY, SCM_GC_SET_ALLOCATED, scm_debug_newcell,
326scm_debug_newcell2, scm_substring_move_left_x, scm_substring_move_right_x,
327long_long, ulong_long, scm_sizet, SCM_WNA, SCM_OUTOFRANGE, SCM_NALLOC,
328SCM_HUP_SIGNAL, SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL,
329SCM_SEGV_SIGNAL, SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL,
330SCM_SIG_ORD, SCM_ORD_SIG, SCM_NUM_SIGS, moddata, registered_mods,
331scm_register_module_xxx, scm_registered_modules,
332scm_clear_registered_modules, scm_wta, *top-level-lookup-closure*,
333scm_top_level_lookup_closure_var, scm_system_transformer, scm_eval_3,
334scm_eval2, SCM_SETAND_CAR, SCM_SETOR_CAR, SCM_SETAND_CDR, SCM_SETOR_CDR,
335SCM_FREEP, SCM_NFREEP, SCM_GC8MARKP, SCM_SETGC8MARK, SCM_CLRGC8MARK,
336SCM_GCTYP16, SCM_GCCDR, scm_remember, scm_protect_object,
337scm_unprotect_object, root_module_lookup_closure, scm_sym_app,
338scm_sym_modules, module_prefix, make_modules_in_var,
339beautify_user_module_x_var, try_module_autoload_var, scm_module_full_name,
340scm_the_root_module, scm_make_module, scm_ensure_user_module,
341scm_load_scheme_module, scm_port, scm_ptob_descriptor, scm_port_rw_active,
342scm_close_all_ports_except, scm_rstate, scm_rng, scm_i_rstate,
343SCM_SLOPPY_STRINGP, SCM_RWSTRINGP, SCM_STRING_UCHARS, SCM_STRING_CHARS,
344scm_read_only_string_p, scm_makstr, scm_makfromstr,
345scm_make_shared_substring, scm_tc7_substring, SCM_SLOPPY_CONSP,
346SCM_SLOPPY_NCONSP, scm_tc7_ssymbol, scm_tc7_msymbol, scm_tcs_symbols,
347sym_huh, scm_variable_set_name_hint, scm_builtin_variable, SCM_VARVCELL,
348SCM_UDVARIABLEP, SCM_DEFVARIABLEP, scm_internal_with_fluids,
349scm_make_gsubr, scm_make_gsubr_with_generic, scm_create_hook, list*,
350SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
351SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify, scm_sloppy_memq,
352scm_sloppy_memv, scm_sloppy_member, scm_end_of_file_key,
353scm_read_and_eval_x, scm_mkbig, scm_big2inum, scm_adjbig, scm_normbig,
354scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl, SCM_FIXNUM_BIT,
355scm_subr_entry, SCM_SUBR_DOC, scm_make_subr_opt, scm_make_subr,
356scm_make_subr_with_generic, setjmp_type, setjmp_type,
357scm_call_catching_errors, scm_make_smob_type_mfpe, scm_set_smob_mfpe,
358scm_strprint_obj, scm_read_0str, scm_eval_0str, SCM_CHARS, SCM_UCHARS,
359SCM_SETCHARS, SCM_SLOPPY_SUBSTRP, SCM_SUBSTR_STR, SCM_SUBSTR_OFFSET,
360SCM_LENGTH_MAX, SCM_LENGTH, SCM_SETLENGTH, SCM_ROSTRINGP, SCM_ROLENGTH,
361SCM_ROCHARS, SCM_ROUCHARS, SCM_SUBSTRP, SCM_COERCE_SUBSTR, scm_strhash,
362scm_sym2vcell, scm_sym2ovcell_soft, scm_sym2ovcell,
363scm_intern_obarray_soft, scm_intern_obarray, scm_intern, scm_intern0,
364scm_sysintern, scm_sysintern0, scm_sysintern0_no_module_lookup,
365scm_symbol_value0, scm_string_to_obarray_symbol, scm_intern_symbol,
366scm_unintern_symbol, scm_symbol_binding, scm_symbol_interned_p,
367scm_symbol_bound_p, scm_symbol_set_x, scm_gentemp,
368scm_init_symbols_deprecated, s_vector_set_length_x, scm_vector_set_length_x,
369scm_contregs, scm_debug_info, scm_debug_frame, SCM_DSIDEVAL, SCM_OPDIRP,
370scm_fport, scm_option, SCM_CONST_LONG, SCM_VCELL, SCM_GLOBAL_VCELL,
371SCM_VCELL_INIT, SCM_GLOBAL_VCELL_INIT, scm_srcprops, scm_srcprops_chunk,
372scm_info_frame, scm_stack, scm_array, scm_array_dim, SCM_ARRAY_CONTIGUOUS,
373SCM_HUGE_LENGTH, SCM_FUNC_NAME, SCM_WTA, RETURN_SCM_WTA,
374SCM_VALIDATE_NUMBER_COPY, SCM_VALIDATE_NUMBER_DEF_COPY,
375SCM_VALIDATE_STRINGORSUBSTR, SCM_VALIDATE_ROSTRING,
376SCM_VALIDATE_ROSTRING_COPY, SCM_VALIDATE_NULLORROSTRING_COPY,
377SCM_VALIDATE_RWSTRING, SCM_VALIDATE_OPDIR, DIGITS, scm_small_istr2int,
378scm_istr2int, scm_istr2flo, scm_istring2number, scm_istr2int,
379scm_istr2flo, scm_istring2number, scm_vtable_index_vcell, scm_si_vcell,
380SCM_ECONSP, SCM_NECONSP, SCM_GLOC_VAR, SCM_GLOC_VAL, SCM_GLOC_SET_VAL,
381SCM_GLOC_VAL_LOC, scm_make_gloc, scm_gloc_p, scm_tc16_variable
382
c299f186
MD
383Changes since Guile 1.4:
384
385* Changes to the distribution
386
32d6f999
TTN
387** A top-level TODO file is included.
388
311b6a3c 389** Guile now uses a versioning scheme similar to that of the Linux kernel.
c81ea65d
RB
390
391Guile now always uses three numbers to represent the version,
392i.e. "1.6.5". The first number, 1, is the major version number, the
393second number, 6, is the minor version number, and the third number,
3945, is the micro version number. Changes in major version number
395indicate major changes in Guile.
396
397Minor version numbers that are even denote stable releases, and odd
398minor version numbers denote development versions (which may be
399unstable). The micro version number indicates a minor sub-revision of
400a given MAJOR.MINOR release.
401
402In keeping with the new scheme, (minor-version) and scm_minor_version
403no longer return everything but the major version number. They now
404just return the minor version number. Two new functions
405(micro-version) and scm_micro_version have been added to report the
406micro version number.
407
408In addition, ./GUILE-VERSION now defines GUILE_MICRO_VERSION.
409
5c790b44
RB
410** New preprocessor definitions are available for checking versions.
411
412version.h now #defines SCM_MAJOR_VERSION, SCM_MINOR_VERSION, and
413SCM_MICRO_VERSION to the appropriate integer values.
414
311b6a3c
MV
415** Guile now actively warns about deprecated features.
416
417The new configure option `--enable-deprecated=LEVEL' and the
418environment variable GUILE_WARN_DEPRECATED control this mechanism.
419See INSTALL and README for more information.
420
0b073f0f
RB
421** Guile is much more likely to work on 64-bit architectures.
422
423Guile now compiles and passes "make check" with only two UNRESOLVED GC
5e137c65
RB
424cases on Alpha and ia64 based machines now. Thanks to John Goerzen
425for the use of a test machine, and thanks to Stefan Jahn for ia64
426patches.
0b073f0f 427
e658215a
RB
428** New functions: setitimer and getitimer.
429
430These implement a fairly direct interface to the libc functions of the
431same name.
432
8630fdfc
RB
433** The #. reader extension is now disabled by default.
434
435For safety reasons, #. evaluation is disabled by default. To
436re-enable it, set the fluid read-eval? to #t. For example:
437
67b7dd9e 438 (fluid-set! read-eval? #t)
8630fdfc
RB
439
440but make sure you realize the potential security risks involved. With
441read-eval? enabled, reading a data file from an untrusted source can
442be dangerous.
443
f2a75d81 444** New SRFI modules have been added:
4df36934 445
dfdf5826
MG
446SRFI-0 `cond-expand' is now supported in Guile, without requiring
447using a module.
448
e8bb0476
MG
449(srfi srfi-1) is a library containing many useful pair- and list-processing
450 procedures.
451
7adc2c58 452(srfi srfi-2) exports and-let*.
4df36934 453
b74a7ec8
MG
454(srfi srfi-4) implements homogeneous numeric vector datatypes.
455
7adc2c58
RB
456(srfi srfi-6) is a dummy module for now, since guile already provides
457 all of the srfi-6 procedures by default: open-input-string,
458 open-output-string, get-output-string.
4df36934 459
7adc2c58 460(srfi srfi-8) exports receive.
4df36934 461
7adc2c58 462(srfi srfi-9) exports define-record-type.
4df36934 463
dfdf5826
MG
464(srfi srfi-10) exports define-reader-ctor and implements the reader
465 extension #,().
466
7adc2c58 467(srfi srfi-11) exports let-values and let*-values.
4df36934 468
7adc2c58 469(srfi srfi-13) implements the SRFI String Library.
53e29a1e 470
7adc2c58 471(srfi srfi-14) implements the SRFI Character-Set Library.
53e29a1e 472
dfdf5826
MG
473(srfi srfi-17) implements setter and getter-with-setter and redefines
474 some accessor procedures as procedures with getters. (such as car,
475 cdr, vector-ref etc.)
476
477(srfi srfi-19) implements the SRFI Time/Date Library.
2b60bc95 478
466bb4b3
TTN
479** New scripts / "executable modules"
480
481Subdirectory "scripts" contains Scheme modules that are packaged to
482also be executable as scripts. At this time, these scripts are available:
483
484 display-commentary
485 doc-snarf
486 generate-autoload
487 punify
58e5b910 488 read-scheme-source
466bb4b3
TTN
489 use2dot
490
491See README there for more info.
492
54c17ccb
TTN
493These scripts can be invoked from the shell with the new program
494"guile-tools", which keeps track of installation directory for you.
495For example:
496
497 $ guile-tools display-commentary srfi/*.scm
498
499guile-tools is copied to the standard $bindir on "make install".
500
0109c4bf
MD
501** New module (ice-9 stack-catch):
502
503stack-catch is like catch, but saves the current state of the stack in
3c1d1301
RB
504the fluid the-last-stack. This fluid can be useful when using the
505debugger and when re-throwing an error.
0109c4bf 506
fbf0c8c7
MV
507** The module (ice-9 and-let*) has been renamed to (ice-9 and-let-star)
508
509This has been done to prevent problems on lesser operating systems
510that can't tolerate `*'s in file names. The exported macro continues
511to be named `and-let*', of course.
512
4f60cc33 513On systems that support it, there is also a compatibility module named
fbf0c8c7 514(ice-9 and-let*). It will go away in the next release.
6c0201ad 515
9d774814 516** New modules (oop goops) etc.:
14f1d9fe
MD
517
518 (oop goops)
519 (oop goops describe)
520 (oop goops save)
521 (oop goops active-slot)
522 (oop goops composite-slot)
523
9d774814 524The Guile Object Oriented Programming System (GOOPS) has been
311b6a3c
MV
525integrated into Guile. For further information, consult the GOOPS
526manual and tutorial in the `doc' directory.
14f1d9fe 527
9d774814
GH
528** New module (ice-9 rdelim).
529
530This exports the following procedures which were previously defined
1c8cbd62 531in the default environment:
9d774814 532
1c8cbd62
GH
533read-line read-line! read-delimited read-delimited! %read-delimited!
534%read-line write-line
9d774814 535
1c8cbd62
GH
536For backwards compatibility the definitions are still imported into the
537default environment in this version of Guile. However you should add:
9d774814
GH
538
539(use-modules (ice-9 rdelim))
540
1c8cbd62
GH
541to any program which uses the definitions, since this may change in
542future.
9d774814
GH
543
544Alternatively, if guile-scsh is installed, the (scsh rdelim) module
545can be used for similar functionality.
546
7e267da1
GH
547** New module (ice-9 rw)
548
549This is a subset of the (scsh rw) module from guile-scsh. Currently
373f4948 550it defines two procedures:
7e267da1 551
311b6a3c 552*** New function: read-string!/partial str [port_or_fdes [start [end]]]
7e267da1 553
4bcdfe46
GH
554 Read characters from a port or file descriptor into a string STR.
555 A port must have an underlying file descriptor -- a so-called
556 fport. This procedure is scsh-compatible and can efficiently read
311b6a3c 557 large strings.
7e267da1 558
4bcdfe46
GH
559*** New function: write-string/partial str [port_or_fdes [start [end]]]
560
561 Write characters from a string STR to a port or file descriptor.
562 A port must have an underlying file descriptor -- a so-called
563 fport. This procedure is mostly compatible and can efficiently
564 write large strings.
565
e5005373
KN
566** New module (ice-9 match)
567
311b6a3c
MV
568This module includes Andrew K. Wright's pattern matcher. See
569ice-9/match.scm for brief description or
e5005373 570
311b6a3c 571 http://www.star-lab.com/wright/code.html
e5005373 572
311b6a3c 573for complete documentation.
e5005373 574
4f60cc33
NJ
575** New module (ice-9 buffered-input)
576
577This module provides procedures to construct an input port from an
578underlying source of input that reads and returns its input in chunks.
579The underlying input source is a Scheme procedure, specified by the
580caller, which the port invokes whenever it needs more input.
581
582This is useful when building an input port whose back end is Readline
583or a UI element such as the GtkEntry widget.
584
585** Documentation
586
587The reference and tutorial documentation that was previously
588distributed separately, as `guile-doc', is now included in the core
589Guile distribution. The documentation consists of the following
590manuals.
591
592- The Guile Tutorial (guile-tut.texi) contains a tutorial introduction
593 to using Guile.
594
595- The Guile Reference Manual (guile.texi) contains (or is intended to
596 contain) reference documentation on all aspects of Guile.
597
598- The GOOPS Manual (goops.texi) contains both tutorial-style and
599 reference documentation for using GOOPS, Guile's Object Oriented
600 Programming System.
601
c3e62877
NJ
602- The Revised^5 Report on the Algorithmic Language Scheme
603 (r5rs.texi).
4f60cc33
NJ
604
605See the README file in the `doc' directory for more details.
606
094a67bb
MV
607** There are a couple of examples in the examples/ directory now.
608
9d774814
GH
609* Changes to the stand-alone interpreter
610
e7e58018
MG
611** New command line option `--use-srfi'
612
613Using this option, SRFI modules can be loaded on startup and be
614available right from the beginning. This makes programming portable
615Scheme programs easier.
616
617The option `--use-srfi' expects a comma-separated list of numbers,
618each representing a SRFI number to be loaded into the interpreter
619before starting evaluating a script file or the REPL. Additionally,
620the feature identifier for the loaded SRFIs is recognized by
621`cond-expand' when using this option.
622
623Example:
624$ guile --use-srfi=8,13
625guile> (receive (x z) (values 1 2) (+ 1 2))
6263
58e5b910 627guile> (string-pad "bla" 20)
e7e58018
MG
628" bla"
629
094a67bb
MV
630** Guile now always starts up in the `(guile-user)' module.
631
6e9382f1 632Previously, scripts executed via the `-s' option would run in the
094a67bb
MV
633`(guile)' module and the repl would run in the `(guile-user)' module.
634Now every user action takes place in the `(guile-user)' module by
635default.
e7e58018 636
c299f186
MD
637* Changes to Scheme functions and syntax
638
720e1c30
MV
639** Character classifiers work for non-ASCII characters.
640
641The predicates `char-alphabetic?', `char-numeric?',
642`char-whitespace?', `char-lower?', `char-upper?' and `char-is-both?'
643no longer check whether their arguments are ASCII characters.
644Previously, a character would only be considered alphabetic when it
645was also ASCII, for example.
646
311b6a3c
MV
647** Previously deprecated Scheme functions have been removed:
648
649 tag - no replacement.
650 fseek - replaced by seek.
651 list* - replaced by cons*.
652
653** It's now possible to create modules with controlled environments
654
655Example:
656
657(use-modules (ice-9 safe))
658(define m (make-safe-module))
659;;; m will now be a module containing only a safe subset of R5RS
660(eval '(+ 1 2) m) --> 3
661(eval 'load m) --> ERROR: Unbound variable: load
662
663** Evaluation of "()", the empty list, is now an error.
8c2c9967
MV
664
665Previously, the expression "()" evaluated to the empty list. This has
666been changed to signal a "missing expression" error. The correct way
667to write the empty list as a literal constant is to use quote: "'()".
668
311b6a3c
MV
669** New concept of `Guile Extensions'.
670
671A Guile Extension is just a ordinary shared library that can be linked
672at run-time. We found it advantageous to give this simple concept a
673dedicated name to distinguish the issues related to shared libraries
674from the issues related to the module system.
675
676*** New function: load-extension
677
678Executing (load-extension lib init) is mostly equivalent to
679
680 (dynamic-call init (dynamic-link lib))
681
682except when scm_register_extension has been called previously.
683Whenever appropriate, you should use `load-extension' instead of
684dynamic-link and dynamic-call.
685
686*** New C function: scm_c_register_extension
687
688This function registers a initialization function for use by
689`load-extension'. Use it when you don't want specific extensions to
690be loaded as shared libraries (for example on platforms that don't
691support dynamic linking).
692
8c2c9967
MV
693** Auto-loading of compiled-code modules is deprecated.
694
695Guile used to be able to automatically find and link a shared
c10ecc4c 696library to satisfy requests for a module. For example, the module
8c2c9967
MV
697`(foo bar)' could be implemented by placing a shared library named
698"foo/libbar.so" (or with a different extension) in a directory on the
699load path of Guile.
700
311b6a3c
MV
701This has been found to be too tricky, and is no longer supported. The
702shared libraries are now called "extensions". You should now write a
703small Scheme file that calls `load-extension' to load the shared
704library and initialize it explicitely.
8c2c9967
MV
705
706The shared libraries themselves should be installed in the usual
707places for shared libraries, with names like "libguile-foo-bar".
708
709For example, place this into a file "foo/bar.scm"
710
711 (define-module (foo bar))
712
311b6a3c
MV
713 (load-extension "libguile-foo-bar" "foobar_init")
714
715** Backward incompatible change: eval EXP ENVIRONMENT-SPECIFIER
716
717`eval' is now R5RS, that is it takes two arguments.
718The second argument is an environment specifier, i.e. either
719
720 (scheme-report-environment 5)
721 (null-environment 5)
722 (interaction-environment)
723
724or
8c2c9967 725
311b6a3c 726 any module.
8c2c9967 727
6f76852b
MV
728** The module system has been made more disciplined.
729
311b6a3c
MV
730The function `eval' will save and restore the current module around
731the evaluation of the specified expression. While this expression is
732evaluated, `(current-module)' will now return the right module, which
733is the module specified as the second argument to `eval'.
6f76852b 734
311b6a3c 735A consequence of this change is that `eval' is not particularly
6f76852b
MV
736useful when you want allow the evaluated code to change what module is
737designated as the current module and have this change persist from one
738call to `eval' to the next. The read-eval-print-loop is an example
739where `eval' is now inadequate. To compensate, there is a new
740function `primitive-eval' that does not take a module specifier and
741that does not save/restore the current module. You should use this
742function together with `set-current-module', `current-module', etc
743when you want to have more control over the state that is carried from
744one eval to the next.
745
746Additionally, it has been made sure that forms that are evaluated at
747the top level are always evaluated with respect to the current module.
748Previously, subforms of top-level forms such as `begin', `case',
749etc. did not respect changes to the current module although these
750subforms are at the top-level as well.
751
311b6a3c 752To prevent strange behavior, the forms `define-module',
6f76852b
MV
753`use-modules', `use-syntax', and `export' have been restricted to only
754work on the top level. The forms `define-public' and
755`defmacro-public' only export the new binding on the top level. They
756behave just like `define' and `defmacro', respectively, when they are
757used in a lexical environment.
758
0a892a2c
MV
759Also, `export' will no longer silently re-export bindings imported
760from a used module. It will emit a `deprecation' warning and will
761cease to perform any re-export in the next version. If you actually
762want to re-export bindings, use the new `re-export' in place of
763`export'. The new `re-export' will not make copies of variables when
764rexporting them, as `export' did wrongly.
765
047dc3ae
TTN
766** Module system now allows selection and renaming of imported bindings
767
768Previously, when using `use-modules' or the `#:use-module' clause in
769the `define-module' form, all the bindings (association of symbols to
770values) for imported modules were added to the "current module" on an
771as-is basis. This has been changed to allow finer control through two
772new facilities: selection and renaming.
773
774You can now select which of the imported module's bindings are to be
775visible in the current module by using the `:select' clause. This
776clause also can be used to rename individual bindings. For example:
777
778 ;; import all bindings no questions asked
779 (use-modules (ice-9 common-list))
780
781 ;; import four bindings, renaming two of them;
782 ;; the current module sees: every some zonk-y zonk-n
783 (use-modules ((ice-9 common-list)
784 :select (every some
785 (remove-if . zonk-y)
786 (remove-if-not . zonk-n))))
787
788You can also programmatically rename all selected bindings using the
789`:renamer' clause, which specifies a proc that takes a symbol and
790returns another symbol. Because it is common practice to use a prefix,
791we now provide the convenience procedure `symbol-prefix-proc'. For
792example:
793
794 ;; import four bindings, renaming two of them specifically,
795 ;; and all four w/ prefix "CL:";
796 ;; the current module sees: CL:every CL:some CL:zonk-y CL:zonk-n
797 (use-modules ((ice-9 common-list)
798 :select (every some
799 (remove-if . zonk-y)
800 (remove-if-not . zonk-n))
801 :renamer (symbol-prefix-proc 'CL:)))
802
803 ;; import four bindings, renaming two of them specifically,
804 ;; and all four by upcasing.
805 ;; the current module sees: EVERY SOME ZONK-Y ZONK-N
806 (define (upcase-symbol sym)
807 (string->symbol (string-upcase (symbol->string sym))))
808
809 (use-modules ((ice-9 common-list)
810 :select (every some
811 (remove-if . zonk-y)
812 (remove-if-not . zonk-n))
813 :renamer upcase-symbol))
814
815Note that programmatic renaming is done *after* individual renaming.
816Also, the above examples show `use-modules', but the same facilities are
817available for the `#:use-module' clause of `define-module'.
818
819See manual for more info.
820
b7d69200 821** The semantics of guardians have changed.
56495472 822
b7d69200 823The changes are for the most part compatible. An important criterion
6c0201ad 824was to keep the typical usage of guardians as simple as before, but to
c0a5d888 825make the semantics safer and (as a result) more useful.
56495472 826
c0a5d888 827*** All objects returned from guardians are now properly alive.
56495472 828
c0a5d888
ML
829It is now guaranteed that any object referenced by an object returned
830from a guardian is alive. It's now impossible for a guardian to
831return a "contained" object before its "containing" object.
56495472
ML
832
833One incompatible (but probably not very important) change resulting
834from this is that it is no longer possible to guard objects that
835indirectly reference themselves (i.e. are parts of cycles). If you do
836so accidentally, you'll get a warning.
837
c0a5d888
ML
838*** There are now two types of guardians: greedy and sharing.
839
840If you call (make-guardian #t) or just (make-guardian), you'll get a
841greedy guardian, and for (make-guardian #f) a sharing guardian.
842
843Greedy guardians are the default because they are more "defensive".
844You can only greedily guard an object once. If you guard an object
845more than once, once in a greedy guardian and the rest of times in
846sharing guardians, then it is guaranteed that the object won't be
847returned from sharing guardians as long as it is greedily guarded
848and/or alive.
849
850Guardians returned by calls to `make-guardian' can now take one more
851optional parameter, which says whether to throw an error in case an
852attempt is made to greedily guard an object that is already greedily
853guarded. The default is true, i.e. throw an error. If the parameter
854is false, the guardian invocation returns #t if guarding was
855successful and #f if it wasn't.
856
857Also, since greedy guarding is, in effect, a side-effecting operation
858on objects, a new function is introduced: `destroy-guardian!'.
859Invoking this function on a guardian renders it unoperative and, if
860the guardian is greedy, clears the "greedily guarded" property of the
861objects that were guarded by it, thus undoing the side effect.
862
863Note that all this hair is hardly very important, since guardian
864objects are usually permanent.
865
311b6a3c
MV
866** Continuations created by call-with-current-continuation now accept
867any number of arguments, as required by R5RS.
818febc0 868
c10ecc4c 869** New function `issue-deprecation-warning'
56426fdb 870
311b6a3c 871This function is used to display the deprecation messages that are
c10ecc4c 872controlled by GUILE_WARN_DEPRECATION as explained in the README.
56426fdb
KN
873
874 (define (id x)
c10ecc4c
MV
875 (issue-deprecation-warning "`id' is deprecated. Use `identity' instead.")
876 (identity x))
56426fdb
KN
877
878 guile> (id 1)
879 ;; `id' is deprecated. Use `identity' instead.
880 1
881 guile> (id 1)
882 1
883
c10ecc4c
MV
884** New syntax `begin-deprecated'
885
886When deprecated features are included (as determined by the configure
887option --enable-deprecated), `begin-deprecated' is identical to
888`begin'. When deprecated features are excluded, it always evaluates
889to `#f', ignoring the body forms.
890
17f367e0
MV
891** New function `make-object-property'
892
893This function returns a new `procedure with setter' P that can be used
894to attach a property to objects. When calling P as
895
896 (set! (P obj) val)
897
898where `obj' is any kind of object, it attaches `val' to `obj' in such
899a way that it can be retrieved by calling P as
900
901 (P obj)
902
903This function will replace procedure properties, symbol properties and
904source properties eventually.
905
76ef92f3
MV
906** Module (ice-9 optargs) now uses keywords instead of `#&'.
907
908Instead of #&optional, #&key, etc you should now use #:optional,
909#:key, etc. Since #:optional is a keyword, you can write it as just
910:optional when (read-set! keywords 'prefix) is active.
911
912The old reader syntax `#&' is still supported, but deprecated. It
913will be removed in the next release.
914
c0997079
MD
915** New define-module option: pure
916
917Tells the module system not to include any bindings from the root
918module.
919
920Example:
921
922(define-module (totally-empty-module)
923 :pure)
924
925** New define-module option: export NAME1 ...
926
927Export names NAME1 ...
928
929This option is required if you want to be able to export bindings from
930a module which doesn't import one of `define-public' or `export'.
931
932Example:
933
311b6a3c
MV
934 (define-module (foo)
935 :pure
936 :use-module (ice-9 r5rs)
937 :export (bar))
69b5f65a 938
311b6a3c 939 ;;; Note that we're pure R5RS below this point!
69b5f65a 940
311b6a3c
MV
941 (define (bar)
942 ...)
daa6ba18 943
1f3908c4
KN
944** New function: object->string OBJ
945
946Return a Scheme string obtained by printing a given object.
947
eb5c0a2a
GH
948** New function: port? X
949
950Returns a boolean indicating whether X is a port. Equivalent to
951`(or (input-port? X) (output-port? X))'.
952
efa40607
DH
953** New function: file-port?
954
955Determines whether a given object is a port that is related to a file.
956
34b56ec4
GH
957** New function: port-for-each proc
958
311b6a3c
MV
959Apply PROC to each port in the Guile port table in turn. The return
960value is unspecified. More specifically, PROC is applied exactly once
961to every port that exists in the system at the time PORT-FOR-EACH is
962invoked. Changes to the port table while PORT-FOR-EACH is running
963have no effect as far as PORT-FOR-EACH is concerned.
34b56ec4
GH
964
965** New function: dup2 oldfd newfd
966
967A simple wrapper for the `dup2' system call. Copies the file
968descriptor OLDFD to descriptor number NEWFD, replacing the
969previous meaning of NEWFD. Both OLDFD and NEWFD must be integers.
970Unlike for dup->fdes or primitive-move->fdes, no attempt is made
264e9cbc 971to move away ports which are using NEWFD. The return value is
34b56ec4
GH
972unspecified.
973
974** New function: close-fdes fd
975
976A simple wrapper for the `close' system call. Close file
977descriptor FD, which must be an integer. Unlike close (*note
978close: Ports and File Descriptors.), the file descriptor will be
979closed even if a port is using it. The return value is
980unspecified.
981
94e6d793
MG
982** New function: crypt password salt
983
984Encrypts `password' using the standard unix password encryption
985algorithm.
986
987** New function: chroot path
988
989Change the root directory of the running process to `path'.
990
991** New functions: getlogin, cuserid
992
993Return the login name or the user name of the current effective user
994id, respectively.
995
996** New functions: getpriority which who, setpriority which who prio
997
998Get or set the priority of the running process.
999
1000** New function: getpass prompt
1001
1002Read a password from the terminal, first displaying `prompt' and
1003disabling echoing.
1004
1005** New function: flock file operation
1006
1007Set/remove an advisory shared or exclusive lock on `file'.
1008
1009** New functions: sethostname name, gethostname
1010
1011Set or get the hostname of the machine the current process is running
1012on.
1013
6d163216 1014** New function: mkstemp! tmpl
4f60cc33 1015
6d163216
GH
1016mkstemp creates a new unique file in the file system and returns a
1017new buffered port open for reading and writing to the file. TMPL
1018is a string specifying where the file should be created: it must
1019end with `XXXXXX' and will be changed in place to return the name
1020of the temporary file.
1021
62e63ba9
MG
1022** New function: open-input-string string
1023
1024Return an input string port which delivers the characters from
4f60cc33 1025`string'. This procedure, together with `open-output-string' and
62e63ba9
MG
1026`get-output-string' implements SRFI-6.
1027
1028** New function: open-output-string
1029
1030Return an output string port which collects all data written to it.
1031The data can then be retrieved by `get-output-string'.
1032
1033** New function: get-output-string
1034
1035Return the contents of an output string port.
1036
56426fdb
KN
1037** New function: identity
1038
1039Return the argument.
1040
5bef627d
GH
1041** socket, connect, accept etc., now have support for IPv6. IPv6 addresses
1042 are represented in Scheme as integers with normal host byte ordering.
1043
1044** New function: inet-pton family address
1045
311b6a3c
MV
1046Convert a printable string network address into an integer. Note that
1047unlike the C version of this function, the result is an integer with
1048normal host byte ordering. FAMILY can be `AF_INET' or `AF_INET6'.
1049e.g.,
1050
1051 (inet-pton AF_INET "127.0.0.1") => 2130706433
1052 (inet-pton AF_INET6 "::1") => 1
5bef627d
GH
1053
1054** New function: inet-ntop family address
1055
311b6a3c
MV
1056Convert an integer network address into a printable string. Note that
1057unlike the C version of this function, the input is an integer with
1058normal host byte ordering. FAMILY can be `AF_INET' or `AF_INET6'.
1059e.g.,
1060
1061 (inet-ntop AF_INET 2130706433) => "127.0.0.1"
1062 (inet-ntop AF_INET6 (- (expt 2 128) 1)) =>
5bef627d
GH
1063 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
1064
56426fdb
KN
1065** Deprecated: id
1066
1067Use `identity' instead.
1068
5cd06d5e
DH
1069** Deprecated: -1+
1070
1071Use `1-' instead.
1072
1073** Deprecated: return-it
1074
311b6a3c 1075Do without it.
5cd06d5e
DH
1076
1077** Deprecated: string-character-length
1078
1079Use `string-length' instead.
1080
1081** Deprecated: flags
1082
1083Use `logior' instead.
1084
4f60cc33
NJ
1085** Deprecated: close-all-ports-except.
1086
1087This was intended for closing ports in a child process after a fork,
1088but it has the undesirable side effect of flushing buffers.
1089port-for-each is more flexible.
34b56ec4
GH
1090
1091** The (ice-9 popen) module now attempts to set up file descriptors in
1092the child process from the current Scheme ports, instead of using the
1093current values of file descriptors 0, 1, and 2 in the parent process.
1094
b52e071b
DH
1095** Removed function: builtin-weak-bindings
1096
1097There is no such concept as a weak binding any more.
1098
9d774814 1099** Removed constants: bignum-radix, scm-line-incrementors
0f979f3f 1100
7d435120
MD
1101** define-method: New syntax mandatory.
1102
1103The new method syntax is now mandatory:
1104
1105(define-method (NAME ARG-SPEC ...) BODY ...)
1106(define-method (NAME ARG-SPEC ... . REST-ARG) BODY ...)
1107
1108 ARG-SPEC ::= ARG-NAME | (ARG-NAME TYPE)
1109 REST-ARG ::= ARG-NAME
1110
1111If you have old code using the old syntax, import
1112(oop goops old-define-method) before (oop goops) as in:
1113
1114 (use-modules (oop goops old-define-method) (oop goops))
1115
f3f9dcbc
MV
1116** Deprecated function: builtin-variable
1117 Removed function: builtin-bindings
1118
1119There is no longer a distinction between builtin or other variables.
1120Use module system operations for all variables.
1121
311b6a3c
MV
1122** Lazy-catch handlers are no longer allowed to return.
1123
1124That is, a call to `throw', `error', etc is now guaranteed to not
1125return.
1126
a583bf1e 1127** Bugfixes for (ice-9 getopt-long)
8c84b81e 1128
a583bf1e
TTN
1129This module is now tested using test-suite/tests/getopt-long.test.
1130The following bugs have been fixed:
1131
1132*** Parsing for options that are specified to have `optional' args now checks
1133if the next element is an option instead of unconditionally taking it as the
8c84b81e
TTN
1134option arg.
1135
a583bf1e
TTN
1136*** An error is now thrown for `--opt=val' when the option description
1137does not specify `(value #t)' or `(value optional)'. This condition used to
1138be accepted w/o error, contrary to the documentation.
1139
1140*** The error message for unrecognized options is now more informative.
1141It used to be "not a record", an artifact of the implementation.
1142
1143*** The error message for `--opt' terminating the arg list (no value), when
1144`(value #t)' is specified, is now more informative. It used to be "not enough
1145args".
1146
1147*** "Clumped" single-char args now preserve trailing string, use it as arg.
1148The expansion used to be like so:
1149
1150 ("-abc5d" "--xyz") => ("-a" "-b" "-c" "--xyz")
1151
1152Note that the "5d" is dropped. Now it is like so:
1153
1154 ("-abc5d" "--xyz") => ("-a" "-b" "-c" "5d" "--xyz")
1155
1156This enables single-char options to have adjoining arguments as long as their
1157constituent characters are not potential single-char options.
8c84b81e 1158
998bfc70
TTN
1159** (ice-9 session) procedure `arity' now works with (ice-9 optargs) `lambda*'
1160
1161The `lambda*' and derivative forms in (ice-9 optargs) now set a procedure
1162property `arglist', which can be retrieved by `arity'. The result is that
1163`arity' can give more detailed information than before:
1164
1165Before:
1166
1167 guile> (use-modules (ice-9 optargs))
1168 guile> (define* (foo #:optional a b c) a)
1169 guile> (arity foo)
1170 0 or more arguments in `lambda*:G0'.
1171
1172After:
1173
1174 guile> (arity foo)
1175 3 optional arguments: `a', `b' and `c'.
1176 guile> (define* (bar a b #:key c d #:allow-other-keys) a)
1177 guile> (arity bar)
1178 2 required arguments: `a' and `b', 2 keyword arguments: `c'
1179 and `d', other keywords allowed.
1180 guile> (define* (baz a b #:optional c #:rest r) a)
1181 guile> (arity baz)
1182 2 required arguments: `a' and `b', 1 optional argument: `c',
1183 the rest in `r'.
1184
311b6a3c
MV
1185* Changes to the C interface
1186
c81c130e
MV
1187** Types have been renamed from scm_*_t to scm_t_*.
1188
1189This has been done for POSIX sake. It reserves identifiers ending
1190with "_t". What a concept.
1191
1192The old names are still available with status `deprecated'.
1193
1194** scm_t_bits (former scm_bits_t) is now a unsigned type.
1195
6e9382f1 1196** Deprecated features have been removed.
e6c9e497
MV
1197
1198*** Macros removed
1199
1200 SCM_INPORTP, SCM_OUTPORTP SCM_ICHRP, SCM_ICHR, SCM_MAKICHR
1201 SCM_SETJMPBUF SCM_NSTRINGP SCM_NRWSTRINGP SCM_NVECTORP SCM_DOUBLE_CELLP
1202
1203*** C Functions removed
1204
1205 scm_sysmissing scm_tag scm_tc16_flo scm_tc_flo
1206 scm_fseek - replaced by scm_seek.
1207 gc-thunk - replaced by after-gc-hook.
1208 gh_int2scmb - replaced by gh_bool2scm.
1209 scm_tc_dblr - replaced by scm_tc16_real.
1210 scm_tc_dblc - replaced by scm_tc16_complex.
1211 scm_list_star - replaced by scm_cons_star.
1212
36284627
DH
1213** Deprecated: scm_makfromstr
1214
1215Use scm_mem2string instead.
1216
311b6a3c
MV
1217** Deprecated: scm_make_shared_substring
1218
1219Explicit shared substrings will disappear from Guile.
1220
1221Instead, "normal" strings will be implemented using sharing
1222internally, combined with a copy-on-write strategy.
1223
1224** Deprecated: scm_read_only_string_p
1225
1226The concept of read-only strings will disappear in next release of
1227Guile.
1228
1229** Deprecated: scm_sloppy_memq, scm_sloppy_memv, scm_sloppy_member
c299f186 1230
311b6a3c 1231Instead, use scm_c_memq or scm_memq, scm_memv, scm_member.
c299f186 1232
dd0e04ed
KN
1233** New functions: scm_call_0, scm_call_1, scm_call_2, scm_call_3
1234
1235Call a procedure with the indicated number of arguments.
1236
1237Example:
1238
1239 scm_call_1 (proc, arg1);
1240
1241** New functions: scm_apply_0, scm_apply_1, scm_apply_2, scm_apply_3
1242
1243Call a procedure with the indicated number of arguments and a list
1244of arguments.
1245
1246Example:
1247
1248 scm_apply_1 (proc, arg1, args);
1249
e235f2a6
KN
1250** New functions: scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5
1251
1252Create a list of the given number of elements.
1253
1254** Renamed function: scm_listify has been replaced by scm_list_n.
1255
1256** Deprecated macros: SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4,
1257SCM_LIST5, SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9.
1258
1259Use functions scm_list_N instead.
1260
6fe692e9
MD
1261** New function: scm_c_read (SCM port, void *buffer, scm_sizet size)
1262
1263Used by an application to read arbitrary number of bytes from a port.
1264Same semantics as libc read, except that scm_c_read only returns less
1265than SIZE bytes if at end-of-file.
1266
1267Warning: Doesn't update port line and column counts!
1268
1269** New function: scm_c_write (SCM port, const void *ptr, scm_sizet size)
1270
1271Used by an application to write arbitrary number of bytes to an SCM
1272port. Similar semantics as libc write. However, unlike libc
1273write, scm_c_write writes the requested number of bytes and has no
1274return value.
1275
1276Warning: Doesn't update port line and column counts!
1277
17f367e0
MV
1278** New function: scm_init_guile ()
1279
1280In contrast to scm_boot_guile, scm_init_guile will return normally
1281after initializing Guile. It is not available on all systems, tho.
1282
23ade5e7
DH
1283** New functions: scm_str2symbol, scm_mem2symbol
1284
1285The function scm_str2symbol takes a const char* pointing to a zero-terminated
1286field of characters and creates a scheme symbol object from that C string.
1287The function scm_mem2symbol takes a const char* and a number of characters and
1288creates a symbol from the characters in that memory area.
1289
17f367e0
MV
1290** New functions: scm_primitive_make_property
1291 scm_primitive_property_ref
1292 scm_primitive_property_set_x
1293 scm_primitive_property_del_x
1294
1295These functions implement a new way to deal with object properties.
1296See libguile/properties.c for their documentation.
1297
9d47a1e6
ML
1298** New function: scm_done_free (long size)
1299
1300This function is the inverse of scm_done_malloc. Use it to report the
1301amount of smob memory you free. The previous method, which involved
1302calling scm_done_malloc with negative argument, was somewhat
1303unintuitive (and is still available, of course).
1304
79a3dafe
DH
1305** New function: scm_c_memq (SCM obj, SCM list)
1306
1307This function provides a fast C level alternative for scm_memq for the case
1308that the list parameter is known to be a proper list. The function is a
1309replacement for scm_sloppy_memq, but is stricter in its requirements on its
1310list input parameter, since for anything else but a proper list the function's
1311behaviour is undefined - it may even crash or loop endlessly. Further, for
1312the case that the object is not found in the list, scm_c_memq returns #f which
1313is similar to scm_memq, but different from scm_sloppy_memq's behaviour.
1314
6c0201ad 1315** New functions: scm_remember_upto_here_1, scm_remember_upto_here_2,
5d2b97cd
DH
1316scm_remember_upto_here
1317
1318These functions replace the function scm_remember.
1319
1320** Deprecated function: scm_remember
1321
1322Use one of the new functions scm_remember_upto_here_1,
1323scm_remember_upto_here_2 or scm_remember_upto_here instead.
1324
be54b15d
DH
1325** New function: scm_allocate_string
1326
1327This function replaces the function scm_makstr.
1328
1329** Deprecated function: scm_makstr
1330
1331Use the new function scm_allocate_string instead.
1332
32d0d4b1
DH
1333** New global variable scm_gc_running_p introduced.
1334
1335Use this variable to find out if garbage collection is being executed. Up to
1336now applications have used scm_gc_heap_lock to test if garbage collection was
1337running, which also works because of the fact that up to know only the garbage
1338collector has set this variable. But, this is an implementation detail that
1339may change. Further, scm_gc_heap_lock is not set throughout gc, thus the use
1340of this variable is (and has been) not fully safe anyway.
1341
5b9eb8ae
DH
1342** New macros: SCM_BITVECTOR_MAX_LENGTH, SCM_UVECTOR_MAX_LENGTH
1343
1344Use these instead of SCM_LENGTH_MAX.
1345
6c0201ad 1346** New macros: SCM_CONTINUATION_LENGTH, SCM_CCLO_LENGTH, SCM_STACK_LENGTH,
a6d9e5ab
DH
1347SCM_STRING_LENGTH, SCM_SYMBOL_LENGTH, SCM_UVECTOR_LENGTH,
1348SCM_BITVECTOR_LENGTH, SCM_VECTOR_LENGTH.
1349
1350Use these instead of SCM_LENGTH.
1351
6c0201ad 1352** New macros: SCM_SET_CONTINUATION_LENGTH, SCM_SET_STRING_LENGTH,
93778877
DH
1353SCM_SET_SYMBOL_LENGTH, SCM_SET_VECTOR_LENGTH, SCM_SET_UVECTOR_LENGTH,
1354SCM_SET_BITVECTOR_LENGTH
bc0eaf7b
DH
1355
1356Use these instead of SCM_SETLENGTH
1357
6c0201ad 1358** New macros: SCM_STRING_CHARS, SCM_SYMBOL_CHARS, SCM_CCLO_BASE,
a6d9e5ab
DH
1359SCM_VECTOR_BASE, SCM_UVECTOR_BASE, SCM_BITVECTOR_BASE, SCM_COMPLEX_MEM,
1360SCM_ARRAY_MEM
1361
e51fe79c
DH
1362Use these instead of SCM_CHARS, SCM_UCHARS, SCM_ROCHARS, SCM_ROUCHARS or
1363SCM_VELTS.
a6d9e5ab 1364
6c0201ad 1365** New macros: SCM_SET_BIGNUM_BASE, SCM_SET_STRING_CHARS,
6a0476fd
DH
1366SCM_SET_SYMBOL_CHARS, SCM_SET_UVECTOR_BASE, SCM_SET_BITVECTOR_BASE,
1367SCM_SET_VECTOR_BASE
1368
1369Use these instead of SCM_SETCHARS.
1370
a6d9e5ab
DH
1371** New macro: SCM_BITVECTOR_P
1372
1373** New macro: SCM_STRING_COERCE_0TERMINATION_X
1374
1375Use instead of SCM_COERCE_SUBSTR.
1376
30ea841d
DH
1377** New macros: SCM_DIR_OPEN_P, SCM_DIR_FLAG_OPEN
1378
1379For directory objects, use these instead of SCM_OPDIRP and SCM_OPN.
1380
6c0201ad
TTN
1381** Deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,
1382SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL,
1383SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD,
d1ca2c64 1384SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SYMBOL_SLOTS, SCM_SLOTS, SCM_SLOPPY_STRINGP,
a6d9e5ab
DH
1385SCM_VALIDATE_STRINGORSUBSTR, SCM_FREEP, SCM_NFREEP, SCM_CHARS, SCM_UCHARS,
1386SCM_VALIDATE_ROSTRING, SCM_VALIDATE_ROSTRING_COPY,
1387SCM_VALIDATE_NULLORROSTRING_COPY, SCM_ROLENGTH, SCM_LENGTH, SCM_HUGE_LENGTH,
b24b5e13 1388SCM_SUBSTRP, SCM_SUBSTR_STR, SCM_SUBSTR_OFFSET, SCM_COERCE_SUBSTR,
34f0f2b8 1389SCM_ROSTRINGP, SCM_RWSTRINGP, SCM_VALIDATE_RWSTRING, SCM_ROCHARS,
fd336365 1390SCM_ROUCHARS, SCM_SETLENGTH, SCM_SETCHARS, SCM_LENGTH_MAX, SCM_GC8MARKP,
30ea841d 1391SCM_SETGC8MARK, SCM_CLRGC8MARK, SCM_GCTYP16, SCM_GCCDR, SCM_SUBR_DOC,
b3fcac34
DH
1392SCM_OPDIRP, SCM_VALIDATE_OPDIR, SCM_WTA, RETURN_SCM_WTA, SCM_CONST_LONG,
1393SCM_WNA, SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
61045190 1394SCM_VALIDATE_NUMBER_DEF_COPY, SCM_SLOPPY_CONSP, SCM_SLOPPY_NCONSP,
e038c042 1395SCM_SETAND_CDR, SCM_SETOR_CDR, SCM_SETAND_CAR, SCM_SETOR_CAR
b63a956d
DH
1396
1397Use SCM_ASSERT_RANGE or SCM_VALIDATE_XXX_RANGE instead of SCM_OUTOFRANGE.
1398Use scm_memory_error instead of SCM_NALLOC.
c1aef037 1399Use SCM_STRINGP instead of SCM_SLOPPY_STRINGP.
d1ca2c64
DH
1400Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_STRINGORSUBSTR.
1401Use SCM_FREE_CELL_P instead of SCM_FREEP/SCM_NFREEP
a6d9e5ab 1402Use a type specific accessor macro instead of SCM_CHARS/SCM_UCHARS.
6c0201ad 1403Use a type specific accessor instead of SCM(_|_RO|_HUGE_)LENGTH.
a6d9e5ab
DH
1404Use SCM_VALIDATE_(SYMBOL|STRING) instead of SCM_VALIDATE_ROSTRING.
1405Use SCM_STRING_COERCE_0TERMINATION_X instead of SCM_COERCE_SUBSTR.
b24b5e13 1406Use SCM_STRINGP or SCM_SYMBOLP instead of SCM_ROSTRINGP.
f0942910
DH
1407Use SCM_STRINGP instead of SCM_RWSTRINGP.
1408Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_RWSTRING.
34f0f2b8
DH
1409Use SCM_STRING_CHARS instead of SCM_ROCHARS.
1410Use SCM_STRING_UCHARS instead of SCM_ROUCHARS.
93778877 1411Use a type specific setter macro instead of SCM_SETLENGTH.
6a0476fd 1412Use a type specific setter macro instead of SCM_SETCHARS.
5b9eb8ae 1413Use a type specific length macro instead of SCM_LENGTH_MAX.
fd336365
DH
1414Use SCM_GCMARKP instead of SCM_GC8MARKP.
1415Use SCM_SETGCMARK instead of SCM_SETGC8MARK.
1416Use SCM_CLRGCMARK instead of SCM_CLRGC8MARK.
1417Use SCM_TYP16 instead of SCM_GCTYP16.
1418Use SCM_CDR instead of SCM_GCCDR.
30ea841d 1419Use SCM_DIR_OPEN_P instead of SCM_OPDIRP.
276dd677
DH
1420Use SCM_MISC_ERROR or SCM_WRONG_TYPE_ARG instead of SCM_WTA.
1421Use SCM_MISC_ERROR or SCM_WRONG_TYPE_ARG instead of RETURN_SCM_WTA.
8dea8611 1422Use SCM_VCELL_INIT instead of SCM_CONST_LONG.
b3fcac34 1423Use SCM_WRONG_NUM_ARGS instead of SCM_WNA.
ced99e92
DH
1424Use SCM_CONSP instead of SCM_SLOPPY_CONSP.
1425Use !SCM_CONSP instead of SCM_SLOPPY_NCONSP.
b63a956d 1426
f7620510
DH
1427** Removed function: scm_struct_init
1428
93d40df2
DH
1429** Removed variable: scm_symhash_dim
1430
818febc0
GH
1431** Renamed function: scm_make_cont has been replaced by
1432scm_make_continuation, which has a different interface.
1433
cc4feeca
DH
1434** Deprecated function: scm_call_catching_errors
1435
1436Use scm_catch or scm_lazy_catch from throw.[ch] instead.
1437
28b06554
DH
1438** Deprecated function: scm_strhash
1439
1440Use scm_string_hash instead.
1441
1b9be268
DH
1442** Deprecated function: scm_vector_set_length_x
1443
1444Instead, create a fresh vector of the desired size and copy the contents.
1445
302f229e
MD
1446** scm_gensym has changed prototype
1447
1448scm_gensym now only takes one argument.
1449
1660782e
DH
1450** Deprecated type tags: scm_tc7_ssymbol, scm_tc7_msymbol, scm_tcs_symbols,
1451scm_tc7_lvector
28b06554
DH
1452
1453There is now only a single symbol type scm_tc7_symbol.
1660782e 1454The tag scm_tc7_lvector was not used anyway.
28b06554 1455
2f6fb7c5
KN
1456** Deprecated function: scm_make_smob_type_mfpe, scm_set_smob_mfpe.
1457
1458Use scm_make_smob_type and scm_set_smob_XXX instead.
1459
1460** New function scm_set_smob_apply.
1461
1462This can be used to set an apply function to a smob type.
1463
1f3908c4
KN
1464** Deprecated function: scm_strprint_obj
1465
1466Use scm_object_to_string instead.
1467
b3fcac34
DH
1468** Deprecated function: scm_wta
1469
1470Use scm_wrong_type_arg, or another appropriate error signalling function
1471instead.
1472
f3f9dcbc
MV
1473** Explicit support for obarrays has been deprecated.
1474
1475Use `scm_str2symbol' and the generic hashtable functions instead.
1476
1477** The concept of `vcells' has been deprecated.
1478
1479The data type `variable' is now used exclusively. `Vcells' have been
1480a low-level concept so you are likely not affected by this change.
1481
1482*** Deprecated functions: scm_sym2vcell, scm_sysintern,
1483 scm_sysintern0, scm_symbol_value0, scm_intern, scm_intern0.
1484
1485Use scm_c_define or scm_c_lookup instead, as appropriate.
1486
1487*** New functions: scm_c_module_lookup, scm_c_lookup,
1488 scm_c_module_define, scm_c_define, scm_module_lookup, scm_lookup,
1489 scm_module_define, scm_define.
1490
1491These functions work with variables instead of with vcells.
1492
311b6a3c
MV
1493** New functions for creating and defining `subr's and `gsubr's.
1494
1495The new functions more clearly distinguish between creating a subr (or
1496gsubr) object and adding it to the current module.
1497
1498These new functions are available: scm_c_make_subr, scm_c_define_subr,
1499scm_c_make_subr_with_generic, scm_c_define_subr_with_generic,
1500scm_c_make_gsubr, scm_c_define_gsubr, scm_c_make_gsubr_with_generic,
1501scm_c_define_gsubr_with_generic.
1502
1503** Deprecated functions: scm_make_subr, scm_make_subr_opt,
1504 scm_make_subr_with_generic, scm_make_gsubr,
1505 scm_make_gsubr_with_generic.
1506
1507Use the new ones from above instead.
1508
1509** C interface to the module system has changed.
1510
1511While we suggest that you avoid as many explicit module system
1512operations from C as possible for the time being, the C interface has
1513been made more similar to the high-level Scheme module system.
1514
1515*** New functions: scm_c_define_module, scm_c_use_module,
1516 scm_c_export, scm_c_resolve_module.
1517
1518They mostly work like their Scheme namesakes. scm_c_define_module
1519takes a function that is called a context where the new module is
1520current.
1521
1522*** Deprecated functions: scm_the_root_module, scm_make_module,
1523 scm_ensure_user_module, scm_load_scheme_module.
1524
1525Use the new functions instead.
1526
1527** Renamed function: scm_internal_with_fluids becomes
1528 scm_c_with_fluids.
1529
1530scm_internal_with_fluids is available as a deprecated function.
1531
1532** New function: scm_c_with_fluid.
1533
1534Just like scm_c_with_fluids, but takes one fluid and one value instead
1535of lists of same.
1536
1be6b49c
ML
1537** Deprecated typedefs: long_long, ulong_long.
1538
1539They are of questionable utility and they pollute the global
1540namespace.
1541
1be6b49c
ML
1542** Deprecated typedef: scm_sizet
1543
1544It is of questionable utility now that Guile requires ANSI C, and is
1545oddly named.
1546
1547** Deprecated typedefs: scm_port_rw_active, scm_port,
1548 scm_ptob_descriptor, scm_debug_info, scm_debug_frame, scm_fport,
1549 scm_option, scm_rstate, scm_rng, scm_array, scm_array_dim.
1550
1551Made more compliant with the naming policy by adding a _t at the end.
1552
1553** Deprecated functions: scm_mkbig, scm_big2num, scm_adjbig,
1554 scm_normbig, scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl
1555
373f4948 1556With the exception of the mysterious scm_2ulong2big, they are still
1be6b49c
ML
1557available under new names (scm_i_mkbig etc). These functions are not
1558intended to be used in user code. You should avoid dealing with
1559bignums directly, and should deal with numbers in general (which can
1560be bignums).
1561
147c18a0
MD
1562** Change in behavior: scm_num2long, scm_num2ulong
1563
1564The scm_num2[u]long functions don't any longer accept an inexact
1565argument. This change in behavior is motivated by concordance with
1566R5RS: It is more common that a primitive doesn't want to accept an
1567inexact for an exact.
1568
1be6b49c 1569** New functions: scm_short2num, scm_ushort2num, scm_int2num,
f3f70257
ML
1570 scm_uint2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
1571 scm_num2ushort, scm_num2int, scm_num2uint, scm_num2ptrdiff,
1be6b49c
ML
1572 scm_num2size.
1573
1574These are conversion functions between the various ANSI C integral
147c18a0
MD
1575types and Scheme numbers. NOTE: The scm_num2xxx functions don't
1576accept an inexact argument.
1be6b49c 1577
5437598b
MD
1578** New functions: scm_float2num, scm_double2num,
1579 scm_num2float, scm_num2double.
1580
1581These are conversion functions between the two ANSI C float types and
1582Scheme numbers.
1583
1be6b49c 1584** New number validation macros:
f3f70257 1585 SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,INT,UINT}[_DEF]
1be6b49c
ML
1586
1587See above.
1588
fc62c86a
ML
1589** New functions: scm_gc_protect_object, scm_gc_unprotect_object
1590
1591These are just nicer-named old scm_protect_object and
1592scm_unprotect_object.
1593
1594** Deprecated functions: scm_protect_object, scm_unprotect_object
1595
1596** New functions: scm_gc_[un]register_root, scm_gc_[un]register_roots
1597
1598These functions can be used to register pointers to locations that
1599hold SCM values.
1600
5b2ad23b
ML
1601** Deprecated function: scm_create_hook.
1602
1603Its sins are: misleading name, non-modularity and lack of general
1604usefulness.
1605
c299f186 1606\f
cc36e791
JB
1607Changes since Guile 1.3.4:
1608
80f27102
JB
1609* Changes to the distribution
1610
ce358662
JB
1611** Trees from nightly snapshots and CVS now require you to run autogen.sh.
1612
1613We've changed the way we handle generated files in the Guile source
1614repository. As a result, the procedure for building trees obtained
1615from the nightly FTP snapshots or via CVS has changed:
1616- You must have appropriate versions of autoconf, automake, and
1617 libtool installed on your system. See README for info on how to
1618 obtain these programs.
1619- Before configuring the tree, you must first run the script
1620 `autogen.sh' at the top of the source tree.
1621
1622The Guile repository used to contain not only source files, written by
1623humans, but also some generated files, like configure scripts and
1624Makefile.in files. Even though the contents of these files could be
1625derived mechanically from other files present, we thought it would
1626make the tree easier to build if we checked them into CVS.
1627
1628However, this approach means that minor differences between
1629developer's installed tools and habits affected the whole team.
1630So we have removed the generated files from the repository, and
1631added the autogen.sh script, which will reconstruct them
1632appropriately.
1633
1634
dc914156
GH
1635** configure now has experimental options to remove support for certain
1636features:
52cfc69b 1637
dc914156
GH
1638--disable-arrays omit array and uniform array support
1639--disable-posix omit posix interfaces
1640--disable-networking omit networking interfaces
1641--disable-regex omit regular expression interfaces
52cfc69b
GH
1642
1643These are likely to become separate modules some day.
1644
9764c29b 1645** New configure option --enable-debug-freelist
e1b0d0ac 1646
38a15cfd
GB
1647This enables a debugging version of SCM_NEWCELL(), and also registers
1648an extra primitive, the setter `gc-set-debug-check-freelist!'.
1649
1650Configure with the --enable-debug-freelist option to enable
1651the gc-set-debug-check-freelist! primitive, and then use:
1652
1653(gc-set-debug-check-freelist! #t) # turn on checking of the freelist
1654(gc-set-debug-check-freelist! #f) # turn off checking
1655
1656Checking of the freelist forces a traversal of the freelist and
1657a garbage collection before each allocation of a cell. This can
1658slow down the interpreter dramatically, so the setter should be used to
1659turn on this extra processing only when necessary.
e1b0d0ac 1660
9764c29b
MD
1661** New configure option --enable-debug-malloc
1662
1663Include code for debugging of calls to scm_must_malloc/realloc/free.
1664
1665Checks that
1666
16671. objects freed by scm_must_free has been mallocated by scm_must_malloc
16682. objects reallocated by scm_must_realloc has been allocated by
1669 scm_must_malloc
16703. reallocated objects are reallocated with the same what string
1671
1672But, most importantly, it records the number of allocated objects of
1673each kind. This is useful when searching for memory leaks.
1674
1675A Guile compiled with this option provides the primitive
1676`malloc-stats' which returns an alist with pairs of kind and the
1677number of objects of that kind.
1678
e415cb06
MD
1679** All includes are now referenced relative to the root directory
1680
1681Since some users have had problems with mixups between Guile and
1682system headers, we have decided to always refer to Guile headers via
1683their parent directories. This essentially creates a "private name
1684space" for Guile headers. This means that the compiler only is given
1685-I options for the root build and root source directory.
1686
341f78c9
MD
1687** Header files kw.h and genio.h have been removed.
1688
1689** The module (ice-9 getopt-gnu-style) has been removed.
1690
e8855f8d
MD
1691** New module (ice-9 documentation)
1692
1693Implements the interface to documentation strings associated with
1694objects.
1695
0c0ffe09
KN
1696** New module (ice-9 time)
1697
1698Provides a macro `time', which displays execution time of a given form.
1699
cf7a5ee5
KN
1700** New module (ice-9 history)
1701
1702Loading this module enables value history in the repl.
1703
0af43c4a 1704* Changes to the stand-alone interpreter
bd9e24b3 1705
67ef2dca
MD
1706** New command line option --debug
1707
1708Start Guile with debugging evaluator and backtraces enabled.
1709
1710This is useful when debugging your .guile init file or scripts.
1711
aa4bb95d
MD
1712** New help facility
1713
341f78c9
MD
1714Usage: (help NAME) gives documentation about objects named NAME (a symbol)
1715 (help REGEXP) ditto for objects with names matching REGEXP (a string)
58e5b910 1716 (help 'NAME) gives documentation for NAME, even if it is not an object
341f78c9 1717 (help ,EXPR) gives documentation for object returned by EXPR
6c0201ad 1718 (help (my module)) gives module commentary for `(my module)'
341f78c9
MD
1719 (help) gives this text
1720
1721`help' searches among bindings exported from loaded modules, while
1722`apropos' searches among bindings visible from the "current" module.
1723
1724Examples: (help help)
1725 (help cons)
1726 (help "output-string")
aa4bb95d 1727
e8855f8d
MD
1728** `help' and `apropos' now prints full module names
1729
0af43c4a 1730** Dynamic linking now uses libltdl from the libtool package.
bd9e24b3 1731
0af43c4a
MD
1732The old system dependent code for doing dynamic linking has been
1733replaced with calls to the libltdl functions which do all the hairy
1734details for us.
bd9e24b3 1735
0af43c4a
MD
1736The major improvement is that you can now directly pass libtool
1737library names like "libfoo.la" to `dynamic-link' and `dynamic-link'
1738will be able to do the best shared library job you can get, via
1739libltdl.
bd9e24b3 1740
0af43c4a
MD
1741The way dynamic libraries are found has changed and is not really
1742portable across platforms, probably. It is therefore recommended to
1743use absolute filenames when possible.
1744
1745If you pass a filename without an extension to `dynamic-link', it will
1746try a few appropriate ones. Thus, the most platform ignorant way is
1747to specify a name like "libfoo", without any directories and
1748extensions.
0573ddae 1749
91163914
MD
1750** Guile COOP threads are now compatible with LinuxThreads
1751
1752Previously, COOP threading wasn't possible in applications linked with
1753Linux POSIX threads due to their use of the stack pointer to find the
1754thread context. This has now been fixed with a workaround which uses
1755the pthreads to allocate the stack.
1756
6c0201ad 1757** New primitives: `pkgdata-dir', `site-dir', `library-dir'
62b82274 1758
9770d235
MD
1759** Positions of erring expression in scripts
1760
1761With version 1.3.4, the location of the erring expression in Guile
1762scipts is no longer automatically reported. (This should have been
1763documented before the 1.3.4 release.)
1764
1765You can get this information by enabling recording of positions of
1766source expressions and running the debugging evaluator. Put this at
1767the top of your script (or in your "site" file):
1768
1769 (read-enable 'positions)
1770 (debug-enable 'debug)
1771
0573ddae
MD
1772** Backtraces in scripts
1773
1774It is now possible to get backtraces in scripts.
1775
1776Put
1777
1778 (debug-enable 'debug 'backtrace)
1779
1780at the top of the script.
1781
1782(The first options enables the debugging evaluator.
1783 The second enables backtraces.)
1784
e8855f8d
MD
1785** Part of module system symbol lookup now implemented in C
1786
1787The eval closure of most modules is now implemented in C. Since this
1788was one of the bottlenecks for loading speed, Guile now loads code
1789substantially faster than before.
1790
f25f761d
GH
1791** Attempting to get the value of an unbound variable now produces
1792an exception with a key of 'unbound-variable instead of 'misc-error.
1793
1a35eadc
GH
1794** The initial default output port is now unbuffered if it's using a
1795tty device. Previously in this situation it was line-buffered.
1796
820920e6
MD
1797** New hook: after-gc-hook
1798
1799after-gc-hook takes over the role of gc-thunk. This hook is run at
1800the first SCM_TICK after a GC. (Thus, the code is run at the same
1801point during evaluation as signal handlers.)
1802
1803Note that this hook should be used only for diagnostic and debugging
1804purposes. It is not certain that it will continue to be well-defined
1805when this hook is run in the future.
1806
1807C programmers: Note the new C level hooks scm_before_gc_c_hook,
1808scm_before_sweep_c_hook, scm_after_gc_c_hook.
1809
b5074b23
MD
1810** Improvements to garbage collector
1811
1812Guile 1.4 has a new policy for triggering heap allocation and
1813determining the sizes of heap segments. It fixes a number of problems
1814in the old GC.
1815
18161. The new policy can handle two separate pools of cells
1817 (2-word/4-word) better. (The old policy would run wild, allocating
1818 more and more memory for certain programs.)
1819
18202. The old code would sometimes allocate far too much heap so that the
1821 Guile process became gigantic. The new code avoids this.
1822
18233. The old code would sometimes allocate too little so that few cells
1824 were freed at GC so that, in turn, too much time was spent in GC.
1825
18264. The old code would often trigger heap allocation several times in a
1827 row. (The new scheme predicts how large the segments needs to be
1828 in order not to need further allocation.)
1829
e8855f8d
MD
1830All in all, the new GC policy will make larger applications more
1831efficient.
1832
b5074b23
MD
1833The new GC scheme also is prepared for POSIX threading. Threads can
1834allocate private pools of cells ("clusters") with just a single
1835function call. Allocation of single cells from such a cluster can
1836then proceed without any need of inter-thread synchronization.
1837
1838** New environment variables controlling GC parameters
1839
1840GUILE_MAX_SEGMENT_SIZE Maximal segment size
1841 (default = 2097000)
1842
1843Allocation of 2-word cell heaps:
1844
1845GUILE_INIT_SEGMENT_SIZE_1 Size of initial heap segment in bytes
1846 (default = 360000)
1847
1848GUILE_MIN_YIELD_1 Minimum number of freed cells at each
1849 GC in percent of total heap size
1850 (default = 40)
1851
1852Allocation of 4-word cell heaps
1853(used for real numbers and misc other objects):
1854
1855GUILE_INIT_SEGMENT_SIZE_2, GUILE_MIN_YIELD_2
1856
1857(See entry "Way for application to customize GC parameters" under
1858 section "Changes to the scm_ interface" below.)
1859
67ef2dca
MD
1860** Guile now implements reals using 4-word cells
1861
1862This speeds up computation with reals. (They were earlier allocated
1863with `malloc'.) There is still some room for optimizations, however.
1864
1865** Some further steps toward POSIX thread support have been taken
1866
1867*** Guile's critical sections (SCM_DEFER/ALLOW_INTS)
1868don't have much effect any longer, and many of them will be removed in
1869next release.
1870
1871*** Signals
1872are only handled at the top of the evaluator loop, immediately after
1873I/O, and in scm_equalp.
1874
1875*** The GC can allocate thread private pools of pairs.
1876
0af43c4a
MD
1877* Changes to Scheme functions and syntax
1878
a0128ebe 1879** close-input-port and close-output-port are now R5RS
7c1e0b12 1880
a0128ebe 1881These procedures have been turned into primitives and have R5RS behaviour.
7c1e0b12 1882
0af43c4a
MD
1883** New procedure: simple-format PORT MESSAGE ARG1 ...
1884
1885(ice-9 boot) makes `format' an alias for `simple-format' until possibly
1886extended by the more sophisticated version in (ice-9 format)
1887
1888(simple-format port message . args)
1889Write MESSAGE to DESTINATION, defaulting to `current-output-port'.
1890MESSAGE can contain ~A (was %s) and ~S (was %S) escapes. When printed,
1891the escapes are replaced with corresponding members of ARGS:
1892~A formats using `display' and ~S formats using `write'.
1893If DESTINATION is #t, then use the `current-output-port',
1894if DESTINATION is #f, then return a string containing the formatted text.
1895Does not add a trailing newline."
1896
1897** string-ref: the second argument is no longer optional.
1898
1899** string, list->string: no longer accept strings in their arguments,
1900only characters, for compatibility with R5RS.
1901
1902** New procedure: port-closed? PORT
1903Returns #t if PORT is closed or #f if it is open.
1904
0a9e521f
MD
1905** Deprecated: list*
1906
1907The list* functionality is now provided by cons* (SRFI-1 compliant)
1908
b5074b23
MD
1909** New procedure: cons* ARG1 ARG2 ... ARGn
1910
1911Like `list', but the last arg provides the tail of the constructed list,
1912returning (cons ARG1 (cons ARG2 (cons ... ARGn))).
1913
1914Requires at least one argument. If given one argument, that argument
1915is returned as result.
1916
1917This function is called `list*' in some other Schemes and in Common LISP.
1918
341f78c9
MD
1919** Removed deprecated: serial-map, serial-array-copy!, serial-array-map!
1920
e8855f8d
MD
1921** New procedure: object-documentation OBJECT
1922
1923Returns the documentation string associated with OBJECT. The
1924procedure uses a caching mechanism so that subsequent lookups are
1925faster.
1926
1927Exported by (ice-9 documentation).
1928
1929** module-name now returns full names of modules
1930
1931Previously, only the last part of the name was returned (`session' for
1932`(ice-9 session)'). Ex: `(ice-9 session)'.
1933
894a712b
DH
1934* Changes to the gh_ interface
1935
1936** Deprecated: gh_int2scmb
1937
1938Use gh_bool2scm instead.
1939
a2349a28
GH
1940* Changes to the scm_ interface
1941
810e1aec
MD
1942** Guile primitives now carry docstrings!
1943
1944Thanks to Greg Badros!
1945
0a9e521f 1946** Guile primitives are defined in a new way: SCM_DEFINE/SCM_DEFINE1/SCM_PROC
0af43c4a 1947
0a9e521f
MD
1948Now Guile primitives are defined using the SCM_DEFINE/SCM_DEFINE1/SCM_PROC
1949macros and must contain a docstring that is extracted into foo.doc using a new
0af43c4a
MD
1950guile-doc-snarf script (that uses guile-doc-snarf.awk).
1951
0a9e521f
MD
1952However, a major overhaul of these macros is scheduled for the next release of
1953guile.
1954
0af43c4a
MD
1955** Guile primitives use a new technique for validation of arguments
1956
1957SCM_VALIDATE_* macros are defined to ease the redundancy and improve
1958the readability of argument checking.
1959
1960** All (nearly?) K&R prototypes for functions replaced with ANSI C equivalents.
1961
894a712b 1962** New macros: SCM_PACK, SCM_UNPACK
f8a72ca4
MD
1963
1964Compose/decompose an SCM value.
1965
894a712b
DH
1966The SCM type is now treated as an abstract data type and may be defined as a
1967long, a void* or as a struct, depending on the architecture and compile time
1968options. This makes it easier to find several types of bugs, for example when
1969SCM values are treated as integers without conversion. Values of the SCM type
1970should be treated as "atomic" values. These macros are used when
f8a72ca4
MD
1971composing/decomposing an SCM value, either because you want to access
1972individual bits, or because you want to treat it as an integer value.
1973
1974E.g., in order to set bit 7 in an SCM value x, use the expression
1975
1976 SCM_PACK (SCM_UNPACK (x) | 0x80)
1977
e11f8b42
DH
1978** The name property of hooks is deprecated.
1979Thus, the use of SCM_HOOK_NAME and scm_make_hook_with_name is deprecated.
1980
1981You can emulate this feature by using object properties.
1982
6c0201ad 1983** Deprecated macros: SCM_INPORTP, SCM_OUTPORTP, SCM_CRDY, SCM_ICHRP,
894a712b
DH
1984SCM_ICHR, SCM_MAKICHR, SCM_SETJMPBUF, SCM_NSTRINGP, SCM_NRWSTRINGP,
1985SCM_NVECTORP
f8a72ca4 1986
894a712b 1987These macros will be removed in a future release of Guile.
7c1e0b12 1988
6c0201ad 1989** The following types, functions and macros from numbers.h are deprecated:
0a9e521f
MD
1990scm_dblproc, SCM_UNEGFIXABLE, SCM_FLOBUFLEN, SCM_INEXP, SCM_CPLXP, SCM_REAL,
1991SCM_IMAG, SCM_REALPART, scm_makdbl, SCM_SINGP, SCM_NUM2DBL, SCM_NO_BIGDIG
1992
1993Further, it is recommended not to rely on implementation details for guile's
1994current implementation of bignums. It is planned to replace this
1995implementation with gmp in the future.
1996
a2349a28
GH
1997** Port internals: the rw_random variable in the scm_port structure
1998must be set to non-zero in any random access port. In recent Guile
1999releases it was only set for bidirectional random-access ports.
2000
7dcb364d
GH
2001** Port internals: the seek ptob procedure is now responsible for
2002resetting the buffers if required. The change was made so that in the
2003special case of reading the current position (i.e., seek p 0 SEEK_CUR)
2004the fport and strport ptobs can avoid resetting the buffers,
2005in particular to avoid discarding unread chars. An existing port
2006type can be fixed by adding something like the following to the
2007beginning of the ptob seek procedure:
2008
2009 if (pt->rw_active == SCM_PORT_READ)
2010 scm_end_input (object);
2011 else if (pt->rw_active == SCM_PORT_WRITE)
2012 ptob->flush (object);
2013
2014although to actually avoid resetting the buffers and discard unread
2015chars requires further hacking that depends on the characteristics
2016of the ptob.
2017
894a712b
DH
2018** Deprecated functions: scm_fseek, scm_tag
2019
2020These functions are no longer used and will be removed in a future version.
2021
f25f761d
GH
2022** The scm_sysmissing procedure is no longer used in libguile.
2023Unless it turns out to be unexpectedly useful to somebody, it will be
2024removed in a future version.
2025
0af43c4a
MD
2026** The format of error message strings has changed
2027
2028The two C procedures: scm_display_error and scm_error, as well as the
2029primitive `scm-error', now use scm_simple_format to do their work.
2030This means that the message strings of all code must be updated to use
2031~A where %s was used before, and ~S where %S was used before.
2032
2033During the period when there still are a lot of old Guiles out there,
2034you might want to support both old and new versions of Guile.
2035
2036There are basically two methods to achieve this. Both methods use
2037autoconf. Put
2038
2039 AC_CHECK_FUNCS(scm_simple_format)
2040
2041in your configure.in.
2042
2043Method 1: Use the string concatenation features of ANSI C's
2044 preprocessor.
2045
2046In C:
2047
2048#ifdef HAVE_SCM_SIMPLE_FORMAT
2049#define FMT_S "~S"
2050#else
2051#define FMT_S "%S"
2052#endif
2053
2054Then represent each of your error messages using a preprocessor macro:
2055
2056#define E_SPIDER_ERROR "There's a spider in your " ## FMT_S ## "!!!"
2057
2058In Scheme:
2059
2060(define fmt-s (if (defined? 'simple-format) "~S" "%S"))
2061(define make-message string-append)
2062
2063(define e-spider-error (make-message "There's a spider in your " fmt-s "!!!"))
2064
2065Method 2: Use the oldfmt function found in doc/oldfmt.c.
2066
2067In C:
2068
2069scm_misc_error ("picnic", scm_c_oldfmt0 ("There's a spider in your ~S!!!"),
2070 ...);
2071
2072In Scheme:
2073
2074(scm-error 'misc-error "picnic" (oldfmt "There's a spider in your ~S!!!")
2075 ...)
2076
2077
f3b5e185
MD
2078** Deprecated: coop_mutex_init, coop_condition_variable_init
2079
2080Don't use the functions coop_mutex_init and
2081coop_condition_variable_init. They will change.
2082
2083Use scm_mutex_init and scm_cond_init instead.
2084
f3b5e185
MD
2085** New function: int scm_cond_timedwait (scm_cond_t *COND, scm_mutex_t *MUTEX, const struct timespec *ABSTIME)
2086 `scm_cond_timedwait' atomically unlocks MUTEX and waits on
2087 COND, as `scm_cond_wait' does, but it also bounds the duration
2088 of the wait. If COND has not been signaled before time ABSTIME,
2089 the mutex MUTEX is re-acquired and `scm_cond_timedwait'
2090 returns the error code `ETIMEDOUT'.
2091
2092 The ABSTIME parameter specifies an absolute time, with the same
2093 origin as `time' and `gettimeofday': an ABSTIME of 0 corresponds
2094 to 00:00:00 GMT, January 1, 1970.
2095
2096** New function: scm_cond_broadcast (scm_cond_t *COND)
2097 `scm_cond_broadcast' restarts all the threads that are waiting
2098 on the condition variable COND. Nothing happens if no threads are
2099 waiting on COND.
2100
2101** New function: scm_key_create (scm_key_t *KEY, void (*destr_function) (void *))
2102 `scm_key_create' allocates a new TSD key. The key is stored in
2103 the location pointed to by KEY. There is no limit on the number
2104 of keys allocated at a given time. The value initially associated
2105 with the returned key is `NULL' in all currently executing threads.
2106
2107 The DESTR_FUNCTION argument, if not `NULL', specifies a destructor
2108 function associated with the key. When a thread terminates,
2109 DESTR_FUNCTION is called on the value associated with the key in
2110 that thread. The DESTR_FUNCTION is not called if a key is deleted
2111 with `scm_key_delete' or a value is changed with
2112 `scm_setspecific'. The order in which destructor functions are
2113 called at thread termination time is unspecified.
2114
2115 Destructors are not yet implemented.
2116
2117** New function: scm_setspecific (scm_key_t KEY, const void *POINTER)
2118 `scm_setspecific' changes the value associated with KEY in the
2119 calling thread, storing the given POINTER instead.
2120
2121** New function: scm_getspecific (scm_key_t KEY)
2122 `scm_getspecific' returns the value currently associated with
2123 KEY in the calling thread.
2124
2125** New function: scm_key_delete (scm_key_t KEY)
2126 `scm_key_delete' deallocates a TSD key. It does not check
2127 whether non-`NULL' values are associated with that key in the
2128 currently executing threads, nor call the destructor function
2129 associated with the key.
2130
820920e6
MD
2131** New function: scm_c_hook_init (scm_c_hook_t *HOOK, void *HOOK_DATA, scm_c_hook_type_t TYPE)
2132
2133Initialize a C level hook HOOK with associated HOOK_DATA and type
2134TYPE. (See scm_c_hook_run ().)
2135
2136** New function: scm_c_hook_add (scm_c_hook_t *HOOK, scm_c_hook_function_t FUNC, void *FUNC_DATA, int APPENDP)
2137
2138Add hook function FUNC with associated FUNC_DATA to HOOK. If APPENDP
2139is true, add it last, otherwise first. The same FUNC can be added
2140multiple times if FUNC_DATA differ and vice versa.
2141
2142** New function: scm_c_hook_remove (scm_c_hook_t *HOOK, scm_c_hook_function_t FUNC, void *FUNC_DATA)
2143
2144Remove hook function FUNC with associated FUNC_DATA from HOOK. A
2145function is only removed if both FUNC and FUNC_DATA matches.
2146
2147** New function: void *scm_c_hook_run (scm_c_hook_t *HOOK, void *DATA)
2148
2149Run hook HOOK passing DATA to the hook functions.
2150
2151If TYPE is SCM_C_HOOK_NORMAL, all hook functions are run. The value
2152returned is undefined.
2153
2154If TYPE is SCM_C_HOOK_OR, hook functions are run until a function
2155returns a non-NULL value. This value is returned as the result of
2156scm_c_hook_run. If all functions return NULL, NULL is returned.
2157
2158If TYPE is SCM_C_HOOK_AND, hook functions are run until a function
2159returns a NULL value, and NULL is returned. If all functions returns
2160a non-NULL value, the last value is returned.
2161
2162** New C level GC hooks
2163
2164Five new C level hooks has been added to the garbage collector.
2165
2166 scm_before_gc_c_hook
2167 scm_after_gc_c_hook
2168
2169are run before locking and after unlocking the heap. The system is
2170thus in a mode where evaluation can take place. (Except that
2171scm_before_gc_c_hook must not allocate new cells.)
2172
2173 scm_before_mark_c_hook
2174 scm_before_sweep_c_hook
2175 scm_after_sweep_c_hook
2176
2177are run when the heap is locked. These are intended for extension of
2178the GC in a modular fashion. Examples are the weaks and guardians
2179modules.
2180
b5074b23
MD
2181** Way for application to customize GC parameters
2182
2183The application can set up other default values for the GC heap
2184allocation parameters
2185
2186 GUILE_INIT_HEAP_SIZE_1, GUILE_MIN_YIELD_1,
2187 GUILE_INIT_HEAP_SIZE_2, GUILE_MIN_YIELD_2,
2188 GUILE_MAX_SEGMENT_SIZE,
2189
2190by setting
2191
2192 scm_default_init_heap_size_1, scm_default_min_yield_1,
2193 scm_default_init_heap_size_2, scm_default_min_yield_2,
2194 scm_default_max_segment_size
2195
2196respectively before callong scm_boot_guile.
2197
2198(See entry "New environment variables ..." in section
2199"Changes to the stand-alone interpreter" above.)
2200
9704841c
MD
2201** scm_protect_object/scm_unprotect_object now nest
2202
67ef2dca
MD
2203This means that you can call scm_protect_object multiple times on an
2204object and count on the object being protected until
2205scm_unprotect_object has been call the same number of times.
2206
2207The functions also have better time complexity.
2208
2209Still, it is usually possible to structure the application in a way
2210that you don't need to use these functions. For example, if you use a
2211protected standard Guile list to keep track of live objects rather
2212than some custom data type, objects will die a natural death when they
2213are no longer needed.
2214
0a9e521f
MD
2215** Deprecated type tags: scm_tc16_flo, scm_tc_flo, scm_tc_dblr, scm_tc_dblc
2216
2217Guile does not provide the float representation for inexact real numbers any
2218more. Now, only doubles are used to represent inexact real numbers. Further,
2219the tag names scm_tc_dblr and scm_tc_dblc have been changed to scm_tc16_real
2220and scm_tc16_complex, respectively.
2221
341f78c9
MD
2222** Removed deprecated type scm_smobfuns
2223
2224** Removed deprecated function scm_newsmob
2225
b5074b23
MD
2226** Warning: scm_make_smob_type_mfpe might become deprecated in a future release
2227
2228There is an ongoing discussion among the developers whether to
2229deprecate `scm_make_smob_type_mfpe' or not. Please use the current
2230standard interface (scm_make_smob_type, scm_set_smob_XXX) in new code
2231until this issue has been settled.
2232
341f78c9
MD
2233** Removed deprecated type tag scm_tc16_kw
2234
2728d7f4
MD
2235** Added type tag scm_tc16_keyword
2236
2237(This was introduced already in release 1.3.4 but was not documented
2238 until now.)
2239
67ef2dca
MD
2240** gdb_print now prints "*** Guile not initialized ***" until Guile initialized
2241
f25f761d
GH
2242* Changes to system call interfaces:
2243
28d77376
GH
2244** The "select" procedure now tests port buffers for the ability to
2245provide input or accept output. Previously only the underlying file
2246descriptors were checked.
2247
bd9e24b3
GH
2248** New variable PIPE_BUF: the maximum number of bytes that can be
2249atomically written to a pipe.
2250
f25f761d
GH
2251** If a facility is not available on the system when Guile is
2252compiled, the corresponding primitive procedure will not be defined.
2253Previously it would have been defined but would throw a system-error
2254exception if called. Exception handlers which catch this case may
2255need minor modification: an error will be thrown with key
2256'unbound-variable instead of 'system-error. Alternatively it's
2257now possible to use `defined?' to check whether the facility is
2258available.
2259
38c1d3c4 2260** Procedures which depend on the timezone should now give the correct
6c0201ad 2261result on systems which cache the TZ environment variable, even if TZ
38c1d3c4
GH
2262is changed without calling tzset.
2263
5c11cc9d
GH
2264* Changes to the networking interfaces:
2265
2266** New functions: htons, ntohs, htonl, ntohl: for converting short and
2267long integers between network and host format. For now, it's not
2268particularly convenient to do this kind of thing, but consider:
2269
2270(define write-network-long
2271 (lambda (value port)
2272 (let ((v (make-uniform-vector 1 1 0)))
2273 (uniform-vector-set! v 0 (htonl value))
2274 (uniform-vector-write v port))))
2275
2276(define read-network-long
2277 (lambda (port)
2278 (let ((v (make-uniform-vector 1 1 0)))
2279 (uniform-vector-read! v port)
2280 (ntohl (uniform-vector-ref v 0)))))
2281
2282** If inet-aton fails, it now throws an error with key 'misc-error
2283instead of 'system-error, since errno is not relevant.
2284
2285** Certain gethostbyname/gethostbyaddr failures now throw errors with
2286specific keys instead of 'system-error. The latter is inappropriate
2287since errno will not have been set. The keys are:
afe5177e 2288'host-not-found, 'try-again, 'no-recovery and 'no-data.
5c11cc9d
GH
2289
2290** sethostent, setnetent, setprotoent, setservent: now take an
2291optional argument STAYOPEN, which specifies whether the database
2292remains open after a database entry is accessed randomly (e.g., using
2293gethostbyname for the hosts database.) The default is #f. Previously
2294#t was always used.
2295
cc36e791 2296\f
43fa9a05
JB
2297Changes since Guile 1.3.2:
2298
0fdcbcaa
MD
2299* Changes to the stand-alone interpreter
2300
2301** Debugger
2302
2303An initial version of the Guile debugger written by Chris Hanson has
2304been added. The debugger is still under development but is included
2305in the distribution anyway since it is already quite useful.
2306
2307Type
2308
2309 (debug)
2310
2311after an error to enter the debugger. Type `help' inside the debugger
2312for a description of available commands.
2313
2314If you prefer to have stack frames numbered and printed in
2315anti-chronological order and prefer up in the stack to be down on the
2316screen as is the case in gdb, you can put
2317
2318 (debug-enable 'backwards)
2319
2320in your .guile startup file. (However, this means that Guile can't
2321use indentation to indicate stack level.)
2322
2323The debugger is autoloaded into Guile at the first use.
2324
2325** Further enhancements to backtraces
2326
2327There is a new debug option `width' which controls the maximum width
2328on the screen of printed stack frames. Fancy printing parameters
2329("level" and "length" as in Common LISP) are adaptively adjusted for
2330each stack frame to give maximum information while still fitting
2331within the bounds. If the stack frame can't be made to fit by
2332adjusting parameters, it is simply cut off at the end. This is marked
2333with a `$'.
2334
2335** Some modules are now only loaded when the repl is started
2336
2337The modules (ice-9 debug), (ice-9 session), (ice-9 threads) and (ice-9
2338regex) are now loaded into (guile-user) only if the repl has been
2339started. The effect is that the startup time for scripts has been
2340reduced to 30% of what it was previously.
2341
2342Correctly written scripts load the modules they require at the top of
2343the file and should not be affected by this change.
2344
ece41168
MD
2345** Hooks are now represented as smobs
2346
6822fe53
MD
2347* Changes to Scheme functions and syntax
2348
0ce204b0
MV
2349** Readline support has changed again.
2350
2351The old (readline-activator) module is gone. Use (ice-9 readline)
2352instead, which now contains all readline functionality. So the code
2353to activate readline is now
2354
2355 (use-modules (ice-9 readline))
2356 (activate-readline)
2357
2358This should work at any time, including from the guile prompt.
2359
5d195868
JB
2360To avoid confusion about the terms of Guile's license, please only
2361enable readline for your personal use; please don't make it the
2362default for others. Here is why we make this rather odd-sounding
2363request:
2364
2365Guile is normally licensed under a weakened form of the GNU General
2366Public License, which allows you to link code with Guile without
2367placing that code under the GPL. This exception is important to some
2368people.
2369
2370However, since readline is distributed under the GNU General Public
2371License, when you link Guile with readline, either statically or
2372dynamically, you effectively change Guile's license to the strict GPL.
2373Whenever you link any strictly GPL'd code into Guile, uses of Guile
2374which are normally permitted become forbidden. This is a rather
2375non-obvious consequence of the licensing terms.
2376
2377So, to make sure things remain clear, please let people choose for
2378themselves whether to link GPL'd libraries like readline with Guile.
2379
25b0654e
JB
2380** regexp-substitute/global has changed slightly, but incompatibly.
2381
2382If you include a function in the item list, the string of the match
2383object it receives is the same string passed to
2384regexp-substitute/global, not some suffix of that string.
2385Correspondingly, the match's positions are relative to the entire
2386string, not the suffix.
2387
2388If the regexp can match the empty string, the way matches are chosen
2389from the string has changed. regexp-substitute/global recognizes the
2390same set of matches that list-matches does; see below.
2391
2392** New function: list-matches REGEXP STRING [FLAGS]
2393
2394Return a list of match objects, one for every non-overlapping, maximal
2395match of REGEXP in STRING. The matches appear in left-to-right order.
2396list-matches only reports matches of the empty string if there are no
2397other matches which begin on, end at, or include the empty match's
2398position.
2399
2400If present, FLAGS is passed as the FLAGS argument to regexp-exec.
2401
2402** New function: fold-matches REGEXP STRING INIT PROC [FLAGS]
2403
2404For each match of REGEXP in STRING, apply PROC to the match object,
2405and the last value PROC returned, or INIT for the first call. Return
2406the last value returned by PROC. We apply PROC to the matches as they
2407appear from left to right.
2408
2409This function recognizes matches according to the same criteria as
2410list-matches.
2411
2412Thus, you could define list-matches like this:
2413
2414 (define (list-matches regexp string . flags)
2415 (reverse! (apply fold-matches regexp string '() cons flags)))
2416
2417If present, FLAGS is passed as the FLAGS argument to regexp-exec.
2418
bc848f7f
MD
2419** Hooks
2420
2421*** New function: hook? OBJ
2422
2423Return #t if OBJ is a hook, otherwise #f.
2424
ece41168
MD
2425*** New function: make-hook-with-name NAME [ARITY]
2426
2427Return a hook with name NAME and arity ARITY. The default value for
2428ARITY is 0. The only effect of NAME is that it will appear when the
2429hook object is printed to ease debugging.
2430
bc848f7f
MD
2431*** New function: hook-empty? HOOK
2432
2433Return #t if HOOK doesn't contain any procedures, otherwise #f.
2434
2435*** New function: hook->list HOOK
2436
2437Return a list of the procedures that are called when run-hook is
2438applied to HOOK.
2439
b074884f
JB
2440** `map' signals an error if its argument lists are not all the same length.
2441
2442This is the behavior required by R5RS, so this change is really a bug
2443fix. But it seems to affect a lot of people's code, so we're
2444mentioning it here anyway.
2445
6822fe53
MD
2446** Print-state handling has been made more transparent
2447
2448Under certain circumstances, ports are represented as a port with an
2449associated print state. Earlier, this pair was represented as a pair
2450(see "Some magic has been added to the printer" below). It is now
2451indistinguishable (almost; see `get-print-state') from a port on the
2452user level.
2453
2454*** New function: port-with-print-state OUTPUT-PORT PRINT-STATE
2455
2456Return a new port with the associated print state PRINT-STATE.
2457
2458*** New function: get-print-state OUTPUT-PORT
2459
2460Return the print state associated with this port if it exists,
2461otherwise return #f.
2462
340a8770 2463*** New function: directory-stream? OBJECT
77242ff9 2464
340a8770 2465Returns true iff OBJECT is a directory stream --- the sort of object
77242ff9
GH
2466returned by `opendir'.
2467
0fdcbcaa
MD
2468** New function: using-readline?
2469
2470Return #t if readline is in use in the current repl.
2471
26405bc1
MD
2472** structs will be removed in 1.4
2473
2474Structs will be replaced in Guile 1.4. We will merge GOOPS into Guile
2475and use GOOPS objects as the fundamental record type.
2476
49199eaa
MD
2477* Changes to the scm_ interface
2478
26405bc1
MD
2479** structs will be removed in 1.4
2480
2481The entire current struct interface (struct.c, struct.h) will be
2482replaced in Guile 1.4. We will merge GOOPS into libguile and use
2483GOOPS objects as the fundamental record type.
2484
49199eaa
MD
2485** The internal representation of subr's has changed
2486
2487Instead of giving a hint to the subr name, the CAR field of the subr
2488now contains an index to a subr entry in scm_subr_table.
2489
2490*** New variable: scm_subr_table
2491
2492An array of subr entries. A subr entry contains the name, properties
2493and documentation associated with the subr. The properties and
2494documentation slots are not yet used.
2495
2496** A new scheme for "forwarding" calls to a builtin to a generic function
2497
2498It is now possible to extend the functionality of some Guile
2499primitives by letting them defer a call to a GOOPS generic function on
240ed66f 2500argument mismatch. This means that there is no loss of efficiency in
daf516d6 2501normal evaluation.
49199eaa
MD
2502
2503Example:
2504
daf516d6 2505 (use-modules (oop goops)) ; Must be GOOPS version 0.2.
49199eaa
MD
2506 (define-method + ((x <string>) (y <string>))
2507 (string-append x y))
2508
86a4d62e
MD
2509+ will still be as efficient as usual in numerical calculations, but
2510can also be used for concatenating strings.
49199eaa 2511
86a4d62e 2512Who will be the first one to extend Guile's numerical tower to
daf516d6
MD
2513rationals? :) [OK, there a few other things to fix before this can
2514be made in a clean way.]
49199eaa
MD
2515
2516*** New snarf macros for defining primitives: SCM_GPROC, SCM_GPROC1
2517
2518 New macro: SCM_GPROC (CNAME, SNAME, REQ, OPT, VAR, CFUNC, GENERIC)
2519
2520 New macro: SCM_GPROC1 (CNAME, SNAME, TYPE, CFUNC, GENERIC)
2521
d02cafe7 2522These do the same job as SCM_PROC and SCM_PROC1, but they also define
49199eaa
MD
2523a variable GENERIC which can be used by the dispatch macros below.
2524
2525[This is experimental code which may change soon.]
2526
2527*** New macros for forwarding control to a generic on arg type error
2528
2529 New macro: SCM_WTA_DISPATCH_1 (GENERIC, ARG1, POS, SUBR)
2530
2531 New macro: SCM_WTA_DISPATCH_2 (GENERIC, ARG1, ARG2, POS, SUBR)
2532
2533These correspond to the scm_wta function call, and have the same
2534behaviour until the user has called the GOOPS primitive
2535`enable-primitive-generic!'. After that, these macros will apply the
2536generic function GENERIC to the argument(s) instead of calling
2537scm_wta.
2538
2539[This is experimental code which may change soon.]
2540
2541*** New macros for argument testing with generic dispatch
2542
2543 New macro: SCM_GASSERT1 (COND, GENERIC, ARG1, POS, SUBR)
2544
2545 New macro: SCM_GASSERT2 (COND, GENERIC, ARG1, ARG2, POS, SUBR)
2546
2547These correspond to the SCM_ASSERT macro, but will defer control to
2548GENERIC on error after `enable-primitive-generic!' has been called.
2549
2550[This is experimental code which may change soon.]
2551
2552** New function: SCM scm_eval_body (SCM body, SCM env)
2553
2554Evaluates the body of a special form.
2555
2556** The internal representation of struct's has changed
2557
2558Previously, four slots were allocated for the procedure(s) of entities
2559and operators. The motivation for this representation had to do with
2560the structure of the evaluator, the wish to support tail-recursive
2561generic functions, and efficiency. Since the generic function
2562dispatch mechanism has changed, there is no longer a need for such an
2563expensive representation, and the representation has been simplified.
2564
2565This should not make any difference for most users.
2566
2567** GOOPS support has been cleaned up.
2568
2569Some code has been moved from eval.c to objects.c and code in both of
2570these compilation units has been cleaned up and better structured.
2571
2572*** New functions for applying generic functions
2573
2574 New function: SCM scm_apply_generic (GENERIC, ARGS)
2575 New function: SCM scm_call_generic_0 (GENERIC)
2576 New function: SCM scm_call_generic_1 (GENERIC, ARG1)
2577 New function: SCM scm_call_generic_2 (GENERIC, ARG1, ARG2)
2578 New function: SCM scm_call_generic_3 (GENERIC, ARG1, ARG2, ARG3)
2579
ece41168
MD
2580** Deprecated function: scm_make_named_hook
2581
2582It is now replaced by:
2583
2584** New function: SCM scm_create_hook (const char *name, int arity)
2585
2586Creates a hook in the same way as make-hook above but also
2587binds a variable named NAME to it.
2588
2589This is the typical way of creating a hook from C code.
2590
2591Currently, the variable is created in the "current" module.
2592This might change when we get the new module system.
2593
2594[The behaviour is identical to scm_make_named_hook.]
2595
2596
43fa9a05 2597\f
f3227c7a
JB
2598Changes since Guile 1.3:
2599
6ca345f3
JB
2600* Changes to mailing lists
2601
2602** Some of the Guile mailing lists have moved to sourceware.cygnus.com.
2603
2604See the README file to find current addresses for all the Guile
2605mailing lists.
2606
d77fb593
JB
2607* Changes to the distribution
2608
1d335863
JB
2609** Readline support is no longer included with Guile by default.
2610
2611Based on the different license terms of Guile and Readline, we
2612concluded that Guile should not *by default* cause the linking of
2613Readline into an application program. Readline support is now offered
2614as a separate module, which is linked into an application only when
2615you explicitly specify it.
2616
2617Although Guile is GNU software, its distribution terms add a special
2618exception to the usual GNU General Public License (GPL). Guile's
2619license includes a clause that allows you to link Guile with non-free
2620programs. We add this exception so as not to put Guile at a
2621disadvantage vis-a-vis other extensibility packages that support other
2622languages.
2623
2624In contrast, the GNU Readline library is distributed under the GNU
2625General Public License pure and simple. This means that you may not
2626link Readline, even dynamically, into an application unless it is
2627distributed under a free software license that is compatible the GPL.
2628
2629Because of this difference in distribution terms, an application that
2630can use Guile may not be able to use Readline. Now users will be
2631explicitly offered two independent decisions about the use of these
2632two packages.
d77fb593 2633
0e8a8468
MV
2634You can activate the readline support by issuing
2635
2636 (use-modules (readline-activator))
2637 (activate-readline)
2638
2639from your ".guile" file, for example.
2640
e4eae9b1
MD
2641* Changes to the stand-alone interpreter
2642
67ad463a
MD
2643** All builtins now print as primitives.
2644Previously builtin procedures not belonging to the fundamental subr
2645types printed as #<compiled closure #<primitive-procedure gsubr-apply>>.
2646Now, they print as #<primitive-procedure NAME>.
2647
2648** Backtraces slightly more intelligible.
2649gsubr-apply and macro transformer application frames no longer appear
2650in backtraces.
2651
69c6acbb
JB
2652* Changes to Scheme functions and syntax
2653
2a52b429
MD
2654** Guile now correctly handles internal defines by rewriting them into
2655their equivalent letrec. Previously, internal defines would
2656incrementally add to the innermost environment, without checking
2657whether the restrictions specified in RnRS were met. This lead to the
2658correct behaviour when these restriction actually were met, but didn't
2659catch all illegal uses. Such an illegal use could lead to crashes of
2660the Guile interpreter or or other unwanted results. An example of
2661incorrect internal defines that made Guile behave erratically:
2662
2663 (let ()
2664 (define a 1)
2665 (define (b) a)
2666 (define c (1+ (b)))
2667 (define d 3)
2668
2669 (b))
2670
2671 => 2
2672
2673The problem with this example is that the definition of `c' uses the
2674value of `b' directly. This confuses the meoization machine of Guile
2675so that the second call of `b' (this time in a larger environment that
2676also contains bindings for `c' and `d') refers to the binding of `c'
2677instead of `a'. You could also make Guile crash with a variation on
2678this theme:
2679
2680 (define (foo flag)
2681 (define a 1)
2682 (define (b flag) (if flag a 1))
2683 (define c (1+ (b flag)))
2684 (define d 3)
2685
2686 (b #t))
2687
2688 (foo #f)
2689 (foo #t)
2690
2691From now on, Guile will issue an `Unbound variable: b' error message
2692for both examples.
2693
36d3d540
MD
2694** Hooks
2695
2696A hook contains a list of functions which should be called on
2697particular occasions in an existing program. Hooks are used for
2698customization.
2699
2700A window manager might have a hook before-window-map-hook. The window
2701manager uses the function run-hooks to call all functions stored in
2702before-window-map-hook each time a window is mapped. The user can
2703store functions in the hook using add-hook!.
2704
2705In Guile, hooks are first class objects.
2706
2707*** New function: make-hook [N_ARGS]
2708
2709Return a hook for hook functions which can take N_ARGS arguments.
2710The default value for N_ARGS is 0.
2711
ad91d6c3
MD
2712(See also scm_make_named_hook below.)
2713
36d3d540
MD
2714*** New function: add-hook! HOOK PROC [APPEND_P]
2715
2716Put PROC at the beginning of the list of functions stored in HOOK.
2717If APPEND_P is supplied, and non-false, put PROC at the end instead.
2718
2719PROC must be able to take the number of arguments specified when the
2720hook was created.
2721
2722If PROC already exists in HOOK, then remove it first.
2723
2724*** New function: remove-hook! HOOK PROC
2725
2726Remove PROC from the list of functions in HOOK.
2727
2728*** New function: reset-hook! HOOK
2729
2730Clear the list of hook functions stored in HOOK.
2731
2732*** New function: run-hook HOOK ARG1 ...
2733
2734Run all hook functions stored in HOOK with arguments ARG1 ... .
2735The number of arguments supplied must correspond to the number given
2736when the hook was created.
2737
56a19408
MV
2738** The function `dynamic-link' now takes optional keyword arguments.
2739 The only keyword argument that is currently defined is `:global
2740 BOOL'. With it, you can control whether the shared library will be
2741 linked in global mode or not. In global mode, the symbols from the
2742 linked library can be used to resolve references from other
2743 dynamically linked libraries. In non-global mode, the linked
2744 library is essentially invisible and can only be accessed via
2745 `dynamic-func', etc. The default is now to link in global mode.
2746 Previously, the default has been non-global mode.
2747
2748 The `#:global' keyword is only effective on platforms that support
2749 the dlopen family of functions.
2750
ad226f25 2751** New function `provided?'
b7e13f65
JB
2752
2753 - Function: provided? FEATURE
2754 Return true iff FEATURE is supported by this installation of
2755 Guile. FEATURE must be a symbol naming a feature; the global
2756 variable `*features*' is a list of available features.
2757
ad226f25
JB
2758** Changes to the module (ice-9 expect):
2759
2760*** The expect-strings macro now matches `$' in a regular expression
2761 only at a line-break or end-of-file by default. Previously it would
ab711359
JB
2762 match the end of the string accumulated so far. The old behaviour
2763 can be obtained by setting the variable `expect-strings-exec-flags'
2764 to 0.
ad226f25
JB
2765
2766*** The expect-strings macro now uses a variable `expect-strings-exec-flags'
2767 for the regexp-exec flags. If `regexp/noteol' is included, then `$'
2768 in a regular expression will still match before a line-break or
2769 end-of-file. The default is `regexp/noteol'.
2770
6c0201ad 2771*** The expect-strings macro now uses a variable
ad226f25
JB
2772 `expect-strings-compile-flags' for the flags to be supplied to
2773 `make-regexp'. The default is `regexp/newline', which was previously
2774 hard-coded.
2775
2776*** The expect macro now supplies two arguments to a match procedure:
ab711359
JB
2777 the current accumulated string and a flag to indicate whether
2778 end-of-file has been reached. Previously only the string was supplied.
2779 If end-of-file is reached, the match procedure will be called an
2780 additional time with the same accumulated string as the previous call
2781 but with the flag set.
ad226f25 2782
b7e13f65
JB
2783** New module (ice-9 format), implementing the Common Lisp `format' function.
2784
2785This code, and the documentation for it that appears here, was
2786borrowed from SLIB, with minor adaptations for Guile.
2787
2788 - Function: format DESTINATION FORMAT-STRING . ARGUMENTS
2789 An almost complete implementation of Common LISP format description
2790 according to the CL reference book `Common LISP' from Guy L.
2791 Steele, Digital Press. Backward compatible to most of the
2792 available Scheme format implementations.
2793
2794 Returns `#t', `#f' or a string; has side effect of printing
2795 according to FORMAT-STRING. If DESTINATION is `#t', the output is
2796 to the current output port and `#t' is returned. If DESTINATION
2797 is `#f', a formatted string is returned as the result of the call.
2798 NEW: If DESTINATION is a string, DESTINATION is regarded as the
2799 format string; FORMAT-STRING is then the first argument and the
2800 output is returned as a string. If DESTINATION is a number, the
2801 output is to the current error port if available by the
2802 implementation. Otherwise DESTINATION must be an output port and
2803 `#t' is returned.
2804
2805 FORMAT-STRING must be a string. In case of a formatting error
2806 format returns `#f' and prints a message on the current output or
2807 error port. Characters are output as if the string were output by
2808 the `display' function with the exception of those prefixed by a
2809 tilde (~). For a detailed description of the FORMAT-STRING syntax
2810 please consult a Common LISP format reference manual. For a test
2811 suite to verify this format implementation load `formatst.scm'.
2812 Please send bug reports to `lutzeb@cs.tu-berlin.de'.
2813
2814 Note: `format' is not reentrant, i.e. only one `format'-call may
2815 be executed at a time.
2816
2817
2818*** Format Specification (Format version 3.0)
2819
2820 Please consult a Common LISP format reference manual for a detailed
2821description of the format string syntax. For a demonstration of the
2822implemented directives see `formatst.scm'.
2823
2824 This implementation supports directive parameters and modifiers (`:'
2825and `@' characters). Multiple parameters must be separated by a comma
2826(`,'). Parameters can be numerical parameters (positive or negative),
2827character parameters (prefixed by a quote character (`''), variable
2828parameters (`v'), number of rest arguments parameter (`#'), empty and
2829default parameters. Directive characters are case independent. The
2830general form of a directive is:
2831
2832DIRECTIVE ::= ~{DIRECTIVE-PARAMETER,}[:][@]DIRECTIVE-CHARACTER
2833
2834DIRECTIVE-PARAMETER ::= [ [-|+]{0-9}+ | 'CHARACTER | v | # ]
2835
2836*** Implemented CL Format Control Directives
2837
2838 Documentation syntax: Uppercase characters represent the
2839corresponding control directive characters. Lowercase characters
2840represent control directive parameter descriptions.
2841
2842`~A'
2843 Any (print as `display' does).
2844 `~@A'
2845 left pad.
2846
2847 `~MINCOL,COLINC,MINPAD,PADCHARA'
2848 full padding.
2849
2850`~S'
2851 S-expression (print as `write' does).
2852 `~@S'
2853 left pad.
2854
2855 `~MINCOL,COLINC,MINPAD,PADCHARS'
2856 full padding.
2857
2858`~D'
2859 Decimal.
2860 `~@D'
2861 print number sign always.
2862
2863 `~:D'
2864 print comma separated.
2865
2866 `~MINCOL,PADCHAR,COMMACHARD'
2867 padding.
2868
2869`~X'
2870 Hexadecimal.
2871 `~@X'
2872 print number sign always.
2873
2874 `~:X'
2875 print comma separated.
2876
2877 `~MINCOL,PADCHAR,COMMACHARX'
2878 padding.
2879
2880`~O'
2881 Octal.
2882 `~@O'
2883 print number sign always.
2884
2885 `~:O'
2886 print comma separated.
2887
2888 `~MINCOL,PADCHAR,COMMACHARO'
2889 padding.
2890
2891`~B'
2892 Binary.
2893 `~@B'
2894 print number sign always.
2895
2896 `~:B'
2897 print comma separated.
2898
2899 `~MINCOL,PADCHAR,COMMACHARB'
2900 padding.
2901
2902`~NR'
2903 Radix N.
2904 `~N,MINCOL,PADCHAR,COMMACHARR'
2905 padding.
2906
2907`~@R'
2908 print a number as a Roman numeral.
2909
2910`~:@R'
2911 print a number as an "old fashioned" Roman numeral.
2912
2913`~:R'
2914 print a number as an ordinal English number.
2915
2916`~:@R'
2917 print a number as a cardinal English number.
2918
2919`~P'
2920 Plural.
2921 `~@P'
2922 prints `y' and `ies'.
2923
2924 `~:P'
2925 as `~P but jumps 1 argument backward.'
2926
2927 `~:@P'
2928 as `~@P but jumps 1 argument backward.'
2929
2930`~C'
2931 Character.
2932 `~@C'
2933 prints a character as the reader can understand it (i.e. `#\'
2934 prefixing).
2935
2936 `~:C'
2937 prints a character as emacs does (eg. `^C' for ASCII 03).
2938
2939`~F'
2940 Fixed-format floating-point (prints a flonum like MMM.NNN).
2941 `~WIDTH,DIGITS,SCALE,OVERFLOWCHAR,PADCHARF'
2942 `~@F'
2943 If the number is positive a plus sign is printed.
2944
2945`~E'
2946 Exponential floating-point (prints a flonum like MMM.NNN`E'EE).
2947 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARE'
2948 `~@E'
2949 If the number is positive a plus sign is printed.
2950
2951`~G'
2952 General floating-point (prints a flonum either fixed or
2953 exponential).
2954 `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARG'
2955 `~@G'
2956 If the number is positive a plus sign is printed.
2957
2958`~$'
2959 Dollars floating-point (prints a flonum in fixed with signs
2960 separated).
2961 `~DIGITS,SCALE,WIDTH,PADCHAR$'
2962 `~@$'
2963 If the number is positive a plus sign is printed.
2964
2965 `~:@$'
2966 A sign is always printed and appears before the padding.
2967
2968 `~:$'
2969 The sign appears before the padding.
2970
2971`~%'
2972 Newline.
2973 `~N%'
2974 print N newlines.
2975
2976`~&'
2977 print newline if not at the beginning of the output line.
2978 `~N&'
2979 prints `~&' and then N-1 newlines.
2980
2981`~|'
2982 Page Separator.
2983 `~N|'
2984 print N page separators.
2985
2986`~~'
2987 Tilde.
2988 `~N~'
2989 print N tildes.
2990
2991`~'<newline>
2992 Continuation Line.
2993 `~:'<newline>
2994 newline is ignored, white space left.
2995
2996 `~@'<newline>
2997 newline is left, white space ignored.
2998
2999`~T'
3000 Tabulation.
3001 `~@T'
3002 relative tabulation.
3003
3004 `~COLNUM,COLINCT'
3005 full tabulation.
3006
3007`~?'
3008 Indirection (expects indirect arguments as a list).
3009 `~@?'
3010 extracts indirect arguments from format arguments.
3011
3012`~(STR~)'
3013 Case conversion (converts by `string-downcase').
3014 `~:(STR~)'
3015 converts by `string-capitalize'.
3016
3017 `~@(STR~)'
3018 converts by `string-capitalize-first'.
3019
3020 `~:@(STR~)'
3021 converts by `string-upcase'.
3022
3023`~*'
3024 Argument Jumping (jumps 1 argument forward).
3025 `~N*'
3026 jumps N arguments forward.
3027
3028 `~:*'
3029 jumps 1 argument backward.
3030
3031 `~N:*'
3032 jumps N arguments backward.
3033
3034 `~@*'
3035 jumps to the 0th argument.
3036
3037 `~N@*'
3038 jumps to the Nth argument (beginning from 0)
3039
3040`~[STR0~;STR1~;...~;STRN~]'
3041 Conditional Expression (numerical clause conditional).
3042 `~N['
3043 take argument from N.
3044
3045 `~@['
3046 true test conditional.
3047
3048 `~:['
3049 if-else-then conditional.
3050
3051 `~;'
3052 clause separator.
3053
3054 `~:;'
3055 default clause follows.
3056
3057`~{STR~}'
3058 Iteration (args come from the next argument (a list)).
3059 `~N{'
3060 at most N iterations.
3061
3062 `~:{'
3063 args from next arg (a list of lists).
3064
3065 `~@{'
3066 args from the rest of arguments.
3067
3068 `~:@{'
3069 args from the rest args (lists).
3070
3071`~^'
3072 Up and out.
3073 `~N^'
3074 aborts if N = 0
3075
3076 `~N,M^'
3077 aborts if N = M
3078
3079 `~N,M,K^'
3080 aborts if N <= M <= K
3081
3082*** Not Implemented CL Format Control Directives
3083
3084`~:A'
3085 print `#f' as an empty list (see below).
3086
3087`~:S'
3088 print `#f' as an empty list (see below).
3089
3090`~<~>'
3091 Justification.
3092
3093`~:^'
3094 (sorry I don't understand its semantics completely)
3095
3096*** Extended, Replaced and Additional Control Directives
3097
3098`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHD'
3099`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHX'
3100`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHO'
3101`~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHB'
3102`~N,MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHR'
3103 COMMAWIDTH is the number of characters between two comma
3104 characters.
3105
3106`~I'
3107 print a R4RS complex number as `~F~@Fi' with passed parameters for
3108 `~F'.
3109
3110`~Y'
3111 Pretty print formatting of an argument for scheme code lists.
3112
3113`~K'
3114 Same as `~?.'
3115
3116`~!'
3117 Flushes the output if format DESTINATION is a port.
3118
3119`~_'
3120 Print a `#\space' character
3121 `~N_'
3122 print N `#\space' characters.
3123
3124`~/'
3125 Print a `#\tab' character
3126 `~N/'
3127 print N `#\tab' characters.
3128
3129`~NC'
3130 Takes N as an integer representation for a character. No arguments
3131 are consumed. N is converted to a character by `integer->char'. N
3132 must be a positive decimal number.
3133
3134`~:S'
3135 Print out readproof. Prints out internal objects represented as
3136 `#<...>' as strings `"#<...>"' so that the format output can always
3137 be processed by `read'.
3138
3139`~:A'
3140 Print out readproof. Prints out internal objects represented as
3141 `#<...>' as strings `"#<...>"' so that the format output can always
3142 be processed by `read'.
3143
3144`~Q'
3145 Prints information and a copyright notice on the format
3146 implementation.
3147 `~:Q'
3148 prints format version.
3149
3150`~F, ~E, ~G, ~$'
3151 may also print number strings, i.e. passing a number as a string
3152 and format it accordingly.
3153
3154*** Configuration Variables
3155
3156 The format module exports some configuration variables to suit the
3157systems and users needs. There should be no modification necessary for
3158the configuration that comes with Guile. Format detects automatically
3159if the running scheme system implements floating point numbers and
3160complex numbers.
3161
3162format:symbol-case-conv
3163 Symbols are converted by `symbol->string' so the case type of the
3164 printed symbols is implementation dependent.
3165 `format:symbol-case-conv' is a one arg closure which is either
3166 `#f' (no conversion), `string-upcase', `string-downcase' or
3167 `string-capitalize'. (default `#f')
3168
3169format:iobj-case-conv
3170 As FORMAT:SYMBOL-CASE-CONV but applies for the representation of
3171 implementation internal objects. (default `#f')
3172
3173format:expch
3174 The character prefixing the exponent value in `~E' printing.
3175 (default `#\E')
3176
3177*** Compatibility With Other Format Implementations
3178
3179SLIB format 2.x:
3180 See `format.doc'.
3181
3182SLIB format 1.4:
3183 Downward compatible except for padding support and `~A', `~S',
3184 `~P', `~X' uppercase printing. SLIB format 1.4 uses C-style
3185 `printf' padding support which is completely replaced by the CL
3186 `format' padding style.
3187
3188MIT C-Scheme 7.1:
3189 Downward compatible except for `~', which is not documented
3190 (ignores all characters inside the format string up to a newline
3191 character). (7.1 implements `~a', `~s', ~NEWLINE, `~~', `~%',
3192 numerical and variable parameters and `:/@' modifiers in the CL
3193 sense).
3194
3195Elk 1.5/2.0:
3196 Downward compatible except for `~A' and `~S' which print in
3197 uppercase. (Elk implements `~a', `~s', `~~', and `~%' (no
3198 directive parameters or modifiers)).
3199
3200Scheme->C 01nov91:
3201 Downward compatible except for an optional destination parameter:
3202 S2C accepts a format call without a destination which returns a
3203 formatted string. This is equivalent to a #f destination in S2C.
3204 (S2C implements `~a', `~s', `~c', `~%', and `~~' (no directive
3205 parameters or modifiers)).
3206
3207
e7d37b0a 3208** Changes to string-handling functions.
b7e13f65 3209
e7d37b0a 3210These functions were added to support the (ice-9 format) module, above.
b7e13f65 3211
e7d37b0a
JB
3212*** New function: string-upcase STRING
3213*** New function: string-downcase STRING
b7e13f65 3214
e7d37b0a
JB
3215These are non-destructive versions of the existing string-upcase! and
3216string-downcase! functions.
b7e13f65 3217
e7d37b0a
JB
3218*** New function: string-capitalize! STRING
3219*** New function: string-capitalize STRING
3220
3221These functions convert the first letter of each word in the string to
3222upper case. Thus:
3223
3224 (string-capitalize "howdy there")
3225 => "Howdy There"
3226
3227As with the other functions, string-capitalize! modifies the string in
3228place, while string-capitalize returns a modified copy of its argument.
3229
3230*** New function: string-ci->symbol STRING
3231
3232Return a symbol whose name is STRING, but having the same case as if
3233the symbol had be read by `read'.
3234
3235Guile can be configured to be sensitive or insensitive to case
3236differences in Scheme identifiers. If Guile is case-insensitive, all
3237symbols are converted to lower case on input. The `string-ci->symbol'
3238function returns a symbol whose name in STRING, transformed as Guile
3239would if STRING were input.
3240
3241*** New function: substring-move! STRING1 START END STRING2 START
3242
3243Copy the substring of STRING1 from START (inclusive) to END
3244(exclusive) to STRING2 at START. STRING1 and STRING2 may be the same
3245string, and the source and destination areas may overlap; in all
3246cases, the function behaves as if all the characters were copied
3247simultanously.
3248
6c0201ad 3249*** Extended functions: substring-move-left! substring-move-right!
e7d37b0a
JB
3250
3251These functions now correctly copy arbitrarily overlapping substrings;
3252they are both synonyms for substring-move!.
b7e13f65 3253
b7e13f65 3254
deaceb4e
JB
3255** New module (ice-9 getopt-long), with the function `getopt-long'.
3256
3257getopt-long is a function for parsing command-line arguments in a
3258manner consistent with other GNU programs.
3259
3260(getopt-long ARGS GRAMMAR)
3261Parse the arguments ARGS according to the argument list grammar GRAMMAR.
3262
3263ARGS should be a list of strings. Its first element should be the
3264name of the program; subsequent elements should be the arguments
3265that were passed to the program on the command line. The
3266`program-arguments' procedure returns a list of this form.
3267
3268GRAMMAR is a list of the form:
3269((OPTION (PROPERTY VALUE) ...) ...)
3270
3271Each OPTION should be a symbol. `getopt-long' will accept a
3272command-line option named `--OPTION'.
3273Each option can have the following (PROPERTY VALUE) pairs:
3274
3275 (single-char CHAR) --- Accept `-CHAR' as a single-character
3276 equivalent to `--OPTION'. This is how to specify traditional
3277 Unix-style flags.
3278 (required? BOOL) --- If BOOL is true, the option is required.
3279 getopt-long will raise an error if it is not found in ARGS.
3280 (value BOOL) --- If BOOL is #t, the option accepts a value; if
3281 it is #f, it does not; and if it is the symbol
3282 `optional', the option may appear in ARGS with or
6c0201ad 3283 without a value.
deaceb4e
JB
3284 (predicate FUNC) --- If the option accepts a value (i.e. you
3285 specified `(value #t)' for this option), then getopt
3286 will apply FUNC to the value, and throw an exception
3287 if it returns #f. FUNC should be a procedure which
3288 accepts a string and returns a boolean value; you may
3289 need to use quasiquotes to get it into GRAMMAR.
3290
3291The (PROPERTY VALUE) pairs may occur in any order, but each
3292property may occur only once. By default, options do not have
3293single-character equivalents, are not required, and do not take
3294values.
3295
3296In ARGS, single-character options may be combined, in the usual
3297Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option
3298accepts values, then it must be the last option in the
3299combination; the value is the next argument. So, for example, using
3300the following grammar:
3301 ((apples (single-char #\a))
3302 (blimps (single-char #\b) (value #t))
3303 (catalexis (single-char #\c) (value #t)))
3304the following argument lists would be acceptable:
3305 ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values
3306 for "blimps" and "catalexis")
3307 ("-ab" "bang" "-c" "couth") (same)
3308 ("-ac" "couth" "-b" "bang") (same)
3309 ("-abc" "couth" "bang") (an error, since `-b' is not the
3310 last option in its combination)
3311
3312If an option's value is optional, then `getopt-long' decides
3313whether it has a value by looking at what follows it in ARGS. If
3314the next element is a string, and it does not appear to be an
3315option itself, then that string is the option's value.
3316
3317The value of a long option can appear as the next element in ARGS,
3318or it can follow the option name, separated by an `=' character.
3319Thus, using the same grammar as above, the following argument lists
3320are equivalent:
3321 ("--apples" "Braeburn" "--blimps" "Goodyear")
3322 ("--apples=Braeburn" "--blimps" "Goodyear")
3323 ("--blimps" "Goodyear" "--apples=Braeburn")
3324
3325If the option "--" appears in ARGS, argument parsing stops there;
3326subsequent arguments are returned as ordinary arguments, even if
3327they resemble options. So, in the argument list:
3328 ("--apples" "Granny Smith" "--" "--blimp" "Goodyear")
3329`getopt-long' will recognize the `apples' option as having the
3330value "Granny Smith", but it will not recognize the `blimp'
3331option; it will return the strings "--blimp" and "Goodyear" as
3332ordinary argument strings.
3333
3334The `getopt-long' function returns the parsed argument list as an
3335assocation list, mapping option names --- the symbols from GRAMMAR
3336--- onto their values, or #t if the option does not accept a value.
3337Unused options do not appear in the alist.
3338
3339All arguments that are not the value of any option are returned
3340as a list, associated with the empty list.
3341
3342`getopt-long' throws an exception if:
3343- it finds an unrecognized option in ARGS
3344- a required option is omitted
3345- an option that requires an argument doesn't get one
3346- an option that doesn't accept an argument does get one (this can
3347 only happen using the long option `--opt=value' syntax)
3348- an option predicate fails
3349
3350So, for example:
3351
3352(define grammar
3353 `((lockfile-dir (required? #t)
3354 (value #t)
3355 (single-char #\k)
3356 (predicate ,file-is-directory?))
3357 (verbose (required? #f)
3358 (single-char #\v)
3359 (value #f))
3360 (x-includes (single-char #\x))
6c0201ad 3361 (rnet-server (single-char #\y)
deaceb4e
JB
3362 (predicate ,string?))))
3363
6c0201ad 3364(getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include"
deaceb4e
JB
3365 "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3")
3366 grammar)
3367=> ((() "foo1" "-fred" "foo2" "foo3")
3368 (rnet-server . "lamprod")
3369 (x-includes . "/usr/include")
3370 (lockfile-dir . "/tmp")
3371 (verbose . #t))
3372
3373** The (ice-9 getopt-gnu-style) module is obsolete; use (ice-9 getopt-long).
3374
3375It will be removed in a few releases.
3376
08394899
MS
3377** New syntax: lambda*
3378** New syntax: define*
6c0201ad 3379** New syntax: define*-public
08394899
MS
3380** New syntax: defmacro*
3381** New syntax: defmacro*-public
6c0201ad 3382Guile now supports optional arguments.
08394899
MS
3383
3384`lambda*', `define*', `define*-public', `defmacro*' and
3385`defmacro*-public' are identical to the non-* versions except that
3386they use an extended type of parameter list that has the following BNF
3387syntax (parentheses are literal, square brackets indicate grouping,
3388and `*', `+' and `?' have the usual meaning):
3389
3390 ext-param-list ::= ( [identifier]* [#&optional [ext-var-decl]+]?
6c0201ad 3391 [#&key [ext-var-decl]+ [#&allow-other-keys]?]?
08394899
MS
3392 [[#&rest identifier]|[. identifier]]? ) | [identifier]
3393
6c0201ad 3394 ext-var-decl ::= identifier | ( identifier expression )
08394899
MS
3395
3396The semantics are best illustrated with the following documentation
3397and examples for `lambda*':
3398
3399 lambda* args . body
3400 lambda extended for optional and keyword arguments
6c0201ad 3401
08394899
MS
3402 lambda* creates a procedure that takes optional arguments. These
3403 are specified by putting them inside brackets at the end of the
3404 paramater list, but before any dotted rest argument. For example,
3405 (lambda* (a b #&optional c d . e) '())
3406 creates a procedure with fixed arguments a and b, optional arguments c
3407 and d, and rest argument e. If the optional arguments are omitted
3408 in a call, the variables for them are unbound in the procedure. This
3409 can be checked with the bound? macro.
3410
3411 lambda* can also take keyword arguments. For example, a procedure
3412 defined like this:
3413 (lambda* (#&key xyzzy larch) '())
3414 can be called with any of the argument lists (#:xyzzy 11)
3415 (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments
3416 are given as keywords are bound to values.
3417
3418 Optional and keyword arguments can also be given default values
3419 which they take on when they are not present in a call, by giving a
3420 two-item list in place of an optional argument, for example in:
6c0201ad 3421 (lambda* (foo #&optional (bar 42) #&key (baz 73)) (list foo bar baz))
08394899
MS
3422 foo is a fixed argument, bar is an optional argument with default
3423 value 42, and baz is a keyword argument with default value 73.
3424 Default value expressions are not evaluated unless they are needed
6c0201ad 3425 and until the procedure is called.
08394899
MS
3426
3427 lambda* now supports two more special parameter list keywords.
3428
3429 lambda*-defined procedures now throw an error by default if a
3430 keyword other than one of those specified is found in the actual
3431 passed arguments. However, specifying #&allow-other-keys
3432 immediately after the kyword argument declarations restores the
3433 previous behavior of ignoring unknown keywords. lambda* also now
3434 guarantees that if the same keyword is passed more than once, the
3435 last one passed is the one that takes effect. For example,
3436 ((lambda* (#&key (heads 0) (tails 0)) (display (list heads tails)))
3437 #:heads 37 #:tails 42 #:heads 99)
3438 would result in (99 47) being displayed.
3439
3440 #&rest is also now provided as a synonym for the dotted syntax rest
3441 argument. The argument lists (a . b) and (a #&rest b) are equivalent in
3442 all respects to lambda*. This is provided for more similarity to DSSSL,
3443 MIT-Scheme and Kawa among others, as well as for refugees from other
3444 Lisp dialects.
3445
3446Further documentation may be found in the optargs.scm file itself.
3447
3448The optional argument module also exports the macros `let-optional',
3449`let-optional*', `let-keywords', `let-keywords*' and `bound?'. These
3450are not documented here because they may be removed in the future, but
3451full documentation is still available in optargs.scm.
3452
2e132553
JB
3453** New syntax: and-let*
3454Guile now supports the `and-let*' form, described in the draft SRFI-2.
3455
3456Syntax: (land* (<clause> ...) <body> ...)
3457Each <clause> should have one of the following forms:
3458 (<variable> <expression>)
3459 (<expression>)
3460 <bound-variable>
3461Each <variable> or <bound-variable> should be an identifier. Each
3462<expression> should be a valid expression. The <body> should be a
3463possibly empty sequence of expressions, like the <body> of a
3464lambda form.
3465
3466Semantics: A LAND* expression is evaluated by evaluating the
3467<expression> or <bound-variable> of each of the <clause>s from
3468left to right. The value of the first <expression> or
3469<bound-variable> that evaluates to a false value is returned; the
3470remaining <expression>s and <bound-variable>s are not evaluated.
3471The <body> forms are evaluated iff all the <expression>s and
3472<bound-variable>s evaluate to true values.
3473
3474The <expression>s and the <body> are evaluated in an environment
3475binding each <variable> of the preceding (<variable> <expression>)
3476clauses to the value of the <expression>. Later bindings
3477shadow earlier bindings.
3478
3479Guile's and-let* macro was contributed by Michael Livshin.
3480
36d3d540
MD
3481** New sorting functions
3482
3483*** New function: sorted? SEQUENCE LESS?
ed8c8636
MD
3484Returns `#t' when the sequence argument is in non-decreasing order
3485according to LESS? (that is, there is no adjacent pair `... x y
3486...' for which `(less? y x)').
3487
3488Returns `#f' when the sequence contains at least one out-of-order
3489pair. It is an error if the sequence is neither a list nor a
3490vector.
3491
36d3d540 3492*** New function: merge LIST1 LIST2 LESS?
ed8c8636
MD
3493LIST1 and LIST2 are sorted lists.
3494Returns the sorted list of all elements in LIST1 and LIST2.
3495
3496Assume that the elements a and b1 in LIST1 and b2 in LIST2 are "equal"
3497in the sense that (LESS? x y) --> #f for x, y in {a, b1, b2},
3498and that a < b1 in LIST1. Then a < b1 < b2 in the result.
3499(Here "<" should read "comes before".)
3500
36d3d540 3501*** New procedure: merge! LIST1 LIST2 LESS?
ed8c8636
MD
3502Merges two lists, re-using the pairs of LIST1 and LIST2 to build
3503the result. If the code is compiled, and LESS? constructs no new
3504pairs, no pairs at all will be allocated. The first pair of the
3505result will be either the first pair of LIST1 or the first pair of
3506LIST2.
3507
36d3d540 3508*** New function: sort SEQUENCE LESS?
ed8c8636
MD
3509Accepts either a list or a vector, and returns a new sequence
3510which is sorted. The new sequence is the same type as the input.
3511Always `(sorted? (sort sequence less?) less?)'. The original
3512sequence is not altered in any way. The new sequence shares its
3513elements with the old one; no elements are copied.
3514
36d3d540 3515*** New procedure: sort! SEQUENCE LESS
ed8c8636
MD
3516Returns its sorted result in the original boxes. No new storage is
3517allocated at all. Proper usage: (set! slist (sort! slist <))
3518
36d3d540 3519*** New function: stable-sort SEQUENCE LESS?
ed8c8636
MD
3520Similar to `sort' but stable. That is, if "equal" elements are
3521ordered a < b in the original sequence, they will have the same order
3522in the result.
3523
36d3d540 3524*** New function: stable-sort! SEQUENCE LESS?
ed8c8636
MD
3525Similar to `sort!' but stable.
3526Uses temporary storage when sorting vectors.
3527
36d3d540 3528*** New functions: sort-list, sort-list!
ed8c8636
MD
3529Added for compatibility with scsh.
3530
36d3d540
MD
3531** New built-in random number support
3532
3533*** New function: random N [STATE]
3e8370c3
MD
3534Accepts a positive integer or real N and returns a number of the
3535same type between zero (inclusive) and N (exclusive). The values
3536returned have a uniform distribution.
3537
3538The optional argument STATE must be of the type produced by
416075f1
MD
3539`copy-random-state' or `seed->random-state'. It defaults to the value
3540of the variable `*random-state*'. This object is used to maintain the
3541state of the pseudo-random-number generator and is altered as a side
3542effect of the `random' operation.
3e8370c3 3543
36d3d540 3544*** New variable: *random-state*
3e8370c3
MD
3545Holds a data structure that encodes the internal state of the
3546random-number generator that `random' uses by default. The nature
3547of this data structure is implementation-dependent. It may be
3548printed out and successfully read back in, but may or may not
3549function correctly as a random-number state object in another
3550implementation.
3551
36d3d540 3552*** New function: copy-random-state [STATE]
3e8370c3
MD
3553Returns a new object of type suitable for use as the value of the
3554variable `*random-state*' and as a second argument to `random'.
3555If argument STATE is given, a copy of it is returned. Otherwise a
3556copy of `*random-state*' is returned.
416075f1 3557
36d3d540 3558*** New function: seed->random-state SEED
416075f1
MD
3559Returns a new object of type suitable for use as the value of the
3560variable `*random-state*' and as a second argument to `random'.
3561SEED is a string or a number. A new state is generated and
3562initialized using SEED.
3e8370c3 3563
36d3d540 3564*** New function: random:uniform [STATE]
3e8370c3
MD
3565Returns an uniformly distributed inexact real random number in the
3566range between 0 and 1.
3567
36d3d540 3568*** New procedure: random:solid-sphere! VECT [STATE]
3e8370c3
MD
3569Fills VECT with inexact real random numbers the sum of whose
3570squares is less than 1.0. Thinking of VECT as coordinates in
3571space of dimension N = `(vector-length VECT)', the coordinates are
3572uniformly distributed within the unit N-shere. The sum of the
3573squares of the numbers is returned. VECT can be either a vector
3574or a uniform vector of doubles.
3575
36d3d540 3576*** New procedure: random:hollow-sphere! VECT [STATE]
3e8370c3
MD
3577Fills VECT with inexact real random numbers the sum of whose squares
3578is equal to 1.0. Thinking of VECT as coordinates in space of
3579dimension n = `(vector-length VECT)', the coordinates are uniformly
3580distributed over the surface of the unit n-shere. VECT can be either
3581a vector or a uniform vector of doubles.
3582
36d3d540 3583*** New function: random:normal [STATE]
3e8370c3
MD
3584Returns an inexact real in a normal distribution with mean 0 and
3585standard deviation 1. For a normal distribution with mean M and
3586standard deviation D use `(+ M (* D (random:normal)))'.
3587
36d3d540 3588*** New procedure: random:normal-vector! VECT [STATE]
3e8370c3
MD
3589Fills VECT with inexact real random numbers which are independent and
3590standard normally distributed (i.e., with mean 0 and variance 1).
3591VECT can be either a vector or a uniform vector of doubles.
3592
36d3d540 3593*** New function: random:exp STATE
3e8370c3
MD
3594Returns an inexact real in an exponential distribution with mean 1.
3595For an exponential distribution with mean U use (* U (random:exp)).
3596
69c6acbb
JB
3597** The range of logand, logior, logxor, logtest, and logbit? have changed.
3598
3599These functions now operate on numbers in the range of a C unsigned
3600long.
3601
3602These functions used to operate on numbers in the range of a C signed
3603long; however, this seems inappropriate, because Guile integers don't
3604overflow.
3605
ba4ee0d6
MD
3606** New function: make-guardian
3607This is an implementation of guardians as described in
3608R. Kent Dybvig, Carl Bruggeman, and David Eby (1993) "Guardians in a
3609Generation-Based Garbage Collector" ACM SIGPLAN Conference on
3610Programming Language Design and Implementation, June 1993
3611ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz
3612
88ceea5c
MD
3613** New functions: delq1!, delv1!, delete1!
3614These procedures behave similar to delq! and friends but delete only
3615one object if at all.
3616
55254a6a
MD
3617** New function: unread-string STRING PORT
3618Unread STRING to PORT, that is, push it back onto the port so that
3619next read operation will work on the pushed back characters.
3620
3621** unread-char can now be called multiple times
3622If unread-char is called multiple times, the unread characters will be
3623read again in last-in first-out order.
3624
9e97c52d
GH
3625** the procedures uniform-array-read! and uniform-array-write! now
3626work on any kind of port, not just ports which are open on a file.
3627
b074884f 3628** Now 'l' in a port mode requests line buffering.
9e97c52d 3629
69bc9ff3
GH
3630** The procedure truncate-file now works on string ports as well
3631as file ports. If the size argument is omitted, the current
1b9c3dae 3632file position is used.
9e97c52d 3633
c94577b4 3634** new procedure: seek PORT/FDES OFFSET WHENCE
9e97c52d
GH
3635The arguments are the same as for the old fseek procedure, but it
3636works on string ports as well as random-access file ports.
3637
3638** the fseek procedure now works on string ports, since it has been
c94577b4 3639redefined using seek.
9e97c52d
GH
3640
3641** the setvbuf procedure now uses a default size if mode is _IOFBF and
3642size is not supplied.
3643
3644** the newline procedure no longer flushes the port if it's not
3645line-buffered: previously it did if it was the current output port.
3646
3647** open-pipe and close-pipe are no longer primitive procedures, but
3648an emulation can be obtained using `(use-modules (ice-9 popen))'.
3649
3650** the freopen procedure has been removed.
3651
3652** new procedure: drain-input PORT
3653Drains PORT's read buffers (including any pushed-back characters)
3654and returns the contents as a single string.
3655
67ad463a 3656** New function: map-in-order PROC LIST1 LIST2 ...
d41b3904
MD
3657Version of `map' which guarantees that the procedure is applied to the
3658lists in serial order.
3659
67ad463a
MD
3660** Renamed `serial-array-copy!' and `serial-array-map!' to
3661`array-copy-in-order!' and `array-map-in-order!'. The old names are
3662now obsolete and will go away in release 1.5.
3663
cf7132b3 3664** New syntax: collect BODY1 ...
d41b3904
MD
3665Version of `begin' which returns a list of the results of the body
3666forms instead of the result of the last body form. In contrast to
cf7132b3 3667`begin', `collect' allows an empty body.
d41b3904 3668
e4eae9b1
MD
3669** New functions: read-history FILENAME, write-history FILENAME
3670Read/write command line history from/to file. Returns #t on success
3671and #f if an error occured.
3672
d21ffe26
JB
3673** `ls' and `lls' in module (ice-9 ls) now handle no arguments.
3674
3675These procedures return a list of definitions available in the specified
3676argument, a relative module reference. In the case of no argument,
3677`(current-module)' is now consulted for definitions to return, instead
3678of simply returning #f, the former behavior.
3679
f8c9d497
JB
3680** The #/ syntax for lists is no longer supported.
3681
3682Earlier versions of Scheme accepted this syntax, but printed a
3683warning.
3684
3685** Guile no longer consults the SCHEME_LOAD_PATH environment variable.
3686
3687Instead, you should set GUILE_LOAD_PATH to tell Guile where to find
3688modules.
3689
3ffc7a36
MD
3690* Changes to the gh_ interface
3691
3692** gh_scm2doubles
3693
3694Now takes a second argument which is the result array. If this
3695pointer is NULL, a new array is malloced (the old behaviour).
3696
3697** gh_chars2byvect, gh_shorts2svect, gh_floats2fvect, gh_scm2chars,
3698 gh_scm2shorts, gh_scm2longs, gh_scm2floats
3699
3700New functions.
3701
3e8370c3
MD
3702* Changes to the scm_ interface
3703
ad91d6c3
MD
3704** Function: scm_make_named_hook (char* name, int n_args)
3705
3706Creates a hook in the same way as make-hook above but also
3707binds a variable named NAME to it.
3708
3709This is the typical way of creating a hook from C code.
3710
ece41168
MD
3711Currently, the variable is created in the "current" module. This
3712might change when we get the new module system.
ad91d6c3 3713
16a5a9a4
MD
3714** The smob interface
3715
3716The interface for creating smobs has changed. For documentation, see
3717data-rep.info (made from guile-core/doc/data-rep.texi).
3718
3719*** Deprecated function: SCM scm_newsmob (scm_smobfuns *)
3720
3721>>> This function will be removed in 1.3.4. <<<
3722
3723It is replaced by:
3724
3725*** Function: SCM scm_make_smob_type (const char *name, scm_sizet size)
3726This function adds a new smob type, named NAME, with instance size
3727SIZE to the system. The return value is a tag that is used in
3728creating instances of the type. If SIZE is 0, then no memory will
3729be allocated when instances of the smob are created, and nothing
3730will be freed by the default free function.
6c0201ad 3731
16a5a9a4
MD
3732*** Function: void scm_set_smob_mark (long tc, SCM (*mark) (SCM))
3733This function sets the smob marking procedure for the smob type
3734specified by the tag TC. TC is the tag returned by
3735`scm_make_smob_type'.
3736
3737*** Function: void scm_set_smob_free (long tc, SCM (*mark) (SCM))
3738This function sets the smob freeing procedure for the smob type
3739specified by the tag TC. TC is the tag returned by
3740`scm_make_smob_type'.
3741
3742*** Function: void scm_set_smob_print (tc, print)
3743
3744 - Function: void scm_set_smob_print (long tc,
3745 scm_sizet (*print) (SCM,
3746 SCM,
3747 scm_print_state *))
3748
3749This function sets the smob printing procedure for the smob type
3750specified by the tag TC. TC is the tag returned by
3751`scm_make_smob_type'.
3752
3753*** Function: void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM))
3754This function sets the smob equality-testing predicate for the
3755smob type specified by the tag TC. TC is the tag returned by
3756`scm_make_smob_type'.
3757
3758*** Macro: void SCM_NEWSMOB (SCM var, long tc, void *data)
3759Make VALUE contain a smob instance of the type with type code TC and
3760smob data DATA. VALUE must be previously declared as C type `SCM'.
3761
3762*** Macro: fn_returns SCM_RETURN_NEWSMOB (long tc, void *data)
3763This macro expands to a block of code that creates a smob instance
3764of the type with type code TC and smob data DATA, and returns that
3765`SCM' value. It should be the last piece of code in a block.
3766
9e97c52d
GH
3767** The interfaces for using I/O ports and implementing port types
3768(ptobs) have changed significantly. The new interface is based on
3769shared access to buffers and a new set of ptob procedures.
3770
16a5a9a4
MD
3771*** scm_newptob has been removed
3772
3773It is replaced by:
3774
3775*** Function: SCM scm_make_port_type (type_name, fill_buffer, write_flush)
3776
3777- Function: SCM scm_make_port_type (char *type_name,
3778 int (*fill_buffer) (SCM port),
3779 void (*write_flush) (SCM port));
3780
3781Similarly to the new smob interface, there is a set of function
3782setters by which the user can customize the behaviour of his port
544e9093 3783type. See ports.h (scm_set_port_XXX).
16a5a9a4 3784
9e97c52d
GH
3785** scm_strport_to_string: New function: creates a new string from
3786a string port's buffer.
3787
3e8370c3
MD
3788** Plug in interface for random number generators
3789The variable `scm_the_rng' in random.c contains a value and three
3790function pointers which together define the current random number
3791generator being used by the Scheme level interface and the random
3792number library functions.
3793
3794The user is free to replace the default generator with the generator
3795of his own choice.
3796
3797*** Variable: size_t scm_the_rng.rstate_size
3798The size of the random state type used by the current RNG
3799measured in chars.
3800
3801*** Function: unsigned long scm_the_rng.random_bits (scm_rstate *STATE)
3802Given the random STATE, return 32 random bits.
3803
3804*** Function: void scm_the_rng.init_rstate (scm_rstate *STATE, chars *S, int N)
3805Seed random state STATE using string S of length N.
3806
3807*** Function: scm_rstate *scm_the_rng.copy_rstate (scm_rstate *STATE)
3808Given random state STATE, return a malloced copy.
3809
3810** Default RNG
3811The default RNG is the MWC (Multiply With Carry) random number
3812generator described by George Marsaglia at the Department of
3813Statistics and Supercomputer Computations Research Institute, The
3814Florida State University (http://stat.fsu.edu/~geo).
3815
3816It uses 64 bits, has a period of 4578426017172946943 (4.6e18), and
3817passes all tests in the DIEHARD test suite
3818(http://stat.fsu.edu/~geo/diehard.html). The generation of 32 bits
3819costs one multiply and one add on platforms which either supports long
3820longs (gcc does this on most systems) or have 64 bit longs. The cost
3821is four multiply on other systems but this can be optimized by writing
3822scm_i_uniform32 in assembler.
3823
3824These functions are provided through the scm_the_rng interface for use
3825by libguile and the application.
3826
3827*** Function: unsigned long scm_i_uniform32 (scm_i_rstate *STATE)
3828Given the random STATE, return 32 random bits.
3829Don't use this function directly. Instead go through the plugin
3830interface (see "Plug in interface" above).
3831
3832*** Function: void scm_i_init_rstate (scm_i_rstate *STATE, char *SEED, int N)
3833Initialize STATE using SEED of length N.
3834
3835*** Function: scm_i_rstate *scm_i_copy_rstate (scm_i_rstate *STATE)
3836Return a malloc:ed copy of STATE. This function can easily be re-used
3837in the interfaces to other RNGs.
3838
3839** Random number library functions
3840These functions use the current RNG through the scm_the_rng interface.
3841It might be a good idea to use these functions from your C code so
3842that only one random generator is used by all code in your program.
3843
259529f2 3844The default random state is stored in:
3e8370c3
MD
3845
3846*** Variable: SCM scm_var_random_state
3847Contains the vcell of the Scheme variable "*random-state*" which is
3848used as default state by all random number functions in the Scheme
3849level interface.
3850
3851Example:
3852
259529f2 3853 double x = scm_c_uniform01 (SCM_RSTATE (SCM_CDR (scm_var_random_state)));
3e8370c3 3854
259529f2
MD
3855*** Function: scm_rstate *scm_c_default_rstate (void)
3856This is a convenience function which returns the value of
3857scm_var_random_state. An error message is generated if this value
3858isn't a random state.
3859
3860*** Function: scm_rstate *scm_c_make_rstate (char *SEED, int LENGTH)
3861Make a new random state from the string SEED of length LENGTH.
3862
3863It is generally not a good idea to use multiple random states in a
3864program. While subsequent random numbers generated from one random
3865state are guaranteed to be reasonably independent, there is no such
3866guarantee for numbers generated from different random states.
3867
3868*** Macro: unsigned long scm_c_uniform32 (scm_rstate *STATE)
3869Return 32 random bits.
3870
3871*** Function: double scm_c_uniform01 (scm_rstate *STATE)
3e8370c3
MD
3872Return a sample from the uniform(0,1) distribution.
3873
259529f2 3874*** Function: double scm_c_normal01 (scm_rstate *STATE)
3e8370c3
MD
3875Return a sample from the normal(0,1) distribution.
3876
259529f2 3877*** Function: double scm_c_exp1 (scm_rstate *STATE)
3e8370c3
MD
3878Return a sample from the exp(1) distribution.
3879
259529f2
MD
3880*** Function: unsigned long scm_c_random (scm_rstate *STATE, unsigned long M)
3881Return a sample from the discrete uniform(0,M) distribution.
3882
3883*** Function: SCM scm_c_random_bignum (scm_rstate *STATE, SCM M)
3e8370c3 3884Return a sample from the discrete uniform(0,M) distribution.
259529f2 3885M must be a bignum object. The returned value may be an INUM.
3e8370c3 3886
9e97c52d 3887
f3227c7a 3888\f
d23bbf3e 3889Changes in Guile 1.3 (released Monday, October 19, 1998):
c484bf7f
JB
3890
3891* Changes to the distribution
3892
e2d6569c
JB
3893** We renamed the SCHEME_LOAD_PATH environment variable to GUILE_LOAD_PATH.
3894To avoid conflicts, programs should name environment variables after
3895themselves, except when there's a common practice establishing some
3896other convention.
3897
3898For now, Guile supports both GUILE_LOAD_PATH and SCHEME_LOAD_PATH,
3899giving the former precedence, and printing a warning message if the
3900latter is set. Guile 1.4 will not recognize SCHEME_LOAD_PATH at all.
3901
3902** The header files related to multi-byte characters have been removed.
3903They were: libguile/extchrs.h and libguile/mbstrings.h. Any C code
3904which referred to these explicitly will probably need to be rewritten,
3905since the support for the variant string types has been removed; see
3906below.
3907
3908** The header files append.h and sequences.h have been removed. These
3909files implemented non-R4RS operations which would encourage
3910non-portable programming style and less easy-to-read code.
3a97e020 3911
c484bf7f
JB
3912* Changes to the stand-alone interpreter
3913
2e368582 3914** New procedures have been added to implement a "batch mode":
ec4ab4fd 3915
2e368582 3916*** Function: batch-mode?
ec4ab4fd
GH
3917
3918 Returns a boolean indicating whether the interpreter is in batch
3919 mode.
3920
2e368582 3921*** Function: set-batch-mode?! ARG
ec4ab4fd
GH
3922
3923 If ARG is true, switches the interpreter to batch mode. The `#f'
3924 case has not been implemented.
3925
2e368582
JB
3926** Guile now provides full command-line editing, when run interactively.
3927To use this feature, you must have the readline library installed.
3928The Guile build process will notice it, and automatically include
3929support for it.
3930
3931The readline library is available via anonymous FTP from any GNU
3932mirror site; the canonical location is "ftp://prep.ai.mit.edu/pub/gnu".
3933
a5d6d578
MD
3934** the-last-stack is now a fluid.
3935
c484bf7f
JB
3936* Changes to the procedure for linking libguile with your programs
3937
71f20534 3938** You can now use the `guile-config' utility to build programs that use Guile.
2e368582 3939
2adfe1c0 3940Guile now includes a command-line utility called `guile-config', which
71f20534
JB
3941can provide information about how to compile and link programs that
3942use Guile.
3943
3944*** `guile-config compile' prints any C compiler flags needed to use Guile.
3945You should include this command's output on the command line you use
3946to compile C or C++ code that #includes the Guile header files. It's
3947usually just a `-I' flag to help the compiler find the Guile headers.
3948
3949
3950*** `guile-config link' prints any linker flags necessary to link with Guile.
8aa5c148 3951
71f20534 3952This command writes to its standard output a list of flags which you
8aa5c148
JB
3953must pass to the linker to link your code against the Guile library.
3954The flags include '-lguile' itself, any other libraries the Guile
3955library depends upon, and any `-L' flags needed to help the linker
3956find those libraries.
2e368582
JB
3957
3958For example, here is a Makefile rule that builds a program named 'foo'
3959from the object files ${FOO_OBJECTS}, and links them against Guile:
3960
3961 foo: ${FOO_OBJECTS}
2adfe1c0 3962 ${CC} ${CFLAGS} ${FOO_OBJECTS} `guile-config link` -o foo
2e368582 3963
e2d6569c
JB
3964Previous Guile releases recommended that you use autoconf to detect
3965which of a predefined set of libraries were present on your system.
2adfe1c0 3966It is more robust to use `guile-config', since it records exactly which
e2d6569c
JB
3967libraries the installed Guile library requires.
3968
2adfe1c0
JB
3969This was originally called `build-guile', but was renamed to
3970`guile-config' before Guile 1.3 was released, to be consistent with
3971the analogous script for the GTK+ GUI toolkit, which is called
3972`gtk-config'.
3973
2e368582 3974
8aa5c148
JB
3975** Use the GUILE_FLAGS macro in your configure.in file to find Guile.
3976
3977If you are using the GNU autoconf package to configure your program,
3978you can use the GUILE_FLAGS autoconf macro to call `guile-config'
3979(described above) and gather the necessary values for use in your
3980Makefiles.
3981
3982The GUILE_FLAGS macro expands to configure script code which runs the
3983`guile-config' script, to find out where Guile's header files and
3984libraries are installed. It sets two variables, marked for
3985substitution, as by AC_SUBST.
3986
3987 GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
3988 code that uses Guile header files. This is almost always just a
3989 -I flag.
3990
3991 GUILE_LDFLAGS --- flags to pass to the linker to link a
3992 program against Guile. This includes `-lguile' for the Guile
3993 library itself, any libraries that Guile itself requires (like
3994 -lqthreads), and so on. It may also include a -L flag to tell the
3995 compiler where to find the libraries.
3996
3997GUILE_FLAGS is defined in the file guile.m4, in the top-level
3998directory of the Guile distribution. You can copy it into your
3999package's aclocal.m4 file, and then use it in your configure.in file.
4000
4001If you are using the `aclocal' program, distributed with GNU automake,
4002to maintain your aclocal.m4 file, the Guile installation process
4003installs guile.m4 where aclocal will find it. All you need to do is
4004use GUILE_FLAGS in your configure.in file, and then run `aclocal';
4005this will copy the definition of GUILE_FLAGS into your aclocal.m4
4006file.
4007
4008
c484bf7f 4009* Changes to Scheme functions and syntax
7ad3c1e7 4010
02755d59 4011** Multi-byte strings have been removed, as have multi-byte and wide
e2d6569c
JB
4012ports. We felt that these were the wrong approach to
4013internationalization support.
02755d59 4014
2e368582
JB
4015** New function: readline [PROMPT]
4016Read a line from the terminal, and allow the user to edit it,
4017prompting with PROMPT. READLINE provides a large set of Emacs-like
4018editing commands, lets the user recall previously typed lines, and
4019works on almost every kind of terminal, including dumb terminals.
4020
4021READLINE assumes that the cursor is at the beginning of the line when
4022it is invoked. Thus, you can't print a prompt yourself, and then call
4023READLINE; you need to package up your prompt as a string, pass it to
4024the function, and let READLINE print the prompt itself. This is
4025because READLINE needs to know the prompt's screen width.
4026
8cd57bd0
JB
4027For Guile to provide this function, you must have the readline
4028library, version 2.1 or later, installed on your system. Readline is
4029available via anonymous FTP from prep.ai.mit.edu in pub/gnu, or from
4030any GNU mirror site.
2e368582
JB
4031
4032See also ADD-HISTORY function.
4033
4034** New function: add-history STRING
4035Add STRING as the most recent line in the history used by the READLINE
4036command. READLINE does not add lines to the history itself; you must
4037call ADD-HISTORY to make previous input available to the user.
4038
8cd57bd0
JB
4039** The behavior of the read-line function has changed.
4040
4041This function now uses standard C library functions to read the line,
4042for speed. This means that it doesn not respect the value of
4043scm-line-incrementors; it assumes that lines are delimited with
4044#\newline.
4045
4046(Note that this is read-line, the function that reads a line of text
4047from a port, not readline, the function that reads a line from a
4048terminal, providing full editing capabilities.)
4049
1a0106ef
JB
4050** New module (ice-9 getopt-gnu-style): Parse command-line arguments.
4051
4052This module provides some simple argument parsing. It exports one
4053function:
4054
4055Function: getopt-gnu-style ARG-LS
4056 Parse a list of program arguments into an alist of option
4057 descriptions.
4058
4059 Each item in the list of program arguments is examined to see if
4060 it meets the syntax of a GNU long-named option. An argument like
4061 `--MUMBLE' produces an element of the form (MUMBLE . #t) in the
4062 returned alist, where MUMBLE is a keyword object with the same
4063 name as the argument. An argument like `--MUMBLE=FROB' produces
4064 an element of the form (MUMBLE . FROB), where FROB is a string.
4065
4066 As a special case, the returned alist also contains a pair whose
4067 car is the symbol `rest'. The cdr of this pair is a list
4068 containing all the items in the argument list that are not options
4069 of the form mentioned above.
4070
4071 The argument `--' is treated specially: all items in the argument
4072 list appearing after such an argument are not examined, and are
4073 returned in the special `rest' list.
4074
4075 This function does not parse normal single-character switches.
4076 You will need to parse them out of the `rest' list yourself.
4077
8cd57bd0
JB
4078** The read syntax for byte vectors and short vectors has changed.
4079
4080Instead of #bytes(...), write #y(...).
4081
4082Instead of #short(...), write #h(...).
4083
4084This may seem nutty, but, like the other uniform vectors, byte vectors
4085and short vectors want to have the same print and read syntax (and,
4086more basic, want to have read syntax!). Changing the read syntax to
4087use multiple characters after the hash sign breaks with the
4088conventions used in R5RS and the conventions used for the other
4089uniform vectors. It also introduces complexity in the current reader,
4090both on the C and Scheme levels. (The Right solution is probably to
4091change the syntax and prototypes for uniform vectors entirely.)
4092
4093
4094** The new module (ice-9 session) provides useful interactive functions.
4095
4096*** New procedure: (apropos REGEXP OPTION ...)
4097
4098Display a list of top-level variables whose names match REGEXP, and
4099the modules they are imported from. Each OPTION should be one of the
4100following symbols:
4101
4102 value --- Show the value of each matching variable.
4103 shadow --- Show bindings shadowed by subsequently imported modules.
4104 full --- Same as both `shadow' and `value'.
4105
4106For example:
4107
4108 guile> (apropos "trace" 'full)
4109 debug: trace #<procedure trace args>
4110 debug: untrace #<procedure untrace args>
4111 the-scm-module: display-backtrace #<compiled-closure #<primitive-procedure gsubr-apply>>
4112 the-scm-module: before-backtrace-hook ()
4113 the-scm-module: backtrace #<primitive-procedure backtrace>
4114 the-scm-module: after-backtrace-hook ()
4115 the-scm-module: has-shown-backtrace-hint? #f
6c0201ad 4116 guile>
8cd57bd0
JB
4117
4118** There are new functions and syntax for working with macros.
4119
4120Guile implements macros as a special object type. Any variable whose
4121top-level binding is a macro object acts as a macro. The macro object
4122specifies how the expression should be transformed before evaluation.
4123
4124*** Macro objects now print in a reasonable way, resembling procedures.
4125
4126*** New function: (macro? OBJ)
4127True iff OBJ is a macro object.
4128
4129*** New function: (primitive-macro? OBJ)
4130Like (macro? OBJ), but true only if OBJ is one of the Guile primitive
4131macro transformers, implemented in eval.c rather than Scheme code.
4132
dbdd0c16
JB
4133Why do we have this function?
4134- For symmetry with procedure? and primitive-procedure?,
4135- to allow custom print procedures to tell whether a macro is
4136 primitive, and display it differently, and
4137- to allow compilers and user-written evaluators to distinguish
4138 builtin special forms from user-defined ones, which could be
4139 compiled.
4140
8cd57bd0
JB
4141*** New function: (macro-type OBJ)
4142Return a value indicating what kind of macro OBJ is. Possible return
4143values are:
4144
4145 The symbol `syntax' --- a macro created by procedure->syntax.
4146 The symbol `macro' --- a macro created by procedure->macro.
4147 The symbol `macro!' --- a macro created by procedure->memoizing-macro.
6c0201ad 4148 The boolean #f --- if OBJ is not a macro object.
8cd57bd0
JB
4149
4150*** New function: (macro-name MACRO)
4151Return the name of the macro object MACRO's procedure, as returned by
4152procedure-name.
4153
4154*** New function: (macro-transformer MACRO)
4155Return the transformer procedure for MACRO.
4156
4157*** New syntax: (use-syntax MODULE ... TRANSFORMER)
4158
4159Specify a new macro expander to use in the current module. Each
4160MODULE is a module name, with the same meaning as in the `use-modules'
4161form; each named module's exported bindings are added to the current
4162top-level environment. TRANSFORMER is an expression evaluated in the
4163resulting environment which must yield a procedure to use as the
4164module's eval transformer: every expression evaluated in this module
4165is passed to this function, and the result passed to the Guile
6c0201ad 4166interpreter.
8cd57bd0
JB
4167
4168*** macro-eval! is removed. Use local-eval instead.
29521173 4169
8d9dcb3c
MV
4170** Some magic has been added to the printer to better handle user
4171written printing routines (like record printers, closure printers).
4172
4173The problem is that these user written routines must have access to
7fbd77df 4174the current `print-state' to be able to handle fancy things like
8d9dcb3c
MV
4175detection of circular references. These print-states have to be
4176passed to the builtin printing routines (display, write, etc) to
4177properly continue the print chain.
4178
4179We didn't want to change all existing print code so that it
8cd57bd0 4180explicitly passes thru a print state in addition to a port. Instead,
8d9dcb3c
MV
4181we extented the possible values that the builtin printing routines
4182accept as a `port'. In addition to a normal port, they now also take
4183a pair of a normal port and a print-state. Printing will go to the
4184port and the print-state will be used to control the detection of
4185circular references, etc. If the builtin function does not care for a
4186print-state, it is simply ignored.
4187
4188User written callbacks are now called with such a pair as their
4189`port', but because every function now accepts this pair as a PORT
4190argument, you don't have to worry about that. In fact, it is probably
4191safest to not check for these pairs.
4192
4193However, it is sometimes necessary to continue a print chain on a
4194different port, for example to get a intermediate string
4195representation of the printed value, mangle that string somehow, and
4196then to finally print the mangled string. Use the new function
4197
4198 inherit-print-state OLD-PORT NEW-PORT
4199
4200for this. It constructs a new `port' that prints to NEW-PORT but
4201inherits the print-state of OLD-PORT.
4202
ef1ea498
MD
4203** struct-vtable-offset renamed to vtable-offset-user
4204
4205** New constants: vtable-index-layout, vtable-index-vtable, vtable-index-printer
4206
e478dffa
MD
4207** There is now a third optional argument to make-vtable-vtable
4208 (and fourth to make-struct) when constructing new types (vtables).
4209 This argument initializes field vtable-index-printer of the vtable.
ef1ea498 4210
4851dc57
MV
4211** The detection of circular references has been extended to structs.
4212That is, a structure that -- in the process of being printed -- prints
4213itself does not lead to infinite recursion.
4214
4215** There is now some basic support for fluids. Please read
4216"libguile/fluid.h" to find out more. It is accessible from Scheme with
4217the following functions and macros:
4218
9c3fb66f
MV
4219Function: make-fluid
4220
4221 Create a new fluid object. Fluids are not special variables or
4222 some other extension to the semantics of Scheme, but rather
4223 ordinary Scheme objects. You can store them into variables (that
4224 are still lexically scoped, of course) or into any other place you
4225 like. Every fluid has a initial value of `#f'.
04c76b58 4226
9c3fb66f 4227Function: fluid? OBJ
04c76b58 4228
9c3fb66f 4229 Test whether OBJ is a fluid.
04c76b58 4230
9c3fb66f
MV
4231Function: fluid-ref FLUID
4232Function: fluid-set! FLUID VAL
04c76b58
MV
4233
4234 Access/modify the fluid FLUID. Modifications are only visible
4235 within the current dynamic root (that includes threads).
4236
9c3fb66f
MV
4237Function: with-fluids* FLUIDS VALUES THUNK
4238
4239 FLUIDS is a list of fluids and VALUES a corresponding list of
4240 values for these fluids. Before THUNK gets called the values are
6c0201ad 4241 installed in the fluids and the old values of the fluids are
9c3fb66f
MV
4242 saved in the VALUES list. When the flow of control leaves THUNK
4243 or reenters it, the values get swapped again. You might think of
4244 this as a `safe-fluid-excursion'. Note that the VALUES list is
4245 modified by `with-fluids*'.
4246
4247Macro: with-fluids ((FLUID VALUE) ...) FORM ...
4248
4249 The same as `with-fluids*' but with a different syntax. It looks
4250 just like `let', but both FLUID and VALUE are evaluated. Remember,
4251 fluids are not special variables but ordinary objects. FLUID
4252 should evaluate to a fluid.
04c76b58 4253
e2d6569c 4254** Changes to system call interfaces:
64d01d13 4255
e2d6569c 4256*** close-port, close-input-port and close-output-port now return a
64d01d13
GH
4257boolean instead of an `unspecified' object. #t means that the port
4258was successfully closed, while #f means it was already closed. It is
4259also now possible for these procedures to raise an exception if an
4260error occurs (some errors from write can be delayed until close.)
4261
e2d6569c 4262*** the first argument to chmod, fcntl, ftell and fseek can now be a
6afcd3b2
GH
4263file descriptor.
4264
e2d6569c 4265*** the third argument to fcntl is now optional.
6afcd3b2 4266
e2d6569c 4267*** the first argument to chown can now be a file descriptor or a port.
6afcd3b2 4268
e2d6569c 4269*** the argument to stat can now be a port.
6afcd3b2 4270
e2d6569c 4271*** The following new procedures have been added (most use scsh
64d01d13
GH
4272interfaces):
4273
e2d6569c 4274*** procedure: close PORT/FD
ec4ab4fd
GH
4275 Similar to close-port (*note close-port: Closing Ports.), but also
4276 works on file descriptors. A side effect of closing a file
4277 descriptor is that any ports using that file descriptor are moved
4278 to a different file descriptor and have their revealed counts set
4279 to zero.
4280
e2d6569c 4281*** procedure: port->fdes PORT
ec4ab4fd
GH
4282 Returns the integer file descriptor underlying PORT. As a side
4283 effect the revealed count of PORT is incremented.
4284
e2d6569c 4285*** procedure: fdes->ports FDES
ec4ab4fd
GH
4286 Returns a list of existing ports which have FDES as an underlying
4287 file descriptor, without changing their revealed counts.
4288
e2d6569c 4289*** procedure: fdes->inport FDES
ec4ab4fd
GH
4290 Returns an existing input port which has FDES as its underlying
4291 file descriptor, if one exists, and increments its revealed count.
4292 Otherwise, returns a new input port with a revealed count of 1.
4293
e2d6569c 4294*** procedure: fdes->outport FDES
ec4ab4fd
GH
4295 Returns an existing output port which has FDES as its underlying
4296 file descriptor, if one exists, and increments its revealed count.
4297 Otherwise, returns a new output port with a revealed count of 1.
4298
4299 The next group of procedures perform a `dup2' system call, if NEWFD
4300(an integer) is supplied, otherwise a `dup'. The file descriptor to be
4301duplicated can be supplied as an integer or contained in a port. The
64d01d13
GH
4302type of value returned varies depending on which procedure is used.
4303
ec4ab4fd
GH
4304 All procedures also have the side effect when performing `dup2' that
4305any ports using NEWFD are moved to a different file descriptor and have
64d01d13
GH
4306their revealed counts set to zero.
4307
e2d6569c 4308*** procedure: dup->fdes PORT/FD [NEWFD]
ec4ab4fd 4309 Returns an integer file descriptor.
64d01d13 4310
e2d6569c 4311*** procedure: dup->inport PORT/FD [NEWFD]
ec4ab4fd 4312 Returns a new input port using the new file descriptor.
64d01d13 4313
e2d6569c 4314*** procedure: dup->outport PORT/FD [NEWFD]
ec4ab4fd 4315 Returns a new output port using the new file descriptor.
64d01d13 4316
e2d6569c 4317*** procedure: dup PORT/FD [NEWFD]
ec4ab4fd
GH
4318 Returns a new port if PORT/FD is a port, with the same mode as the
4319 supplied port, otherwise returns an integer file descriptor.
64d01d13 4320
e2d6569c 4321*** procedure: dup->port PORT/FD MODE [NEWFD]
ec4ab4fd
GH
4322 Returns a new port using the new file descriptor. MODE supplies a
4323 mode string for the port (*note open-file: File Ports.).
64d01d13 4324
e2d6569c 4325*** procedure: setenv NAME VALUE
ec4ab4fd
GH
4326 Modifies the environment of the current process, which is also the
4327 default environment inherited by child processes.
64d01d13 4328
ec4ab4fd
GH
4329 If VALUE is `#f', then NAME is removed from the environment.
4330 Otherwise, the string NAME=VALUE is added to the environment,
4331 replacing any existing string with name matching NAME.
64d01d13 4332
ec4ab4fd 4333 The return value is unspecified.
956055a9 4334
e2d6569c 4335*** procedure: truncate-file OBJ SIZE
6afcd3b2
GH
4336 Truncates the file referred to by OBJ to at most SIZE bytes. OBJ
4337 can be a string containing a file name or an integer file
4338 descriptor or port open for output on the file. The underlying
4339 system calls are `truncate' and `ftruncate'.
4340
4341 The return value is unspecified.
4342
e2d6569c 4343*** procedure: setvbuf PORT MODE [SIZE]
7a6f1ffa
GH
4344 Set the buffering mode for PORT. MODE can be:
4345 `_IONBF'
4346 non-buffered
4347
4348 `_IOLBF'
4349 line buffered
4350
4351 `_IOFBF'
4352 block buffered, using a newly allocated buffer of SIZE bytes.
4353 However if SIZE is zero or unspecified, the port will be made
4354 non-buffered.
4355
4356 This procedure should not be used after I/O has been performed with
4357 the port.
4358
4359 Ports are usually block buffered by default, with a default buffer
4360 size. Procedures e.g., *Note open-file: File Ports, which accept a
4361 mode string allow `0' to be added to request an unbuffered port.
4362
e2d6569c 4363*** procedure: fsync PORT/FD
6afcd3b2
GH
4364 Copies any unwritten data for the specified output file descriptor
4365 to disk. If PORT/FD is a port, its buffer is flushed before the
4366 underlying file descriptor is fsync'd. The return value is
4367 unspecified.
4368
e2d6569c 4369*** procedure: open-fdes PATH FLAGS [MODES]
6afcd3b2
GH
4370 Similar to `open' but returns a file descriptor instead of a port.
4371
e2d6569c 4372*** procedure: execle PATH ENV [ARG] ...
6afcd3b2
GH
4373 Similar to `execl', but the environment of the new process is
4374 specified by ENV, which must be a list of strings as returned by
4375 the `environ' procedure.
4376
4377 This procedure is currently implemented using the `execve' system
4378 call, but we call it `execle' because of its Scheme calling
4379 interface.
4380
e2d6569c 4381*** procedure: strerror ERRNO
ec4ab4fd
GH
4382 Returns the Unix error message corresponding to ERRNO, an integer.
4383
e2d6569c 4384*** procedure: primitive-exit [STATUS]
6afcd3b2
GH
4385 Terminate the current process without unwinding the Scheme stack.
4386 This is would typically be useful after a fork. The exit status
4387 is STATUS if supplied, otherwise zero.
4388
e2d6569c 4389*** procedure: times
6afcd3b2
GH
4390 Returns an object with information about real and processor time.
4391 The following procedures accept such an object as an argument and
4392 return a selected component:
4393
4394 `tms:clock'
4395 The current real time, expressed as time units relative to an
4396 arbitrary base.
4397
4398 `tms:utime'
4399 The CPU time units used by the calling process.
4400
4401 `tms:stime'
4402 The CPU time units used by the system on behalf of the
4403 calling process.
4404
4405 `tms:cutime'
4406 The CPU time units used by terminated child processes of the
4407 calling process, whose status has been collected (e.g., using
4408 `waitpid').
4409
4410 `tms:cstime'
4411 Similarly, the CPU times units used by the system on behalf of
4412 terminated child processes.
7ad3c1e7 4413
e2d6569c
JB
4414** Removed: list-length
4415** Removed: list-append, list-append!
4416** Removed: list-reverse, list-reverse!
4417
4418** array-map renamed to array-map!
4419
4420** serial-array-map renamed to serial-array-map!
4421
660f41fa
MD
4422** catch doesn't take #f as first argument any longer
4423
4424Previously, it was possible to pass #f instead of a key to `catch'.
4425That would cause `catch' to pass a jump buffer object to the procedure
4426passed as second argument. The procedure could then use this jump
4427buffer objekt as an argument to throw.
4428
4429This mechanism has been removed since its utility doesn't motivate the
4430extra complexity it introduces.
4431
332d00f6
JB
4432** The `#/' notation for lists now provokes a warning message from Guile.
4433This syntax will be removed from Guile in the near future.
4434
4435To disable the warning message, set the GUILE_HUSH environment
4436variable to any non-empty value.
4437
8cd57bd0
JB
4438** The newline character now prints as `#\newline', following the
4439normal Scheme notation, not `#\nl'.
4440
c484bf7f
JB
4441* Changes to the gh_ interface
4442
8986901b
JB
4443** The gh_enter function now takes care of loading the Guile startup files.
4444gh_enter works by calling scm_boot_guile; see the remarks below.
4445
5424b4f7
MD
4446** Function: void gh_write (SCM x)
4447
4448Write the printed representation of the scheme object x to the current
4449output port. Corresponds to the scheme level `write'.
4450
3a97e020
MD
4451** gh_list_length renamed to gh_length.
4452
8d6787b6
MG
4453** vector handling routines
4454
4455Several major changes. In particular, gh_vector() now resembles
4456(vector ...) (with a caveat -- see manual), and gh_make_vector() now
956328d2
MG
4457exists and behaves like (make-vector ...). gh_vset() and gh_vref()
4458have been renamed gh_vector_set_x() and gh_vector_ref(). Some missing
8d6787b6
MG
4459vector-related gh_ functions have been implemented.
4460
7fee59bd
MG
4461** pair and list routines
4462
4463Implemented several of the R4RS pair and list functions that were
4464missing.
4465
171422a9
MD
4466** gh_scm2doubles, gh_doubles2scm, gh_doubles2dvect
4467
4468New function. Converts double arrays back and forth between Scheme
4469and C.
4470
c484bf7f
JB
4471* Changes to the scm_ interface
4472
8986901b
JB
4473** The function scm_boot_guile now takes care of loading the startup files.
4474
4475Guile's primary initialization function, scm_boot_guile, now takes
4476care of loading `boot-9.scm', in the `ice-9' module, to initialize
4477Guile, define the module system, and put together some standard
4478bindings. It also loads `init.scm', which is intended to hold
4479site-specific initialization code.
4480
4481Since Guile cannot operate properly until boot-9.scm is loaded, there
4482is no reason to separate loading boot-9.scm from Guile's other
4483initialization processes.
4484
4485This job used to be done by scm_compile_shell_switches, which didn't
4486make much sense; in particular, it meant that people using Guile for
4487non-shell-like applications had to jump through hoops to get Guile
4488initialized properly.
4489
4490** The function scm_compile_shell_switches no longer loads the startup files.
4491Now, Guile always loads the startup files, whenever it is initialized;
4492see the notes above for scm_boot_guile and scm_load_startup_files.
4493
4494** Function: scm_load_startup_files
4495This new function takes care of loading Guile's initialization file
4496(`boot-9.scm'), and the site initialization file, `init.scm'. Since
4497this is always called by the Guile initialization process, it's
4498probably not too useful to call this yourself, but it's there anyway.
4499
87148d9e
JB
4500** The semantics of smob marking have changed slightly.
4501
4502The smob marking function (the `mark' member of the scm_smobfuns
4503structure) is no longer responsible for setting the mark bit on the
4504smob. The generic smob handling code in the garbage collector will
4505set this bit. The mark function need only ensure that any other
4506objects the smob refers to get marked.
4507
4508Note that this change means that the smob's GC8MARK bit is typically
4509already set upon entry to the mark function. Thus, marking functions
4510which look like this:
4511
4512 {
4513 if (SCM_GC8MARKP (ptr))
4514 return SCM_BOOL_F;
4515 SCM_SETGC8MARK (ptr);
4516 ... mark objects to which the smob refers ...
4517 }
4518
4519are now incorrect, since they will return early, and fail to mark any
4520other objects the smob refers to. Some code in the Guile library used
4521to work this way.
4522
1cf84ea5
JB
4523** The semantics of the I/O port functions in scm_ptobfuns have changed.
4524
4525If you have implemented your own I/O port type, by writing the
4526functions required by the scm_ptobfuns and then calling scm_newptob,
4527you will need to change your functions slightly.
4528
4529The functions in a scm_ptobfuns structure now expect the port itself
4530as their argument; they used to expect the `stream' member of the
4531port's scm_port_table structure. This allows functions in an
4532scm_ptobfuns structure to easily access the port's cell (and any flags
4533it its CAR), and the port's scm_port_table structure.
4534
4535Guile now passes the I/O port itself as the `port' argument in the
4536following scm_ptobfuns functions:
4537
4538 int (*free) (SCM port);
4539 int (*fputc) (int, SCM port);
4540 int (*fputs) (char *, SCM port);
4541 scm_sizet (*fwrite) SCM_P ((char *ptr,
4542 scm_sizet size,
4543 scm_sizet nitems,
4544 SCM port));
4545 int (*fflush) (SCM port);
4546 int (*fgetc) (SCM port);
4547 int (*fclose) (SCM port);
4548
4549The interfaces to the `mark', `print', `equalp', and `fgets' methods
4550are unchanged.
4551
4552If you have existing code which defines its own port types, it is easy
4553to convert your code to the new interface; simply apply SCM_STREAM to
4554the port argument to yield the value you code used to expect.
4555
4556Note that since both the port and the stream have the same type in the
4557C code --- they are both SCM values --- the C compiler will not remind
4558you if you forget to update your scm_ptobfuns functions.
4559
4560
933a7411
MD
4561** Function: int scm_internal_select (int fds,
4562 SELECT_TYPE *rfds,
4563 SELECT_TYPE *wfds,
4564 SELECT_TYPE *efds,
4565 struct timeval *timeout);
4566
4567This is a replacement for the `select' function provided by the OS.
4568It enables I/O blocking and sleeping to happen for one cooperative
4569thread without blocking other threads. It also avoids busy-loops in
4570these situations. It is intended that all I/O blocking and sleeping
4571will finally go through this function. Currently, this function is
4572only available on systems providing `gettimeofday' and `select'.
4573
5424b4f7
MD
4574** Function: SCM scm_internal_stack_catch (SCM tag,
4575 scm_catch_body_t body,
4576 void *body_data,
4577 scm_catch_handler_t handler,
4578 void *handler_data)
4579
4580A new sibling to the other two C level `catch' functions
4581scm_internal_catch and scm_internal_lazy_catch. Use it if you want
4582the stack to be saved automatically into the variable `the-last-stack'
4583(scm_the_last_stack_var) on error. This is necessary if you want to
4584use advanced error reporting, such as calling scm_display_error and
4585scm_display_backtrace. (They both take a stack object as argument.)
4586
df366c26
MD
4587** Function: SCM scm_spawn_thread (scm_catch_body_t body,
4588 void *body_data,
4589 scm_catch_handler_t handler,
4590 void *handler_data)
4591
4592Spawns a new thread. It does a job similar to
4593scm_call_with_new_thread but takes arguments more suitable when
4594spawning threads from application C code.
4595
88482b31
MD
4596** The hook scm_error_callback has been removed. It was originally
4597intended as a way for the user to install his own error handler. But
4598that method works badly since it intervenes between throw and catch,
4599thereby changing the semantics of expressions like (catch #t ...).
4600The correct way to do it is to use one of the C level catch functions
4601in throw.c: scm_internal_catch/lazy_catch/stack_catch.
4602
3a97e020
MD
4603** Removed functions:
4604
4605scm_obj_length, scm_list_length, scm_list_append, scm_list_append_x,
4606scm_list_reverse, scm_list_reverse_x
4607
4608** New macros: SCM_LISTn where n is one of the integers 0-9.
4609
4610These can be used for pretty list creation from C. The idea is taken
4611from Erick Gallesio's STk.
4612
298aa6e3
MD
4613** scm_array_map renamed to scm_array_map_x
4614
527da704
MD
4615** mbstrings are now removed
4616
4617This means that the type codes scm_tc7_mb_string and
4618scm_tc7_mb_substring has been removed.
4619
8cd57bd0
JB
4620** scm_gen_putc, scm_gen_puts, scm_gen_write, and scm_gen_getc have changed.
4621
4622Since we no longer support multi-byte strings, these I/O functions
4623have been simplified, and renamed. Here are their old names, and
4624their new names and arguments:
4625
4626scm_gen_putc -> void scm_putc (int c, SCM port);
4627scm_gen_puts -> void scm_puts (char *s, SCM port);
4628scm_gen_write -> void scm_lfwrite (char *ptr, scm_sizet size, SCM port);
4629scm_gen_getc -> void scm_getc (SCM port);
4630
4631
527da704
MD
4632** The macros SCM_TYP7D and SCM_TYP7SD has been removed.
4633
4634** The macro SCM_TYP7S has taken the role of the old SCM_TYP7D
4635
4636SCM_TYP7S now masks away the bit which distinguishes substrings from
4637strings.
4638
660f41fa
MD
4639** scm_catch_body_t: Backward incompatible change!
4640
4641Body functions to scm_internal_catch and friends do not any longer
4642take a second argument. This is because it is no longer possible to
4643pass a #f arg to catch.
4644
a8e05009
JB
4645** Calls to scm_protect_object and scm_unprotect now nest properly.
4646
4647The function scm_protect_object protects its argument from being freed
4648by the garbage collector. scm_unprotect_object removes that
4649protection.
4650
4651These functions now nest properly. That is, for every object O, there
4652is a counter which scm_protect_object(O) increments and
4653scm_unprotect_object(O) decrements, if the counter is greater than
4654zero. Every object's counter is zero when it is first created. If an
4655object's counter is greater than zero, the garbage collector will not
4656reclaim its storage.
4657
4658This allows you to use scm_protect_object in your code without
4659worrying that some other function you call will call
4660scm_unprotect_object, and allow it to be freed. Assuming that the
4661functions you call are well-behaved, and unprotect only those objects
4662they protect, you can follow the same rule and have confidence that
4663objects will be freed only at appropriate times.
4664
c484bf7f
JB
4665\f
4666Changes in Guile 1.2 (released Tuesday, June 24 1997):
cf78e9e8 4667
737c9113
JB
4668* Changes to the distribution
4669
832b09ed
JB
4670** Nightly snapshots are now available from ftp.red-bean.com.
4671The old server, ftp.cyclic.com, has been relinquished to its rightful
4672owner.
4673
4674Nightly snapshots of the Guile development sources are now available via
4675anonymous FTP from ftp.red-bean.com, as /pub/guile/guile-snap.tar.gz.
4676
4677Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-snap.tar.gz
4678For getit, that's: ftp.red-bean.com:/pub/guile/guile-snap.tar.gz
4679
0fcab5ed
JB
4680** To run Guile without installing it, the procedure has changed a bit.
4681
4682If you used a separate build directory to compile Guile, you'll need
4683to include the build directory in SCHEME_LOAD_PATH, as well as the
4684source directory. See the `INSTALL' file for examples.
4685
737c9113
JB
4686* Changes to the procedure for linking libguile with your programs
4687
94982a4e
JB
4688** The standard Guile load path for Scheme code now includes
4689$(datadir)/guile (usually /usr/local/share/guile). This means that
4690you can install your own Scheme files there, and Guile will find them.
4691(Previous versions of Guile only checked a directory whose name
4692contained the Guile version number, so you had to re-install or move
4693your Scheme sources each time you installed a fresh version of Guile.)
4694
4695The load path also includes $(datadir)/guile/site; we recommend
4696putting individual Scheme files there. If you want to install a
4697package with multiple source files, create a directory for them under
4698$(datadir)/guile.
4699
4700** Guile 1.2 will now use the Rx regular expression library, if it is
4701installed on your system. When you are linking libguile into your own
4702programs, this means you will have to link against -lguile, -lqt (if
4703you configured Guile with thread support), and -lrx.
27590f82
JB
4704
4705If you are using autoconf to generate configuration scripts for your
4706application, the following lines should suffice to add the appropriate
4707libraries to your link command:
4708
4709### Find Rx, quickthreads and libguile.
4710AC_CHECK_LIB(rx, main)
4711AC_CHECK_LIB(qt, main)
4712AC_CHECK_LIB(guile, scm_shell)
4713
94982a4e
JB
4714The Guile 1.2 distribution does not contain sources for the Rx
4715library, as Guile 1.0 did. If you want to use Rx, you'll need to
4716retrieve it from a GNU FTP site and install it separately.
4717
b83b8bee
JB
4718* Changes to Scheme functions and syntax
4719
e035e7e6
MV
4720** The dynamic linking features of Guile are now enabled by default.
4721You can disable them by giving the `--disable-dynamic-linking' option
4722to configure.
4723
e035e7e6
MV
4724 (dynamic-link FILENAME)
4725
4726 Find the object file denoted by FILENAME (a string) and link it
4727 into the running Guile application. When everything works out,
4728 return a Scheme object suitable for representing the linked object
4729 file. Otherwise an error is thrown. How object files are
4730 searched is system dependent.
4731
4732 (dynamic-object? VAL)
4733
4734 Determine whether VAL represents a dynamically linked object file.
4735
4736 (dynamic-unlink DYNOBJ)
4737
4738 Unlink the indicated object file from the application. DYNOBJ
4739 should be one of the values returned by `dynamic-link'.
4740
4741 (dynamic-func FUNCTION DYNOBJ)
4742
4743 Search the C function indicated by FUNCTION (a string or symbol)
4744 in DYNOBJ and return some Scheme object that can later be used
4745 with `dynamic-call' to actually call this function. Right now,
4746 these Scheme objects are formed by casting the address of the
4747 function to `long' and converting this number to its Scheme
4748 representation.
4749
4750 (dynamic-call FUNCTION DYNOBJ)
4751
4752 Call the C function indicated by FUNCTION and DYNOBJ. The
4753 function is passed no arguments and its return value is ignored.
4754 When FUNCTION is something returned by `dynamic-func', call that
4755 function and ignore DYNOBJ. When FUNCTION is a string (or symbol,
4756 etc.), look it up in DYNOBJ; this is equivalent to
4757
4758 (dynamic-call (dynamic-func FUNCTION DYNOBJ) #f)
4759
4760 Interrupts are deferred while the C function is executing (with
4761 SCM_DEFER_INTS/SCM_ALLOW_INTS).
4762
4763 (dynamic-args-call FUNCTION DYNOBJ ARGS)
4764
4765 Call the C function indicated by FUNCTION and DYNOBJ, but pass it
4766 some arguments and return its return value. The C function is
4767 expected to take two arguments and return an `int', just like
4768 `main':
4769
4770 int c_func (int argc, char **argv);
4771
4772 ARGS must be a list of strings and is converted into an array of
4773 `char *'. The array is passed in ARGV and its size in ARGC. The
4774 return value is converted to a Scheme number and returned from the
4775 call to `dynamic-args-call'.
4776
0fcab5ed
JB
4777When dynamic linking is disabled or not supported on your system,
4778the above functions throw errors, but they are still available.
4779
e035e7e6
MV
4780Here is a small example that works on GNU/Linux:
4781
4782 (define libc-obj (dynamic-link "libc.so"))
4783 (dynamic-args-call 'rand libc-obj '())
4784
4785See the file `libguile/DYNAMIC-LINKING' for additional comments.
4786
27590f82 4787** The #/ syntax for module names is depreciated, and will be removed
6c0201ad 4788in a future version of Guile. Instead of
27590f82
JB
4789
4790 #/foo/bar/baz
4791
4792instead write
4793
4794 (foo bar baz)
4795
4796The latter syntax is more consistent with existing Lisp practice.
4797
5dade857
MV
4798** Guile now does fancier printing of structures. Structures are the
4799underlying implementation for records, which in turn are used to
4800implement modules, so all of these object now print differently and in
4801a more informative way.
4802
161029df
JB
4803The Scheme printer will examine the builtin variable *struct-printer*
4804whenever it needs to print a structure object. When this variable is
4805not `#f' it is deemed to be a procedure and will be applied to the
4806structure object and the output port. When *struct-printer* is `#f'
4807or the procedure return `#f' the structure object will be printed in
4808the boring #<struct 80458270> form.
5dade857
MV
4809
4810This hook is used by some routines in ice-9/boot-9.scm to implement
4811type specific printing routines. Please read the comments there about
4812"printing structs".
4813
4814One of the more specific uses of structs are records. The printing
4815procedure that could be passed to MAKE-RECORD-TYPE is now actually
4816called. It should behave like a *struct-printer* procedure (described
4817above).
4818
b83b8bee
JB
4819** Guile now supports a new R4RS-compliant syntax for keywords. A
4820token of the form #:NAME, where NAME has the same syntax as a Scheme
4821symbol, is the external representation of the keyword named NAME.
4822Keyword objects print using this syntax as well, so values containing
1e5afba0
JB
4823keyword objects can be read back into Guile. When used in an
4824expression, keywords are self-quoting objects.
b83b8bee
JB
4825
4826Guile suports this read syntax, and uses this print syntax, regardless
4827of the current setting of the `keyword' read option. The `keyword'
4828read option only controls whether Guile recognizes the `:NAME' syntax,
4829which is incompatible with R4RS. (R4RS says such token represent
4830symbols.)
737c9113
JB
4831
4832** Guile has regular expression support again. Guile 1.0 included
4833functions for matching regular expressions, based on the Rx library.
4834In Guile 1.1, the Guile/Rx interface was removed to simplify the
4835distribution, and thus Guile had no regular expression support. Guile
94982a4e
JB
48361.2 again supports the most commonly used functions, and supports all
4837of SCSH's regular expression functions.
2409cdfa 4838
94982a4e
JB
4839If your system does not include a POSIX regular expression library,
4840and you have not linked Guile with a third-party regexp library such as
4841Rx, these functions will not be available. You can tell whether your
4842Guile installation includes regular expression support by checking
4843whether the `*features*' list includes the `regex' symbol.
737c9113 4844
94982a4e 4845*** regexp functions
161029df 4846
94982a4e
JB
4847By default, Guile supports POSIX extended regular expressions. That
4848means that the characters `(', `)', `+' and `?' are special, and must
4849be escaped if you wish to match the literal characters.
e1a191a8 4850
94982a4e
JB
4851This regular expression interface was modeled after that implemented
4852by SCSH, the Scheme Shell. It is intended to be upwardly compatible
4853with SCSH regular expressions.
4854
4855**** Function: string-match PATTERN STR [START]
4856 Compile the string PATTERN into a regular expression and compare
4857 it with STR. The optional numeric argument START specifies the
4858 position of STR at which to begin matching.
4859
4860 `string-match' returns a "match structure" which describes what,
4861 if anything, was matched by the regular expression. *Note Match
4862 Structures::. If STR does not match PATTERN at all,
4863 `string-match' returns `#f'.
4864
4865 Each time `string-match' is called, it must compile its PATTERN
4866argument into a regular expression structure. This operation is
4867expensive, which makes `string-match' inefficient if the same regular
4868expression is used several times (for example, in a loop). For better
4869performance, you can compile a regular expression in advance and then
4870match strings against the compiled regexp.
4871
4872**** Function: make-regexp STR [FLAGS]
4873 Compile the regular expression described by STR, and return the
4874 compiled regexp structure. If STR does not describe a legal
4875 regular expression, `make-regexp' throws a
4876 `regular-expression-syntax' error.
4877
4878 FLAGS may be the bitwise-or of one or more of the following:
4879
4880**** Constant: regexp/extended
4881 Use POSIX Extended Regular Expression syntax when interpreting
4882 STR. If not set, POSIX Basic Regular Expression syntax is used.
4883 If the FLAGS argument is omitted, we assume regexp/extended.
4884
4885**** Constant: regexp/icase
4886 Do not differentiate case. Subsequent searches using the
4887 returned regular expression will be case insensitive.
4888
4889**** Constant: regexp/newline
4890 Match-any-character operators don't match a newline.
4891
4892 A non-matching list ([^...]) not containing a newline matches a
4893 newline.
4894
4895 Match-beginning-of-line operator (^) matches the empty string
4896 immediately after a newline, regardless of whether the FLAGS
4897 passed to regexp-exec contain regexp/notbol.
4898
4899 Match-end-of-line operator ($) matches the empty string
4900 immediately before a newline, regardless of whether the FLAGS
4901 passed to regexp-exec contain regexp/noteol.
4902
4903**** Function: regexp-exec REGEXP STR [START [FLAGS]]
4904 Match the compiled regular expression REGEXP against `str'. If
4905 the optional integer START argument is provided, begin matching
4906 from that position in the string. Return a match structure
4907 describing the results of the match, or `#f' if no match could be
4908 found.
4909
4910 FLAGS may be the bitwise-or of one or more of the following:
4911
4912**** Constant: regexp/notbol
4913 The match-beginning-of-line operator always fails to match (but
4914 see the compilation flag regexp/newline above) This flag may be
4915 used when different portions of a string are passed to
4916 regexp-exec and the beginning of the string should not be
4917 interpreted as the beginning of the line.
4918
4919**** Constant: regexp/noteol
4920 The match-end-of-line operator always fails to match (but see the
4921 compilation flag regexp/newline above)
4922
4923**** Function: regexp? OBJ
4924 Return `#t' if OBJ is a compiled regular expression, or `#f'
4925 otherwise.
4926
4927 Regular expressions are commonly used to find patterns in one string
4928and replace them with the contents of another string.
4929
4930**** Function: regexp-substitute PORT MATCH [ITEM...]
4931 Write to the output port PORT selected contents of the match
4932 structure MATCH. Each ITEM specifies what should be written, and
4933 may be one of the following arguments:
4934
4935 * A string. String arguments are written out verbatim.
4936
4937 * An integer. The submatch with that number is written.
4938
4939 * The symbol `pre'. The portion of the matched string preceding
4940 the regexp match is written.
4941
4942 * The symbol `post'. The portion of the matched string
4943 following the regexp match is written.
4944
4945 PORT may be `#f', in which case nothing is written; instead,
4946 `regexp-substitute' constructs a string from the specified ITEMs
4947 and returns that.
4948
4949**** Function: regexp-substitute/global PORT REGEXP TARGET [ITEM...]
4950 Similar to `regexp-substitute', but can be used to perform global
4951 substitutions on STR. Instead of taking a match structure as an
4952 argument, `regexp-substitute/global' takes two string arguments: a
4953 REGEXP string describing a regular expression, and a TARGET string
4954 which should be matched against this regular expression.
4955
4956 Each ITEM behaves as in REGEXP-SUBSTITUTE, with the following
4957 exceptions:
4958
4959 * A function may be supplied. When this function is called, it
4960 will be passed one argument: a match structure for a given
4961 regular expression match. It should return a string to be
4962 written out to PORT.
4963
4964 * The `post' symbol causes `regexp-substitute/global' to recurse
4965 on the unmatched portion of STR. This *must* be supplied in
4966 order to perform global search-and-replace on STR; if it is
4967 not present among the ITEMs, then `regexp-substitute/global'
4968 will return after processing a single match.
4969
4970*** Match Structures
4971
4972 A "match structure" is the object returned by `string-match' and
4973`regexp-exec'. It describes which portion of a string, if any, matched
4974the given regular expression. Match structures include: a reference to
4975the string that was checked for matches; the starting and ending
4976positions of the regexp match; and, if the regexp included any
4977parenthesized subexpressions, the starting and ending positions of each
4978submatch.
4979
4980 In each of the regexp match functions described below, the `match'
4981argument must be a match structure returned by a previous call to
4982`string-match' or `regexp-exec'. Most of these functions return some
4983information about the original target string that was matched against a
4984regular expression; we will call that string TARGET for easy reference.
4985
4986**** Function: regexp-match? OBJ
4987 Return `#t' if OBJ is a match structure returned by a previous
4988 call to `regexp-exec', or `#f' otherwise.
4989
4990**** Function: match:substring MATCH [N]
4991 Return the portion of TARGET matched by subexpression number N.
4992 Submatch 0 (the default) represents the entire regexp match. If
4993 the regular expression as a whole matched, but the subexpression
4994 number N did not match, return `#f'.
4995
4996**** Function: match:start MATCH [N]
4997 Return the starting position of submatch number N.
4998
4999**** Function: match:end MATCH [N]
5000 Return the ending position of submatch number N.
5001
5002**** Function: match:prefix MATCH
5003 Return the unmatched portion of TARGET preceding the regexp match.
5004
5005**** Function: match:suffix MATCH
5006 Return the unmatched portion of TARGET following the regexp match.
5007
5008**** Function: match:count MATCH
5009 Return the number of parenthesized subexpressions from MATCH.
5010 Note that the entire regular expression match itself counts as a
5011 subexpression, and failed submatches are included in the count.
5012
5013**** Function: match:string MATCH
5014 Return the original TARGET string.
5015
5016*** Backslash Escapes
5017
5018 Sometimes you will want a regexp to match characters like `*' or `$'
5019exactly. For example, to check whether a particular string represents
5020a menu entry from an Info node, it would be useful to match it against
5021a regexp like `^* [^:]*::'. However, this won't work; because the
5022asterisk is a metacharacter, it won't match the `*' at the beginning of
5023the string. In this case, we want to make the first asterisk un-magic.
5024
5025 You can do this by preceding the metacharacter with a backslash
5026character `\'. (This is also called "quoting" the metacharacter, and
5027is known as a "backslash escape".) When Guile sees a backslash in a
5028regular expression, it considers the following glyph to be an ordinary
5029character, no matter what special meaning it would ordinarily have.
5030Therefore, we can make the above example work by changing the regexp to
5031`^\* [^:]*::'. The `\*' sequence tells the regular expression engine
5032to match only a single asterisk in the target string.
5033
5034 Since the backslash is itself a metacharacter, you may force a
5035regexp to match a backslash in the target string by preceding the
5036backslash with itself. For example, to find variable references in a
5037TeX program, you might want to find occurrences of the string `\let\'
5038followed by any number of alphabetic characters. The regular expression
5039`\\let\\[A-Za-z]*' would do this: the double backslashes in the regexp
5040each match a single backslash in the target string.
5041
5042**** Function: regexp-quote STR
5043 Quote each special character found in STR with a backslash, and
5044 return the resulting string.
5045
5046 *Very important:* Using backslash escapes in Guile source code (as
5047in Emacs Lisp or C) can be tricky, because the backslash character has
5048special meaning for the Guile reader. For example, if Guile encounters
5049the character sequence `\n' in the middle of a string while processing
5050Scheme code, it replaces those characters with a newline character.
5051Similarly, the character sequence `\t' is replaced by a horizontal tab.
5052Several of these "escape sequences" are processed by the Guile reader
5053before your code is executed. Unrecognized escape sequences are
5054ignored: if the characters `\*' appear in a string, they will be
5055translated to the single character `*'.
5056
5057 This translation is obviously undesirable for regular expressions,
5058since we want to be able to include backslashes in a string in order to
5059escape regexp metacharacters. Therefore, to make sure that a backslash
5060is preserved in a string in your Guile program, you must use *two*
5061consecutive backslashes:
5062
5063 (define Info-menu-entry-pattern (make-regexp "^\\* [^:]*"))
5064
5065 The string in this example is preprocessed by the Guile reader before
5066any code is executed. The resulting argument to `make-regexp' is the
5067string `^\* [^:]*', which is what we really want.
5068
5069 This also means that in order to write a regular expression that
5070matches a single backslash character, the regular expression string in
5071the source code must include *four* backslashes. Each consecutive pair
5072of backslashes gets translated by the Guile reader to a single
5073backslash, and the resulting double-backslash is interpreted by the
5074regexp engine as matching a single backslash character. Hence:
5075
5076 (define tex-variable-pattern (make-regexp "\\\\let\\\\=[A-Za-z]*"))
5077
5078 The reason for the unwieldiness of this syntax is historical. Both
5079regular expression pattern matchers and Unix string processing systems
5080have traditionally used backslashes with the special meanings described
5081above. The POSIX regular expression specification and ANSI C standard
5082both require these semantics. Attempting to abandon either convention
5083would cause other kinds of compatibility problems, possibly more severe
5084ones. Therefore, without extending the Scheme reader to support
5085strings with different quoting conventions (an ungainly and confusing
5086extension when implemented in other languages), we must adhere to this
5087cumbersome escape syntax.
5088
7ad3c1e7
GH
5089* Changes to the gh_ interface
5090
5091* Changes to the scm_ interface
5092
5093* Changes to system call interfaces:
94982a4e 5094
7ad3c1e7 5095** The value returned by `raise' is now unspecified. It throws an exception
e1a191a8
GH
5096if an error occurs.
5097
94982a4e 5098*** A new procedure `sigaction' can be used to install signal handlers
115b09a5
GH
5099
5100(sigaction signum [action] [flags])
5101
5102signum is the signal number, which can be specified using the value
5103of SIGINT etc.
5104
5105If action is omitted, sigaction returns a pair: the CAR is the current
5106signal hander, which will be either an integer with the value SIG_DFL
5107(default action) or SIG_IGN (ignore), or the Scheme procedure which
5108handles the signal, or #f if a non-Scheme procedure handles the
5109signal. The CDR contains the current sigaction flags for the handler.
5110
5111If action is provided, it is installed as the new handler for signum.
5112action can be a Scheme procedure taking one argument, or the value of
5113SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore
5114whatever signal handler was installed before sigaction was first used.
5115Flags can optionally be specified for the new handler (SA_RESTART is
5116always used if the system provides it, so need not be specified.) The
5117return value is a pair with information about the old handler as
5118described above.
5119
5120This interface does not provide access to the "signal blocking"
5121facility. Maybe this is not needed, since the thread support may
5122provide solutions to the problem of consistent access to data
5123structures.
e1a191a8 5124
94982a4e 5125*** A new procedure `flush-all-ports' is equivalent to running
89ea5b7c
GH
5126`force-output' on every port open for output.
5127
94982a4e
JB
5128** Guile now provides information on how it was built, via the new
5129global variable, %guile-build-info. This variable records the values
5130of the standard GNU makefile directory variables as an assocation
5131list, mapping variable names (symbols) onto directory paths (strings).
5132For example, to find out where the Guile link libraries were
5133installed, you can say:
5134
5135guile -c "(display (assq-ref %guile-build-info 'libdir)) (newline)"
5136
5137
5138* Changes to the scm_ interface
5139
5140** The new function scm_handle_by_message_noexit is just like the
5141existing scm_handle_by_message function, except that it doesn't call
5142exit to terminate the process. Instead, it prints a message and just
5143returns #f. This might be a more appropriate catch-all handler for
5144new dynamic roots and threads.
5145
cf78e9e8 5146\f
c484bf7f 5147Changes in Guile 1.1 (released Friday, May 16 1997):
f3b1485f
JB
5148
5149* Changes to the distribution.
5150
5151The Guile 1.0 distribution has been split up into several smaller
5152pieces:
5153guile-core --- the Guile interpreter itself.
5154guile-tcltk --- the interface between the Guile interpreter and
5155 Tcl/Tk; Tcl is an interpreter for a stringy language, and Tk
5156 is a toolkit for building graphical user interfaces.
5157guile-rgx-ctax --- the interface between Guile and the Rx regular
5158 expression matcher, and the translator for the Ctax
5159 programming language. These are packaged together because the
5160 Ctax translator uses Rx to parse Ctax source code.
5161
095936d2
JB
5162This NEWS file describes the changes made to guile-core since the 1.0
5163release.
5164
48d224d7
JB
5165We no longer distribute the documentation, since it was either out of
5166date, or incomplete. As soon as we have current documentation, we
5167will distribute it.
5168
0fcab5ed
JB
5169
5170
f3b1485f
JB
5171* Changes to the stand-alone interpreter
5172
48d224d7
JB
5173** guile now accepts command-line arguments compatible with SCSH, Olin
5174Shivers' Scheme Shell.
5175
5176In general, arguments are evaluated from left to right, but there are
5177exceptions. The following switches stop argument processing, and
5178stash all remaining command-line arguments as the value returned by
5179the (command-line) function.
5180 -s SCRIPT load Scheme source code from FILE, and exit
5181 -c EXPR evalute Scheme expression EXPR, and exit
5182 -- stop scanning arguments; run interactively
5183
5184The switches below are processed as they are encountered.
5185 -l FILE load Scheme source code from FILE
5186 -e FUNCTION after reading script, apply FUNCTION to
5187 command line arguments
5188 -ds do -s script at this point
5189 --emacs enable Emacs protocol (experimental)
5190 -h, --help display this help and exit
5191 -v, --version display version information and exit
5192 \ read arguments from following script lines
5193
5194So, for example, here is a Guile script named `ekko' (thanks, Olin)
5195which re-implements the traditional "echo" command:
5196
5197#!/usr/local/bin/guile -s
5198!#
5199(define (main args)
5200 (map (lambda (arg) (display arg) (display " "))
5201 (cdr args))
5202 (newline))
5203
5204(main (command-line))
5205
5206Suppose we invoke this script as follows:
5207
5208 ekko a speckled gecko
5209
5210Through the magic of Unix script processing (triggered by the `#!'
5211token at the top of the file), /usr/local/bin/guile receives the
5212following list of command-line arguments:
5213
5214 ("-s" "./ekko" "a" "speckled" "gecko")
5215
5216Unix inserts the name of the script after the argument specified on
5217the first line of the file (in this case, "-s"), and then follows that
5218with the arguments given to the script. Guile loads the script, which
5219defines the `main' function, and then applies it to the list of
5220remaining command-line arguments, ("a" "speckled" "gecko").
5221
095936d2
JB
5222In Unix, the first line of a script file must take the following form:
5223
5224#!INTERPRETER ARGUMENT
5225
5226where INTERPRETER is the absolute filename of the interpreter
5227executable, and ARGUMENT is a single command-line argument to pass to
5228the interpreter.
5229
5230You may only pass one argument to the interpreter, and its length is
5231limited. These restrictions can be annoying to work around, so Guile
5232provides a general mechanism (borrowed from, and compatible with,
5233SCSH) for circumventing them.
5234
5235If the ARGUMENT in a Guile script is a single backslash character,
5236`\', Guile will open the script file, parse arguments from its second
5237and subsequent lines, and replace the `\' with them. So, for example,
5238here is another implementation of the `ekko' script:
5239
5240#!/usr/local/bin/guile \
5241-e main -s
5242!#
5243(define (main args)
5244 (for-each (lambda (arg) (display arg) (display " "))
5245 (cdr args))
5246 (newline))
5247
5248If the user invokes this script as follows:
5249
5250 ekko a speckled gecko
5251
5252Unix expands this into
5253
5254 /usr/local/bin/guile \ ekko a speckled gecko
5255
5256When Guile sees the `\' argument, it replaces it with the arguments
5257read from the second line of the script, producing:
5258
5259 /usr/local/bin/guile -e main -s ekko a speckled gecko
5260
5261This tells Guile to load the `ekko' script, and apply the function
5262`main' to the argument list ("a" "speckled" "gecko").
5263
5264Here is how Guile parses the command-line arguments:
5265- Each space character terminates an argument. This means that two
5266 spaces in a row introduce an empty-string argument.
5267- The tab character is not permitted (unless you quote it with the
5268 backslash character, as described below), to avoid confusion.
5269- The newline character terminates the sequence of arguments, and will
5270 also terminate a final non-empty argument. (However, a newline
5271 following a space will not introduce a final empty-string argument;
5272 it only terminates the argument list.)
5273- The backslash character is the escape character. It escapes
5274 backslash, space, tab, and newline. The ANSI C escape sequences
5275 like \n and \t are also supported. These produce argument
5276 constituents; the two-character combination \n doesn't act like a
5277 terminating newline. The escape sequence \NNN for exactly three
5278 octal digits reads as the character whose ASCII code is NNN. As
5279 above, characters produced this way are argument constituents.
5280 Backslash followed by other characters is not allowed.
5281
48d224d7
JB
5282* Changes to the procedure for linking libguile with your programs
5283
5284** Guile now builds and installs a shared guile library, if your
5285system support shared libraries. (It still builds a static library on
5286all systems.) Guile automatically detects whether your system
5287supports shared libraries. To prevent Guile from buildisg shared
5288libraries, pass the `--disable-shared' flag to the configure script.
5289
5290Guile takes longer to compile when it builds shared libraries, because
5291it must compile every file twice --- once to produce position-
5292independent object code, and once to produce normal object code.
5293
5294** The libthreads library has been merged into libguile.
5295
5296To link a program against Guile, you now need only link against
5297-lguile and -lqt; -lthreads is no longer needed. If you are using
5298autoconf to generate configuration scripts for your application, the
5299following lines should suffice to add the appropriate libraries to
5300your link command:
5301
5302### Find quickthreads and libguile.
5303AC_CHECK_LIB(qt, main)
5304AC_CHECK_LIB(guile, scm_shell)
f3b1485f
JB
5305
5306* Changes to Scheme functions
5307
095936d2
JB
5308** Guile Scheme's special syntax for keyword objects is now optional,
5309and disabled by default.
5310
5311The syntax variation from R4RS made it difficult to port some
5312interesting packages to Guile. The routines which accepted keyword
5313arguments (mostly in the module system) have been modified to also
5314accept symbols whose names begin with `:'.
5315
5316To change the keyword syntax, you must first import the (ice-9 debug)
5317module:
5318 (use-modules (ice-9 debug))
5319
5320Then you can enable the keyword syntax as follows:
5321 (read-set! keywords 'prefix)
5322
5323To disable keyword syntax, do this:
5324 (read-set! keywords #f)
5325
5326** Many more primitive functions accept shared substrings as
5327arguments. In the past, these functions required normal, mutable
5328strings as arguments, although they never made use of this
5329restriction.
5330
5331** The uniform array functions now operate on byte vectors. These
5332functions are `array-fill!', `serial-array-copy!', `array-copy!',
5333`serial-array-map', `array-map', `array-for-each', and
5334`array-index-map!'.
5335
5336** The new functions `trace' and `untrace' implement simple debugging
5337support for Scheme functions.
5338
5339The `trace' function accepts any number of procedures as arguments,
5340and tells the Guile interpreter to display each procedure's name and
5341arguments each time the procedure is invoked. When invoked with no
5342arguments, `trace' returns the list of procedures currently being
5343traced.
5344
5345The `untrace' function accepts any number of procedures as arguments,
5346and tells the Guile interpreter not to trace them any more. When
5347invoked with no arguments, `untrace' untraces all curretly traced
5348procedures.
5349
5350The tracing in Guile has an advantage over most other systems: we
5351don't create new procedure objects, but mark the procedure objects
5352themselves. This means that anonymous and internal procedures can be
5353traced.
5354
5355** The function `assert-repl-prompt' has been renamed to
5356`set-repl-prompt!'. It takes one argument, PROMPT.
5357- If PROMPT is #f, the Guile read-eval-print loop will not prompt.
5358- If PROMPT is a string, we use it as a prompt.
5359- If PROMPT is a procedure accepting no arguments, we call it, and
5360 display the result as a prompt.
5361- Otherwise, we display "> ".
5362
5363** The new function `eval-string' reads Scheme expressions from a
5364string and evaluates them, returning the value of the last expression
5365in the string. If the string contains no expressions, it returns an
5366unspecified value.
5367
5368** The new function `thunk?' returns true iff its argument is a
5369procedure of zero arguments.
5370
5371** `defined?' is now a builtin function, instead of syntax. This
5372means that its argument should be quoted. It returns #t iff its
5373argument is bound in the current module.
5374
5375** The new syntax `use-modules' allows you to add new modules to your
5376environment without re-typing a complete `define-module' form. It
5377accepts any number of module names as arguments, and imports their
5378public bindings into the current module.
5379
5380** The new function (module-defined? NAME MODULE) returns true iff
5381NAME, a symbol, is defined in MODULE, a module object.
5382
5383** The new function `builtin-bindings' creates and returns a hash
5384table containing copies of all the root module's bindings.
5385
5386** The new function `builtin-weak-bindings' does the same as
5387`builtin-bindings', but creates a doubly-weak hash table.
5388
5389** The `equal?' function now considers variable objects to be
5390equivalent if they have the same name and the same value.
5391
5392** The new function `command-line' returns the command-line arguments
5393given to Guile, as a list of strings.
5394
5395When using guile as a script interpreter, `command-line' returns the
5396script's arguments; those processed by the interpreter (like `-s' or
5397`-c') are omitted. (In other words, you get the normal, expected
5398behavior.) Any application that uses scm_shell to process its
5399command-line arguments gets this behavior as well.
5400
5401** The new function `load-user-init' looks for a file called `.guile'
5402in the user's home directory, and loads it if it exists. This is
5403mostly for use by the code generated by scm_compile_shell_switches,
5404but we thought it might also be useful in other circumstances.
5405
5406** The new function `log10' returns the base-10 logarithm of its
5407argument.
5408
5409** Changes to I/O functions
5410
6c0201ad 5411*** The functions `read', `primitive-load', `read-and-eval!', and
095936d2
JB
5412`primitive-load-path' no longer take optional arguments controlling
5413case insensitivity and a `#' parser.
5414
5415Case sensitivity is now controlled by a read option called
5416`case-insensitive'. The user can add new `#' syntaxes with the
5417`read-hash-extend' function (see below).
5418
5419*** The new function `read-hash-extend' allows the user to change the
5420syntax of Guile Scheme in a somewhat controlled way.
5421
5422(read-hash-extend CHAR PROC)
5423 When parsing S-expressions, if we read a `#' character followed by
5424 the character CHAR, use PROC to parse an object from the stream.
5425 If PROC is #f, remove any parsing procedure registered for CHAR.
5426
5427 The reader applies PROC to two arguments: CHAR and an input port.
5428
6c0201ad 5429*** The new functions read-delimited and read-delimited! provide a
095936d2
JB
5430general mechanism for doing delimited input on streams.
5431
5432(read-delimited DELIMS [PORT HANDLE-DELIM])
5433 Read until we encounter one of the characters in DELIMS (a string),
5434 or end-of-file. PORT is the input port to read from; it defaults to
5435 the current input port. The HANDLE-DELIM parameter determines how
5436 the terminating character is handled; it should be one of the
5437 following symbols:
5438
5439 'trim omit delimiter from result
5440 'peek leave delimiter character in input stream
5441 'concat append delimiter character to returned value
5442 'split return a pair: (RESULT . TERMINATOR)
5443
5444 HANDLE-DELIM defaults to 'peek.
5445
5446(read-delimited! DELIMS BUF [PORT HANDLE-DELIM START END])
5447 A side-effecting variant of `read-delimited'.
5448
5449 The data is written into the string BUF at the indices in the
5450 half-open interval [START, END); the default interval is the whole
5451 string: START = 0 and END = (string-length BUF). The values of
5452 START and END must specify a well-defined interval in BUF, i.e.
5453 0 <= START <= END <= (string-length BUF).
5454
5455 It returns NBYTES, the number of bytes read. If the buffer filled
5456 up without a delimiter character being found, it returns #f. If the
5457 port is at EOF when the read starts, it returns the EOF object.
5458
5459 If an integer is returned (i.e., the read is successfully terminated
5460 by reading a delimiter character), then the HANDLE-DELIM parameter
5461 determines how to handle the terminating character. It is described
5462 above, and defaults to 'peek.
5463
5464(The descriptions of these functions were borrowed from the SCSH
5465manual, by Olin Shivers and Brian Carlstrom.)
5466
5467*** The `%read-delimited!' function is the primitive used to implement
5468`read-delimited' and `read-delimited!'.
5469
5470(%read-delimited! DELIMS BUF GOBBLE? [PORT START END])
5471
5472This returns a pair of values: (TERMINATOR . NUM-READ).
5473- TERMINATOR describes why the read was terminated. If it is a
5474 character or the eof object, then that is the value that terminated
5475 the read. If it is #f, the function filled the buffer without finding
5476 a delimiting character.
5477- NUM-READ is the number of characters read into BUF.
5478
5479If the read is successfully terminated by reading a delimiter
5480character, then the gobble? parameter determines what to do with the
5481terminating character. If true, the character is removed from the
5482input stream; if false, the character is left in the input stream
5483where a subsequent read operation will retrieve it. In either case,
5484the character is also the first value returned by the procedure call.
5485
5486(The descriptions of this function was borrowed from the SCSH manual,
5487by Olin Shivers and Brian Carlstrom.)
5488
5489*** The `read-line' and `read-line!' functions have changed; they now
5490trim the terminator by default; previously they appended it to the
5491returned string. For the old behavior, use (read-line PORT 'concat).
5492
5493*** The functions `uniform-array-read!' and `uniform-array-write!' now
5494take new optional START and END arguments, specifying the region of
5495the array to read and write.
5496
f348c807
JB
5497*** The `ungetc-char-ready?' function has been removed. We feel it's
5498inappropriate for an interface to expose implementation details this
5499way.
095936d2
JB
5500
5501** Changes to the Unix library and system call interface
5502
5503*** The new fcntl function provides access to the Unix `fcntl' system
5504call.
5505
5506(fcntl PORT COMMAND VALUE)
5507 Apply COMMAND to PORT's file descriptor, with VALUE as an argument.
5508 Values for COMMAND are:
5509
5510 F_DUPFD duplicate a file descriptor
5511 F_GETFD read the descriptor's close-on-exec flag
5512 F_SETFD set the descriptor's close-on-exec flag to VALUE
5513 F_GETFL read the descriptor's flags, as set on open
5514 F_SETFL set the descriptor's flags, as set on open to VALUE
5515 F_GETOWN return the process ID of a socket's owner, for SIGIO
5516 F_SETOWN set the process that owns a socket to VALUE, for SIGIO
5517 FD_CLOEXEC not sure what this is
5518
5519For details, see the documentation for the fcntl system call.
5520
5521*** The arguments to `select' have changed, for compatibility with
5522SCSH. The TIMEOUT parameter may now be non-integral, yielding the
5523expected behavior. The MILLISECONDS parameter has been changed to
5524MICROSECONDS, to more closely resemble the underlying system call.
5525The RVEC, WVEC, and EVEC arguments can now be vectors; the type of the
5526corresponding return set will be the same.
5527
5528*** The arguments to the `mknod' system call have changed. They are
5529now:
5530
5531(mknod PATH TYPE PERMS DEV)
5532 Create a new file (`node') in the file system. PATH is the name of
5533 the file to create. TYPE is the kind of file to create; it should
5534 be 'fifo, 'block-special, or 'char-special. PERMS specifies the
5535 permission bits to give the newly created file. If TYPE is
5536 'block-special or 'char-special, DEV specifies which device the
5537 special file refers to; its interpretation depends on the kind of
5538 special file being created.
5539
5540*** The `fork' function has been renamed to `primitive-fork', to avoid
5541clashing with various SCSH forks.
5542
5543*** The `recv' and `recvfrom' functions have been renamed to `recv!'
5544and `recvfrom!'. They no longer accept a size for a second argument;
5545you must pass a string to hold the received value. They no longer
5546return the buffer. Instead, `recv' returns the length of the message
5547received, and `recvfrom' returns a pair containing the packet's length
6c0201ad 5548and originating address.
095936d2
JB
5549
5550*** The file descriptor datatype has been removed, as have the
5551`read-fd', `write-fd', `close', `lseek', and `dup' functions.
5552We plan to replace these functions with a SCSH-compatible interface.
5553
5554*** The `create' function has been removed; it's just a special case
5555of `open'.
5556
5557*** There are new functions to break down process termination status
5558values. In the descriptions below, STATUS is a value returned by
5559`waitpid'.
5560
5561(status:exit-val STATUS)
5562 If the child process exited normally, this function returns the exit
5563 code for the child process (i.e., the value passed to exit, or
5564 returned from main). If the child process did not exit normally,
5565 this function returns #f.
5566
5567(status:stop-sig STATUS)
5568 If the child process was suspended by a signal, this function
5569 returns the signal that suspended the child. Otherwise, it returns
5570 #f.
5571
5572(status:term-sig STATUS)
5573 If the child process terminated abnormally, this function returns
5574 the signal that terminated the child. Otherwise, this function
5575 returns false.
5576
5577POSIX promises that exactly one of these functions will return true on
5578a valid STATUS value.
5579
5580These functions are compatible with SCSH.
5581
5582*** There are new accessors and setters for the broken-out time vectors
48d224d7
JB
5583returned by `localtime', `gmtime', and that ilk. They are:
5584
5585 Component Accessor Setter
5586 ========================= ============ ============
5587 seconds tm:sec set-tm:sec
5588 minutes tm:min set-tm:min
5589 hours tm:hour set-tm:hour
5590 day of the month tm:mday set-tm:mday
5591 month tm:mon set-tm:mon
5592 year tm:year set-tm:year
5593 day of the week tm:wday set-tm:wday
5594 day in the year tm:yday set-tm:yday
5595 daylight saving time tm:isdst set-tm:isdst
5596 GMT offset, seconds tm:gmtoff set-tm:gmtoff
5597 name of time zone tm:zone set-tm:zone
5598
095936d2
JB
5599*** There are new accessors for the vectors returned by `uname',
5600describing the host system:
48d224d7
JB
5601
5602 Component Accessor
5603 ============================================== ================
5604 name of the operating system implementation utsname:sysname
5605 network name of this machine utsname:nodename
5606 release level of the operating system utsname:release
5607 version level of the operating system utsname:version
5608 machine hardware platform utsname:machine
5609
095936d2
JB
5610*** There are new accessors for the vectors returned by `getpw',
5611`getpwnam', `getpwuid', and `getpwent', describing entries from the
5612system's user database:
5613
5614 Component Accessor
5615 ====================== =================
5616 user name passwd:name
5617 user password passwd:passwd
5618 user id passwd:uid
5619 group id passwd:gid
5620 real name passwd:gecos
5621 home directory passwd:dir
5622 shell program passwd:shell
5623
5624*** There are new accessors for the vectors returned by `getgr',
5625`getgrnam', `getgrgid', and `getgrent', describing entries from the
5626system's group database:
5627
5628 Component Accessor
5629 ======================= ============
5630 group name group:name
5631 group password group:passwd
5632 group id group:gid
5633 group members group:mem
5634
5635*** There are new accessors for the vectors returned by `gethost',
5636`gethostbyaddr', `gethostbyname', and `gethostent', describing
5637internet hosts:
5638
5639 Component Accessor
5640 ========================= ===============
5641 official name of host hostent:name
5642 alias list hostent:aliases
5643 host address type hostent:addrtype
5644 length of address hostent:length
5645 list of addresses hostent:addr-list
5646
5647*** There are new accessors for the vectors returned by `getnet',
5648`getnetbyaddr', `getnetbyname', and `getnetent', describing internet
5649networks:
5650
5651 Component Accessor
5652 ========================= ===============
5653 official name of net netent:name
5654 alias list netent:aliases
5655 net number type netent:addrtype
5656 net number netent:net
5657
5658*** There are new accessors for the vectors returned by `getproto',
5659`getprotobyname', `getprotobynumber', and `getprotoent', describing
5660internet protocols:
5661
5662 Component Accessor
5663 ========================= ===============
5664 official protocol name protoent:name
5665 alias list protoent:aliases
5666 protocol number protoent:proto
5667
5668*** There are new accessors for the vectors returned by `getserv',
5669`getservbyname', `getservbyport', and `getservent', describing
5670internet protocols:
5671
5672 Component Accessor
5673 ========================= ===============
6c0201ad 5674 official service name servent:name
095936d2 5675 alias list servent:aliases
6c0201ad
TTN
5676 port number servent:port
5677 protocol to use servent:proto
095936d2
JB
5678
5679*** There are new accessors for the sockaddr structures returned by
5680`accept', `getsockname', `getpeername', `recvfrom!':
5681
5682 Component Accessor
5683 ======================================== ===============
6c0201ad 5684 address format (`family') sockaddr:fam
095936d2
JB
5685 path, for file domain addresses sockaddr:path
5686 address, for internet domain addresses sockaddr:addr
5687 TCP or UDP port, for internet sockaddr:port
5688
5689*** The `getpwent', `getgrent', `gethostent', `getnetent',
5690`getprotoent', and `getservent' functions now return #f at the end of
5691the user database. (They used to throw an exception.)
5692
5693Note that calling MUMBLEent function is equivalent to calling the
5694corresponding MUMBLE function with no arguments.
5695
5696*** The `setpwent', `setgrent', `sethostent', `setnetent',
5697`setprotoent', and `setservent' routines now take no arguments.
5698
5699*** The `gethost', `getproto', `getnet', and `getserv' functions now
5700provide more useful information when they throw an exception.
5701
5702*** The `lnaof' function has been renamed to `inet-lnaof'.
5703
5704*** Guile now claims to have the `current-time' feature.
5705
5706*** The `mktime' function now takes an optional second argument ZONE,
5707giving the time zone to use for the conversion. ZONE should be a
5708string, in the same format as expected for the "TZ" environment variable.
5709
5710*** The `strptime' function now returns a pair (TIME . COUNT), where
5711TIME is the parsed time as a vector, and COUNT is the number of
5712characters from the string left unparsed. This function used to
5713return the remaining characters as a string.
5714
5715*** The `gettimeofday' function has replaced the old `time+ticks' function.
5716The return value is now (SECONDS . MICROSECONDS); the fractional
5717component is no longer expressed in "ticks".
5718
5719*** The `ticks/sec' constant has been removed, in light of the above change.
6685dc83 5720
ea00ecba
MG
5721* Changes to the gh_ interface
5722
5723** gh_eval_str() now returns an SCM object which is the result of the
5724evaluation
5725
aaef0d2a
MG
5726** gh_scm2str() now copies the Scheme data to a caller-provided C
5727array
5728
5729** gh_scm2newstr() now makes a C array, copies the Scheme data to it,
5730and returns the array
5731
5732** gh_scm2str0() is gone: there is no need to distinguish
5733null-terminated from non-null-terminated, since gh_scm2newstr() allows
5734the user to interpret the data both ways.
5735
f3b1485f
JB
5736* Changes to the scm_ interface
5737
095936d2
JB
5738** The new function scm_symbol_value0 provides an easy way to get a
5739symbol's value from C code:
5740
5741SCM scm_symbol_value0 (char *NAME)
5742 Return the value of the symbol named by the null-terminated string
5743 NAME in the current module. If the symbol named NAME is unbound in
5744 the current module, return SCM_UNDEFINED.
5745
5746** The new function scm_sysintern0 creates new top-level variables,
5747without assigning them a value.
5748
5749SCM scm_sysintern0 (char *NAME)
5750 Create a new Scheme top-level variable named NAME. NAME is a
5751 null-terminated string. Return the variable's value cell.
5752
5753** The function scm_internal_catch is the guts of catch. It handles
5754all the mechanics of setting up a catch target, invoking the catch
5755body, and perhaps invoking the handler if the body does a throw.
5756
5757The function is designed to be usable from C code, but is general
5758enough to implement all the semantics Guile Scheme expects from throw.
5759
5760TAG is the catch tag. Typically, this is a symbol, but this function
5761doesn't actually care about that.
5762
5763BODY is a pointer to a C function which runs the body of the catch;
5764this is the code you can throw from. We call it like this:
5765 BODY (BODY_DATA, JMPBUF)
5766where:
5767 BODY_DATA is just the BODY_DATA argument we received; we pass it
5768 through to BODY as its first argument. The caller can make
5769 BODY_DATA point to anything useful that BODY might need.
5770 JMPBUF is the Scheme jmpbuf object corresponding to this catch,
5771 which we have just created and initialized.
5772
5773HANDLER is a pointer to a C function to deal with a throw to TAG,
5774should one occur. We call it like this:
5775 HANDLER (HANDLER_DATA, THROWN_TAG, THROW_ARGS)
5776where
5777 HANDLER_DATA is the HANDLER_DATA argument we recevied; it's the
5778 same idea as BODY_DATA above.
5779 THROWN_TAG is the tag that the user threw to; usually this is
5780 TAG, but it could be something else if TAG was #t (i.e., a
5781 catch-all), or the user threw to a jmpbuf.
5782 THROW_ARGS is the list of arguments the user passed to the THROW
5783 function.
5784
5785BODY_DATA is just a pointer we pass through to BODY. HANDLER_DATA
5786is just a pointer we pass through to HANDLER. We don't actually
5787use either of those pointers otherwise ourselves. The idea is
5788that, if our caller wants to communicate something to BODY or
5789HANDLER, it can pass a pointer to it as MUMBLE_DATA, which BODY and
5790HANDLER can then use. Think of it as a way to make BODY and
5791HANDLER closures, not just functions; MUMBLE_DATA points to the
5792enclosed variables.
5793
5794Of course, it's up to the caller to make sure that any data a
5795MUMBLE_DATA needs is protected from GC. A common way to do this is
5796to make MUMBLE_DATA a pointer to data stored in an automatic
5797structure variable; since the collector must scan the stack for
5798references anyway, this assures that any references in MUMBLE_DATA
5799will be found.
5800
5801** The new function scm_internal_lazy_catch is exactly like
5802scm_internal_catch, except:
5803
5804- It does not unwind the stack (this is the major difference).
5805- If handler returns, its value is returned from the throw.
5806- BODY always receives #f as its JMPBUF argument (since there's no
5807 jmpbuf associated with a lazy catch, because we don't unwind the
5808 stack.)
5809
5810** scm_body_thunk is a new body function you can pass to
5811scm_internal_catch if you want the body to be like Scheme's `catch'
5812--- a thunk, or a function of one argument if the tag is #f.
5813
5814BODY_DATA is a pointer to a scm_body_thunk_data structure, which
5815contains the Scheme procedure to invoke as the body, and the tag
5816we're catching. If the tag is #f, then we pass JMPBUF (created by
5817scm_internal_catch) to the body procedure; otherwise, the body gets
5818no arguments.
5819
5820** scm_handle_by_proc is a new handler function you can pass to
5821scm_internal_catch if you want the handler to act like Scheme's catch
5822--- call a procedure with the tag and the throw arguments.
5823
5824If the user does a throw to this catch, this function runs a handler
5825procedure written in Scheme. HANDLER_DATA is a pointer to an SCM
5826variable holding the Scheme procedure object to invoke. It ought to
5827be a pointer to an automatic variable (i.e., one living on the stack),
5828or the procedure object should be otherwise protected from GC.
5829
5830** scm_handle_by_message is a new handler function to use with
5831`scm_internal_catch' if you want Guile to print a message and die.
5832It's useful for dealing with throws to uncaught keys at the top level.
5833
5834HANDLER_DATA, if non-zero, is assumed to be a char * pointing to a
5835message header to print; if zero, we use "guile" instead. That
5836text is followed by a colon, then the message described by ARGS.
5837
5838** The return type of scm_boot_guile is now void; the function does
5839not return a value, and indeed, never returns at all.
5840
f3b1485f
JB
5841** The new function scm_shell makes it easy for user applications to
5842process command-line arguments in a way that is compatible with the
5843stand-alone guile interpreter (which is in turn compatible with SCSH,
5844the Scheme shell).
5845
5846To use the scm_shell function, first initialize any guile modules
5847linked into your application, and then call scm_shell with the values
7ed46dc8 5848of ARGC and ARGV your `main' function received. scm_shell will add
f3b1485f
JB
5849any SCSH-style meta-arguments from the top of the script file to the
5850argument vector, and then process the command-line arguments. This
5851generally means loading a script file or starting up an interactive
5852command interpreter. For details, see "Changes to the stand-alone
5853interpreter" above.
5854
095936d2 5855** The new functions scm_get_meta_args and scm_count_argv help you
6c0201ad 5856implement the SCSH-style meta-argument, `\'.
095936d2
JB
5857
5858char **scm_get_meta_args (int ARGC, char **ARGV)
5859 If the second element of ARGV is a string consisting of a single
5860 backslash character (i.e. "\\" in Scheme notation), open the file
5861 named by the following argument, parse arguments from it, and return
5862 the spliced command line. The returned array is terminated by a
5863 null pointer.
6c0201ad 5864
095936d2
JB
5865 For details of argument parsing, see above, under "guile now accepts
5866 command-line arguments compatible with SCSH..."
5867
5868int scm_count_argv (char **ARGV)
5869 Count the arguments in ARGV, assuming it is terminated by a null
5870 pointer.
5871
5872For an example of how these functions might be used, see the source
5873code for the function scm_shell in libguile/script.c.
5874
5875You will usually want to use scm_shell instead of calling this
5876function yourself.
5877
5878** The new function scm_compile_shell_switches turns an array of
5879command-line arguments into Scheme code to carry out the actions they
5880describe. Given ARGC and ARGV, it returns a Scheme expression to
5881evaluate, and calls scm_set_program_arguments to make any remaining
5882command-line arguments available to the Scheme code. For example,
5883given the following arguments:
5884
5885 -e main -s ekko a speckled gecko
5886
5887scm_set_program_arguments will return the following expression:
5888
5889 (begin (load "ekko") (main (command-line)) (quit))
5890
5891You will usually want to use scm_shell instead of calling this
5892function yourself.
5893
5894** The function scm_shell_usage prints a usage message appropriate for
5895an interpreter that uses scm_compile_shell_switches to handle its
5896command-line arguments.
5897
5898void scm_shell_usage (int FATAL, char *MESSAGE)
5899 Print a usage message to the standard error output. If MESSAGE is
5900 non-zero, write it before the usage message, followed by a newline.
5901 If FATAL is non-zero, exit the process, using FATAL as the
5902 termination status. (If you want to be compatible with Guile,
5903 always use 1 as the exit status when terminating due to command-line
5904 usage problems.)
5905
5906You will usually want to use scm_shell instead of calling this
5907function yourself.
48d224d7
JB
5908
5909** scm_eval_0str now returns SCM_UNSPECIFIED if the string contains no
095936d2
JB
5910expressions. It used to return SCM_EOL. Earth-shattering.
5911
5912** The macros for declaring scheme objects in C code have been
5913rearranged slightly. They are now:
5914
5915SCM_SYMBOL (C_NAME, SCHEME_NAME)
5916 Declare a static SCM variable named C_NAME, and initialize it to
5917 point to the Scheme symbol whose name is SCHEME_NAME. C_NAME should
5918 be a C identifier, and SCHEME_NAME should be a C string.
5919
5920SCM_GLOBAL_SYMBOL (C_NAME, SCHEME_NAME)
5921 Just like SCM_SYMBOL, but make C_NAME globally visible.
5922
5923SCM_VCELL (C_NAME, SCHEME_NAME)
5924 Create a global variable at the Scheme level named SCHEME_NAME.
5925 Declare a static SCM variable named C_NAME, and initialize it to
5926 point to the Scheme variable's value cell.
5927
5928SCM_GLOBAL_VCELL (C_NAME, SCHEME_NAME)
5929 Just like SCM_VCELL, but make C_NAME globally visible.
5930
5931The `guile-snarf' script writes initialization code for these macros
5932to its standard output, given C source code as input.
5933
5934The SCM_GLOBAL macro is gone.
5935
5936** The scm_read_line and scm_read_line_x functions have been replaced
5937by Scheme code based on the %read-delimited! procedure (known to C
5938code as scm_read_delimited_x). See its description above for more
5939information.
48d224d7 5940
095936d2
JB
5941** The function scm_sys_open has been renamed to scm_open. It now
5942returns a port instead of an FD object.
ea00ecba 5943
095936d2
JB
5944* The dynamic linking support has changed. For more information, see
5945libguile/DYNAMIC-LINKING.
ea00ecba 5946
f7b47737
JB
5947\f
5948Guile 1.0b3
3065a62a 5949
f3b1485f
JB
5950User-visible changes from Thursday, September 5, 1996 until Guile 1.0
5951(Sun 5 Jan 1997):
3065a62a 5952
4b521edb 5953* Changes to the 'guile' program:
3065a62a 5954
4b521edb
JB
5955** Guile now loads some new files when it starts up. Guile first
5956searches the load path for init.scm, and loads it if found. Then, if
5957Guile is not being used to execute a script, and the user's home
5958directory contains a file named `.guile', Guile loads that.
c6486f8a 5959
4b521edb 5960** You can now use Guile as a shell script interpreter.
3065a62a
JB
5961
5962To paraphrase the SCSH manual:
5963
5964 When Unix tries to execute an executable file whose first two
5965 characters are the `#!', it treats the file not as machine code to
5966 be directly executed by the native processor, but as source code
5967 to be executed by some interpreter. The interpreter to use is
5968 specified immediately after the #! sequence on the first line of
5969 the source file. The kernel reads in the name of the interpreter,
5970 and executes that instead. It passes the interpreter the source
5971 filename as its first argument, with the original arguments
5972 following. Consult the Unix man page for the `exec' system call
5973 for more information.
5974
1a1945be
JB
5975Now you can use Guile as an interpreter, using a mechanism which is a
5976compatible subset of that provided by SCSH.
5977
3065a62a
JB
5978Guile now recognizes a '-s' command line switch, whose argument is the
5979name of a file of Scheme code to load. It also treats the two
5980characters `#!' as the start of a comment, terminated by `!#'. Thus,
5981to make a file of Scheme code directly executable by Unix, insert the
5982following two lines at the top of the file:
5983
5984#!/usr/local/bin/guile -s
5985!#
5986
5987Guile treats the argument of the `-s' command-line switch as the name
5988of a file of Scheme code to load, and treats the sequence `#!' as the
5989start of a block comment, terminated by `!#'.
5990
5991For example, here's a version of 'echo' written in Scheme:
5992
5993#!/usr/local/bin/guile -s
5994!#
5995(let loop ((args (cdr (program-arguments))))
5996 (if (pair? args)
5997 (begin
5998 (display (car args))
5999 (if (pair? (cdr args))
6000 (display " "))
6001 (loop (cdr args)))))
6002(newline)
6003
6004Why does `#!' start a block comment terminated by `!#', instead of the
6005end of the line? That is the notation SCSH uses, and although we
6006don't yet support the other SCSH features that motivate that choice,
6007we would like to be backward-compatible with any existing Guile
3763761c
JB
6008scripts once we do. Furthermore, if the path to Guile on your system
6009is too long for your kernel, you can start the script with this
6010horrible hack:
6011
6012#!/bin/sh
6013exec /really/long/path/to/guile -s "$0" ${1+"$@"}
6014!#
3065a62a
JB
6015
6016Note that some very old Unix systems don't support the `#!' syntax.
6017
c6486f8a 6018
4b521edb 6019** You can now run Guile without installing it.
6685dc83
JB
6020
6021Previous versions of the interactive Guile interpreter (`guile')
6022couldn't start up unless Guile's Scheme library had been installed;
6023they used the value of the environment variable `SCHEME_LOAD_PATH'
6024later on in the startup process, but not to find the startup code
6025itself. Now Guile uses `SCHEME_LOAD_PATH' in all searches for Scheme
6026code.
6027
6028To run Guile without installing it, build it in the normal way, and
6029then set the environment variable `SCHEME_LOAD_PATH' to a
6030colon-separated list of directories, including the top-level directory
6031of the Guile sources. For example, if you unpacked Guile so that the
6032full filename of this NEWS file is /home/jimb/guile-1.0b3/NEWS, then
6033you might say
6034
6035 export SCHEME_LOAD_PATH=/home/jimb/my-scheme:/home/jimb/guile-1.0b3
6036
c6486f8a 6037
4b521edb
JB
6038** Guile's read-eval-print loop no longer prints #<unspecified>
6039results. If the user wants to see this, she can evaluate the
6040expression (assert-repl-print-unspecified #t), perhaps in her startup
48d224d7 6041file.
6685dc83 6042
4b521edb
JB
6043** Guile no longer shows backtraces by default when an error occurs;
6044however, it does display a message saying how to get one, and how to
6045request that they be displayed by default. After an error, evaluate
6046 (backtrace)
6047to see a backtrace, and
6048 (debug-enable 'backtrace)
6049to see them by default.
6685dc83 6050
6685dc83 6051
d9fb83d9 6052
4b521edb
JB
6053* Changes to Guile Scheme:
6054
6055** Guile now distinguishes between #f and the empty list.
6056
6057This is for compatibility with the IEEE standard, the (possibly)
6058upcoming Revised^5 Report on Scheme, and many extant Scheme
6059implementations.
6060
6061Guile used to have #f and '() denote the same object, to make Scheme's
6062type system more compatible with Emacs Lisp's. However, the change
6063caused too much trouble for Scheme programmers, and we found another
6064way to reconcile Emacs Lisp with Scheme that didn't require this.
6065
6066
6067** Guile's delq, delv, delete functions, and their destructive
c6486f8a
JB
6068counterparts, delq!, delv!, and delete!, now remove all matching
6069elements from the list, not just the first. This matches the behavior
6070of the corresponding Emacs Lisp functions, and (I believe) the Maclisp
6071functions which inspired them.
6072
6073I recognize that this change may break code in subtle ways, but it
6074seems best to make the change before the FSF's first Guile release,
6075rather than after.
6076
6077
4b521edb 6078** The compiled-library-path function has been deleted from libguile.
6685dc83 6079
4b521edb 6080** The facilities for loading Scheme source files have changed.
c6486f8a 6081
4b521edb 6082*** The variable %load-path now tells Guile which directories to search
6685dc83
JB
6083for Scheme code. Its value is a list of strings, each of which names
6084a directory.
6085
4b521edb
JB
6086*** The variable %load-extensions now tells Guile which extensions to
6087try appending to a filename when searching the load path. Its value
6088is a list of strings. Its default value is ("" ".scm").
6089
6090*** (%search-load-path FILENAME) searches the directories listed in the
6091value of the %load-path variable for a Scheme file named FILENAME,
6092with all the extensions listed in %load-extensions. If it finds a
6093match, then it returns its full filename. If FILENAME is absolute, it
6094returns it unchanged. Otherwise, it returns #f.
6685dc83 6095
4b521edb
JB
6096%search-load-path will not return matches that refer to directories.
6097
6098*** (primitive-load FILENAME :optional CASE-INSENSITIVE-P SHARP)
6099uses %seach-load-path to find a file named FILENAME, and loads it if
6100it finds it. If it can't read FILENAME for any reason, it throws an
6101error.
6685dc83
JB
6102
6103The arguments CASE-INSENSITIVE-P and SHARP are interpreted as by the
4b521edb
JB
6104`read' function.
6105
6106*** load uses the same searching semantics as primitive-load.
6107
6108*** The functions %try-load, try-load-with-path, %load, load-with-path,
6109basic-try-load-with-path, basic-load-with-path, try-load-module-with-
6110path, and load-module-with-path have been deleted. The functions
6111above should serve their purposes.
6112
6113*** If the value of the variable %load-hook is a procedure,
6114`primitive-load' applies its value to the name of the file being
6115loaded (without the load path directory name prepended). If its value
6116is #f, it is ignored. Otherwise, an error occurs.
6117
6118This is mostly useful for printing load notification messages.
6119
6120
6121** The function `eval!' is no longer accessible from the scheme level.
6122We can't allow operations which introduce glocs into the scheme level,
6123because Guile's type system can't handle these as data. Use `eval' or
6124`read-and-eval!' (see below) as replacement.
6125
6126** The new function read-and-eval! reads an expression from PORT,
6127evaluates it, and returns the result. This is more efficient than
6128simply calling `read' and `eval', since it is not necessary to make a
6129copy of the expression for the evaluator to munge.
6130
6131Its optional arguments CASE_INSENSITIVE_P and SHARP are interpreted as
6132for the `read' function.
6133
6134
6135** The function `int?' has been removed; its definition was identical
6136to that of `integer?'.
6137
6138** The functions `<?', `<?', `<=?', `=?', `>?', and `>=?'. Code should
6139use the R4RS names for these functions.
6140
6141** The function object-properties no longer returns the hash handle;
6142it simply returns the object's property list.
6143
6144** Many functions have been changed to throw errors, instead of
6145returning #f on failure. The point of providing exception handling in
6146the language is to simplify the logic of user code, but this is less
6147useful if Guile's primitives don't throw exceptions.
6148
6149** The function `fileno' has been renamed from `%fileno'.
6150
6151** The function primitive-mode->fdes returns #t or #f now, not 1 or 0.
6152
6153
6154* Changes to Guile's C interface:
6155
6156** The library's initialization procedure has been simplified.
6157scm_boot_guile now has the prototype:
6158
6159void scm_boot_guile (int ARGC,
6160 char **ARGV,
6161 void (*main_func) (),
6162 void *closure);
6163
6164scm_boot_guile calls MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV.
6165MAIN_FUNC should do all the work of the program (initializing other
6166packages, reading user input, etc.) before returning. When MAIN_FUNC
6167returns, call exit (0); this function never returns. If you want some
6168other exit value, MAIN_FUNC may call exit itself.
6169
6170scm_boot_guile arranges for program-arguments to return the strings
6171given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should call
6172scm_set_program_arguments with the final list, so Scheme code will
6173know which arguments have been processed.
6174
6175scm_boot_guile establishes a catch-all catch handler which prints an
6176error message and exits the process. This means that Guile exits in a
6177coherent way when system errors occur and the user isn't prepared to
6178handle it. If the user doesn't like this behavior, they can establish
6179their own universal catcher in MAIN_FUNC to shadow this one.
6180
6181Why must the caller do all the real work from MAIN_FUNC? The garbage
6182collector assumes that all local variables of type SCM will be above
6183scm_boot_guile's stack frame on the stack. If you try to manipulate
6184SCM values after this function returns, it's the luck of the draw
6185whether the GC will be able to find the objects you allocate. So,
6186scm_boot_guile function exits, rather than returning, to discourage
6187people from making that mistake.
6188
6189The IN, OUT, and ERR arguments were removed; there are other
6190convenient ways to override these when desired.
6191
6192The RESULT argument was deleted; this function should never return.
6193
6194The BOOT_CMD argument was deleted; the MAIN_FUNC argument is more
6195general.
6196
6197
6198** Guile's header files should no longer conflict with your system's
6199header files.
6200
6201In order to compile code which #included <libguile.h>, previous
6202versions of Guile required you to add a directory containing all the
6203Guile header files to your #include path. This was a problem, since
6204Guile's header files have names which conflict with many systems'
6205header files.
6206
6207Now only <libguile.h> need appear in your #include path; you must
6208refer to all Guile's other header files as <libguile/mumble.h>.
6209Guile's installation procedure puts libguile.h in $(includedir), and
6210the rest in $(includedir)/libguile.
6211
6212
6213** Two new C functions, scm_protect_object and scm_unprotect_object,
6214have been added to the Guile library.
6215
6216scm_protect_object (OBJ) protects OBJ from the garbage collector.
6217OBJ will not be freed, even if all other references are dropped,
6218until someone does scm_unprotect_object (OBJ). Both functions
6219return OBJ.
6220
6221Note that calls to scm_protect_object do not nest. You can call
6222scm_protect_object any number of times on a given object, and the
6223next call to scm_unprotect_object will unprotect it completely.
6224
6225Basically, scm_protect_object and scm_unprotect_object just
6226maintain a list of references to things. Since the GC knows about
6227this list, all objects it mentions stay alive. scm_protect_object
6228adds its argument to the list; scm_unprotect_object remove its
6229argument from the list.
6230
6231
6232** scm_eval_0str now returns the value of the last expression
6233evaluated.
6234
6235** The new function scm_read_0str reads an s-expression from a
6236null-terminated string, and returns it.
6237
6238** The new function `scm_stdio_to_port' converts a STDIO file pointer
6239to a Scheme port object.
6240
6241** The new function `scm_set_program_arguments' allows C code to set
e80c8fea 6242the value returned by the Scheme `program-arguments' function.
6685dc83 6243
6685dc83 6244\f
1a1945be
JB
6245Older changes:
6246
6247* Guile no longer includes sophisticated Tcl/Tk support.
6248
6249The old Tcl/Tk support was unsatisfying to us, because it required the
6250user to link against the Tcl library, as well as Tk and Guile. The
6251interface was also un-lispy, in that it preserved Tcl/Tk's practice of
6252referring to widgets by names, rather than exporting widgets to Scheme
6253code as a special datatype.
6254
6255In the Usenix Tk Developer's Workshop held in July 1996, the Tcl/Tk
6256maintainers described some very interesting changes in progress to the
6257Tcl/Tk internals, which would facilitate clean interfaces between lone
6258Tk and other interpreters --- even for garbage-collected languages
6259like Scheme. They expected the new Tk to be publicly available in the
6260fall of 1996.
6261
6262Since it seems that Guile might soon have a new, cleaner interface to
6263lone Tk, and that the old Guile/Tk glue code would probably need to be
6264completely rewritten, we (Jim Blandy and Richard Stallman) have
6265decided not to support the old code. We'll spend the time instead on
6266a good interface to the newer Tk, as soon as it is available.
5c54da76 6267
8512dea6 6268Until then, gtcltk-lib provides trivial, low-maintenance functionality.
deb95d71 6269
5c54da76
JB
6270\f
6271Copyright information:
6272
7e267da1 6273Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5c54da76
JB
6274
6275 Permission is granted to anyone to make or distribute verbatim copies
6276 of this document as received, in any medium, provided that the
6277 copyright notice and this permission notice are preserved,
6278 thus giving the recipient permission to redistribute in turn.
6279
6280 Permission is granted to distribute modified versions
6281 of this document, or of portions of it,
6282 under the above conditions, provided also that they
6283 carry prominent notices stating who last changed them.
6284
48d224d7
JB
6285\f
6286Local variables:
6287mode: outline
6288paragraph-separate: "[ \f]*$"
6289end:
6290