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