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