From 1fd92c34ebd67d73aaa18d29dd85c8a3aec4e64c Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 30 Sep 2001 22:32:13 +0000 Subject: [PATCH 001/281] (EXTRA_DIST): Add BUGS file. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index e37a678a4..08f905225 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,7 @@ include_HEADERS = libguile.h # automake sometimes forgets to distribute acconfig.h, # apparently depending on the phase of the moon. EXTRA_DIST = qthreads.m4 HACKING GUILE-VERSION ANON-CVS SNAPSHOTS TODO \ - $(ACLOCAL) acconfig.h + $(ACLOCAL) acconfig.h BUGS TESTS = check-guile From 6768cfba8c4dcbc683797a93769875e1a9c9809d Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 30 Sep 2001 22:33:38 +0000 Subject: [PATCH 002/281] *** empty log message *** --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 748f28f48..1445ba838 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-09-30 Thien-Thi Nguyen + + * BUGS: New file. + * Makefile.am (EXTRA_DIST): Add BUGS file. + 2001-09-25 Thien-Thi Nguyen * TODO: Add bugfix item to "Eventually". From 2dbec7b5fc3525b6800ba27895e255d3f8cae3d1 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Wed, 3 Oct 2001 20:45:44 +0000 Subject: [PATCH 003/281] * continuations.h, unif.h: in the descriptions of the bit patterns of the heap cells, make bit 0 the least significant. --- libguile/ChangeLog | 5 +++++ libguile/continuations.h | 4 ++-- libguile/unif.h | 10 +++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 3f81af82a..2a994253a 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-10-03 Gary Houston + + * continuations.h, unif.h: in the descriptions of the bit patterns + of the heap cells, make bit 0 the least significant. + 2001-09-25 Thien-Thi Nguyen * chars.h (SCM_MAKE_CHAR): Use `scm_t_bits' instead of `intptr_t'. diff --git a/libguile/continuations.h b/libguile/continuations.h index 74f2b1aa3..21616173c 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -51,8 +51,8 @@ /* a continuation SCM is a non-immediate pointing to a heap cell with: - word 0: bits 0-15: unused. - bits 16-31: smob type tag: scm_tc16_continuation. + word 0: bits 0-15: smob type tag: scm_tc16_continuation. + bits 16-31: unused. word 1: malloc block containing an scm_t_contregs structure with a tail array of SCM_STACKITEM. the size of the array is stored in the num_stack_items field of the structure. diff --git a/libguile/unif.h b/libguile/unif.h index 66a33fcf0..24da36e72 100644 --- a/libguile/unif.h +++ b/libguile/unif.h @@ -51,12 +51,12 @@ /* - an array SCM is a non-immediate pointing to a heap cell with: + an array SCM is a non-immediate pointing to a heap cell where: - CAR: bits 0-14 hold the dimension (0 -- 32767) - bit 15 is the SCM_ARRAY_FLAG_CONTIGUOUS flag - bits 16-31 hold the smob type id: scm_tc16_array - CDR: pointer to a malloced block containing an scm_array structure + CAR: bits 0-15 hold the smob type id: scm_tc16_array + bit 16 is the SCM_ARRAY_FLAG_CONTIGUOUS flag + bits 17-31 hold the dimension (0 -- 32767) + CDR: pointer to a malloced block containing an scm_t_array structure followed by an scm_t_array_dim structure for each dimension. */ From 9eb96786d0e731ee648768b951e0f3b19f77e03f Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 5 Oct 2001 15:58:51 +0000 Subject: [PATCH 004/281] (Writing): Add entry for `display'. Include in R5RS Index. --- doc/ref/scheme-io.texi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/ref/scheme-io.texi b/doc/ref/scheme-io.texi index c775c165c..07a258868 100644 --- a/doc/ref/scheme-io.texi +++ b/doc/ref/scheme-io.texi @@ -151,9 +151,18 @@ Return the print state of the port @var{port}. If @var{port} has no associated print state, @code{#f} is returned. @end deffn +@rnindex display +@deffn primitive display obj [port] +Send a representation of @var{obj} to @var{current-output-port}. +Optional second arg @var{port} specifies an alternative output port. +The representation is similar to that produced by @code{write} (REFFIXME), +the differences being strings are not quoted (and their characters are not +escaped), and characters are rendered as if with @code{write-char}. +@end deffn + @rnindex newline @deffn primitive newline [port] -Send a newline to @var{port}. +Send a newline to @var{port} (default @var{current-output-port} if omitted). @end deffn @deffn primitive port-with-print-state port pstate From 74e0de864ba9eab0bf5190a3a4788599eacbcff2 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 5 Oct 2001 16:00:24 +0000 Subject: [PATCH 005/281] *** empty log message *** --- doc/ref/ChangeLog | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 17c12b23d..b2dfb17e0 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-10-05 Thien-Thi Nguyen + + * scheme-io.texi (Writing): Add entry for `display'. + Include in R5RS Index. Thanks to Alex Schroeder for suggestion. + 2001-09-26 Martin Grabmueller * srfi-modules.texi (SRFI-13): Tyop fix. @@ -9,7 +14,7 @@ Thanks to Alex Schroeder for pointing out the typos and sending suggestions. - + 2001-09-25 Thien-Thi Nguyen * scheme-procedures.texi (Syntax Rules): Add `cindex' directive. From 14282d0f5c839816aff0e83466b6ea46e51cdac0 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Fri, 5 Oct 2001 17:43:49 +0000 Subject: [PATCH 006/281] * numbers.h: Removed old comment about using SCM_CAR to access non-pair cells. (SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Make sure the return value is signed. Thanks to Brian Crowder for the bug report. (SCM_SRS): Avoid unnecessary casting and don't unpack input values. With this patch, SCM_SRS can be safely used for other types than scm_t_signed_bits. However, it should still better be an internal macro and thus be renamed to SCM_I_SRS. (SCM_MAKINUM, SCM_INUM): Use proper casting. --- THANKS | 1 + libguile/ChangeLog | 16 ++++++++++++++++ libguile/numbers.h | 29 +++++++++++++---------------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/THANKS b/THANKS index 1eb38dc64..2d74681dd 100644 --- a/THANKS +++ b/THANKS @@ -11,5 +11,6 @@ For fixes or providing information which led to a fix: Martin Baulig Rob Browning + Brian Crowder Christopher Cramer John Goerzen diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 2a994253a..84b3e814c 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,19 @@ +2001-10-05 Dirk Herrmann + + * numbers.h: Removed old comment about using SCM_CAR to access + non-pair cells. + + (SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Make sure + the return value is signed. Thanks to Brian Crowder for the bug + report. + + (SCM_SRS): Avoid unnecessary casting and don't unpack input + values. With this patch, SCM_SRS can be safely used for other + types than scm_t_signed_bits. However, it should still better be + an internal macro and thus be renamed to SCM_I_SRS. + + (SCM_MAKINUM, SCM_INUM): Use proper casting. + 2001-10-03 Gary Houston * continuations.h, unif.h: in the descriptions of the bit patterns diff --git a/libguile/numbers.h b/libguile/numbers.h index 350f43f3d..d12578127 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -51,39 +51,36 @@ -/* Immediate Numbers +/* Immediate Numbers, also known as fixnums * - * Inums are exact integer data that fits within an SCM word. - * - * SCM_INUMP applies only to values known to be Scheme objects. - * In particular, SCM_INUMP (SCM_CAR (x)) is valid only if x is known - * to be a SCM_CONSP. If x is only known to be a non-immediate, - * SCM_INUMP (SCM_CAR (x)) can give wrong answers. - */ + * Inums are exact integer data that fits within an SCM word. */ -#define SCM_I_FIXNUM_BIT (SCM_LONG_BIT - 2) -#define SCM_MOST_POSITIVE_FIXNUM ((1L << (SCM_I_FIXNUM_BIT - 1)) - 1) -#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM - 1) +#define SCM_I_FIXNUM_BIT \ + (SCM_LONG_BIT - 2) +#define SCM_MOST_POSITIVE_FIXNUM \ + ((((scm_t_signed_bits) 1) << (SCM_I_FIXNUM_BIT - 1)) - 1) +#define SCM_MOST_NEGATIVE_FIXNUM \ + (-((scm_t_signed_bits) SCM_MOST_POSITIVE_FIXNUM) - 1) /* SCM_SRS is signed right shift */ #if (-1 == (((-1) << 2) + 2) >> 2) -# define SCM_SRS(x, y) ((scm_t_signed_bits)(x) >> (y)) +# define SCM_SRS(x, y) ((x) >> (y)) #else -# define SCM_SRS(x, y) ((SCM_UNPACK (x) < 0) ? ~((~SCM_UNPACK (x)) >> (y)) : (SCM_UNPACK (x) >> (y))) +# define SCM_SRS(x, y) ((x) < 0 ? ~((~(x)) >> (y)) : ((x) >> (y))) #endif /* (-1 == (((-1) << 2) + 2) >> 2) */ #define SCM_INUMP(x) (2 & SCM_UNPACK (x)) #define SCM_NINUMP(x) (!SCM_INUMP (x)) -#define SCM_MAKINUM(x) (SCM_PACK (((x) << 2) + 2L)) -#define SCM_INUM(x) ((scm_t_signed_bits)(SCM_SRS (SCM_UNPACK (x), 2))) +#define SCM_MAKINUM(x) (SCM_PACK ((((scm_t_signed_bits) (x)) << 2) + 2)) +#define SCM_INUM(x) (SCM_SRS ((scm_t_signed_bits) SCM_UNPACK (x), 2)) /* SCM_FIXABLE is true if its long argument can be encoded in an SCM_INUM. */ #define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM) #define SCM_NEGFIXABLE(n) ((n) >= SCM_MOST_NEGATIVE_FIXNUM) -#define SCM_FIXABLE(n) (SCM_POSFIXABLE(n) && SCM_NEGFIXABLE(n)) +#define SCM_FIXABLE(n) (SCM_POSFIXABLE (n) && SCM_NEGFIXABLE (n)) /* A name for 0. */ From a599743cdc4864b233200300e65b52def6b8072b Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Fri, 5 Oct 2001 18:05:10 +0000 Subject: [PATCH 007/281] * Remove doc for read-and-eval! and eval2. --- doc/ref/ChangeLog | 6 ++++++ doc/ref/scheme-evaluation.texi | 15 --------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index b2dfb17e0..9f2eb9980 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,9 @@ +2001-10-05 Neil Jerram + + * scheme-evaluation.texi (Fly Evaluation): Removed documentation + for `read-and-eval!' and `eval2'. (Thanks to Alex Schroeder for + noticing that they'd disappeared!) + 2001-10-05 Thien-Thi Nguyen * scheme-io.texi (Writing): Add entry for `display'. diff --git a/doc/ref/scheme-evaluation.texi b/doc/ref/scheme-evaluation.texi index 210f26040..094214a76 100644 --- a/doc/ref/scheme-evaluation.texi +++ b/doc/ref/scheme-evaluation.texi @@ -224,21 +224,6 @@ Evaluate @var{exp} in the top-level environment specified by the current module. @end deffn -@deffn primitive eval2 obj env_thunk -Evaluate @var{exp}, a Scheme expression, in the environment -designated by @var{lookup}, a symbol-lookup function. -Do not use this version of eval, it does not play well -with the module system. Use @code{eval} or -@code{primitive-eval} instead. -@end deffn - -@deffn primitive read-and-eval! [port] -Read a form from @var{port} (standard input by default), and evaluate it -(memoizing it in the process) in the top-level environment. If no data -is left to be read from @var{port}, an @code{end-of-file} error is -signalled. -@end deffn - @node Loading @section Loading Scheme Code from File From 3dbacabc55535dcff956db1d40c5f6d85973176f Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Fri, 5 Oct 2001 18:26:46 +0000 Subject: [PATCH 008/281] * num2integral.i.c (NUM2INTEGRAL): Eliminated some warnings about testing an unsigned value for being >= 0. --- libguile/ChangeLog | 5 +++++ libguile/num2integral.i.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 84b3e814c..d01beda16 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-10-05 Dirk Herrmann + + * num2integral.i.c (NUM2INTEGRAL): Eliminated some warnings about + testing an unsigned value for being >= 0. + 2001-10-05 Dirk Herrmann * numbers.h: Removed old comment about using SCM_CAR to access diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index 61b1255c8..29e7effc0 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -35,6 +35,11 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) ITYPE res = 0; size_t l; +#ifdef UNSIGNED + if (SCM_BIGSIGN (num)) + scm_out_of_range (s_caller, num); +#endif + for (l = SCM_NUMDIGS (num); l--;) { ITYPE new = SCM_I_BIGUP (ITYPE, res) + SCM_BDIGITS (num)[l]; @@ -47,10 +52,10 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) res = new; } - if (SCM_BIGSIGN (num)) #ifdef UNSIGNED - scm_out_of_range (s_caller, num); + return res; #else + if (SCM_BIGSIGN (num)) { res = -res; if (res <= 0) @@ -58,7 +63,6 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) else scm_out_of_range (s_caller, num); } -#endif else { if (res >= 0) @@ -66,8 +70,7 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) else scm_out_of_range (s_caller, num); } - - return res; +#endif } else scm_wrong_type_arg (s_caller, pos, num); From 11d49f5489a88c3fa5f51993849f342db2c4bc4b Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Fri, 5 Oct 2001 20:18:30 +0000 Subject: [PATCH 009/281] * options.c (protected_objects, scm_init_options): The content of protected_objects is now protected from garbage collection using scm_gc_register_root instead of scm_permanent_object. (get_option_setting): New static function that computes an option setting as it was formerly done in the function scm_options. (get_documented_option_setting): New static function that returns option documentation as it was formerly done in the function scm_options. Note that documentation C strings are no longer precomputed into SCM objects. Instead, they are converted into SCM strings every time get_documented_option_setting is called. (change_option_setting): New static functions that modifies the option setting as it was formerly done in the function scm_options. The function is now exception safe, i. e. won't cause a memory leak when interrupted. Further, only non-immediate option values are added to the protection list. (scm_options): This function now has only the purpose to dispatch to to get_option_setting, get_documented_option_setting or change_option_setting, depending on the arguments given to scm_options. (scm_init_opts): Don't convert documentation C strings into SCM strings. Further, don't protect any object values: They _must_ be immediate values, otherwise there is no guarantee that they have not been collected before anyway. * options.[ch] (scm_t_option): Made type unsigned, name into a constant char* and val into a scm_t_bits type. (scm_options, scm_init_opts): The number of options is guaranteed to be larger or equal to zero. Thus, the type is changed to unsigned. --- libguile/ChangeLog | 39 ++++++++ libguile/options.c | 242 ++++++++++++++++++++++++++++----------------- libguile/options.h | 15 +-- 3 files changed, 193 insertions(+), 103 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index d01beda16..5f682e8dc 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,42 @@ +2001-10-05 Dirk Herrmann + + * options.c (protected_objects, scm_init_options): The content of + protected_objects is now protected from garbage collection using + scm_gc_register_root instead of scm_permanent_object. + + (get_option_setting): New static function that computes an option + setting as it was formerly done in the function scm_options. + + (get_documented_option_setting): New static function that + returns option documentation as it was formerly done in the + function scm_options. Note that documentation C strings are no + longer precomputed into SCM objects. Instead, they are converted + into SCM strings every time get_documented_option_setting is + called. + + (change_option_setting): New static functions that modifies the + option setting as it was formerly done in the function + scm_options. The function is now exception safe, i. e. won't + cause a memory leak when interrupted. Further, only non-immediate + option values are added to the protection list. + + (scm_options): This function now has only the purpose to dispatch + to to get_option_setting, get_documented_option_setting or + change_option_setting, depending on the arguments given to + scm_options. + + (scm_init_opts): Don't convert documentation C strings into SCM + strings. Further, don't protect any object values: They _must_ + be immediate values, otherwise there is no guarantee that they + have not been collected before anyway. + + * options.[ch] (scm_t_option): Made type unsigned, name into a + constant char* and val into a scm_t_bits type. + + (scm_options, scm_init_opts): The number of options is guaranteed + to be larger or equal to zero. Thus, the type is changed to + unsigned. + 2001-10-05 Dirk Herrmann * num2integral.i.c (NUM2INTEGRAL): Eliminated some warnings about diff --git a/libguile/options.c b/libguile/options.c index 74cb820f9..e95c12a85 100644 --- a/libguile/options.c +++ b/libguile/options.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation +/* Copyright (C) 1995,1996,1998,2000,2001 Free Software Foundation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,10 +42,10 @@ * The author can be reached at djurfeldt@nada.kth.se * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ - #include "libguile/_scm.h" +#include "libguile/mallocs.h" #include "libguile/strings.h" #include "libguile/options.h" @@ -116,118 +116,173 @@ SCM_SYMBOL (scm_yes_sym, "yes"); SCM_SYMBOL (scm_no_sym, "no"); -static SCM protected_objects; +static SCM protected_objects = SCM_EOL; -SCM -scm_options (SCM arg, scm_t_option options[], int n, const char *s) + +/* Return a list of the current option setting. The format of an option + * setting is described in the above documentation. */ +static SCM +get_option_setting (const scm_t_option options[], unsigned int n) { - int i, docp = (!SCM_UNBNDP (arg) && !SCM_NULLP (arg) && !SCM_CONSP (arg)); - /* Let `arg' GC protect the arguments */ - SCM new_mode = arg, ans = SCM_EOL, ls; - for (i = 0; i < n; ++i) + unsigned int i; + SCM ls = SCM_EOL; + for (i = 0; i != n; ++i) { - ls = docp ? scm_cons ((SCM) options[i].doc, SCM_EOL) : ans; switch (options[i].type) { case SCM_OPTION_BOOLEAN: - if (docp) - ls = scm_cons ((int) options[i].val - ? scm_yes_sym - : scm_no_sym, - ls); + if (options[i].val) + ls = scm_cons (SCM_PACK (options[i].name), ls); + break; + case SCM_OPTION_INTEGER: + ls = scm_cons (SCM_MAKINUM (options[i].val), ls); + ls = scm_cons (SCM_PACK (options[i].name), ls); + break; + case SCM_OPTION_SCM: + ls = scm_cons (SCM_PACK (options[i].val), ls); + ls = scm_cons (SCM_PACK (options[i].name), ls); + } + } + return ls; +} + + +/* Return a list of sublists, where each sublist contains option name, value + * and documentation string. */ +static SCM +get_documented_option_setting (const scm_t_option options[], unsigned int n) +{ + SCM ans = SCM_EOL; + unsigned int i; + + for (i = 0; i != n; ++i) + { + SCM ls = scm_cons (scm_str2string (options[i].doc), SCM_EOL); + switch (options[i].type) + { + case SCM_OPTION_BOOLEAN: + ls = scm_cons (options[i].val ? scm_yes_sym : scm_no_sym, ls); break; case SCM_OPTION_INTEGER: ls = scm_cons (SCM_MAKINUM (options[i].val), ls); break; case SCM_OPTION_SCM: - ls = scm_cons ((SCM) options[i].val, ls); + ls = scm_cons (SCM_PACK (options[i].val), ls); } - if (!((options[i].type == SCM_OPTION_BOOLEAN) - && !docp - && ! (int) options[i].val)) - ls = scm_cons ((SCM) options[i].name, ls); - ans = docp ? scm_cons (ls, ans) : ls; - } - if (!(SCM_UNBNDP (new_mode) || docp)) - { - unsigned long *flags; - flags = (unsigned long *) scm_must_malloc (n * sizeof (unsigned long), - "mode buffer"); - for (i = 0; i < n; ++i) - if (options[i].type == SCM_OPTION_BOOLEAN) - flags[i] = 0; - else - flags[i] = (unsigned long) options[i].val; - while (SCM_NNULLP (new_mode)) - { - SCM_ASSERT (SCM_CONSP (new_mode), - new_mode, - SCM_ARG1, - s); - for (i = 0; i < n; ++i) - if (SCM_CAR (new_mode) == (SCM) options[i].name) - switch (options[i].type) - { - case SCM_OPTION_BOOLEAN: - flags[i] = 1; - goto cont; - case SCM_OPTION_INTEGER: - new_mode = SCM_CDR (new_mode); - SCM_ASSERT ( SCM_CONSP (new_mode) - && SCM_INUMP (SCM_CAR (new_mode)), - new_mode, - SCM_ARG1, - s); - flags[i] = (unsigned long) SCM_INUM (SCM_CAR (new_mode)); - goto cont; - case SCM_OPTION_SCM: - new_mode = SCM_CDR (new_mode); - flags[i] = SCM_UNPACK (SCM_CAR (new_mode)); - goto cont; - } -#ifndef SCM_RECKLESS - scm_must_free ((char *) flags); - scm_misc_error (s, "Unknown mode flag: ~S", - scm_list_1 (SCM_CAR (new_mode))); -#endif - cont: - new_mode = SCM_CDR (new_mode); - } - for (i = 0; i < n; ++i) - { - /* scm_option doesn't know if its a long or an SCM */ - if (options[i].type == SCM_OPTION_SCM) - SCM_SETCDR (protected_objects, - scm_cons (SCM_PACK(flags[i]), - scm_delq1_x (SCM_PACK(options[i].val), - SCM_CDR (protected_objects)))); - options[i].val = flags[i]; - } - scm_must_free ((char *) flags); + ls = scm_cons (SCM_PACK (options[i].name), ls); + ans = scm_cons (ls, ans); } return ans; } -void -scm_init_opts (SCM (*func) (SCM), scm_t_option options[], int n) +/* Alters options according to the given option setting 'args'. The value of + * args is known to be a list, but it is not known whether the list is a well + * formed option setting, i. e. if for every non-boolean option a value is + * given. For this reason, the function applies all changes to a copy of the + * original setting in memory. Only if 'args' was successfully processed, + * the new setting will overwrite the old one. */ +static void +change_option_setting (SCM args, scm_t_option options[], unsigned int n, const char *s) { - int i; + unsigned int i; + SCM locally_protected_args = args; + SCM malloc_obj = scm_malloc_obj (n * sizeof (scm_t_bits)); + scm_t_bits *flags = (scm_t_bits *) SCM_MALLOCDATA (malloc_obj); - for (i = 0; i < n; ++i) + for (i = 0; i != n; ++i) { - SCM name; - SCM doc; + if (options[i].type == SCM_OPTION_BOOLEAN) + flags[i] = 0; + else + flags[i] = options[i].val; + } - name = scm_str2symbol (options[i].name); - options[i].name = (char *) name; - scm_permanent_object (name); - doc = scm_take0str (options[i].doc); - options[i].doc = (char *) doc; - scm_permanent_object (doc); + while (!SCM_NULLP (args)) + { + SCM name = SCM_CAR (args); + int found = 0; + + for (i = 0; i != n && !found; ++i) + { + if (SCM_EQ_P (name, SCM_PACK (options[i].name))) + { + switch (options[i].type) + { + case SCM_OPTION_BOOLEAN: + flags[i] = 1; + break; + case SCM_OPTION_INTEGER: + args = SCM_CDR (args); + SCM_ASSERT (SCM_CONSP (args), args, SCM_ARG1, s); + SCM_ASSERT (SCM_INUMP (SCM_CAR (args)), args, SCM_ARG1, s); + flags[i] = SCM_INUM (SCM_CAR (args)); + break; + case SCM_OPTION_SCM: + args = SCM_CDR (args); + SCM_ASSERT (SCM_CONSP (args), args, SCM_ARG1, s); + flags[i] = SCM_UNPACK (SCM_CAR (args)); + break; + } + found = 1; + } + } + + if (!found) + scm_misc_error (s, "Unknown option name: ~S", scm_list_1 (name)); + + args = SCM_CDR (args); + } + + for (i = 0; i != n; ++i) + { if (options[i].type == SCM_OPTION_SCM) - SCM_SETCDR (protected_objects, - scm_cons (SCM_PACK(options[i].val), SCM_CDR (protected_objects))); + { + SCM old = SCM_PACK (options[i].val); + SCM new = SCM_PACK (flags[i]); + if (!SCM_IMP (old)) + protected_objects = scm_delq1_x (old, protected_objects); + if (!SCM_IMP (new)) + protected_objects = scm_cons (new, protected_objects); + } + options[i].val = flags[i]; + } + + scm_remember_upto_here_2 (locally_protected_args, malloc_obj); +} + + +SCM +scm_options (SCM args, scm_t_option options[], unsigned int n, const char *s) +{ + if (SCM_UNBNDP (args)) + return get_option_setting (options, n); + else if (!SCM_NULLP (args) && !SCM_CONSP (args)) + /* Dirk:FIXME:: This criterion should be improved. IMO it is better to + * demand that args is #t if documentation should be shown than to say + * that every argument except a list will print out documentation. */ + return get_documented_option_setting (options, n); + else + { + SCM old_setting; + SCM_ASSERT (!SCM_FALSEP (scm_list_p (args)), args, 1, s); + old_setting = get_option_setting (options, n); + change_option_setting (args, options, n, s); + return old_setting; + } +} + + +void +scm_init_opts (SCM (*func) (SCM), scm_t_option options[], unsigned int n) +{ + unsigned int i; + + for (i = 0; i != n; ++i) + { + SCM name = scm_str2symbol (options[i].name); + options[i].name = (char *) SCM_UNPACK (name); + scm_permanent_object (name); } func (SCM_UNDEFINED); } @@ -236,7 +291,8 @@ scm_init_opts (SCM (*func) (SCM), scm_t_option options[], int n) void scm_init_options () { - protected_objects = scm_permanent_object (scm_cons (SCM_UNDEFINED, SCM_EOL)); + scm_gc_register_root (&protected_objects); + #ifndef SCM_MAGIC_SNARFER #include "libguile/options.x" #endif diff --git a/libguile/options.h b/libguile/options.h index 98f21c464..3ab28cb69 100644 --- a/libguile/options.h +++ b/libguile/options.h @@ -55,14 +55,9 @@ typedef struct scm_t_option { - int type; - char *name; - - /* - schizophrenic use: both SCM and int - */ - unsigned long val; - /* SCM val */ + unsigned int type; + const char *name; + scm_t_bits val; char *doc; } scm_t_option; @@ -72,8 +67,8 @@ typedef struct scm_t_option #define SCM_OPTION_SCM 2 -extern SCM scm_options (SCM new_mode, scm_t_option options[], int n, const char *s); -extern void scm_init_opts (SCM (*func) (SCM), scm_t_option options[], int n); +extern SCM scm_options (SCM, scm_t_option [], unsigned int, const char*); +extern void scm_init_opts (SCM (*) (SCM), scm_t_option [], unsigned int n); extern void scm_init_options (void); #endif /* SCM_OPTIONS_H */ From 6f2ec1d1f3c49974faa4f5fbfd8a86c747cf4dbc Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 6 Oct 2001 06:44:48 +0000 Subject: [PATCH 010/281] (quoted?, clump): New procs, exported. --- scripts/read-scheme-source | 88 +++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/scripts/read-scheme-source b/scripts/read-scheme-source index 1a9c0e59b..31d851bd2 100755 --- a/scripts/read-scheme-source +++ b/scripts/read-scheme-source @@ -76,6 +76,13 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ;; (use-modules (scripts read-scheme-source)) ;; (define source-forms (read-scheme-source-silently "FILE1" "FILE2" ...)) ;; +;; There are also two convenience procs exported for use by Scheme programs: +;; +;; (clump FORMS) --- filter FORMS combining contiguous comment forms that +;; have the same number of leading semicolons. +;; +;; (quoted? SYM FORM) --- see if FORM looks like: "(quote (SYM ...))", parse +;; the ":tags", and return alist of (TAG . VAL) elems. ;; ;; TODO: Add option "--clump-comments", maybe w/ different clumping styles. ;; Make `annotate!' extensible. @@ -84,7 +91,10 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (define-module (scripts read-scheme-source) :use-module (ice-9 rdelim) - :export (read-scheme-source read-scheme-source-silently)) + :export (read-scheme-source + read-scheme-source-silently + quoted? + clump)) ;; Try to figure out what FORM is and its various attributes. ;; Call proc NOTE! with key (a symbol) and value. @@ -179,6 +189,8 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (nb! form)))) (loop (1+ (port-line p)) (read-line p))))))) +;;; entry points + (define (read-scheme-source-silently . files) "See commentary in module (scripts read-scheme-source)." (let* ((res '())) @@ -193,6 +205,80 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (process file (lambda (e) (write e) (newline)))) files)) +;; Recognize: (quote (SYM :TAG1 VAL1 :TAG2 VAL2 ...)) +;; and return alist: ((TAG1 . VAL1) (TAG2 . VAL2) ...) +;; where the tags are symbols. +;; +(define (quoted? sym form) + (and (list? form) + (= 2 (length form)) + (eq? 'quote (car form)) + (let ((inside (cadr form))) + (and (list? inside) + (< 0 (length inside)) + (eq? sym (car inside)) + (let loop ((ls (cdr inside)) (alist '())) + (if (null? ls) + alist ; retval + (let ((first (car ls))) + (or (symbol? first) + (error "bad list!")) + (loop (cddr ls) + (acons (string->symbol + (substring (symbol->string first) 1)) + (cadr ls) + alist))))))))) + +;; Filter FORMS, combining contiguous comment forms that have the same number +;; of leading semicolons. Do not include in them whitespace lines. +;; Whitespace lines outside of such comment groupings are ignored, as are +;; hash-bang comments. All other forms are passed through unchanged. +;; +(define (clump forms) + (let loop ((forms forms) (acc '()) (pass-this-one-through? #f)) + (if (null? forms) + (reverse acc) ; retval + (let ((form (car forms))) + (cond (pass-this-one-through? + (loop (cdr forms) (cons form acc) #f)) + ((quoted? 'following-form-properties form) + (loop (cdr forms) (cons form acc) #t)) + ((quoted? 'whitespace form) ;;; ignore + (loop (cdr forms) acc #f)) + ((quoted? 'hash-bang-comment form) ;;; ignore for now + (loop (cdr forms) acc #f)) + ((quoted? 'comment form) + => (lambda (alist) + (let cloop ((inner-forms (cdr forms)) + (level (assq-ref alist 'leading-semicolons)) + (text (list (assq-ref alist 'text)))) + (let ((up (lambda () + (loop inner-forms + (cons (cons level (reverse text)) + acc) + #f)))) + (if (null? inner-forms) + (up) + (let ((inner-form (car inner-forms))) + (cond ((quoted? 'comment inner-form) + => (lambda (inner-alist) + (let ((new-level + (assq-ref + inner-alist + 'leading-semicolons))) + (if (= new-level level) + (cloop (cdr inner-forms) + level + (cons (assq-ref + inner-alist + 'text) + text)) + (up))))) + (else (up))))))))) + (else (loop (cdr forms) (cons form acc) #f))))))) + +;;; script entry point + (define main read-scheme-source) ;;; read-scheme-source ends here From 2d7cbf9e0baba2586239f55c29fdd6ba7db20055 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 6 Oct 2001 06:45:54 +0000 Subject: [PATCH 011/281] *** empty log message *** --- scripts/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/ChangeLog b/scripts/ChangeLog index d6445e73b..0aff09883 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2001-10-05 Thien-Thi Nguyen + + * read-scheme-source (quoted?, clump): New procs, exported. + 2001-09-30 Thien-Thi Nguyen * display-commentary (module-name->filename-frag, From 152812c0575076645a6f41940cac1133ce24ffa9 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Sat, 6 Oct 2001 16:30:20 +0000 Subject: [PATCH 012/281] * coop.c (mother_awake_p): New variable. (coop_create): Set mother_awake_p before creating or signalling mother; wait until mother is going to sleep before returning. (mother): Reset mother_awake_p before going to sleep. --- libguile/ChangeLog | 10 ++++++++++ libguile/coop.c | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 5f682e8dc..155d41d87 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,13 @@ +2001-10-06 Mikael Djurfeldt + + These changes fixes a race condition in the Guile coop - pthread + compatibility code. + + * coop.c (mother_awake_p): New variable. + (coop_create): Set mother_awake_p before creating or signalling + mother; wait until mother is going to sleep before returning. + (mother): Reset mother_awake_p before going to sleep. + 2001-10-05 Dirk Herrmann * options.c (protected_objects, scm_init_options): The content of diff --git a/libguile/coop.c b/libguile/coop.c index a6ef33ed2..987a71f9a 100644 --- a/libguile/coop.c +++ b/libguile/coop.c @@ -40,7 +40,7 @@ * If you do not wish that, delete this exception notice. */ -/* $Id: coop.c,v 1.27 2001-03-10 03:09:07 mdj Exp $ */ +/* $Id: coop.c,v 1.28 2001-10-06 16:30:20 mdj Exp $ */ /* Cooperative thread library, based on QuickThreads */ @@ -171,6 +171,7 @@ static pthread_cond_t coop_cond_quit; static pthread_cond_t coop_cond_create; static pthread_mutex_t coop_mutex_create; static pthread_t coop_mother; +static int mother_awake_p = 0; static coop_t *coop_child; #endif @@ -584,6 +585,7 @@ mother (void *dummy) NULL, dummy_start, coop_child); + mother_awake_p = 0; do res = pthread_cond_wait (&coop_cond_create, &coop_mutex_create); while (res == EINTR); @@ -618,6 +620,7 @@ coop_create (coop_userf_t *f, void *pu) t->n_keys = 0; #ifdef GUILE_PTHREAD_COMPAT coop_child = t; + mother_awake_p = 1; if (coop_quitting_p < 0) { coop_quitting_p = 0; @@ -635,7 +638,7 @@ coop_create (coop_userf_t *f, void *pu) * condition variable because they are not safe against * pre-emptive switching. */ - while (coop_child) + while (coop_child || mother_awake_p) usleep (0); #else t->sto = malloc (COOP_STKSIZE); From 004c0902ff70d23bcbf9dcea62f8d53e467e5c80 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 6 Oct 2001 19:58:02 +0000 Subject: [PATCH 013/281] * tags.h (SCM_T_BITS_MAX, SCM_T_SIGNED_BITS_MAX, SCM_T_SIGNED_BITS_MIN): New. * numbers.h (SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Use them to make these macros computable by the preprocessor. --- libguile/numbers.h | 10 +++------- libguile/tags.h | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libguile/numbers.h b/libguile/numbers.h index d12578127..f2a355ac5 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -55,13 +55,9 @@ * * Inums are exact integer data that fits within an SCM word. */ -#define SCM_I_FIXNUM_BIT \ - (SCM_LONG_BIT - 2) -#define SCM_MOST_POSITIVE_FIXNUM \ - ((((scm_t_signed_bits) 1) << (SCM_I_FIXNUM_BIT - 1)) - 1) -#define SCM_MOST_NEGATIVE_FIXNUM \ - (-((scm_t_signed_bits) SCM_MOST_POSITIVE_FIXNUM) - 1) - +#define SCM_I_FIXNUM_BIT (SCM_LONG_BIT - 2) +#define SCM_MOST_POSITIVE_FIXNUM (SCM_T_SIGNED_BITS_MAX/8-1) +#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1) /* SCM_SRS is signed right shift */ #if (-1 == (((-1) << 2) + 2) >> 2) diff --git a/libguile/tags.h b/libguile/tags.h index 6304a2625..e8e160dad 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -65,9 +65,15 @@ #ifdef HAVE_UINTPTR_T typedef uintptr_t scm_t_bits; typedef intptr_t scm_t_signed_bits; +#define SCM_T_BITS_MAX UINTPTR_MAX +#define SCM_T_SIGNED_BITS_MAX INTPTR_MAX +#define SCM_T_SIGNED_BITS_MIN INTPTR_MIN #else typedef unsigned long scm_t_bits; typedef signed long scm_t_signed_bits; +#define SCM_T_BITS_MAX ULONG_MAX +#define SCM_T_SIGNED_BITS_MAX LONG_MAX +#define SCM_T_SIGNED_BITS_MIN LONG_MIN #endif /* But as external interface, we use SCM, which may, according to the desired From dcb6a296dcf019c431076fc37375f30797ea38e9 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 6 Oct 2001 19:58:24 +0000 Subject: [PATCH 014/281] Define NO_PREPRO_MAGOC when including num2integral.c.i for `long long' and `signed long long'. --- libguile/numbers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libguile/numbers.c b/libguile/numbers.c index 596bacb33..b77e5add8 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4353,6 +4353,7 @@ scm_i_big2dbl (SCM b) #define ITYPE long long #define MIN_VALUE LLONG_MIN #define MAX_VALUE LLONG_MAX +#define NO_PREPRO_MAGIC #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2ulong_long @@ -4361,6 +4362,7 @@ scm_i_big2dbl (SCM b) #define UNSIGNED #define ITYPE unsigned long long #define MAX_VALUE ULLONG_MAX +#define NO_PREPRO_MAGIC #include "libguile/num2integral.i.c" #endif /* HAVE_LONG_LONGS */ From 801ba33101a882fc1146823f3c805b966cf2e31d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 6 Oct 2001 20:00:43 +0000 Subject: [PATCH 015/281] (INTEGRAL2NUM): Let the preprocessor test whether the integral type fits in a fixnum, not the compiler. This removes a spurious compiler warning. Also, honor the NO_PREPRO_MAGIC flag to suppress any preprocessor tests. This is needed for `long long's. --- libguile/num2integral.i.c | 42 ++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index 29e7effc0..acba57d1d 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -79,16 +79,43 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) SCM INTEGRAL2NUM (ITYPE n) { - if (sizeof (ITYPE) < sizeof (scm_t_signed_bits) - || -#ifndef UNSIGNED - SCM_FIXABLE (n) + /* Determine at compile time whether we need to porferm the FIXABLE + test or not. This is not done to get more optimal code out of + the compiler (it can figure this out on its already), but to + avoid a spurious warning. + */ + +#ifdef NEED_CHECK +#undef NEED_CHECK +#endif + +#ifdef NO_PREPRO_MAGIC +#define NEED_CHECK #else - SCM_POSFIXABLE (n) -#endif - ) +#ifdef UNSIGNED +#if MAX_VALUE > SCM_MOST_POSITIVE_FIXNUM +#define NEED_CHECK +#endif +#else +#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM +#define NEED_CHECK +#endif +#endif +#endif + +#ifndef UNSIGNED +#ifdef NEED_CHECK + if (SCM_FIXABLE (n)) +#endif +#else +#ifdef NEED_CHECK + if (SCM_FIXABLE (n)) +#endif +#endif return SCM_MAKINUM ((scm_t_signed_bits) n); +#undef NEED_CHECK + #ifdef SCM_BIGDIG return INTEGRAL2BIG (n); #else @@ -152,6 +179,7 @@ INTEGRAL2BIG (ITYPE n) #undef ITYPE #undef MIN_VALUE #undef MAX_VALUE +#undef NO_PREPRO_MAGIC /* Local Variables: From 71dcdbf9a0c198eecc0a51fd3c8897d63fcbe3c0 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 6 Oct 2001 20:01:36 +0000 Subject: [PATCH 016/281] *** empty log message *** --- libguile/ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 155d41d87..cca0c7b84 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,19 @@ +2001-10-06 Marius Vollmer + + * tags.h (SCM_T_BITS_MAX, SCM_T_SIGNED_BITS_MAX, + SCM_T_SIGNED_BITS_MIN): New. + * numbers.h (SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): + Use them to make these macros computable by the preprocessor. + + * num2integral.i.c (INTEGRAL2NUM): Let the preprocessor test + whether the integral type fits in a fixnum, not the compiler. + This removes a spurious compiler warning. Also, honor the + NO_PREPRO_MAGIC flag to suppress any preprocessor tests. This is + needed for `long long's. + + * numbers.c: Define NO_PREPRO_MAGOC when including + num2integral.c.i for `long long' and `signed long long'. + 2001-10-06 Mikael Djurfeldt These changes fixes a race condition in the Guile coop - pthread From c0060c9589ba8ca3638638f17b495c84b80f8154 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 6 Oct 2001 20:48:27 +0000 Subject: [PATCH 017/281] Corrected definition of SCM_MOST_POSITIVE_FIXNUM. Boy was I confused. --- libguile/numbers.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libguile/numbers.h b/libguile/numbers.h index f2a355ac5..e1dc39adc 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -55,8 +55,13 @@ * * Inums are exact integer data that fits within an SCM word. */ +/* SCM_T_SIGNED_MAX is (- (expt 2 n) 1), + * SCM_MOST_POSITIVE_FIXNUM should be (- (expt 2 (- n 2)) 1) + * which is the same as (/ (- (expt 2 n) 4) 4) + */ + #define SCM_I_FIXNUM_BIT (SCM_LONG_BIT - 2) -#define SCM_MOST_POSITIVE_FIXNUM (SCM_T_SIGNED_BITS_MAX/8-1) +#define SCM_MOST_POSITIVE_FIXNUM ((SCM_T_SIGNED_BITS_MAX-3)/4) #define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1) /* SCM_SRS is signed right shift */ @@ -83,7 +88,7 @@ #define SCM_INUM0 (SCM_MAKINUM (0)) -/* SCM_MAXEXP is the maximum double precision expontent +/* SCM_MAXEXP is the maximum double precision exponent * SCM_FLTMAX is less than or scm_equal the largest single precision float */ From ce191a26e6e5be7b2cdcb33a05505926340489d1 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 6 Oct 2001 20:49:10 +0000 Subject: [PATCH 018/281] Correct cut and paste error: use SCM_POSFIXABLE for unsigned types. --- libguile/num2integral.i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index acba57d1d..e81204433 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -109,7 +109,7 @@ INTEGRAL2NUM (ITYPE n) #endif #else #ifdef NEED_CHECK - if (SCM_FIXABLE (n)) + if (SCM_POSFIXABLE (n)) #endif #endif return SCM_MAKINUM ((scm_t_signed_bits) n); From c81f296a087281bab5a8708b2b16966e328c2363 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Mon, 8 Oct 2001 12:40:14 +0000 Subject: [PATCH 019/281] * emacs.scm (%%load-port, %%emacs-load, %%emacs-eval-request, %%emacs-select-frame, %%emacs-frame-eval, %%emacs-symdoc, %%apropos-internal): Use module-define! instead of builtin-variable. --- ice-9/ChangeLog | 7 +++++++ ice-9/emacs.scm | 25 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index abdf1fe75..3f5f18326 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,10 @@ +2001-10-08 Mikael Djurfeldt + + * emacs.scm (%%load-port, %%emacs-load, %%emacs-eval-request, + %%emacs-select-frame, %%emacs-frame-eval, %%emacs-symdoc, + %%apropos-internal): Use module-define! instead of + builtin-variable. + 2001-09-24 Mikael Djurfeldt * boot-9.scm (process-define-module): Added :re-export. diff --git a/ice-9/emacs.scm b/ice-9/emacs.scm index 85e9bd551..7673d52e5 100644 --- a/ice-9/emacs.scm +++ b/ice-9/emacs.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -278,10 +278,19 @@ ;;; A fix to get the emacs interface to work together with the module system. ;;; -(variable-set! (builtin-variable '%%load-port) load-port) -(variable-set! (builtin-variable '%%emacs-load) emacs-load) -(variable-set! (builtin-variable '%%emacs-eval-request) emacs-eval-request) -(variable-set! (builtin-variable '%%emacs-select-frame) emacs-select-frame) -(variable-set! (builtin-variable '%%emacs-frame-eval) emacs-frame-eval) -(variable-set! (builtin-variable '%%emacs-symdoc) emacs-symdoc) -(variable-set! (builtin-variable '%%apropos-internal) apropos-internal) +(for-each (lambda (name value) + (module-define! the-root-module name value)) + '(%%load-port + %%emacs-load + %%emacs-eval-request + %%emacs-select-frame + %%emacs-frame-eval + %%emacs-symdoc + %%apropos-internal) + (list load-port + emacs-load + emacs-eval-request + emacs-select-frame + emacs-frame-eval + emacs-symdoc + apropos-internal)) From ee083ac29f32c5657f02fae999701310bd7da7bf Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Mon, 8 Oct 2001 21:23:00 +0000 Subject: [PATCH 020/281] * hashtab.c (scm_hash_fn_create_handle_x): The result of assoc_fn is known to be #f if no entry is found. Thus, use !SCM_FALSEP instead of SCM_NIMP to test for that case. * strings.h (SCM_SET_STRING_LENGTH): Cast the length to scm_t_bits instead of long. --- libguile/ChangeLog | 9 +++++++++ libguile/hashtab.c | 21 +++++++++++---------- libguile/strings.h | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index cca0c7b84..9c76c0f6a 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,12 @@ +2001-10-08 Dirk Herrmann + + * hashtab.c (scm_hash_fn_create_handle_x): The result of assoc_fn + is known to be #f if no entry is found. Thus, use !SCM_FALSEP + instead of SCM_NIMP to test for that case. + + * strings.h (SCM_SET_STRING_LENGTH): Cast the length to + scm_t_bits instead of long. + 2001-10-06 Marius Vollmer * tags.h (SCM_T_BITS_MAX, SCM_T_SIGNED_BITS_MAX, diff --git a/libguile/hashtab.c b/libguile/hashtab.c index ca06b2030..dc5545390 100644 --- a/libguile/hashtab.c +++ b/libguile/hashtab.c @@ -96,20 +96,21 @@ scm_hash_fn_create_handle_x (SCM table,SCM obj,SCM init,unsigned long (*hash_fn) scm_out_of_range ("hash_fn_create_handle_x", scm_ulong2num (k)); SCM_REDEFER_INTS; it = assoc_fn (obj, SCM_VELTS (table)[k], closure); - if (SCM_NIMP (it)) + if (!SCM_FALSEP (it)) { SCM_REALLOW_INTS; return it; } - { - SCM new_bucket; - SCM old_bucket; - old_bucket = SCM_VELTS (table)[k]; - new_bucket = scm_acons (obj, init, old_bucket); - SCM_VELTS(table)[k] = new_bucket; - SCM_REALLOW_INTS; - return SCM_CAR (new_bucket); - } + else + { + SCM new_bucket; + SCM old_bucket; + old_bucket = SCM_VELTS (table)[k]; + new_bucket = scm_acons (obj, init, old_bucket); + SCM_VELTS(table)[k] = new_bucket; + SCM_REALLOW_INTS; + return SCM_CAR (new_bucket); + } } #undef FUNC_NAME diff --git a/libguile/strings.h b/libguile/strings.h index 271497a5d..2c943d17c 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -56,7 +56,7 @@ #define SCM_SET_STRING_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c))) #define SCM_STRING_MAX_LENGTH ((1UL << 24) - 1UL) #define SCM_STRING_LENGTH(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 8)) -#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), (((long) (l)) << 8) + scm_tc7_string)) +#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), (((scm_t_bits) (l)) << 8) + scm_tc7_string)) From 5e137c657b2d3e87ed94771b060c6ebd0cb02b69 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 9 Oct 2001 03:32:12 +0000 Subject: [PATCH 021/281] *** empty log message *** --- AUTHORS | 6 ++++++ NEWS | 5 +++-- libguile/ChangeLog | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2eeba2c1b..74cdb2ba1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -316,3 +316,9 @@ In the subdirectory libguile, changes to: keywords.c list.c strports.c tag.c Makefile.am guile-snarf.awk.in Many other changes throughout. + +Stefan Jahn: +In the subdirectory libguile, changes to: + continuations.h + continuations.c + gc.c diff --git a/NEWS b/NEWS index d97db2ee7..0634cd840 100644 --- a/NEWS +++ b/NEWS @@ -55,8 +55,9 @@ See INSTALL and README for more information. ** Guile is much more likely to work on 64-bit architectures. Guile now compiles and passes "make check" with only two UNRESOLVED GC -cases on Alpha based machines now. Thanks to John Goerzen for the use -of a test machine. +cases on Alpha and ia64 based machines now. Thanks to John Goerzen +for the use of a test machine, and thanks to Stefan Jahn for ia64 +patches. ** New functions: setitimer and getitimer. diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 9c76c0f6a..f099fbdd7 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,17 @@ +2001-10-08 Rob Browning + + * gc.c: support ia64 register backing store. + (SCM_MARK_BACKING_STORE): new macro. + + * continuations.h: support ia64 register backing store. + (struct scm_t_contregs): add ia64 register backing store. + + * continuations.c: support ia64 register backing store. + (continuation_mark): mark ia64 register backing store. + (continuation_free): free ia64 register backing store. + (scm_make_continuation): capture ia64 register backing store. + (copy_stack_and_call): copy ia64 register backing store. + 2001-10-08 Dirk Herrmann * hashtab.c (scm_hash_fn_create_handle_x): The result of assoc_fn From 193297d8b5e46d3077059587190b33a8651cb752 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 9 Oct 2001 03:32:20 +0000 Subject: [PATCH 022/281] * continuations.c: support ia64 register backing store. (continuation_mark): mark ia64 register backing store. (continuation_free): free ia64 register backing store. (scm_make_continuation): capture ia64 register backing store. (copy_stack_and_call): copy ia64 register backing store. --- libguile/continuations.c | 55 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/libguile/continuations.c b/libguile/continuations.c index d3fbd6b93..586ab1f0d 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -73,6 +73,12 @@ continuation_mark (SCM obj) scm_gc_mark (continuation->throw_value); scm_mark_locations (continuation->stack, continuation->num_stack_items); +#ifdef __ia64__ + if (continuation->backing_store) + scm_mark_locations (continuation->backing_store, + continuation->backing_store_size / + sizeof (SCM_STACKITEM)); +#endif /* __ia64__ */ return continuation->dynenv; } @@ -86,7 +92,11 @@ continuation_free (SCM obj) : 0; size_t bytes_free = sizeof (scm_t_contregs) + extra_items * sizeof (SCM_STACKITEM); - + +#ifdef __ia64__ + bytes_free += continuation->backing_store_size; + scm_must_free (continuation->backing_store); +#endif /* __ia64__ */ scm_must_free (continuation); return bytes_free; } @@ -104,6 +114,16 @@ continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED) return 1; } +#ifdef __ia64__ +struct rv +{ + long retval; + long first_return; +}; +extern struct rv getcontext (ucontext_t *); +extern int setcontext (ucontext_t *); +#endif /* __ia64__ */ + /* this may return more than once: the first time with the escape procedure, then subsequently with the value to be passed to the continuation. */ @@ -116,6 +136,9 @@ scm_make_continuation (int *first) scm_t_contregs *rootcont = SCM_CONTREGS (scm_rootcont); long stack_size; SCM_STACKITEM * src; +#ifdef __ia64__ + struct rv rv; +#endif SCM_ENTER_A_SECTION; SCM_FLUSH_REGISTER_WINDOWS; @@ -139,6 +162,28 @@ scm_make_continuation (int *first) #endif memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size); +#ifdef __ia64__ + rv = getcontext (&continuation->ctx); + if (rv.first_return) + { + continuation->backing_store_size = + continuation->ctx.uc_mcontext.sc_ar_bsp - + __libc_ia64_register_backing_store_base; + continuation->backing_store = NULL; + continuation->backing_store = + scm_must_malloc (continuation->backing_store_size, FUNC_NAME); + memcpy (continuation->backing_store, + (void *) __libc_ia64_register_backing_store_base, + continuation->backing_store_size); + *first = 1; + return cont; + } + else + { + *first = 0; + return continuation->throw_value; + } +#else /* !__ia64__ */ if (setjmp (continuation->jmpbuf)) { *first = 0; @@ -149,6 +194,7 @@ scm_make_continuation (int *first) *first = 1; return cont; } +#endif /* !__ia64__ */ } #undef FUNC_NAME @@ -189,7 +235,14 @@ copy_stack_and_call (scm_t_contregs *continuation, SCM val, #endif continuation->throw_value = val; +#ifdef __ia64__ + memcpy ((void *) __libc_ia64_register_backing_store_base, + continuation->backing_store, + continuation->backing_store_size); + setcontext (&continuation->ctx); +#else longjmp (continuation->jmpbuf, 1); +#endif } From 766c5eaf49da2d1fd1027870a62cb4c3b5ea2f41 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 9 Oct 2001 03:33:06 +0000 Subject: [PATCH 023/281] * continuations.h: support ia64 register backing store. (struct scm_t_contregs): add ia64 register backing store. --- libguile/continuations.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libguile/continuations.h b/libguile/continuations.h index 21616173c..4a0c55ca1 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -48,6 +48,10 @@ #include "libguile/__scm.h" +#ifdef __ia64__ +#include +extern unsigned long __libc_ia64_register_backing_store_base; +#endif /* a continuation SCM is a non-immediate pointing to a heap cell with: @@ -65,6 +69,11 @@ typedef struct SCM throw_value; jmp_buf jmpbuf; SCM dynenv; +#ifdef __ia64__ + ucontext_t ctx; + void *backing_store; + unsigned long backing_store_size; +#endif /* __ia64__ */ SCM_STACKITEM *base; /* base of the live stack, before it was saved. */ size_t num_stack_items; /* size of the saved stack. */ unsigned long seq; /* dynamic root identifier. */ From d9189652722d4deec57d74e001ccdaab8ddfa394 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 9 Oct 2001 03:33:16 +0000 Subject: [PATCH 024/281] * gc.c: support ia64 register backing store. (SCM_MARK_BACKING_STORE): new macro. --- libguile/gc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libguile/gc.c b/libguile/gc.c index 3a2aeba22..4808625cf 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -52,6 +52,11 @@ #include #include +#ifdef __ia64__ +#include +extern unsigned long __libc_ia64_register_backing_store_base; +#endif + #include "libguile/_scm.h" #include "libguile/eval.h" #include "libguile/stime.h" @@ -1029,6 +1034,20 @@ scm_t_c_hook scm_before_sweep_c_hook; scm_t_c_hook scm_after_sweep_c_hook; scm_t_c_hook scm_after_gc_c_hook; +#ifdef __ia64__ +# define SCM_MARK_BACKING_STORE() do { \ + ucontext_t ctx; \ + SCM_STACKITEM * top, * bot; \ + getcontext (&ctx); \ + scm_mark_locations ((SCM_STACKITEM *) &ctx.uc_mcontext, \ + ((size_t) (sizeof (SCM_STACKITEM) - 1 + sizeof ctx.uc_mcontext) \ + / sizeof (SCM_STACKITEM))); \ + bot = (SCM_STACKITEM *) __libc_ia64_register_backing_store_base; \ + top = (SCM_STACKITEM *) ctx.uc_mcontext.sc_ar_bsp; \ + scm_mark_locations (bot, top - bot); } while (0) +#else +# define SCM_MARK_BACKING_STORE() +#endif void scm_igc (const char *what) @@ -1084,6 +1103,7 @@ scm_igc (const char *what) scm_mark_locations (scm_stack_base - stack_len, stack_len); #endif } + SCM_MARK_BACKING_STORE(); #else /* USE_THREADS */ From 79d34f68e7bc6cb534a6392d2d145dba9ac86a2b Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Tue, 9 Oct 2001 20:56:36 +0000 Subject: [PATCH 025/281] * numbers.c (mem2decimal_from_point): Cleaned up the parsing a little bit - should even be somewhat more accurate now. --- libguile/ChangeLog | 5 +++++ libguile/numbers.c | 26 +++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index f099fbdd7..e37cf5399 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-10-09 Dirk Herrmann + + * numbers.c (mem2decimal_from_point): Cleaned up the parsing a + little bit - should even be somewhat more accurate now. + 2001-10-08 Rob Browning * gc.c: support ia64 register backing store. diff --git a/libguile/numbers.c b/libguile/numbers.c index b77e5add8..24d9c9bf5 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -39,7 +39,6 @@ * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ - #include @@ -2343,31 +2342,29 @@ mem2uinteger (const char* mem, size_t len, unsigned int *p_idx, /* R5RS, section 7.1.1, lexical structure of numbers: . Only * covers the parts of the rules that start at a potential point. The value * of the digits up to the point have been parsed by the caller and are given - * in variable prepoint. The content of *p_exactness indicates, whether a - * hash has already been seen in the digits before the point. + * in variable result. The content of *p_exactness indicates, whether a hash + * has already been seen in the digits before the point. */ /* In non ASCII-style encodings the following macro might not work. */ #define DIGIT2UINT(d) ((d) - '0') static SCM -mem2decimal_from_point (SCM prepoint, const char* mem, size_t len, +mem2decimal_from_point (SCM result, const char* mem, size_t len, unsigned int *p_idx, enum t_exactness *p_exactness) { unsigned int idx = *p_idx; enum t_exactness x = *p_exactness; - SCM big_shift = SCM_MAKINUM (1); - SCM big_add = SCM_MAKINUM (0); - SCM result; if (idx == len) - return prepoint; + return result; if (mem[idx] == '.') { scm_t_bits shift = 1; scm_t_bits add = 0; unsigned int digit_value; + SCM big_shift = SCM_MAKINUM (1); idx++; while (idx != len) @@ -2392,9 +2389,9 @@ mem2decimal_from_point (SCM prepoint, const char* mem, size_t len, if (SCM_MOST_POSITIVE_FIXNUM / 10 < shift) { big_shift = scm_product (big_shift, SCM_MAKINUM (shift)); - big_add = scm_product (big_add, SCM_MAKINUM (shift)); + result = scm_product (result, SCM_MAKINUM (shift)); if (add > 0) - big_add = scm_sum (big_add, SCM_MAKINUM (add)); + result = scm_sum (result, SCM_MAKINUM (add)); shift = 10; add = digit_value; @@ -2409,17 +2406,16 @@ mem2decimal_from_point (SCM prepoint, const char* mem, size_t len, if (add > 0) { big_shift = scm_product (big_shift, SCM_MAKINUM (shift)); - big_add = scm_product (big_add, SCM_MAKINUM (shift)); - big_add = scm_sum (big_add, SCM_MAKINUM (add)); + result = scm_product (result, SCM_MAKINUM (shift)); + result = scm_sum (result, SCM_MAKINUM (add)); } + result = scm_divide (result, big_shift); + /* We've seen a decimal point, thus the value is implicitly inexact. */ x = INEXACT; } - big_add = scm_divide (big_add, big_shift); - result = scm_sum (prepoint, big_add); - if (idx != len) { int sign = 1; From 37c56aecf830c10f43d122659584674e61e974ba Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 11 Oct 2001 22:26:25 +0000 Subject: [PATCH 026/281] * debug.c (scm_make_iloc): Prefer !SCM_ over SCM_N. (scm_memcons, scm_mem_to_proc): When building lists, prefer scm_list_ over scm_cons[2]?. (scm_mem_to_proc): Prefer SCM_CONSP over SCM_NIMP. (scm_procedure_name): Use SCM_CADR instead of explicit form. (debugobj_print): Coerce scm_intprint arg 1 to long, not int. Thanks to Rob Browning for the patch (see log entry 2001-09-21) - for some reason his patch didn't make it into the cvs. --- libguile/ChangeLog | 15 +++++++++++++++ libguile/debug.c | 16 ++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index e37cf5399..8c51b00a6 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,18 @@ +2001-10-11 Dirk Herrmann + + * debug.c (scm_make_iloc): Prefer !SCM_ over SCM_N. + + (scm_memcons, scm_mem_to_proc): When building lists, prefer + scm_list_ over scm_cons[2]?. + + (scm_mem_to_proc): Prefer SCM_CONSP over SCM_NIMP. + + (scm_procedure_name): Use SCM_CADR instead of explicit form. + + (debugobj_print): Coerce scm_intprint arg 1 to long, not int. + Thanks to Rob Browning for the patch (see log entry 2001-09-21) - + for some reason his patch didn't make it into the cvs. + 2001-10-09 Dirk Herrmann * numbers.c (mem2decimal_from_point): Cleaned up the parsing a diff --git a/libguile/debug.c b/libguile/debug.c index d4a97e260..6e1979bb0 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -47,6 +47,7 @@ #include "libguile/_scm.h" #include "libguile/eval.h" +#include "libguile/list.h" #include "libguile/stackchk.h" #include "libguile/throw.h" #include "libguile/macros.h" @@ -251,7 +252,7 @@ SCM_DEFINE (scm_make_iloc, "make-iloc", 3, 0, 0, SCM_VALIDATE_INUM (2,binding); return SCM_PACK (SCM_UNPACK (SCM_ILOC00) + SCM_IFRINC * SCM_INUM (frame) - + (SCM_NFALSEP (cdrp) ? SCM_ICDR : 0) + + (!SCM_FALSEP (cdrp) ? SCM_ICDR : 0) + SCM_IDINC * SCM_INUM (binding)); } #undef FUNC_NAME @@ -276,7 +277,7 @@ SCM_DEFINE (scm_memcons, "memcons", 2, 1, 0, /*fixme* environments may be two different but equal top-level envs */ if (!SCM_UNBNDP (env) && SCM_MEMOIZED_ENV (car) != env) SCM_MISC_ERROR ("environment mismatch arg1 <-> arg3", - scm_cons2 (car, env, SCM_EOL)); + scm_list_2 (car, env)); else env = SCM_MEMOIZED_ENV (car); car = SCM_MEMOIZED_EXP (car); @@ -285,7 +286,7 @@ SCM_DEFINE (scm_memcons, "memcons", 2, 1, 0, { if (!SCM_UNBNDP (env) && SCM_MEMOIZED_ENV (cdr) != env) SCM_MISC_ERROR ("environment mismatch arg2 <-> arg3", - scm_cons2 (cdr, env, SCM_EOL)); + scm_list_2 (cdr, env)); else env = SCM_MEMOIZED_ENV (cdr); cdr = SCM_MEMOIZED_EXP (cdr); @@ -308,9 +309,8 @@ SCM_DEFINE (scm_mem_to_proc, "mem->proc", 1, 0, 0, SCM_VALIDATE_MEMOIZED (1,obj); env = SCM_MEMOIZED_ENV (obj); obj = SCM_MEMOIZED_EXP (obj); - if (!(SCM_NIMP (obj) && SCM_CAR (obj) == SCM_IM_LAMBDA)) - SCM_MISC_ERROR ("expected lambda expression", - scm_cons (obj, SCM_EOL)); + if (!SCM_CONSP (obj) || !SCM_EQ_P (CAR (obj), SCM_IM_LAMBDA)) + SCM_MISC_ERROR ("expected lambda expression", scm_list_1 (obj)); return scm_closure (SCM_CDR (obj), env); } #undef FUNC_NAME @@ -362,7 +362,7 @@ SCM_DEFINE (scm_procedure_name, "procedure-name", 1, 0, 0, SCM name = scm_procedure_property (proc, scm_sym_name); #if 0 /* Source property scm_sym_procname not implemented yet... */ - SCM name = scm_source_property (SCM_CAR (SCM_CDR (SCM_CODE (proc))), scm_sym_procname); + SCM name = scm_source_property (SCM_CADR (SCM_CODE (proc)), scm_sym_procname); if (SCM_FALSEP (name)) name = scm_procedure_property (proc, scm_sym_name); #endif @@ -521,7 +521,7 @@ static int debugobj_print (SCM obj, SCM port, scm_print_state *pstate SCM_UNUSED) { scm_puts ("#', port); return 1; } From d5cf5324a3a9c8f0202d1bd49aacc98bbe331f55 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 11 Oct 2001 23:20:52 +0000 Subject: [PATCH 027/281] * print.c (scm_print_state_vtable, print_state_pool): Initialize. These variables are now registered as gc roots. (scm_current_pstate): Update documentation. (scm_current_pstate, scm_make_print_state, scm_free_print_state, scm_prin1, scm_init_print): print_state_pool is registered as a gc root and thus does not need to be protected by a surrounding pair any more. (make_print_state): The car of print_state_pool no longer holds the scm_print_state_vtable. (scm_current_pstate, scm_make_print_state, print_circref, scm_iprin1, scm_prin1, scm_iprlist): Prefer !SCM_ over SCM_N. (scm_prin1): When building lists, prefer scm_list_ over scm_cons[2]?. (scm_iprlist): Removed a redundant SCM_IMP test. (scm_simple_format): Use SCM_EQ_P to compare SCM values. --- libguile/ChangeLog | 26 +++++++++++++++++++++ libguile/print.c | 57 +++++++++++++++++++++++----------------------- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 8c51b00a6..ca9ed8bc6 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,29 @@ +2001-10-12 Dirk Herrmann + + * print.c (scm_print_state_vtable, print_state_pool): + Initialize. These variables are now registered as gc roots. + + (scm_current_pstate): Update documentation. + + (scm_current_pstate, scm_make_print_state, scm_free_print_state, + scm_prin1, scm_init_print): print_state_pool is registered as a + gc root and thus does not need to be protected by a surrounding + pair any more. + + (make_print_state): The car of print_state_pool no longer holds + the scm_print_state_vtable. + + (scm_current_pstate, scm_make_print_state, print_circref, + scm_iprin1, scm_prin1, scm_iprlist): Prefer !SCM_ over + SCM_N. + + (scm_prin1): When building lists, prefer scm_list_ over + scm_cons[2]?. + + (scm_iprlist): Removed a redundant SCM_IMP test. + + (scm_simple_format): Use SCM_EQ_P to compare SCM values. + 2001-10-11 Dirk Herrmann * debug.c (scm_make_iloc): Prefer !SCM_ over SCM_N. diff --git a/libguile/print.c b/libguile/print.c index e207f411a..31b12e5ce 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -185,21 +185,20 @@ do { \ #define EXIT_NESTED_DATA(pstate) { --pstate->top; } -SCM scm_print_state_vtable; - -static SCM print_state_pool; +SCM scm_print_state_vtable = SCM_BOOL_F; +static SCM print_state_pool = SCM_EOL; #ifdef GUILE_DEBUG /* Used for debugging purposes */ SCM_DEFINE (scm_current_pstate, "current-pstate", 0, 0, 0, (), - "Return the current-pstate -- the cadr of the\n" + "Return the current-pstate -- the car of the\n" "@code{print_state_pool}. @code{current-pstate} is only\n" "included in @code{--enable-guile-debug} builds.") #define FUNC_NAME s_scm_current_pstate { - if (SCM_NNULLP (SCM_CDR (print_state_pool))) - return SCM_CADR (print_state_pool); + if (!SCM_NULLP (print_state_pool)) + return SCM_CAR (print_state_pool); else return SCM_BOOL_F; } @@ -212,9 +211,8 @@ SCM_DEFINE (scm_current_pstate, "current-pstate", 0, 0, 0, static SCM make_print_state (void) { - SCM print_state = scm_make_struct (SCM_CAR (print_state_pool), /* pstate type */ - SCM_INUM0, - SCM_EOL); + SCM print_state + = scm_make_struct (scm_print_state_vtable, SCM_INUM0, SCM_EOL); scm_print_state *pstate = SCM_PRINT_STATE (print_state); pstate->ref_vect = scm_c_make_vector (PSTATE_SIZE, SCM_UNDEFINED); pstate->ref_stack = SCM_VELTS (pstate->ref_vect); @@ -229,10 +227,10 @@ scm_make_print_state () /* First try to allocate a print state from the pool */ SCM_DEFER_INTS; - if (SCM_NNULLP (SCM_CDR (print_state_pool))) + if (!SCM_NULLP (print_state_pool)) { - answer = SCM_CADR (print_state_pool); - SCM_SETCDR (print_state_pool, SCM_CDDR (print_state_pool)); + answer = SCM_CAR (print_state_pool); + print_state_pool = SCM_CDR (print_state_pool); } SCM_ALLOW_INTS; @@ -254,8 +252,8 @@ scm_free_print_state (SCM print_state) SCM_NEWCELL (handle); SCM_DEFER_INTS; SCM_SET_CELL_WORD_0 (handle, print_state); - SCM_SET_CELL_WORD_1 (handle, SCM_CDR (print_state_pool)); - SCM_SETCDR (print_state_pool, handle); + SCM_SET_CELL_WORD_1 (handle, print_state_pool); + print_state_pool = handle; SCM_ALLOW_INTS; } @@ -288,7 +286,7 @@ print_circref (SCM port,scm_print_state *pstate,SCM ref) { while (i > 0) { - if (SCM_NCONSP (pstate->ref_stack[i - 1]) + if (!SCM_CONSP (pstate->ref_stack[i - 1]) || !SCM_EQ_P (SCM_CDR (pstate->ref_stack[i - 1]), pstate->ref_stack[i])) break; @@ -607,7 +605,7 @@ scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate) /* Print gsubrs as primitives */ SCM name = scm_procedure_name (exp); scm_puts ("#revealed) { SCM_DEFER_INTS; - SCM_SETCDR (handle, SCM_CDR (print_state_pool)); - SCM_SETCDR (print_state_pool, handle); + SCM_SETCDR (handle, print_state_pool); + print_state_pool = handle; SCM_ALLOW_INTS; } } @@ -764,7 +762,7 @@ scm_iprlist (char *hdr,SCM exp,int tlr,SCM port,scm_print_state *pstate) if (SCM_EQ_P (hare, tortoise)) goto fancy_printing; hare = SCM_CDR (hare); - if (SCM_IMP (hare) || SCM_NCONSP (hare)) + if (!SCM_CONSP (hare)) break; hare = SCM_CDR (hare); tortoise = SCM_CDR (tortoise); @@ -825,7 +823,7 @@ fancy_printing: scm_iprin1 (SCM_CAR (exp), port, pstate); } } - if (SCM_NNULLP (exp)) + if (!SCM_NULLP (exp)) { scm_puts (" . ", port); scm_iprin1 (exp, port, pstate); @@ -979,7 +977,7 @@ SCM_DEFINE (scm_simple_format, "simple-format", 2, 0, 1, } scm_lfwrite (start, p - start, destination); - if (args != SCM_EOL) + if (!SCM_EQ_P (args, SCM_EOL)) SCM_MISC_ERROR ("FORMAT: ~A superfluous arguments", scm_list_1 (scm_length (args))); @@ -1094,14 +1092,15 @@ void scm_init_print () { SCM vtable, layout, type; - + scm_init_opts (scm_print_options, scm_print_opts, SCM_N_PRINT_OPTIONS); + + scm_gc_register_root (&print_state_pool); + scm_gc_register_root (&scm_print_state_vtable); vtable = scm_make_vtable_vtable (scm_nullstr, SCM_INUM0, SCM_EOL); layout = scm_make_struct_layout (scm_makfrom0str (SCM_PRINT_STATE_LAYOUT)); type = scm_make_struct (vtable, SCM_INUM0, scm_list_1 (layout)); scm_set_struct_vtable_name_x (type, scm_str2symbol ("print-state")); - print_state_pool = scm_permanent_object (scm_cons (type, SCM_EOL)); - scm_print_state_vtable = type; /* Don't want to bind a wrapper class in GOOPS, so pass 0 as arg1. */ From 68665a970864f16cb9e1a19411ab11dbf2ae138c Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Fri, 12 Oct 2001 08:55:05 +0000 Subject: [PATCH 028/281] * validate.h (SCM_VALIDATE_DOUBLE_DEF_COPY): New macro. --- libguile/ChangeLog | 6 ++++++ libguile/validate.h | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index ca9ed8bc6..ded18c105 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2001-10-12 Mikael Djurfeldt + + * debug.c (scm_mem_to_proc): Fixed typo in previous change. + + * validate.h (SCM_VALIDATE_DOUBLE_DEF_COPY): New macro. + 2001-10-12 Dirk Herrmann * print.c (scm_print_state_vtable, print_state_pool): diff --git a/libguile/validate.h b/libguile/validate.h index f7b7aec53..21aadbe57 100644 --- a/libguile/validate.h +++ b/libguile/validate.h @@ -293,6 +293,19 @@ } \ } while (0) +#define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \ + do { \ + if (SCM_UNBNDP (k)) \ + { \ + k = scm_make_real (default); \ + cvar = default; \ + } \ + else \ + { \ + cvar = SCM_NUM2DOUBLE (pos, k); \ + } \ + } while (0) + /* [low,high) */ #define SCM_VALIDATE_INUM_RANGE(pos,k,low,high) \ do { SCM_ASSERT(SCM_INUMP(k), k, pos, FUNC_NAME); \ From aa5e5d63eb611ad7985978bf9301cc85764e6cdb Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Fri, 12 Oct 2001 09:02:03 +0000 Subject: [PATCH 029/281] * debug.c (scm_mem_to_proc): Fixed typo in previous change. --- libguile/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/debug.c b/libguile/debug.c index 6e1979bb0..0f5373e5c 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -309,7 +309,7 @@ SCM_DEFINE (scm_mem_to_proc, "mem->proc", 1, 0, 0, SCM_VALIDATE_MEMOIZED (1,obj); env = SCM_MEMOIZED_ENV (obj); obj = SCM_MEMOIZED_EXP (obj); - if (!SCM_CONSP (obj) || !SCM_EQ_P (CAR (obj), SCM_IM_LAMBDA)) + if (!SCM_CONSP (obj) || !SCM_EQ_P (SCM_CAR (obj), SCM_IM_LAMBDA)) SCM_MISC_ERROR ("expected lambda expression", scm_list_1 (obj)); return scm_closure (SCM_CDR (obj), env); } From b7d9b1cf5a1e1736b416e2e2dea1da46710154ba Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 13 Oct 2001 12:29:44 +0000 Subject: [PATCH 030/281] * tests/numbers.test: Added a test case that checks if valid number strings are transformed correctly by string->number. --- test-suite/ChangeLog | 5 ++++ test-suite/tests/numbers.test | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index c70fc90ed..dbdec40cb 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,8 @@ +2001-10-13 Dirk Herrmann + + * tests/numbers.test: Added a test case that checks if valid + number strings are transformed correctly by string->number. + 2001-09-21 Rob Browning * tests/numbers.test (fixnum-bit): compute dynamically. diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test index ad02d62cb..ab3b80234 100644 --- a/test-suite/tests/numbers.test +++ b/test-suite/tests/numbers.test @@ -867,6 +867,59 @@ "#i#i1" "12@12+0i")) #t) + (pass-if "valid number strings" + (for-each (lambda (couple) + (apply + (lambda (x y) + (let ((x (string->number x))) + (if (or (eq? x #f) (not (eqv? x y))) (throw 'fail)))) + couple)) + `(;; Radix: + ("#b0" 0) ("#B0" 0) ("#b1" 1) ("#B1" 1) ("#o0" 0) ("#O0" 0) + ("#o1" 1) ("#O1" 1) ("#o2" 2) ("#O2" 2) ("#o3" 3) ("#O3" 3) + ("#o4" 4) ("#O4" 4) ("#o5" 5) ("#O5" 5) ("#o6" 6) ("#O6" 6) + ("#o7" 7) ("#O7" 7) ("#d0" 0) ("#D0" 0) ("#d1" 1) ("#D1" 1) + ("#d2" 2) ("#D2" 2) ("#d3" 3) ("#D3" 3) ("#d4" 4) ("#D4" 4) + ("#d5" 5) ("#D5" 5) ("#d6" 6) ("#D6" 6) ("#d7" 7) ("#D7" 7) + ("#d8" 8) ("#D8" 8) ("#d9" 9) ("#D9" 9) + ("#xa" 10) ("#Xa" 10) ("#xb" 11) ("#Xb" 11) + ("#xc" 12) ("#Xc" 12) ("#xd" 13) ("#Xd" 13) + ("#xe" 14) ("#Xe" 14) ("#xf" 15) ("#Xf" 15) + ("#b1010" 10) + ("#o12345670" 2739128) + ("#d1234567890" 1234567890) + ("#x1234567890abcdef" 1311768467294899695) + ;; Exactness: + ("#e1" 1) ("#e1.2" 1) ("#i1.1" 1.1) ("#i1" 1.0) + ;; Integers: + ("1" ,(1+ 0)) ("23" ,(+ 9 9 5)) ("-1" ,(- 0 1)) + ("-45" ,(- 0 45)) ("2#" 20.0) ("2##" 200.0) ("12##" 1200.0) + ("#b#i100" 4.0) + ;; Rationals: + ("1/1" 1) ("1/2" 0.5) ("-1/2" -0.5) ("1#/1" 10.0) + ("10/1#" 1.0) ("1#/1#" 1.0) ("#e9/10" 1) ("#e10/1#" 1) + ("#i6/8" 0.75) ("#i1/1" 1.0) + ;; Decimal numbers: + ;; * + ("1e2" 100.0) ("1E2" 100.0) ("1s2" 100.0) ("1S2" 100.0) + ("1f2" 100.0) ("1F2" 100.0) ("1d2" 100.0) ("1D2" 100.0) + ("1l2" 100.0) ("1L2" 100.0) ("1e+2" 100.0) ("1e-2" 0.01) + ;; * . + #* + (".1" .1) (".0123456789" 123456789e-10) (".16#" 0.16) + (".0123456789e10" 123456789.0) (".16#e3" 160.0) ("#d.3" 0.3) + ;; * + . * #* + ("3." ,(exact->inexact 3)) ("3.e0" ,(exact->inexact 3)) + ("3.1" ,(exact->inexact 31/10)) ("3.1e0" 3.1) ("3.1#" 3.1) + ("3.1#e0" 3.1) + ;; * + #+ . #* + ("3#." 30.0) ("3#.e0" 30.0) ("3#.#" 30.0) ("3#.#e0" 30.0) + ;; Complex: + ("1@0" 1.0) ("1@+0" 1.0) ("1@-0" 1.0) + ("2+3i" ,(+ 2 (* 3 +i))) ("4-5i" ,(- 4 (* 5 +i))) + ("1+i" 1+1i) ("1-i" 1-1i) ("+1i" 0+1i) ("-1i" 0-1i) + ("+i" +1i) ("-i" -1i))) + #t) + (pass-if-exception "exponent too big" exception:out-of-range (string->number "12.13e141414"))) From 1fe5e088ff343c5ba6bc1c85132bac0e0b0101a9 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 13 Oct 2001 12:39:26 +0000 Subject: [PATCH 031/281] * numbers.c (mem2uinteger): Return number read so far when coming across a hexdigit after having read a # or if not reading a hex value. This will enable the calling code to correctly handle forms like 1e2. (The background is, that the exponent markers d, e and f are also hexdigits.) Thanks to Mikael Djurfeldt for providing this patch. (mem2complex): Fix erroneous double-negation. Now, numbers like 1-i will be read correctly. --- libguile/ChangeLog | 12 ++++++++++++ libguile/numbers.c | 12 +++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index ded18c105..efc2cc2fa 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,15 @@ +2001-10-13 Dirk Herrmann + + * numbers.c (mem2uinteger): Return number read so far when coming + across a hexdigit after having read a # or if not reading a hex + value. This will enable the calling code to correctly handle + forms like 1e2. (The background is, that the exponent markers d, + e and f are also hexdigits.) Thanks to Mikael Djurfeldt for + providing this patch. + + (mem2complex): Fix erroneous double-negation. Now, numbers like + 1-i will be read correctly. + 2001-10-12 Mikael Djurfeldt * debug.c (scm_mem_to_proc): Fixed typo in previous change. diff --git a/libguile/numbers.c b/libguile/numbers.c index 24d9c9bf5..279be88e9 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -2296,10 +2296,10 @@ mem2uinteger (const char* mem, size_t len, unsigned int *p_idx, if (isxdigit (c)) { if (hash_seen) - return SCM_BOOL_F; + break; digit_value = XDIGIT2UINT (c); if (digit_value >= radix) - return SCM_BOOL_F; + break; } else if (c == '#') { @@ -2683,10 +2683,11 @@ mem2complex (const char* mem, size_t len, unsigned int idx, { int sign = (c == '+') ? 1 : -1; SCM imag = mem2ureal (mem, len, &idx, radix, p_exactness); - SCM result; if (SCM_FALSEP (imag)) imag = SCM_MAKINUM (sign); + else if (sign == -1) + imag = scm_difference (imag, SCM_UNDEFINED); if (idx == len) return SCM_BOOL_F; @@ -2697,10 +2698,7 @@ mem2complex (const char* mem, size_t len, unsigned int idx, if (idx != len) return SCM_BOOL_F; - if (sign == -1) - imag = scm_difference (imag, SCM_UNDEFINED); - result = scm_make_rectangular (ureal, imag); - return result; + return scm_make_rectangular (ureal, imag); } default: return SCM_BOOL_F; From 3756da52d9eebdb54481bfb1783e847a04a2a5b7 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:39:53 +0000 Subject: [PATCH 032/281] Set NO_PREPRO_MAGIC when defining our version of PTRDIFF_MIN. Thanks to Ken Raeburn. --- libguile/numbers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libguile/numbers.c b/libguile/numbers.c index 279be88e9..91e0359e5 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4265,6 +4265,9 @@ scm_i_big2dbl (SCM b) #ifndef PTRDIFF_MIN /* the below is not really guaranteed to work (I think), but probably does: */ #define PTRDIFF_MIN ((ptrdiff_t) ((ptrdiff_t)1 << (sizeof (ptrdiff_t)*8 - 1))) +/* this prevents num2integral.c.i from using PTRDIFF_MIN in + preprocessor expressions. */ +#define NO_PREPRO_MAGIC #endif #ifndef PTRDIFF_MAX From dc187f33fdc9142d030daa565eddff76bcc8b667 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:40:29 +0000 Subject: [PATCH 033/281] (module_variable): Pass over variables that exist but are unbound. --- libguile/modules.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libguile/modules.c b/libguile/modules.c index 1d6040d62..1c458683e 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -269,9 +269,13 @@ static SCM module_make_local_var_x_var; static SCM module_variable (SCM module, SCM sym) { +#define SCM_BOUND_THING_P(b) \ + (SCM_NFALSEP(b) && \ + (!SCM_VARIABLEP(b) || !SCM_UNBNDP (SCM_VARIABLE_REF (b)))) + /* 1. Check module obarray */ SCM b = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym, SCM_UNDEFINED); - if (SCM_VARIABLEP (b)) + if (SCM_BOUND_THING_P (b)) return b; { SCM binder = SCM_MODULE_BINDER (module); @@ -279,7 +283,7 @@ module_variable (SCM module, SCM sym) /* 2. Custom binder */ { b = scm_call_3 (binder, module, sym, SCM_BOOL_F); - if (SCM_NFALSEP (b)) + if (SCM_BOUND_THING_P (b)) return b; } } @@ -289,12 +293,13 @@ module_variable (SCM module, SCM sym) while (SCM_CONSP (uses)) { b = module_variable (SCM_CAR (uses), sym); - if (SCM_NFALSEP (b)) + if (SCM_BOUND_THING_P (b)) return b; uses = SCM_CDR (uses); } return SCM_BOOL_F; } +#undef SCM_BOUND_THING_P } scm_t_bits scm_tc16_eval_closure; From 311f67823da38891c829ccd84f982c8b844b51c1 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:41:12 +0000 Subject: [PATCH 034/281] (scm_m_atbind): First try to find the variable without defining it locally; when it has not been found, define it locally. --- libguile/eval.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libguile/eval.c b/libguile/eval.c index 6ea2a9dd9..4e272cb51 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -1135,7 +1135,7 @@ scm_m_atbind (SCM xorig, SCM env) { SCM x = SCM_CDR (xorig); SCM top_level = scm_env_top_level (env); - SCM vars = SCM_EOL; + SCM vars = SCM_EOL, var; SCM exps = SCM_EOL; SCM_ASSYNT (scm_ilength (x) > 1, scm_s_expression, s_atbind); @@ -1151,8 +1151,12 @@ scm_m_atbind (SCM xorig, SCM env) for (rest = x; SCM_NIMP (rest); rest = SCM_CDR (rest)) if (SCM_EQ_P (SCM_CAR (sym_exp), SCM_CAR (SCM_CAR (rest)))) scm_misc_error (s_atbind, scm_s_duplicate_bindings, SCM_EOL); - vars = scm_cons (scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_T), - vars); + /* The first call to scm_sym2var will look beyond the current + module, while the second call wont. */ + var = scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_F); + if (SCM_FALSEP (var)) + var = scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_T); + vars = scm_cons (var, vars); exps = scm_cons (SCM_CADR (sym_exp), exps); } return scm_cons (SCM_IM_BIND, From 4110fa69b02999d9432ca46c545a74bc22f7fb78 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:41:40 +0000 Subject: [PATCH 035/281] (display_backtrace_file_and_line): Only use scm_basename when POSIX support is compiled in. Thanks to Chris Cramer. --- libguile/backtrace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libguile/backtrace.c b/libguile/backtrace.c index 39d7563ac..803f5aaaa 100644 --- a/libguile/backtrace.c +++ b/libguile/backtrace.c @@ -499,8 +499,12 @@ display_backtrace_file_and_line (SCM frame, SCM port, scm_print_state *pstate) else { pstate -> writingp = 0; +#ifdef HAVE_POSIX scm_iprin1 (SCM_STRINGP (file) ? scm_basename (file, SCM_UNDEFINED) : file, port, pstate); +#else + scm_iprin1 (file, port, pstate); +#endif pstate -> writingp = 1; } From 143883dd3f4ab9041d2044af92fd41d601b3a915 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:42:07 +0000 Subject: [PATCH 036/281] (EXTRA_libguile_la_SOURCES): Added "mkstemp.c". --- libguile/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 9ead1f8a6..6e9294afa 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -94,7 +94,7 @@ EXTRA_libguile_la_SOURCES = _scm.h \ alloca.c inet_aton.c memmove.c putenv.c strerror.c \ threads.c regex-posix.c \ filesys.c posix.c net_db.c socket.c \ - ramap.c unif.c debug-malloc.c + ramap.c unif.c debug-malloc.c mkstemp.c ## In next release, threads will be factored out of libguile. ## Until then, the machine specific headers is a temporary kludge. From 9c7ce56302e312f840348da739aa59b0a5e9001e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:42:52 +0000 Subject: [PATCH 037/281] *** empty log message *** --- libguile/ChangeLog | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index efc2cc2fa..ed58e920e 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,25 @@ +2001-10-13 Marius Vollmer + + * numbers.c: Set NO_PREPRO_MAGIC when defining our version of + PTRDIFF_MIN. Thanks to Ken Raeburn. + +2001-10-07 Marius Vollmer + + * Makefile.am (EXTRA_libguile_la_SOURCES): Added "mkstemp.c". + + * eval.c (scm_m_atbind): First try to find the variable without + defining it locally; when it has not been found, define it + locally. + + * modules.c (module_variable): Pass over variables that exist but + are unbound. + +2001-10-06 Marius Vollmer + + * backtrace.c (display_backtrace_file_and_line): Only use + scm_basename when POSIX support is compiled in. Thanks to Chris + Cramer. + 2001-10-13 Dirk Herrmann * numbers.c (mem2uinteger): Return number read so far when coming From a8e8c20438cfe01e875fe2ee071a8f1669cb3f41 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Oct 2001 15:43:38 +0000 Subject: [PATCH 038/281] Thank Ken Raeburn and Chris Cramer. Removed Jim and Maciej from maintainer list. --- THANKS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 2d74681dd..66dd9c641 100644 --- a/THANKS +++ b/THANKS @@ -1,8 +1,6 @@ The Guile maintainer committee consists of - Jim Blandy Mikael Djurfeldt - Maciej Stachowiak Marius Vollmer Contributors since the last release: @@ -14,3 +12,5 @@ For fixes or providing information which led to a fix: Brian Crowder Christopher Cramer John Goerzen + Ken Raeburn + Chris Cramer From 27a226665e8b2d9e3911865cd0b8097a1184b8d0 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 13 Oct 2001 17:02:01 +0000 Subject: [PATCH 039/281] * tests/syntax.test: Added test cases for 'case' syntax. --- test-suite/ChangeLog | 4 +++ test-suite/tests/syntax.test | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index dbdec40cb..52681d579 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,7 @@ +2001-10-13 Dirk Herrmann + + * tests/syntax.test: Added test cases for 'case' syntax. + 2001-10-13 Dirk Herrmann * tests/numbers.test: Added a test case that checks if valid diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test index 53370c9dd..e9b23ecc0 100644 --- a/test-suite/tests/syntax.test +++ b/test-suite/tests/syntax.test @@ -356,6 +356,67 @@ exception:bad-formals (cond (1 => (lambda (x 1) 2)))))) +(with-test-prefix "case" + + (with-test-prefix "bad or missing clauses" + + (pass-if-exception "(case)" + exception:bad/missing-clauses + (case)) + + ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? + (pass-if-exception "(case . \"foo\")" + exception:wrong-type-arg + (case . "foo")) + + (pass-if-exception "(case 1)" + exception:bad/missing-clauses + (case 1)) + + ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? + (pass-if-exception "(case 1 . \"foo\")" + exception:wrong-type-arg + (case 1 . "foo")) + + (pass-if-exception "(case 1 \"foo\")" + exception:bad/missing-clauses + (case 1 "foo")) + + (pass-if-exception "(case 1 ())" + exception:bad/missing-clauses + (case 1 ())) + + (pass-if-exception "(case 1 (\"foo\"))" + exception:bad/missing-clauses + (case 1 ("foo"))) + + (pass-if-exception "(case 1 (\"foo\" \"bar\"))" + exception:bad/missing-clauses + (case 1 ("foo" "bar"))) + + ;; According to R5RS, the following one is syntactically correct. + ;; (pass-if-exception "(case 1 (() \"bar\"))" + ;; exception:bad/missing-clauses + ;; (case 1 (() "bar"))) + + ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? + (pass-if-exception "(case 1 ((2) \"bar\") . \"foo\")" + exception:wrong-type-arg + (case 1 ((2) "bar") . "foo")) + + (pass-if-exception "(case 1 (else #f) ((1) #t))" + exception:bad/missing-clauses + (case 1 ((2) "bar") (else))) + + ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? + (pass-if-exception "(case 1 (else #f) . \"foo\")" + exception:wrong-type-arg + (case 1 (else #f) . "foo")) + + (pass-if-exception "(case 1 (else #f) ((1) #t))" + exception:bad/missing-clauses + (case 1 (else #f) ((1) #t))))) + (with-test-prefix "define" (with-test-prefix "missing or extra expressions" From ea6c2147b7229ba5d1ffcd890abf03fee4132bb7 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 13 Oct 2001 23:59:27 +0000 Subject: [PATCH 040/281] * tests/syntax.test: Added test cases for 'lambda' syntax. --- test-suite/ChangeLog | 4 ++++ test-suite/tests/syntax.test | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 52681d579..909a1a019 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,7 @@ +2001-10-14 Dirk Herrmann + + * tests/syntax.test: Added test cases for 'lambda' syntax. + 2001-10-13 Dirk Herrmann * tests/syntax.test: Added test cases for 'case' syntax. diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test index e9b23ecc0..d1d54f97c 100644 --- a/test-suite/tests/syntax.test +++ b/test-suite/tests/syntax.test @@ -55,7 +55,27 @@ (with-test-prefix "bad formals" - (pass-if-exception "(lambda (x 1) 2)" + (pass-if-exception "(lambda)" + exception:bad-formals + (lambda)) + + (pass-if-exception "(lambda . \"foo\")" + exception:bad-formals + (lambda . "foo")) + + (pass-if-exception "(lambda ())" + exception:bad-formals + (lambda ())) + + (pass-if-exception "(lambda \"foo\")" + exception:bad-formals + (lambda "foo")) + + (pass-if-exception "(lambda \"foo\" #f)" + exception:bad-formals + (lambda "foo" #f)) + + (pass-if-exception "(lambda (x 1) 2)" exception:bad-formals (lambda (x 1) 2)) From 89759084ab381f7181bb0aef250f5161d012d41e Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Sun, 14 Oct 2001 16:05:04 +0000 Subject: [PATCH 041/281] * read.c (scm_lreadr): When user-defined hash procedure returns SCM_UNSPECIFIED: Fall back to standard handling instead of raising an exception. (This prevents parsing of uniform vectors from interfering with parsing of numbers.) * arrays.scm (read:uniform-vector): Return *unspecified* instead of raising an exception if hash extend character isn't followed by the array list. (This prevents parsing of uniform vectors from interfering with parsing of numbers.) --- ice-9/ChangeLog | 7 +++++++ ice-9/arrays.scm | 3 +-- libguile/ChangeLog | 7 +++++++ libguile/read.c | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index 3f5f18326..70e1e2df9 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,10 @@ +2001-10-14 Mikael Djurfeldt + + * arrays.scm (read:uniform-vector): Return *unspecified* instead + of raising an exception if hash extend character isn't followed by + the array list. (This prevents parsing of uniform vectors from + interfering with parsing of numbers.) + 2001-10-08 Mikael Djurfeldt * emacs.scm (%%load-port, %%emacs-load, %%emacs-eval-request, diff --git a/ice-9/arrays.scm b/ice-9/arrays.scm index b08de5e97..ae711d062 100644 --- a/ice-9/arrays.scm +++ b/ice-9/arrays.scm @@ -79,5 +79,4 @@ (define (read:uniform-vector proto port) (if (eq? #\( (peek-char port)) - (list->uniform-array 1 proto (read port)) - (error "read:uniform-vector list not found"))) + (list->uniform-array 1 proto (read port)))) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index ed58e920e..88437daa0 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,10 @@ +2001-10-14 Mikael Djurfeldt + + * read.c (scm_lreadr): When user-defined hash procedure returns + SCM_UNSPECIFIED: Fall back to standard handling instead of raising + an exception. (This prevents parsing of uniform vectors from + interfering with parsing of numbers.) + 2001-10-13 Marius Vollmer * numbers.c: Set NO_PREPRO_MAGIC when defining our version of diff --git a/libguile/read.c b/libguile/read.c index 0387c293d..1b8979ce1 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -350,7 +350,7 @@ scm_lreadr (SCM *tok_buf,SCM port,SCM *copy) got = scm_call_2 (sharp, SCM_MAKE_CHAR (c), port); if (SCM_EQ_P (got, SCM_UNSPECIFIED)) - goto unkshrp; + goto handle_sharp; if (SCM_RECORD_POSITIONS_P) return *copy = recsexpr (got, line, column, SCM_FILENAME (port)); @@ -358,6 +358,7 @@ scm_lreadr (SCM *tok_buf,SCM port,SCM *copy) return got; } } + handle_sharp: switch (c) { case '(': From 4874dfc849abe4a01236d1cdcb1796d15cb38d7f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 14 Oct 2001 20:08:08 +0000 Subject: [PATCH 042/281] Do not use an absolute path for when checking for return type of usleep. Thanks to Michael Carmack. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 590b33a10..756a40735 100644 --- a/configure.in +++ b/configure.in @@ -272,7 +272,7 @@ GUILE_FUNC_DECLARED(usleep, unistd.h) ### we'd like to return it; otherwise, we'll fake it. AC_CACHE_CHECK([return type of usleep], guile_cv_func_usleep_return_type, [AC_EGREP_HEADER(changequote(<, >)changequote([, ]), - /usr/include/unistd.h, + unistd.h, [guile_cv_func_usleep_return_type=void], [guile_cv_func_usleep_return_type=int])]) case "$guile_cv_func_usleep_return_type" in From f84c3705f2039109258c0236611ed39bbf1e2b05 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 14 Oct 2001 20:08:20 +0000 Subject: [PATCH 043/281] *** empty log message *** --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1445ba838..9da47c34a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-10-14 Marius Vollmer + + * configure.in: Do not use an absolute path for when + checking for return type of usleep. Thanks to Michael Carmack. + 2001-09-30 Thien-Thi Nguyen * BUGS: New file. From dba1190aed539650bf1a16b51210f77c5beadbb2 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 14 Oct 2001 20:15:07 +0000 Subject: [PATCH 044/281] Added Michael Carmack. Removed "Chris Cramer" since he is already listed as "Christopher". --- THANKS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 66dd9c641..b32f84671 100644 --- a/THANKS +++ b/THANKS @@ -9,8 +9,8 @@ For fixes or providing information which led to a fix: Martin Baulig Rob Browning + Michael Carmack Brian Crowder Christopher Cramer John Goerzen Ken Raeburn - Chris Cramer From 4f522b6f5c299e1ca63efdc44fbf79a32585d88e Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Sun, 14 Oct 2001 21:21:20 +0000 Subject: [PATCH 045/281] * configure.in: include sys/types.h when testing uint32_t. thanks to Bill Schottstaedt. --- ChangeLog | 5 +++++ configure.in | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9da47c34a..1486683be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-10-14 Gary Houston + + * configure.in: include sys/types.h when testing uint32_t. + thanks to Bill Schottstaedt. + 2001-10-14 Marius Vollmer * configure.in: Do not use an absolute path for when diff --git a/configure.in b/configure.in index 756a40735..0ddff0eb7 100644 --- a/configure.in +++ b/configure.in @@ -309,11 +309,12 @@ if test $guile_cv_have_h_errno = yes; then AC_DEFINE(HAVE_H_ERRNO) fi -AC_MSG_CHECKING(whether netdb.h defines uint32_t) +AC_MSG_CHECKING(whether uint32_t is defined) AC_CACHE_VAL(guile_cv_have_uint32_t, -[AC_TRY_COMPILE([#include ], -[uint32_t a;], -guile_cv_have_uint32_t=yes, guile_cv_have_uint32_t=no)]) + [AC_TRY_COMPILE([#include + #include ], + [uint32_t a;], + guile_cv_have_uint32_t=yes, guile_cv_have_uint32_t=no)]) AC_MSG_RESULT($guile_cv_have_uint32_t) if test $guile_cv_have_uint32_t = yes; then AC_DEFINE(HAVE_UINT32_T) From 8186c4f536f9f95524f1136acedc7d1660035905 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Sun, 14 Oct 2001 21:28:23 +0000 Subject: [PATCH 046/281] * version.c (scm_version): use sprintf instead of snprintf, for portability. thanks to Bill Schottstaedt. --- libguile/ChangeLog | 5 +++++ libguile/version.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 88437daa0..ef0aa937a 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-10-14 Gary Houston + + * version.c (scm_version): use sprintf instead of snprintf, + for portability. thanks to Bill Schottstaedt. + 2001-10-14 Mikael Djurfeldt * read.c (scm_lreadr): When user-defined hash procedure returns diff --git a/libguile/version.c b/libguile/version.c index 3d130564a..1bf1f6ff2 100644 --- a/libguile/version.c +++ b/libguile/version.c @@ -106,9 +106,13 @@ SCM_DEFINE (scm_version, "version", 0, 0, 0, #define FUNC_NAME s_scm_version { - char version_str[64]; + char version_str[3 * 4 + 3]; - snprintf(version_str, sizeof(version_str), "%d.%d.%d", +#if SCM_GUILE_MAJOR_VERSION > 9999 || SCM_GUILE_MINOR_VERSION > 9999 \ + || SCM_GUILE_MICRO_VERSION > 9999 +# error version string may overflow buffer +#endif + sprintf (version_str, "%d.%d.%d", SCM_GUILE_MAJOR_VERSION, SCM_GUILE_MINOR_VERSION, SCM_GUILE_MICRO_VERSION); From 39819fa9e45de806fbcd4e6a32ee6c3fee561ce7 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Wed, 17 Oct 2001 12:02:13 +0000 Subject: [PATCH 047/281] * boot-9.scm (process-define-module): New options: :export-syntax, :re-export-syntax --- ice-9/ChangeLog | 5 +++++ ice-9/boot-9.scm | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index 70e1e2df9..6218c22f8 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,8 @@ +2001-10-17 Mikael Djurfeldt + + * boot-9.scm (process-define-module): New options: :export-syntax, + :re-export-syntax + 2001-10-14 Mikael Djurfeldt * arrays.scm (read:uniform-vector): Return *unspecified* instead diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index fb9feef3b..c7ed61a0b 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -1749,14 +1749,14 @@ ((#:pure) (purify-module! module) (loop (cdr kws) reversed-interfaces exports re-exports)) - ((#:export) + ((#:export #:export-syntax) (or (pair? (cdr kws)) (unrecognized kws)) (loop (cddr kws) reversed-interfaces (append (cadr kws) exports) re-exports)) - ((#:re-export) + ((#:re-export #:re-export-syntax) (or (pair? (cdr kws)) (unrecognized kws)) (loop (cddr kws) From 8ea462495377d44d677190379e56829c7404c49b Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 18 Oct 2001 21:38:04 +0000 Subject: [PATCH 048/281] * eval.c (scm_lookupcar, scm_m_letstar, scm_m_do, iqq, scm_m_define, scm_m_letrec1, scm_m_let, scm_m_expand_body, scm_macroexp, unmemocopy, scm_eval_args, scm_deval_args, SCM_CEVAL, scm_map, scm_init_eval): When building lists, prefer scm_list_ over scm_cons[2]?. (scm_unmemocar, scm_m_cond, scm_m_letstar, scm_m_letrec1, scm_m_let, scm_m_atbind, unmemocopy, SCM_CEVAL, SCM_APPLY): Use SCM_C[AD][AD]R instead of explicit form. (scm_m_set_x, scm_m_cond, scm_m_letstar, scm_m_do): Reordered comparison parameters. (scm_m_case, scm_m_cond, scm_m_letstar, scm_m_do, SCM_CEVAL): Use !SCM_NULLP instead of SCM_NIMP. (scm_m_case): Don't copy the form. Renamed proc to clause and minimized its scope. Renamed x to clauses. Removed side effecting operation from macro call. (scm_m_cond): Don't copy the form. Renamed arg1 to clause and minimized its scope. Renamed x to clauses. Minimized the scope of variable 'len'. Make sure the else clause is treated specially even in case of '=>' occurences. Don't change the else to #t in order to be able to distinguish this case in the evaluator. Leave type checking of the recipient to the evaluator. (scm_c_improper_memq): Made the comment somewhat clearer. (scm_m_lambda): Renamed proc to formals. Removed unnecessary test for SCM_IM_LET at the place of the formal parameters. Simplified the formal parameter checking. (scm_m_letstar): Added Comment. Renamed proc to bindings. Renamed arg1 to binding and minimized its scope. Eliminated unnecessary consing. (scm_m_do): Renamed proc to bindings. Minimized the scope of variable 'len'. (build_binding_list): New static function. (unmemocopy): Don't use SCM_TYP7 on pairs (it's unclean). Further, split up the 'letrec' unmemoizing code to the corresponding parts for 'do', 'let' and 'letrec', adding comments to each form. Cleanup the handling of the do form (This removes some *real* code :-). (SCM_CEVAL): Removed side effecting operation from macro call. Handle the 'else clause of the 'cond form specially - the symbol 'else is not replaced with #t any more. --- libguile/ChangeLog | 54 +++++ libguile/eval.c | 517 ++++++++++++++++++++++++--------------------- 2 files changed, 331 insertions(+), 240 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index ef0aa937a..a00a3bd07 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,57 @@ +2001-10-14 Dirk Herrmann + + * eval.c (scm_lookupcar, scm_m_letstar, scm_m_do, iqq, + scm_m_define, scm_m_letrec1, scm_m_let, scm_m_expand_body, + scm_macroexp, unmemocopy, scm_eval_args, scm_deval_args, + SCM_CEVAL, scm_map, scm_init_eval): When building lists, prefer + scm_list_ over scm_cons[2]?. + + (scm_unmemocar, scm_m_cond, scm_m_letstar, scm_m_letrec1, + scm_m_let, scm_m_atbind, unmemocopy, SCM_CEVAL, SCM_APPLY): Use + SCM_C[AD][AD]R instead of explicit form. + + (scm_m_set_x, scm_m_cond, scm_m_letstar, scm_m_do): Reordered + comparison parameters. + + (scm_m_case, scm_m_cond, scm_m_letstar, scm_m_do, SCM_CEVAL): Use + !SCM_NULLP instead of SCM_NIMP. + + (scm_m_case): Don't copy the form. Renamed proc to clause and + minimized its scope. Renamed x to clauses. Removed side + effecting operation from macro call. + + (scm_m_cond): Don't copy the form. Renamed arg1 to clause and + minimized its scope. Renamed x to clauses. Minimized the scope + of variable 'len'. Make sure the else clause is treated specially + even in case of '=>' occurences. Don't change the else to #t in + order to be able to distinguish this case in the evaluator. Leave + type checking of the recipient to the evaluator. + + (scm_c_improper_memq): Made the comment somewhat clearer. + + (scm_m_lambda): Renamed proc to formals. Removed unnecessary + test for SCM_IM_LET at the place of the formal parameters. + Simplified the formal parameter checking. + + (scm_m_letstar): Added Comment. Renamed proc to bindings. + Renamed arg1 to binding and minimized its scope. Eliminated + unnecessary consing. + + (scm_m_do): Renamed proc to bindings. Minimized the scope of + variable 'len'. + + (build_binding_list): New static function. + + (unmemocopy): Don't use SCM_TYP7 on pairs (it's unclean). + Further, split up the 'letrec' unmemoizing code to the + corresponding parts for 'do', 'let' and 'letrec', adding comments + to each form. Cleanup the handling of the do form (This removes + some *real* code :-). + + (SCM_CEVAL): Removed side effecting operation from macro call. + Handle the 'else clause of the 'cond form specially - the symbol + 'else is not replaced with #t any more. + 2001-10-14 Gary Houston * version.c (scm_version): use sprintf instead of snprintf, diff --git a/libguile/eval.c b/libguile/eval.c index 4e272cb51..c6a209cb2 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -39,7 +39,6 @@ * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ - /* This file is read twice in order to produce debugging versions of @@ -345,10 +344,10 @@ scm_lookupcar (SCM vloc, SCM genv, int check) if (SCM_NULLP (env)) scm_error (scm_unbound_variable_key, NULL, "Unbound variable: ~S", - scm_cons (var, SCM_EOL), SCM_BOOL_F); + scm_list_1 (var), SCM_BOOL_F); else scm_misc_error (NULL, "Damaged environment: ~S", - scm_cons (var, SCM_EOL)); + scm_list_1 (var)); } else { @@ -426,7 +425,7 @@ scm_unmemocar (SCM form, SCM env) for (ir = SCM_IFRAME (c); ir != 0; --ir) env = SCM_CDR (env); - env = SCM_CAR (SCM_CAR (env)); + env = SCM_CAAR (env); for (ir = SCM_IDIST (c); ir != 0; --ir) env = SCM_CDR (env); SCM_SETCAR (form, SCM_ICDRP (c) ? env : SCM_CAR (env)); @@ -500,19 +499,20 @@ scm_m_body (SCM op, SCM xorig, const char *what) /* Retain possible doc string. */ if (!SCM_CONSP (SCM_CAR (xorig))) { - if (!SCM_NULLP (SCM_CDR(xorig))) + if (!SCM_NULLP (SCM_CDR (xorig))) return scm_cons (SCM_CAR (xorig), - scm_m_body (op, SCM_CDR(xorig), what)); + scm_m_body (op, SCM_CDR (xorig), what)); return xorig; } return scm_cons (op, xorig); } -SCM_SYNTAX(s_quote,"quote", scm_makmmacro, scm_m_quote); -SCM_GLOBAL_SYMBOL(scm_sym_quote, s_quote); -SCM +SCM_SYNTAX (s_quote, "quote", scm_makmmacro, scm_m_quote); +SCM_GLOBAL_SYMBOL (scm_sym_quote, s_quote); + +SCM scm_m_quote (SCM xorig, SCM env SCM_UNUSED) { SCM x = scm_copy_tree (SCM_CDR (xorig)); @@ -522,21 +522,21 @@ scm_m_quote (SCM xorig, SCM env SCM_UNUSED) } +SCM_SYNTAX (s_begin, "begin", scm_makmmacro, scm_m_begin); +SCM_GLOBAL_SYMBOL (scm_sym_begin, s_begin); -SCM_SYNTAX(s_begin, "begin", scm_makmmacro, scm_m_begin); -SCM_GLOBAL_SYMBOL(scm_sym_begin, s_begin); - -SCM +SCM scm_m_begin (SCM xorig, SCM env SCM_UNUSED) { SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 1, scm_s_expression, s_begin); return scm_cons (SCM_IM_BEGIN, SCM_CDR (xorig)); } -SCM_SYNTAX(s_if, "if", scm_makmmacro, scm_m_if); -SCM_GLOBAL_SYMBOL(scm_sym_if, s_if); -SCM +SCM_SYNTAX (s_if, "if", scm_makmmacro, scm_m_if); +SCM_GLOBAL_SYMBOL (scm_sym_if, s_if); + +SCM scm_m_if (SCM xorig, SCM env SCM_UNUSED) { long len = scm_ilength (SCM_CDR (xorig)); @@ -546,24 +546,24 @@ scm_m_if (SCM xorig, SCM env SCM_UNUSED) /* Will go into the RnRS module when Guile is factorized. -SCM_SYNTAX(scm_s_set_x,"set!", scm_makmmacro, scm_m_set_x); */ +SCM_SYNTAX (scm_s_set_x,"set!", scm_makmmacro, scm_m_set_x); */ const char scm_s_set_x[] = "set!"; -SCM_GLOBAL_SYMBOL(scm_sym_set_x, scm_s_set_x); +SCM_GLOBAL_SYMBOL (scm_sym_set_x, scm_s_set_x); -SCM +SCM scm_m_set_x (SCM xorig, SCM env SCM_UNUSED) { SCM x = SCM_CDR (xorig); - SCM_ASSYNT (2 == scm_ilength (x), scm_s_expression, scm_s_set_x); + SCM_ASSYNT (scm_ilength (x) == 2, scm_s_expression, scm_s_set_x); SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (x)), scm_s_variable, scm_s_set_x); return scm_cons (SCM_IM_SET_X, x); } -SCM_SYNTAX(s_and, "and", scm_makmmacro, scm_m_and); -SCM_GLOBAL_SYMBOL(scm_sym_and, s_and); +SCM_SYNTAX (s_and, "and", scm_makmmacro, scm_m_and); +SCM_GLOBAL_SYMBOL (scm_sym_and, s_and); -SCM +SCM scm_m_and (SCM xorig, SCM env SCM_UNUSED) { long len = scm_ilength (SCM_CDR (xorig)); @@ -574,10 +574,11 @@ scm_m_and (SCM xorig, SCM env SCM_UNUSED) return SCM_BOOL_T; } -SCM_SYNTAX(s_or,"or", scm_makmmacro, scm_m_or); -SCM_GLOBAL_SYMBOL(scm_sym_or,s_or); -SCM +SCM_SYNTAX (s_or, "or", scm_makmmacro, scm_m_or); +SCM_GLOBAL_SYMBOL (scm_sym_or, s_or); + +SCM scm_m_or (SCM xorig, SCM env SCM_UNUSED) { long len = scm_ilength (SCM_CDR (xorig)); @@ -589,63 +590,66 @@ scm_m_or (SCM xorig, SCM env SCM_UNUSED) } -SCM_SYNTAX(s_case, "case", scm_makmmacro, scm_m_case); -SCM_GLOBAL_SYMBOL(scm_sym_case, s_case); +SCM_SYNTAX (s_case, "case", scm_makmmacro, scm_m_case); +SCM_GLOBAL_SYMBOL (scm_sym_case, s_case); -SCM +SCM scm_m_case (SCM xorig, SCM env SCM_UNUSED) { - SCM proc, cdrx = scm_list_copy (SCM_CDR (xorig)), x = cdrx; - SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_clauses, s_case); - while (SCM_NIMP (x = SCM_CDR (x))) + SCM clauses; + SCM cdrx = SCM_CDR (xorig); + SCM_ASSYNT (scm_ilength (cdrx) >= 2, scm_s_clauses, s_case); + clauses = SCM_CDR (cdrx); + while (!SCM_NULLP (clauses)) { - proc = SCM_CAR (x); - SCM_ASSYNT (scm_ilength (proc) >= 2, scm_s_clauses, s_case); - SCM_ASSYNT (scm_ilength (SCM_CAR (proc)) >= 0 - || (SCM_EQ_P (scm_sym_else, SCM_CAR (proc)) - && SCM_NULLP (SCM_CDR (x))), + SCM clause = SCM_CAR (clauses); + SCM_ASSYNT (scm_ilength (clause) >= 2, scm_s_clauses, s_case); + SCM_ASSYNT (scm_ilength (SCM_CAR (clause)) >= 0 + || (SCM_EQ_P (scm_sym_else, SCM_CAR (clause)) + && SCM_NULLP (SCM_CDR (clauses))), scm_s_clauses, s_case); + clauses = SCM_CDR (clauses); } return scm_cons (SCM_IM_CASE, cdrx); } -SCM_SYNTAX(s_cond, "cond", scm_makmmacro, scm_m_cond); -SCM_GLOBAL_SYMBOL(scm_sym_cond, s_cond); +SCM_SYNTAX (s_cond, "cond", scm_makmmacro, scm_m_cond); +SCM_GLOBAL_SYMBOL (scm_sym_cond, s_cond); - -SCM +SCM scm_m_cond (SCM xorig, SCM env SCM_UNUSED) { - SCM arg1, cdrx = scm_list_copy (SCM_CDR (xorig)), x = cdrx; - long len = scm_ilength (x); - SCM_ASSYNT (len >= 1, scm_s_clauses, s_cond); - while (SCM_NIMP (x)) + SCM cdrx = SCM_CDR (xorig); + SCM clauses = cdrx; + SCM_ASSYNT (scm_ilength (clauses) >= 1, scm_s_clauses, s_cond); + while (!SCM_NULLP (clauses)) { - arg1 = SCM_CAR (x); - len = scm_ilength (arg1); + SCM clause = SCM_CAR (clauses); + long len = scm_ilength (clause); SCM_ASSYNT (len >= 1, scm_s_clauses, s_cond); - if (SCM_EQ_P (scm_sym_else, SCM_CAR (arg1))) + if (SCM_EQ_P (scm_sym_else, SCM_CAR (clause))) { - SCM_ASSYNT (SCM_NULLP (SCM_CDR (x)) && len >= 2, - "bad ELSE clause", s_cond); - SCM_SETCAR (arg1, SCM_BOOL_T); + int last_clause_p = SCM_NULLP (SCM_CDR (clauses)); + SCM_ASSYNT (len >= 2 && last_clause_p, "bad ELSE clause", s_cond); } - if (len >= 2 && SCM_EQ_P (scm_sym_arrow, SCM_CAR (SCM_CDR (arg1)))) - SCM_ASSYNT (3 == len && SCM_NIMP (SCM_CAR (SCM_CDR (SCM_CDR (arg1)))), - "bad recipient", s_cond); - x = SCM_CDR (x); + else if (len >= 2 && SCM_EQ_P (scm_sym_arrow, SCM_CADR (clause))) + { + SCM_ASSYNT (len > 2, "missing recipient", s_cond); + SCM_ASSYNT (len == 3, "bad recipient", s_cond); + } + clauses = SCM_CDR (clauses); } return scm_cons (SCM_IM_COND, cdrx); } -SCM_SYNTAX(s_lambda, "lambda", scm_makmmacro, scm_m_lambda); -SCM_GLOBAL_SYMBOL(scm_sym_lambda, s_lambda); + +SCM_SYNTAX (s_lambda, "lambda", scm_makmmacro, scm_m_lambda); +SCM_GLOBAL_SYMBOL (scm_sym_lambda, s_lambda); /* Return true if OBJ is `eq?' to one of the elements of LIST or to the - cdr of the last cons. (Thus, LIST is not required to be a proper - list and when OBJ also found in the improper ending.) */ - + * cdr of the last cons. (Thus, LIST is not required to be a proper + * list and OBJ can also be found in the improper ending.) */ static int scm_c_improper_memq (SCM obj, SCM list) { @@ -657,76 +661,60 @@ scm_c_improper_memq (SCM obj, SCM list) return SCM_EQ_P (list, obj); } -SCM +SCM scm_m_lambda (SCM xorig, SCM env SCM_UNUSED) { - SCM proc, x = SCM_CDR (xorig); + SCM formals; + SCM x = SCM_CDR (xorig); if (scm_ilength (x) < 2) - goto badforms; - proc = SCM_CAR (x); - if (SCM_NULLP (proc)) - goto memlambda; - if (SCM_EQ_P (SCM_IM_LET, proc)) /* named let */ - goto memlambda; - if (SCM_IMP (proc)) - goto badforms; - if (SCM_SYMBOLP (proc)) - goto memlambda; - if (!SCM_CONSP (proc)) - goto badforms; - while (SCM_NIMP (proc)) - { - if (!SCM_CONSP (proc)) - { - if (!SCM_SYMBOLP (proc)) - goto badforms; - else - goto memlambda; - } - if (!SCM_SYMBOLP (SCM_CAR (proc))) - goto badforms; - else if (scm_c_improper_memq (SCM_CAR(proc), SCM_CDR(proc))) - scm_misc_error (s_lambda, scm_s_duplicate_formals, SCM_EOL); - proc = SCM_CDR (proc); - } - if (!SCM_NULLP (proc)) - { - badforms: - scm_misc_error (s_lambda, scm_s_formals, SCM_EOL); - } + scm_misc_error (s_lambda, scm_s_formals, SCM_EOL); + + formals = SCM_CAR (x); + while (SCM_CONSP (formals)) + { + SCM formal = SCM_CAR (formals); + SCM_ASSYNT (SCM_SYMBOLP (formal), scm_s_formals, s_lambda); + if (scm_c_improper_memq (formal, SCM_CDR (formals))) + scm_misc_error (s_lambda, scm_s_duplicate_formals, SCM_EOL); + formals = SCM_CDR (formals); + } + if (!SCM_NULLP (formals) && !SCM_SYMBOLP (formals)) + scm_misc_error (s_lambda, scm_s_formals, SCM_EOL); - memlambda: return scm_cons2 (SCM_IM_LAMBDA, SCM_CAR (x), scm_m_body (SCM_IM_LAMBDA, SCM_CDR (x), s_lambda)); } -SCM_SYNTAX(s_letstar,"let*", scm_makmmacro, scm_m_letstar); -SCM_GLOBAL_SYMBOL(scm_sym_letstar,s_letstar); +SCM_SYNTAX (s_letstar, "let*", scm_makmmacro, scm_m_letstar); +SCM_GLOBAL_SYMBOL (scm_sym_letstar, s_letstar); -SCM +/* (let* ((v1 i1) (v2 i2) ...) body) with variables v1 .. vk and initializers + * i1 .. ik is transformed into the form (#@let* (v1 i1 v2 i2 ...) body*). */ +SCM scm_m_letstar (SCM xorig, SCM env SCM_UNUSED) { - SCM x = SCM_CDR (xorig), arg1, proc, vars = SCM_EOL, *varloc = &vars; - long len = scm_ilength (x); - SCM_ASSYNT (len >= 2, scm_s_body, s_letstar); - proc = SCM_CAR (x); - SCM_ASSYNT (scm_ilength (proc) >= 0, scm_s_bindings, s_letstar); - while (SCM_NIMP (proc)) + SCM bindings; + SCM x = SCM_CDR (xorig); + SCM vars = SCM_EOL; + SCM *varloc = &vars; + SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_body, s_letstar); + bindings = SCM_CAR (x); + SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_letstar); + while (!SCM_NULLP (bindings)) { - arg1 = SCM_CAR (proc); - SCM_ASSYNT (2 == scm_ilength (arg1), scm_s_bindings, s_letstar); - SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (arg1)), scm_s_variable, s_letstar); - *varloc = scm_cons2 (SCM_CAR (arg1), SCM_CAR (SCM_CDR (arg1)), SCM_EOL); + SCM binding = SCM_CAR (bindings); + SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, s_letstar); + SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, s_letstar); + *varloc = scm_list_2 (SCM_CAR (binding), SCM_CADR (binding)); varloc = SCM_CDRLOC (SCM_CDR (*varloc)); - proc = SCM_CDR (proc); + bindings = SCM_CDR (bindings); } - x = scm_cons (vars, SCM_CDR (x)); - - return scm_cons2 (SCM_IM_LETSTAR, SCM_CAR (x), + return scm_cons2 (SCM_IM_LETSTAR, vars, scm_m_body (SCM_IM_LETSTAR, SCM_CDR (x), s_letstar)); } + /* DO gets the most radically altered syntax (do (( ) ( ) @@ -747,28 +735,31 @@ SCM_GLOBAL_SYMBOL(scm_sym_do, s_do); SCM scm_m_do (SCM xorig, SCM env SCM_UNUSED) { - SCM x = SCM_CDR (xorig), arg1, proc; - SCM vars = SCM_EOL, inits = SCM_EOL, steps = SCM_EOL; - SCM *initloc = &inits, *steploc = &steps; - long len = scm_ilength (x); - SCM_ASSYNT (len >= 2, scm_s_test, "do"); - proc = SCM_CAR (x); - SCM_ASSYNT (scm_ilength (proc) >= 0, scm_s_bindings, "do"); - while (SCM_NIMP(proc)) + SCM bindings; + SCM x = SCM_CDR (xorig); + SCM vars = SCM_EOL; + SCM inits = SCM_EOL; + SCM *initloc = &inits; + SCM steps = SCM_EOL; + SCM *steploc = &steps; + SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_test, "do"); + bindings = SCM_CAR (x); + SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, "do"); + while (!SCM_NULLP (bindings)) { - arg1 = SCM_CAR (proc); - len = scm_ilength (arg1); - SCM_ASSYNT (2 == len || 3 == len, scm_s_bindings, "do"); + SCM arg1 = SCM_CAR (bindings); + long len = scm_ilength (arg1); + SCM_ASSYNT (len == 2 || len == 3, scm_s_bindings, "do"); SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (arg1)), scm_s_variable, "do"); /* vars reversed here, inits and steps reversed at evaluation */ vars = scm_cons (SCM_CAR (arg1), vars); /* variable */ arg1 = SCM_CDR (arg1); - *initloc = scm_cons (SCM_CAR (arg1), SCM_EOL); /* init */ + *initloc = scm_list_1 (SCM_CAR (arg1)); /* init */ initloc = SCM_CDRLOC (*initloc); arg1 = SCM_CDR (arg1); - *steploc = scm_cons (SCM_IMP (arg1) ? SCM_CAR (vars) : SCM_CAR (arg1), SCM_EOL); /* step */ + *steploc = scm_list_1 (len == 2 ? SCM_CAR (vars) : SCM_CAR (arg1)); steploc = SCM_CDRLOC (*steploc); - proc = SCM_CDR (proc); + bindings = SCM_CDR (bindings); } x = SCM_CDR (x); SCM_ASSYNT (scm_ilength (SCM_CAR (x)) >= 1, scm_s_test, "do"); @@ -830,13 +821,13 @@ iqq (SCM form, SCM env, long depth) form, SCM_ARG1, s_quasiquote); if (0 == depth) return evalcar (form, env); - return scm_cons2 (tmp, iqq (SCM_CAR (form), env, depth), SCM_EOL); + return scm_list_2 (tmp, iqq (SCM_CAR (form), env, depth)); } if (SCM_CONSP (tmp) && (SCM_EQ_P (scm_sym_uq_splicing, SCM_CAR (tmp)))) { tmp = SCM_CDR (tmp); if (0 == --edepth) - return scm_append (scm_cons2 (evalcar (tmp, env), iqq (SCM_CDR (form), env, depth), SCM_EOL)); + return scm_append (scm_list_2 (evalcar (tmp, env), iqq (SCM_CDR (form), env, depth))); } return scm_cons (iqq (SCM_CAR (form), env, edepth), iqq (SCM_CDR (form), env, depth)); } @@ -867,7 +858,7 @@ scm_m_define (SCM x, SCM env) x = SCM_CDR (x); while (SCM_CONSP (proc)) { /* nested define syntax */ - x = scm_cons (scm_cons2 (scm_sym_lambda, SCM_CDR (proc), x), SCM_EOL); + x = scm_list_1 (scm_cons2 (scm_sym_lambda, SCM_CDR (proc), x)); proc = SCM_CAR (proc); } SCM_ASSYNT (SCM_SYMBOLP (proc), scm_s_variable, s_define); @@ -896,7 +887,7 @@ scm_m_define (SCM x, SCM env) arg1 = scm_sym2var (proc, scm_env_top_level (env), SCM_BOOL_T); SCM_VARIABLE_SET (arg1, x); #ifdef SICP - return scm_cons2 (scm_sym_quote, proc, SCM_EOL); + return scm_list_2 (scm_sym_quote, proc); #else return SCM_UNSPECIFIED; #endif @@ -925,7 +916,7 @@ scm_m_letrec1 (SCM op, SCM imm, SCM xorig, SCM env SCM_UNUSED) if (scm_c_improper_memq (SCM_CAR (arg1), vars)) scm_misc_error (what, scm_s_duplicate_bindings, SCM_EOL); vars = scm_cons (SCM_CAR (arg1), vars); - *initloc = scm_cons (SCM_CAR (SCM_CDR (arg1)), SCM_EOL); + *initloc = scm_list_1 (SCM_CADR (arg1)); initloc = SCM_CDRLOC (*initloc); } while (SCM_NIMP (proc = SCM_CDR (proc))); @@ -996,18 +987,18 @@ scm_m_let (SCM xorig, SCM env) arg1 = SCM_CAR (proc); SCM_ASSYNT (2 == scm_ilength (arg1), scm_s_bindings, s_let); SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (arg1)), scm_s_variable, s_let); - *varloc = scm_cons (SCM_CAR (arg1), SCM_EOL); + *varloc = scm_list_1 (SCM_CAR (arg1)); varloc = SCM_CDRLOC (*varloc); - *initloc = scm_cons (SCM_CAR (SCM_CDR (arg1)), SCM_EOL); + *initloc = scm_list_1 (SCM_CADR (arg1)); initloc = SCM_CDRLOC (*initloc); proc = SCM_CDR (proc); } proc = scm_cons2 (scm_sym_lambda, vars, scm_m_body (SCM_IM_LET, SCM_CDR (x), "let")); - proc = scm_cons2 (scm_sym_let, scm_cons (scm_cons2 (name, proc, SCM_EOL), - SCM_EOL), - scm_acons (name, inits, SCM_EOL)); + proc = scm_list_3 (scm_sym_let, + scm_list_1 (scm_list_2 (name, proc)), + scm_cons (name, inits)); return scm_m_letrec1 (SCM_IM_LETREC, SCM_IM_LET, proc, env); } @@ -1149,7 +1140,7 @@ scm_m_atbind (SCM xorig, SCM env) SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (sym_exp)), scm_s_bindings, s_atbind); x = SCM_CDR (x); for (rest = x; SCM_NIMP (rest); rest = SCM_CDR (rest)) - if (SCM_EQ_P (SCM_CAR (sym_exp), SCM_CAR (SCM_CAR (rest)))) + if (SCM_EQ_P (SCM_CAR (sym_exp), SCM_CAAR (rest))) scm_misc_error (s_atbind, scm_s_duplicate_bindings, SCM_EOL); /* The first call to scm_sym2var will look beyond the current module, while the second call wont. */ @@ -1205,7 +1196,7 @@ scm_m_expand_body (SCM xorig, SCM env) } else if (SCM_EQ_P (SCM_IM_BEGIN, SCM_CAR (form))) { - x = scm_append (scm_cons2 (SCM_CDR (form), SCM_CDR (x), SCM_EOL)); + x = scm_append (scm_list_2 (SCM_CDR (form), SCM_CDR (x))); } else { @@ -1217,11 +1208,10 @@ scm_m_expand_body (SCM xorig, SCM env) SCM_ASSYNT (SCM_NIMP (x), scm_s_body, what); if (SCM_NIMP (defs)) { - x = scm_cons (scm_m_letrec1 (SCM_IM_LETREC, - SCM_IM_DEFINE, - scm_cons2 (scm_sym_define, defs, x), - env), - SCM_EOL); + x = scm_list_1 (scm_m_letrec1 (SCM_IM_LETREC, + SCM_IM_DEFINE, + scm_cons2 (scm_sym_define, defs, x), + env)); } SCM_DEFER_INTS; @@ -1269,7 +1259,7 @@ scm_macroexp (SCM x, SCM env) res = scm_call_2 (SCM_MACRO_CODE (proc), x, env); if (scm_ilength (res) <= 0) - res = scm_cons2 (SCM_IM_BEGIN, res, SCM_EOL); + res = scm_list_2 (SCM_IM_BEGIN, res); SCM_DEFER_INTS; SCM_SETCAR (x, SCM_CAR (res)); @@ -1296,6 +1286,20 @@ scm_macroexp (SCM x, SCM env) #define SCM_BIT8(x) (127 & SCM_UNPACK (x)) +static SCM +build_binding_list (SCM names, SCM inits) +{ + SCM bindings = SCM_EOL; + while (!SCM_NULLP (names)) + { + SCM binding = scm_list_2 (SCM_CAR (names), SCM_CAR (inits)); + bindings = scm_cons (binding, bindings); + names = SCM_CDR (names); + inits = SCM_CDR (inits); + } + return bindings; +} + static SCM unmemocopy (SCM x, SCM env) { @@ -1308,7 +1312,7 @@ unmemocopy (SCM x, SCM env) #ifdef DEBUG_EXTENSIONS p = scm_whash_lookup (scm_source_whash, x); #endif - switch (SCM_TYP7 (x)) + switch (SCM_ITAG7 (SCM_CAR (x))) { case SCM_BIT8(SCM_IM_AND): ls = z = scm_cons (scm_sym_and, SCM_UNSPECIFIED); @@ -1322,60 +1326,85 @@ unmemocopy (SCM x, SCM env) case SCM_BIT8(SCM_IM_COND): ls = z = scm_cons (scm_sym_cond, SCM_UNSPECIFIED); break; - case SCM_BIT8(SCM_IM_DO): - ls = scm_cons (scm_sym_do, SCM_UNSPECIFIED); - goto transform; + case SCM_BIT8 (SCM_IM_DO): + { + /* format: (#@do (nk nk-1 ...) (i1 ... ik) (test) (body) s1 ... sk), + * where nx is the name of a local variable, ix is an initializer for + * the local variable, test is the test clause of the do loop, body is + * the body of the do loop and sx are the step clauses for the local + * variables. */ + SCM names, inits, test, memoized_body, steps, bindings; + + x = SCM_CDR (x); + names = SCM_CAR (x); + x = SCM_CDR (x); + inits = scm_reverse (unmemocopy (SCM_CAR (x), env)); + env = EXTEND_ENV (names, SCM_EOL, env); + x = SCM_CDR (x); + test = unmemocopy (SCM_CAR (x), env); + x = SCM_CDR (x); + memoized_body = SCM_CAR (x); + x = SCM_CDR (x); + steps = scm_reverse (unmemocopy (x, env)); + + /* build transformed binding list */ + bindings = SCM_EOL; + while (!SCM_NULLP (names)) + { + SCM name = SCM_CAR (names); + SCM init = SCM_CAR (inits); + SCM step = SCM_CAR (steps); + step = SCM_EQ_P (step, name) ? SCM_EOL : scm_list_1 (step); + + bindings = scm_cons (scm_cons2 (name, init, step), bindings); + + names = SCM_CDR (names); + inits = SCM_CDR (inits); + steps = SCM_CDR (steps); + } + z = scm_cons (test, SCM_UNSPECIFIED); + ls = scm_cons2 (scm_sym_do, bindings, z); + + x = scm_cons (SCM_BOOL_F, memoized_body); + break; + } case SCM_BIT8(SCM_IM_IF): ls = z = scm_cons (scm_sym_if, SCM_UNSPECIFIED); break; - case SCM_BIT8(SCM_IM_LET): - ls = scm_cons (scm_sym_let, SCM_UNSPECIFIED); - goto transform; - case SCM_BIT8(SCM_IM_LETREC): + case SCM_BIT8 (SCM_IM_LET): { - SCM f, v, e, s; - ls = scm_cons (scm_sym_letrec, SCM_UNSPECIFIED); - transform: + /* format: (#@let (nk nk-1 ...) (i1 ... ik) b1 ...), + * where nx is the name of a local variable, ix is an initializer for + * the local variable and by are the body clauses. */ + SCM names, inits, bindings; + x = SCM_CDR (x); - /* binding names */ - f = v = SCM_CAR (x); + names = SCM_CAR (x); x = SCM_CDR (x); - z = EXTEND_ENV (f, SCM_EOL, env); - /* inits */ - e = scm_reverse (unmemocopy (SCM_CAR (x), - SCM_EQ_P (SCM_CAR (ls), scm_sym_letrec) ? z : env)); - env = z; - /* increments */ - s = SCM_EQ_P (SCM_CAR (ls), scm_sym_do) - ? scm_reverse (unmemocopy (SCM_CDR (SCM_CDR (SCM_CDR (x))), env)) - : f; - /* build transformed binding list */ - z = SCM_EOL; - while (SCM_NIMP (v)) - { - z = scm_acons (SCM_CAR (v), - scm_cons (SCM_CAR (e), - SCM_EQ_P (SCM_CAR (s), SCM_CAR (v)) - ? SCM_EOL - : scm_cons (SCM_CAR (s), SCM_EOL)), - z); - v = SCM_CDR (v); - e = SCM_CDR (e); - s = SCM_CDR (s); - } - z = scm_cons (z, SCM_UNSPECIFIED); - SCM_SETCDR (ls, z); - if (SCM_EQ_P (SCM_CAR (ls), scm_sym_do)) - { - x = SCM_CDR (x); - /* test clause */ - SCM_SETCDR (z, scm_cons (unmemocopy (SCM_CAR (x), env), - SCM_UNSPECIFIED)); - z = SCM_CDR (z); - x = (SCM) (SCM_CARLOC (SCM_CDR (x)) - 1); - /* body forms are now to be found in SCM_CDR (x) - (this is how *real* code look like! :) */ - } + inits = scm_reverse (unmemocopy (SCM_CAR (x), env)); + env = EXTEND_ENV (names, SCM_EOL, env); + + bindings = build_binding_list (names, inits); + z = scm_cons (bindings, SCM_UNSPECIFIED); + ls = scm_cons (scm_sym_let, z); + break; + } + case SCM_BIT8 (SCM_IM_LETREC): + { + /* format: (#@letrec (nk nk-1 ...) (i1 ... ik) b1 ...), + * where nx is the name of a local variable, ix is an initializer for + * the local variable and by are the body clauses. */ + SCM names, inits, bindings; + + x = SCM_CDR (x); + names = SCM_CAR (x); + env = EXTEND_ENV (names, SCM_EOL, env); + x = SCM_CDR (x); + inits = scm_reverse (unmemocopy (SCM_CAR (x), env)); + + bindings = build_binding_list (names, inits); + z = scm_cons (bindings, SCM_UNSPECIFIED); + ls = scm_cons (scm_sym_letrec, z); break; } case SCM_BIT8(SCM_IM_LETSTAR): @@ -1391,10 +1420,10 @@ unmemocopy (SCM x, SCM env) } y = z = scm_acons (SCM_CAR (b), unmemocar ( - scm_cons (unmemocopy (SCM_CAR (SCM_CDR (b)), env), SCM_EOL), env), + scm_cons (unmemocopy (SCM_CADR (b), env), SCM_EOL), env), SCM_UNSPECIFIED); env = EXTEND_ENV (SCM_CAR (b), SCM_BOOL_F, env); - b = SCM_CDR (SCM_CDR (b)); + b = SCM_CDDR (b); if (SCM_IMP (b)) { SCM_SETCDR (y, SCM_EOL); @@ -1405,11 +1434,11 @@ unmemocopy (SCM x, SCM env) { SCM_SETCDR (z, scm_acons (SCM_CAR (b), unmemocar ( - scm_cons (unmemocopy (SCM_CAR (SCM_CDR (b)), env), SCM_EOL), env), + scm_list_1 (unmemocopy (SCM_CADR (b), env)), env), SCM_UNSPECIFIED)); z = SCM_CDR (z); env = EXTEND_ENV (SCM_CAR (b), SCM_BOOL_F, env); - b = SCM_CDR (SCM_CDR (b)); + b = SCM_CDDR (b); } while (SCM_NIMP (b)); SCM_SETCDR (z, SCM_EOL); @@ -1422,8 +1451,8 @@ unmemocopy (SCM x, SCM env) break; case SCM_BIT8(SCM_IM_LAMBDA): x = SCM_CDR (x); - ls = scm_cons (scm_sym_lambda, - z = scm_cons (SCM_CAR (x), SCM_UNSPECIFIED)); + z = scm_cons (SCM_CAR (x), SCM_UNSPECIFIED); + ls = scm_cons (scm_sym_lambda, z); env = EXTEND_ENV (SCM_CAR (x), SCM_EOL, env); break; case SCM_BIT8(SCM_IM_QUOTE): @@ -1436,10 +1465,11 @@ unmemocopy (SCM x, SCM env) { SCM n; x = SCM_CDR (x); - ls = scm_cons (scm_sym_define, - z = scm_cons (n = SCM_CAR (x), SCM_UNSPECIFIED)); + n = SCM_CAR (x); + z = scm_cons (n, SCM_UNSPECIFIED); + ls = scm_cons (scm_sym_define, z); if (!SCM_NULLP (env)) - SCM_SETCAR (SCM_CAR (env), scm_cons (n, SCM_CAR (SCM_CAR (env)))); + SCM_SETCAR (SCM_CAR (env), scm_cons (n, SCM_CAAR (env))); break; } case SCM_BIT8(SCM_MAKISYM (0)): @@ -1546,7 +1576,7 @@ scm_eval_args (SCM l, SCM env, SCM proc) { res = EVALCAR (l, env); - *lloc = scm_cons (res, SCM_EOL); + *lloc = scm_list_1 (res); lloc = SCM_CDRLOC (*lloc); l = SCM_CDR (l); } @@ -1754,7 +1784,7 @@ scm_deval_args (SCM l, SCM env, SCM proc, SCM *lloc) { res = EVALCAR (l, env); - *lloc = scm_cons (res, SCM_EOL); + *lloc = scm_list_1 (res); lloc = SCM_CDRLOC (*lloc); l = SCM_CDR (l); } @@ -2013,7 +2043,7 @@ dispatch: { if (CHECK_EQVISH (SCM_CAR (proc), t.arg1)) { - x = SCM_CDR (SCM_CAR (x)); + x = SCM_CDAR (x); PREP_APPLY (SCM_UNDEFINED, SCM_EOL); goto begin; } @@ -2023,10 +2053,17 @@ dispatch: RETURN (SCM_UNSPECIFIED) - case SCM_BIT8(SCM_IM_COND): - while (!SCM_IMP (x = SCM_CDR (x))) + case SCM_BIT8 (SCM_IM_COND): + x = SCM_CDR (x); + while (!SCM_NULLP (x)) { proc = SCM_CAR (x); + if (SCM_EQ_P (SCM_CAR (proc), scm_sym_else)) + { + x = SCM_CDR (proc); + PREP_APPLY (SCM_UNDEFINED, SCM_EOL); + goto begin; + } t.arg1 = EVALCAR (proc, env); if (!SCM_FALSEP (t.arg1)) { @@ -2043,19 +2080,20 @@ dispatch: proc = SCM_CDR (x); proc = EVALCAR (proc, env); SCM_ASRTGO (SCM_NIMP (proc), badfun); - PREP_APPLY (proc, scm_cons (t.arg1, SCM_EOL)); + PREP_APPLY (proc, scm_list_1 (t.arg1)); ENTER_APPLY; if (SCM_CLOSUREP(proc) && scm_badformalsp (proc, 1)) goto umwrongnumargs; goto evap1; } + x = SCM_CDR (x); } RETURN (SCM_UNSPECIFIED) case SCM_BIT8(SCM_IM_DO): x = SCM_CDR (x); - proc = SCM_CAR (SCM_CDR (x)); /* inits */ + proc = SCM_CADR (x); /* inits */ t.arg1 = SCM_EOL; /* values */ while (SCM_NIMP (proc)) { @@ -2063,7 +2101,7 @@ dispatch: proc = SCM_CDR (proc); } env = EXTEND_ENV (SCM_CAR (x), t.arg1, env); - x = SCM_CDR (SCM_CDR (x)); + x = SCM_CDDR (x); while (proc = SCM_CAR (x), SCM_FALSEP (EVALCAR (proc, env))) { for (proc = SCM_CADR (x); SCM_NIMP (proc); proc = SCM_CDR (proc)) @@ -2075,7 +2113,7 @@ dispatch: SCM_NIMP (proc); proc = SCM_CDR (proc)) t.arg1 = scm_cons (EVALCAR (proc, env), t.arg1); /* steps */ - env = EXTEND_ENV (SCM_CAR (SCM_CAR (env)), t.arg1, SCM_CDR (env)); + env = EXTEND_ENV (SCM_CAAR (env), t.arg1, SCM_CDR (env)); } x = SCM_CDR (proc); if (SCM_NULLP (x)) @@ -2088,7 +2126,7 @@ dispatch: x = SCM_CDR (x); if (!SCM_FALSEP (EVALCAR (x, env))) x = SCM_CDR (x); - else if (SCM_IMP (x = SCM_CDR (SCM_CDR (x)))) + else if (SCM_IMP (x = SCM_CDDR (x))) { RETURN (SCM_UNSPECIFIED); } @@ -2098,7 +2136,7 @@ dispatch: case SCM_BIT8(SCM_IM_LET): x = SCM_CDR (x); - proc = SCM_CAR (SCM_CDR (x)); + proc = SCM_CADR (x); t.arg1 = SCM_EOL; do { @@ -2163,7 +2201,7 @@ dispatch: case SCM_BIT8(SCM_IM_QUOTE): - RETURN (SCM_CAR (SCM_CDR (x))); + RETURN (SCM_CADR (x)); case SCM_BIT8(SCM_IM_SET_X): @@ -2209,7 +2247,7 @@ dispatch: { SCM argl, tl; PREP_APPLY (proc, SCM_EOL); - t.arg1 = SCM_CDR (SCM_CDR (x)); + t.arg1 = SCM_CDDR (x); t.arg1 = EVALCAR (t.arg1, env); apply_closure: /* Go here to tail-call a closure. PROC is the closure @@ -2259,7 +2297,7 @@ dispatch: proc = SCM_CDR (x); proc = evalcar (proc, env); SCM_ASRTGO (SCM_NIMP (proc), badfun); - PREP_APPLY (proc, scm_cons (t.arg1, SCM_EOL)); + PREP_APPLY (proc, scm_list_1 (t.arg1)); ENTER_APPLY; if (SCM_CLOSUREP(proc) && scm_badformalsp (proc, 1)) goto umwrongnumargs; @@ -2282,11 +2320,11 @@ dispatch: } else { - arg2 = scm_cons (EVALCAR (proc, env), SCM_EOL); + arg2 = scm_list_1 (EVALCAR (proc, env)); t.lloc = SCM_CDRLOC (arg2); while (SCM_NIMP (proc = SCM_CDR (proc))) { - *t.lloc = scm_cons (EVALCAR (proc, env), SCM_EOL); + *t.lloc = scm_list_1 (EVALCAR (proc, env)); t.lloc = SCM_CDRLOC (*t.lloc); } } @@ -2479,7 +2517,7 @@ dispatch: if (SCM_VALUESP (t.arg1)) t.arg1 = scm_struct_ref (t.arg1, SCM_INUM0); else - t.arg1 = scm_cons (t.arg1, SCM_EOL); + t.arg1 = scm_list_1 (t.arg1); if (SCM_CLOSUREP (proc)) { PREP_APPLY (proc, t.arg1); @@ -2578,7 +2616,7 @@ dispatch: { case 2: if (scm_ilength (t.arg1) <= 0) - t.arg1 = scm_cons2 (SCM_IM_BEGIN, t.arg1, SCM_EOL); + t.arg1 = scm_list_2 (SCM_IM_BEGIN, t.arg1); #ifdef DEVAL if (!SCM_CLOSUREP (SCM_MACRO_CODE (proc))) { @@ -2661,7 +2699,7 @@ evapply: proc = SCM_CCLO_SUBR (proc); #ifdef DEVAL debug.info->a.proc = proc; - debug.info->a.args = scm_cons (t.arg1, SCM_EOL); + debug.info->a.args = scm_list_1 (t.arg1); #endif goto evap1; case scm_tc7_pws: @@ -2694,7 +2732,7 @@ evapply: : SCM_OPERATOR_PROCEDURE (proc)); #ifdef DEVAL debug.info->a.proc = proc; - debug.info->a.args = scm_cons (t.arg1, SCM_EOL); + debug.info->a.args = scm_list_1 (t.arg1); #endif if (SCM_NIMP (proc)) goto evap1; @@ -2736,7 +2774,7 @@ evapply: t.arg1 = EVALCAR (x, env); #endif #ifdef DEVAL - debug.info->a.args = scm_cons (t.arg1, SCM_EOL); + debug.info->a.args = scm_list_1 (t.arg1); #endif x = SCM_CDR (x); if (SCM_NULLP (x)) @@ -2789,7 +2827,7 @@ evapply: #ifdef DEVAL RETURN (SCM_SUBRF (proc) (debug.info->a.args)) #else - RETURN (SCM_SUBRF (proc) (scm_cons (t.arg1, SCM_EOL))); + RETURN (SCM_SUBRF (proc) (scm_list_1 (t.arg1))); #endif case scm_tc7_smob: if (!SCM_SMOB_APPLICABLE_P (proc)) @@ -2819,7 +2857,7 @@ evapply: #ifdef DEVAL env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), debug.info->a.args, SCM_ENV (proc)); #else - env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), scm_cons (t.arg1, SCM_EOL), SCM_ENV (proc)); + env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), scm_list_1 (t.arg1), SCM_ENV (proc)); #endif goto nontoplevel_cdrxbegin; case scm_tcs_struct: @@ -2829,7 +2867,7 @@ evapply: #ifdef DEVAL arg2 = debug.info->a.args; #else - arg2 = scm_cons (t.arg1, SCM_EOL); + arg2 = scm_list_1 (t.arg1); #endif goto type_dispatch; } @@ -2877,7 +2915,7 @@ evapply: #endif { /* have two or more arguments */ #ifdef DEVAL - debug.info->a.args = scm_cons2 (t.arg1, arg2, SCM_EOL); + debug.info->a.args = scm_list_2 (t.arg1, arg2); #endif x = SCM_CDR (x); if (SCM_NULLP (x)) { @@ -2892,7 +2930,7 @@ evapply: #ifdef DEVAL RETURN (SCM_SUBRF (proc) (debug.info->a.args)) #else - RETURN (SCM_SUBRF (proc) (scm_cons2 (t.arg1, arg2, SCM_EOL))); + RETURN (SCM_SUBRF (proc) (scm_list_2 (t.arg1, arg2))); #endif case scm_tc7_lsubr_2: RETURN (SCM_SUBRF (proc) (t.arg1, arg2, SCM_EOL)); @@ -2925,7 +2963,7 @@ evapply: #ifdef DEVAL arg2 = debug.info->a.args; #else - arg2 = scm_cons2 (t.arg1, arg2, SCM_EOL); + arg2 = scm_list_2 (t.arg1, arg2); #endif goto type_dispatch; } @@ -2977,7 +3015,7 @@ evapply: SCM_ENV (proc)); #else env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), - scm_cons2 (t.arg1, arg2, SCM_EOL), SCM_ENV (proc)); + scm_list_2 (t.arg1, arg2), SCM_ENV (proc)); #endif x = SCM_CODE (proc); goto nontoplevel_cdrxbegin; @@ -3004,7 +3042,7 @@ evapply: case scm_tc7_asubr: #ifdef BUILTIN_RPASUBR t.arg1 = SCM_SUBRF(proc)(t.arg1, arg2); - arg2 = SCM_CDR (SCM_CDR (debug.info->a.args)); + arg2 = SCM_CDDR (debug.info->a.args); do { t.arg1 = SCM_SUBRF(proc)(t.arg1, SCM_CAR (arg2)); @@ -3017,7 +3055,7 @@ evapply: #ifdef BUILTIN_RPASUBR if (SCM_FALSEP (SCM_SUBRF (proc) (t.arg1, arg2))) RETURN (SCM_BOOL_F) - t.arg1 = SCM_CDR (SCM_CDR (debug.info->a.args)); + t.arg1 = SCM_CDDR (debug.info->a.args); do { if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, SCM_CAR (t.arg1)))) @@ -3030,12 +3068,12 @@ evapply: #else /* BUILTIN_RPASUBR */ RETURN (SCM_APPLY (proc, t.arg1, scm_acons (arg2, - SCM_CDR (SCM_CDR (debug.info->a.args)), + SCM_CDDR (debug.info->a.args), SCM_EOL))) #endif /* BUILTIN_RPASUBR */ case scm_tc7_lsubr_2: RETURN (SCM_SUBRF (proc) (t.arg1, arg2, - SCM_CDR (SCM_CDR (debug.info->a.args)))) + SCM_CDDR (debug.info->a.args))) case scm_tc7_lsubr: RETURN (SCM_SUBRF (proc) (debug.info->a.args)) case scm_tc7_smob: @@ -3464,7 +3502,7 @@ tail: && !SCM_NULLP (SCM_CDR (args)) && SCM_NULLP (SCM_CDDR (args)), wrongnumargs); - RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CAR (SCM_CDR (args)))) + RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CADR (args))) case scm_tc7_lsubr: #ifdef DEVAL RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : debug.vect[0].a.args)) @@ -3711,8 +3749,7 @@ scm_map (SCM proc, SCM arg1, SCM args) { while (SCM_NIMP (arg1)) { - *pres = scm_cons (scm_apply (proc, SCM_CAR (arg1), scm_listofnull), - SCM_EOL); + *pres = scm_list_1 (scm_apply (proc, SCM_CAR (arg1), scm_listofnull)); pres = SCM_CDRLOC (*pres); arg1 = SCM_CDR (arg1); } @@ -3733,7 +3770,7 @@ scm_map (SCM proc, SCM arg1, SCM args) arg1 = scm_cons (SCM_CAR (ve[i]), arg1); ve[i] = SCM_CDR (ve[i]); } - *pres = scm_cons (scm_apply (proc, arg1, SCM_EOL), SCM_EOL); + *pres = scm_list_1 (scm_apply (proc, arg1, SCM_EOL)); pres = SCM_CDRLOC (*pres); } } @@ -4078,9 +4115,9 @@ scm_init_eval () scm_set_smob_print (scm_tc16_promise, promise_print); /* Dirk:Fixme:: make scm_undefineds local to eval.c: it's only used here. */ - scm_undefineds = scm_cons (SCM_UNDEFINED, SCM_EOL); + scm_undefineds = scm_list_1 (SCM_UNDEFINED); SCM_SETCDR (scm_undefineds, scm_undefineds); - scm_listofnull = scm_cons (SCM_EOL, SCM_EOL); + scm_listofnull = scm_list_1 (SCM_EOL); scm_f_apply = scm_c_define_subr ("apply", scm_tc7_lsubr_2, scm_apply); From b461abe73f84e023fa3df782ea82b3582a48412f Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 18 Oct 2001 21:59:29 +0000 Subject: [PATCH 049/281] * tests/syntax.test: Added test cases for 'cond =>' syntax with else clause. Changed some tests and comments related to the 'case' form to reflect recent changes in the implementation. --- test-suite/ChangeLog | 6 ++++++ test-suite/tests/syntax.test | 22 ++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 909a1a019..1be4e7c60 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,9 @@ +2001-10-18 Dirk Herrmann + + * tests/syntax.test: Added test cases for 'cond =>' syntax with + else clause. Changed some tests and comments related to the + 'case' form to reflect recent changes in the implementation. + 2001-10-14 Dirk Herrmann * tests/syntax.test: Added test cases for 'lambda' syntax. diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test index d1d54f97c..2c5f06bf2 100644 --- a/test-suite/tests/syntax.test +++ b/test-suite/tests/syntax.test @@ -370,6 +370,16 @@ (with-test-prefix "cond =>" + (with-test-prefix "else is handled correctly" + + (pass-if "else =>" + (let ((=> 'foo)) + (eq? (cond (else =>)) 'foo))) + + (pass-if "else => identity" + (let* ((=> 'foo)) + (eq? (cond (else => identity)) identity)))) + (with-test-prefix "bad formals" (pass-if-exception "=> (lambda (x 1) 2)" @@ -384,18 +394,16 @@ exception:bad/missing-clauses (case)) - ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? (pass-if-exception "(case . \"foo\")" - exception:wrong-type-arg + exception:bad/missing-clauses (case . "foo")) (pass-if-exception "(case 1)" exception:bad/missing-clauses (case 1)) - ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? (pass-if-exception "(case 1 . \"foo\")" - exception:wrong-type-arg + exception:bad/missing-clauses (case 1 . "foo")) (pass-if-exception "(case 1 \"foo\")" @@ -419,18 +427,16 @@ ;; exception:bad/missing-clauses ;; (case 1 (() "bar"))) - ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? (pass-if-exception "(case 1 ((2) \"bar\") . \"foo\")" - exception:wrong-type-arg + exception:bad/missing-clauses (case 1 ((2) "bar") . "foo")) (pass-if-exception "(case 1 (else #f) ((1) #t))" exception:bad/missing-clauses (case 1 ((2) "bar") (else))) - ;; FIXME: Wouldn't one rather expect a 'bad or missing clauses' error? (pass-if-exception "(case 1 (else #f) . \"foo\")" - exception:wrong-type-arg + exception:bad/missing-clauses (case 1 (else #f) . "foo")) (pass-if-exception "(case 1 (else #f) ((1) #t))" From 1a179b03b02d7967c9eba7ef6f196fcbfbafa15b Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Sun, 21 Oct 2001 09:49:19 +0000 Subject: [PATCH 050/281] * lib.scm: Move module the system directives `export', `export-syntax', `re-export' and `re-export-syntax' into the `define-module' form. This is the recommended way of exporting bindings. * srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm, srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system directives `export', `export-syntax', `re-export' and `re-export-syntax' into the `define-module' form. This is the recommended way of exporting bindings. * goops.scm, goops/active-slot.scm, goops/compile.scm, goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm, goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move module the system directives `export', `export-syntax', `re-export' and `re-export-syntax' into the `define-module' form. This is the recommended way of exporting bindings. * slib.scm (array-indexes): New procedure. (*features*): Extend. (Probably some of these options should be set elsewhere.) (Thanks to Aubrey Jaffer.) * and-let-star-compat.scm, and-let-star.scm, calling.scm, channel.scm, common-list.scm, debug.scm, debugger.scm, expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm, null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm, q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm, safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm, syncase.scm, threads.scm: Move module the system directives `export', `export-syntax', `re-export' and `re-export-syntax' into the `define-module' form. This is the recommended way of exporting bindings. --- ice-9/ChangeLog | 17 +++ ice-9/and-let-star.scm | 5 +- ice-9/calling.scm | 31 +++-- ice-9/channel.scm | 14 +- ice-9/common-list.scm | 54 ++++---- ice-9/debug.scm | 13 +- ice-9/debugger.scm | 3 +- ice-9/expect.scm | 28 ++-- ice-9/hcons.scm | 25 ++-- ice-9/lineio.scm | 12 +- ice-9/ls.scm | 16 ++- ice-9/mapping.scm | 57 +++++---- ice-9/null.scm | 21 ++- ice-9/optargs.scm | 28 ++-- ice-9/poe.scm | 9 +- ice-9/popen.scm | 16 ++- ice-9/pretty-print.scm | 5 +- ice-9/q.scm | 30 +++-- ice-9/r5rs.scm | 29 ++--- ice-9/rdelim.scm | 8 +- ice-9/regex.scm | 36 +++--- ice-9/runq.scm | 19 +-- ice-9/safe-r5rs.scm | 219 ++++++++++++++++---------------- ice-9/safe.scm | 9 +- ice-9/session.scm | 25 ++-- ice-9/slib.scm | 176 +++++++++++++++---------- ice-9/streams.scm | 17 ++- ice-9/string-fun.scm | 50 +++++--- ice-9/syncase.scm | 66 ++++++---- ice-9/threads.scm | 16 +-- oop/ChangeLog | 9 ++ oop/goops.scm | 92 +++++++------- oop/goops/active-slot.scm | 5 +- oop/goops/compile.scm | 5 +- oop/goops/composite-slot.scm | 5 +- oop/goops/describe.scm | 5 +- oop/goops/dispatch.scm | 5 +- oop/goops/old-define-method.scm | 3 +- oop/goops/save.scm | 13 +- oop/goops/util.scm | 7 +- srfi/ChangeLog | 8 ++ srfi/srfi-10.scm | 5 +- srfi/srfi-11.scm | 6 +- srfi/srfi-14.scm | 7 +- srfi/srfi-16.scm | 5 +- srfi/srfi-2.scm | 5 +- srfi/srfi-4.scm | 7 +- srfi/srfi-8.scm | 5 +- srfi/srfi-9.scm | 5 +- test-suite/ChangeLog | 7 + test-suite/lib.scm | 7 +- 51 files changed, 700 insertions(+), 570 deletions(-) diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index 6218c22f8..c18e49fa2 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,20 @@ +2001-10-21 Mikael Djurfeldt + + * slib.scm (array-indexes): New procedure. + (*features*): Extend. (Probably some of these options should be + set elsewhere.) (Thanks to Aubrey Jaffer.) + + * and-let-star-compat.scm, and-let-star.scm, calling.scm, + channel.scm, common-list.scm, debug.scm, debugger.scm, + expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm, + null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm, + q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm, + safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm, + syncase.scm, threads.scm: Move module the system directives + `export', `export-syntax', `re-export' and `re-export-syntax' + into the `define-module' form. This is the recommended way of + exporting bindings. + 2001-10-17 Mikael Djurfeldt * boot-9.scm (process-define-module): New options: :export-syntax, diff --git a/ice-9/and-let-star.scm b/ice-9/and-let-star.scm index 61765f910..472d8b626 100644 --- a/ice-9/and-let-star.scm +++ b/ice-9/and-let-star.scm @@ -42,7 +42,8 @@ ;;;; whether to permit this exception to apply to your modifications. ;;;; If you do not wish that, delete this exception notice. -(define-module (ice-9 and-let-star)) +(define-module (ice-9 and-let-star) + :export-syntax (and-let*)) (defmacro and-let* (vars . body) @@ -68,5 +69,3 @@ (error "not a proper list" vars)))) (expand vars body)) - -(export-syntax and-let*) diff --git a/ice-9/calling.scm b/ice-9/calling.scm index 3f2f57b65..7785391bd 100644 --- a/ice-9/calling.scm +++ b/ice-9/calling.scm @@ -1,6 +1,6 @@ ;;;; calling.scm --- Calling Conventions ;;;; -;;;; Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -42,7 +42,15 @@ ;;;; If you do not wish that, delete this exception notice. ;;;; -(define-module (ice-9 calling)) +(define-module (ice-9 calling) + :export-syntax (with-excursion-function + with-getter-and-setter + with-getter + with-delegating-getter-and-setter + with-excursion-getter-and-setter + with-configuration-getter-and-setter + with-delegating-configuration-getter-and-setter + let-with-configuration-getter-and-setter)) ;;;; ;;; @@ -62,7 +70,7 @@ ;;; entering and leaving the call to proc non-locally, such as using ;;; call-with-current-continuation, error, or throw. ;;; -(defmacro-public with-excursion-function (vars proc) +(defmacro with-excursion-function (vars proc) `(,proc ,(excursion-function-syntax vars))) @@ -107,7 +115,7 @@ ;;; ;; takes its arguments in a different order. ;;; ;;; -(defmacro-public with-getter-and-setter (vars proc) +(defmacro with-getter-and-setter (vars proc) `(,proc ,@ (getter-and-setter-syntax vars))) ;;; with-getter vars proc @@ -115,7 +123,7 @@ ;;; The procedure is called: ;;; (proc getter) ;;; -(defmacro-public with-getter (vars proc) +(defmacro with-getter (vars proc) `(,proc ,(car (getter-and-setter-syntax vars)))) @@ -132,7 +140,7 @@ ;;; proc is a procedure that is called ;;; (proc getter setter) ;;; -(defmacro-public with-delegating-getter-and-setter (vars get-delegate set-delegate proc) +(defmacro with-delegating-getter-and-setter (vars get-delegate set-delegate proc) `(,proc ,@ (delegating-getter-and-setter-syntax vars get-delegate set-delegate))) @@ -146,7 +154,7 @@ ;;; with-getter-and-setter ;;; with-excursion-function ;;; -(defmacro-public with-excursion-getter-and-setter (vars proc) +(defmacro with-excursion-getter-and-setter (vars proc) `(,proc ,(excursion-function-syntax vars) ,@ (getter-and-setter-syntax vars))) @@ -272,7 +280,7 @@ ;;; for the corresponding variable. If omitted, the binding of ;;; is simply set using set!. ;;; -(defmacro-public with-configuration-getter-and-setter (vars-etc proc) +(defmacro with-configuration-getter-and-setter (vars-etc proc) `((lambda (simpler-get simpler-set body-proc) (with-delegating-getter-and-setter () simpler-get simpler-set body-proc)) @@ -295,7 +303,7 @@ ,proc)) -(defmacro-public with-delegating-configuration-getter-and-setter (vars-etc delegate-get delegate-set proc) +(defmacro with-delegating-configuration-getter-and-setter (vars-etc delegate-get delegate-set proc) `((lambda (simpler-get simpler-set body-proc) (with-delegating-getter-and-setter () simpler-get simpler-set body-proc)) @@ -337,10 +345,7 @@ ;;; ...) ;;; (with-configuration-getter-and-setter (( v1-get v1-set) ...) proc)) ;;; -(defmacro-public let-with-configuration-getter-and-setter (vars-etc proc) +(defmacro let-with-configuration-getter-and-setter (vars-etc proc) `(let ,(map (lambda (v) `(,(car v) ,(cadr v))) vars-etc) (with-configuration-getter-and-setter ,(map (lambda (v) `(,(car v) ,(caddr v) ,(cadddr v))) vars-etc) ,proc))) - - - diff --git a/ice-9/channel.scm b/ice-9/channel.scm index e3527d441..0ca2fcf3a 100644 --- a/ice-9/channel.scm +++ b/ice-9/channel.scm @@ -95,7 +95,11 @@ ;;; Code: -(define-module (ice-9 channel)) +(define-module (ice-9 channel) + :export (make-object-channel + channel-open + channel-print-value + channel-print-token)) ;;; ;;; Channel type @@ -106,7 +110,7 @@ (define make-channel (record-constructor channel-type)) -(define-public (make-object-channel printer) +(define (make-object-channel printer) (make-channel (current-input-port) (current-output-port) printer @@ -121,7 +125,7 @@ ;;; Channel ;;; -(define-public (channel-open ch) +(define (channel-open ch) (let ((stdin (channel-stdin ch)) (stdout (channel-stdout ch)) (printer (channel-printer ch)) @@ -155,10 +159,10 @@ (list key (apply format #f (cadr args) (caddr args)))) (loop)))))))) -(define-public (channel-print-value ch val) +(define (channel-print-value ch val) (format (channel-stdout ch) "value = ~S\n" val)) -(define-public (channel-print-token ch val) +(define (channel-print-token ch val) (let* ((token (symbol-append (gensym "%%") '%%)) (pair (cons token (object->string val)))) (format (channel-stdout ch) "token = ~S\n" pair) diff --git a/ice-9/common-list.scm b/ice-9/common-list.scm index a8b775cef..29fa0e536 100644 --- a/ice-9/common-list.scm +++ b/ice-9/common-list.scm @@ -75,7 +75,11 @@ ;;; Code: -(define-module (ice-9 common-list)) +(define-module (ice-9 common-list) + :export (adjoin union intersection set-difference reduce-init reduce + some every notany notevery count-if find-if member-if remove-if + remove-if-not delete-if! delete-if-not! butlast and? or? + has-duplicates? pick pick-mappings uniq)) ;;"comlist.scm" Implementation of COMMON LISP list functions for Scheme ; Copyright (C) 1991, 1993, 1995 Aubrey Jaffer. @@ -96,11 +100,11 @@ ;promotional, or sales literature without prior written consent in ;each case. -(define-public (adjoin e l) +(define (adjoin e l) "Return list L, possibly with element E added if it is not already in L." (if (memq e l) l (cons e l))) -(define-public (union l1 l2) +(define (union l1 l2) "Return a new list that is the union of L1 and L2. Elements that occur in both lists occur only once in the result list." @@ -108,7 +112,7 @@ the result list." ((null? l2) l1) (else (union (cdr l1) (adjoin (car l1) l2))))) -(define-public (intersection l1 l2) +(define (intersection l1 l2) "Return a new list that is the intersection of L1 and L2. Only elements that occur in both lists occur in the result list." (if (null? l2) l2 @@ -117,20 +121,20 @@ Only elements that occur in both lists occur in the result list." ((memv (car l1) l2) (loop (cdr l1) (cons (car l1) result))) (else (loop (cdr l1) result)))))) -(define-public (set-difference l1 l2) +(define (set-difference l1 l2) "Return elements from list L1 that are not in list L2." (let loop ((l1 l1) (result '())) (cond ((null? l1) (reverse! result)) ((memv (car l1) l2) (loop (cdr l1) result)) (else (loop (cdr l1) (cons (car l1) result)))))) -(define-public (reduce-init p init l) +(define (reduce-init p init l) "Same as `reduce' except it implicitly inserts INIT at the start of L." (if (null? l) init (reduce-init p (p init (car l)) (cdr l)))) -(define-public (reduce p l) +(define (reduce p l) "Combine all the elements of sequence L using a binary operation P. The combination is left-associative. For example, using +, one can add up all the elements. `reduce' allows you to apply a function which @@ -140,7 +144,7 @@ programmers usually refer to this as foldl." ((null? (cdr l)) (car l)) (else (reduce-init p (car l) (cdr l))))) -(define-public (some pred l . rest) +(define (some pred l . rest) "PRED is a boolean function of as many arguments as there are list arguments to `some', i.e., L plus any optional arguments. PRED is applied to successive elements of the list arguments in order. As soon @@ -156,7 +160,7 @@ All the lists should have the same length." (or (apply pred (car l) (map car rest)) (mapf (cdr l) (map cdr rest)))))))) -(define-public (every pred l . rest) +(define (every pred l . rest) "Return #t iff every application of PRED to L, etc., returns #t. Analogous to `some' except it returns #t if every application of PRED is #t and #f otherwise." @@ -169,39 +173,39 @@ PRED is #t and #f otherwise." (and (apply pred (car l) (map car rest)) (mapf (cdr l) (map cdr rest)))))))) -(define-public (notany pred . ls) +(define (notany pred . ls) "Return #t iff every application of PRED to L, etc., returns #f. Analogous to some but returns #t if no application of PRED returns a true value or #f as soon as any one does." (not (apply some pred ls))) -(define-public (notevery pred . ls) +(define (notevery pred . ls) "Return #t iff there is an application of PRED to L, etc., that returns #f. Analogous to some but returns #t as soon as an application of PRED returns #f, or #f otherwise." (not (apply every pred ls))) -(define-public (count-if pred l) +(define (count-if pred l) "Return the number of elements in L for which (PRED element) returns true." (let loop ((n 0) (l l)) (cond ((null? l) n) ((pred (car l)) (loop (+ n 1) (cdr l))) (else (loop n (cdr l)))))) -(define-public (find-if pred l) +(define (find-if pred l) "Search for the first element in L for which (PRED element) returns true. If found, return that element, otherwise return #f." (cond ((null? l) #f) ((pred (car l)) (car l)) (else (find-if pred (cdr l))))) -(define-public (member-if pred l) +(define (member-if pred l) "Return the first sublist of L for whose car PRED is true." (cond ((null? l) #f) ((pred (car l)) l) (else (member-if pred (cdr l))))) -(define-public (remove-if pred l) +(define (remove-if pred l) "Remove all elements from L where (PRED element) is true. Return everything that's left." (let loop ((l l) (result '())) @@ -209,7 +213,7 @@ Return everything that's left." ((pred (car l)) (loop (cdr l) result)) (else (loop (cdr l) (cons (car l) result)))))) -(define-public (remove-if-not pred l) +(define (remove-if-not pred l) "Remove all elements from L where (PRED element) is #f. Return everything that's left." (let loop ((l l) (result '())) @@ -217,7 +221,7 @@ Return everything that's left." ((not (pred (car l))) (loop (cdr l) result)) (else (loop (cdr l) (cons (car l) result)))))) -(define-public (delete-if! pred l) +(define (delete-if! pred l) "Destructive version of `remove-if'." (let delete-if ((l l)) (cond ((null? l) '()) @@ -226,7 +230,7 @@ Return everything that's left." (set-cdr! l (delete-if (cdr l))) l)))) -(define-public (delete-if-not! pred l) +(define (delete-if-not! pred l) "Destructive version of `remove-if-not'." (let delete-if-not ((l l)) (cond ((null? l) '()) @@ -235,7 +239,7 @@ Return everything that's left." (set-cdr! l (delete-if-not (cdr l))) l)))) -(define-public (butlast lst n) +(define (butlast lst n) "Return all but the last N elements of LST." (letrec ((l (- (length lst) n)) (bl (lambda (lst n) @@ -247,25 +251,25 @@ Return everything that's left." (error "negative argument to butlast" n) l)))) -(define-public (and? . args) +(define (and? . args) "Return #t iff all of ARGS are true." (cond ((null? args) #t) ((car args) (apply and? (cdr args))) (else #f))) -(define-public (or? . args) +(define (or? . args) "Return #t iff any of ARGS is true." (cond ((null? args) #f) ((car args) #t) (else (apply or? (cdr args))))) -(define-public (has-duplicates? lst) +(define (has-duplicates? lst) "Return #t iff 2 members of LST are equal?, else #f." (cond ((null? lst) #f) ((member (car lst) (cdr lst)) #t) (else (has-duplicates? (cdr lst))))) -(define-public (pick p l) +(define (pick p l) "Apply P to each element of L, returning a list of elts for which P returns a non-#f value." (let loop ((s '()) @@ -275,7 +279,7 @@ for which P returns a non-#f value." ((p (car l)) (loop (cons (car l) s) (cdr l))) (else (loop s (cdr l)))))) -(define-public (pick-mappings p l) +(define (pick-mappings p l) "Apply P to each element of L, returning a list of the non-#f return values of P." (let loop ((s '()) @@ -285,7 +289,7 @@ non-#f return values of P." ((p (car l)) => (lambda (mapping) (loop (cons mapping s) (cdr l)))) (else (loop s (cdr l)))))) -(define-public (uniq l) +(define (uniq l) "Return a list containing elements of L, with duplicates removed." (let loop ((acc '()) (l l)) diff --git a/ice-9/debug.scm b/ice-9/debug.scm index bec2068b8..56729952d 100644 --- a/ice-9/debug.scm +++ b/ice-9/debug.scm @@ -44,12 +44,13 @@ ;;;; -(define-module (ice-9 debug)) +(define-module (ice-9 debug) + :export (frame-number->index trace untrace trace-stack untrace-stack)) ;;; {Misc} ;;; -(define-public (frame-number->index n . stack) +(define (frame-number->index n . stack) (let ((stack (if (null? stack) (fluid-ref the-last-stack) (car stack)))) @@ -66,7 +67,7 @@ ;;; (define traced-procedures '()) -(define-public (trace . args) +(define (trace . args) (if (null? args) (nameify traced-procedures) (begin @@ -87,7 +88,7 @@ (debug-enable 'trace) (nameify args)))) -(define-public (untrace . args) +(define (untrace . args) (if (and (null? args) (not (null? traced-procedures))) (apply untrace traced-procedures) @@ -112,7 +113,7 @@ (define traced-stack-ids (list 'repl-stack)) (define trace-all-stacks? #f) -(define-public (trace-stack id) +(define (trace-stack id) "Add ID to the set of stack ids for which tracing is active. If `#t' is in this set, tracing is active regardless of stack context. To remove ID again, use `untrace-stack'. If you add the same ID twice @@ -120,7 +121,7 @@ using `trace-stack', you will need to remove it twice." (set! traced-stack-ids (cons id traced-stack-ids)) (set! trace-all-stacks? (memq #t traced-stack-ids))) -(define-public (untrace-stack id) +(define (untrace-stack id) "Remove ID from the set of stack ids for which tracing is active." (set! traced-stack-ids (delq1! id traced-stack-ids)) (set! trace-all-stacks? (memq #t traced-stack-ids))) diff --git a/ice-9/debugger.scm b/ice-9/debugger.scm index f98509c2c..e65da390b 100644 --- a/ice-9/debugger.scm +++ b/ice-9/debugger.scm @@ -44,6 +44,7 @@ (define-module (ice-9 debugger) :use-module (ice-9 debug) :use-module (ice-9 format) + :export (debug) :no-backtrace ) @@ -54,7 +55,7 @@ (define debugger-prompt "debug> ") -(define-public (debug) +(define (debug) (let ((stack (fluid-ref the-last-stack))) (if stack (let ((state (make-state stack 0))) diff --git a/ice-9/expect.scm b/ice-9/expect.scm index 0fb55b7b7..ba12b2ab0 100644 --- a/ice-9/expect.scm +++ b/ice-9/expect.scm @@ -53,22 +53,26 @@ ;;; Code: (define-module (ice-9 expect) - :use-module (ice-9 regex)) + :use-module (ice-9 regex) + :export-syntax (expect expect-strings) + :export (expect-port expect-timeout expect-timeout-proc + expect-eof-proc expect-char-proc expect-strings-compile-flags + expect-strings-exec-flags expect-select expect-regexec)) ;;; Expect: a macro for selecting actions based on what it reads from a port. ;;; The idea is from Don Libes' expect based on Tcl. ;;; This version by Gary Houston incorporating ideas from Aubrey Jaffer. -(define-public expect-port #f) -(define-public expect-timeout #f) -(define-public expect-timeout-proc #f) -(define-public expect-eof-proc #f) -(define-public expect-char-proc #f) +(define expect-port #f) +(define expect-timeout #f) +(define expect-timeout-proc #f) +(define expect-eof-proc #f) +(define expect-char-proc #f) ;;; expect: each test is a procedure which is applied to the accumulating ;;; string. -(defmacro-public expect clauses +(defmacro expect clauses (let ((s (gensym)) (c (gensym)) (port (gensym)) @@ -134,12 +138,12 @@ (next-char))))))))))) -(define-public expect-strings-compile-flags regexp/newline) -(define-public expect-strings-exec-flags regexp/noteol) +(define expect-strings-compile-flags regexp/newline) +(define expect-strings-exec-flags regexp/noteol) ;;; the regexec front-end to expect: ;;; each test must evaluate to a regular expression. -(defmacro-public expect-strings clauses +(defmacro expect-strings clauses `(let ,@(let next-test ((tests (map car clauses)) (exprs (map cdr clauses)) (defs '()) @@ -162,7 +166,7 @@ ;;; simplified select: returns #t if input is waiting or #f if timed out or ;;; select was interrupted by a signal. ;;; timeout is an absolute time in floating point seconds. -(define-public (expect-select port timeout) +(define (expect-select port timeout) (let* ((secs-usecs (gettimeofday)) (relative (- timeout (car secs-usecs) @@ -175,7 +179,7 @@ ;;; match a string against a regexp, returning a list of strings (required ;;; by the => syntax) or #f. called once each time a character is added ;;; to s (eof? will be #f), and once when eof is reached (with eof? #t). -(define-public (expect-regexec rx s eof?) +(define (expect-regexec rx s eof?) ;; if expect-strings-exec-flags contains regexp/noteol, ;; remove it for the eof test. (let* ((flags (if (and eof? diff --git a/ice-9/hcons.scm b/ice-9/hcons.scm index 1b20a5362..811f9fd48 100644 --- a/ice-9/hcons.scm +++ b/ice-9/hcons.scm @@ -1,6 +1,6 @@ ;;; installed-scm-file -;;;; Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. +;;;; Copyright (C) 1995, 1996, 1998, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -43,7 +43,10 @@ ;;;; -(define-module (ice-9 hcons)) +(define-module (ice-9 hcons) + :export (hashq-cons-hash hashq-cons-assoc hashq-cons-get-handle + hashq-cons-create-handle! hashq-cons-ref hashq-cons-set! hashq-cons + hashq-conser make-gc-buffer)) ;;; {Eq? hash-consing} @@ -54,12 +57,12 @@ ;;; A hash conser does not contribute life to the pairs it returns. ;;; -(define-public (hashq-cons-hash pair n) +(define (hashq-cons-hash pair n) (modulo (logxor (hashq (car pair) 4194303) (hashq (cdr pair) 4194303)) n)) -(define-public (hashq-cons-assoc key l) +(define (hashq-cons-assoc key l) (and (not (null? l)) (or (and (pair? l) ; If not a pair, use its cdr? (pair? (car l)) @@ -69,22 +72,22 @@ (car l)) (hashq-cons-assoc key (cdr l))))) -(define-public (hashq-cons-get-handle table key) +(define (hashq-cons-get-handle table key) (hashx-get-handle hashq-cons-hash hashq-cons-assoc table key #f)) -(define-public (hashq-cons-create-handle! table key init) +(define (hashq-cons-create-handle! table key init) (hashx-create-handle! hashq-cons-hash hashq-cons-assoc table key init)) -(define-public (hashq-cons-ref table key) +(define (hashq-cons-ref table key) (hashx-ref hashq-cons-hash hashq-cons-assoc table key #f)) -(define-public (hashq-cons-set! table key val) +(define (hashq-cons-set! table key val) (hashx-set! hashq-cons-hash hashq-cons-assoc table key val)) -(define-public (hashq-cons table a d) +(define (hashq-cons table a d) (car (hashq-cons-create-handle! table (cons a d) #f))) -(define-public (hashq-conser hash-tab-or-size) +(define (hashq-conser hash-tab-or-size) (let ((table (if (vector? hash-tab-or-size) hash-tab-or-size (make-doubly-weak-hash-table hash-tab-or-size)))) @@ -93,7 +96,7 @@ -(define-public (make-gc-buffer n) +(define (make-gc-buffer n) (let ((ring (make-list n #f))) (append! ring ring) (lambda (next) diff --git a/ice-9/lineio.scm b/ice-9/lineio.scm index b45cf0d52..c18e87f7e 100644 --- a/ice-9/lineio.scm +++ b/ice-9/lineio.scm @@ -45,7 +45,9 @@ (define-module (ice-9 lineio) - :use-module (ice-9 readline)) + :use-module (ice-9 readline) + :export (unread-string read-string lineio-port? + make-line-buffering-input-port)) ;;; {Line Buffering Input Ports} @@ -77,15 +79,15 @@ ;; 'unread-string and 'read-string properties, bound to hooks ;; implementing these functions. ;; -(define-public (unread-string str line-buffering-input-port) +(define (unread-string str line-buffering-input-port) ((object-property line-buffering-input-port 'unread-string) str)) ;; -(define-public (read-string line-buffering-input-port) +(define (read-string line-buffering-input-port) ((object-property line-buffering-input-port 'read-string))) -(define-public (lineio-port? port) +(define (lineio-port? port) (not (not (object-property port 'read-string)))) ;; make-line-buffering-input-port port @@ -96,7 +98,7 @@ ;; to read-char, read-string, and unread-string. ;; -(define-public (make-line-buffering-input-port underlying-port) +(define (make-line-buffering-input-port underlying-port) (let* (;; buffers - a list of strings put back by unread-string or cached ;; using read-line. ;; diff --git a/ice-9/ls.scm b/ice-9/ls.scm index 60c765eb9..37cdaf019 100644 --- a/ice-9/ls.scm +++ b/ice-9/ls.scm @@ -1,6 +1,6 @@ ;;;; ls.scm --- functions for browsing modules ;;;; -;;;; Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. +;;;; Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -43,7 +43,9 @@ ;;;; (define-module (ice-9 ls) - :use-module (ice-9 common-list)) + :use-module (ice-9 common-list) + :export (local-definitions-in definitions-in ls lls + recursive-local-define)) ;;;; ;;; local-definitions-in root name @@ -76,7 +78,7 @@ ;;; ;;; Analogous to `ls', but with local definitions only. -(define-public (local-definitions-in root names) +(define (local-definitions-in root names) (let ((m (nested-ref root names)) (answer '())) (if (not (module? m)) @@ -84,7 +86,7 @@ (module-for-each (lambda (k v) (set! answer (cons k answer))) m)) answer)) -(define-public (definitions-in root names) +(define (definitions-in root names) (let ((m (nested-ref root names))) (if (not (module? m)) m @@ -93,7 +95,7 @@ (map (lambda (m2) (definitions-in m2 '())) (module-uses m))))))) -(define-public (ls . various-refs) +(define (ls . various-refs) (if (pair? various-refs) (if (cdr various-refs) (map (lambda (ref) @@ -102,7 +104,7 @@ (definitions-in (current-module) (car various-refs))) (definitions-in (current-module) '()))) -(define-public (lls . various-refs) +(define (lls . various-refs) (if (pair? various-refs) (if (cdr various-refs) (map (lambda (ref) @@ -111,7 +113,7 @@ (local-definitions-in (current-module) (car various-refs))) (local-definitions-in (current-module) '()))) -(define-public (recursive-local-define name value) +(define (recursive-local-define name value) (let ((parent (reverse! (cdr (reverse name))))) (and parent (make-modules-in (current-module) parent)) (local-define name value))) diff --git a/ice-9/mapping.scm b/ice-9/mapping.scm index 3630147ab..34820ee4f 100644 --- a/ice-9/mapping.scm +++ b/ice-9/mapping.scm @@ -1,6 +1,6 @@ ;;; installed-scm-file -;;;; Copyright (C) 1996 Free Software Foundation, Inc. +;;;; Copyright (C) 1996, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -45,46 +45,53 @@ (define-module (ice-9 mapping) - :use-module (ice-9 poe)) + :use-module (ice-9 poe) + :export (mapping-hooks-type make-mapping-hooks mapping-hooks? + mapping-hooks-get-handle mapping-hooks-create-handle + mapping-hooks-remove mapping-type make-mapping mapping? + mapping-hooks mapping-data set-mapping-hooks! set-mapping-data! + mapping-get-handle mapping-create-handle! mapping-remove! + mapping-ref mapping-set! hash-table-mapping-hooks + make-hash-table-mapping hash-table-mapping)) -(define-public mapping-hooks-type (make-record-type 'mapping-hooks '(get-handle - create-handle - remove))) +(define mapping-hooks-type (make-record-type 'mapping-hooks '(get-handle + create-handle + remove))) -(define-public make-mapping-hooks (perfect-funcq 17 (record-constructor mapping-hooks-type))) -(define-public mapping-hooks? (record-predicate mapping-hooks-type)) -(define-public mapping-hooks-get-handle (record-accessor mapping-hooks-type 'get-handle)) -(define-public mapping-hooks-create-handle (record-accessor mapping-hooks-type 'create-handle)) -(define-public mapping-hooks-remove (record-accessor mapping-hooks-type 'remove)) +(define make-mapping-hooks (perfect-funcq 17 (record-constructor mapping-hooks-type))) +(define mapping-hooks? (record-predicate mapping-hooks-type)) +(define mapping-hooks-get-handle (record-accessor mapping-hooks-type 'get-handle)) +(define mapping-hooks-create-handle (record-accessor mapping-hooks-type 'create-handle)) +(define mapping-hooks-remove (record-accessor mapping-hooks-type 'remove)) -(define-public mapping-type (make-record-type 'mapping '(hooks data))) -(define-public make-mapping (record-constructor mapping-type)) -(define-public mapping? (record-predicate mapping-type)) -(define-public mapping-hooks (record-accessor mapping-type 'hooks)) -(define-public mapping-data (record-accessor mapping-type 'data)) -(define-public set-mapping-hooks! (record-modifier mapping-type 'hooks)) -(define-public set-mapping-data! (record-modifier mapping-type 'data)) +(define mapping-type (make-record-type 'mapping '(hooks data))) +(define make-mapping (record-constructor mapping-type)) +(define mapping? (record-predicate mapping-type)) +(define mapping-hooks (record-accessor mapping-type 'hooks)) +(define mapping-data (record-accessor mapping-type 'data)) +(define set-mapping-hooks! (record-modifier mapping-type 'hooks)) +(define set-mapping-data! (record-modifier mapping-type 'data)) -(define-public (mapping-get-handle map key) +(define (mapping-get-handle map key) ((mapping-hooks-get-handle (mapping-hooks map)) map key)) -(define-public (mapping-create-handle! map key . opts) +(define (mapping-create-handle! map key . opts) (apply (mapping-hooks-create-handle (mapping-hooks map)) map key opts)) -(define-public (mapping-remove! map key) +(define (mapping-remove! map key) ((mapping-hooks-remove (mapping-hooks map)) map key)) -(define-public (mapping-ref map key . dflt) +(define (mapping-ref map key . dflt) (cond ((mapping-get-handle map key) => cdr) (dflt => car) (else #f))) -(define-public (mapping-set! map key val) +(define (mapping-set! map key val) (set-cdr! (mapping-create-handle! map key #f) val)) -(define-public hash-table-mapping-hooks +(define hash-table-mapping-hooks (let ((wrap (lambda (proc) (lambda (1st . rest) (apply proc (mapping-data 1st) rest))))) (perfect-funcq 17 @@ -114,10 +121,10 @@ (lambda (table key) (hashx-get-handle hash-proc assoc-proc delete-proc table key))))))))))) -(define-public (make-hash-table-mapping table hash-proc assoc-proc delete-proc) +(define (make-hash-table-mapping table hash-proc assoc-proc delete-proc) (make-mapping (hash-table-mapping-hooks hash-proc assoc-proc delete-proc) table)) -(define-public (hash-table-mapping . options) +(define (hash-table-mapping . options) (let* ((size (or (and options (number? (car options)) (car options)) 71)) (hash-proc (or (kw-arg-ref options :hash-proc) hash)) diff --git a/ice-9/null.scm b/ice-9/null.scm index 30f785a4f..2ca35529c 100644 --- a/ice-9/null.scm +++ b/ice-9/null.scm @@ -43,19 +43,18 @@ ;;;; The null environment - only syntactic bindings (define-module (ice-9 null) - :use-module (ice-9 syncase)) - -(re-export define quote lambda if set! + :use-module (ice-9 syncase) + :re-export-syntax (define quote lambda if set! - cond case and or + cond case and or + + let let* letrec - let let* letrec + begin do - begin do + delay - delay + quasiquote - quasiquote - - define-syntax - let-syntax letrec-syntax) + define-syntax + let-syntax letrec-syntax)) diff --git a/ice-9/optargs.scm b/ice-9/optargs.scm index 47e1a5045..bbeab8cf4 100644 --- a/ice-9/optargs.scm +++ b/ice-9/optargs.scm @@ -82,7 +82,15 @@ ;;; Code: -(define-module (ice-9 optargs)) +(define-module (ice-9 optargs) + :export-syntax (let-optional + let-optional* + let-keywords + let-keywords* + define* lambda* + define*-public + defmacro* + defmacro*-public)) ;; let-optional rest-arg (binding ...) . body ;; let-optional* rest-arg (binding ...) . body @@ -100,10 +108,10 @@ ;; bound to whatever may have been left of rest-arg. ;; -(defmacro-public let-optional (REST-ARG BINDINGS . BODY) +(defmacro let-optional (REST-ARG BINDINGS . BODY) (let-optional-template REST-ARG BINDINGS BODY 'let)) -(defmacro-public let-optional* (REST-ARG BINDINGS . BODY) +(defmacro let-optional* (REST-ARG BINDINGS . BODY) (let-optional-template REST-ARG BINDINGS BODY 'let*)) @@ -123,10 +131,10 @@ ;; -(defmacro-public let-keywords (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) +(defmacro let-keywords (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY 'let)) -(defmacro-public let-keywords* (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) +(defmacro let-keywords* (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY 'let*)) @@ -248,7 +256,7 @@ ;; Lisp dialects. -(defmacro-public lambda* (ARGLIST . BODY) +(defmacro lambda* (ARGLIST . BODY) (parse-arglist ARGLIST (lambda (non-optional-args optionals keys aok? rest-arg) @@ -387,10 +395,10 @@ ;; Of course, define*[-public] also supports #:rest and #:allow-other-keys ;; in the same way as lambda*. -(defmacro-public define* (ARGLIST . BODY) +(defmacro define* (ARGLIST . BODY) (define*-guts 'define ARGLIST BODY)) -(defmacro-public define*-public (ARGLIST . BODY) +(defmacro define*-public (ARGLIST . BODY) (define*-guts 'define-public ARGLIST BODY)) ;; The guts of define* and define*-public. @@ -421,10 +429,10 @@ ;; semantics. Here is an example of a macro with an optional argument: ;; (defmacro* transmorgify (a #:optional b) -(defmacro-public defmacro* (NAME ARGLIST . BODY) +(defmacro defmacro* (NAME ARGLIST . BODY) (defmacro*-guts 'define NAME ARGLIST BODY)) -(defmacro-public defmacro*-public (NAME ARGLIST . BODY) +(defmacro defmacro*-public (NAME ARGLIST . BODY) (defmacro*-guts 'define-public NAME ARGLIST BODY)) ;; The guts of defmacro* and defmacro*-public diff --git a/ice-9/poe.scm b/ice-9/poe.scm index 91acd1195..96133c764 100644 --- a/ice-9/poe.scm +++ b/ice-9/poe.scm @@ -1,6 +1,6 @@ ;;; installed-scm-file -;;;; Copyright (C) 1996 Free Software Foundation, Inc. +;;;; Copyright (C) 1996, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -44,7 +44,8 @@ (define-module (ice-9 poe) - :use-module (ice-9 hcons)) + :use-module (ice-9 hcons) + :export (pure-funcq perfect-funcq)) @@ -95,7 +96,7 @@ -(define-public (pure-funcq base-func) +(define (pure-funcq base-func) (lambda args (let ((cached (hashx-get-handle funcq-hash funcq-assoc funcq-memo (cons base-func args)))) (if cached @@ -117,7 +118,7 @@ ;;; funcq never does. ;;; -(define-public (perfect-funcq size base-func) +(define (perfect-funcq size base-func) (define funcq-memo (make-hash-table size)) (lambda args diff --git a/ice-9/popen.scm b/ice-9/popen.scm index 62846ff6c..2a3bdd605 100644 --- a/ice-9/popen.scm +++ b/ice-9/popen.scm @@ -1,6 +1,6 @@ ;; popen emulation, for non-stdio based ports. -;;;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -42,7 +42,9 @@ ;;;; If you do not wish that, delete this exception notice. ;;;; -(define-module (ice-9 popen)) +(define-module (ice-9 popen) + :export (port/pid-table open-pipe close-pipe open-input-pipe + open-output-pipe)) ;; (define-module (guile popen) ;; :use-module (guile posix)) @@ -52,7 +54,7 @@ (define pipe-guardian (make-guardian)) ;; a weak hash-table to store the process ids. -(define-public port/pid-table (make-weak-key-hash-table 31)) +(define port/pid-table (make-weak-key-hash-table 31)) (define (ensure-fdes port mode) (or (false-if-exception (fileno port)) @@ -134,7 +136,7 @@ (cdr p)) pid)))))) -(define-public (open-pipe command mode) +(define (open-pipe command mode) "Executes the shell command @var{command} (a string) in a subprocess. A pipe to the process is created and returned. @var{modes} specifies whether an input or output pipe to the process is created: it should @@ -173,7 +175,7 @@ be the value of @code{OPEN_READ} or @code{OPEN_WRITE}." (car port/pid) (cdr port/pid)))))) (lambda args #f))) -(define-public (close-pipe p) +(define (close-pipe p) "Closes the pipe created by @code{open-pipe}, then waits for the process to terminate and returns its status value, @xref{Processes, waitpid}, for information on how to interpret this value." @@ -194,10 +196,10 @@ information on how to interpret this value." (add-hook! after-gc-hook reap-pipes) -(define-public (open-input-pipe command) +(define (open-input-pipe command) "Equivalent to @code{open-pipe} with mode @code{OPEN_READ}" (open-pipe command OPEN_READ)) -(define-public (open-output-pipe command) +(define (open-output-pipe command) "Equivalent to @code{open-pipe} with mode @code{OPEN_WRITE}" (open-pipe command OPEN_WRITE)) diff --git a/ice-9/pretty-print.scm b/ice-9/pretty-print.scm index 2eac93e94..cc32c8917 100644 --- a/ice-9/pretty-print.scm +++ b/ice-9/pretty-print.scm @@ -41,9 +41,8 @@ ;;;; whether to permit this exception to apply to your modifications. ;;;; If you do not wish that, delete this exception notice. ;;;; -(define-module (ice-9 pretty-print)) - -(export pretty-print) +(define-module (ice-9 pretty-print) + :export (pretty-print)) ;; From SLIB. diff --git a/ice-9/q.scm b/ice-9/q.scm index 335ec4ecd..b09f69537 100644 --- a/ice-9/q.scm +++ b/ice-9/q.scm @@ -81,7 +81,9 @@ ;;; Code: -(define-module (ice-9 q)) +(define-module (ice-9 q) + :export (sync-q! make-q q? q-empty? q-empty-check q-front q-rear + q-remove! q-push! enq! q-pop! deq! q-length)) ;;; sync-q! ;;; The procedure @@ -90,7 +92,7 @@ ;;; ;;; recomputes and resets the component of a queue. ;;; -(define-public (sync-q! q) +(define (sync-q! q) (set-cdr! q (if (pair? (car q)) (last-pair (car q)) #f)) q) @@ -98,7 +100,7 @@ ;;; make-q ;;; return a new q. ;;; -(define-public (make-q) (cons '() #f)) +(define (make-q) (cons '() #f)) ;;; q? obj ;;; Return true if obj is a Q. @@ -106,7 +108,7 @@ ;;; or it is a pair P with (list? (car P)) ;;; and (eq? (cdr P) (last-pair (car P))). ;;; -(define-public (q? obj) +(define (q? obj) (and (pair? obj) (if (pair? (car obj)) (eq? (cdr obj) (last-pair (car obj))) @@ -115,29 +117,29 @@ ;;; q-empty? obj ;;; -(define-public (q-empty? obj) (null? (car obj))) +(define (q-empty? obj) (null? (car obj))) ;;; q-empty-check q ;;; Throw a q-empty exception if Q is empty. -(define-public (q-empty-check q) (if (q-empty? q) (throw 'q-empty q))) +(define (q-empty-check q) (if (q-empty? q) (throw 'q-empty q))) ;;; q-front q ;;; Return the first element of Q. -(define-public (q-front q) (q-empty-check q) (caar q)) +(define (q-front q) (q-empty-check q) (caar q)) ;;; q-rear q ;;; Return the last element of Q. -(define-public (q-rear q) (q-empty-check q) (cadr q)) +(define (q-rear q) (q-empty-check q) (cadr q)) ;;; q-remove! q obj ;;; Remove all occurences of obj from Q. -(define-public (q-remove! q obj) +(define (q-remove! q obj) (set-car! q (delq! obj (car q))) (sync-q! q)) ;;; q-push! q obj ;;; Add obj to the front of Q -(define-public (q-push! q obj) +(define (q-push! q obj) (let ((h (cons obj (car q)))) (set-car! q h) (or (cdr q) (set-cdr! q h))) @@ -145,7 +147,7 @@ ;;; enq! q obj ;;; Add obj to the rear of Q -(define-public (enq! q obj) +(define (enq! q obj) (let ((h (cons obj '()))) (if (null? (car q)) (set-car! q h) @@ -155,7 +157,7 @@ ;;; q-pop! q ;;; Take the front of Q and return it. -(define-public (q-pop! q) +(define (q-pop! q) (q-empty-check q) (let ((it (caar q)) (next (cdar q))) @@ -166,11 +168,11 @@ ;;; deq! q ;;; Take the front of Q and return it. -(define-public deq! q-pop!) +(define deq! q-pop!) ;;; q-length q ;;; Return the number of enqueued elements. ;;; -(define-public (q-length q) (length (car q))) +(define (q-length q) (length (car q))) ;;; q.scm ends here diff --git a/ice-9/r5rs.scm b/ice-9/r5rs.scm index 73b9d0fe0..0704ce5a2 100644 --- a/ice-9/r5rs.scm +++ b/ice-9/r5rs.scm @@ -42,25 +42,22 @@ ;;;; R5RS bindings -(define-module (ice-9 r5rs)) +(define-module (ice-9 r5rs) + :export (scheme-report-environment + ;;transcript-on + ;;transcript-off + ) + :re-export (interaction-environment + + call-with-input-file call-with-output-file + with-input-from-file with-output-to-file + open-input-file open-output-file + close-input-port close-output-port + + load)) (module-use! %module-public-interface (resolve-interface '(ice-9 safe-r5rs))) -(export scheme-report-environment - ;;transcript-on - ;;transcript-off - ) - -(re-export interaction-environment - - call-with-input-file call-with-output-file - with-input-from-file with-output-to-file - open-input-file open-output-file - close-input-port close-output-port - - load - ) - (define scheme-report-interface %module-public-interface) (define (scheme-report-environment n) diff --git a/ice-9/rdelim.scm b/ice-9/rdelim.scm index edc8cf8ec..97c27039f 100644 --- a/ice-9/rdelim.scm +++ b/ice-9/rdelim.scm @@ -46,13 +46,13 @@ ;;; This is the Scheme part of the module for delimited I/O. It's ;;; similar to (scsh rdelim) but somewhat incompatible. -(define-module (ice-9 rdelim)) +(define-module (ice-9 rdelim) + :export (read-line read-line! read-delimited read-delimited! + %read-delimited! %read-line write-line) ; C + ) (%init-rdelim-builtins) -(export read-line read-line! read-delimited read-delimited!) -(export %read-delimited! %read-line write-line) ; C - (define (read-line! string . maybe-port) ;; corresponds to SCM_LINE_INCREMENTORS in libguile. (define scm-line-incrementors "\n") diff --git a/ice-9/regex.scm b/ice-9/regex.scm index 023c0b7bc..fb4a93e58 100644 --- a/ice-9/regex.scm +++ b/ice-9/regex.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 1997, 1999 Free Software Foundation, Inc. +;;;; Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -42,7 +42,11 @@ ;;;; POSIX regex support functions. -(define-module (ice-9 regex)) +(define-module (ice-9 regex) + :export (match:count match:string match:prefix match:suffix + regexp-match? regexp-quote match:start match:end match:substring + string-match regexp-substitute fold-matches list-matches + regexp-substitute/global)) ;;; FIXME: ;;; It is not clear what should happen if a `match' function @@ -53,22 +57,22 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; These procedures are not defined in SCSH, but I found them useful. -(define-public (match:count match) +(define (match:count match) (- (vector-length match) 1)) -(define-public (match:string match) +(define (match:string match) (vector-ref match 0)) -(define-public (match:prefix match) +(define (match:prefix match) (substring (match:string match) 0 (match:start match 0))) -(define-public (match:suffix match) +(define (match:suffix match) (substring (match:string match) (match:end match 0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; SCSH compatibility routines. -(define-public (regexp-match? match) +(define (regexp-match? match) (and (vector? match) (string? (vector-ref match 0)) (let loop ((i 1)) @@ -79,7 +83,7 @@ (loop (+ 1 i))) (else #f))))) -(define-public (regexp-quote regexp) +(define (regexp-quote regexp) (call-with-output-string (lambda (p) (let loop ((i 0)) @@ -91,21 +95,21 @@ (write-char (string-ref regexp i) p) (loop (1+ i)))))))) -(define-public (match:start match . args) +(define (match:start match . args) (let* ((matchnum (if (pair? args) (+ 1 (car args)) 1)) (start (car (vector-ref match matchnum)))) (if (= start -1) #f start))) -(define-public (match:end match . args) +(define (match:end match . args) (let* ((matchnum (if (pair? args) (+ 1 (car args)) 1)) (end (cdr (vector-ref match matchnum)))) (if (= end -1) #f end))) -(define-public (match:substring match . args) +(define (match:substring match . args) (let* ((matchnum (if (pair? args) (car args) 0)) @@ -113,12 +117,12 @@ (end (match:end match matchnum))) (and start end (substring (match:string match) start end)))) -(define-public (string-match pattern str . args) +(define (string-match pattern str . args) (let ((rx (make-regexp pattern)) (start (if (pair? args) (car args) 0))) (regexp-exec rx str start))) -(define-public (regexp-substitute port match . items) +(define (regexp-substitute port match . items) ;; If `port' is #f, send output to a string. (if (not port) (call-with-output-string @@ -153,7 +157,7 @@ ;;; `b'. Around or within `xxx', only the match covering all three ;;; x's counts, because the rest are not maximal. -(define-public (fold-matches regexp string init proc . flags) +(define (fold-matches regexp string init proc . flags) (let ((regexp (if (regexp? regexp) regexp (make-regexp regexp))) (flags (if (null? flags) 0 flags))) (let loop ((start 0) @@ -171,10 +175,10 @@ (else (loop (match:end m) (proc m value) #t))))))) -(define-public (list-matches regexp string . flags) +(define (list-matches regexp string . flags) (reverse! (apply fold-matches regexp string '() cons flags))) -(define-public (regexp-substitute/global port regexp string . items) +(define (regexp-substitute/global port regexp string . items) ;; If `port' is #f, send output to a string. (if (not port) diff --git a/ice-9/runq.scm b/ice-9/runq.scm index 4929756d3..4f8f8026c 100644 --- a/ice-9/runq.scm +++ b/ice-9/runq.scm @@ -72,7 +72,10 @@ ;;; Code: (define-module (ice-9 runq) - :use-module (ice-9 q)) + :use-module (ice-9 q) + :export (runq-control make-void-runq make-fair-runq + make-exclusive-runq make-subordinate-runq-to strip-sequence + fair-strip-subtask)) ;;;; ;;; (runq-control q msg . args) @@ -91,7 +94,7 @@ ;;; 'kill! ;; empty the queue ;;; else ;; throw 'not-understood ;;; -(define-public (runq-control q msg . args) +(define (runq-control q msg . args) (case msg ((add!) (for-each (lambda (t) (enq! q t)) args) '*unspecified*) ((enqueue!) (for-each (lambda (t) (enq! q t)) args) '*unspecified*) @@ -109,7 +112,7 @@ ;;; Make a runq that discards all messages except "length", for which ;;; it returns 0. ;;; -(define-public (make-void-runq) +(define (make-void-runq) (lambda opts (and opts (apply-to-args opts @@ -129,7 +132,7 @@ ;;; to the end of the queue, meaning it will be the last to execute ;;; of all the remaining procedures. ;;; -(define-public (make-fair-runq) +(define (make-fair-runq) (letrec ((q (make-q)) (self (lambda ctl @@ -165,7 +168,7 @@ ;;; of that (if the CDR is not nil). This way, the rest of the thunks ;;; in the list that contained W have priority over the return value of W. ;;; -(define-public (make-exclusive-runq) +(define (make-exclusive-runq) (letrec ((q (make-q)) (self (lambda ctl @@ -197,7 +200,7 @@ ;;; N is the length of the basic-inferior queue when the proxy ;;; strip is entered. [Countless scheduling variations are possible.] ;;; -(define-public (make-subordinate-runq-to superior-runq basic-runq) +(define (make-subordinate-runq-to superior-runq basic-runq) (let ((runq-task (cons #f #f))) (set-car! runq-task (lambda () @@ -238,7 +241,7 @@ ;;; ;;; Returns a new strip which is the concatenation of the argument strips. ;;; -(define-public ((strip-sequence . strips)) +(define ((strip-sequence . strips)) (let loop ((st (let ((a strips)) (set! strips #f) a))) (and (not (null? st)) (let ((then ((car st)))) @@ -255,7 +258,7 @@ ;;; ;;; ;;; -(define-public (fair-strip-subtask . initial-strips) +(define (fair-strip-subtask . initial-strips) (let ((st (make-fair-runq))) (apply st 'add! initial-strips) st)) diff --git a/ice-9/safe-r5rs.scm b/ice-9/safe-r5rs.scm index b17dd57b0..c60fb820f 100644 --- a/ice-9/safe-r5rs.scm +++ b/ice-9/safe-r5rs.scm @@ -42,121 +42,120 @@ ;;;; Safe subset of R5RS bindings -(define-module (ice-9 safe-r5rs)) +(define-module (ice-9 safe-r5rs) + :re-export (eqv? eq? equal? + number? complex? real? rational? integer? + exact? inexact? + = < > <= >= + zero? positive? negative? odd? even? + max min + + * - / + abs + quotient remainder modulo + gcd lcm + ;;numerator denominator XXX + ;;rationalize XXX + floor ceiling truncate round + exp log sin cos tan asin acos atan + sqrt + expt + make-rectangular make-polar real-part imag-part magnitude angle + exact->inexact inexact->exact + + number->string string->number + + boolean? + not + + pair? + cons car cdr + set-car! set-cdr! + caar cadr cdar cddr + caaar caadr cadar caddr cdaar cdadr cddar cdddr + caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr + cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr + null? + list? + list + length + append + reverse + list-tail list-ref + memq memv member + assq assv assoc + + symbol? + symbol->string string->symbol + + char? + char=? char? char<=? char>=? + char-ci=? char-ci? char-ci<=? char-ci>=? + char-alphabetic? char-numeric? char-whitespace? + char-upper-case? char-lower-case? + char->integer integer->char + char-upcase + char-downcase + + string? + make-string + string + string-length + string-ref string-set! + string=? string-ci=? + string? string<=? string>=? + string-ci? string-ci<=? string-ci>=? + substring + string-length + string-append + string->list list->string + string-copy string-fill! + + vector? + make-vector + vector + vector-length + vector-ref vector-set! + vector->list list->vector + vector-fill! + + procedure? + apply + map + for-each + force + + call-with-current-continuation + + values + call-with-values + dynamic-wind + + eval + + input-port? output-port? + current-input-port current-output-port + + read + read-char + peek-char + eof-object? + char-ready? + + write + display + newline + write-char + + ;;transcript-on + ;;transcript-off + ) + + :export (null-environment)) (define null-interface (resolve-interface '(ice-9 null))) (module-use! %module-public-interface null-interface) -(re-export eqv? eq? equal? - number? complex? real? rational? integer? - exact? inexact? - = < > <= >= - zero? positive? negative? odd? even? - max min - + * - / - abs - quotient remainder modulo - gcd lcm - ;;numerator denominator XXX - ;;rationalize XXX - floor ceiling truncate round - exp log sin cos tan asin acos atan - sqrt - expt - make-rectangular make-polar real-part imag-part magnitude angle - exact->inexact inexact->exact - - number->string string->number - - boolean? - not - - pair? - cons car cdr - set-car! set-cdr! - caar cadr cdar cddr - caaar caadr cadar caddr cdaar cdadr cddar cdddr - caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr - cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr - null? - list? - list - length - append - reverse - list-tail list-ref - memq memv member - assq assv assoc - - symbol? - symbol->string string->symbol - - char? - char=? char? char<=? char>=? - char-ci=? char-ci? char-ci<=? char-ci>=? - char-alphabetic? char-numeric? char-whitespace? - char-upper-case? char-lower-case? - char->integer integer->char - char-upcase - char-downcase - - string? - make-string - string - string-length - string-ref string-set! - string=? string-ci=? - string? string<=? string>=? - string-ci? string-ci<=? string-ci>=? - substring - string-length - string-append - string->list list->string - string-copy string-fill! - - vector? - make-vector - vector - vector-length - vector-ref vector-set! - vector->list list->vector - vector-fill! - - procedure? - apply - map - for-each - force - - call-with-current-continuation - - values - call-with-values - dynamic-wind - - eval - - input-port? output-port? - current-input-port current-output-port - - read - read-char - peek-char - eof-object? - char-ready? - - write - display - newline - write-char - - ;;transcript-on - ;;transcript-off - ) - -(export null-environment) - (define (null-environment n) (if (not (= n 5)) (scm-error 'misc-error 'null-environment diff --git a/ice-9/safe.scm b/ice-9/safe.scm index b8bd7ac6f..aca656d1d 100644 --- a/ice-9/safe.scm +++ b/ice-9/safe.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -42,11 +42,12 @@ ;;;; Safe subset of R5RS bindings -(define-module (ice-9 safe)) +(define-module (ice-9 safe) + :export (safe-environment make-safe-module)) (define safe-r5rs-interface (resolve-interface '(ice-9 safe-r5rs))) -(define-public (safe-environment n) +(define (safe-environment n) (if (not (= n 5)) (scm-error 'misc-error 'safe-environment "~A is not a valid version" @@ -54,5 +55,5 @@ '())) safe-r5rs-interface) -(define-public (make-safe-module) +(define (make-safe-module) (make-module 1021 (list safe-r5rs-interface))) diff --git a/ice-9/session.scm b/ice-9/session.scm index 23ae667f6..00a023084 100644 --- a/ice-9/session.scm +++ b/ice-9/session.scm @@ -44,13 +44,16 @@ (define-module (ice-9 session) :use-module (ice-9 documentation) :use-module (ice-9 regex) - :use-module (ice-9 rdelim)) + :use-module (ice-9 rdelim) + :export (help apropos apropos-internal apropos-fold + apropos-fold-accessible apropos-fold-exported apropos-fold-all + source arity system-module)) ;;; Documentation ;;; -(define-public help +(define help (procedure->syntax (lambda (exp env) "(help [NAME]) @@ -255,7 +258,7 @@ where OPTIONSET is one of debug, read, eval, print ;;; Author: Roland Orre ;;; -(define-public (apropos rgx . options) +(define (apropos rgx . options) "Search for bindings: apropos regexp {options= 'full 'shadow 'value}" (if (zero? (string-length rgx)) "Empty string not allowed" @@ -300,7 +303,7 @@ where OPTIONSET is one of debug, read, eval, print obarray))) modules)))) -(define-public (apropos-internal rgx) +(define (apropos-internal rgx) "Return a list of accessible variable names." (apropos-fold (lambda (module name var data) (cons name data)) @@ -308,7 +311,7 @@ where OPTIONSET is one of debug, read, eval, print rgx (apropos-fold-accessible (current-module)))) -(define-public (apropos-fold proc init rgx folder) +(define (apropos-fold proc init rgx folder) "Folds PROCEDURE over bindings matching third arg REGEXP. Result is @@ -369,7 +372,7 @@ It is an image under the mapping EXTRACT." data))) ((null? modules) data)))))) -(define-public (apropos-fold-accessible module) +(define (apropos-fold-accessible module) (make-fold-modules (lambda () (list module)) module-uses identity)) @@ -388,18 +391,18 @@ It is an image under the mapping EXTRACT." '() (module-obarray m))) -(define-public apropos-fold-exported +(define apropos-fold-exported (make-fold-modules root-modules submodules module-public-interface)) -(define-public apropos-fold-all +(define apropos-fold-all (make-fold-modules root-modules submodules identity)) -(define-public (source obj) +(define (source obj) (cond ((procedure? obj) (procedure-source obj)) ((macro? obj) (procedure-source (macro-transformer obj))) (else #f))) -(define-public (arity obj) +(define (arity obj) (define (display-arg-list arg-list) (display #\`) (display (car arg-list)) @@ -480,7 +483,7 @@ It is an image under the mapping EXTRACT." (display #\')))))))) (display ".\n")) -(define-public system-module +(define system-module (procedure->syntax (lambda (exp env) (let* ((m (nested-ref the-root-module diff --git a/ice-9/slib.scm b/ice-9/slib.scm index c7d3af57f..e91edaedc 100644 --- a/ice-9/slib.scm +++ b/ice-9/slib.scm @@ -1,6 +1,6 @@ ;;;; slib.scm --- definitions needed to get SLIB to work with Guile ;;;; -;;;; Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This file is part of GUILE. ;;;; @@ -44,8 +44,18 @@ ;;;; If you do not wish that, delete this exception notice. ;;;; (define-module (ice-9 slib) + :export (slib:load slib:load-source defmacro:load + implementation-vicinity library-vicinity home-vicinity + scheme-implementation-type scheme-implementation-version + output-port-width output-port-height identity array-indexes + make-random-state require slib:error slib:exit slib:warn slib:eval + defmacro:eval logical:logand logical:logior logical:logxor + logical:lognot logical:ash logical:logcount logical:integer-length + logical:bit-extract logical:integer-expt logical:ipow-by-squaring + slib:eval-load slib:tab slib:form-feed difftime offset-time + software-type) :no-backtrace) - + (define (eval-load evl) @@ -86,71 +96,98 @@ (define (defined? symbol) (module-defined? slib-module symbol)) -(define slib:features - (append '(source - eval - abort - alist - defmacro - delay - dynamic-wind - full-continuation - hash - hash-table - line-i/o - logical - multiarg/and- - multiarg-apply - promise - rev2-procedures - rev4-optional-procedures - string-port - with-file) +;;; *FEATURES* should be set to a list of symbols describing features +;;; of this implementation. Suggestions for features are: +(define *features* + (append + '( + source ;can load scheme source files + ;(slib:load-source "filename") +; compiled ;can load compiled files + ;(slib:load-compiled "filename") - (if (defined? 'getenv) - '(getenv) - '()) + ;; Scheme report features - (if (defined? 'current-time) - '(current-time) - '()) +; rev5-report ;conforms to + eval ;R5RS two-argument eval +; values ;R5RS multiple values + dynamic-wind ;R5RS dynamic-wind +; macro ;R5RS high level macros + delay ;has DELAY and FORCE + multiarg-apply ;APPLY can take more than 2 args. +; rationalize + rev4-optional-procedures ;LIST-TAIL, STRING->LIST, + ;LIST->STRING, STRING-COPY, + ;STRING-FILL!, LIST->VECTOR, + ;VECTOR->LIST, and VECTOR-FILL! - (if (defined? 'system) - '(system) - '()) +; rev4-report ;conforms to - (if (defined? 'array?) - '(array) - '()) +; ieee-p1178 ;conforms to - (if (defined? 'char-ready?) - '(char-ready?) - '()) +; rev3-report ;conforms to - (if (defined? 'array-for-each) - '(array-for-each) - '()) + rev2-procedures ;SUBSTRING-MOVE-LEFT!, + ;SUBSTRING-MOVE-RIGHT!, + ;SUBSTRING-FILL!, + ;STRING-NULL?, APPEND!, 1+, + ;-1+, ?, >=? +; object-hash ;has OBJECT-HASH - (if (and (string->number "0.0") (inexact? (string->number "0.0"))) - '(inexact) - '()) + multiarg/and- ;/ and - can take more than 2 args. + with-file ;has WITH-INPUT-FROM-FILE and + ;WITH-OUTPUT-FROM-FILE +; transcript ;TRANSCRIPT-ON and TRANSCRIPT-OFF +; ieee-floating-point ;conforms to IEEE Standard 754-1985 + ;IEEE Standard for Binary + ;Floating-Point Arithmetic. + full-continuation ;can return multiple times - (if (rational? (string->number "1/19")) - '(rational) - '()) + ;; Other common features - (if (real? (string->number "0.0")) - '(real) - ()) +; srfi ;srfi-0, COND-EXPAND finds all srfi-* +; sicp ;runs code from Structure and + ;Interpretation of Computer + ;Programs by Abelson and Sussman. + defmacro ;has Common Lisp DEFMACRO +; record ;has user defined data structures + string-port ;has CALL-WITH-INPUT-STRING and + ;CALL-WITH-OUTPUT-STRING +; sort +; pretty-print +; object->string +; format ;Common-lisp output formatting +; trace ;has macros: TRACE and UNTRACE +; compiler ;has (COMPILER) +; ed ;(ED) is editor + random + ) - (if (complex? (string->number "1+i")) - '(complex) - '()) + (if (defined? 'getenv) + '(getenv) + '()) - (let ((n (string->number "9999999999999999999999999999999"))) - (if (and n (exact? n)) - '(bignum) - '())))) + (if (defined? 'current-time) + '(current-time) + '()) + + (if (defined? 'system) + '(system) + '()) + + (if (defined? 'array?) + '(array) + '()) + + (if (defined? 'char-ready?) + '(char-ready?) + '()) + + (if (defined? 'array-for-each) + '(array-for-each) + '()) + + *features*)) ;;; FIXME: Because uers want require to search the path, this uses @@ -162,7 +199,7 @@ ;;; changing catalog:get in slib/require.scm, and I don't expect ;;; Aubrey will integrate such a change. So I'm just going to punt ;;; for the time being. -(define-public (slib:load name) +(define (slib:load name) (save-module-excursion (lambda () (set-current-module slib-module) @@ -189,23 +226,34 @@ (substring path 0 (- (string-length path) 17)) (error "Could not find slib/require.scm in " %load-path)))) -(define-public (implementation-vicinity) +(define (implementation-vicinity) (string-append slib-parent-dir "/")) -(define-public (library-vicinity) +(define (library-vicinity) (string-append (implementation-vicinity) "slib/")) -(define-public home-vicinity +(define home-vicinity (let ((home-path (getenv "HOME"))) (lambda () home-path))) -(define-public (scheme-implementation-type) 'guile) -(define-public (scheme-implementation-version) "") +(define (scheme-implementation-type) 'guile) +(define scheme-implementation-version version) +;;; (scheme-implementation-home-page) should return a (string) URI +;;; (Uniform Resource Identifier) for this scheme implementation's home +;;; page; or false if there isn't one. +(define (scheme-implementation-home-page) + "http://www.gnu.org/software/guile/guile.html") (define (output-port-width . arg) 80) (define (output-port-height . arg) 24) (define (identity x) x) +;;; {array-for-each} +(define (array-indexes ra) + (let ((ra0 (apply make-array '() (array-shape ra)))) + (array-index-map! ra0 list) + ra0)) + ;;; {Random numbers} ;;; -(define-public (make-random-state . args) +(define (make-random-state . args) (let ((seed (if (null? args) *random-state* (car args)))) (cond ((string? seed)) ((number? seed) (set! seed (number->string seed))) @@ -251,7 +299,7 @@ no other easy or unambiguous way of detecting such features." (slib:load (in-vicinity (library-vicinity) "require.scm")) -(define-public require require:require) +(define require require:require) ;; {Extensions to the require system so that the user can add new ;; require modules easily.} diff --git a/ice-9/streams.scm b/ice-9/streams.scm index 9091b896c..518adbf22 100644 --- a/ice-9/streams.scm +++ b/ice-9/streams.scm @@ -46,15 +46,14 @@ ;; (i.e. ripped off) Scheme48's `stream' package, ;; modulo stream-empty? -> stream-null? renaming. -(define-module (ice-9 streams)) - -(export make-stream - stream-car stream-cdr stream-null? - list->stream vector->stream port->stream - stream->list stream->reversed-list - stream->list&length stream->reversed-list&length - stream->vector - stream-fold stream-for-each stream-map) +(define-module (ice-9 streams) + :export (make-stream + stream-car stream-cdr stream-null? + list->stream vector->stream port->stream + stream->list stream->reversed-list + stream->list&length stream->reversed-list&length + stream->vector + stream-fold stream-for-each stream-map)) ;; Use: ;; diff --git a/ice-9/string-fun.scm b/ice-9/string-fun.scm index f6ffaa1d9..8470e39d6 100644 --- a/ice-9/string-fun.scm +++ b/ice-9/string-fun.scm @@ -1,6 +1,6 @@ ;;;; string-fun.scm --- string manipulation functions ;;;; -;;;; Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. +;;;; Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -42,7 +42,15 @@ ;;;; If you do not wish that, delete this exception notice. ;;;; -(define-module (ice-9 string-fun)) +(define-module (ice-9 string-fun) + :export (split-after-char split-before-char split-discarding-char + split-after-char-last split-before-char-last + split-discarding-char-last split-before-predicate + split-after-predicate split-discarding-predicate + separate-fields-discarding-char separate-fields-after-char + separate-fields-before-char string-prefix-predicate string-prefix=? + sans-surrounding-whitespace sans-trailing-whitespace + sans-leading-whitespace sans-final-newline has-trailing-newline?)) ;;;; ;;; @@ -112,53 +120,53 @@ ;;; complicated with these functions, consider using regular expressions. ;;; -(define-public (split-after-char char str ret) +(define (split-after-char char str ret) (let ((end (cond ((string-index str char) => 1+) (else (string-length str))))) (ret (substring str 0 end) (substring str end)))) -(define-public (split-before-char char str ret) +(define (split-before-char char str ret) (let ((end (or (string-index str char) (string-length str)))) (ret (substring str 0 end) (substring str end)))) -(define-public (split-discarding-char char str ret) +(define (split-discarding-char char str ret) (let ((end (string-index str char))) (if (not end) (ret str "") (ret (substring str 0 end) (substring str (1+ end)))))) -(define-public (split-after-char-last char str ret) +(define (split-after-char-last char str ret) (let ((end (cond ((string-rindex str char) => 1+) (else 0)))) (ret (substring str 0 end) (substring str end)))) -(define-public (split-before-char-last char str ret) +(define (split-before-char-last char str ret) (let ((end (or (string-rindex str char) 0))) (ret (substring str 0 end) (substring str end)))) -(define-public (split-discarding-char-last char str ret) +(define (split-discarding-char-last char str ret) (let ((end (string-rindex str char))) (if (not end) (ret str "") (ret (substring str 0 end) (substring str (1+ end)))))) -(define-public (split-before-predicate pred str ret) +(define (split-before-predicate pred str ret) (let loop ((n 0)) (cond ((= n (string-length str)) (ret str "")) ((not (pred (string-ref str n))) (loop (1+ n))) (else (ret (substring str 0 n) (substring str n)))))) -(define-public (split-after-predicate pred str ret) +(define (split-after-predicate pred str ret) (let loop ((n 0)) (cond ((= n (string-length str)) (ret str "")) @@ -166,7 +174,7 @@ (else (ret (substring str 0 (1+ n)) (substring str (1+ n))))))) -(define-public (split-discarding-predicate pred str ret) +(define (split-discarding-predicate pred str ret) (let loop ((n 0)) (cond ((= n (string-length str)) (ret str "")) @@ -174,7 +182,7 @@ (else (ret (substring str 0 n) (substring str (1+ n))))))) -(define-public (separate-fields-discarding-char ch str ret) +(define (separate-fields-discarding-char ch str ret) (let loop ((fields '()) (str str)) (cond @@ -183,7 +191,7 @@ (substring str 0 w)))) (else (apply ret str fields))))) -(define-public (separate-fields-after-char ch str ret) +(define (separate-fields-after-char ch str ret) (reverse (let loop ((fields '()) (str str)) @@ -193,7 +201,7 @@ (substring str (+ 1 w))))) (else (apply ret str fields)))))) -(define-public (separate-fields-before-char ch str ret) +(define (separate-fields-before-char ch str ret) (let loop ((fields '()) (str str)) (cond @@ -214,11 +222,11 @@ ;;; (define-public string-prefix=? (string-prefix-predicate string=?)) ;;; -(define-public ((string-prefix-predicate pred?) prefix str) +(define ((string-prefix-predicate pred?) prefix str) (and (<= (string-length prefix) (string-length str)) (pred? prefix (substring str 0 (string-length prefix))))) -(define-public string-prefix=? (string-prefix-predicate string=?)) +(define string-prefix=? (string-prefix-predicate string=?)) ;;; {String Fun: Strippers} @@ -231,7 +239,7 @@ ;;; | final-newline ;;; -(define-public (sans-surrounding-whitespace s) +(define (sans-surrounding-whitespace s) (let ((st 0) (end (string-length s))) (while (and (< st (string-length s)) @@ -244,7 +252,7 @@ "" (substring s st end)))) -(define-public (sans-trailing-whitespace s) +(define (sans-trailing-whitespace s) (let ((st 0) (end (string-length s))) (while (and (< 0 end) @@ -254,7 +262,7 @@ "" (substring s st end)))) -(define-public (sans-leading-whitespace s) +(define (sans-leading-whitespace s) (let ((st 0) (end (string-length s))) (while (and (< st (string-length s)) @@ -264,7 +272,7 @@ "" (substring s st end)))) -(define-public (sans-final-newline str) +(define (sans-final-newline str) (cond ((= 0 (string-length str)) str) @@ -277,7 +285,7 @@ ;;; {String Fun: has-trailing-newline?} ;;; -(define-public (has-trailing-newline? str) +(define (has-trailing-newline? str) (and (< 0 (string-length str)) (char=? #\nl (string-ref str (1- (string-length str)))))) diff --git a/ice-9/syncase.scm b/ice-9/syncase.scm index 948e11b86..36ea4f962 100644 --- a/ice-9/syncase.scm +++ b/ice-9/syncase.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 1997, 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -42,40 +42,50 @@ (define-module (ice-9 syncase) - :use-module (ice-9 debug)) + :use-module (ice-9 debug) + :export-syntax (sc-macro define-syntax eval-when fluid-let-syntax + identifier-syntax let-syntax + letrec-syntax syntax syntax-case syntax-rules + with-syntax + include) + :export (sc-expand sc-expand3 install-global-transformer + syntax-dispatch syntax-error bound-identifier=? + datum->syntax-object free-identifier=? + generate-temporaries identifier? syntax-object->datum + void eval syncase)) -(define-public sc-macro +(define sc-macro (procedure->memoizing-macro (lambda (exp env) (sc-expand exp)))) ;;; Exported variables -(define-public sc-expand #f) -(define-public sc-expand3 #f) -(define-public install-global-transformer #f) -(define-public syntax-dispatch #f) -(define-public syntax-error #f) +(define sc-expand #f) +(define sc-expand3 #f) +(define install-global-transformer #f) +(define syntax-dispatch #f) +(define syntax-error #f) -(define-public bound-identifier=? #f) -(define-public datum->syntax-object #f) -(define-public define-syntax sc-macro) -(define-public eval-when sc-macro) -(define-public fluid-let-syntax sc-macro) -(define-public free-identifier=? #f) -(define-public generate-temporaries #f) -(define-public identifier? #f) -(define-public identifier-syntax sc-macro) -(define-public let-syntax sc-macro) -(define-public letrec-syntax sc-macro) -(define-public syntax sc-macro) -(define-public syntax-case sc-macro) -(define-public syntax-object->datum #f) -(define-public syntax-rules sc-macro) -(define-public with-syntax sc-macro) -(define-public include sc-macro) +(define bound-identifier=? #f) +(define datum->syntax-object #f) +(define define-syntax sc-macro) +(define eval-when sc-macro) +(define fluid-let-syntax sc-macro) +(define free-identifier=? #f) +(define generate-temporaries #f) +(define identifier? #f) +(define identifier-syntax sc-macro) +(define let-syntax sc-macro) +(define letrec-syntax sc-macro) +(define syntax sc-macro) +(define syntax-case sc-macro) +(define syntax-object->datum #f) +(define syntax-rules sc-macro) +(define with-syntax sc-macro) +(define include sc-macro) (define primitive-syntax '(quote lambda letrec if set! begin define or and let let* cond do quasiquote unquote @@ -87,7 +97,7 @@ ;;; Hooks needed by the syntax-case macro package -(define-public (void) *unspecified*) +(define (void) *unspecified*) (define andmap (lambda (f first . rest) @@ -161,7 +171,7 @@ (define internal-eval (nested-ref the-scm-module '(app modules guile eval))) -(define-public (eval x environment) +(define (eval x environment) (internal-eval (if (and (pair? x) (equal? (car x) "noexpand")) (cadr x) @@ -175,4 +185,4 @@ '*sc-expander* '(define)))) -(define-public syncase sc-expand) +(define syncase sc-expand) diff --git a/ice-9/threads.scm b/ice-9/threads.scm index 6fc4511d0..586bae368 100644 --- a/ice-9/threads.scm +++ b/ice-9/threads.scm @@ -56,7 +56,12 @@ ;;; Code: -(define-module (ice-9 threads)) +(define-module (ice-9 threads) + :export-syntax (make-thread + begin-thread + with-mutex + monitor) + :export (%thread-handler)) @@ -109,13 +114,4 @@ (begin ,first ,@rest))) -;; export - -(export %thread-handler) - -(export-syntax make-thread - begin-thread - with-mutex - monitor) - ;;; threads.scm ends here diff --git a/oop/ChangeLog b/oop/ChangeLog index 87a52a216..5fc09eed1 100644 --- a/oop/ChangeLog +++ b/oop/ChangeLog @@ -1,3 +1,12 @@ +2001-10-21 Mikael Djurfeldt + + * goops.scm, goops/active-slot.scm, goops/compile.scm, + goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm, + goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move + module the system directives `export', `export-syntax', + `re-export' and `re-export-syntax' into the `define-module' form. + This is the recommended way of exporting bindings. + 2001-08-25 Marius Vollmer * Makefile.am, goops/Makefile.am: (AUTOMAKE_OPTIONS): Change diff --git a/oop/goops.scm b/oop/goops.scm index 4f997da3f..b8f63ff27 100644 --- a/oop/goops.scm +++ b/oop/goops.scm @@ -51,6 +51,51 @@ ;;;; (define-module (oop goops) + :export-syntax (define-class class + define-generic define-accessor define-method + method) + :export (goops-version is-a? + ensure-metaclass ensure-metaclass-with-supers + make-class + make-generic ensure-generic + make-accessor ensure-accessor + make-method add-method! + object-eqv? object-equal? + class-slot-ref class-slot-set! slot-unbound slot-missing + slot-definition-name slot-definition-options + slot-definition-allocation + slot-definition-getter slot-definition-setter + slot-definition-accessor + slot-definition-init-value slot-definition-init-form + slot-definition-init-thunk slot-definition-init-keyword + slot-init-function class-slot-definition + method-source + compute-cpl compute-std-cpl compute-get-n-set compute-slots + compute-getter-method compute-setter-method + allocate-instance initialize make-instance make + no-next-method no-applicable-method no-method + change-class update-instance-for-different-class + shallow-clone deep-clone + class-redefinition + apply-generic apply-method apply-methods + compute-applicable-methods %compute-applicable-methods + method-more-specific? sort-applicable-methods + class-subclasses class-methods + goops-error + min-fixnum max-fixnum + ;;; *fixme* Should go into goops.c + instance? slot-ref-using-class + slot-set-using-class! slot-bound-using-class? + slot-exists-using-class? slot-ref slot-set! slot-bound? + class-name class-direct-supers class-direct-subclasses + class-direct-methods class-direct-slots class-precedence-list + class-slots class-environment + generic-function-name + generic-function-methods method-generic-function method-specializers + primitive-generic-generic enable-primitive-generic! + method-procedure accessor-method-slot-definition + slot-exists? make find-method get-keyword) + :re-export (class-of) ;; from (guile) :no-backtrace) ;; First initialize the builtin part of GOOPS @@ -61,53 +106,6 @@ (oop goops dispatch) (oop goops compile)) -(export ; Define the exported symbols of this file - goops-version is-a? - ensure-metaclass ensure-metaclass-with-supers - define-class class make-class - define-generic make-generic ensure-generic - define-accessor make-accessor ensure-accessor - define-method make-method method add-method! - object-eqv? object-equal? - class-slot-ref class-slot-set! slot-unbound slot-missing - slot-definition-name slot-definition-options slot-definition-allocation - slot-definition-getter slot-definition-setter slot-definition-accessor - slot-definition-init-value slot-definition-init-form - slot-definition-init-thunk slot-definition-init-keyword - slot-init-function class-slot-definition - method-source - compute-cpl compute-std-cpl compute-get-n-set compute-slots - compute-getter-method compute-setter-method - allocate-instance initialize make-instance make - no-next-method no-applicable-method no-method - change-class update-instance-for-different-class - shallow-clone deep-clone - class-redefinition - apply-generic apply-method apply-methods - compute-applicable-methods %compute-applicable-methods - method-more-specific? sort-applicable-methods - class-subclasses class-methods - goops-error - min-fixnum max-fixnum -) - -;;; *fixme* Should go into goops.c - -(export - instance? slot-ref-using-class - slot-set-using-class! slot-bound-using-class? - slot-exists-using-class? slot-ref slot-set! slot-bound? - class-name class-direct-supers class-direct-subclasses - class-direct-methods class-direct-slots class-precedence-list - class-slots class-environment - generic-function-name - generic-function-methods method-generic-function method-specializers - primitive-generic-generic enable-primitive-generic! - method-procedure accessor-method-slot-definition - slot-exists? make find-method get-keyword) - -(re-export class-of) ;; from (guile) - (define min-fixnum (- (expt 2 29))) diff --git a/oop/goops/active-slot.scm b/oop/goops/active-slot.scm index cdedd30aa..7060b83be 100644 --- a/oop/goops/active-slot.scm +++ b/oop/goops/active-slot.scm @@ -51,9 +51,8 @@ ;;;; (define-module (oop goops active-slot) - :use-module (oop goops internal)) - -(export ) + :use-module (oop goops internal) + :export ()) (define-class ()) diff --git a/oop/goops/compile.scm b/oop/goops/compile.scm index a538215ae..e84d3d0d9 100644 --- a/oop/goops/compile.scm +++ b/oop/goops/compile.scm @@ -44,12 +44,11 @@ (define-module (oop goops compile) :use-module (oop goops) :use-module (oop goops util) + :export (compute-cmethod compute-entry-with-cmethod + compile-method cmethod-code cmethod-environment) :no-backtrace ) -(export compute-cmethod compute-entry-with-cmethod - compile-method cmethod-code cmethod-environment) - (define source-formals cadr) (define source-body cddr) diff --git a/oop/goops/composite-slot.scm b/oop/goops/composite-slot.scm index 88147a571..84ce7937f 100644 --- a/oop/goops/composite-slot.scm +++ b/oop/goops/composite-slot.scm @@ -51,9 +51,8 @@ ;;;; (define-module (oop goops composite-slot) - :use-module (oop goops)) - -(export ) + :use-module (oop goops) + :export ()) ;;; ;;; (define-class CLASS SUPERS diff --git a/oop/goops/describe.scm b/oop/goops/describe.scm index 4dd218127..dc0e63424 100644 --- a/oop/goops/describe.scm +++ b/oop/goops/describe.scm @@ -53,9 +53,8 @@ (define-module (oop goops describe) :use-module (oop goops) :use-module (ice-9 session) - :use-module (ice-9 format)) - -(export describe) ; Export the describe generic function + :use-module (ice-9 format) + :export (describe)) ; Export the describe generic function ;;; ;;; describe for simple objects diff --git a/oop/goops/dispatch.scm b/oop/goops/dispatch.scm index cd1c7e698..749cf9273 100644 --- a/oop/goops/dispatch.scm +++ b/oop/goops/dispatch.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. +;;;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -45,11 +45,10 @@ :use-module (oop goops) :use-module (oop goops util) :use-module (oop goops compile) + :export (memoize-method!) :no-backtrace ) -(export memoize-method!) - ;;; ;;; This file implements method memoization. It will finally be ;;; implemented on C level in order to obtain fast generic function diff --git a/oop/goops/old-define-method.scm b/oop/goops/old-define-method.scm index 79165ae44..13f05c284 100644 --- a/oop/goops/old-define-method.scm +++ b/oop/goops/old-define-method.scm @@ -45,11 +45,10 @@ (define-module (oop goops old-define-method) :use-module (oop goops) + :export (define-method) :no-backtrace ) -(export define-method) - (define define-method (procedure->memoizing-macro (lambda (exp env) diff --git a/oop/goops/save.scm b/oop/goops/save.scm index 1597c8e90..7db319e22 100644 --- a/oop/goops/save.scm +++ b/oop/goops/save.scm @@ -46,14 +46,11 @@ (define-module (oop goops save) :use-module (oop goops internal) :use-module (oop goops util) - ) - -(re-export make-unbound) - -(export save-objects load-objects restore - enumerate! enumerate-component! - write-readably write-component write-component-procedure - literal? readable make-readable) + :re-export (make-unbound) + :export (save-objects load-objects restore + enumerate! enumerate-component! + write-readably write-component write-component-procedure + literal? readable make-readable)) ;;; ;;; save-objects ALIST PORT [EXCLUDED] [USES] diff --git a/oop/goops/util.scm b/oop/goops/util.scm index d3d904c60..9e6a3c927 100644 --- a/oop/goops/util.scm +++ b/oop/goops/util.scm @@ -42,13 +42,12 @@ (define-module (oop goops util) + :export (any every filter + mapappend find-duplicate top-level-env top-level-env? + map* for-each* length* improper->proper) :no-backtrace ) -(export any every filter - mapappend find-duplicate top-level-env top-level-env? - map* for-each* length* improper->proper - ) ;;; ;;; {Utilities} diff --git a/srfi/ChangeLog b/srfi/ChangeLog index f3f76740e..a6a49435e 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,11 @@ +2001-10-21 Mikael Djurfeldt + + * srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm, + srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system + directives `export', `export-syntax', `re-export' and + `re-export-syntax' into the `define-module' form. This is the + recommended way of exporting bindings. + 2001-09-22 Mikael Djurfeldt * srfi-19.scm (priv:split-real): Inserted missing call to diff --git a/srfi/srfi-10.scm b/srfi/srfi-10.scm index f24ec0d94..e3327548c 100644 --- a/srfi/srfi-10.scm +++ b/srfi/srfi-10.scm @@ -69,9 +69,8 @@ ;;; Code: (define-module (srfi srfi-10) - #:use-module (ice-9 rdelim)) - -(export define-reader-ctor) + :use-module (ice-9 rdelim) + :export (define-reader-ctor)) (cond-expand-provide (current-module) '(srfi-10)) diff --git a/srfi/srfi-11.scm b/srfi/srfi-11.scm index de0753636..e60ef43f9 100644 --- a/srfi/srfi-11.scm +++ b/srfi/srfi-11.scm @@ -42,7 +42,8 @@ ;;; If you do not wish that, delete this exception notice. (define-module (srfi srfi-11) - :use-module (ice-9 syncase)) + :use-module (ice-9 syncase) + :export-syntax (let-values let*-values)) (cond-expand-provide (current-module) '(srfi-11)) @@ -256,6 +257,3 @@ ; (if (null? vars) ; `(begin ,@body) ; (let-values-helper vars body))) - -(export-syntax let-values - let*-values) diff --git a/srfi/srfi-14.scm b/srfi/srfi-14.scm index 08aa7b71e..c47ddd514 100644 --- a/srfi/srfi-14.scm +++ b/srfi/srfi-14.scm @@ -41,9 +41,8 @@ ;;;; whether to permit this exception to apply to your modifications. ;;;; If you do not wish that, delete this exception notice. -(define-module (srfi srfi-14)) - -(export +(define-module (srfi srfi-14) + :export ( ;;; General procedures char-set? char-set= @@ -112,7 +111,7 @@ char-set:ascii char-set:empty char-set:full - ) + )) (cond-expand-provide (current-module) '(srfi-14)) diff --git a/srfi/srfi-16.scm b/srfi/srfi-16.scm index 73fd22dc7..fe179e849 100644 --- a/srfi/srfi-16.scm +++ b/srfi/srfi-16.scm @@ -69,9 +69,8 @@ ;;; Author: Martin Grabmueller ;;; Code: -(define-module (srfi srfi-16)) - -(export-syntax case-lambda) +(define-module (srfi srfi-16) + :export-syntax (case-lambda)) (cond-expand-provide (current-module) '(srfi-16)) diff --git a/srfi/srfi-2.scm b/srfi/srfi-2.scm index fa6d0c960..9febda017 100644 --- a/srfi/srfi-2.scm +++ b/srfi/srfi-2.scm @@ -42,8 +42,7 @@ ;;;; If you do not wish that, delete this exception notice. (define-module (srfi srfi-2) - :use-module (ice-9 and-let-star)) - -(re-export-syntax and-let*) + :use-module (ice-9 and-let-star) + :re-export-syntax (and-let*)) (cond-expand-provide (current-module) '(srfi-2)) diff --git a/srfi/srfi-4.scm b/srfi/srfi-4.scm index ea7137cd1..134ac5875 100644 --- a/srfi/srfi-4.scm +++ b/srfi/srfi-4.scm @@ -49,9 +49,8 @@ ;;; Author: Martin Grabmueller -(define-module (srfi srfi-4)) - -(export +(define-module (srfi srfi-4) + :export ( ;;; Unsigned 8-bit vectors. u8vector? make-u8vector u8vector u8vector-length u8vector-ref u8vector-set! u8vector->list list->u8vector @@ -91,7 +90,7 @@ ;;; 64-bit floating point vectors. f64vector? make-f64vector f64vector f64vector-length f64vector-ref f64vector-set! f64vector->list list->f64vector - ) + )) ;; Make 'srfi-4 available as a feature identifiere to `cond-expand'. diff --git a/srfi/srfi-8.scm b/srfi/srfi-8.scm index 52961ed3a..85b31830e 100644 --- a/srfi/srfi-8.scm +++ b/srfi/srfi-8.scm @@ -42,8 +42,7 @@ ;;; If you do not wish that, delete this exception notice. (define-module (srfi srfi-8) - :use-module (ice-9 receive)) - -(re-export-syntax receive) + :use-module (ice-9 receive) + :re-export-syntax (receive)) (cond-expand-provide (current-module) '(srfi-8)) diff --git a/srfi/srfi-9.scm b/srfi/srfi-9.scm index 7bf032721..b36b11f4e 100644 --- a/srfi/srfi-9.scm +++ b/srfi/srfi-9.scm @@ -83,9 +83,8 @@ ;;; Code: -(define-module (srfi srfi-9)) - -(export-syntax define-record-type) +(define-module (srfi srfi-9) + :export-syntax (define-record-type)) (cond-expand-provide (current-module) '(srfi-9)) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 1be4e7c60..7ee1d514f 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,10 @@ +2001-10-21 Mikael Djurfeldt + + * lib.scm: Move module the system directives `export', + `export-syntax', `re-export' and `re-export-syntax' into the + `define-module' form. This is the recommended way of exporting + bindings. + 2001-10-18 Dirk Herrmann * tests/syntax.test: Added test cases for 'cond =>' syntax with diff --git a/test-suite/lib.scm b/test-suite/lib.scm index a5a44fa8a..de242bd11 100644 --- a/test-suite/lib.scm +++ b/test-suite/lib.scm @@ -18,9 +18,8 @@ (define-module (test-suite lib) :use-module (ice-9 stack-catch) - :use-module (ice-9 regex)) - -(export + :use-module (ice-9 regex) + :export ( ;; Exceptions which are commonly being tested for. exception:out-of-range exception:unbound-var @@ -40,7 +39,7 @@ make-log-reporter full-reporter user-reporter - format-test-name) + format-test-name)) ;;;; If you're using Emacs's Scheme mode: From 7d87115cf8195c28fd21e67344eef345d091c07f Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 16:38:46 +0000 Subject: [PATCH 051/281] Expand on file format description. (1): Update "fixed" field. (2, 3): New. --- BUGS | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/BUGS b/BUGS index 303b89974..0348096a9 100644 --- a/BUGS +++ b/BUGS @@ -3,28 +3,62 @@ BUGS This file contains bugs we haven't fixed yet, and some we have. The format is very simple (one bug per page): -bug NUMBER -- ONE-LINE-DESCRIPTION -reported-by: SOMEONE / DATE -fixed: DATE (for guile VERSION) -OTHER-NOTES +# line regexp + +1 bug NUMBER -- ONE-LINE-DESCRIPTION ^bug ([0-9]+) -- (.+)$ +2 reported-by: SOMEONE / DATE ^reported-by: ([^/]) */ *(.+)$ +3 fixed: DATE (for guile VERSION) ^fixed: (.+) .for guile (.+).$ +4+ OTHER-NOTES + +DATE is formatted YYY-MM-DD, or "not-yet". Line numbering is zero-origin; +line 0 is empty (newline always follows newpage (recognizable w/ "\f\n")). +The suggested regexps can be used in a line-oriented parser. bug 0 -- no BUGS file reported-by: ttn / 2001-09-25 fixed: 2001-09-30 (1.5.x, 1.7.x) -all bugs are good bugs! +bugs are good. bug 1 -- (debug-disable 'debug) has no effect if first form in ~/.guile reported-by: Sven.Hartrumpf@fernuni-hagen.de / 2001-08-31 -fixed: +fixed: not-yet -buggy behavior confirmed on both 1.5.x and 1.7.x (ttn). +ttn sez: +buggy behavior confirmed on both 1.5.x and 1.7.x. on the other hand, when second or later, the expected effect (disabling use of debugging evaluator) seems to be reflected when viewing the debug options. it could be that the bug is in display and not the actual setting. + +bug 2 -- documentation mirroring not complete +reported-by: lord@regexps.com / 2001-08 +fixed: not-yet + +ttn sez: +uncollated mirroring is already available: +http://savannah.gnu.org/cgi-bin/viewcvs/guile/ +http://mail.gnu.org/pipermail/guile-devel/ + + +bug 3 -- design decisions not recorded +reported-by: lord@regexps.com / 2001-08 +fixed: not-yet + +changes are made w/ little documentation on their motivation, design and +consequences. past initiatives and current maintainer discipline to support +them need shoring up. + +ttn sez: +someone also mentioned that process and product are orthogonal; nastiness can +result in/from either, and for different reasons. i tend to believe this up +until a certain point, when the process becomes self-aware and includes its own +improvement in its considerations. then, hopefully it becomes light. + +to change people is difficult, but that's why we have guile... + [BUGS ends here] From c95d1a2d80f770360566ad17591d1336b947c684 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 16:41:53 +0000 Subject: [PATCH 052/281] *** empty log message *** --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1486683be..d152f8836 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-10-25 Thien-Thi Nguyen + + * BUGS: Expand on file format description. + + (1): Update "fixed" field. + (2, 3): New. + 2001-10-14 Gary Houston * configure.in: include sys/types.h when testing uint32_t. From 23c06383b4b819c2f3b4a35be1975566297a9cbe Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 17:11:13 +0000 Subject: [PATCH 053/281] (4): New. --- BUGS | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/BUGS b/BUGS index 0348096a9..ad6ce5bc6 100644 --- a/BUGS +++ b/BUGS @@ -10,7 +10,7 @@ The format is very simple (one bug per page): 3 fixed: DATE (for guile VERSION) ^fixed: (.+) .for guile (.+).$ 4+ OTHER-NOTES -DATE is formatted YYY-MM-DD, or "not-yet". Line numbering is zero-origin; +DATE is formatted YYYY-MM-DD, or "not-yet". Line numbering is zero-origin; line 0 is empty (newline always follows newpage (recognizable w/ "\f\n")). The suggested regexps can be used in a line-oriented parser. @@ -60,5 +60,26 @@ improvement in its considerations. then, hopefully it becomes light. to change people is difficult, but that's why we have guile... + +bug 4 -- named-let transform evaluates initvalue in the wrong scope +reported-by: agj@alum.mit.edu / 2001-09-21 +fixed: not-yet + +currently: +> (let name ((var init) ...) body ...) +> +> to +> +> (letrec ((name (lambda (var ...) body ...))) +> (name init ...)) + +should be: +> ((letrec ((name (lambda (var ...) body ...))) name) init ...) + +Dirk Herrmann sez: +I will do it - no big deal (I hope). But, I won't have time to do it +before next week. What about adding this code as a test case to the test +suite? Until it is fixed, it can be tagged as expected to fail. + [BUGS ends here] From 65aec929a69f28471082dccbcdc206d7bf2277a1 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 17:11:46 +0000 Subject: [PATCH 054/281] *** empty log message *** --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d152f8836..f1070ba22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ * BUGS: Expand on file format description. (1): Update "fixed" field. - (2, 3): New. + (2, 3, 4): New. 2001-10-14 Gary Houston From 88463d071dc096055600d314f807f9e1e87c923e Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 18:13:46 +0000 Subject: [PATCH 055/281] Initial revision --- emacs/README | 11 ++++++ emacs/patch.el | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 emacs/README create mode 100644 emacs/patch.el diff --git a/emacs/README b/emacs/README new file mode 100644 index 000000000..49229a242 --- /dev/null +++ b/emacs/README @@ -0,0 +1,11 @@ +Index + +guile-c.el --- Guile C editing commands +guile-scheme.el --- Guile Scheme editing mode +guile.el --- Emacs Guile interface +multistring.el --- editing multiline strings. +patch.el --- mail/apply a patch +ppexpand.el --- temporarily expanding macros in a pretty way. + + +Generated using: (for f in *.el ; do head -1 $f ; done) | sed 's/^....//g' diff --git a/emacs/patch.el b/emacs/patch.el new file mode 100644 index 000000000..e97c4231b --- /dev/null +++ b/emacs/patch.el @@ -0,0 +1,98 @@ +;;; patch.el --- mail/apply a patch + +;; Copyright (C) 2001 Free Software Foundation, Inc. + +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Author: Thien-Thi Nguyen +;;; Version: 1 +;;; Favorite-Favorite: Favorite-Favorite + +;;; Commentary: + +;; This file has two symmetrical usage modes, for patch creation and +;; application, respectively. The details are somewhat tuned for Guile +;; maintenance; probably we should generalize it a bit and add it to +;; Emacs proper at some point in the future. Long live free software! +;; +;; On the patch creation side of things, there are various version +;; control systems that are happy to write a diff to stdout (and +;; numerous Emacs interfaces to them all). Thus, we provide only a +;; simple `patch-submit' that composes mail from the current buffer; +;; the contents of that buffer are left as an exercise for the patch +;; creator. When preparing the mail, `patch-submit' scans the patch +;; for standard filename headers and sets up a skeleton change log -- +;; filling this in is a good way to earn respect from maintainers (hint +;; hint). Type `C-c C-c' to send the mail when you are done. (See +;; `compose-mail' for more info.) +;; +;; TODO: Write/document patch-apply side of things. +;; TODO: Integrate w/ `ediff-patch-buffer' et al. + +;;; Code: + +(require 'cl) + +(defvar patch-greeting "hello guile maintainers,\n\n" + "*String to insert at beginning of patch mail.") + +(defun patch-scan-files () + (let (files) + (save-excursion + (while (re-search-forward "^[+][+][+] \\(\\S-+\\)" (point-max) t) + (setq files (cons (cons (match-string 1) + (match-beginning 0)) + files)))) + (reverse files))) + +(defun patch-common-prefix (filenames) + (let* ((first-file (car filenames)) + (prefix (and first-file (file-name-directory first-file)))) + (while (and prefix + (not (string= "" prefix)) + (not (every (lambda (filename) + (string-match (concat "^" prefix) filename)) + filenames))) + (setq prefix (file-name-directory (substring prefix 0 -1)))) + prefix)) + +(defun patch-changelog-skeleton () + (let* ((file-info (patch-scan-files)) + (fullpath-files (mapcar 'car file-info)) + (cut (length (patch-common-prefix fullpath-files))) + (files (mapcar (lambda (fullpath-file) + (substring fullpath-file cut)) + fullpath-files))) + (mapconcat + (lambda (file) + (concat (make-string (length file) ?_) "\n" file "\n[writeme]")) + files + "\n"))) + +(defun patch-submit (buffer subject) + (interactive "bBuffer: \nsSubject: ") + (when (string= "" subject) + (error "(empty subject)")) + (compose-mail "bug-guile@gnu.org" subject) + (insert (with-current-buffer buffer (buffer-string))) + (mail-text) + (insert patch-greeting) + (save-excursion + (insert "here is a patch ... [overview/observations/etc]\n\n" + (patch-changelog-skeleton) "\n\n\n" + (make-string 72 ?_) "\n"))) + +;;; patch.el ends here From a514023d74503b4a9998dc0e1e0dbacc92c5c76f Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 18:14:35 +0000 Subject: [PATCH 056/281] *** empty log message *** --- emacs/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/emacs/ChangeLog b/emacs/ChangeLog index 69b67b581..98fc02270 100644 --- a/emacs/ChangeLog +++ b/emacs/ChangeLog @@ -1,3 +1,7 @@ +2001-10-25 Thien-Thi Nguyen + + * patch.el, README: New files. + 2001-06-21 Neil Jerram * guile.el (guile-channel-file): Signal an error if unable to find From 969182acf56f64d376e85551efc07cde489d0467 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 22:10:04 +0000 Subject: [PATCH 057/281] (5): New. --- BUGS | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/BUGS b/BUGS index ad6ce5bc6..8f7f3c344 100644 --- a/BUGS +++ b/BUGS @@ -81,5 +81,31 @@ I will do it - no big deal (I hope). But, I won't have time to do it before next week. What about adding this code as a test case to the test suite? Until it is fixed, it can be tagged as expected to fail. + +bug 5 -- uniform vector read-hash "e" clashes w/ exactness specification +reported-by: kwright@gis.net / 2001-10-07 +fixed: not-yet + +Keith Wright sez: +> Before getting into philosophy, I want to mention that while poking +> around and rethinking I found the following Bug. +> +> guile> (version) +> "1.5.2" +> guile> #E3 +> 3 +> guile> #e3 +> ERROR: read:uniform-vector list not found +> ABORT: (misc-error) +> guile> 3 +> +> This violates both R5RS 7.1 ``Case is insignificant'' and +> +> > From: guile-1.5.2/doc/ref/guile.info-3 Line 568 +> > +> > The codes for indicating exactness (which can, incidentally, be +> > applied to all numerical values) are: +> > +> > * `#e', `#E' -- the number is exact [BUGS ends here] From f135ca5568b9795cc135ac7f6d268c9cf78ba16c Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 22:10:49 +0000 Subject: [PATCH 058/281] *** empty log message *** --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f1070ba22..074e1aff6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ * BUGS: Expand on file format description. (1): Update "fixed" field. - (2, 3, 4): New. + (2, 3, 4, 5): New. 2001-10-14 Gary Houston From dc5ab9af958e9cca974403fac6453734c10c6e25 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 22:52:34 +0000 Subject: [PATCH 059/281] (6): New. --- BUGS | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/BUGS b/BUGS index 8f7f3c344..b9e533c99 100644 --- a/BUGS +++ b/BUGS @@ -107,5 +107,31 @@ Keith Wright sez: > > applied to all numerical values) are: > > > > * `#e', `#E' -- the number is exact + + +bug 6 -- exactness prefix doesn't do nothing gracefully +reported-by: kwright@gis.net / 2001-10-09 +fixed: not-yet + +[this may be related to bug 5. --ttn] + +Keith Wright sez: +> The saga continues... +> +> > > The codes for indicating exactness (which can, incidentally, be +> > > applied to all numerical values) are: +> > > +> > > * `#e', `#E' -- the number is exact +> +> guile> #E3 ==> 3 +> guile> #E3.0 +> ERROR: In procedure scm_lreadr: +> ERROR: unknown # object +> +> Better change the reference manual s/, incidentally,/'t/. +> +> (That's a joke son. The Scheme language requires #e in front +> of any number to at least do nothing successfully.) + [BUGS ends here] From d07db248f18c4f8e261357bc9d9a4679b4fcc338 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 25 Oct 2001 22:53:07 +0000 Subject: [PATCH 060/281] *** empty log message *** --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 074e1aff6..a5f9cb4b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ * BUGS: Expand on file format description. (1): Update "fixed" field. - (2, 3, 4, 5): New. + (2, 3, 4, 5, 6): New. 2001-10-14 Gary Houston From 6cf0878f9e2811782685f2aab047cc85e0ca1dd2 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 26 Oct 2001 12:57:25 +0000 Subject: [PATCH 061/281] (7, 8): New. --- BUGS | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/BUGS b/BUGS index b9e533c99..976531782 100644 --- a/BUGS +++ b/BUGS @@ -133,5 +133,32 @@ Keith Wright sez: > (That's a joke son. The Scheme language requires #e in front > of any number to at least do nothing successfully.) + +bug 7 -- readline configuration anomolies not handled gracefully +reported-by: kwright@gis.net / 2001-10-17 +fixed: not-yet + + +bug 8 -- install requires makeinfo +reported-by: kwright@gis.net / 2001-10-17 +fixed: not-yet + +Keith Wright sez: +> I got guile-1.5.4 and installed it on one machine with no problem. +> On another I did ./configure;make as before and it died with: +> +> > ... +> > on.doc vports.doc weaks.doc symbols-deprecated.doc regex-posix.doc ramap.doc unif.doc filesys.doc posix.doc net_db.doc socket.doc | ./guile-snarf-docs-texi > guile.texi \ +> > || { rm guile.texi; false; } +> > rm -f guile-procedures.txt +> > makeinfo --force -o guile-procedures.txt guile.texi || test -f guile-procedures.txt +> > /bin/sh: makeinfo: command not found +> > make[1]: *** [guile-procedures.txt] Error 1 +> > make[1]: Leaving directory `/home/kwright/build/guile-1.5.4/libguile' +> > make: *** [all-recursive] Error 1 +> +> I get the impression that it is supposed to build without 'makeinfo', +> if this is not so it should be mentioned in the README or INSTALL. + [BUGS ends here] From 2ad3278ab958938f95f32ea46eb91f8ad7dca2af Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 26 Oct 2001 12:58:20 +0000 Subject: [PATCH 062/281] *** empty log message *** --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index a5f9cb4b6..d807895c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-10-26 Thien-Thi Nguyen + + * BUGS (7, 8): New. + 2001-10-25 Thien-Thi Nguyen * BUGS: Expand on file format description. From 2b6b59081af307d5bf6d89e35dc904886ccf9873 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Fri, 26 Oct 2001 19:47:57 +0000 Subject: [PATCH 063/281] * tests/eval.test: Added tests for promises. --- test-suite/ChangeLog | 4 +++ test-suite/tests/eval.test | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 7ee1d514f..5fae02107 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,7 @@ +2001-10-26 Dirk Herrmann + + * tests/eval.test: Added tests for promises. + 2001-10-21 Mikael Djurfeldt * lib.scm: Move module the system directives `export', diff --git a/test-suite/tests/eval.test b/test-suite/tests/eval.test index 8e94885c3..fc97fa5a9 100644 --- a/test-suite/tests/eval.test +++ b/test-suite/tests/eval.test @@ -177,4 +177,72 @@ (map + '(1 2) '(3))) ))) +;;; +;;; promises +;;; + +(with-test-prefix "promises" + + (with-test-prefix "basic promise behaviour" + + (pass-if "delay gives a promise" + (promise? (delay 1))) + + (pass-if "force evaluates a promise" + (eqv? (force (delay (+ 1 2))) 3)) + + (pass-if "a forced promise is a promise" + (let ((p (delay (+ 1 2)))) + (force p) + (promise? p))) + + (pass-if "forcing a forced promise works" + (let ((p (delay (+ 1 2)))) + (force p) + (eqv? (force p) 3))) + + (pass-if "a promise is evaluated once" + (let* ((x 1) + (p (delay (+ x 1)))) + (force p) + (set! x (+ x 1)) + (eqv? (force p) 2))) + + (pass-if "a promise may call itself" + (define p + (let ((x 0)) + (delay + (begin + (set! x (+ x 1)) + (if (> x 1) x (force p)))))) + (eqv? (force p) 2)) + + (pass-if "a promise carries its environment" + (let* ((x 1) (p #f)) + (let* ((x 2)) + (set! p (delay (+ x 1)))) + (eqv? (force p) 3))) + + (pass-if "a forced promise does not reference its environment" + (let* ((g (make-guardian)) + (p #f)) + (let* ((x (cons #f #f))) + (g x) + (set! p (delay (car x)))) + (force p) + (gc) + (if (not (equal? (g) (cons #f #f))) + (throw 'unresolved) + #t)))) + + (with-test-prefix "extended promise behaviour" + + (pass-if-exception "forcing a non-promise object is not supported" + exception:wrong-type-arg + (force 1)) + + (pass-if-exception "implicit forcing is not supported" + exception:wrong-type-arg + (+ (delay (* 3 7)) 13)))) + ;;; eval.test ends here From 1ac8e04192fef3f6ff5c47d1039a7f35f9d89836 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Sat, 27 Oct 2001 11:47:25 +0000 Subject: [PATCH 064/281] bugs 5 and 6 seem to be fixed. --- BUGS | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/BUGS b/BUGS index 976531782..914dad17e 100644 --- a/BUGS +++ b/BUGS @@ -84,7 +84,7 @@ suite? Until it is fixed, it can be tagged as expected to fail. bug 5 -- uniform vector read-hash "e" clashes w/ exactness specification reported-by: kwright@gis.net / 2001-10-07 -fixed: not-yet +fixed: 2001-10-14 (1.5.x, 1.7.x) Keith Wright sez: > Before getting into philosophy, I want to mention that while poking @@ -108,10 +108,17 @@ Keith Wright sez: > > > > * `#e', `#E' -- the number is exact +2001-10-14 Mikael Djurfeldt + + * read.c (scm_lreadr): When user-defined hash procedure returns + SCM_UNSPECIFIED: Fall back to standard handling instead of raising + an exception. (This prevents parsing of uniform vectors from + interfering with parsing of numbers.) + bug 6 -- exactness prefix doesn't do nothing gracefully reported-by: kwright@gis.net / 2001-10-09 -fixed: not-yet +fixed: 2001-10-14 (1.5.x, 1.7.x) (see bug 5) [this may be related to bug 5. --ttn] From c2c67382d7b0e01a779bc225dae6dc58054880ab Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Sat, 27 Oct 2001 11:50:59 +0000 Subject: [PATCH 065/281] * minor updates to the slib installation notes. --- doc/ref/ChangeLog | 4 ++++ doc/ref/slib.texi | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 9f2eb9980..08e29903a 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,7 @@ +2001-10-27 Gary Houston + + * minor updates to the slib installation notes. + 2001-10-05 Neil Jerram * scheme-evaluation.texi (Fly Evaluation): Removed documentation diff --git a/doc/ref/slib.texi b/doc/ref/slib.texi index 445b084c6..a765a1329 100644 --- a/doc/ref/slib.texi +++ b/doc/ref/slib.texi @@ -28,17 +28,17 @@ guile> (probably-prime? 13) @node SLIB installation @section SLIB installation -The following seems to work, at least with slib 2c7: +The following seems to work (e.g., with slib versions 2c7 and 2d2): @enumerate @item -Unpack slib somewhere, e.g., /usr/local/lib/slib. +Unpack slib somewhere, e.g., /usr/local/share/slib. @item Create a symlink in the Guile site directory to slib, e.g.,: @example -ln -s /usr/local/lib/slib /usr/local/share/guile/site/slib +ln -s /usr/local/share/slib /usr/local/share/guile/site/slib @end example @item @@ -47,7 +47,7 @@ Use Guile to create the catalogue file, e.g.,: @example # guile guile> (use-modules (ice-9 slib)) -guile> (load "/usr/local/lib/slib/mklibcat.scm") +guile> (load "/usr/local/share/slib/mklibcat.scm") guile> (quit) @end example @@ -68,7 +68,7 @@ offending variables. Install the documentation: @example -cd /usr/local/lib/slib +cd /usr/local/share/slib rm /usr/local/info/slib.info* cp slib.info /usr/local/info install-info slib.info /usr/local/info/dir From a42b5e5b962686b6961e425e3cd8877f25ddfaf1 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Sat, 27 Oct 2001 16:53:35 +0000 Subject: [PATCH 066/281] * guile.texi, scsh.texi: removed obsolete guile-scsh material and updated links (I don't know if it should remain in the main menu. It's like slib I think.) --- doc/ref/ChangeLog | 4 ++++ doc/ref/guile.texi | 8 ++------ doc/ref/scsh.texi | 23 ++++++++--------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 08e29903a..23bf1e09b 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,5 +1,9 @@ 2001-10-27 Gary Houston + * guile.texi, scsh.texi: removed obsolete guile-scsh material + and updated links (I don't know if it should remain in the + main menu. It's like slib I think.) + * minor updates to the slib installation notes. 2001-10-05 Neil Jerram diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index a47956a3a..7d5e0ba01 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -80,7 +80,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.4 2001-08-30 20:19:20 ossau Exp $ +@subtitle $Id: guile.texi,v 1.5 2001-10-27 16:53:34 ghouston Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -223,11 +223,7 @@ Part III: Guile Modules * Pretty Printing:: Nicely formatting Scheme objects for output. * Formatted Output:: The @code{format} procedure. * Expect:: Controlling interactive programs with Guile. -* The Scheme shell (scsh):: - The SCSH compatibility module has been made an - add-on, so maybe it shouldn't be documented here - (though it is nice to have a link from here to the - Guile-scsh manual, if one exists). +* The Scheme shell (scsh):: Using scsh interfaces in Guile. @c * Tcl/Tk Interface:: Part IV: Guile Scripting diff --git a/doc/ref/scsh.texi b/doc/ref/scsh.texi index 99afc0406..56177e78f 100644 --- a/doc/ref/scsh.texi +++ b/doc/ref/scsh.texi @@ -2,24 +2,17 @@ @node The Scheme shell (scsh) @chapter The Scheme shell (scsh) -An incomplete port of the Scheme shell (scsh) 0.5.1 is available for -Guile. The idea is to allow Scheme code using scsh interfaces to be run -inside the Guile interpreter. +An incomplete port of the Scheme shell (scsh) is available for Guile +as a separate package. The current status of guile-scsh can be found at +@url{http://arglist.com/guile/}. -For information about scsh on the Web see -@url{http://www-swiss.ai.mit.edu/scsh/scsh.html}. -The original scsh is available by ftp from -@url{ftp://swiss-ftp.ai.mit.edu:/pub/su}. +For information about scsh see +@url{http://www-swiss.ai.mit.edu/ftpdir/scsh/}. -The scsh code is distributed as a separate module, guile-scsh, -which must be installed somewhere in Guile's load path before -it can be used. This is similar to the installation -of slib (you may want to install that first, since it's needed before -scsh can run in Guile: see @ref{SLIB} for details). - -This port of scsh does not currently use the Guile module system, but -can be initialized with: +The closest emulation of scsh can be obtained by running: @smalllisp (load-from-path "scsh/init") @end smalllisp + +See the USAGE file supplied with guile-scsh for more details. From d245ce231d1b0eb29c229f4f0ccf148209dd56c4 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Sun, 28 Oct 2001 11:13:35 +0000 Subject: [PATCH 067/281] * unif.c (scm_uniform_array_read_x, scm_uniform_array_write): Don't apply scm_uniform_vector_length on arrays. --- libguile/ChangeLog | 5 +++++ libguile/unif.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index a00a3bd07..d958496f6 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-10-28 Mikael Djurfeldt + + * unif.c (scm_uniform_array_read_x, scm_uniform_array_write): + Don't apply scm_uniform_vector_length on arrays. + 2001-10-14 Dirk Herrmann * eval.c (scm_lookupcar, scm_m_letstar, scm_m_do, iqq, diff --git a/libguile/unif.c b/libguile/unif.c index 5b2af435c..2ace9239e 100644 --- a/libguile/unif.c +++ b/libguile/unif.c @@ -1511,7 +1511,9 @@ SCM_DEFINE (scm_uniform_array_read_x, "uniform-array-read!", 1, 3, 0, SCM_ASSERT (SCM_INUMP (port_or_fd) || (SCM_OPINPORTP (port_or_fd)), port_or_fd, SCM_ARG2, FUNC_NAME); - vlen = SCM_INUM (scm_uniform_vector_length (v)); + vlen = (SCM_TYP7 (v) == scm_tc7_smob + ? 0 + : SCM_INUM (scm_uniform_vector_length (v))); loop: switch SCM_TYP7 (v) @@ -1675,8 +1677,10 @@ SCM_DEFINE (scm_uniform_array_write, "uniform-array-write", 1, 3, 0, SCM_ASSERT (SCM_INUMP (port_or_fd) || (SCM_OPOUTPORTP (port_or_fd)), port_or_fd, SCM_ARG2, FUNC_NAME); - vlen = SCM_INUM (scm_uniform_vector_length (v)); - + vlen = (SCM_TYP7 (v) == scm_tc7_smob + ? 0 + : SCM_INUM (scm_uniform_vector_length (v))); + loop: switch SCM_TYP7 (v) { @@ -1686,8 +1690,8 @@ loop: SCM_ASRTGO (SCM_ARRAYP (v), badarg1); v = scm_ra2contig (v, 1); cstart = SCM_ARRAY_BASE (v); - vlen = SCM_ARRAY_DIMS (v)->inc - * (SCM_ARRAY_DIMS (v)->ubnd - SCM_ARRAY_DIMS (v)->lbnd + 1); + vlen = (SCM_ARRAY_DIMS (v)->inc + * (SCM_ARRAY_DIMS (v)->ubnd - SCM_ARRAY_DIMS (v)->lbnd + 1)); v = SCM_ARRAY_V (v); goto loop; case scm_tc7_string: From 8dd6dfdcd23a0fd47a4e2a4c94e27a3e05e7c43e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Thu, 1 Nov 2001 23:23:41 +0000 Subject: [PATCH 068/281] New files with implementations of dirent and uname for Win32. --- libguile/win32-dirent.c | 152 ++++++++++++++++++++++++++++++++++++ libguile/win32-dirent.h | 88 +++++++++++++++++++++ libguile/win32-uname.c | 165 ++++++++++++++++++++++++++++++++++++++++ libguile/win32-uname.h | 75 ++++++++++++++++++ 4 files changed, 480 insertions(+) create mode 100644 libguile/win32-dirent.c create mode 100644 libguile/win32-dirent.h create mode 100644 libguile/win32-uname.c create mode 100644 libguile/win32-uname.h diff --git a/libguile/win32-dirent.c b/libguile/win32-dirent.c new file mode 100644 index 000000000..00954f9d5 --- /dev/null +++ b/libguile/win32-dirent.c @@ -0,0 +1,152 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + +#include "libguile/__scm.h" + +#include +#include +#include + +#include "dirent.h" + +DIR * +opendir (const char * name) +{ + DIR *dir; + HANDLE hnd; + char *file; + WIN32_FIND_DATA find; + + if (!name || !*name) + return NULL; + file = malloc (strlen (name) + 3); + strcpy (file, name); + if (file[strlen (name) - 1] != '/' && file[strlen (name) - 1] != '\\') + strcat (file, "/*"); + else + strcat (file, "*"); + + if ((hnd = FindFirstFile (file, &find)) == INVALID_HANDLE_VALUE) + { + free (file); + return NULL; + } + + dir = malloc (sizeof (DIR)); + dir->mask = file; + dir->fd = (int) hnd; + dir->data = malloc (sizeof (WIN32_FIND_DATA)); + dir->allocation = sizeof (WIN32_FIND_DATA); + dir->size = dir->allocation; + dir->filepos = 0; + memcpy (dir->data, &find, sizeof (WIN32_FIND_DATA)); + return dir; +} + +struct dirent * +readdir (DIR * dir) +{ + static struct dirent entry; + WIN32_FIND_DATA *find; + + entry.d_ino = 0; + entry.d_type = 0; + find = (WIN32_FIND_DATA *) dir->data; + + if (dir->filepos) + { + if (!FindNextFile ((HANDLE) dir->fd, find)) + return NULL; + } + + entry.d_off = dir->filepos; + strncpy (entry.d_name, find->cFileName, sizeof (entry.d_name)); + entry.d_reclen = strlen (find->cFileName); + dir->filepos++; + return &entry; +} + +int +closedir (DIR * dir) +{ + HANDLE hnd = (HANDLE) dir->fd; + free (dir->data); + free (dir->mask); + free (dir); + return FindClose (hnd) ? 0 : -1; +} + +void +rewinddir (DIR * dir) +{ + HANDLE hnd = (HANDLE) dir->fd; + WIN32_FIND_DATA *find = (WIN32_FIND_DATA *) dir->data; + + FindClose (hnd); + hnd = FindFirstFile (dir->mask, find); + dir->fd = (int) hnd; + dir->filepos = 0; +} + +void +seekdir (DIR * dir, off_t offset) +{ + off_t n; + + rewinddir (dir); + for (n = 0; n < offset; n++) + { + if (FindNextFile ((HANDLE) dir->fd, (WIN32_FIND_DATA *) dir->data)) + dir->filepos++; + } +} + +off_t +telldir (DIR * dir) +{ + return dir->filepos; +} + +int +dirfd (DIR * dir) +{ + return dir->fd; +} diff --git a/libguile/win32-dirent.h b/libguile/win32-dirent.h new file mode 100644 index 000000000..ffc5e2a2d --- /dev/null +++ b/libguile/win32-dirent.h @@ -0,0 +1,88 @@ +/* classes: h_files */ + +#ifndef SCM_DIRENT_H +#define SCM_DIRENT_H + +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + +/* Directory stream type. + The miscellaneous Unix `readdir' implementations read directory data + into a buffer and return `struct dirent *' pointers into it. */ + +#include + +struct dirstream +{ + int fd; /* File descriptor. */ + char *data; /* Directory block. */ + size_t allocation; /* Space allocated for the block. */ + size_t size; /* Total valid data in the block. */ + size_t offset; /* Current offset into the block. */ + off_t filepos; /* Position of next entry to read. */ + char *mask; /* Initial file mask. */ +}; + +struct dirent +{ + long d_ino; + off_t d_off; + unsigned short int d_reclen; + unsigned char d_type; + char d_name[256]; +}; + +#define d_fileno d_ino /* Backwards compatibility. */ + +/* This is the data type of directory stream objects. + The actual structure is opaque to users. */ + +typedef struct dirstream DIR; + +DIR * opendir (const char * name); +struct dirent * readdir (DIR * dir); +int closedir (DIR * dir); +void rewinddir (DIR * dir); +void seekdir (DIR * dir, off_t offset); +off_t telldir (DIR * dir); +int dirfd (DIR * dir); + +#endif /* SCM_DIRENT_H */ diff --git a/libguile/win32-uname.c b/libguile/win32-uname.c new file mode 100644 index 000000000..1abbc8e94 --- /dev/null +++ b/libguile/win32-uname.c @@ -0,0 +1,165 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + +#include "libguile/__scm.h" + +#include +#include +#include + +#include "uname.h" + +/* + * Get name and information about current kernel. + */ +int +uname (struct utsname *uts) +{ + enum { WinNT, Win95, Win98, WinUnknown }; + OSVERSIONINFO osver; + SYSTEM_INFO sysinfo; + DWORD sLength; + DWORD os = WinUnknown; + + memset (uts, 0, sizeof (*uts)); + + osver.dwOSVersionInfoSize = sizeof (osver); + GetVersionEx (&osver); + GetSystemInfo (&sysinfo); + + switch (osver.dwPlatformId) + { + case VER_PLATFORM_WIN32_NT: /* NT, Windows 2000 or Windows XP */ + if (osver.dwMajorVersion == 4) + strcpy (uts->sysname, "Windows NT4x"); /* NT4x */ + else if (osver.dwMajorVersion <= 3) + strcpy (uts->sysname, "Windows NT3x"); /* NT3x */ + else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion < 1) + strcpy (uts->sysname, "Windows 2000"); /* 2k */ + else if (osver.dwMajorVersion >= 5) + strcpy (uts->sysname, "Windows XP"); /* XP */ + os = WinNT; + break; + + case VER_PLATFORM_WIN32_WINDOWS: /* Win95, Win98 or WinME */ + if ((osver.dwMajorVersion > 4) || + ((osver.dwMajorVersion == 4) && (osver.dwMinorVersion > 0))) + { + if (osver.dwMinorVersion >= 90) + strcpy (uts->sysname, "Windows ME"); /* ME */ + else + strcpy (uts->sysname, "Windows 98"); /* 98 */ + os = Win98; + } + else + { + strcpy (uts->sysname, "Windows 95"); /* 95 */ + os = Win95; + } + break; + + case VER_PLATFORM_WIN32s: /* Windows 3.x */ + strcpy (uts->sysname, "Windows"); + break; + } + + sprintf (uts->version, "%ld.%02ld", + osver.dwMajorVersion, osver.dwMinorVersion); + + if (osver.szCSDVersion[0] != '\0' && + (strlen (osver.szCSDVersion) + strlen (uts->version) + 1) < + sizeof (uts->version)) + { + strcat (uts->version, " "); + strcat (uts->version, osver.szCSDVersion); + } + + sprintf (uts->release, "build %ld", osver.dwBuildNumber & 0xFFFF); + + switch (sysinfo.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_PPC: + strcpy (uts->machine, "ppc"); + break; + case PROCESSOR_ARCHITECTURE_ALPHA: + strcpy (uts->machine, "alpha"); + break; + case PROCESSOR_ARCHITECTURE_MIPS: + strcpy (uts->machine, "mips"); + break; + case PROCESSOR_ARCHITECTURE_INTEL: + /* + * dwProcessorType is only valid in Win95 and Win98 and WinME + * wProcessorLevel is only valid in WinNT + */ + switch (os) + { + case Win95: + case Win98: + switch (sysinfo.dwProcessorType) + { + case PROCESSOR_INTEL_386: + case PROCESSOR_INTEL_486: + case PROCESSOR_INTEL_PENTIUM: + sprintf (uts->machine, "i%ld", sysinfo.dwProcessorType); + break; + default: + strcpy (uts->machine, "i386"); + break; + } + break; + case WinNT: + sprintf (uts->machine, "i%d86", sysinfo.wProcessorLevel); + break; + default: + strcpy (uts->machine, "unknown"); + break; + } + break; + default: + strcpy (uts->machine, "unknown"); + break; + } + + sLength = sizeof (uts->nodename) - 1; + GetComputerName (uts->nodename, &sLength); + return 0; +} diff --git a/libguile/win32-uname.h b/libguile/win32-uname.h new file mode 100644 index 000000000..a61b5ca5a --- /dev/null +++ b/libguile/win32-uname.h @@ -0,0 +1,75 @@ +/* classes: h_files */ + +#ifndef SCM_UNAME_H +#define SCM_UNAME_H + +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + +#define _UTSNAME_LENGTH 65 +#define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH +#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH + +/* Structure describing the system and machine. */ +struct utsname +{ + /* Name of the implementation of the operating system. */ + char sysname[_UTSNAME_LENGTH]; + + /* Name of this node on the network. */ + char nodename[_UTSNAME_NODENAME_LENGTH]; + + /* Current release level of this implementation. */ + char release[_UTSNAME_LENGTH]; + + /* Current version level of this release. */ + char version[_UTSNAME_LENGTH]; + + /* Name of the hardware type the system is running on. */ + char machine[_UTSNAME_LENGTH]; + + /* Name of the domain of this node on the network. */ + char domainname[_UTSNAME_DOMAIN_LENGTH]; +}; + +int uname (struct utsname *uts); + +#endif /* SCM_UNAME_H */ From fb39eb4933e2bedecc2b7359d7cdbb9953e42216 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:05:45 +0000 Subject: [PATCH 069/281] * check-guile.in: Replaced `ln -s' by `@LN_S@' to supports build systems which do not have symbolic links. --- check-guile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-guile.in b/check-guile.in index 126550a0c..ebfe89cb2 100644 --- a/check-guile.in +++ b/check-guile.in @@ -37,7 +37,7 @@ fi # documentation searching ignores GUILE_LOAD_PATH. if [ ! -f guile-procedures.txt ] ; then - ln -s libguile/guile-procedures.txt . + @LN_S@ libguile/guile-procedures.txt . fi exec "$guile" -e main -s "$TEST_SUITE_DIR/guile-test" --test-suite "$TEST_SUITE_DIR/tests" --log-file check-guile.log "$@" From f9e5e096e79e85376c18be5d5f7087240d139ff5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:05:57 +0000 Subject: [PATCH 070/281] * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls on Win32 platforms. Checking for `ws2_32.dll', `winsock2.h', add `uname.o' and `dirent.o' and define extra compiler flags necessary to build clean dlls. Check for `regcomp()' inside `-lregex'. --- configure.in | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 0ddff0eb7..1a95617a9 100644 --- a/configure.in +++ b/configure.in @@ -152,9 +152,15 @@ fi #-------------------------------------------------------------------- +dnl Some more checks for Win32 +AC_CYGWIN +AC_MINGW32 +AC_LIBTOOL_WIN32_DLL + AC_LIBLTDL_CONVENIENCE AC_CONFIG_SUBDIRS(libltdl) +AC_PROG_INSTALL AC_PROG_CC AC_PROG_CPP AC_LIBTOOL_DLOPEN @@ -201,7 +207,7 @@ AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h sys/utime.h time.h unistd.h utime.h pwd.h winsock2.h grp.h sys/utsname.h) +AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h direct.h) GUILE_HEADER_LIBC_WITH_UNISTD AC_TYPE_GETGROUPS @@ -218,7 +224,25 @@ if test $ac_cv_func_connect = no; then AC_CHECK_LIB(socket, connect) fi -# Check for dynamic linking +dnl +dnl Check for Winsock and other functionality on Win32 (*not* CygWin) +dnl +EXTRA_DEFS="" +EXTRA_LIB_DEFS="" +if test "$MINGW32" = "yes" ; then + AC_CHECK_HEADER(winsock2.h, [AC_DEFINE([HAVE_WINSOCK2_H], 1, + [Define if you have the header file.])]) + AC_CHECK_LIB(ws2_32, main) + LIBOBJS="$LIBOBJS uname.o dirent.o" + if test $enable_shared = yes ; then + EXTRA_DEFS="-D__SCM_IMPORT__ -D__REGEX_IMPORT__ -D__CRYPT_IMPORT__" + EXTRA_LIB_DEFS="-D__REGEX_IMPORT__ -D__CRYPT_IMPORT__" + fi +fi +AC_SUBST(EXTRA_DEFS) +AC_SUBST(EXTRA_LIB_DEFS) + +dnl Check for dynamic linking use_modules=yes AC_ARG_WITH(modules, @@ -407,11 +431,14 @@ if test "$enable_regex" = yes; then test "$ac_cv_header_rx_rxposix_h" = yes; then GUILE_NAMED_CHECK_FUNC(regcomp, norx, [LIBOBJS="regex-posix.o $LIBOBJS"], [AC_CHECK_LIB(rx, main) - GUILE_NAMED_CHECK_FUNC(regcomp, rx, [LIBOBJS="regex-posix.o $LIBOBJS"])] + GUILE_NAMED_CHECK_FUNC(regcomp, rx, [LIBOBJS="regex-posix.o $LIBOBJS"], + [AC_CHECK_LIB(regex, main) + GUILE_NAMED_CHECK_FUNC(regcomp, regex, [LIBOBJS="regex-posix.o $LIBOBJS"])])] ) dnl The following should not be necessary, but for some reason dnl autoheader misses it if we don't include it! if test "$ac_cv_func_regcomp_norx" = yes || + test "$ac_cv_func_regcomp_regex" = yes || test "$ac_cv_func_regcomp_rx" = yes; then AC_DEFINE(HAVE_REGCOMP) fi From 7ed1380067469173f1185a944dcb692e4afae32c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:06:18 +0000 Subject: [PATCH 071/281] Put `-export-dynamic -no-undefined' into LDFLAGS and add the library `libguile.la' to support linkers which do not allow unresolved symbols inside shared libraries. --- guile-readline/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/guile-readline/Makefile.am b/guile-readline/Makefile.am index 1094501e9..fe35d398b 100644 --- a/guile-readline/Makefile.am +++ b/guile-readline/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = foreign ## Prevent automake from adding extra -I options -DEFS = @DEFS@ +DEFS = @DEFS@ @EXTRA_DEFS@ ## Check for headers in $(srcdir)/.., so that #include ## will find MUMBLE.h in this dir when we're ## building. @@ -33,6 +33,8 @@ GUILE_SNARF = ../libguile/guile-snarf lib_LTLIBRARIES = libguilereadline.la libguilereadline_la_SOURCES = readline.c +libguilereadline_la_LDFLAGS = -export-dynamic -no-undefined +libguilereadline_la_LIBADD = ../libguile/libguile.la BUILT_SOURCES = readline.x From 78f8126600b9008c2b39bd395ebbd2be5030c412 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:06:26 +0000 Subject: [PATCH 072/281] Define AC_LIBTOOL_WIN32_DLL to build clean dlls on Win32 platforms. Define extra compiler flags necessary to build clean dlls. --- guile-readline/configure.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guile-readline/configure.in b/guile-readline/configure.in index ef62338d8..c6162e033 100644 --- a/guile-readline/configure.in +++ b/guile-readline/configure.in @@ -6,10 +6,25 @@ AC_CONFIG_SRCDIR([readline.c]) PACKAGE=guile-readline AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) +AC_PROG_INSTALL AC_PROG_CC AM_PROG_CC_STDC +AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL +dnl +dnl Check for Winsock and other functionality on Win32 (*not* CygWin) +dnl +AC_CYGWIN +AC_MINGW32 +EXTRA_DEFS="" +if test "$MINGW32" = "yes" ; then + if test $enable_shared = yes ; then + EXTRA_DEFS="-D__SCM_IMPORT__ -D__READLINE_IMPORT__" + fi +fi +AC_SUBST(EXTRA_DEFS) + for termlib in ncurses curses termcap terminfo termlib ; do AC_CHECK_LIB(${termlib}, tgoto, [LIBS="-l${termlib} $LIBS"; break]) From 5e90b6ac042cacb59c5344d84c6b86d0262839f5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:06:34 +0000 Subject: [PATCH 073/281] Include `io.h' and exclude `sys/time.h' for MinGW. --- guile-readline/readline.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guile-readline/readline.c b/guile-readline/readline.c index 72d46c91c..6fcd656bf 100644 --- a/guile-readline/readline.c +++ b/guile-readline/readline.c @@ -34,7 +34,11 @@ #endif #include #include +#ifndef __MINGW32__ #include +#else +#include +#endif #include #include "libguile/validate.h" From 7500c31618bac0a67c883f96770c84a2aa5ca65d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:06:49 +0000 Subject: [PATCH 074/281] Defintion of SCM_RL_API. Prefixed each exported symbol with SCM_RL_API. --- guile-readline/readline.h | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/guile-readline/readline.h b/guile-readline/readline.h index 20d44df10..327708270 100644 --- a/guile-readline/readline.h +++ b/guile-readline/readline.h @@ -20,24 +20,36 @@ * */ +/* SCM_RL_API is a macro prepended to all function and data definitions + which should be exported or imported in the resulting dynamic link + library in the Win32 port. */ + +#if defined (__SCM_RL_IMPORT__) +# define SCM_RL_API __declspec (dllimport) +#elif defined (__SCM_RL_EXPORT__) || defined (DLL_EXPORT) +# define SCM_RL_API __declspec (dllexport) +#else +# define SCM_RL_API extern +#endif + #include "libguile/__scm.h" -extern scm_t_option scm_readline_opts[]; +SCM_RL_API scm_t_option scm_readline_opts[]; #define SCM_HISTORY_FILE_P scm_readline_opts[0].val #define SCM_HISTORY_LENGTH scm_readline_opts[1].val #define SCM_READLINE_BOUNCE_PARENS scm_readline_opts[2].val #define SCM_N_READLINE_OPTIONS 3 -extern SCM scm_readline_options (SCM setting); -extern void scm_readline_init_ports (SCM inp, SCM outp); -extern SCM scm_readline (SCM txt, SCM inp, SCM outp, SCM read_hook); -extern SCM scm_add_history (SCM txt); -extern SCM scm_clear_history (void); -extern SCM scm_read_history (SCM file); -extern SCM scm_write_history (SCM file); -extern SCM scm_filename_completion_function (SCM text, SCM continuep); -extern void scm_init_readline (void); +SCM_RL_API SCM scm_readline_options (SCM setting); +SCM_RL_API void scm_readline_init_ports (SCM inp, SCM outp); +SCM_RL_API SCM scm_readline (SCM txt, SCM inp, SCM outp, SCM read_hook); +SCM_RL_API SCM scm_add_history (SCM txt); +SCM_RL_API SCM scm_clear_history (void); +SCM_RL_API SCM scm_read_history (SCM file); +SCM_RL_API SCM scm_write_history (SCM file); +SCM_RL_API SCM scm_filename_completion_function (SCM text, SCM continuep); +SCM_RL_API void scm_init_readline (void); #ifndef HAVE_RL_CLEANUP_AFTER_SIGNAL void rl_cleanup_after_signal (); From 257b6d408d492e82248e720feefb896af57cb86d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:06:57 +0000 Subject: [PATCH 075/281] *** empty log message *** --- ChangeLog | 13 +++++++++++++ guile-readline/ChangeLog | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ChangeLog b/ChangeLog index d807895c2..aee0757db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-11-02 Marius Vollmer + + Support for native Win32. Thanks to Stefan Jahn! + + * check-guile.in: Replaced `ln -s' by `@LN_S@' to supports + build systems which do not have symbolic links. + * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls + on Win32 platforms. + Checking for `ws2_32.dll', `winsock2.h', add `uname.o' and + `dirent.o' and define extra compiler flags necessary to build + clean dlls. + Check for `regcomp()' inside `-lregex'. + 2001-10-26 Thien-Thi Nguyen * BUGS (7, 8): New. diff --git a/guile-readline/ChangeLog b/guile-readline/ChangeLog index 8da222be4..4c23f0457 100644 --- a/guile-readline/ChangeLog +++ b/guile-readline/ChangeLog @@ -1,3 +1,20 @@ +2001-11-02 Marius Vollmer + + Support for native Win32. Thanks to Stefan Jahn! + + * Makefile.am: Put `-export-dynamic -no-undefined' into LDFLAGS + and add the library `libguile.la' to support linkers which do not + allow unresolved symbols inside shared libraries. + + * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls + on Win32 platforms. + Define extra compiler flags necessary to build clean dlls. + + * readline.c: Include `io.h' and exclude `sys/time.h' for MinGW. + + * readline.h: Defintion of SCM_RL_API. Prefixed each exported + symbol with SCM_RL_API. + 2001-08-31 Dirk Herrmann * readline.c (scm_readline, scm_add_history, From 94b1762d3229122bad4cece53aa9088f0b8c2f6f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:07:11 +0000 Subject: [PATCH 076/281] Add win32-uname.c, win32-uname.h, win32-dirent.c and win32-dirent.h to extra source and header files. These include the uname() and the POSIX dirent interface implementation for M$-Windows. Put `-no-undefined' into LDFLAGS to support linkers which do not allow unresolved symbols inside shared libraries. Corrected `guile_filter_doc_snarfage$(EXEEXT)' dependency. --- libguile/Makefile.am | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 6e9294afa..16ab8213d 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = gnu ## Prevent automake from adding extra -I options -DEFS = @DEFS@ +DEFS = @DEFS@ @EXTRA_LIB_DEFS@ ## Check for headers in $(srcdir)/.., so that #include ## will find MUMBLE.h in this dir when we're ## building. @@ -94,7 +94,7 @@ EXTRA_libguile_la_SOURCES = _scm.h \ alloca.c inet_aton.c memmove.c putenv.c strerror.c \ threads.c regex-posix.c \ filesys.c posix.c net_db.c socket.c \ - ramap.c unif.c debug-malloc.c mkstemp.c + ramap.c unif.c debug-malloc.c mkstemp.c win32-uname.c win32-dirent.c ## In next release, threads will be factored out of libguile. ## Until then, the machine specific headers is a temporary kludge. @@ -112,11 +112,11 @@ install-exec-hook: ## Perhaps we can deal with them normally once the merge seems to be ## working. noinst_HEADERS = coop-threads.c coop-threads.h coop.c \ - num2integral.i.c num2float.i.c + num2integral.i.c num2float.i.c win32-uname.h win32-dirent.h libguile_la_DEPENDENCIES = @LIBLOBJS@ libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) -libguile_la_LDFLAGS = -version-info @LIBGUILE_INTERFACE_CURRENT@:@LIBGUILE_INTERFACE_REVISION@:@LIBGUILE_INTERFACE_AGE@ -export-dynamic +libguile_la_LDFLAGS = -version-info @LIBGUILE_INTERFACE_CURRENT@:@LIBGUILE_INTERFACE_REVISION@:@LIBGUILE_INTERFACE_AGE@ -export-dynamic -no-undefined # These are headers visible as pkginclude_HEADERS = gh.h @@ -198,7 +198,7 @@ SUFFIXES = .x .doc $(DOT_X_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf.in -$(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf-docs.in guile_filter_doc_snarfage +$(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf-docs.in guile_filter_doc_snarfage$(EXEEXT) error.x: cpp_err_symbols.c posix.x: cpp_sig_symbols.c From 1174045c9ade5765b91d80d12af7f70b7744f305 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:07:21 +0000 Subject: [PATCH 077/281] * __scm.h: Defined SCM_API. This macro gets prepended to all function and data definitions which should be exported or imported in the resulting dynamic link library in the Win32 port. * __scm.h, alist.h, arbiters.h, async.h, backtrace.h, boolean.h, chars.h, continuations.h, coop-defs.h, coop-threads.h, debug-malloc.h, debug.h, deprecation.h, dynl.h, dynwind.h, environments.h, eq.h, error.h, eval.h, evalext.h, extensions.h, feature.h, filesys.h, fluids.h, fports.h, gc.h, gdb_interface.h, gdbint.h, gh.h, goops.h, gsubr.h, guardians.h, hash.h, hashtab.h, hooks.h, init.h, ioext.h, iselect.h, keywords.h, lang.h, list.h, load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h, objects.h, objprop.h, options.h, pairs.h, ports.h, posix.h, print.h, procprop.h, procs.h, properties.h, ramap.h, random.h, rdelim.h, read.h, regex-posix.h, root.h, rw.h, scmsigs.h, script.h, simpos.h, smob.h, socket.h, sort.h, srcprop.h, stackchk.h, stacks.h, stime.h, strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h, tags.h, threads.h, throw.h, unif.h, values.h, variable.h, vectors.h, vports.h, weaks.h: Prefixed each each exported symbol with SCM_API. --- libguile/__scm.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libguile/__scm.h b/libguile/__scm.h index fb2d9c2cd..b24158b51 100644 --- a/libguile/__scm.h +++ b/libguile/__scm.h @@ -157,6 +157,20 @@ +/* SCM_API is a macro prepended to all function and data definitions + which should be exported or imported in the resulting dynamic link + library in the Win32 port. */ + +#if defined (__SCM_IMPORT__) +# define SCM_API __declspec (dllimport) extern +#elif defined (__SCM_EXPORT__) || defined (DLL_EXPORT) +# define SCM_API __declspec (dllexport) extern +#else +# define SCM_API extern +#endif + + + /* What did the configure script discover about the outside world? */ #include "libguile/scmconfig.h" @@ -384,7 +398,7 @@ typedef long SCM_STACKITEM; #endif #ifdef GUILE_OLD_ASYNC_CLICK -extern unsigned int scm_async_clock; +SCM_API unsigned int scm_async_clock; #define SCM_ASYNC_TICK \ do { \ @@ -392,7 +406,7 @@ do { \ scm_async_click (); \ } while(0) #else -extern int scm_asyncs_pending_p; +SCM_API int scm_asyncs_pending_p; #define SCM_ASYNC_TICK /*fixme* should change names */ \ do { \ @@ -565,7 +579,7 @@ do { \ * like SCM_BOOL_F or SCM_UNDEFINED was chosen. */ -extern SCM scm_call_generic_0 (SCM gf); +SCM_API SCM scm_call_generic_0 (SCM gf); #define SCM_WTA_DISPATCH_0(gf, subr) \ return (SCM_UNPACK (gf) \ @@ -574,7 +588,7 @@ extern SCM scm_call_generic_0 (SCM gf); #define SCM_GASSERT0(cond, gf, subr) \ if (!(cond)) SCM_WTA_DISPATCH_0((gf), (subr)) -extern SCM scm_call_generic_1 (SCM gf, SCM a1); +SCM_API SCM scm_call_generic_1 (SCM gf, SCM a1); #define SCM_WTA_DISPATCH_1(gf, a1, pos, subr) \ return (SCM_UNPACK (gf) \ @@ -583,7 +597,7 @@ extern SCM scm_call_generic_1 (SCM gf, SCM a1); #define SCM_GASSERT1(cond, gf, a1, pos, subr) \ if (!(cond)) SCM_WTA_DISPATCH_1((gf), (a1), (pos), (subr)) -extern SCM scm_call_generic_2 (SCM gf, SCM a1, SCM a2); +SCM_API SCM scm_call_generic_2 (SCM gf, SCM a1, SCM a2); #define SCM_WTA_DISPATCH_2(gf, a1, a2, pos, subr) \ return (SCM_UNPACK (gf) \ @@ -594,7 +608,7 @@ extern SCM scm_call_generic_2 (SCM gf, SCM a1, SCM a2); #define SCM_GASSERT2(cond, gf, a1, a2, pos, subr) \ if (!(cond)) SCM_WTA_DISPATCH_2((gf), (a1), (a2), (pos), (subr)) -extern SCM scm_apply_generic (SCM gf, SCM args); +SCM_API SCM scm_apply_generic (SCM gf, SCM args); #define SCM_WTA_DISPATCH_n(gf, args, pos, subr) \ return (SCM_UNPACK (gf) \ From e4e933734c267ff14e02f3ae721c06223803dd65 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:08:10 +0000 Subject: [PATCH 078/281] Prefixed each each exported symbol with SCM_API. --- libguile/alist.h | 34 +++++++++++++++++----------------- libguile/arbiters.h | 8 ++++---- libguile/async.h | 30 +++++++++++++++--------------- libguile/backtrace.h | 18 +++++++++--------- libguile/boolean.h | 6 +++--- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/libguile/alist.h b/libguile/alist.h index bf8b4562e..010802b5a 100644 --- a/libguile/alist.h +++ b/libguile/alist.h @@ -50,23 +50,23 @@ -extern SCM scm_acons (SCM w, SCM x, SCM y); -extern SCM scm_sloppy_assq (SCM x, SCM alist); -extern SCM scm_sloppy_assv (SCM x, SCM alist); -extern SCM scm_sloppy_assoc (SCM x, SCM alist); -extern SCM scm_assq (SCM x, SCM alist); -extern SCM scm_assv (SCM x, SCM alist); -extern SCM scm_assoc (SCM x, SCM alist); -extern SCM scm_assq_ref (SCM alist, SCM key); -extern SCM scm_assv_ref (SCM alist, SCM key); -extern SCM scm_assoc_ref (SCM alist, SCM key); -extern SCM scm_assq_set_x (SCM alist, SCM key, SCM val); -extern SCM scm_assv_set_x (SCM alist, SCM key, SCM val); -extern SCM scm_assoc_set_x (SCM alist, SCM key, SCM val); -extern SCM scm_assq_remove_x (SCM alist, SCM key); -extern SCM scm_assv_remove_x (SCM alist, SCM key); -extern SCM scm_assoc_remove_x (SCM alist, SCM key); -extern void scm_init_alist (void); +SCM_API SCM scm_acons (SCM w, SCM x, SCM y); +SCM_API SCM scm_sloppy_assq (SCM x, SCM alist); +SCM_API SCM scm_sloppy_assv (SCM x, SCM alist); +SCM_API SCM scm_sloppy_assoc (SCM x, SCM alist); +SCM_API SCM scm_assq (SCM x, SCM alist); +SCM_API SCM scm_assv (SCM x, SCM alist); +SCM_API SCM scm_assoc (SCM x, SCM alist); +SCM_API SCM scm_assq_ref (SCM alist, SCM key); +SCM_API SCM scm_assv_ref (SCM alist, SCM key); +SCM_API SCM scm_assoc_ref (SCM alist, SCM key); +SCM_API SCM scm_assq_set_x (SCM alist, SCM key, SCM val); +SCM_API SCM scm_assv_set_x (SCM alist, SCM key, SCM val); +SCM_API SCM scm_assoc_set_x (SCM alist, SCM key, SCM val); +SCM_API SCM scm_assq_remove_x (SCM alist, SCM key); +SCM_API SCM scm_assv_remove_x (SCM alist, SCM key); +SCM_API SCM scm_assoc_remove_x (SCM alist, SCM key); +SCM_API void scm_init_alist (void); #endif /* SCM_ALIST_H */ diff --git a/libguile/arbiters.h b/libguile/arbiters.h index 7cda145c7..c0d331515 100644 --- a/libguile/arbiters.h +++ b/libguile/arbiters.h @@ -50,10 +50,10 @@ -extern SCM scm_make_arbiter (SCM name); -extern SCM scm_try_arbiter (SCM arb); -extern SCM scm_release_arbiter (SCM arb); -extern void scm_init_arbiters (void); +SCM_API SCM scm_make_arbiter (SCM name); +SCM_API SCM scm_try_arbiter (SCM arb); +SCM_API SCM scm_release_arbiter (SCM arb); +SCM_API void scm_init_arbiters (void); #endif /* SCM_ARBITERS_H */ diff --git a/libguile/async.h b/libguile/async.h index ed2d7c416..7cdb81cd1 100644 --- a/libguile/async.h +++ b/libguile/async.h @@ -50,24 +50,24 @@ -extern unsigned int scm_mask_ints; +SCM_API unsigned int scm_mask_ints; -extern int scm_asyncs_pending (void); -extern void scm_async_click (void); -extern void scm_switch (void); -extern SCM scm_async (SCM thunk); -extern SCM scm_system_async (SCM thunk); -extern SCM scm_async_mark (SCM a); -extern SCM scm_system_async_mark (SCM a); -extern SCM scm_run_asyncs (SCM list_of_a); -extern SCM scm_noop (SCM args); -extern SCM scm_set_tick_rate (SCM n); -extern SCM scm_set_switch_rate (SCM n); -extern SCM scm_unmask_signals (void); -extern SCM scm_mask_signals (void); -extern void scm_init_async (void); +SCM_API int scm_asyncs_pending (void); +SCM_API void scm_async_click (void); +SCM_API void scm_switch (void); +SCM_API SCM scm_async (SCM thunk); +SCM_API SCM scm_system_async (SCM thunk); +SCM_API SCM scm_async_mark (SCM a); +SCM_API SCM scm_system_async_mark (SCM a); +SCM_API SCM scm_run_asyncs (SCM list_of_a); +SCM_API SCM scm_noop (SCM args); +SCM_API SCM scm_set_tick_rate (SCM n); +SCM_API SCM scm_set_switch_rate (SCM n); +SCM_API SCM scm_unmask_signals (void); +SCM_API SCM scm_mask_signals (void); +SCM_API void scm_init_async (void); #endif /* SCM_ASYNC_H */ diff --git a/libguile/backtrace.h b/libguile/backtrace.h index 0c0b7417b..482488da5 100644 --- a/libguile/backtrace.h +++ b/libguile/backtrace.h @@ -51,19 +51,19 @@ #include "libguile/__scm.h" -extern SCM scm_the_last_stack_fluid_var; +SCM_API SCM scm_the_last_stack_fluid_var; -void scm_display_error_message (SCM message, SCM args, SCM port); -void scm_i_display_error (SCM stack, SCM port, SCM subr, SCM message, SCM args, SCM rest); -SCM scm_display_error (SCM stack, SCM port, SCM subr, SCM message, SCM args, SCM rest); -SCM scm_display_application (SCM frame, SCM port, SCM indent); -SCM scm_display_backtrace (SCM stack, SCM port, SCM first, SCM depth); -SCM scm_backtrace (void); +SCM_API void scm_display_error_message (SCM message, SCM args, SCM port); +SCM_API void scm_i_display_error (SCM stack, SCM port, SCM subr, SCM message, SCM args, SCM rest); +SCM_API SCM scm_display_error (SCM stack, SCM port, SCM subr, SCM message, SCM args, SCM rest); +SCM_API SCM scm_display_application (SCM frame, SCM port, SCM indent); +SCM_API SCM scm_display_backtrace (SCM stack, SCM port, SCM first, SCM depth); +SCM_API SCM scm_backtrace (void); #ifdef GUILE_DEBUG -SCM scm_set_print_params_x (SCM params); +SCM_API SCM scm_set_print_params_x (SCM params); #endif -void scm_init_backtrace (void); +SCM_API void scm_init_backtrace (void); #endif /* SCM_BACKTRACE_H */ diff --git a/libguile/boolean.h b/libguile/boolean.h index a4328fd48..907873e8d 100644 --- a/libguile/boolean.h +++ b/libguile/boolean.h @@ -73,9 +73,9 @@ -extern SCM scm_not (SCM x); -extern SCM scm_boolean_p (SCM obj); -extern void scm_init_boolean (void); +SCM_API SCM scm_not (SCM x); +SCM_API SCM scm_boolean_p (SCM obj); +SCM_API void scm_init_boolean (void); #endif /* SCM_BOOLEAN_H */ From 87855fa2c4eec5782afe92157848a7507ee821c9 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:08:41 +0000 Subject: [PATCH 079/281] * __scm.h, alist.h, arbiters.h, async.h, backtrace.h, boolean.h, chars.h, continuations.h, coop-defs.h, coop-threads.h, debug-malloc.h, debug.h, deprecation.h, dynl.h, dynwind.h, environments.h, eq.h, error.h, eval.h, evalext.h, extensions.h, feature.h, filesys.h, fluids.h, fports.h, gc.h, gdb_interface.h, gdbint.h, gh.h, goops.h, gsubr.h, guardians.h, hash.h, hashtab.h, hooks.h, init.h, ioext.h, iselect.h, keywords.h, lang.h, list.h, load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h, objects.h, objprop.h, options.h, pairs.h, ports.h, posix.h, print.h, procprop.h, procs.h, properties.h, ramap.h, random.h, rdelim.h, read.h, regex-posix.h, root.h, rw.h, scmsigs.h, script.h, simpos.h, smob.h, socket.h, sort.h, srcprop.h, stackchk.h, stacks.h, stime.h, strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h, tags.h, threads.h, throw.h, unif.h, values.h, variable.h, vectors.h, vports.h, weaks.h: Prefixed each each exported symbol with SCM_API. * continuations.c: Added comment about the use of the extern declarations of {get,set}context() functions used in the ia64 port. * continuations.h, gc.c: `__libc_ia64_register_backing_store_base' is meant to be a `unsigned long *'. --- libguile/continuations.c | 7 +++++-- libguile/continuations.h | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libguile/continuations.c b/libguile/continuations.c index 586ab1f0d..769bbfc84 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -115,6 +115,9 @@ continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED) } #ifdef __ia64__ +/* Extern declaration of getcontext()/setcontext() in order to redefine + getcontext() since on ia64-linux the second return value indicates whether + it returned from getcontext() itself or by running setcontext(). */ struct rv { long retval; @@ -138,7 +141,7 @@ scm_make_continuation (int *first) SCM_STACKITEM * src; #ifdef __ia64__ struct rv rv; -#endif +#endif /* __ia64__ */ SCM_ENTER_A_SECTION; SCM_FLUSH_REGISTER_WINDOWS; @@ -168,7 +171,7 @@ scm_make_continuation (int *first) { continuation->backing_store_size = continuation->ctx.uc_mcontext.sc_ar_bsp - - __libc_ia64_register_backing_store_base; + (unsigned long) __libc_ia64_register_backing_store_base; continuation->backing_store = NULL; continuation->backing_store = scm_must_malloc (continuation->backing_store_size, FUNC_NAME); diff --git a/libguile/continuations.h b/libguile/continuations.h index 4a0c55ca1..d8db12ff0 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -50,8 +50,8 @@ #ifdef __ia64__ #include -extern unsigned long __libc_ia64_register_backing_store_base; -#endif +extern unsigned long * __libc_ia64_register_backing_store_base; +#endif /* __ia64__ */ /* a continuation SCM is a non-immediate pointing to a heap cell with: @@ -62,7 +62,7 @@ extern unsigned long __libc_ia64_register_backing_store_base; in the num_stack_items field of the structure. */ -extern scm_t_bits scm_tc16_continuation; +SCM_API scm_t_bits scm_tc16_continuation; typedef struct { @@ -102,8 +102,8 @@ typedef struct -extern SCM scm_make_continuation (int *first); -extern void scm_init_continuations (void); +SCM_API SCM scm_make_continuation (int *first); +SCM_API void scm_init_continuations (void); #endif /* SCM_CONTINUATIONS_H */ From e0c73a1cb69d4a2971000cb80d83f59b39a3f656 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:09:02 +0000 Subject: [PATCH 080/281] Include `direct.h' if possible. Use local `win32-dirent.h' for the native M$-Windows port. Define S_IS*() macros for M$-Windows. Implementation of `fstat_Win32()' which is able to differentiate between sockets and other file descriptors. Use this function as wrapper in `scm_fstat()'. Fixed typo in `scm_dirname()'. --- libguile/filesys.c | 59 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/libguile/filesys.c b/libguile/filesys.c index 1482db521..93015d8df 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -60,6 +60,10 @@ #include #endif +#ifdef HAVE_DIRECT_H +#include +#endif + #ifdef TIME_WITH_SYS_TIME # include # include @@ -96,7 +100,10 @@ #endif -#if HAVE_DIRENT_H +#if defined (__MINGW32__) || defined (_MSC_VER) || defined (__BORLANDC__) +# include "win32-dirent.h" +# define NAMLEN(dirent) strlen((dirent)->d_name) +#elif HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) #else @@ -121,10 +128,12 @@ /* The MinGW gcc does not define the S_ISSOCK macro. Any other native Windows compiler like BorlandC or MSVC has none of these macros defined. */ #ifdef __MINGW32__ -# define S_ISSOCK(mode) (0) +# define _S_IFSOCK 0xC000 +# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK) #endif #if defined (__BORLANDC__) || defined (_MSC_VER) -# define S_ISBLK(mode) (0) +# define _S_IFBLK 0x3000 +# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK) # define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) # define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR) # define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) @@ -483,6 +492,31 @@ scm_stat2scm (struct stat *stat_temp) return ans; } +#ifdef __MINGW32__ +/* + * Try getting the appropiate stat buffer for a given file descriptor + * under Windows. It differentiates between file, pipe and socket + * descriptors. + */ +static int fstat_Win32 (int fdes, struct stat *buf) +{ + int error, optlen = sizeof (int); + + memset (buf, 0, sizeof (struct stat)); + + /* Is this a socket ? */ + if (getsockopt (fdes, SOL_SOCKET, SO_ERROR, (void *) &error, &optlen) >= 0) + { + buf->st_mode = _S_IFSOCK | _S_IREAD | _S_IWRITE | _S_IEXEC; + buf->st_nlink = 1; + buf->st_atime = buf->st_ctime = buf->st_mtime = time (NULL); + return 0; + } + /* Maybe a regular file or pipe ? */ + return fstat (fdes, buf); +} +#endif /* __MINGW32__ */ + SCM_DEFINE (scm_stat, "stat", 1, 0, 0, (SCM object), "Return an object containing various information about the file\n" @@ -549,18 +583,35 @@ SCM_DEFINE (scm_stat, "stat", 1, 0, 0, if (SCM_INUMP (object)) { +#ifdef __MINGW32__ + SCM_SYSCALL (rv = fstat_Win32 (SCM_INUM (object), &stat_temp)); +#else SCM_SYSCALL (rv = fstat (SCM_INUM (object), &stat_temp)); +#endif } else if (SCM_STRINGP (object)) { +#ifdef __MINGW32__ + char *p, *file = strdup (SCM_STRING_CHARS (object)); + p = file + strlen (file) - 1; + while (p > file && (*p == '/' || *p == '\\')) + *p-- = '\0'; + SCM_SYSCALL (rv = stat (file, &stat_temp)); + free (file); +#else SCM_SYSCALL (rv = stat (SCM_STRING_CHARS (object), &stat_temp)); +#endif } else { object = SCM_COERCE_OUTPORT (object); SCM_VALIDATE_OPFPORT (1, object); fdes = SCM_FPORT_FDES (object); +#ifdef __MINGW32__ + SCM_SYSCALL (rv = fstat_Win32 (fdes, &stat_temp)); +#else SCM_SYSCALL (rv = fstat (fdes, &stat_temp)); +#endif } if (rv == -1) @@ -1378,7 +1429,7 @@ SCM_DEFINE (scm_dirname, "dirname", 1, 0, 0, i = len - 1; #ifdef __MINGW32__ while (i >= 0 && (s[i] == '/' || s[i] == '\\')) --i; - while (i >= 0 && (s[i] != '/' || s[i] != '\\')) --i; + while (i >= 0 && (s[i] != '/' && s[i] != '\\')) --i; while (i >= 0 && (s[i] == '/' || s[i] == '\\')) --i; #else while (i >= 0 && s[i] == '/') --i; From b8b17bfd316c9f038a578c739577c32e79ade312 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:09:14 +0000 Subject: [PATCH 081/281] Include `io.h' is possible. Put `*fp' into referring statement block in `scm_fport_buffer_add()'. Some corrections in `getflags()'. --- libguile/fports.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libguile/fports.c b/libguile/fports.c index 7317ed17d..6c1106052 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -59,6 +59,9 @@ #else size_t fwrite (); #endif +#ifdef HAVE_IO_H +#include +#endif #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE #include #endif @@ -86,7 +89,6 @@ static void scm_fport_buffer_add (SCM port, long read_size, int write_size) #define FUNC_NAME "scm_fport_buffer_add" { - scm_t_fport *fp = SCM_FSTREAM (port); scm_t_port *pt = SCM_PTAB_ENTRY (port); if (read_size == -1 || write_size == -1) @@ -94,6 +96,7 @@ scm_fport_buffer_add (SCM port, long read_size, int write_size) size_t default_size; #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE struct stat st; + scm_t_fport *fp = SCM_FSTREAM (port); default_size = (fstat (fp->fdes, &st) == -1) ? default_buffer_size : st.st_blksize; @@ -376,13 +379,14 @@ static int getflags (int fdes) else { /* Or an anonymous pipe handle ? */ - if (buf.st_mode & 0x1000 /* _O_SHORT_LIVED */) + if (buf.st_mode & _S_IFIFO) flags = O_RDWR; /* stdin ? */ - else if (fdes == 0 && isatty (fdes)) + else if (fdes == fileno (stdin) && isatty (fdes)) flags = O_RDONLY; /* stdout / stderr ? */ - else if ((fdes == 1 || fdes == 2) && isatty (fdes)) + else if ((fdes == fileno (stdout) || fdes == fileno (stderr)) && + isatty (fdes)) flags = O_WRONLY; else flags = buf.st_mode; From bb1180ef26f737d0a071a8e830e295f6c88570af Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:09:28 +0000 Subject: [PATCH 082/281] `__libc_ia64_register_backing_store_base' is meant to be a `unsigned long *'. --- libguile/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/gc.c b/libguile/gc.c index 4808625cf..de1b3ee0d 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -54,7 +54,7 @@ #ifdef __ia64__ #include -extern unsigned long __libc_ia64_register_backing_store_base; +extern unsigned long * __libc_ia64_register_backing_store_base; #endif #include "libguile/_scm.h" From c01a6af52fca315df0141fa1a7d8d7d707ded04c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:09:41 +0000 Subject: [PATCH 083/281] * __scm.h, alist.h, arbiters.h, async.h, backtrace.h, boolean.h, chars.h, continuations.h, coop-defs.h, coop-threads.h, debug-malloc.h, debug.h, deprecation.h, dynl.h, dynwind.h, environments.h, eq.h, error.h, eval.h, evalext.h, extensions.h, feature.h, filesys.h, fluids.h, fports.h, gc.h, gdb_interface.h, gdbint.h, gh.h, goops.h, gsubr.h, guardians.h, hash.h, hashtab.h, hooks.h, init.h, ioext.h, iselect.h, keywords.h, lang.h, list.h, load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h, objects.h, objprop.h, options.h, pairs.h, ports.h, posix.h, print.h, procprop.h, procs.h, properties.h, ramap.h, random.h, rdelim.h, read.h, regex-posix.h, root.h, rw.h, scmsigs.h, script.h, simpos.h, smob.h, socket.h, sort.h, srcprop.h, stackchk.h, stacks.h, stime.h, strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h, tags.h, threads.h, throw.h, unif.h, values.h, variable.h, vectors.h, vports.h, weaks.h: Prefixed each each exported symbol with SCM_API. * gdb_interface.h (GDB_INTERFACE): Also support __CYGWIN__. --- libguile/gdb_interface.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libguile/gdb_interface.h b/libguile/gdb_interface.h index ad93b463e..0274ecb8d 100644 --- a/libguile/gdb_interface.h +++ b/libguile/gdb_interface.h @@ -59,7 +59,7 @@ Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ interface in your main program. This is necessary if the interface is defined in a library, such as Guile. */ -#ifndef __MINGW32__ +#if !defined (__MINGW32__) && !defined (__CYGWIN__) #define GDB_INTERFACE \ void *gdb_interface[] = { \ &gdb_options, \ @@ -73,7 +73,7 @@ void *gdb_interface[] = { \ (void *) gdb_print, \ (void *) gdb_binding \ } -#else /* __MINGW32__ */ +#else /* __MINGW32__, __CYGWIN__ */ /* Because the following functions are imported from a DLL (some kind of shared library) these are NO static initializers. That is why you need to define them and assign the functions and data items at run time. */ @@ -103,25 +103,25 @@ void *gdb_interface[] = \ #define GDB_HAVE_BINDINGS 1 -extern unsigned short gdb_options; +SCM_API unsigned short gdb_options; /* GDB_LANGUAGE holds the name of the preferred language mode for this interpreter. For lisp interpreters, the suggested mode is "lisp/c". */ -extern char *gdb_language; +SCM_API char *gdb_language; /* GDB_RESULT is used for passing results from the interpreter to GDB */ -extern GDB_TYPE gdb_result; +SCM_API GDB_TYPE gdb_result; /* The interpreter passes strings to GDB in GDB_OUTPUT and GDB_OUTPUT_LENGTH. GDB_OUTPUT should hold the pointer to the string. GDB_OUTPUT_LENGTH should hold its length. The string doesn't need to be terminated by '\0'. */ -extern char *gdb_output; +SCM_API char *gdb_output; -extern int gdb_output_length; +SCM_API int gdb_output_length; /* Return TRUE if the interpreter regards VALUE's type as valid. A lazy implementation is allowed to pass TRUE always. FALSE should @@ -130,7 +130,7 @@ extern int gdb_output_length; In the "lisp/c" language mode, this is used to heuristically discriminate lisp values from C values during printing. */ -extern int gdb_maybe_valid_type_p (GDB_TYPE value); +SCM_API int gdb_maybe_valid_type_p (GDB_TYPE value); /* Parse expression in string STR. Store result in GDB_RESULT, then return 0 to indicate success. On error, return -1 to indicate @@ -139,7 +139,7 @@ extern int gdb_maybe_valid_type_p (GDB_TYPE value); no message is passed. Please note that the resulting value should be protected against garbage collection. */ -extern int gdb_read (char *str); +SCM_API int gdb_read (char *str); /* Evaluate expression EXP. Store result in GDB_RESULT, then return 0 to indicate success. On error, return -1 to indicate failure. Any @@ -148,7 +148,7 @@ extern int gdb_read (char *str); if no output is passed. Please note that the resulting lisp object should be protected against garbage collection. */ -extern int gdb_eval (GDB_TYPE exp); +SCM_API int gdb_eval (GDB_TYPE exp); /* Print VALUE. Store output in GDB_OUTPUT and GDB_OUTPUT_LENGTH. Return 0 to indicate success. On error, return -1 to indicate @@ -156,7 +156,7 @@ extern int gdb_eval (GDB_TYPE exp); failure. Note that this function should be robust against strange values. It could in fact be passed any kind of value. */ -extern int gdb_print (GDB_TYPE value); +SCM_API int gdb_print (GDB_TYPE value); /* Bind NAME to VALUE in interpreter. (GDB has previously obtained NAME by passing a string to gdb_read.) Return 0 to indicate @@ -168,7 +168,7 @@ extern int gdb_print (GDB_TYPE value); For scheme interpreters, this function should introduce top-level bindings. */ -extern int gdb_binding (GDB_TYPE name, GDB_TYPE value); +SCM_API int gdb_binding (GDB_TYPE name, GDB_TYPE value); #endif /* GDB_INTERFACE_H */ From ec65f5dadc484dc65f513db0dd7b4e00e9c0142b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:15:41 +0000 Subject: [PATCH 084/281] * fports.c: Include `io.h' is possible. Put `*fp' into referring statement block in `scm_fport_buffer_add()'. Some corrections in `getflags()'. * ioext.c, ports.c: Include `io.h' is possible. --- libguile/ioext.c | 3 +++ libguile/ports.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/libguile/ioext.c b/libguile/ioext.c index dddd38dda..6d57cd3ee 100644 --- a/libguile/ioext.c +++ b/libguile/ioext.c @@ -55,6 +55,9 @@ #include +#ifdef HAVE_IO_H +#include +#endif #ifdef HAVE_UNISTD_H #include #endif diff --git a/libguile/ports.c b/libguile/ports.c index 9e1acad54..7a02b1308 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -67,6 +67,10 @@ #include #endif +#ifdef HAVE_IO_H +#include +#endif + #ifdef HAVE_UNISTD_H #include #endif From d7db9f60c29f9dac209b678265b4096d2a39db45 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:15:53 +0000 Subject: [PATCH 085/281] Make sure to define __SCM_IMPORT__ for shared library build on Win32. Disable preloaded symbols on Win2 platforms. --- libguile/guile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libguile/guile.c b/libguile/guile.c index d25a70d07..18df2af30 100644 --- a/libguile/guile.c +++ b/libguile/guile.c @@ -46,6 +46,9 @@ based on the list of installed, statically linked libraries on the system. For now, please don't put interesting code in here. */ +#ifdef __MINGW32__ +# define __SCM_IMPORT__ 1 +#endif #include #ifdef HAVE_CONFIG_H @@ -85,7 +88,7 @@ inner_main (void *closure SCM_UNUSED, int argc, char **argv) int main (int argc, char **argv) { -#ifdef DYNAMIC_LINKING +#if defined (DYNAMIC_LINKING) && !defined (__MINGW32__) LTDL_SET_PRELOADED_SYMBOLS (); #endif scm_boot_guile (argc, argv, inner_main, 0); From 5507e7260b4809c3f631e8f4b568158735fc5612 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:16:19 +0000 Subject: [PATCH 086/281] Include `process.h' is possible. --- libguile/mkstemp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libguile/mkstemp.c b/libguile/mkstemp.c index ce7c376c2..795132ce7 100644 --- a/libguile/mkstemp.c +++ b/libguile/mkstemp.c @@ -34,6 +34,9 @@ #ifdef HAVE_SYS_TIME_H #include #endif +#ifdef __MINGW32__ +#include +#endif /* We need to provide a type for gcc_uint64_t. */ #ifdef __GNUC__ From e2c801663cfa97dc7686d525685a4152f36e10fd Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:16:28 +0000 Subject: [PATCH 087/281] Disable extern declaration of `h_errno' for __CYGWIN__, too. Put `scm_return_entry()' into HAVE_GETSERVENT conditional. --- libguile/net_db.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libguile/net_db.c b/libguile/net_db.c index 91d0d8347..8afd9244c 100644 --- a/libguile/net_db.c +++ b/libguile/net_db.c @@ -74,7 +74,7 @@ #include #endif -#if !defined (HAVE_H_ERRNO) && !defined (__MINGW32__) +#if !defined (HAVE_H_ERRNO) && !defined (__MINGW32__) && !defined (__CYGWIN__) /* h_errno not found in netdb.h, maybe this will help. */ extern int h_errno; #endif @@ -314,6 +314,7 @@ SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0, #undef FUNC_NAME #endif +#ifdef HAVE_GETSERVENT static SCM scm_return_entry (struct servent *entry) { @@ -329,7 +330,6 @@ scm_return_entry (struct servent *entry) return ans; } -#ifdef HAVE_GETSERVENT SCM_DEFINE (scm_getserv, "getserv", 0, 2, 0, (SCM name, SCM protocol), "@deffnx procedure getservbyname name protocol\n" From 4f68365d03031ea959e47c03b4fdd60ab33709e7 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:16:46 +0000 Subject: [PATCH 088/281] Remove unnecessary dirent includes and defines. Include local `win32-uname.h' for MinGW. Extern declaration of `mkstemp()' for systems where it does not exists. Make `getlogin()' available on M$-Windows. --- libguile/posix.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/libguile/posix.c b/libguile/posix.c index 54998f091..70b30f6fd 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -126,23 +126,6 @@ extern char ** environ; #include #endif -#if HAVE_DIRENT_H -# include -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -# define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen -# if HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -#endif - #ifdef HAVE_SETLOCALE #include #endif @@ -994,7 +977,11 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_FORK */ -#ifdef HAVE_UNAME +#ifdef __MINGW32__ +# include "win32-uname.h" +#endif + +#if defined (HAVE_UNAME) || defined (__MINGW32__) SCM_DEFINE (scm_uname, "uname", 0, 0, 0, (), "Return an object with some information about the computer\n" @@ -1082,6 +1069,10 @@ SCM_DEFINE (scm_tmpnam, "tmpnam", 0, 0, 0, #endif +#ifndef HAVE_MKSTEMP +extern int mkstemp (char *); +#endif + SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0, (SCM tmpl), "Create a new unique file in the file system and returns a new\n" @@ -1385,7 +1376,7 @@ static char * getlogin (void) #endif /* __MINGW32__ */ -#if HAVE_GETLOGIN +#if defined (HAVE_GETLOGIN) || defined (__MINGW32__) SCM_DEFINE (scm_getlogin, "getlogin", 0, 0, 0, (void), "Return a string containing the name of the user logged in on\n" From ed618cc9c1f0018889323f9fc7d5e3e7a7b6cd1c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:16:57 +0000 Subject: [PATCH 089/281] Made `usleep()' avalable on MinGW. --- libguile/scmsigs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 93f806a33..55439f2e5 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -81,6 +81,7 @@ int usleep (); #define alarm(sec) (0) /* This weird comma expression is because Sleep is void under Windows. */ #define sleep(sec) (Sleep ((sec) * 1000), 0) +#define usleep(usec) (Sleep ((usec) / 1000), 0) #define kill(pid, sig) raise (sig) #endif @@ -534,7 +535,7 @@ SCM_DEFINE (scm_sleep, "sleep", 1, 0, 0, } #undef FUNC_NAME -#if defined(USE_THREADS) || defined(HAVE_USLEEP) +#if defined(USE_THREADS) || defined(HAVE_USLEEP) || defined(__MINGW32__) SCM_DEFINE (scm_usleep, "usleep", 1, 0, 0, (SCM i), "Sleep for I microseconds. @code{usleep} is not available on\n" @@ -562,7 +563,7 @@ SCM_DEFINE (scm_usleep, "usleep", 1, 0, 0, #endif } #undef FUNC_NAME -#endif /* GUILE_ISELECT || HAVE_USLEEP */ +#endif /* USE_THREADS || HAVE_USLEEP || __MINGW32__ */ SCM_DEFINE (scm_raise, "raise", 1, 0, 0, (SCM sig), From 79dcdf5188b5da6772f96262656b7c2c714732b7 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:17:10 +0000 Subject: [PATCH 090/281] On M$-Windows `tzname[]' is known to be `_tzname[]'. --- libguile/stime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libguile/stime.c b/libguile/stime.c index 4d310071f..a8ba26b8b 100644 --- a/libguile/stime.c +++ b/libguile/stime.c @@ -90,6 +90,9 @@ #ifndef tzname /* For SGI. */ extern char *tzname[]; /* RS6000 and others reject char **tzname. */ #endif +#if defined (__MINGW32__) +# define tzname _tzname +#endif #ifdef MISSING_STRPTIME_DECL extern char *strptime (); From 21e11a3b150b598010e2a8483c8d19ea2461112e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:18:22 +0000 Subject: [PATCH 091/281] * win32-dirent.c: Include "win32-dirent.h", not "dirent.h". --- libguile/win32-dirent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/win32-dirent.c b/libguile/win32-dirent.c index 00954f9d5..2f9458f2a 100644 --- a/libguile/win32-dirent.c +++ b/libguile/win32-dirent.c @@ -45,7 +45,7 @@ #include #include -#include "dirent.h" +#include "win32-dirent.h" DIR * opendir (const char * name) From 1dcb9876f51c1c87ee94690544e7b68b0c7893be Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:18:32 +0000 Subject: [PATCH 092/281] * win32-uname.c: Include "win32-uname.h", not "uname.h". --- libguile/win32-uname.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/win32-uname.c b/libguile/win32-uname.c index 1abbc8e94..0f26968bb 100644 --- a/libguile/win32-uname.c +++ b/libguile/win32-uname.c @@ -45,7 +45,7 @@ #include #include -#include "uname.h" +#include "win32-uname.h" /* * Get name and information about current kernel. From 33b001fd89d070cc6e2d8a0d6d6c43fe90555972 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:19:12 +0000 Subject: [PATCH 093/281] Prefixed each each exported symbol with SCM_API. --- libguile/chars.h | 56 ++++----- libguile/coop-defs.h | 54 ++++---- libguile/coop-threads.h | 28 ++--- libguile/debug-malloc.h | 12 +- libguile/debug.h | 66 +++++----- libguile/deprecation.h | 8 +- libguile/dynl.h | 14 +-- libguile/dynwind.h | 20 +-- libguile/environments.h | 92 +++++++------- libguile/eq.h | 8 +- libguile/error.h | 58 ++++----- libguile/eval.h | 214 ++++++++++++++++---------------- libguile/evalext.h | 8 +- libguile/extensions.h | 10 +- libguile/feature.h | 8 +- libguile/filesys.h | 62 +++++----- libguile/fluids.h | 30 ++--- libguile/fports.h | 16 +-- libguile/gc.h | 150 +++++++++++----------- libguile/gdbint.h | 4 +- libguile/gh.h | 228 +++++++++++++++++----------------- libguile/goops.h | 204 ++++++++++++++++-------------- libguile/gsubr.h | 26 ++-- libguile/guardians.h | 14 +-- libguile/hash.h | 18 +-- libguile/hashtab.h | 58 ++++----- libguile/hooks.h | 44 +++---- libguile/init.h | 16 +-- libguile/ioext.h | 20 +-- libguile/iselect.h | 16 +-- libguile/keywords.h | 12 +- libguile/lang.h | 18 +-- libguile/list.h | 74 +++++------ libguile/load.h | 26 ++-- libguile/macros.h | 24 ++-- libguile/mallocs.h | 6 +- libguile/modules.h | 78 ++++++------ libguile/net_db.h | 18 +-- libguile/num2integral.i.c | 8 +- libguile/numbers.c | 2 - libguile/numbers.h | 254 +++++++++++++++++++------------------- libguile/objects.h | 73 ++++++----- libguile/objprop.h | 10 +- libguile/options.h | 6 +- libguile/pairs.h | 14 +-- libguile/ports.h | 188 ++++++++++++++-------------- libguile/posix.h | 112 ++++++++--------- libguile/print.h | 46 +++---- libguile/procprop.h | 18 +-- libguile/procs.h | 48 +++---- libguile/properties.h | 10 +- libguile/ramap.h | 44 +++---- libguile/random.h | 48 +++---- libguile/rdelim.h | 12 +- libguile/read.h | 24 ++-- libguile/regex-posix.h | 10 +- libguile/root.h | 26 ++-- libguile/rw.h | 10 +- libguile/scmsigs.h | 24 ++-- libguile/script.h | 24 ++-- libguile/simpos.h | 8 +- libguile/smob.h | 40 +++--- libguile/socket.h | 56 ++++----- libguile/sort.h | 28 ++--- libguile/srcprop.h | 28 ++--- libguile/stackchk.h | 10 +- libguile/stacks.h | 38 +++--- libguile/stime.h | 26 ++-- libguile/strings.h | 34 ++--- libguile/strop.h | 36 +++--- libguile/strorder.h | 22 ++-- libguile/strports.h | 26 ++-- libguile/struct.h | 46 +++---- libguile/symbols.h | 28 ++--- libguile/tags.h | 2 +- libguile/threads.h | 48 +++---- libguile/throw.h | 54 ++++---- libguile/unif.h | 74 +++++------ libguile/values.h | 6 +- libguile/variable.h | 16 +-- libguile/vectors.h | 30 ++--- libguile/vports.h | 4 +- libguile/weaks.h | 24 ++-- 83 files changed, 1769 insertions(+), 1744 deletions(-) diff --git a/libguile/chars.h b/libguile/chars.h index 221a4039b..6fa459055 100644 --- a/libguile/chars.h +++ b/libguile/chars.h @@ -57,37 +57,37 @@ -extern char *const scm_charnames[]; -extern int scm_n_charnames; -extern const char scm_charnums[]; +SCM_API char *const scm_charnames[]; +SCM_API int scm_n_charnames; +SCM_API const char scm_charnums[]; -extern SCM scm_char_p (SCM x); -extern SCM scm_char_eq_p (SCM x, SCM y); -extern SCM scm_char_less_p (SCM x, SCM y); -extern SCM scm_char_leq_p (SCM x, SCM y); -extern SCM scm_char_gr_p (SCM x, SCM y); -extern SCM scm_char_geq_p (SCM x, SCM y); -extern SCM scm_char_ci_eq_p (SCM x, SCM y); -extern SCM scm_char_ci_less_p (SCM x, SCM y); -extern SCM scm_char_ci_leq_p (SCM x, SCM y); -extern SCM scm_char_ci_gr_p (SCM x, SCM y); -extern SCM scm_char_ci_geq_p (SCM x, SCM y); -extern SCM scm_char_alphabetic_p (SCM chr); -extern SCM scm_char_numeric_p (SCM chr); -extern SCM scm_char_whitespace_p (SCM chr); -extern SCM scm_char_upper_case_p (SCM chr); -extern SCM scm_char_lower_case_p (SCM chr); -extern SCM scm_char_is_both_p (SCM chr); -extern SCM scm_char_to_integer (SCM chr); -extern SCM scm_integer_to_char (SCM n); -extern SCM scm_char_upcase (SCM chr); -extern SCM scm_char_downcase (SCM chr); -extern void scm_tables_prehistory (void); -extern int scm_upcase (unsigned int c); -extern int scm_downcase (unsigned int c); -extern void scm_init_chars (void); +SCM_API SCM scm_char_p (SCM x); +SCM_API SCM scm_char_eq_p (SCM x, SCM y); +SCM_API SCM scm_char_less_p (SCM x, SCM y); +SCM_API SCM scm_char_leq_p (SCM x, SCM y); +SCM_API SCM scm_char_gr_p (SCM x, SCM y); +SCM_API SCM scm_char_geq_p (SCM x, SCM y); +SCM_API SCM scm_char_ci_eq_p (SCM x, SCM y); +SCM_API SCM scm_char_ci_less_p (SCM x, SCM y); +SCM_API SCM scm_char_ci_leq_p (SCM x, SCM y); +SCM_API SCM scm_char_ci_gr_p (SCM x, SCM y); +SCM_API SCM scm_char_ci_geq_p (SCM x, SCM y); +SCM_API SCM scm_char_alphabetic_p (SCM chr); +SCM_API SCM scm_char_numeric_p (SCM chr); +SCM_API SCM scm_char_whitespace_p (SCM chr); +SCM_API SCM scm_char_upper_case_p (SCM chr); +SCM_API SCM scm_char_lower_case_p (SCM chr); +SCM_API SCM scm_char_is_both_p (SCM chr); +SCM_API SCM scm_char_to_integer (SCM chr); +SCM_API SCM scm_integer_to_char (SCM n); +SCM_API SCM scm_char_upcase (SCM chr); +SCM_API SCM scm_char_downcase (SCM chr); +SCM_API void scm_tables_prehistory (void); +SCM_API int scm_upcase (unsigned int c); +SCM_API int scm_downcase (unsigned int c); +SCM_API void scm_init_chars (void); #endif /* SCM_CHARS_H */ diff --git a/libguile/coop-defs.h b/libguile/coop-defs.h index 302230ebe..b9c5b4f9c 100644 --- a/libguile/coop-defs.h +++ b/libguile/coop-defs.h @@ -143,12 +143,12 @@ typedef int coop_mattr; typedef coop_m scm_t_mutex; -extern int coop_mutex_init (coop_m*); -extern int coop_new_mutex_init (coop_m*, coop_mattr*); -extern int coop_mutex_lock (coop_m*); -extern int coop_mutex_trylock (coop_m*); -extern int coop_mutex_unlock (coop_m*); -extern int coop_mutex_destroy (coop_m*); +SCM_API int coop_mutex_init (coop_m*); +SCM_API int coop_new_mutex_init (coop_m*, coop_mattr*); +SCM_API int coop_mutex_lock (coop_m*); +SCM_API int coop_mutex_trylock (coop_m*); +SCM_API int coop_mutex_unlock (coop_m*); +SCM_API int coop_mutex_destroy (coop_m*); #define scm_mutex_init coop_mutex_init #define scm_mutex_lock coop_mutex_lock #define scm_mutex_trylock coop_mutex_lock @@ -176,14 +176,14 @@ struct timespec }; #endif -extern int coop_condition_variable_init (coop_c*); -extern int coop_new_condition_variable_init (coop_c*, coop_cattr*); -extern int coop_condition_variable_wait_mutex (coop_c*, coop_m*); -extern int coop_condition_variable_timed_wait_mutex (coop_c*, - coop_m*, - const struct timespec *abstime); -extern int coop_condition_variable_signal (coop_c*); -extern int coop_condition_variable_destroy (coop_c*); +SCM_API int coop_condition_variable_init (coop_c*); +SCM_API int coop_new_condition_variable_init (coop_c*, coop_cattr*); +SCM_API int coop_condition_variable_wait_mutex (coop_c*, coop_m*); +SCM_API int coop_condition_variable_timed_wait_mutex (coop_c*, + coop_m*, + const struct timespec *abstime); +SCM_API int coop_condition_variable_signal (coop_c*); +SCM_API int coop_condition_variable_destroy (coop_c*); #define scm_cond_init coop_new_condition_variable_init #define scm_cond_wait coop_condition_variable_wait_mutex #define scm_cond_timedwait coop_condition_variable_timed_wait_mutex @@ -195,22 +195,22 @@ typedef int coop_k; typedef coop_k scm_t_key; -extern int coop_key_create (coop_k *keyp, void (*destruktor) (void *value)); -extern int coop_setspecific (coop_k key, const void *value); -extern void *coop_getspecific (coop_k key); -extern int coop_key_delete (coop_k); +SCM_API int coop_key_create (coop_k *keyp, void (*destruktor) (void *value)); +SCM_API int coop_setspecific (coop_k key, const void *value); +SCM_API void *coop_getspecific (coop_k key); +SCM_API int coop_key_delete (coop_k); #define scm_key_create coop_key_create #define scm_setspecific coop_setspecific #define scm_getspecific coop_getspecific #define scm_key_delete coop_key_delete -extern coop_t *coop_global_curr; /* Currently-executing thread. */ +SCM_API coop_t *coop_global_curr; /* Currently-executing thread. */ -extern void coop_join (coop_t *t); -extern void coop_yield (void); +SCM_API void coop_join (coop_t *t); +SCM_API void coop_yield (void); -extern size_t scm_switch_counter; -extern size_t scm_thread_count; +SCM_API size_t scm_switch_counter; +SCM_API size_t scm_thread_count; /* Some iselect functions. */ @@ -222,11 +222,11 @@ extern size_t scm_thread_count; (and failing) attempt at modularity here, and I don't have time to rethink this at the moment. This code awaits a Hero. --JimB */ #ifdef GUILE_ISELECT -void coop_timeout_qinsert (coop_q_t *, coop_t *); +SCM_API void coop_timeout_qinsert (coop_q_t *, coop_t *); #endif -extern coop_t *coop_next_runnable_thread (void); -extern coop_t *coop_wait_for_runnable_thread_now (struct timeval *); -extern coop_t *coop_wait_for_runnable_thread (void); +SCM_API coop_t *coop_next_runnable_thread (void); +SCM_API coop_t *coop_wait_for_runnable_thread_now (struct timeval *); +SCM_API coop_t *coop_wait_for_runnable_thread (void); diff --git a/libguile/coop-threads.h b/libguile/coop-threads.h index ffc1ef120..98afebef9 100644 --- a/libguile/coop-threads.h +++ b/libguile/coop-threads.h @@ -81,46 +81,46 @@ typedef void (coop_userf_t)(void *p0); /* Call this before any other primitives. */ -extern void coop_init (void); +SCM_API void coop_init (void); /* When one or more threads are created by the main thread, the system goes multithread when this is called. It is done (no more runable threads) when this returns. */ -extern void coop_start (void); +SCM_API void coop_start (void); /* Create a thread and make it runable. When the thread starts running it will call `f' with arguments `p0' and `p1'. */ -extern coop_t *coop_create (coop_userf_t *f, void *p0); +SCM_API coop_t *coop_create (coop_userf_t *f, void *p0); /* The current thread stops running but stays runable. It is an error to call `coop_yield' before `coop_start' is called or after `coop_start' returns. */ -extern void coop_yield (void); +SCM_API void coop_yield (void); /* Like `coop_yield' but the thread is discarded. Any intermediate state is lost. The thread can also terminate by simply returning. */ -extern void coop_abort (void); +SCM_API void coop_abort (void); /* The following are needed in iselect.c */ -extern coop_t *coop_qget (coop_q_t *); -extern void coop_qput (coop_q_t *, coop_t *); -extern void *coop_sleephelp (qt_t *, void *, void *); +SCM_API coop_t *coop_qget (coop_q_t *); +SCM_API void coop_qput (coop_q_t *, coop_t *); +SCM_API void *coop_sleephelp (qt_t *, void *, void *); #ifdef GUILE_ISELECT -extern coop_t *coop_wait_for_runnable_thread (); +SCM_API coop_t *coop_wait_for_runnable_thread (); #endif -extern coop_q_t coop_global_runq; /* A queue of runable threads. */ -extern coop_q_t coop_global_sleepq; -extern coop_q_t coop_tmp_queue; -extern coop_q_t coop_global_allq; /* A queue of all threads. */ -extern coop_t *coop_global_curr; /* Currently-executing thread. */ +SCM_API coop_q_t coop_global_runq; /* A queue of runable threads. */ +SCM_API coop_q_t coop_global_sleepq; +SCM_API coop_q_t coop_tmp_queue; +SCM_API coop_q_t coop_global_allq; /* A queue of all threads. */ +SCM_API coop_t *coop_global_curr; /* Currently-executing thread. */ #endif /* SCM_COOP_THREADS_H */ diff --git a/libguile/debug-malloc.h b/libguile/debug-malloc.h index 1d646fcb9..f337b1193 100644 --- a/libguile/debug-malloc.h +++ b/libguile/debug-malloc.h @@ -50,14 +50,14 @@ -extern void scm_malloc_register (void *obj, const char *what); -extern void scm_malloc_unregister (void *obj); -extern void scm_malloc_reregister (void *obj, void *new, const char *what); +SCM_API void scm_malloc_register (void *obj, const char *what); +SCM_API void scm_malloc_unregister (void *obj); +SCM_API void scm_malloc_reregister (void *obj, void *new, const char *what); -extern SCM scm_malloc_stats (void); +SCM_API SCM scm_malloc_stats (void); -extern void scm_debug_malloc_prehistory (void); -extern void scm_init_debug_malloc (void); +SCM_API void scm_debug_malloc_prehistory (void); +SCM_API void scm_init_debug_malloc (void); #endif /* SCM_DEBUG_MALLOC_H */ diff --git a/libguile/debug.h b/libguile/debug.h index baa209fbd..f7059266f 100644 --- a/libguile/debug.h +++ b/libguile/debug.h @@ -68,7 +68,7 @@ /* scm_debug_opts is defined in eval.c. */ -extern scm_t_option scm_debug_opts[]; +SCM_API scm_t_option scm_debug_opts[]; #define SCM_CHEAPTRAPS_P scm_debug_opts[0].val #define SCM_BREAKPOINTS_P scm_debug_opts[1].val @@ -86,10 +86,12 @@ extern scm_t_option scm_debug_opts[]; #define SCM_SHOW_FILE_NAME scm_debug_opts[13].val #define SCM_N_DEBUG_OPTIONS 14 -extern SCM (*scm_ceval_ptr) (SCM exp, SCM env); +SCM_API SCM (*scm_ceval_ptr) (SCM exp, SCM env); -extern int scm_debug_mode; -extern int scm_check_entry_p, scm_check_apply_p, scm_check_exit_p; +SCM_API int scm_debug_mode; +SCM_API int scm_check_entry_p; +SCM_API int scm_check_apply_p; +SCM_API int scm_check_exit_p; #define CHECK_ENTRY scm_check_entry_p #define CHECK_APPLY scm_check_apply_p @@ -117,7 +119,7 @@ typedef union scm_t_debug_info SCM id; } scm_t_debug_info; -extern long scm_debug_eframe_size; +SCM_API long scm_debug_eframe_size; typedef struct scm_t_debug_frame { @@ -128,7 +130,7 @@ typedef struct scm_t_debug_frame } scm_t_debug_frame; #ifndef USE_THREADS -extern scm_t_debug_frame *scm_last_debug_frame; +SCM_API scm_t_debug_frame *scm_last_debug_frame; #endif #define SCM_EVALFRAME (0L << 11) @@ -165,7 +167,7 @@ extern scm_t_debug_frame *scm_last_debug_frame; /* {Debug Objects} */ -extern scm_t_bits scm_tc16_debugobj; +SCM_API scm_t_bits scm_tc16_debugobj; #define SCM_DEBUGOBJP(x) \ SCM_TYP16_PREDICATE (scm_tc16_debugobj, x) @@ -176,7 +178,7 @@ extern scm_t_bits scm_tc16_debugobj; /* {Memoized Source} */ -extern scm_t_bits scm_tc16_memoized; +SCM_API scm_t_bits scm_tc16_memoized; #define SCM_MEMOIZEDP(x) SCM_TYP16_PREDICATE (scm_tc16_memoized, x) #define SCM_MEMOIZED_EXP(x) SCM_CAR (SCM_CELL_OBJECT_1 (x)) @@ -184,32 +186,32 @@ extern scm_t_bits scm_tc16_memoized; -extern int scm_ready_p (void); -extern void debug_print (SCM obj); -extern SCM scm_debug_object_p (SCM obj); -extern SCM scm_local_eval (SCM exp, SCM env); -extern SCM scm_reverse_lookup (SCM env, SCM data); -extern SCM scm_start_stack (SCM id, SCM exp, SCM env); -extern SCM scm_procedure_environment (SCM proc); -extern SCM scm_procedure_source (SCM proc); -extern SCM scm_procedure_name (SCM proc); -extern SCM scm_memoized_environment (SCM m); -extern SCM scm_make_memoized (SCM exp, SCM env); -extern SCM scm_memoized_p (SCM obj); -extern SCM scm_with_traps (SCM thunk); -extern SCM scm_evaluator_traps (SCM setting); -extern SCM scm_debug_options (SCM setting); -extern SCM scm_unmemoize (SCM memoized); -extern SCM scm_make_debugobj (scm_t_debug_frame *debug); -extern void scm_init_debug (void); +SCM_API int scm_ready_p (void); +SCM_API void debug_print (SCM obj); +SCM_API SCM scm_debug_object_p (SCM obj); +SCM_API SCM scm_local_eval (SCM exp, SCM env); +SCM_API SCM scm_reverse_lookup (SCM env, SCM data); +SCM_API SCM scm_start_stack (SCM id, SCM exp, SCM env); +SCM_API SCM scm_procedure_environment (SCM proc); +SCM_API SCM scm_procedure_source (SCM proc); +SCM_API SCM scm_procedure_name (SCM proc); +SCM_API SCM scm_memoized_environment (SCM m); +SCM_API SCM scm_make_memoized (SCM exp, SCM env); +SCM_API SCM scm_memoized_p (SCM obj); +SCM_API SCM scm_with_traps (SCM thunk); +SCM_API SCM scm_evaluator_traps (SCM setting); +SCM_API SCM scm_debug_options (SCM setting); +SCM_API SCM scm_unmemoize (SCM memoized); +SCM_API SCM scm_make_debugobj (scm_t_debug_frame *debug); +SCM_API void scm_init_debug (void); #ifdef GUILE_DEBUG -extern SCM scm_make_iloc (SCM frame, SCM binding, SCM cdrp); -extern SCM scm_iloc_p (SCM obj); -extern SCM scm_memcons (SCM car, SCM cdr, SCM env); -extern SCM scm_mem_to_proc (SCM obj); -extern SCM scm_proc_to_mem (SCM obj); -extern SCM scm_debug_hang (SCM obj); +SCM_API SCM scm_make_iloc (SCM frame, SCM binding, SCM cdrp); +SCM_API SCM scm_iloc_p (SCM obj); +SCM_API SCM scm_memcons (SCM car, SCM cdr, SCM env); +SCM_API SCM scm_mem_to_proc (SCM obj); +SCM_API SCM scm_proc_to_mem (SCM obj); +SCM_API SCM scm_debug_hang (SCM obj); #endif /*GUILE_DEBUG*/ #endif /* SCM_DEBUG_H */ diff --git a/libguile/deprecation.h b/libguile/deprecation.h index 726c64a05..22f666da3 100644 --- a/libguile/deprecation.h +++ b/libguile/deprecation.h @@ -52,13 +52,13 @@ #if (SCM_ENABLE_DEPRECATED == 1) -void scm_c_issue_deprecation_warning (const char *msg); -SCM scm_issue_deprecation_warning (SCM msgs); +SCM_API void scm_c_issue_deprecation_warning (const char *msg); +SCM_API SCM scm_issue_deprecation_warning (SCM msgs); #endif -SCM scm_include_deprecated_features (void); -void scm_init_deprecation (void); +SCM_API SCM scm_include_deprecated_features (void); +SCM_API void scm_init_deprecation (void); #endif /* SCM_DEPRECATION_H */ diff --git a/libguile/dynl.h b/libguile/dynl.h index 9910499d5..aacf4ef1f 100644 --- a/libguile/dynl.h +++ b/libguile/dynl.h @@ -50,14 +50,14 @@ -SCM scm_dynamic_link (SCM fname); -SCM scm_dynamic_unlink (SCM dobj); -SCM scm_dynamic_object_p (SCM obj); -SCM scm_dynamic_func (SCM symb, SCM dobj); -SCM scm_dynamic_call (SCM symb, SCM dobj); -SCM scm_dynamic_args_call (SCM symb, SCM dobj, SCM args); +SCM_API SCM scm_dynamic_link (SCM fname); +SCM_API SCM scm_dynamic_unlink (SCM dobj); +SCM_API SCM scm_dynamic_object_p (SCM obj); +SCM_API SCM scm_dynamic_func (SCM symb, SCM dobj); +SCM_API SCM scm_dynamic_call (SCM symb, SCM dobj); +SCM_API SCM scm_dynamic_args_call (SCM symb, SCM dobj, SCM args); -void scm_init_dynamic_linking (void); +SCM_API void scm_init_dynamic_linking (void); #endif /* SCM_DYNL_H */ diff --git a/libguile/dynwind.h b/libguile/dynwind.h index d7ac926f3..eae2d84a0 100644 --- a/libguile/dynwind.h +++ b/libguile/dynwind.h @@ -53,19 +53,19 @@ typedef void (*scm_t_guard) (void *); typedef SCM (*scm_t_inner) (void *); -extern SCM scm_dynamic_wind (SCM thunk1, SCM thunk2, SCM thunk3); -extern SCM scm_internal_dynamic_wind (scm_t_guard before, - scm_t_inner inner, - scm_t_guard after, - void *inner_data, - void *guard_data); -extern void scm_dowinds (SCM to, long delta); -extern void scm_init_dynwind (void); +SCM_API SCM scm_dynamic_wind (SCM thunk1, SCM thunk2, SCM thunk3); +SCM_API SCM scm_internal_dynamic_wind (scm_t_guard before, + scm_t_inner inner, + scm_t_guard after, + void *inner_data, + void *guard_data); +SCM_API void scm_dowinds (SCM to, long delta); +SCM_API void scm_init_dynwind (void); -extern void scm_swap_bindings (SCM vars, SCM vals); +SCM_API void scm_swap_bindings (SCM vars, SCM vals); #ifdef GUILE_DEBUG -extern SCM scm_wind_chain (void); +SCM_API SCM scm_wind_chain (void); #endif /*GUILE_DEBUG*/ #endif /* SCM_DYNWIND_H */ diff --git a/libguile/environments.h b/libguile/environments.h index 77f866d2f..5488adba6 100644 --- a/libguile/environments.h +++ b/libguile/environments.h @@ -87,7 +87,7 @@ struct scm_environment_funcs { #define SCM_ENVIRONMENT_LOCATION_IMMUTABLE SCM_MAKINUM (1) #define SCM_ENVIRONMENT_LOCATION_NO_CELL SCM_BOOL_F -extern scm_t_bits scm_tc16_environment; +SCM_API scm_t_bits scm_tc16_environment; #define SCM_ENVIRONMENT_P(x) \ (!SCM_IMP (x) && SCM_CELL_TYPE (x) == scm_tc16_environment) @@ -112,7 +112,7 @@ extern scm_t_bits scm_tc16_environment; #define SCM_ENVIRONMENT_UNOBSERVE(env, token) \ ((*(SCM_ENVIRONMENT_FUNCS (env)->unobserve)) (env, token)) -extern scm_t_bits scm_tc16_observer; +SCM_API scm_t_bits scm_tc16_observer; #define SCM_OBSERVER_P(x) \ (!SCM_IMP (x) && (SCM_CELL_TYPE (x) == scm_tc16_observer)) @@ -123,85 +123,85 @@ extern scm_t_bits scm_tc16_observer; #define SCM_OBSERVER_PROC(x) \ ((scm_environment_observer) SCM_CELL_WORD_3 (x)) -extern SCM scm_system_environment; +SCM_API SCM scm_system_environment; -extern void scm_error_environment_unbound (const char *, SCM, SCM) SCM_NORETURN; -extern void scm_error_environment_immutable_binding (const char *, SCM, SCM) SCM_NORETURN; -extern void scm_error_environment_immutable_location (const char *, SCM, SCM) SCM_NORETURN; +SCM_API void scm_error_environment_unbound (const char *, SCM, SCM) SCM_NORETURN; +SCM_API void scm_error_environment_immutable_binding (const char *, SCM, SCM) SCM_NORETURN; +SCM_API void scm_error_environment_immutable_location (const char *, SCM, SCM) SCM_NORETURN; -extern SCM scm_make_environment (void *type); -extern SCM scm_environment_p (SCM env); -extern SCM scm_environment_bound_p (SCM env, SCM sym); -extern SCM scm_environment_ref (SCM env, SCM sym); -extern SCM scm_c_environment_ref (SCM env, SCM sym); -extern SCM scm_environment_fold (SCM env, SCM proc, SCM init); -extern SCM scm_c_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init); -extern SCM scm_environment_define (SCM env, SCM sym, SCM val); -extern SCM scm_environment_undefine (SCM env, SCM sym); -extern SCM scm_environment_set_x (SCM env, SCM sym, SCM val); -extern SCM scm_environment_cell (SCM env, SCM sym, SCM for_write); -extern SCM scm_c_environment_cell (SCM env, SCM sym, int for_write); -extern SCM scm_environment_observe (SCM env, SCM proc); -extern SCM scm_environment_observe_weak (SCM env, SCM proc); -extern SCM scm_c_environment_observe (SCM env, scm_environment_observer proc, SCM data, int weak_p); -extern SCM scm_environment_unobserve (SCM token); +SCM_API SCM scm_make_environment (void *type); +SCM_API SCM scm_environment_p (SCM env); +SCM_API SCM scm_environment_bound_p (SCM env, SCM sym); +SCM_API SCM scm_environment_ref (SCM env, SCM sym); +SCM_API SCM scm_c_environment_ref (SCM env, SCM sym); +SCM_API SCM scm_environment_fold (SCM env, SCM proc, SCM init); +SCM_API SCM scm_c_environment_fold (SCM env, scm_environment_folder proc, SCM data, SCM init); +SCM_API SCM scm_environment_define (SCM env, SCM sym, SCM val); +SCM_API SCM scm_environment_undefine (SCM env, SCM sym); +SCM_API SCM scm_environment_set_x (SCM env, SCM sym, SCM val); +SCM_API SCM scm_environment_cell (SCM env, SCM sym, SCM for_write); +SCM_API SCM scm_c_environment_cell (SCM env, SCM sym, int for_write); +SCM_API SCM scm_environment_observe (SCM env, SCM proc); +SCM_API SCM scm_environment_observe_weak (SCM env, SCM proc); +SCM_API SCM scm_c_environment_observe (SCM env, scm_environment_observer proc, SCM data, int weak_p); +SCM_API SCM scm_environment_unobserve (SCM token); -extern void scm_environments_prehistory (void); -extern void scm_init_environments (void); +SCM_API void scm_environments_prehistory (void); +SCM_API void scm_init_environments (void); -extern void *scm_type_leaf_environment; +SCM_API void *scm_type_leaf_environment; #define SCM_LEAF_ENVIRONMENT_P(env) \ (SCM_ENVIRONMENT_P (env) \ && SCM_ENVIRONMENT_FUNCS (env) == scm_type_leaf_environment) -extern SCM scm_make_leaf_environment (void); -extern SCM scm_leaf_environment_p (SCM env); +SCM_API SCM scm_make_leaf_environment (void); +SCM_API SCM scm_leaf_environment_p (SCM env); -extern void *scm_type_eval_environment; +SCM_API void *scm_type_eval_environment; #define SCM_EVAL_ENVIRONMENT_P(env) \ (SCM_ENVIRONMENT_P (env) \ && SCM_ENVIRONMENT_FUNCS (env) == scm_type_eval_environment) -extern SCM scm_make_eval_environment (SCM local, SCM imported); -extern SCM scm_eval_environment_p (SCM env); -extern SCM scm_eval_environment_local (SCM env); -extern SCM scm_eval_environment_set_local_x (SCM env, SCM local); -extern SCM scm_eval_environment_imported (SCM env); -extern SCM scm_eval_environment_set_imported_x (SCM env, SCM imported); +SCM_API SCM scm_make_eval_environment (SCM local, SCM imported); +SCM_API SCM scm_eval_environment_p (SCM env); +SCM_API SCM scm_eval_environment_local (SCM env); +SCM_API SCM scm_eval_environment_set_local_x (SCM env, SCM local); +SCM_API SCM scm_eval_environment_imported (SCM env); +SCM_API SCM scm_eval_environment_set_imported_x (SCM env, SCM imported); -extern void *scm_type_import_environment; +SCM_API void *scm_type_import_environment; #define SCM_IMPORT_ENVIRONMENT_P(env) \ (SCM_ENVIRONMENT_P (env) \ && SCM_ENVIRONMENT_FUNCS (env) == scm_type_import_environment) -extern SCM scm_make_import_environment (SCM imports, SCM conflict_proc); -extern SCM scm_import_environment_p (SCM env); -extern SCM scm_import_environment_imports (SCM env); -extern SCM scm_import_environment_set_imports_x (SCM env, SCM imports); +SCM_API SCM scm_make_import_environment (SCM imports, SCM conflict_proc); +SCM_API SCM scm_import_environment_p (SCM env); +SCM_API SCM scm_import_environment_imports (SCM env); +SCM_API SCM scm_import_environment_set_imports_x (SCM env, SCM imports); -extern void *scm_type_export_environment; +SCM_API void *scm_type_export_environment; #define SCM_EXPORT_ENVIRONMENT_P(env) \ (SCM_ENVIRONMENT_P (env) \ && SCM_ENVIRONMENT_FUNCS (env) == scm_type_export_environment) -extern SCM scm_make_export_environment (SCM private, SCM signature); -extern SCM scm_export_environment_p (SCM env); -extern SCM scm_export_environment_private (SCM env); -extern SCM scm_export_environment_set_private_x (SCM env, SCM private); -extern SCM scm_export_environment_signature (SCM env); -extern SCM scm_export_environment_set_signature_x (SCM env, SCM signature); +SCM_API SCM scm_make_export_environment (SCM private, SCM signature); +SCM_API SCM scm_export_environment_p (SCM env); +SCM_API SCM scm_export_environment_private (SCM env); +SCM_API SCM scm_export_environment_set_private_x (SCM env, SCM private); +SCM_API SCM scm_export_environment_signature (SCM env); +SCM_API SCM scm_export_environment_set_signature_x (SCM env, SCM signature); #endif /* SCM_ENVIRONMENTS_H */ diff --git a/libguile/eq.h b/libguile/eq.h index 6fbfe3e1b..5cb326dda 100644 --- a/libguile/eq.h +++ b/libguile/eq.h @@ -50,10 +50,10 @@ -extern SCM scm_eq_p (SCM x, SCM y); -extern SCM scm_eqv_p (SCM x, SCM y); -extern SCM scm_equal_p (SCM x, SCM y); -extern void scm_init_eq (void); +SCM_API SCM scm_eq_p (SCM x, SCM y); +SCM_API SCM scm_eqv_p (SCM x, SCM y); +SCM_API SCM scm_equal_p (SCM x, SCM y); +SCM_API void scm_init_eq (void); #endif /* SCM_EQ_H */ diff --git a/libguile/error.h b/libguile/error.h index 0bdb10895..1f1692024 100644 --- a/libguile/error.h +++ b/libguile/error.h @@ -49,41 +49,41 @@ #include "libguile/__scm.h" -extern int scm_ints_disabled; +SCM_API int scm_ints_disabled; -extern SCM scm_system_error_key; -extern SCM scm_num_overflow_key; -extern SCM scm_out_of_range_key; -extern SCM scm_args_number_key; -extern SCM scm_arg_type_key; -extern SCM scm_memory_alloc_key; -extern SCM scm_misc_error_key; +SCM_API SCM scm_system_error_key; +SCM_API SCM scm_num_overflow_key; +SCM_API SCM scm_out_of_range_key; +SCM_API SCM scm_args_number_key; +SCM_API SCM scm_arg_type_key; +SCM_API SCM scm_memory_alloc_key; +SCM_API SCM scm_misc_error_key; -extern void scm_error (SCM key, const char *subr, const char *message, - SCM args, SCM rest) SCM_NORETURN; -extern SCM scm_error_scm (SCM key, SCM subr, SCM message, - SCM args, SCM rest) SCM_NORETURN; -extern SCM scm_strerror (SCM err); -extern void scm_syserror (const char *subr) SCM_NORETURN; -extern void scm_syserror_msg (const char *subr, const char *message, - SCM args, int eno) SCM_NORETURN; -extern void scm_num_overflow (const char *subr) SCM_NORETURN; -extern void scm_out_of_range (const char *subr, SCM bad_value) +SCM_API void scm_error (SCM key, const char *subr, const char *message, + SCM args, SCM rest) SCM_NORETURN; +SCM_API SCM scm_error_scm (SCM key, SCM subr, SCM message, + SCM args, SCM rest) SCM_NORETURN; +SCM_API SCM scm_strerror (SCM err); +SCM_API void scm_syserror (const char *subr) SCM_NORETURN; +SCM_API void scm_syserror_msg (const char *subr, const char *message, + SCM args, int eno) SCM_NORETURN; +SCM_API void scm_num_overflow (const char *subr) SCM_NORETURN; +SCM_API void scm_out_of_range (const char *subr, SCM bad_value) SCM_NORETURN; -extern void scm_out_of_range_pos (const char *subr, SCM bad_value, SCM pos) +SCM_API void scm_out_of_range_pos (const char *subr, SCM bad_value, SCM pos) SCM_NORETURN; -extern void scm_wrong_num_args (SCM proc) SCM_NORETURN; -extern void scm_error_num_args_subr (const char* subr) SCM_NORETURN; -extern void scm_wrong_type_arg (const char *subr, int pos, - SCM bad_value) SCM_NORETURN; -extern void scm_wrong_type_arg_msg (const char *subr, int pos, - SCM bad_value, const char *sz) SCM_NORETURN; -extern void scm_memory_error (const char *subr) SCM_NORETURN; -extern void scm_misc_error (const char *subr, const char *message, - SCM args) SCM_NORETURN; -extern void scm_init_error (void); +SCM_API void scm_wrong_num_args (SCM proc) SCM_NORETURN; +SCM_API void scm_error_num_args_subr (const char* subr) SCM_NORETURN; +SCM_API void scm_wrong_type_arg (const char *subr, int pos, + SCM bad_value) SCM_NORETURN; +SCM_API void scm_wrong_type_arg_msg (const char *subr, int pos, + SCM bad_value, const char *sz) SCM_NORETURN; +SCM_API void scm_memory_error (const char *subr) SCM_NORETURN; +SCM_API void scm_misc_error (const char *subr, const char *message, + SCM args) SCM_NORETURN; +SCM_API void scm_init_error (void); #endif /* SCM_ERROR_H */ diff --git a/libguile/eval.h b/libguile/eval.h index 8895b9ccb..84705668d 100644 --- a/libguile/eval.h +++ b/libguile/eval.h @@ -55,16 +55,16 @@ /* {Options} */ -extern scm_t_option scm_eval_opts[]; +SCM_API scm_t_option scm_eval_opts[]; #define SCM_EVAL_STACK scm_eval_opts[0].val #define SCM_N_EVAL_OPTIONS 1 -extern long scm_eval_stack; +SCM_API long scm_eval_stack; -extern scm_t_option scm_evaluator_trap_table[]; +SCM_API scm_t_option scm_evaluator_trap_table[]; -extern SCM scm_eval_options_interface (SCM setting); +SCM_API SCM scm_eval_options_interface (SCM setting); #define SCM_TRAPS_P scm_evaluator_trap_table[0].val #define SCM_ENTER_FRAME_P scm_evaluator_trap_table[1].val @@ -137,116 +137,116 @@ extern SCM scm_eval_options_interface (SCM setting); #define SCM_TOP_LEVEL_LOOKUP_CLOSURE (scm_current_module_lookup_closure()) -extern const char scm_s_expression[]; -extern const char scm_s_test[]; -extern const char scm_s_body[]; -extern const char scm_s_bindings[]; -extern const char scm_s_variable[]; -extern const char scm_s_clauses[]; -extern const char scm_s_formals[]; -extern const char scm_s_set_x[]; +SCM_API const char scm_s_expression[]; +SCM_API const char scm_s_test[]; +SCM_API const char scm_s_body[]; +SCM_API const char scm_s_bindings[]; +SCM_API const char scm_s_variable[]; +SCM_API const char scm_s_clauses[]; +SCM_API const char scm_s_formals[]; +SCM_API const char scm_s_set_x[]; -extern SCM scm_sym_and; -extern SCM scm_sym_begin; -extern SCM scm_sym_case; -extern SCM scm_sym_cond; -extern SCM scm_sym_define; -extern SCM scm_sym_do; -extern SCM scm_sym_if; -extern SCM scm_sym_lambda; -extern SCM scm_sym_let; -extern SCM scm_sym_letstar; -extern SCM scm_sym_letrec; -extern SCM scm_sym_quote; -extern SCM scm_sym_quasiquote; -extern SCM scm_sym_unquote; -extern SCM scm_sym_uq_splicing; +SCM_API SCM scm_sym_and; +SCM_API SCM scm_sym_begin; +SCM_API SCM scm_sym_case; +SCM_API SCM scm_sym_cond; +SCM_API SCM scm_sym_define; +SCM_API SCM scm_sym_do; +SCM_API SCM scm_sym_if; +SCM_API SCM scm_sym_lambda; +SCM_API SCM scm_sym_let; +SCM_API SCM scm_sym_letstar; +SCM_API SCM scm_sym_letrec; +SCM_API SCM scm_sym_quote; +SCM_API SCM scm_sym_quasiquote; +SCM_API SCM scm_sym_unquote; +SCM_API SCM scm_sym_uq_splicing; -extern SCM scm_sym_dot; -extern SCM scm_sym_atapply; -extern SCM scm_sym_atcall_cc; -extern SCM scm_sym_at_call_with_values; -extern SCM scm_sym_delay; -extern SCM scm_sym_arrow; -extern SCM scm_sym_else; -extern SCM scm_sym_apply; -extern SCM scm_sym_set_x; -extern SCM scm_sym_args; +SCM_API SCM scm_sym_dot; +SCM_API SCM scm_sym_atapply; +SCM_API SCM scm_sym_atcall_cc; +SCM_API SCM scm_sym_at_call_with_values; +SCM_API SCM scm_sym_delay; +SCM_API SCM scm_sym_arrow; +SCM_API SCM scm_sym_else; +SCM_API SCM scm_sym_apply; +SCM_API SCM scm_sym_set_x; +SCM_API SCM scm_sym_args; -extern SCM scm_f_apply; +SCM_API SCM scm_f_apply; -extern SCM * scm_ilookup (SCM iloc, SCM env); -extern SCM * scm_lookupcar (SCM vloc, SCM genv, int check); -extern SCM scm_unmemocar (SCM form, SCM env); -extern SCM scm_unmemocopy (SCM form, SCM env); -extern SCM scm_eval_car (SCM pair, SCM env); -extern SCM scm_eval_body (SCM code, SCM env); -extern SCM scm_eval_args (SCM i, SCM env, SCM proc); -extern SCM scm_deval_args (SCM l, SCM env, SCM proc, SCM *lloc); -extern SCM scm_m_quote (SCM xorig, SCM env); -extern SCM scm_m_begin (SCM xorig, SCM env); -extern SCM scm_m_if (SCM xorig, SCM env); -extern SCM scm_m_set_x (SCM xorig, SCM env); -extern SCM scm_m_vref (SCM xorig, SCM env); -extern SCM scm_m_vset (SCM xorig, SCM env); -extern SCM scm_m_and (SCM xorig, SCM env); -extern SCM scm_m_or (SCM xorig, SCM env); -extern SCM scm_m_case (SCM xorig, SCM env); -extern SCM scm_m_cond (SCM xorig, SCM env); -extern SCM scm_m_lambda (SCM xorig, SCM env); -extern SCM scm_m_letstar (SCM xorig, SCM env); -extern SCM scm_m_do (SCM xorig, SCM env); -extern SCM scm_m_quasiquote (SCM xorig, SCM env); -extern SCM scm_m_delay (SCM xorig, SCM env); -extern SCM scm_m_define (SCM x, SCM env); -extern SCM scm_m_letrec (SCM xorig, SCM env); -extern SCM scm_m_let (SCM xorig, SCM env); -extern SCM scm_m_apply (SCM xorig, SCM env); -extern SCM scm_m_cont (SCM xorig, SCM env); -extern SCM scm_m_nil_cond (SCM xorig, SCM env); -extern SCM scm_m_nil_ify (SCM xorig, SCM env); -extern SCM scm_m_t_ify (SCM xorig, SCM env); -extern SCM scm_m_0_cond (SCM xorig, SCM env); -extern SCM scm_m_0_ify (SCM xorig, SCM env); -extern SCM scm_m_1_ify (SCM xorig, SCM env); -extern SCM scm_m_atfop (SCM xorig, SCM env); -extern SCM scm_m_atbind (SCM xorig, SCM env); -extern SCM scm_m_at_call_with_values (SCM xorig, SCM env); -extern int scm_badargsp (SCM formals, SCM args); -extern SCM scm_ceval (SCM x, SCM env); -extern SCM scm_deval (SCM x, SCM env); -extern SCM scm_call_0 (SCM proc); -extern SCM scm_call_1 (SCM proc, SCM arg1); -extern SCM scm_call_2 (SCM proc, SCM arg1, SCM arg2); -extern SCM scm_call_3 (SCM proc, SCM arg1, SCM arg2, SCM arg3); -extern SCM scm_call_4 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4); -extern SCM scm_apply_0 (SCM proc, SCM args); -extern SCM scm_apply_1 (SCM proc, SCM arg1, SCM args); -extern SCM scm_apply_2 (SCM proc, SCM arg1, SCM arg2, SCM args); -extern SCM scm_apply_3 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM args); -extern SCM scm_nconc2last (SCM lst); -extern SCM scm_apply (SCM proc, SCM arg1, SCM args); -extern SCM scm_dapply (SCM proc, SCM arg1, SCM args); -extern SCM scm_m_expand_body (SCM xorig, SCM env); -extern SCM scm_macroexp (SCM x, SCM env); -extern SCM scm_map (SCM proc, SCM arg1, SCM args); -extern SCM scm_for_each (SCM proc, SCM arg1, SCM args); -extern SCM scm_closure (SCM code, SCM env); -extern SCM scm_makprom (SCM code); -extern SCM scm_force (SCM x); -extern SCM scm_promise_p (SCM x); -extern SCM scm_cons_source (SCM xorig, SCM x, SCM y); -extern SCM scm_copy_tree (SCM obj); -extern SCM scm_i_eval_x (SCM exp, SCM env); -extern SCM scm_i_eval (SCM exp, SCM env); -extern SCM scm_primitive_eval (SCM exp); -extern SCM scm_primitive_eval_x (SCM exp); -extern SCM scm_eval (SCM exp, SCM module); -extern SCM scm_eval_x (SCM exp, SCM module); +SCM_API SCM * scm_ilookup (SCM iloc, SCM env); +SCM_API SCM * scm_lookupcar (SCM vloc, SCM genv, int check); +SCM_API SCM scm_unmemocar (SCM form, SCM env); +SCM_API SCM scm_unmemocopy (SCM form, SCM env); +SCM_API SCM scm_eval_car (SCM pair, SCM env); +SCM_API SCM scm_eval_body (SCM code, SCM env); +SCM_API SCM scm_eval_args (SCM i, SCM env, SCM proc); +SCM_API SCM scm_deval_args (SCM l, SCM env, SCM proc, SCM *lloc); +SCM_API SCM scm_m_quote (SCM xorig, SCM env); +SCM_API SCM scm_m_begin (SCM xorig, SCM env); +SCM_API SCM scm_m_if (SCM xorig, SCM env); +SCM_API SCM scm_m_set_x (SCM xorig, SCM env); +SCM_API SCM scm_m_vref (SCM xorig, SCM env); +SCM_API SCM scm_m_vset (SCM xorig, SCM env); +SCM_API SCM scm_m_and (SCM xorig, SCM env); +SCM_API SCM scm_m_or (SCM xorig, SCM env); +SCM_API SCM scm_m_case (SCM xorig, SCM env); +SCM_API SCM scm_m_cond (SCM xorig, SCM env); +SCM_API SCM scm_m_lambda (SCM xorig, SCM env); +SCM_API SCM scm_m_letstar (SCM xorig, SCM env); +SCM_API SCM scm_m_do (SCM xorig, SCM env); +SCM_API SCM scm_m_quasiquote (SCM xorig, SCM env); +SCM_API SCM scm_m_delay (SCM xorig, SCM env); +SCM_API SCM scm_m_define (SCM x, SCM env); +SCM_API SCM scm_m_letrec (SCM xorig, SCM env); +SCM_API SCM scm_m_let (SCM xorig, SCM env); +SCM_API SCM scm_m_apply (SCM xorig, SCM env); +SCM_API SCM scm_m_cont (SCM xorig, SCM env); +SCM_API SCM scm_m_nil_cond (SCM xorig, SCM env); +SCM_API SCM scm_m_nil_ify (SCM xorig, SCM env); +SCM_API SCM scm_m_t_ify (SCM xorig, SCM env); +SCM_API SCM scm_m_0_cond (SCM xorig, SCM env); +SCM_API SCM scm_m_0_ify (SCM xorig, SCM env); +SCM_API SCM scm_m_1_ify (SCM xorig, SCM env); +SCM_API SCM scm_m_atfop (SCM xorig, SCM env); +SCM_API SCM scm_m_atbind (SCM xorig, SCM env); +SCM_API SCM scm_m_at_call_with_values (SCM xorig, SCM env); +SCM_API int scm_badargsp (SCM formals, SCM args); +SCM_API SCM scm_ceval (SCM x, SCM env); +SCM_API SCM scm_deval (SCM x, SCM env); +SCM_API SCM scm_call_0 (SCM proc); +SCM_API SCM scm_call_1 (SCM proc, SCM arg1); +SCM_API SCM scm_call_2 (SCM proc, SCM arg1, SCM arg2); +SCM_API SCM scm_call_3 (SCM proc, SCM arg1, SCM arg2, SCM arg3); +SCM_API SCM scm_call_4 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4); +SCM_API SCM scm_apply_0 (SCM proc, SCM args); +SCM_API SCM scm_apply_1 (SCM proc, SCM arg1, SCM args); +SCM_API SCM scm_apply_2 (SCM proc, SCM arg1, SCM arg2, SCM args); +SCM_API SCM scm_apply_3 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM args); +SCM_API SCM scm_nconc2last (SCM lst); +SCM_API SCM scm_apply (SCM proc, SCM arg1, SCM args); +SCM_API SCM scm_dapply (SCM proc, SCM arg1, SCM args); +SCM_API SCM scm_m_expand_body (SCM xorig, SCM env); +SCM_API SCM scm_macroexp (SCM x, SCM env); +SCM_API SCM scm_map (SCM proc, SCM arg1, SCM args); +SCM_API SCM scm_for_each (SCM proc, SCM arg1, SCM args); +SCM_API SCM scm_closure (SCM code, SCM env); +SCM_API SCM scm_makprom (SCM code); +SCM_API SCM scm_force (SCM x); +SCM_API SCM scm_promise_p (SCM x); +SCM_API SCM scm_cons_source (SCM xorig, SCM x, SCM y); +SCM_API SCM scm_copy_tree (SCM obj); +SCM_API SCM scm_i_eval_x (SCM exp, SCM env); +SCM_API SCM scm_i_eval (SCM exp, SCM env); +SCM_API SCM scm_primitive_eval (SCM exp); +SCM_API SCM scm_primitive_eval_x (SCM exp); +SCM_API SCM scm_eval (SCM exp, SCM module); +SCM_API SCM scm_eval_x (SCM exp, SCM module); -extern void scm_init_eval (void); +SCM_API void scm_init_eval (void); #endif /* SCM_EVAL_H */ diff --git a/libguile/evalext.h b/libguile/evalext.h index bac8c0eaa..0f2a7dc65 100644 --- a/libguile/evalext.h +++ b/libguile/evalext.h @@ -50,10 +50,10 @@ -extern SCM scm_m_generalized_set_x (SCM xorig, SCM env); -extern SCM scm_definedp (SCM sym, SCM env); -extern SCM scm_m_undefine (SCM x, SCM env); -extern void scm_init_evalext (void); +SCM_API SCM scm_m_generalized_set_x (SCM xorig, SCM env); +SCM_API SCM scm_definedp (SCM sym, SCM env); +SCM_API SCM scm_m_undefine (SCM x, SCM env); +SCM_API void scm_init_evalext (void); #endif /* SCM_EVALEXT_H */ diff --git a/libguile/extensions.h b/libguile/extensions.h index 184ab0e23..cb259c984 100644 --- a/libguile/extensions.h +++ b/libguile/extensions.h @@ -50,13 +50,13 @@ -extern void scm_c_register_extension (const char *lib, const char *init, - void (*func) (void *), void *data); +SCM_API void scm_c_register_extension (const char *lib, const char *init, + void (*func) (void *), void *data); -extern void scm_c_load_extension (const char *lib, const char *init); -extern SCM scm_load_extension (SCM lib, SCM init); +SCM_API void scm_c_load_extension (const char *lib, const char *init); +SCM_API SCM scm_load_extension (SCM lib, SCM init); -void scm_init_extensions (void); +SCM_API void scm_init_extensions (void); #endif /* SCM_EXTENSIONS_H */ diff --git a/libguile/feature.h b/libguile/feature.h index bbda02c53..c4cceaaac 100644 --- a/libguile/feature.h +++ b/libguile/feature.h @@ -48,10 +48,10 @@ #include "libguile/__scm.h" -extern void scm_add_feature (const char* str); -extern SCM scm_program_arguments (void); -extern void scm_set_program_arguments (int argc, char **argv, char *first); -extern void scm_init_feature (void); +SCM_API void scm_add_feature (const char* str); +SCM_API SCM scm_program_arguments (void); +SCM_API void scm_set_program_arguments (int argc, char **argv, char *first); +SCM_API void scm_init_feature (void); #endif /* SCM_FEATURE_H */ diff --git a/libguile/filesys.h b/libguile/filesys.h index 6ad9179c7..134a0278d 100644 --- a/libguile/filesys.h +++ b/libguile/filesys.h @@ -50,7 +50,7 @@ -extern scm_t_bits scm_tc16_dir; +SCM_API scm_t_bits scm_tc16_dir; #define SCM_DIR_FLAG_OPEN (1L << 16) @@ -59,37 +59,37 @@ extern scm_t_bits scm_tc16_dir; -extern SCM scm_chown (SCM object, SCM owner, SCM group); -extern SCM scm_chmod (SCM object, SCM mode); -extern SCM scm_umask (SCM mode); -extern SCM scm_open_fdes (SCM path, SCM flags, SCM mode); -extern SCM scm_open (SCM path, SCM flags, SCM mode); -extern SCM scm_close (SCM fd_or_port); -extern SCM scm_close_fdes (SCM fd); -extern SCM scm_stat (SCM object); -extern SCM scm_link (SCM oldpath, SCM newpath); -extern SCM scm_rename (SCM oldname, SCM newname); -extern SCM scm_delete_file (SCM str); -extern SCM scm_mkdir (SCM path, SCM mode); -extern SCM scm_rmdir (SCM path); -extern SCM scm_directory_stream_p (SCM obj); -extern SCM scm_opendir (SCM dirname); -extern SCM scm_readdir (SCM port); -extern SCM scm_rewinddir (SCM port); -extern SCM scm_closedir (SCM port); -extern SCM scm_chdir (SCM str); -extern SCM scm_getcwd (void); -extern SCM scm_select (SCM reads, SCM writes, SCM excepts, SCM secs, SCM msecs); -extern SCM scm_fcntl (SCM object, SCM cmd, SCM value); -extern SCM scm_fsync (SCM object); -extern SCM scm_symlink (SCM oldpath, SCM newpath); -extern SCM scm_readlink (SCM path); -extern SCM scm_lstat (SCM str); -extern SCM scm_copy_file (SCM oldfile, SCM newfile); -extern SCM scm_dirname (SCM filename); -extern SCM scm_basename (SCM filename, SCM suffix); +SCM_API SCM scm_chown (SCM object, SCM owner, SCM group); +SCM_API SCM scm_chmod (SCM object, SCM mode); +SCM_API SCM scm_umask (SCM mode); +SCM_API SCM scm_open_fdes (SCM path, SCM flags, SCM mode); +SCM_API SCM scm_open (SCM path, SCM flags, SCM mode); +SCM_API SCM scm_close (SCM fd_or_port); +SCM_API SCM scm_close_fdes (SCM fd); +SCM_API SCM scm_stat (SCM object); +SCM_API SCM scm_link (SCM oldpath, SCM newpath); +SCM_API SCM scm_rename (SCM oldname, SCM newname); +SCM_API SCM scm_delete_file (SCM str); +SCM_API SCM scm_mkdir (SCM path, SCM mode); +SCM_API SCM scm_rmdir (SCM path); +SCM_API SCM scm_directory_stream_p (SCM obj); +SCM_API SCM scm_opendir (SCM dirname); +SCM_API SCM scm_readdir (SCM port); +SCM_API SCM scm_rewinddir (SCM port); +SCM_API SCM scm_closedir (SCM port); +SCM_API SCM scm_chdir (SCM str); +SCM_API SCM scm_getcwd (void); +SCM_API SCM scm_select (SCM reads, SCM writes, SCM excepts, SCM secs, SCM msecs); +SCM_API SCM scm_fcntl (SCM object, SCM cmd, SCM value); +SCM_API SCM scm_fsync (SCM object); +SCM_API SCM scm_symlink (SCM oldpath, SCM newpath); +SCM_API SCM scm_readlink (SCM path); +SCM_API SCM scm_lstat (SCM str); +SCM_API SCM scm_copy_file (SCM oldfile, SCM newfile); +SCM_API SCM scm_dirname (SCM filename); +SCM_API SCM scm_basename (SCM filename, SCM suffix); -extern void scm_init_filesys (void); +SCM_API void scm_init_filesys (void); #endif /* SCM_FILESYS_H */ diff --git a/libguile/fluids.h b/libguile/fluids.h index 6e0aa8f24..ba6437bb7 100644 --- a/libguile/fluids.h +++ b/libguile/fluids.h @@ -72,7 +72,7 @@ implement a more lightweight version of fluids on top of this basic mechanism. */ -extern scm_t_bits scm_tc16_fluid; +SCM_API scm_t_bits scm_tc16_fluid; #define SCM_FLUIDP(x) (!SCM_IMP (x) && (SCM_CELL_TYPE (x) == scm_tc16_fluid)) #define SCM_FLUID_NUM(x) (SCM_CELL_WORD_1 (x)) @@ -89,23 +89,23 @@ SCM_FLUID_NUM, not the fluid itself. */ #define SCM_FAST_FLUID_REF(n) (SCM_VELTS(scm_root->fluids)[n]) #define SCM_FAST_FLUID_SET_X(n, val) (SCM_VELTS(scm_root->fluids)[n] = val) -SCM scm_make_fluid (void); -SCM scm_fluid_p (SCM fl); -SCM scm_fluid_ref (SCM fluid); -SCM scm_fluid_set_x (SCM fluid, SCM value); +SCM_API SCM scm_make_fluid (void); +SCM_API SCM scm_fluid_p (SCM fl); +SCM_API SCM scm_fluid_ref (SCM fluid); +SCM_API SCM scm_fluid_set_x (SCM fluid, SCM value); -SCM scm_c_with_fluids (SCM fluids, SCM vals, - SCM (*cproc)(void *), void *cdata); -SCM scm_c_with_fluid (SCM fluid, SCM val, - SCM (*cproc)(void *), void *cdata); -SCM scm_with_fluids (SCM fluids, SCM vals, SCM thunk); +SCM_API SCM scm_c_with_fluids (SCM fluids, SCM vals, + SCM (*cproc)(void *), void *cdata); +SCM_API SCM scm_c_with_fluid (SCM fluid, SCM val, + SCM (*cproc)(void *), void *cdata); +SCM_API SCM scm_with_fluids (SCM fluids, SCM vals, SCM thunk); -SCM scm_make_initial_fluids (void); -void scm_copy_fluids (scm_root_state *); -void scm_swap_fluids (SCM fluids, SCM vals); -void scm_swap_fluids_reverse (SCM fluids, SCM vals); +SCM_API SCM scm_make_initial_fluids (void); +SCM_API void scm_copy_fluids (scm_root_state *); +SCM_API void scm_swap_fluids (SCM fluids, SCM vals); +SCM_API void scm_swap_fluids_reverse (SCM fluids, SCM vals); -void scm_init_fluids (void); +SCM_API void scm_init_fluids (void); #endif /* SCM_FLUIDS_H */ diff --git a/libguile/fports.h b/libguile/fports.h index db968128d..2f1049ba7 100644 --- a/libguile/fports.h +++ b/libguile/fports.h @@ -57,7 +57,7 @@ typedef struct scm_t_fport { int fdes; /* file descriptor. */ } scm_t_fport; -extern scm_t_bits scm_tc16_fport; +SCM_API scm_t_bits scm_tc16_fport; #define SCM_FSTREAM(x) ((scm_t_fport *) SCM_STREAM (x)) #define SCM_FPORT_FDES(x) (SCM_FSTREAM (x)->fdes) @@ -71,13 +71,13 @@ extern scm_t_bits scm_tc16_fport; #define SCM_FDES_RANDOM_P(fdes) ((lseek (fdes, 0, SEEK_CUR) == -1) ? 0 : 1) -extern SCM scm_setbuf0 (SCM port); -extern SCM scm_setvbuf (SCM port, SCM mode, SCM size); -extern void scm_evict_ports (int fd); -extern SCM scm_open_file (SCM filename, SCM modes); -extern SCM scm_fdes_to_port (int fdes, char *mode, SCM name); -extern SCM scm_file_port_p (SCM obj); -extern void scm_init_fports (void); +SCM_API SCM scm_setbuf0 (SCM port); +SCM_API SCM scm_setvbuf (SCM port, SCM mode, SCM size); +SCM_API void scm_evict_ports (int fd); +SCM_API SCM scm_open_file (SCM filename, SCM modes); +SCM_API SCM scm_fdes_to_port (int fdes, char *mode, SCM name); +SCM_API SCM scm_file_port_p (SCM obj); +SCM_API void scm_init_fports (void); #endif /* SCM_FPORTS_H */ diff --git a/libguile/gc.h b/libguile/gc.h index ac0d5c923..c392b5d07 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -295,100 +295,100 @@ typedef unsigned long scm_t_c_bvec_limb; #define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) #if (SCM_DEBUG_CELL_ACCESSES == 1) -extern scm_t_bits scm_tc16_allocated; -extern unsigned int scm_debug_cell_accesses_p; +SCM_API scm_t_bits scm_tc16_allocated; +SCM_API unsigned int scm_debug_cell_accesses_p; #endif -extern struct scm_t_heap_seg_data *scm_heap_table; -extern size_t scm_n_heap_segs; -extern int scm_block_gc; -extern int scm_gc_heap_lock; -extern unsigned int scm_gc_running_p; +SCM_API struct scm_t_heap_seg_data *scm_heap_table; +SCM_API size_t scm_n_heap_segs; +SCM_API int scm_block_gc; +SCM_API int scm_gc_heap_lock; +SCM_API unsigned int scm_gc_running_p; -extern size_t scm_default_init_heap_size_1; -extern int scm_default_min_yield_1; -extern size_t scm_default_init_heap_size_2; -extern int scm_default_min_yield_2; -extern size_t scm_default_max_segment_size; +SCM_API size_t scm_default_init_heap_size_1; +SCM_API int scm_default_min_yield_1; +SCM_API size_t scm_default_init_heap_size_2; +SCM_API int scm_default_min_yield_2; +SCM_API size_t scm_default_max_segment_size; -extern size_t scm_max_segment_size; -extern SCM_CELLPTR scm_heap_org; -extern SCM scm_freelist; -extern struct scm_t_freelist scm_master_freelist; -extern SCM scm_freelist2; -extern struct scm_t_freelist scm_master_freelist2; -extern unsigned long scm_gc_cells_collected; -extern unsigned long scm_gc_yield; -extern unsigned long scm_gc_malloc_collected; -extern unsigned long scm_gc_ports_collected; -extern unsigned long scm_cells_allocated; -extern unsigned long scm_mallocated; -extern unsigned long scm_mtrigger; +SCM_API size_t scm_max_segment_size; +SCM_API SCM_CELLPTR scm_heap_org; +SCM_API SCM scm_freelist; +SCM_API struct scm_t_freelist scm_master_freelist; +SCM_API SCM scm_freelist2; +SCM_API struct scm_t_freelist scm_master_freelist2; +SCM_API unsigned long scm_gc_cells_collected; +SCM_API unsigned long scm_gc_yield; +SCM_API unsigned long scm_gc_malloc_collected; +SCM_API unsigned long scm_gc_ports_collected; +SCM_API unsigned long scm_cells_allocated; +SCM_API unsigned long scm_mallocated; +SCM_API unsigned long scm_mtrigger; -extern SCM scm_after_gc_hook; +SCM_API SCM scm_after_gc_hook; -extern scm_t_c_hook scm_before_gc_c_hook; -extern scm_t_c_hook scm_before_mark_c_hook; -extern scm_t_c_hook scm_before_sweep_c_hook; -extern scm_t_c_hook scm_after_sweep_c_hook; -extern scm_t_c_hook scm_after_gc_c_hook; +SCM_API scm_t_c_hook scm_before_gc_c_hook; +SCM_API scm_t_c_hook scm_before_mark_c_hook; +SCM_API scm_t_c_hook scm_before_sweep_c_hook; +SCM_API scm_t_c_hook scm_after_sweep_c_hook; +SCM_API scm_t_c_hook scm_after_gc_c_hook; #if defined (GUILE_DEBUG) || defined (GUILE_DEBUG_FREELIST) -extern SCM scm_map_free_list (void); -extern SCM scm_free_list_length (void); +SCM_API SCM scm_map_free_list (void); +SCM_API SCM scm_free_list_length (void); #endif #ifdef GUILE_DEBUG_FREELIST -extern SCM scm_debug_newcell (void); -extern SCM scm_debug_newcell2 (void); -extern SCM scm_gc_set_debug_check_freelist_x (SCM flag); +SCM_API SCM scm_debug_newcell (void); +SCM_API SCM scm_debug_newcell2 (void); +SCM_API SCM scm_gc_set_debug_check_freelist_x (SCM flag); #endif #if (SCM_DEBUG_CELL_ACCESSES == 1) -extern void scm_assert_cell_valid (SCM); -extern SCM scm_set_debug_cell_accesses_x (SCM flag); +SCM_API void scm_assert_cell_valid (SCM); +SCM_API SCM scm_set_debug_cell_accesses_x (SCM flag); #endif -extern SCM scm_object_address (SCM obj); -extern SCM scm_unhash_name (SCM name); -extern SCM scm_gc_stats (void); -extern SCM scm_gc (void); -extern void scm_gc_for_alloc (struct scm_t_freelist *freelist); -extern SCM scm_gc_for_newcell (struct scm_t_freelist *master, SCM *freelist); +SCM_API SCM scm_object_address (SCM obj); +SCM_API SCM scm_unhash_name (SCM name); +SCM_API SCM scm_gc_stats (void); +SCM_API SCM scm_gc (void); +SCM_API void scm_gc_for_alloc (struct scm_t_freelist *freelist); +SCM_API SCM scm_gc_for_newcell (struct scm_t_freelist *master, SCM *freelist); #if 0 -extern void scm_alloc_cluster (struct scm_t_freelist *master); +SCM_API void scm_alloc_cluster (struct scm_t_freelist *master); #endif -extern void scm_igc (const char *what); -extern void scm_gc_mark (SCM p); -extern void scm_gc_mark_dependencies (SCM p); -extern void scm_mark_locations (SCM_STACKITEM x[], unsigned long n); -extern int scm_cellp (SCM value); -extern void scm_gc_sweep (void); -extern void * scm_must_malloc (size_t len, const char *what); -extern void * scm_must_realloc (void *where, - size_t olen, size_t len, - const char *what); -extern char *scm_must_strdup (const char *str); -extern char *scm_must_strndup (const char *str, size_t n); -extern void scm_done_malloc (long size); -extern void scm_done_free (long size); -extern void scm_must_free (void *obj); -extern void scm_remember_upto_here_1 (SCM obj); -extern void scm_remember_upto_here_2 (SCM obj1, SCM obj2); -extern void scm_remember_upto_here (SCM obj1, ...); -extern SCM scm_return_first (SCM elt, ...); -extern int scm_return_first_int (int x, ...); -extern SCM scm_permanent_object (SCM obj); -extern SCM scm_gc_protect_object (SCM obj); -extern SCM scm_gc_unprotect_object (SCM obj); -extern void scm_gc_register_root (SCM *p); -extern void scm_gc_unregister_root (SCM *p); -extern void scm_gc_register_roots (SCM *b, unsigned long n); -extern void scm_gc_unregister_roots (SCM *b, unsigned long n); -extern int scm_init_storage (void); -extern void *scm_get_stack_base (void); -extern void scm_init_gc (void); +SCM_API void scm_igc (const char *what); +SCM_API void scm_gc_mark (SCM p); +SCM_API void scm_gc_mark_dependencies (SCM p); +SCM_API void scm_mark_locations (SCM_STACKITEM x[], unsigned long n); +SCM_API int scm_cellp (SCM value); +SCM_API void scm_gc_sweep (void); +SCM_API void * scm_must_malloc (size_t len, const char *what); +SCM_API void * scm_must_realloc (void *where, + size_t olen, size_t len, + const char *what); +SCM_API char *scm_must_strdup (const char *str); +SCM_API char *scm_must_strndup (const char *str, size_t n); +SCM_API void scm_done_malloc (long size); +SCM_API void scm_done_free (long size); +SCM_API void scm_must_free (void *obj); +SCM_API void scm_remember_upto_here_1 (SCM obj); +SCM_API void scm_remember_upto_here_2 (SCM obj1, SCM obj2); +SCM_API void scm_remember_upto_here (SCM obj1, ...); +SCM_API SCM scm_return_first (SCM elt, ...); +SCM_API int scm_return_first_int (int x, ...); +SCM_API SCM scm_permanent_object (SCM obj); +SCM_API SCM scm_gc_protect_object (SCM obj); +SCM_API SCM scm_gc_unprotect_object (SCM obj); +SCM_API void scm_gc_register_root (SCM *p); +SCM_API void scm_gc_unregister_root (SCM *p); +SCM_API void scm_gc_register_roots (SCM *b, unsigned long n); +SCM_API void scm_gc_unregister_roots (SCM *b, unsigned long n); +SCM_API int scm_init_storage (void); +SCM_API void *scm_get_stack_base (void); +SCM_API void scm_init_gc (void); #endif /* SCM_GC_H */ diff --git a/libguile/gdbint.h b/libguile/gdbint.h index 70bf8b484..726f5584f 100644 --- a/libguile/gdbint.h +++ b/libguile/gdbint.h @@ -53,9 +53,9 @@ -extern int scm_print_carefully_p; +SCM_API int scm_print_carefully_p; -extern void scm_init_gdbint (void); +SCM_API void scm_init_gdbint (void); #endif /* SCM_GDBINT_H */ diff --git a/libguile/gh.h b/libguile/gh.h index dab80b07f..90b229dd9 100644 --- a/libguile/gh.h +++ b/libguile/gh.h @@ -58,107 +58,109 @@ extern "C" { #define EXTINL #endif /* __GNUC__ */ -void gh_enter(int argc, char *argv[], void (*c_main_prog)(int, char **)); +SCM_API void gh_enter(int argc, char *argv[], + void (*c_main_prog)(int, char **)); #define gh_init () scm_init_guile () -void gh_repl(int argc, char *argv[]); -SCM gh_catch(SCM tag, scm_t_catch_body body, void *body_data, - scm_t_catch_handler handler, void *handler_data); +SCM_API void gh_repl(int argc, char *argv[]); +SCM_API SCM gh_catch(SCM tag, scm_t_catch_body body, void *body_data, + scm_t_catch_handler handler, void *handler_data); -SCM gh_standard_handler(void *data, SCM tag, SCM throw_args); +SCM_API SCM gh_standard_handler(void *data, SCM tag, SCM throw_args); -SCM gh_eval_str(const char *scheme_code); -SCM gh_eval_str_with_catch(const char *scheme_code, scm_t_catch_handler handler); -SCM gh_eval_str_with_standard_handler(const char *scheme_code); -SCM gh_eval_str_with_stack_saving_handler(const char *scheme_code); +SCM_API SCM gh_eval_str(const char *scheme_code); +SCM_API SCM gh_eval_str_with_catch(const char *scheme_code, scm_t_catch_handler handler); +SCM_API SCM gh_eval_str_with_standard_handler(const char *scheme_code); +SCM_API SCM gh_eval_str_with_stack_saving_handler(const char *scheme_code); -SCM gh_eval_file(const char *fname); +SCM_API SCM gh_eval_file(const char *fname); #define gh_load(fname) gh_eval_file(fname) -SCM gh_eval_file_with_catch(const char *scheme_code, scm_t_catch_handler handler); -SCM gh_eval_file_with_standard_handler(const char *scheme_code); +SCM_API SCM gh_eval_file_with_catch(const char *scheme_code, scm_t_catch_handler handler); +SCM_API SCM gh_eval_file_with_standard_handler(const char *scheme_code); #define gh_defer_ints() SCM_DEFER_INTS #define gh_allow_ints() SCM_ALLOW_INTS -SCM gh_new_procedure(const char *proc_name, SCM (*fn)(), - int n_required_args, int n_optional_args, int varp); -SCM gh_new_procedure0_0(const char *proc_name, SCM (*fn)(void)); -SCM gh_new_procedure0_1(const char *proc_name, SCM (*fn)(SCM)); -SCM gh_new_procedure0_2(const char *proc_name, SCM (*fn)(SCM, SCM)); -SCM gh_new_procedure1_0(const char *proc_name, SCM (*fn)(SCM)); -SCM gh_new_procedure1_1(const char *proc_name, SCM (*fn)(SCM, SCM)); -SCM gh_new_procedure1_2(const char *proc_name, SCM (*fn)(SCM, SCM, SCM)); -SCM gh_new_procedure2_0(const char *proc_name, SCM (*fn)(SCM, SCM)); -SCM gh_new_procedure2_1(const char *proc_name, SCM (*fn)(SCM, SCM, SCM)); -SCM gh_new_procedure2_2(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM)); -SCM gh_new_procedure3_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM)); -SCM gh_new_procedure4_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM)); -SCM gh_new_procedure5_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM, SCM)); +SCM_API SCM gh_new_procedure(const char *proc_name, SCM (*fn)(), + int n_required_args, int n_optional_args, + int varp); +SCM_API SCM gh_new_procedure0_0(const char *proc_name, SCM (*fn)(void)); +SCM_API SCM gh_new_procedure0_1(const char *proc_name, SCM (*fn)(SCM)); +SCM_API SCM gh_new_procedure0_2(const char *proc_name, SCM (*fn)(SCM, SCM)); +SCM_API SCM gh_new_procedure1_0(const char *proc_name, SCM (*fn)(SCM)); +SCM_API SCM gh_new_procedure1_1(const char *proc_name, SCM (*fn)(SCM, SCM)); +SCM_API SCM gh_new_procedure1_2(const char *proc_name, SCM (*fn)(SCM, SCM, SCM)); +SCM_API SCM gh_new_procedure2_0(const char *proc_name, SCM (*fn)(SCM, SCM)); +SCM_API SCM gh_new_procedure2_1(const char *proc_name, SCM (*fn)(SCM, SCM, SCM)); +SCM_API SCM gh_new_procedure2_2(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM)); +SCM_API SCM gh_new_procedure3_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM)); +SCM_API SCM gh_new_procedure4_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM)); +SCM_API SCM gh_new_procedure5_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM, SCM)); /* C to Scheme conversion */ -SCM gh_bool2scm(int x); -SCM gh_int2scm(int x); -SCM gh_ulong2scm(unsigned long x); -SCM gh_long2scm(long x); -SCM gh_double2scm(double x); -SCM gh_char2scm(char c); -SCM gh_str2scm(const char *s, size_t len); -SCM gh_str02scm(const char *s); -void gh_set_substr(char *src, SCM dst, long start, size_t len); -SCM gh_symbol2scm(const char *symbol_str); -SCM gh_ints2scm(const int *d, long n); +SCM_API SCM gh_bool2scm(int x); +SCM_API SCM gh_int2scm(int x); +SCM_API SCM gh_ulong2scm(unsigned long x); +SCM_API SCM gh_long2scm(long x); +SCM_API SCM gh_double2scm(double x); +SCM_API SCM gh_char2scm(char c); +SCM_API SCM gh_str2scm(const char *s, size_t len); +SCM_API SCM gh_str02scm(const char *s); +SCM_API void gh_set_substr(char *src, SCM dst, long start, size_t len); +SCM_API SCM gh_symbol2scm(const char *symbol_str); +SCM_API SCM gh_ints2scm(const int *d, long n); #ifdef HAVE_ARRAYS -SCM gh_chars2byvect(const char *d, long n); -SCM gh_shorts2svect(const short *d, long n); -SCM gh_longs2ivect(const long *d, long n); -SCM gh_ulongs2uvect(const unsigned long *d, long n); -SCM gh_floats2fvect(const float *d, long n); -SCM gh_doubles2dvect(const double *d, long n); +SCM_API SCM gh_chars2byvect(const char *d, long n); +SCM_API SCM gh_shorts2svect(const short *d, long n); +SCM_API SCM gh_longs2ivect(const long *d, long n); +SCM_API SCM gh_ulongs2uvect(const unsigned long *d, long n); +SCM_API SCM gh_floats2fvect(const float *d, long n); +SCM_API SCM gh_doubles2dvect(const double *d, long n); #endif -SCM gh_doubles2scm(const double *d, long n); +SCM_API SCM gh_doubles2scm(const double *d, long n); /* Scheme to C conversion */ -int gh_scm2bool(SCM obj); -int gh_scm2int(SCM obj); -unsigned long gh_scm2ulong(SCM obj); -long gh_scm2long(SCM obj); -char gh_scm2char(SCM obj); -double gh_scm2double(SCM obj); -char *gh_scm2newstr(SCM str, size_t *lenp); -void gh_get_substr(SCM src, char *dst, long start, size_t len); -char *gh_symbol2newstr(SCM sym, size_t *lenp); -char *gh_scm2chars(SCM vector, char *result); -short *gh_scm2shorts(SCM vector, short *result); -long *gh_scm2longs(SCM vector, long *result); -float *gh_scm2floats(SCM vector, float *result); -double *gh_scm2doubles(SCM vector, double *result); +SCM_API int gh_scm2bool(SCM obj); +SCM_API int gh_scm2int(SCM obj); +SCM_API unsigned long gh_scm2ulong(SCM obj); +SCM_API long gh_scm2long(SCM obj); +SCM_API char gh_scm2char(SCM obj); +SCM_API double gh_scm2double(SCM obj); +SCM_API char *gh_scm2newstr(SCM str, size_t *lenp); +SCM_API void gh_get_substr(SCM src, char *dst, long start, size_t len); +SCM_API char *gh_symbol2newstr(SCM sym, size_t *lenp); +SCM_API char *gh_scm2chars(SCM vector, char *result); +SCM_API short *gh_scm2shorts(SCM vector, short *result); +SCM_API long *gh_scm2longs(SCM vector, long *result); +SCM_API float *gh_scm2floats(SCM vector, float *result); +SCM_API double *gh_scm2doubles(SCM vector, double *result); /* type predicates: tell you if an SCM object has a given type */ -int gh_boolean_p(SCM val); -int gh_symbol_p(SCM val); -int gh_char_p(SCM val); -int gh_vector_p(SCM val); -int gh_pair_p(SCM val); -int gh_number_p(SCM val); -int gh_string_p(SCM val); -int gh_procedure_p(SCM val); -int gh_list_p(SCM val); -int gh_inexact_p(SCM val); -int gh_exact_p(SCM val); +SCM_API int gh_boolean_p(SCM val); +SCM_API int gh_symbol_p(SCM val); +SCM_API int gh_char_p(SCM val); +SCM_API int gh_vector_p(SCM val); +SCM_API int gh_pair_p(SCM val); +SCM_API int gh_number_p(SCM val); +SCM_API int gh_string_p(SCM val); +SCM_API int gh_procedure_p(SCM val); +SCM_API int gh_list_p(SCM val); +SCM_API int gh_inexact_p(SCM val); +SCM_API int gh_exact_p(SCM val); /* more predicates */ -int gh_eq_p(SCM x, SCM y); -int gh_eqv_p(SCM x, SCM y); -int gh_equal_p(SCM x, SCM y); -int gh_string_equal_p(SCM s1, SCM s2); -int gh_null_p(SCM l); +SCM_API int gh_eq_p(SCM x, SCM y); +SCM_API int gh_eqv_p(SCM x, SCM y); +SCM_API int gh_equal_p(SCM x, SCM y); +SCM_API int gh_string_equal_p(SCM s1, SCM s2); +SCM_API int gh_null_p(SCM l); /* standard Scheme procedures available from C */ #define gh_not(x) scm_not(x) -SCM gh_define(const char *name, SCM val); +SCM_API SCM gh_define(const char *name, SCM val); /* string manipulation routines */ #define gh_make_string(k, chr) scm_make_string(k, chr) @@ -175,25 +177,25 @@ SCM gh_define(const char *name, SCM val); data element by element, but rather as a list. thus, gh_vector() ends up being identical to gh_list_to_vector() */ #define gh_vector(ls) scm_vector(ls) -SCM gh_make_vector(SCM length, SCM val); -SCM gh_vector_set_x(SCM vec, SCM pos, SCM val); -SCM gh_vector_ref(SCM vec, SCM pos); -unsigned long gh_vector_length (SCM v); -unsigned long gh_uniform_vector_length (SCM v); -SCM gh_uniform_vector_ref (SCM v, SCM ilist); +SCM_API SCM gh_make_vector(SCM length, SCM val); +SCM_API SCM gh_vector_set_x(SCM vec, SCM pos, SCM val); +SCM_API SCM gh_vector_ref(SCM vec, SCM pos); +SCM_API unsigned long gh_vector_length (SCM v); +SCM_API unsigned long gh_uniform_vector_length (SCM v); +SCM_API SCM gh_uniform_vector_ref (SCM v, SCM ilist); #define gh_list_to_vector(ls) scm_vector(ls) #define gh_vector_to_list(v) scm_vector_to_list(v) -SCM gh_lookup (const char *sname); -SCM gh_module_lookup (SCM module, const char *sname); +SCM_API SCM gh_lookup (const char *sname); +SCM_API SCM gh_module_lookup (SCM module, const char *sname); -SCM gh_cons(SCM x, SCM y); +SCM_API SCM gh_cons(SCM x, SCM y); #define gh_list scm_list_n -unsigned long gh_length(SCM l); -SCM gh_append(SCM args); -SCM gh_append2(SCM l1, SCM l2); -SCM gh_append3(SCM l1, SCM l2, SCM l3); -SCM gh_append4(SCM l1, SCM l2, SCM l3, SCM l4); +SCM_API unsigned long gh_length(SCM l); +SCM_API SCM gh_append(SCM args); +SCM_API SCM gh_append2(SCM l1, SCM l2); +SCM_API SCM gh_append3(SCM l1, SCM l2, SCM l3); +SCM_API SCM gh_append4(SCM l1, SCM l2, SCM l3, SCM l4); #define gh_reverse(ls) scm_reverse(ls) #define gh_list_tail(ls, k) scm_list_tail(ls, k) #define gh_list_ref(ls, k) scm_list_ref(ls, k) @@ -204,38 +206,38 @@ SCM gh_append4(SCM l1, SCM l2, SCM l3, SCM l4); #define gh_assv(x, alist) scm_assv(x, alist) #define gh_assoc(x, alist) scm_assoc(x, alist) -SCM gh_car(SCM x); -SCM gh_cdr(SCM x); +SCM_API SCM gh_car(SCM x); +SCM_API SCM gh_cdr(SCM x); -SCM gh_caar(SCM x); -SCM gh_cadr(SCM x); -SCM gh_cdar(SCM x); -SCM gh_cddr(SCM x); +SCM_API SCM gh_caar(SCM x); +SCM_API SCM gh_cadr(SCM x); +SCM_API SCM gh_cdar(SCM x); +SCM_API SCM gh_cddr(SCM x); -SCM gh_caaar(SCM x); -SCM gh_caadr(SCM x); -SCM gh_cadar(SCM x); -SCM gh_caddr(SCM x); -SCM gh_cdaar(SCM x); -SCM gh_cdadr(SCM x); -SCM gh_cddar(SCM x); -SCM gh_cdddr(SCM x); +SCM_API SCM gh_caaar(SCM x); +SCM_API SCM gh_caadr(SCM x); +SCM_API SCM gh_cadar(SCM x); +SCM_API SCM gh_caddr(SCM x); +SCM_API SCM gh_cdaar(SCM x); +SCM_API SCM gh_cdadr(SCM x); +SCM_API SCM gh_cddar(SCM x); +SCM_API SCM gh_cdddr(SCM x); -SCM gh_set_car_x(SCM pair, SCM value); -SCM gh_set_cdr_x(SCM pair, SCM value); +SCM_API SCM gh_set_car_x(SCM pair, SCM value); +SCM_API SCM gh_set_cdr_x(SCM pair, SCM value); /* Calling Scheme functions from C. */ -SCM gh_apply (SCM proc, SCM ls); -SCM gh_call0 (SCM proc); -SCM gh_call1 (SCM proc, SCM arg); -SCM gh_call2 (SCM proc, SCM arg1, SCM arg2); -SCM gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3); +SCM_API SCM gh_apply (SCM proc, SCM ls); +SCM_API SCM gh_call0 (SCM proc); +SCM_API SCM gh_call1 (SCM proc, SCM arg); +SCM_API SCM gh_call2 (SCM proc, SCM arg1, SCM arg2); +SCM_API SCM gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3); /* reading and writing Scheme objects. */ -void gh_display (SCM x); -void gh_write (SCM x); -void gh_newline (void); +SCM_API void gh_display (SCM x); +SCM_API void gh_write (SCM x); +SCM_API void gh_newline (void); /* void gh_gc_mark(SCM) : mark an SCM as in use. */ /* void gh_defer_ints() : don't interrupt code section. */ diff --git a/libguile/goops.h b/libguile/goops.h index d0b85c684..5ebae6d03 100644 --- a/libguile/goops.h +++ b/libguile/goops.h @@ -178,111 +178,127 @@ typedef struct scm_t_method { #define scm_si_code_table 3 /* offset of code. slot in a */ /* C interface */ -extern SCM scm_class_top, scm_class_object, scm_class_class; -extern SCM scm_class_entity, scm_class_entity_with_setter; -extern SCM scm_class_generic, scm_class_generic_with_setter, scm_class_method; -extern SCM scm_class_simple_method, scm_class_accessor; -extern SCM scm_class_procedure_class; -extern SCM scm_class_operator_class, scm_class_operator_with_setter_class; -extern SCM scm_class_entity_class; -extern SCM scm_class_number, scm_class_list; -extern SCM scm_class_keyword; -extern SCM scm_class_port, scm_class_input_output_port; -extern SCM scm_class_input_port, scm_class_output_port; -extern SCM scm_class_foreign_class, scm_class_foreign_object; -extern SCM scm_class_foreign_slot; -extern SCM scm_class_self, scm_class_protected; -extern SCM scm_class_opaque, scm_class_read_only; -extern SCM scm_class_protected_opaque, scm_class_protected_read_only; -extern SCM scm_class_scm; -extern SCM scm_class_int, scm_class_float, scm_class_double; -extern const char *scm_s_slot_set_x; +SCM_API SCM scm_class_top; +SCM_API SCM scm_class_object; +SCM_API SCM scm_class_class; +SCM_API SCM scm_class_entity; +SCM_API SCM scm_class_entity_with_setter; +SCM_API SCM scm_class_generic; +SCM_API SCM scm_class_generic_with_setter; +SCM_API SCM scm_class_method; +SCM_API SCM scm_class_simple_method; +SCM_API SCM scm_class_accessor; +SCM_API SCM scm_class_procedure_class; +SCM_API SCM scm_class_operator_class; +SCM_API SCM scm_class_operator_with_setter_class; +SCM_API SCM scm_class_entity_class; +SCM_API SCM scm_class_number; +SCM_API SCM scm_class_list; +SCM_API SCM scm_class_keyword; +SCM_API SCM scm_class_port; +SCM_API SCM scm_class_input_output_port; +SCM_API SCM scm_class_input_port; +SCM_API SCM scm_class_output_port; +SCM_API SCM scm_class_foreign_class; +SCM_API SCM scm_class_foreign_object; +SCM_API SCM scm_class_foreign_slot; +SCM_API SCM scm_class_self; +SCM_API SCM scm_class_protected; +SCM_API SCM scm_class_opaque; +SCM_API SCM scm_class_read_only; +SCM_API SCM scm_class_protected_opaque; +SCM_API SCM scm_class_protected_read_only; +SCM_API SCM scm_class_scm; +SCM_API SCM scm_class_int; +SCM_API SCM scm_class_float; +SCM_API SCM scm_class_double; +SCM_API const char *scm_s_slot_set_x; -extern SCM scm_module_goops; +SCM_API SCM scm_module_goops; -SCM scm_goops_version (void); -SCM scm_oldfmt (SCM); -char *scm_c_oldfmt0 (char *); -char *scm_c_oldfmt (char *, int n); -void scm_load_goops (void); -SCM scm_make_foreign_object (SCM cls, SCM initargs); -SCM scm_make_class (SCM meta, char *s_name, SCM supers, size_t size, - void * (*constructor) (SCM initargs), - size_t (*destructor) (void *)); -void scm_add_slot (SCM c, char *slot, SCM slot_class, - SCM (*getter) (SCM obj), - SCM (*setter) (SCM obj, SCM x), - char *accessor_name); -SCM scm_wrap_object (SCM c, void *); -SCM scm_wrap_component (SCM c, SCM obj, void *); -SCM scm_ensure_accessor (SCM name); -void scm_add_method (SCM gf, SCM m); +SCM_API SCM scm_goops_version (void); +SCM_API SCM scm_oldfmt (SCM); +SCM_API char *scm_c_oldfmt0 (char *); +SCM_API char *scm_c_oldfmt (char *, int n); +SCM_API void scm_load_goops (void); +SCM_API SCM scm_make_foreign_object (SCM cls, SCM initargs); +SCM_API SCM scm_make_class (SCM meta, char *s_name, SCM supers, size_t size, + void * (*constructor) (SCM initargs), + size_t (*destructor) (void *)); +SCM_API void scm_add_slot (SCM c, char *slot, SCM slot_class, + SCM (*getter) (SCM obj), + SCM (*setter) (SCM obj, SCM x), + char *accessor_name); +SCM_API SCM scm_wrap_object (SCM c, void *); +SCM_API SCM scm_wrap_component (SCM c, SCM obj, void *); +SCM_API SCM scm_ensure_accessor (SCM name); +SCM_API void scm_add_method (SCM gf, SCM m); /* Low level functions exported */ -SCM scm_make_next_method (SCM methods, SCM args, SCM gf); -SCM scm_basic_basic_make_class (SCM c, SCM name, SCM dsupers, SCM dslots); -SCM scm_basic_make_class (SCM c, SCM name, SCM dsupers, SCM dslots); +SCM_API SCM scm_make_next_method (SCM methods, SCM args, SCM gf); +SCM_API SCM scm_basic_basic_make_class (SCM c, SCM name, SCM dsupers, SCM dslots); +SCM_API SCM scm_basic_make_class (SCM c, SCM name, SCM dsupers, SCM dslots); /* Primitives exported */ -SCM scm_sys_allocate_instance (SCM c, SCM initargs); -SCM scm_sys_set_object_setter_x (SCM obj, SCM setter); -SCM scm_slot_ref (SCM obj, SCM slot_name); -SCM scm_slot_set_x (SCM obj, SCM slot_name, SCM value); +SCM_API SCM scm_sys_allocate_instance (SCM c, SCM initargs); +SCM_API SCM scm_sys_set_object_setter_x (SCM obj, SCM setter); +SCM_API SCM scm_slot_ref (SCM obj, SCM slot_name); +SCM_API SCM scm_slot_set_x (SCM obj, SCM slot_name, SCM value); -SCM scm_compute_applicable_methods (SCM gf, SCM args, long len, int scm_find_method); -SCM scm_sys_compute_applicable_methods (SCM gf, SCM args); -SCM scm_m_atslot_ref (SCM xorig, SCM env); -SCM scm_m_atslot_set_x (SCM xorig, SCM env); -SCM scm_m_atdispatch (SCM xorig, SCM env); +SCM_API SCM scm_compute_applicable_methods (SCM gf, SCM args, long len, int scm_find_method); +SCM_API SCM scm_sys_compute_applicable_methods (SCM gf, SCM args); +SCM_API SCM scm_m_atslot_ref (SCM xorig, SCM env); +SCM_API SCM scm_m_atslot_set_x (SCM xorig, SCM env); +SCM_API SCM scm_m_atdispatch (SCM xorig, SCM env); #ifdef GUILE_DEBUG -SCM scm_pure_generic_p (SCM obj); +SCM_API SCM scm_pure_generic_p (SCM obj); #endif -SCM scm_sys_compute_slots (SCM c); -SCM scm_i_get_keyword (SCM key, SCM l, long len, SCM default_value, const char *subr); -SCM scm_get_keyword (SCM key, SCM l, SCM default_value); -SCM scm_sys_initialize_object (SCM obj, SCM initargs); -SCM scm_sys_prep_layout_x (SCM c); -SCM scm_sys_inherit_magic_x (SCM c, SCM dsupers); -SCM scm_instance_p (SCM obj); -SCM scm_class_name (SCM obj); -SCM scm_class_direct_supers (SCM obj); -SCM scm_class_direct_slots (SCM obj); -SCM scm_class_direct_subclasses (SCM obj); -SCM scm_class_direct_methods (SCM obj); -SCM scm_class_precedence_list (SCM obj); -SCM scm_class_slots (SCM obj); -SCM scm_class_environment (SCM obj); -SCM scm_generic_function_name (SCM obj); -SCM scm_generic_function_methods (SCM obj); -SCM scm_method_generic_function (SCM obj); -SCM scm_method_specializers (SCM obj); -SCM scm_method_procedure (SCM obj); -SCM scm_accessor_method_slot_definition (SCM obj); -SCM scm_sys_tag_body (SCM body); -SCM scm_sys_fast_slot_ref (SCM obj, SCM index); -SCM scm_sys_fast_slot_set_x (SCM obj, SCM index, SCM value); -SCM scm_slot_ref_using_class (SCM cls, SCM obj, SCM slot_name); -SCM scm_slot_set_using_class_x (SCM cls, SCM obj, SCM slot_name, SCM value); -SCM scm_slot_bound_using_class_p (SCM cls, SCM obj, SCM slot_name); -SCM scm_slot_exists_using_class_p (SCM cls, SCM obj, SCM slot_name); -SCM scm_slot_bound_p (SCM obj, SCM slot_name); -SCM scm_slots_exists_p (SCM obj, SCM slot_name); -SCM scm_sys_modify_instance (SCM old, SCM newinst); -SCM scm_sys_modify_class (SCM old, SCM newcls); -SCM scm_sys_invalidate_class (SCM cls); -SCM scm_make_method_cache (SCM gf); -SCM scm_sys_invalidate_method_cache_x (SCM gf); -SCM scm_generic_capability_p (SCM proc); -SCM scm_enable_primitive_generic_x (SCM subrs); -SCM scm_primitive_generic_generic (SCM subr); -SCM stklos_version (void); -SCM scm_make (SCM args); -SCM scm_find_method (SCM args); -SCM scm_sys_method_more_specific_p (SCM m1, SCM m2, SCM targs); +SCM_API SCM scm_sys_compute_slots (SCM c); +SCM_API SCM scm_i_get_keyword (SCM key, SCM l, long len, SCM default_value, const char *subr); +SCM_API SCM scm_get_keyword (SCM key, SCM l, SCM default_value); +SCM_API SCM scm_sys_initialize_object (SCM obj, SCM initargs); +SCM_API SCM scm_sys_prep_layout_x (SCM c); +SCM_API SCM scm_sys_inherit_magic_x (SCM c, SCM dsupers); +SCM_API SCM scm_instance_p (SCM obj); +SCM_API SCM scm_class_name (SCM obj); +SCM_API SCM scm_class_direct_supers (SCM obj); +SCM_API SCM scm_class_direct_slots (SCM obj); +SCM_API SCM scm_class_direct_subclasses (SCM obj); +SCM_API SCM scm_class_direct_methods (SCM obj); +SCM_API SCM scm_class_precedence_list (SCM obj); +SCM_API SCM scm_class_slots (SCM obj); +SCM_API SCM scm_class_environment (SCM obj); +SCM_API SCM scm_generic_function_name (SCM obj); +SCM_API SCM scm_generic_function_methods (SCM obj); +SCM_API SCM scm_method_generic_function (SCM obj); +SCM_API SCM scm_method_specializers (SCM obj); +SCM_API SCM scm_method_procedure (SCM obj); +SCM_API SCM scm_accessor_method_slot_definition (SCM obj); +SCM_API SCM scm_sys_tag_body (SCM body); +SCM_API SCM scm_sys_fast_slot_ref (SCM obj, SCM index); +SCM_API SCM scm_sys_fast_slot_set_x (SCM obj, SCM index, SCM value); +SCM_API SCM scm_slot_ref_using_class (SCM cls, SCM obj, SCM slot_name); +SCM_API SCM scm_slot_set_using_class_x (SCM cls, SCM obj, SCM slot_name, SCM value); +SCM_API SCM scm_slot_bound_using_class_p (SCM cls, SCM obj, SCM slot_name); +SCM_API SCM scm_slot_exists_using_class_p (SCM cls, SCM obj, SCM slot_name); +SCM_API SCM scm_slot_bound_p (SCM obj, SCM slot_name); +SCM_API SCM scm_slots_exists_p (SCM obj, SCM slot_name); +SCM_API SCM scm_sys_modify_instance (SCM old, SCM newinst); +SCM_API SCM scm_sys_modify_class (SCM old, SCM newcls); +SCM_API SCM scm_sys_invalidate_class (SCM cls); +SCM_API SCM scm_make_method_cache (SCM gf); +SCM_API SCM scm_sys_invalidate_method_cache_x (SCM gf); +SCM_API SCM scm_generic_capability_p (SCM proc); +SCM_API SCM scm_enable_primitive_generic_x (SCM subrs); +SCM_API SCM scm_primitive_generic_generic (SCM subr); +SCM_API SCM stklos_version (void); +SCM_API SCM scm_make (SCM args); +SCM_API SCM scm_find_method (SCM args); +SCM_API SCM scm_sys_method_more_specific_p (SCM m1, SCM m2, SCM targs); -SCM scm_init_goops_builtins (void); -void scm_init_goops (void); +SCM_API SCM scm_init_goops_builtins (void); +SCM_API void scm_init_goops (void); #if (SCM_DEBUG_DEPRECATED == 0) diff --git a/libguile/gsubr.h b/libguile/gsubr.h index de3489805..a1e068ba3 100644 --- a/libguile/gsubr.h +++ b/libguile/gsubr.h @@ -61,21 +61,21 @@ #define SCM_GSUBR_PROC(cclo) (SCM_CCLO_REF ((cclo), 2)) #define SCM_SET_GSUBR_PROC(cclo, proc) (SCM_CCLO_SET ((cclo), 2, (proc))) -extern SCM scm_f_gsubr_apply; +SCM_API SCM scm_f_gsubr_apply; -extern SCM scm_c_make_gsubr (const char *name, - int req, int opt, int rst, SCM (*fcn) ()); -extern SCM scm_c_make_gsubr_with_generic (const char *name, - int req, int opt, int rst, - SCM (*fcn) (), SCM *gf); -extern SCM scm_c_define_gsubr (const char *name, - int req, int opt, int rst, SCM (*fcn) ()); -extern SCM scm_c_define_gsubr_with_generic (const char *name, - int req, int opt, int rst, - SCM (*fcn) (), SCM *gf); +SCM_API SCM scm_c_make_gsubr (const char *name, + int req, int opt, int rst, SCM (*fcn) ()); +SCM_API SCM scm_c_make_gsubr_with_generic (const char *name, + int req, int opt, int rst, + SCM (*fcn) (), SCM *gf); +SCM_API SCM scm_c_define_gsubr (const char *name, + int req, int opt, int rst, SCM (*fcn) ()); +SCM_API SCM scm_c_define_gsubr_with_generic (const char *name, + int req, int opt, int rst, + SCM (*fcn) (), SCM *gf); -extern SCM scm_gsubr_apply (SCM args); -extern void scm_init_gsubr (void); +SCM_API SCM scm_gsubr_apply (SCM args); +SCM_API void scm_init_gsubr (void); #endif /* SCM_GSUBR_H */ diff --git a/libguile/guardians.h b/libguile/guardians.h index 344fac7af..fbb291094 100644 --- a/libguile/guardians.h +++ b/libguile/guardians.h @@ -48,17 +48,17 @@ #include "libguile/__scm.h" -SCM scm_make_guardian (SCM greedy_p); -SCM scm_destroy_guardian_x (SCM guardian); +SCM_API SCM scm_make_guardian (SCM greedy_p); +SCM_API SCM scm_destroy_guardian_x (SCM guardian); -SCM scm_guardian_greedy_p (SCM guardian); -SCM scm_guardian_destroyed_p (SCM guardian); +SCM_API SCM scm_guardian_greedy_p (SCM guardian); +SCM_API SCM scm_guardian_destroyed_p (SCM guardian); /* these are to be called from C: */ -SCM scm_guard (SCM guardian, SCM obj, int throw_p); -SCM scm_get_one_zombie (SCM guardian); +SCM_API SCM scm_guard (SCM guardian, SCM obj, int throw_p); +SCM_API SCM scm_get_one_zombie (SCM guardian); -void scm_init_guardians (void); +SCM_API void scm_init_guardians (void); #endif /* SCM_GUARDIANS_H */ diff --git a/libguile/hash.h b/libguile/hash.h index fc3b00b61..09464e045 100644 --- a/libguile/hash.h +++ b/libguile/hash.h @@ -50,15 +50,15 @@ -extern unsigned long scm_string_hash (const unsigned char *str, size_t len); -extern unsigned long scm_hasher (SCM obj, unsigned long n, size_t d); -extern unsigned long scm_ihashq (SCM obj, unsigned long n); -extern SCM scm_hashq (SCM obj, SCM n); -extern unsigned long scm_ihashv (SCM obj, unsigned long n); -extern SCM scm_hashv (SCM obj, SCM n); -extern unsigned long scm_ihash (SCM obj, unsigned long n); -extern SCM scm_hash (SCM obj, SCM n); -extern void scm_init_hash (void); +SCM_API unsigned long scm_string_hash (const unsigned char *str, size_t len); +SCM_API unsigned long scm_hasher (SCM obj, unsigned long n, size_t d); +SCM_API unsigned long scm_ihashq (SCM obj, unsigned long n); +SCM_API SCM scm_hashq (SCM obj, SCM n); +SCM_API unsigned long scm_ihashv (SCM obj, unsigned long n); +SCM_API SCM scm_hashv (SCM obj, SCM n); +SCM_API unsigned long scm_ihash (SCM obj, unsigned long n); +SCM_API SCM scm_hash (SCM obj, SCM n); +SCM_API void scm_init_hash (void); #endif /* SCM_HASH_H */ diff --git a/libguile/hashtab.h b/libguile/hashtab.h index 6e969570b..ae1582af8 100644 --- a/libguile/hashtab.h +++ b/libguile/hashtab.h @@ -56,37 +56,37 @@ typedef SCM scm_t_assoc_fn (SCM key, SCM alist, void *closure); typedef SCM scm_t_delete_fn (SCM elt, SCM list); #endif -extern SCM scm_c_make_hash_table (unsigned long k); +SCM_API SCM scm_c_make_hash_table (unsigned long k); -extern SCM scm_hash_fn_get_handle (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); -extern SCM scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); -extern SCM scm_hash_fn_ref (SCM table, SCM obj, SCM dflt, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); -extern SCM scm_hash_fn_set_x (SCM table, SCM obj, SCM val, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); -extern SCM scm_hash_fn_remove_x (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), SCM (*delete_fn) (), void * closure); -extern SCM scm_internal_hash_fold (SCM (*fn) (), void *closure, SCM init, SCM table); +SCM_API SCM scm_hash_fn_get_handle (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); +SCM_API SCM scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); +SCM_API SCM scm_hash_fn_ref (SCM table, SCM obj, SCM dflt, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); +SCM_API SCM scm_hash_fn_set_x (SCM table, SCM obj, SCM val, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); +SCM_API SCM scm_hash_fn_remove_x (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), SCM (*delete_fn) (), void * closure); +SCM_API SCM scm_internal_hash_fold (SCM (*fn) (), void *closure, SCM init, SCM table); -extern SCM scm_hashq_get_handle (SCM table, SCM obj); -extern SCM scm_hashq_create_handle_x (SCM table, SCM obj, SCM init); -extern SCM scm_hashq_ref (SCM table, SCM obj, SCM dflt); -extern SCM scm_hashq_set_x (SCM table, SCM obj, SCM val); -extern SCM scm_hashq_remove_x (SCM table, SCM obj); -extern SCM scm_hashv_get_handle (SCM table, SCM obj); -extern SCM scm_hashv_create_handle_x (SCM table, SCM obj, SCM init); -extern SCM scm_hashv_ref (SCM table, SCM obj, SCM dflt); -extern SCM scm_hashv_set_x (SCM table, SCM obj, SCM val); -extern SCM scm_hashv_remove_x (SCM table, SCM obj); -extern SCM scm_hash_get_handle (SCM table, SCM obj); -extern SCM scm_hash_create_handle_x (SCM table, SCM obj, SCM init); -extern SCM scm_hash_ref (SCM table, SCM obj, SCM dflt); -extern SCM scm_hash_set_x (SCM table, SCM obj, SCM val); -extern SCM scm_hash_remove_x (SCM table, SCM obj); -extern SCM scm_hashx_get_handle (SCM hash, SCM assoc, SCM table, SCM obj); -extern SCM scm_hashx_create_handle_x (SCM hash, SCM assoc, SCM table, SCM obj, SCM init); -extern SCM scm_hashx_ref (SCM hash, SCM assoc, SCM table, SCM obj, SCM dflt); -extern SCM scm_hashx_set_x (SCM hash, SCM assoc, SCM table, SCM obj, SCM val); -extern SCM scm_hashx_remove_x (SCM hash, SCM assoc, SCM del, SCM table, SCM obj); -extern SCM scm_hash_fold (SCM proc, SCM init, SCM hash); -extern void scm_init_hashtab (void); +SCM_API SCM scm_hashq_get_handle (SCM table, SCM obj); +SCM_API SCM scm_hashq_create_handle_x (SCM table, SCM obj, SCM init); +SCM_API SCM scm_hashq_ref (SCM table, SCM obj, SCM dflt); +SCM_API SCM scm_hashq_set_x (SCM table, SCM obj, SCM val); +SCM_API SCM scm_hashq_remove_x (SCM table, SCM obj); +SCM_API SCM scm_hashv_get_handle (SCM table, SCM obj); +SCM_API SCM scm_hashv_create_handle_x (SCM table, SCM obj, SCM init); +SCM_API SCM scm_hashv_ref (SCM table, SCM obj, SCM dflt); +SCM_API SCM scm_hashv_set_x (SCM table, SCM obj, SCM val); +SCM_API SCM scm_hashv_remove_x (SCM table, SCM obj); +SCM_API SCM scm_hash_get_handle (SCM table, SCM obj); +SCM_API SCM scm_hash_create_handle_x (SCM table, SCM obj, SCM init); +SCM_API SCM scm_hash_ref (SCM table, SCM obj, SCM dflt); +SCM_API SCM scm_hash_set_x (SCM table, SCM obj, SCM val); +SCM_API SCM scm_hash_remove_x (SCM table, SCM obj); +SCM_API SCM scm_hashx_get_handle (SCM hash, SCM assoc, SCM table, SCM obj); +SCM_API SCM scm_hashx_create_handle_x (SCM hash, SCM assoc, SCM table, SCM obj, SCM init); +SCM_API SCM scm_hashx_ref (SCM hash, SCM assoc, SCM table, SCM obj, SCM dflt); +SCM_API SCM scm_hashx_set_x (SCM hash, SCM assoc, SCM table, SCM obj, SCM val); +SCM_API SCM scm_hashx_remove_x (SCM hash, SCM assoc, SCM del, SCM table, SCM obj); +SCM_API SCM scm_hash_fold (SCM proc, SCM init, SCM hash); +SCM_API void scm_init_hashtab (void); #endif /* SCM_HASHTAB_H */ diff --git a/libguile/hooks.h b/libguile/hooks.h index 8f9dc63c5..48e4f8b16 100644 --- a/libguile/hooks.h +++ b/libguile/hooks.h @@ -79,39 +79,39 @@ typedef struct scm_t_c_hook { void *data; } scm_t_c_hook; -extern void scm_c_hook_init (scm_t_c_hook *hook, - void *hook_data, - scm_t_c_hookype_t type); -extern void scm_c_hook_add (scm_t_c_hook *hook, - scm_t_c_hook_function func, - void *func_data, - int appendp); -extern void scm_c_hook_remove (scm_t_c_hook *hook, - scm_t_c_hook_function func, - void *func_data); -extern void *scm_c_hook_run (scm_t_c_hook *hook, void *data); +SCM_API void scm_c_hook_init (scm_t_c_hook *hook, + void *hook_data, + scm_t_c_hookype_t type); +SCM_API void scm_c_hook_add (scm_t_c_hook *hook, + scm_t_c_hook_function func, + void *func_data, + int appendp); +SCM_API void scm_c_hook_remove (scm_t_c_hook *hook, + scm_t_c_hook_function func, + void *func_data); +SCM_API void *scm_c_hook_run (scm_t_c_hook *hook, void *data); /* * Scheme level hooks */ -extern scm_t_bits scm_tc16_hook; +SCM_API scm_t_bits scm_tc16_hook; #define SCM_HOOKP(x) SCM_TYP16_PREDICATE (scm_tc16_hook, x) #define SCM_HOOK_ARITY(hook) (SCM_CELL_WORD_0 (hook) >> 16) #define SCM_HOOK_PROCEDURES(hook) SCM_CELL_OBJECT_1 (hook) #define SCM_SET_HOOK_PROCEDURES(hook, procs) SCM_SET_CELL_OBJECT_1 ((hook), (procs)) -extern SCM scm_make_hook (SCM n_args); -extern SCM scm_hook_p (SCM x); -extern SCM scm_hook_empty_p (SCM hook); -extern SCM scm_add_hook_x (SCM hook, SCM thunk, SCM appendp); -extern SCM scm_remove_hook_x (SCM hook, SCM thunk); -extern SCM scm_reset_hook_x (SCM hook); -extern SCM scm_run_hook (SCM hook, SCM args); -extern void scm_c_run_hook (SCM hook, SCM args); -extern SCM scm_hook_to_list (SCM hook); -extern void scm_init_hooks (void); +SCM_API SCM scm_make_hook (SCM n_args); +SCM_API SCM scm_hook_p (SCM x); +SCM_API SCM scm_hook_empty_p (SCM hook); +SCM_API SCM scm_add_hook_x (SCM hook, SCM thunk, SCM appendp); +SCM_API SCM scm_remove_hook_x (SCM hook, SCM thunk); +SCM_API SCM scm_reset_hook_x (SCM hook); +SCM_API SCM scm_run_hook (SCM hook, SCM args); +SCM_API void scm_c_run_hook (SCM hook, SCM args); +SCM_API SCM scm_hook_to_list (SCM hook); +SCM_API void scm_init_hooks (void); #endif /* SCM_HOOKS_H */ diff --git a/libguile/init.h b/libguile/init.h index 4e95fb557..5347c7731 100644 --- a/libguile/init.h +++ b/libguile/init.h @@ -49,17 +49,17 @@ #include "libguile/__scm.h" -extern int scm_initialized_p; +SCM_API int scm_initialized_p; -extern void scm_init_guile (void); +SCM_API void scm_init_guile (void); -extern void scm_boot_guile (int argc, char **argv, - void (*main_func) (void *closure, - int argc, - char **argv), - void *closure); +SCM_API void scm_boot_guile (int argc, char **argv, + void (*main_func) (void *closure, + int argc, + char **argv), + void *closure); -extern void scm_load_startup_files (void); +SCM_API void scm_load_startup_files (void); #endif /* SCM_INIT_H */ diff --git a/libguile/ioext.h b/libguile/ioext.h index 5cb5e2394..0b8cdf897 100644 --- a/libguile/ioext.h +++ b/libguile/ioext.h @@ -50,16 +50,16 @@ -extern SCM scm_ftell (SCM object); -extern SCM scm_redirect_port (SCM into_pt, SCM from_pt); -extern SCM scm_dup_to_fdes (SCM fd_or_port, SCM newfd); -extern SCM scm_dup2 (SCM oldfd, SCM newfd); -extern SCM scm_fileno (SCM port); -extern SCM scm_isatty_p (SCM port); -extern SCM scm_fdopen (SCM fdes, SCM modes); -extern SCM scm_primitive_move_to_fdes (SCM port, SCM fd); -extern SCM scm_fdes_to_ports (SCM fd); -extern void scm_init_ioext (void); +SCM_API SCM scm_ftell (SCM object); +SCM_API SCM scm_redirect_port (SCM into_pt, SCM from_pt); +SCM_API SCM scm_dup_to_fdes (SCM fd_or_port, SCM newfd); +SCM_API SCM scm_dup2 (SCM oldfd, SCM newfd); +SCM_API SCM scm_fileno (SCM port); +SCM_API SCM scm_isatty_p (SCM port); +SCM_API SCM scm_fdopen (SCM fdes, SCM modes); +SCM_API SCM scm_primitive_move_to_fdes (SCM port, SCM fd); +SCM_API SCM scm_fdes_to_ports (SCM fd); +SCM_API void scm_init_ioext (void); #endif /* SCM_IOEXT_H */ diff --git a/libguile/iselect.h b/libguile/iselect.h index bbacf3036..a7b59594e 100644 --- a/libguile/iselect.h +++ b/libguile/iselect.h @@ -89,18 +89,18 @@ #endif /* no FD_SET */ -extern int scm_internal_select (int fds, - SELECT_TYPE *rfds, - SELECT_TYPE *wfds, - SELECT_TYPE *efds, - struct timeval *timeout); +SCM_API int scm_internal_select (int fds, + SELECT_TYPE *rfds, + SELECT_TYPE *wfds, + SELECT_TYPE *efds, + struct timeval *timeout); #ifdef GUILE_ISELECT -extern int scm_I_am_dead; +SCM_API int scm_I_am_dead; -extern void scm_error_revive_threads (void); -extern void scm_init_iselect (void); +SCM_API void scm_error_revive_threads (void); +SCM_API void scm_init_iselect (void); #endif /* GUILE_ISELECT */ diff --git a/libguile/keywords.h b/libguile/keywords.h index 3ff94907d..d9fee388a 100644 --- a/libguile/keywords.h +++ b/libguile/keywords.h @@ -50,7 +50,7 @@ -extern scm_t_bits scm_tc16_keyword; +SCM_API scm_t_bits scm_tc16_keyword; #define SCM_KEYWORDP(X) (!SCM_IMP (X) && (SCM_CELL_TYPE (X) == scm_tc16_keyword)) #define SCM_KEYWORDSYM(X) (SCM_CELL_OBJECT_1 (X)) @@ -58,11 +58,11 @@ extern scm_t_bits scm_tc16_keyword; -extern SCM scm_make_keyword_from_dash_symbol (SCM symbol); -extern SCM scm_c_make_keyword (char *s); -extern SCM scm_keyword_p (SCM obj); -extern SCM scm_keyword_dash_symbol (SCM keyword); -extern void scm_init_keywords (void); +SCM_API SCM scm_make_keyword_from_dash_symbol (SCM symbol); +SCM_API SCM scm_c_make_keyword (char *s); +SCM_API SCM scm_keyword_p (SCM obj); +SCM_API SCM scm_keyword_dash_symbol (SCM keyword); +SCM_API void scm_init_keywords (void); #endif /* SCM_KEYWORDS_H */ diff --git a/libguile/lang.h b/libguile/lang.h index 0619e5221..ae10869b5 100644 --- a/libguile/lang.h +++ b/libguile/lang.h @@ -50,8 +50,8 @@ -extern SCM scm_lisp_nil; -extern SCM scm_lisp_t; +SCM_API SCM scm_lisp_nil; +SCM_API SCM scm_lisp_t; #define SCM_NILP(x) (SCM_EQ_P ((x), scm_lisp_nil)) #define SCM_NILNULLP(x) (SCM_NILP (x) || SCM_NULLP (x)) @@ -62,13 +62,13 @@ extern SCM scm_lisp_t; -extern SCM scm_nil_cons (SCM x, SCM y); -extern SCM scm_nil_car (SCM x); -extern SCM scm_nil_cdr (SCM x); -extern SCM scm_null (SCM x); -extern SCM scm_m_while (SCM exp, SCM env); -extern SCM scm_nil_eq (SCM x, SCM y); -extern void scm_init_lang (void); +SCM_API SCM scm_nil_cons (SCM x, SCM y); +SCM_API SCM scm_nil_car (SCM x); +SCM_API SCM scm_nil_cdr (SCM x); +SCM_API SCM scm_null (SCM x); +SCM_API SCM scm_m_while (SCM exp, SCM env); +SCM_API SCM scm_nil_eq (SCM x, SCM y); +SCM_API void scm_init_lang (void); #endif /* SCM_LANG_H */ diff --git a/libguile/list.h b/libguile/list.h index 78af07c95..8fc71992c 100644 --- a/libguile/list.h +++ b/libguile/list.h @@ -50,43 +50,43 @@ -extern SCM scm_list_1 (SCM e1); -extern SCM scm_list_2 (SCM e1, SCM e2); -extern SCM scm_list_3 (SCM e1, SCM e2, SCM e3); -extern SCM scm_list_4 (SCM e1, SCM e2, SCM e3, SCM e4); -extern SCM scm_list_5 (SCM e1, SCM e2, SCM e3, SCM e4, SCM e5); -extern SCM scm_list_n (SCM elt, ...); -extern SCM scm_list_head (SCM lst, SCM k); -extern SCM scm_list (SCM objs); -extern SCM scm_cons_star (SCM arg, SCM objs); -extern SCM scm_null_p (SCM x); -extern SCM scm_list_p (SCM x); -extern long scm_ilength (SCM sx); -extern SCM scm_length (SCM x); -extern SCM scm_append (SCM args); -extern SCM scm_append_x (SCM args); -extern SCM scm_reverse (SCM lst); -extern SCM scm_reverse_x (SCM lst, SCM newtail); -extern SCM scm_list_ref (SCM lst, SCM k); -extern SCM scm_list_set_x (SCM lst, SCM k, SCM val); -extern SCM scm_list_cdr_set_x (SCM lst, SCM k, SCM val); -extern SCM scm_last_pair (SCM sx); -extern SCM scm_list_tail (SCM lst, SCM k); -extern SCM scm_c_memq (SCM x, SCM lst); -extern SCM scm_memq (SCM x, SCM lst); -extern SCM scm_memv (SCM x, SCM lst); -extern SCM scm_member (SCM x, SCM lst); -extern SCM scm_delq_x (SCM item, SCM lst); -extern SCM scm_delv_x (SCM item, SCM lst); -extern SCM scm_delete_x (SCM item, SCM lst); -extern SCM scm_list_copy (SCM lst); -extern SCM scm_delq (SCM item, SCM lst); -extern SCM scm_delv (SCM item, SCM lst); -extern SCM scm_delete (SCM item, SCM lst); -extern SCM scm_delq1_x (SCM item, SCM lst); -extern SCM scm_delv1_x (SCM item, SCM lst); -extern SCM scm_delete1_x (SCM item, SCM lst); -extern void scm_init_list (void); +SCM_API SCM scm_list_1 (SCM e1); +SCM_API SCM scm_list_2 (SCM e1, SCM e2); +SCM_API SCM scm_list_3 (SCM e1, SCM e2, SCM e3); +SCM_API SCM scm_list_4 (SCM e1, SCM e2, SCM e3, SCM e4); +SCM_API SCM scm_list_5 (SCM e1, SCM e2, SCM e3, SCM e4, SCM e5); +SCM_API SCM scm_list_n (SCM elt, ...); +SCM_API SCM scm_list_head (SCM lst, SCM k); +SCM_API SCM scm_list (SCM objs); +SCM_API SCM scm_cons_star (SCM arg, SCM objs); +SCM_API SCM scm_null_p (SCM x); +SCM_API SCM scm_list_p (SCM x); +SCM_API long scm_ilength (SCM sx); +SCM_API SCM scm_length (SCM x); +SCM_API SCM scm_append (SCM args); +SCM_API SCM scm_append_x (SCM args); +SCM_API SCM scm_reverse (SCM lst); +SCM_API SCM scm_reverse_x (SCM lst, SCM newtail); +SCM_API SCM scm_list_ref (SCM lst, SCM k); +SCM_API SCM scm_list_set_x (SCM lst, SCM k, SCM val); +SCM_API SCM scm_list_cdr_set_x (SCM lst, SCM k, SCM val); +SCM_API SCM scm_last_pair (SCM sx); +SCM_API SCM scm_list_tail (SCM lst, SCM k); +SCM_API SCM scm_c_memq (SCM x, SCM lst); +SCM_API SCM scm_memq (SCM x, SCM lst); +SCM_API SCM scm_memv (SCM x, SCM lst); +SCM_API SCM scm_member (SCM x, SCM lst); +SCM_API SCM scm_delq_x (SCM item, SCM lst); +SCM_API SCM scm_delv_x (SCM item, SCM lst); +SCM_API SCM scm_delete_x (SCM item, SCM lst); +SCM_API SCM scm_list_copy (SCM lst); +SCM_API SCM scm_delq (SCM item, SCM lst); +SCM_API SCM scm_delv (SCM item, SCM lst); +SCM_API SCM scm_delete (SCM item, SCM lst); +SCM_API SCM scm_delq1_x (SCM item, SCM lst); +SCM_API SCM scm_delv1_x (SCM item, SCM lst); +SCM_API SCM scm_delete1_x (SCM item, SCM lst); +SCM_API void scm_init_list (void); #endif /* SCM_LIST_H */ diff --git a/libguile/load.h b/libguile/load.h index a4d17b1ce..5864309f6 100644 --- a/libguile/load.h +++ b/libguile/load.h @@ -49,19 +49,19 @@ #include "libguile/__scm.h" -extern SCM scm_internal_parse_path (char *path, SCM tail); -extern SCM scm_parse_path (SCM path, SCM tail); -extern void scm_init_load_path (void); -extern SCM scm_primitive_load (SCM filename); -extern SCM scm_c_primitive_load (const char *filename); -extern SCM scm_sys_package_data_dir (void); -extern SCM scm_sys_library_dir (void); -extern SCM scm_sys_site_dir (void); -extern SCM scm_search_path (SCM path, SCM filename, SCM exts); -extern SCM scm_sys_search_load_path (SCM filename); -extern SCM scm_primitive_load_path (SCM filename); -extern SCM scm_c_primitive_load_path (const char *filename); -extern void scm_init_load (void); +SCM_API SCM scm_internal_parse_path (char *path, SCM tail); +SCM_API SCM scm_parse_path (SCM path, SCM tail); +SCM_API void scm_init_load_path (void); +SCM_API SCM scm_primitive_load (SCM filename); +SCM_API SCM scm_c_primitive_load (const char *filename); +SCM_API SCM scm_sys_package_data_dir (void); +SCM_API SCM scm_sys_library_dir (void); +SCM_API SCM scm_sys_site_dir (void); +SCM_API SCM scm_search_path (SCM path, SCM filename, SCM exts); +SCM_API SCM scm_sys_search_load_path (SCM filename); +SCM_API SCM scm_primitive_load_path (SCM filename); +SCM_API SCM scm_c_primitive_load_path (const char *filename); +SCM_API void scm_init_load (void); #endif /* SCM_LOAD_H */ diff --git a/libguile/macros.h b/libguile/macros.h index 1a2203ab1..05f86ca9a 100644 --- a/libguile/macros.h +++ b/libguile/macros.h @@ -57,19 +57,19 @@ #define SCM_MACRO_TYPE(m) (SCM_CELL_WORD_0 (m) >> 16) #define SCM_MACRO_CODE(m) SCM_CELL_OBJECT_1 (m) -extern scm_t_bits scm_tc16_macro; +SCM_API scm_t_bits scm_tc16_macro; -extern SCM scm_makacro (SCM code); -extern SCM scm_makmacro (SCM code); -extern SCM scm_makmmacro (SCM code); -extern SCM scm_macro_p (SCM obj); -extern SCM scm_macro_type (SCM m); -extern SCM scm_macro_name (SCM m); -extern SCM scm_macro_transformer (SCM m); -extern SCM scm_make_synt (const char *name, - SCM (*macroizer) (SCM), - SCM (*fcn) ()); -extern void scm_init_macros (void); +SCM_API SCM scm_makacro (SCM code); +SCM_API SCM scm_makmacro (SCM code); +SCM_API SCM scm_makmmacro (SCM code); +SCM_API SCM scm_macro_p (SCM obj); +SCM_API SCM scm_macro_type (SCM m); +SCM_API SCM scm_macro_name (SCM m); +SCM_API SCM scm_macro_transformer (SCM m); +SCM_API SCM scm_make_synt (const char *name, + SCM (*macroizer) (SCM), + SCM (*fcn) ()); +SCM_API void scm_init_macros (void); #endif /* SCM_MACROS_H */ diff --git a/libguile/mallocs.h b/libguile/mallocs.h index cb96af7f5..765c93351 100644 --- a/libguile/mallocs.h +++ b/libguile/mallocs.h @@ -49,7 +49,7 @@ #include "libguile/__scm.h" -extern scm_t_bits scm_tc16_malloc; +SCM_API scm_t_bits scm_tc16_malloc; #define SCM_MALLOCP(X) (SCM_TYP16 (X) == scm_tc16_malloc) #define SCM_MALLOCDATA(obj) ((char *) SCM_CELL_WORD_1 (obj)) @@ -57,8 +57,8 @@ extern scm_t_bits scm_tc16_malloc; -extern SCM scm_malloc_obj (size_t n); -extern void scm_init_mallocs (void); +SCM_API SCM scm_malloc_obj (size_t n); +SCM_API void scm_init_mallocs (void); #endif /* SCM_MALLOCS_H */ diff --git a/libguile/modules.h b/libguile/modules.h index ece08bb7b..f5e8e4f55 100644 --- a/libguile/modules.h +++ b/libguile/modules.h @@ -52,8 +52,8 @@ -extern int scm_module_system_booted_p; -extern scm_t_bits scm_module_tag; +SCM_API int scm_module_system_booted_p; +SCM_API scm_t_bits scm_module_tag; #define SCM_MODULEP(OBJ) \ (!SCM_IMP (OBJ) && SCM_CELL_TYPE (OBJ) == scm_module_tag) @@ -81,56 +81,56 @@ extern scm_t_bits scm_module_tag; #define SCM_MODULE_TRANSFORMER(module) \ SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_transformer]) -extern scm_t_bits scm_tc16_eval_closure; +SCM_API scm_t_bits scm_tc16_eval_closure; #define SCM_EVAL_CLOSURE_P(x) SCM_TYP16_PREDICATE (scm_tc16_eval_closure, x) -extern SCM scm_current_module (void); -extern SCM scm_interaction_environment (void); -extern SCM scm_set_current_module (SCM module); +SCM_API SCM scm_current_module (void); +SCM_API SCM scm_interaction_environment (void); +SCM_API SCM scm_set_current_module (SCM module); -extern SCM scm_c_call_with_current_module (SCM module, - SCM (*func)(void *), void *data); +SCM_API SCM scm_c_call_with_current_module (SCM module, + SCM (*func)(void *), void *data); -extern SCM scm_c_lookup (const char *name); -extern SCM scm_c_define (const char *name, SCM val); -extern SCM scm_lookup (SCM symbol); -extern SCM scm_define (SCM symbol, SCM val); +SCM_API SCM scm_c_lookup (const char *name); +SCM_API SCM scm_c_define (const char *name, SCM val); +SCM_API SCM scm_lookup (SCM symbol); +SCM_API SCM scm_define (SCM symbol, SCM val); -extern SCM scm_c_module_lookup (SCM module, const char *name); -extern SCM scm_c_module_define (SCM module, const char *name, SCM val); -extern SCM scm_module_lookup (SCM module, SCM symbol); -extern SCM scm_module_define (SCM module, SCM symbol, SCM val); -extern SCM scm_module_reverse_lookup (SCM module, SCM variable); +SCM_API SCM scm_c_module_lookup (SCM module, const char *name); +SCM_API SCM scm_c_module_define (SCM module, const char *name, SCM val); +SCM_API SCM scm_module_lookup (SCM module, SCM symbol); +SCM_API SCM scm_module_define (SCM module, SCM symbol, SCM val); +SCM_API SCM scm_module_reverse_lookup (SCM module, SCM variable); -extern SCM scm_c_resolve_module (const char *name); -extern SCM scm_resolve_module (SCM name); -extern SCM scm_c_define_module (const char *name, - void (*init)(void *), void *data); -extern void scm_c_use_module (const char *name); -extern void scm_c_export (const char *name, ...); +SCM_API SCM scm_c_resolve_module (const char *name); +SCM_API SCM scm_resolve_module (SCM name); +SCM_API SCM scm_c_define_module (const char *name, + void (*init)(void *), void *data); +SCM_API void scm_c_use_module (const char *name); +SCM_API void scm_c_export (const char *name, ...); -extern SCM scm_sym2var (SCM sym, SCM thunk, SCM definep); +SCM_API SCM scm_sym2var (SCM sym, SCM thunk, SCM definep); -extern SCM scm_module_lookup_closure (SCM module); -extern SCM scm_module_transformer (SCM module); -extern SCM scm_current_module_lookup_closure (void); -extern SCM scm_current_module_transformer (void); -extern SCM scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep); -extern SCM scm_standard_eval_closure (SCM module); -extern SCM scm_standard_interface_eval_closure (SCM module); -extern SCM scm_get_pre_modules_obarray (void); -extern SCM scm_lookup_closure_module (SCM proc); +SCM_API SCM scm_module_lookup_closure (SCM module); +SCM_API SCM scm_module_transformer (SCM module); +SCM_API SCM scm_current_module_lookup_closure (void); +SCM_API SCM scm_current_module_transformer (void); +SCM_API SCM scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep); +SCM_API SCM scm_standard_eval_closure (SCM module); +SCM_API SCM scm_standard_interface_eval_closure (SCM module); +SCM_API SCM scm_get_pre_modules_obarray (void); +SCM_API SCM scm_lookup_closure_module (SCM proc); -extern SCM scm_env_top_level (SCM env); -extern SCM scm_env_module (SCM env); -extern SCM scm_top_level_env (SCM thunk); -extern SCM scm_system_module_env_p (SCM env); +SCM_API SCM scm_env_top_level (SCM env); +SCM_API SCM scm_env_module (SCM env); +SCM_API SCM scm_top_level_env (SCM thunk); +SCM_API SCM scm_system_module_env_p (SCM env); -extern void scm_modules_prehistory (void); -extern void scm_init_modules (void); +SCM_API void scm_modules_prehistory (void); +SCM_API void scm_init_modules (void); #endif /* SCM_MODULES_H */ diff --git a/libguile/net_db.h b/libguile/net_db.h index db8f22005..b0ceda9c8 100644 --- a/libguile/net_db.h +++ b/libguile/net_db.h @@ -50,15 +50,15 @@ -extern SCM scm_gethost (SCM host); -extern SCM scm_getnet (SCM name); -extern SCM scm_getproto (SCM name); -extern SCM scm_getserv (SCM name, SCM proto); -extern SCM scm_sethost (SCM arg); -extern SCM scm_setnet (SCM arg); -extern SCM scm_setproto (SCM arg); -extern SCM scm_setserv (SCM arg); -extern void scm_init_net_db (void); +SCM_API SCM scm_gethost (SCM host); +SCM_API SCM scm_getnet (SCM name); +SCM_API SCM scm_getproto (SCM name); +SCM_API SCM scm_getserv (SCM name, SCM proto); +SCM_API SCM scm_sethost (SCM arg); +SCM_API SCM scm_setnet (SCM arg); +SCM_API SCM scm_setproto (SCM arg); +SCM_API SCM scm_setserv (SCM arg); +SCM_API void scm_init_net_db (void); #endif /* SCM_NET_DB_H */ diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index e81204433..09a6e03fa 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -93,13 +93,13 @@ INTEGRAL2NUM (ITYPE n) #define NEED_CHECK #else #ifdef UNSIGNED -#if MAX_VALUE > SCM_MOST_POSITIVE_FIXNUM + /*#if MAX_VALUE > SCM_MOST_POSITIVE_FIXNUM*/ #define NEED_CHECK -#endif + /*#endif*/ #else -#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM + /*#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM*/ #define NEED_CHECK -#endif + /*#endif*/ #endif #endif diff --git a/libguile/numbers.c b/libguile/numbers.c index 91e0359e5..0786697b6 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4415,9 +4415,7 @@ check_sanity () #ifdef HAVE_LONG_LONGS CHECK (long_long, 0LL); CHECK (ulong_long, 0ULL); - CHECK (long_long, -1LL); - CHECK (long_long, LLONG_MAX); CHECK (long_long, LLONG_MIN); CHECK (ulong_long, ULLONG_MAX); diff --git a/libguile/numbers.h b/libguile/numbers.h index e1dc39adc..023288ead 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -198,142 +198,142 @@ typedef struct scm_t_complex -extern SCM scm_exact_p (SCM x); -extern SCM scm_odd_p (SCM n); -extern SCM scm_even_p (SCM n); -extern SCM scm_abs (SCM x); -extern SCM scm_quotient (SCM x, SCM y); -extern SCM scm_remainder (SCM x, SCM y); -extern SCM scm_modulo (SCM x, SCM y); -extern SCM scm_gcd (SCM x, SCM y); -extern SCM scm_lcm (SCM n1, SCM n2); -extern SCM scm_logand (SCM n1, SCM n2); -extern SCM scm_logior (SCM n1, SCM n2); -extern SCM scm_logxor (SCM n1, SCM n2); -extern SCM scm_logtest (SCM n1, SCM n2); -extern SCM scm_logbit_p (SCM n1, SCM n2); -extern SCM scm_lognot (SCM n); -extern SCM scm_integer_expt (SCM z1, SCM z2); -extern SCM scm_ash (SCM n, SCM cnt); -extern SCM scm_bit_extract (SCM n, SCM start, SCM end); -extern SCM scm_logcount (SCM n); -extern SCM scm_integer_length (SCM n); -extern SCM scm_i_mkbig (size_t nlen, int sign); -extern SCM scm_i_big2inum (SCM b, size_t l); -extern SCM scm_i_adjbig (SCM b, size_t nlen); -extern SCM scm_i_normbig (SCM b); -extern SCM scm_i_copybig (SCM b, int sign); -extern SCM scm_i_short2big (short n); -extern SCM scm_i_ushort2big (unsigned short n); -extern SCM scm_i_int2big (int n); -extern SCM scm_i_uint2big (unsigned int n); -extern SCM scm_i_long2big (long n); -extern SCM scm_i_ulong2big (unsigned long n); -extern SCM scm_i_size2big (size_t n); -extern SCM scm_i_ptrdiff2big (ptrdiff_t n); +SCM_API SCM scm_exact_p (SCM x); +SCM_API SCM scm_odd_p (SCM n); +SCM_API SCM scm_even_p (SCM n); +SCM_API SCM scm_abs (SCM x); +SCM_API SCM scm_quotient (SCM x, SCM y); +SCM_API SCM scm_remainder (SCM x, SCM y); +SCM_API SCM scm_modulo (SCM x, SCM y); +SCM_API SCM scm_gcd (SCM x, SCM y); +SCM_API SCM scm_lcm (SCM n1, SCM n2); +SCM_API SCM scm_logand (SCM n1, SCM n2); +SCM_API SCM scm_logior (SCM n1, SCM n2); +SCM_API SCM scm_logxor (SCM n1, SCM n2); +SCM_API SCM scm_logtest (SCM n1, SCM n2); +SCM_API SCM scm_logbit_p (SCM n1, SCM n2); +SCM_API SCM scm_lognot (SCM n); +SCM_API SCM scm_integer_expt (SCM z1, SCM z2); +SCM_API SCM scm_ash (SCM n, SCM cnt); +SCM_API SCM scm_bit_extract (SCM n, SCM start, SCM end); +SCM_API SCM scm_logcount (SCM n); +SCM_API SCM scm_integer_length (SCM n); +SCM_API SCM scm_i_mkbig (size_t nlen, int sign); +SCM_API SCM scm_i_big2inum (SCM b, size_t l); +SCM_API SCM scm_i_adjbig (SCM b, size_t nlen); +SCM_API SCM scm_i_normbig (SCM b); +SCM_API SCM scm_i_copybig (SCM b, int sign); +SCM_API SCM scm_i_short2big (short n); +SCM_API SCM scm_i_ushort2big (unsigned short n); +SCM_API SCM scm_i_int2big (int n); +SCM_API SCM scm_i_uint2big (unsigned int n); +SCM_API SCM scm_i_long2big (long n); +SCM_API SCM scm_i_ulong2big (unsigned long n); +SCM_API SCM scm_i_size2big (size_t n); +SCM_API SCM scm_i_ptrdiff2big (ptrdiff_t n); #ifdef HAVE_LONG_LONGS -extern SCM scm_i_long_long2big (long long n); -extern SCM scm_i_ulong_long2big (unsigned long long n); +SCM_API SCM scm_i_long_long2big (long long n); +SCM_API SCM scm_i_ulong_long2big (unsigned long long n); #endif -extern int scm_bigcomp (SCM x, SCM y); -extern long scm_pseudolong (long x); -extern void scm_longdigs (long x, SCM_BIGDIG digs[]); -extern SCM scm_addbig (SCM_BIGDIG *x, size_t nx, int xsgn, SCM bigy, int sgny); -extern SCM scm_mulbig (SCM_BIGDIG *x, size_t nx, SCM_BIGDIG *y, size_t ny, int sgn); -extern unsigned int scm_divbigdig (SCM_BIGDIG *ds, size_t h, SCM_BIGDIG div); -extern size_t scm_iint2str (long num, int rad, char *p); -extern SCM scm_number_to_string (SCM x, SCM radix); -extern int scm_print_real (SCM sexp, SCM port, scm_print_state *pstate); -extern int scm_print_complex (SCM sexp, SCM port, scm_print_state *pstate); -extern int scm_bigprint (SCM exp, SCM port, scm_print_state *pstate); -extern SCM scm_i_mem2number (const char *mem, size_t len, unsigned int radix); -extern SCM scm_string_to_number (SCM str, SCM radix); -extern SCM scm_make_real (double x); -extern SCM scm_make_complex (double x, double y); -extern SCM scm_bigequal (SCM x, SCM y); -extern SCM scm_real_equalp (SCM x, SCM y); -extern SCM scm_complex_equalp (SCM x, SCM y); -extern SCM scm_number_p (SCM x); -extern SCM scm_real_p (SCM x); -extern SCM scm_integer_p (SCM x); -extern SCM scm_inexact_p (SCM x); -extern SCM scm_num_eq_p (SCM x, SCM y); -extern SCM scm_less_p (SCM x, SCM y); -extern SCM scm_gr_p (SCM x, SCM y); -extern SCM scm_leq_p (SCM x, SCM y); -extern SCM scm_geq_p (SCM x, SCM y); -extern SCM scm_zero_p (SCM z); -extern SCM scm_positive_p (SCM x); -extern SCM scm_negative_p (SCM x); -extern SCM scm_max (SCM x, SCM y); -extern SCM scm_min (SCM x, SCM y); -extern SCM scm_sum (SCM x, SCM y); -extern SCM scm_difference (SCM x, SCM y); -extern SCM scm_product (SCM x, SCM y); -extern double scm_num2dbl (SCM a, const char * why); -extern SCM scm_divide (SCM x, SCM y); -extern double scm_asinh (double x); -extern double scm_acosh (double x); -extern double scm_atanh (double x); -extern double scm_truncate (double x); -extern double scm_round (double x); -extern SCM scm_sys_expt (SCM z1, SCM z2); -extern SCM scm_sys_atan2 (SCM z1, SCM z2); -extern SCM scm_make_rectangular (SCM z1, SCM z2); -extern SCM scm_make_polar (SCM z1, SCM z2); -extern SCM scm_real_part (SCM z); -extern SCM scm_imag_part (SCM z); -extern SCM scm_magnitude (SCM z); -extern SCM scm_angle (SCM z); -extern SCM scm_exact_to_inexact (SCM z); -extern SCM scm_inexact_to_exact (SCM z); -extern SCM scm_trunc (SCM x); -extern SCM scm_i_dbl2big (double d); -extern double scm_i_big2dbl (SCM b); +SCM_API int scm_bigcomp (SCM x, SCM y); +SCM_API long scm_pseudolong (long x); +SCM_API void scm_longdigs (long x, SCM_BIGDIG digs[]); +SCM_API SCM scm_addbig (SCM_BIGDIG *x, size_t nx, int xsgn, SCM bigy, int sgny); +SCM_API SCM scm_mulbig (SCM_BIGDIG *x, size_t nx, SCM_BIGDIG *y, size_t ny, int sgn); +SCM_API unsigned int scm_divbigdig (SCM_BIGDIG *ds, size_t h, SCM_BIGDIG div); +SCM_API size_t scm_iint2str (long num, int rad, char *p); +SCM_API SCM scm_number_to_string (SCM x, SCM radix); +SCM_API int scm_print_real (SCM sexp, SCM port, scm_print_state *pstate); +SCM_API int scm_print_complex (SCM sexp, SCM port, scm_print_state *pstate); +SCM_API int scm_bigprint (SCM exp, SCM port, scm_print_state *pstate); +SCM_API SCM scm_i_mem2number (const char *mem, size_t len, unsigned int radix); +SCM_API SCM scm_string_to_number (SCM str, SCM radix); +SCM_API SCM scm_make_real (double x); +SCM_API SCM scm_make_complex (double x, double y); +SCM_API SCM scm_bigequal (SCM x, SCM y); +SCM_API SCM scm_real_equalp (SCM x, SCM y); +SCM_API SCM scm_complex_equalp (SCM x, SCM y); +SCM_API SCM scm_number_p (SCM x); +SCM_API SCM scm_real_p (SCM x); +SCM_API SCM scm_integer_p (SCM x); +SCM_API SCM scm_inexact_p (SCM x); +SCM_API SCM scm_num_eq_p (SCM x, SCM y); +SCM_API SCM scm_less_p (SCM x, SCM y); +SCM_API SCM scm_gr_p (SCM x, SCM y); +SCM_API SCM scm_leq_p (SCM x, SCM y); +SCM_API SCM scm_geq_p (SCM x, SCM y); +SCM_API SCM scm_zero_p (SCM z); +SCM_API SCM scm_positive_p (SCM x); +SCM_API SCM scm_negative_p (SCM x); +SCM_API SCM scm_max (SCM x, SCM y); +SCM_API SCM scm_min (SCM x, SCM y); +SCM_API SCM scm_sum (SCM x, SCM y); +SCM_API SCM scm_difference (SCM x, SCM y); +SCM_API SCM scm_product (SCM x, SCM y); +SCM_API double scm_num2dbl (SCM a, const char * why); +SCM_API SCM scm_divide (SCM x, SCM y); +SCM_API double scm_asinh (double x); +SCM_API double scm_acosh (double x); +SCM_API double scm_atanh (double x); +SCM_API double scm_truncate (double x); +SCM_API double scm_round (double x); +SCM_API SCM scm_sys_expt (SCM z1, SCM z2); +SCM_API SCM scm_sys_atan2 (SCM z1, SCM z2); +SCM_API SCM scm_make_rectangular (SCM z1, SCM z2); +SCM_API SCM scm_make_polar (SCM z1, SCM z2); +SCM_API SCM scm_real_part (SCM z); +SCM_API SCM scm_imag_part (SCM z); +SCM_API SCM scm_magnitude (SCM z); +SCM_API SCM scm_angle (SCM z); +SCM_API SCM scm_exact_to_inexact (SCM z); +SCM_API SCM scm_inexact_to_exact (SCM z); +SCM_API SCM scm_trunc (SCM x); +SCM_API SCM scm_i_dbl2big (double d); +SCM_API double scm_i_big2dbl (SCM b); -extern SCM scm_short2num (short n); -extern SCM scm_ushort2num (unsigned short n); -extern SCM scm_int2num (int n); -extern SCM scm_uint2num (unsigned int n); -extern SCM scm_long2num (long n); -extern SCM scm_ulong2num (unsigned long n); -extern SCM scm_size2num (size_t n); -extern SCM scm_ptrdiff2num (ptrdiff_t n); -extern short scm_num2short (SCM num, unsigned long int pos, - const char *s_caller); -extern unsigned short scm_num2ushort (SCM num, unsigned long int pos, - const char *s_caller); -extern int scm_num2int (SCM num, unsigned long int pos, - const char *s_caller); -extern unsigned int scm_num2uint (SCM num, unsigned long int pos, - const char *s_caller); -extern long scm_num2long (SCM num, unsigned long int pos, - const char *s_caller); -extern unsigned long scm_num2ulong (SCM num, unsigned long int pos, - const char *s_caller); -extern ptrdiff_t scm_num2ptrdiff (SCM num, unsigned long int pos, - const char *s_caller); -extern size_t scm_num2size (SCM num, unsigned long int pos, - const char *s_caller); +SCM_API SCM scm_short2num (short n); +SCM_API SCM scm_ushort2num (unsigned short n); +SCM_API SCM scm_int2num (int n); +SCM_API SCM scm_uint2num (unsigned int n); +SCM_API SCM scm_long2num (long n); +SCM_API SCM scm_ulong2num (unsigned long n); +SCM_API SCM scm_size2num (size_t n); +SCM_API SCM scm_ptrdiff2num (ptrdiff_t n); +SCM_API short scm_num2short (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API unsigned short scm_num2ushort (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API int scm_num2int (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API unsigned int scm_num2uint (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API long scm_num2long (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API unsigned long scm_num2ulong (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API ptrdiff_t scm_num2ptrdiff (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API size_t scm_num2size (SCM num, unsigned long int pos, + const char *s_caller); #ifdef HAVE_LONG_LONGS -extern SCM scm_long_long2num (long long sl); -extern SCM scm_ulong_long2num (unsigned long long sl); -extern long long scm_num2long_long (SCM num, unsigned long int pos, - const char *s_caller); -extern unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos, - const char *s_caller); +SCM_API SCM scm_long_long2num (long long sl); +SCM_API SCM scm_ulong_long2num (unsigned long long sl); +SCM_API long long scm_num2long_long (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos, + const char *s_caller); #endif -extern SCM scm_float2num (float n); -extern SCM scm_double2num (double n); -extern float scm_num2float (SCM num, unsigned long int pos, - const char *s_caller); -extern double scm_num2double (SCM num, unsigned long int pos, - const char *s_caller); +SCM_API SCM scm_float2num (float n); +SCM_API SCM scm_double2num (double n); +SCM_API float scm_num2float (SCM num, unsigned long int pos, + const char *s_caller); +SCM_API double scm_num2double (SCM num, unsigned long int pos, + const char *s_caller); -extern void scm_init_numbers (void); +SCM_API void scm_init_numbers (void); #endif /* SCM_NUMBERS_H */ diff --git a/libguile/objects.h b/libguile/objects.h index 26d39af61..a2d77a23d 100644 --- a/libguile/objects.h +++ b/libguile/objects.h @@ -198,48 +198,55 @@ typedef struct scm_effective_slot_definition { #define SCM_INOUT_PCLASS_INDEX 0x200 /* Plugin proxy classes for basic types. */ -extern SCM scm_metaclass_standard; -extern SCM scm_metaclass_operator; -extern SCM scm_class_boolean, scm_class_char, scm_class_pair; -extern SCM scm_class_procedure, scm_class_string, scm_class_symbol; -extern SCM scm_class_procedure_with_setter, scm_class_primitive_generic; -extern SCM scm_class_vector, scm_class_null; -extern SCM scm_class_real, scm_class_complex, scm_class_integer; -extern SCM scm_class_unknown; -extern SCM *scm_port_class; -extern SCM *scm_smob_class; +SCM_API SCM scm_metaclass_standard; +SCM_API SCM scm_metaclass_operator; +SCM_API SCM scm_class_boolean; +SCM_API SCM scm_class_char; +SCM_API SCM scm_class_pair; +SCM_API SCM scm_class_procedure; +SCM_API SCM scm_class_string; +SCM_API SCM scm_class_symbol; +SCM_API SCM scm_class_procedure_with_setter; +SCM_API SCM scm_class_primitive_generic; +SCM_API SCM scm_class_vector, scm_class_null; +SCM_API SCM scm_class_real; +SCM_API SCM scm_class_complex; +SCM_API SCM scm_class_integer; +SCM_API SCM scm_class_unknown; +SCM_API SCM *scm_port_class; +SCM_API SCM *scm_smob_class; -extern SCM scm_no_applicable_method; +SCM_API SCM scm_no_applicable_method; /* Goops functions. */ -extern SCM scm_make_extended_class (char *type_name); -extern void scm_make_port_classes (long ptobnum, char *type_name); -extern void scm_change_object_class (SCM, SCM, SCM); -extern SCM scm_memoize_method (SCM x, SCM args); +SCM_API SCM scm_make_extended_class (char *type_name); +SCM_API void scm_make_port_classes (long ptobnum, char *type_name); +SCM_API void scm_change_object_class (SCM, SCM, SCM); +SCM_API SCM scm_memoize_method (SCM x, SCM args); -extern SCM scm_class_of (SCM obj); -extern SCM scm_mcache_lookup_cmethod (SCM cache, SCM args); -extern SCM scm_mcache_compute_cmethod (SCM cache, SCM args); +SCM_API SCM scm_class_of (SCM obj); +SCM_API SCM scm_mcache_lookup_cmethod (SCM cache, SCM args); +SCM_API SCM scm_mcache_compute_cmethod (SCM cache, SCM args); /* The following are declared in __scm.h -extern SCM scm_call_generic_0 (SCM gf); -extern SCM scm_call_generic_1 (SCM gf, SCM a1); -extern SCM scm_call_generic_2 (SCM gf, SCM a1, SCM a2); -extern SCM scm_apply_generic (SCM gf, SCM args); +SCM_API SCM scm_call_generic_0 (SCM gf); +SCM_API SCM scm_call_generic_1 (SCM gf, SCM a1); +SCM_API SCM scm_call_generic_2 (SCM gf, SCM a1, SCM a2); +SCM_API SCM scm_apply_generic (SCM gf, SCM args); */ -extern SCM scm_call_generic_3 (SCM gf, SCM a1, SCM a2, SCM a3); -extern SCM scm_entity_p (SCM obj); -extern SCM scm_operator_p (SCM obj); -extern SCM scm_valid_object_procedure_p (SCM proc); -extern SCM scm_set_object_procedure_x (SCM obj, SCM proc); +SCM_API SCM scm_call_generic_3 (SCM gf, SCM a1, SCM a2, SCM a3); +SCM_API SCM scm_entity_p (SCM obj); +SCM_API SCM scm_operator_p (SCM obj); +SCM_API SCM scm_valid_object_procedure_p (SCM proc); +SCM_API SCM scm_set_object_procedure_x (SCM obj, SCM proc); #ifdef GUILE_DEBUG -extern SCM scm_object_procedure (SCM obj); +SCM_API SCM scm_object_procedure (SCM obj); #endif -extern SCM scm_make_class_object (SCM metaclass, SCM layout); -extern SCM scm_make_subclass_object (SCM c, SCM layout); +SCM_API SCM scm_make_class_object (SCM metaclass, SCM layout); +SCM_API SCM scm_make_subclass_object (SCM c, SCM layout); -extern SCM scm_i_make_class_object (SCM metaclass, SCM layout_string, - unsigned long flags); -extern void scm_init_objects (void); +SCM_API SCM scm_i_make_class_object (SCM metaclass, SCM layout_string, + unsigned long flags); +SCM_API void scm_init_objects (void); #endif /* SCM_OBJECTS_H */ diff --git a/libguile/objprop.h b/libguile/objprop.h index 82afc2534..b3adc7a18 100644 --- a/libguile/objprop.h +++ b/libguile/objprop.h @@ -50,11 +50,11 @@ -extern SCM scm_object_properties (SCM obj); -extern SCM scm_set_object_properties_x (SCM obj, SCM plist); -extern SCM scm_object_property (SCM obj, SCM key); -extern SCM scm_set_object_property_x (SCM obj, SCM key, SCM val); -extern void scm_init_objprop (void); +SCM_API SCM scm_object_properties (SCM obj); +SCM_API SCM scm_set_object_properties_x (SCM obj, SCM plist); +SCM_API SCM scm_object_property (SCM obj, SCM key); +SCM_API SCM scm_set_object_property_x (SCM obj, SCM key, SCM val); +SCM_API void scm_init_objprop (void); #endif /* SCM_OBJPROP_H */ diff --git a/libguile/options.h b/libguile/options.h index 3ab28cb69..79b7883cc 100644 --- a/libguile/options.h +++ b/libguile/options.h @@ -67,9 +67,9 @@ typedef struct scm_t_option #define SCM_OPTION_SCM 2 -extern SCM scm_options (SCM, scm_t_option [], unsigned int, const char*); -extern void scm_init_opts (SCM (*) (SCM), scm_t_option [], unsigned int n); -extern void scm_init_options (void); +SCM_API SCM scm_options (SCM, scm_t_option [], unsigned int, const char*); +SCM_API void scm_init_opts (SCM (*) (SCM), scm_t_option [], unsigned int n); +SCM_API void scm_init_options (void); #endif /* SCM_OPTIONS_H */ diff --git a/libguile/pairs.h b/libguile/pairs.h index 2149b3918..98b0854d6 100644 --- a/libguile/pairs.h +++ b/libguile/pairs.h @@ -101,14 +101,14 @@ #if (SCM_DEBUG_PAIR_ACCESSES == 1) -extern void scm_error_pair_access (SCM); +SCM_API void scm_error_pair_access (SCM); #endif -extern SCM scm_cons (SCM x, SCM y); -extern SCM scm_cons2 (SCM w, SCM x, SCM y); -extern SCM scm_pair_p (SCM x); -extern SCM scm_set_car_x (SCM pair, SCM value); -extern SCM scm_set_cdr_x (SCM pair, SCM value); -extern void scm_init_pairs (void); +SCM_API SCM scm_cons (SCM x, SCM y); +SCM_API SCM scm_cons2 (SCM w, SCM x, SCM y); +SCM_API SCM scm_pair_p (SCM x); +SCM_API SCM scm_set_car_x (SCM pair, SCM value); +SCM_API SCM scm_set_cdr_x (SCM pair, SCM value); +SCM_API void scm_init_pairs (void); #endif /* SCM_PAIRS_H */ diff --git a/libguile/ports.h b/libguile/ports.h index b0d97fd1e..e9a1af950 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -132,8 +132,8 @@ typedef struct size_t putback_buf_size; /* allocated size of putback_buf. */ } scm_t_port; -extern scm_t_port **scm_port_table; -extern long scm_port_table_size; /* Number of ports in scm_port_table. */ +SCM_API scm_t_port **scm_port_table; +SCM_API long scm_port_table_size; /* Number of ports in scm_port_table. */ #define SCM_READ_BUFFER_EMPTY_P(c_port) (c_port->read_pos >= c_port->read_end) @@ -213,105 +213,105 @@ typedef struct scm_t_ptob_descriptor -extern scm_t_ptob_descriptor *scm_ptobs; -extern long scm_numptob; -extern long scm_port_table_room; +SCM_API scm_t_ptob_descriptor *scm_ptobs; +SCM_API long scm_numptob; +SCM_API long scm_port_table_room; -extern SCM scm_markstream (SCM ptr); -extern scm_t_bits scm_make_port_type (char *name, - int (*fill_input) (SCM port), - void (*write) (SCM port, - const void *data, - size_t size)); -extern void scm_set_port_mark (long tc, SCM (*mark) (SCM)); -extern void scm_set_port_free (long tc, size_t (*free) (SCM)); -extern void scm_set_port_print (long tc, - int (*print) (SCM exp, - SCM port, - scm_print_state *pstate)); -extern void scm_set_port_equalp (long tc, SCM (*equalp) (SCM, SCM)); -extern void scm_set_port_close (long tc, int (*close) (SCM)); +SCM_API SCM scm_markstream (SCM ptr); +SCM_API scm_t_bits scm_make_port_type (char *name, + int (*fill_input) (SCM port), + void (*write) (SCM port, + const void *data, + size_t size)); +SCM_API void scm_set_port_mark (long tc, SCM (*mark) (SCM)); +SCM_API void scm_set_port_free (long tc, size_t (*free) (SCM)); +SCM_API void scm_set_port_print (long tc, + int (*print) (SCM exp, + SCM port, + scm_print_state *pstate)); +SCM_API void scm_set_port_equalp (long tc, SCM (*equalp) (SCM, SCM)); +SCM_API void scm_set_port_close (long tc, int (*close) (SCM)); -extern void scm_set_port_flush (long tc, - void (*flush) (SCM port)); -extern void scm_set_port_end_input (long tc, - void (*end_input) (SCM port, - int offset)); -extern void scm_set_port_seek (long tc, - off_t (*seek) (SCM port, - off_t OFFSET, - int WHENCE)); -extern void scm_set_port_truncate (long tc, - void (*truncate) (SCM port, - off_t length)); -extern void scm_set_port_input_waiting (long tc, int (*input_waiting) (SCM)); -extern SCM scm_char_ready_p (SCM port); +SCM_API void scm_set_port_flush (long tc, + void (*flush) (SCM port)); +SCM_API void scm_set_port_end_input (long tc, + void (*end_input) (SCM port, + int offset)); +SCM_API void scm_set_port_seek (long tc, + off_t (*seek) (SCM port, + off_t OFFSET, + int WHENCE)); +SCM_API void scm_set_port_truncate (long tc, + void (*truncate) (SCM port, + off_t length)); +SCM_API void scm_set_port_input_waiting (long tc, int (*input_waiting) (SCM)); +SCM_API SCM scm_char_ready_p (SCM port); size_t scm_take_from_input_buffers (SCM port, char *dest, size_t read_len); -extern SCM scm_drain_input (SCM port); -extern SCM scm_current_input_port (void); -extern SCM scm_current_output_port (void); -extern SCM scm_current_error_port (void); -extern SCM scm_current_load_port (void); -extern SCM scm_set_current_input_port (SCM port); -extern SCM scm_set_current_output_port (SCM port); -extern SCM scm_set_current_error_port (SCM port); -extern scm_t_port * scm_add_to_port_table (SCM port); -extern void scm_remove_from_port_table (SCM port); -extern void scm_grow_port_cbuf (SCM port, size_t requested); -extern SCM scm_pt_size (void); -extern SCM scm_pt_member (SCM member); -extern void scm_port_non_buffer (scm_t_port *pt); -extern int scm_revealed_count (SCM port); -extern SCM scm_port_revealed (SCM port); -extern SCM scm_set_port_revealed_x (SCM port, SCM rcount); -extern long scm_mode_bits (char *modes); -extern SCM scm_port_mode (SCM port); -extern SCM scm_close_input_port (SCM port); -extern SCM scm_close_output_port (SCM port); -extern SCM scm_close_port (SCM port); -extern SCM scm_port_for_each (SCM proc); -extern SCM scm_input_port_p (SCM x); -extern SCM scm_output_port_p (SCM x); -extern SCM scm_port_p (SCM x); -extern SCM scm_port_closed_p (SCM port); -extern SCM scm_eof_object_p (SCM x); -extern SCM scm_force_output (SCM port); -extern SCM scm_flush_all_ports (void); -extern SCM scm_read_char (SCM port); -extern void scm_putc (char c, SCM port); -extern void scm_puts (const char *str_data, SCM port); -extern size_t scm_c_read (SCM port, void *buffer, size_t size); -extern void scm_c_write (SCM port, const void *buffer, size_t size); -extern void scm_lfwrite (const char *ptr, size_t size, SCM port); -extern void scm_flush (SCM port); -extern void scm_end_input (SCM port); -extern int scm_fill_input (SCM port); -extern int scm_getc (SCM port); -extern void scm_ungetc (int c, SCM port); -extern void scm_ungets (const char *s, int n, SCM port); -extern SCM scm_peek_char (SCM port); -extern SCM scm_unread_char (SCM cobj, SCM port); -extern SCM scm_unread_string (SCM str, SCM port); -extern SCM scm_seek (SCM object, SCM offset, SCM whence); -extern SCM scm_truncate_file (SCM object, SCM length); -extern SCM scm_port_line (SCM port); -extern SCM scm_set_port_line_x (SCM port, SCM line); -extern SCM scm_port_column (SCM port); -extern SCM scm_set_port_column_x (SCM port, SCM line); -extern SCM scm_port_filename (SCM port); -extern SCM scm_set_port_filename_x (SCM port, SCM filename); -extern int scm_port_print (SCM exp, SCM port, scm_print_state *); -extern void scm_print_port_mode (SCM exp, SCM port); -extern void scm_ports_prehistory (void); -extern SCM scm_void_port (char * mode_str); -extern SCM scm_sys_make_void_port (SCM mode); -extern void scm_init_ports (void); +SCM_API SCM scm_drain_input (SCM port); +SCM_API SCM scm_current_input_port (void); +SCM_API SCM scm_current_output_port (void); +SCM_API SCM scm_current_error_port (void); +SCM_API SCM scm_current_load_port (void); +SCM_API SCM scm_set_current_input_port (SCM port); +SCM_API SCM scm_set_current_output_port (SCM port); +SCM_API SCM scm_set_current_error_port (SCM port); +SCM_API scm_t_port * scm_add_to_port_table (SCM port); +SCM_API void scm_remove_from_port_table (SCM port); +SCM_API void scm_grow_port_cbuf (SCM port, size_t requested); +SCM_API SCM scm_pt_size (void); +SCM_API SCM scm_pt_member (SCM member); +SCM_API void scm_port_non_buffer (scm_t_port *pt); +SCM_API int scm_revealed_count (SCM port); +SCM_API SCM scm_port_revealed (SCM port); +SCM_API SCM scm_set_port_revealed_x (SCM port, SCM rcount); +SCM_API long scm_mode_bits (char *modes); +SCM_API SCM scm_port_mode (SCM port); +SCM_API SCM scm_close_input_port (SCM port); +SCM_API SCM scm_close_output_port (SCM port); +SCM_API SCM scm_close_port (SCM port); +SCM_API SCM scm_port_for_each (SCM proc); +SCM_API SCM scm_input_port_p (SCM x); +SCM_API SCM scm_output_port_p (SCM x); +SCM_API SCM scm_port_p (SCM x); +SCM_API SCM scm_port_closed_p (SCM port); +SCM_API SCM scm_eof_object_p (SCM x); +SCM_API SCM scm_force_output (SCM port); +SCM_API SCM scm_flush_all_ports (void); +SCM_API SCM scm_read_char (SCM port); +SCM_API void scm_putc (char c, SCM port); +SCM_API void scm_puts (const char *str_data, SCM port); +SCM_API size_t scm_c_read (SCM port, void *buffer, size_t size); +SCM_API void scm_c_write (SCM port, const void *buffer, size_t size); +SCM_API void scm_lfwrite (const char *ptr, size_t size, SCM port); +SCM_API void scm_flush (SCM port); +SCM_API void scm_end_input (SCM port); +SCM_API int scm_fill_input (SCM port); +SCM_API int scm_getc (SCM port); +SCM_API void scm_ungetc (int c, SCM port); +SCM_API void scm_ungets (const char *s, int n, SCM port); +SCM_API SCM scm_peek_char (SCM port); +SCM_API SCM scm_unread_char (SCM cobj, SCM port); +SCM_API SCM scm_unread_string (SCM str, SCM port); +SCM_API SCM scm_seek (SCM object, SCM offset, SCM whence); +SCM_API SCM scm_truncate_file (SCM object, SCM length); +SCM_API SCM scm_port_line (SCM port); +SCM_API SCM scm_set_port_line_x (SCM port, SCM line); +SCM_API SCM scm_port_column (SCM port); +SCM_API SCM scm_set_port_column_x (SCM port, SCM line); +SCM_API SCM scm_port_filename (SCM port); +SCM_API SCM scm_set_port_filename_x (SCM port, SCM filename); +SCM_API int scm_port_print (SCM exp, SCM port, scm_print_state *); +SCM_API void scm_print_port_mode (SCM exp, SCM port); +SCM_API void scm_ports_prehistory (void); +SCM_API SCM scm_void_port (char * mode_str); +SCM_API SCM scm_sys_make_void_port (SCM mode); +SCM_API void scm_init_ports (void); #ifdef GUILE_DEBUG -extern SCM scm_pt_size (void); -extern SCM scm_pt_member (SCM member); +SCM_API SCM scm_pt_size (void); +SCM_API SCM scm_pt_member (SCM member); #endif /* GUILE_DEBUG */ #endif /* SCM_PORTS_H */ diff --git a/libguile/posix.h b/libguile/posix.h index 9f67baa25..c6b1f09fb 100644 --- a/libguile/posix.h +++ b/libguile/posix.h @@ -53,62 +53,62 @@ -extern SCM scm_tcsetpgrp (SCM port, SCM pgid); -extern SCM scm_tcgetpgrp (SCM port); -extern SCM scm_ctermid (void); -extern SCM scm_setsid (void); -extern SCM scm_setpgid (SCM pid, SCM pgid); -extern SCM scm_pipe (void); -extern SCM scm_getgroups (void); -extern SCM scm_getpgrp (void); -extern SCM scm_getpwuid (SCM user); -extern SCM scm_setpwent (SCM arg); -extern SCM scm_getgrgid (SCM name); -extern SCM scm_setgrent (SCM arg); -extern SCM scm_kill (SCM pid, SCM sig); -extern SCM scm_waitpid (SCM pid, SCM options); -extern SCM scm_status_exit_val (SCM status); -extern SCM scm_status_term_sig (SCM status); -extern SCM scm_status_stop_sig (SCM status); -extern SCM scm_getppid (void); -extern SCM scm_getuid (void); -extern SCM scm_getgid (void); -extern SCM scm_geteuid (void); -extern SCM scm_getegid (void); -extern SCM scm_setuid (SCM id); -extern SCM scm_setgid (SCM id); -extern SCM scm_seteuid (SCM id); -extern SCM scm_setegid (SCM id); -extern SCM scm_ttyname (SCM port); -extern SCM scm_execl (SCM filename, SCM args); -extern SCM scm_execlp (SCM filename, SCM args); -extern SCM scm_execle (SCM filename, SCM env, SCM args); -extern SCM scm_fork (void); -extern SCM scm_uname (void); -extern SCM scm_environ (SCM env); -extern SCM scm_tmpnam (void); -extern SCM scm_mkstemp (SCM tmpl); -extern SCM scm_open_pipe (SCM pipestr, SCM modes); -extern SCM scm_close_pipe (SCM port); -extern SCM scm_utime (SCM pathname, SCM actime, SCM modtime); -extern SCM scm_access (SCM path, SCM how); -extern SCM scm_getpid (void); -extern SCM scm_putenv (SCM str); -extern SCM scm_setlocale (SCM category, SCM locale); -extern SCM scm_mknod (SCM path, SCM type, SCM perms, SCM dev); -extern SCM scm_nice (SCM incr); -extern SCM scm_sync (void); -extern SCM scm_crypt (SCM key, SCM salt); -extern SCM scm_chroot (SCM path); -extern SCM scm_getlogin (void); -extern SCM scm_cuserid (void); -extern SCM scm_getpriority (SCM which, SCM who); -extern SCM scm_setpriority (SCM which, SCM who, SCM prio); -extern SCM scm_getpass (SCM prompt); -extern SCM scm_flock (SCM file, SCM operation); -extern SCM scm_sethostname (SCM name); -extern SCM scm_gethostname (void); -extern void scm_init_posix (void); +SCM_API SCM scm_tcsetpgrp (SCM port, SCM pgid); +SCM_API SCM scm_tcgetpgrp (SCM port); +SCM_API SCM scm_ctermid (void); +SCM_API SCM scm_setsid (void); +SCM_API SCM scm_setpgid (SCM pid, SCM pgid); +SCM_API SCM scm_pipe (void); +SCM_API SCM scm_getgroups (void); +SCM_API SCM scm_getpgrp (void); +SCM_API SCM scm_getpwuid (SCM user); +SCM_API SCM scm_setpwent (SCM arg); +SCM_API SCM scm_getgrgid (SCM name); +SCM_API SCM scm_setgrent (SCM arg); +SCM_API SCM scm_kill (SCM pid, SCM sig); +SCM_API SCM scm_waitpid (SCM pid, SCM options); +SCM_API SCM scm_status_exit_val (SCM status); +SCM_API SCM scm_status_term_sig (SCM status); +SCM_API SCM scm_status_stop_sig (SCM status); +SCM_API SCM scm_getppid (void); +SCM_API SCM scm_getuid (void); +SCM_API SCM scm_getgid (void); +SCM_API SCM scm_geteuid (void); +SCM_API SCM scm_getegid (void); +SCM_API SCM scm_setuid (SCM id); +SCM_API SCM scm_setgid (SCM id); +SCM_API SCM scm_seteuid (SCM id); +SCM_API SCM scm_setegid (SCM id); +SCM_API SCM scm_ttyname (SCM port); +SCM_API SCM scm_execl (SCM filename, SCM args); +SCM_API SCM scm_execlp (SCM filename, SCM args); +SCM_API SCM scm_execle (SCM filename, SCM env, SCM args); +SCM_API SCM scm_fork (void); +SCM_API SCM scm_uname (void); +SCM_API SCM scm_environ (SCM env); +SCM_API SCM scm_tmpnam (void); +SCM_API SCM scm_mkstemp (SCM tmpl); +SCM_API SCM scm_open_pipe (SCM pipestr, SCM modes); +SCM_API SCM scm_close_pipe (SCM port); +SCM_API SCM scm_utime (SCM pathname, SCM actime, SCM modtime); +SCM_API SCM scm_access (SCM path, SCM how); +SCM_API SCM scm_getpid (void); +SCM_API SCM scm_putenv (SCM str); +SCM_API SCM scm_setlocale (SCM category, SCM locale); +SCM_API SCM scm_mknod (SCM path, SCM type, SCM perms, SCM dev); +SCM_API SCM scm_nice (SCM incr); +SCM_API SCM scm_sync (void); +SCM_API SCM scm_crypt (SCM key, SCM salt); +SCM_API SCM scm_chroot (SCM path); +SCM_API SCM scm_getlogin (void); +SCM_API SCM scm_cuserid (void); +SCM_API SCM scm_getpriority (SCM which, SCM who); +SCM_API SCM scm_setpriority (SCM which, SCM who, SCM prio); +SCM_API SCM scm_getpass (SCM prompt); +SCM_API SCM scm_flock (SCM file, SCM operation); +SCM_API SCM scm_sethostname (SCM name); +SCM_API SCM scm_gethostname (void); +SCM_API void scm_init_posix (void); #endif /* SCM_POSIX_H */ diff --git a/libguile/print.h b/libguile/print.h index 754f307b1..9ac0916bb 100644 --- a/libguile/print.h +++ b/libguile/print.h @@ -50,7 +50,7 @@ #include "libguile/options.h" -extern scm_t_option scm_print_opts[]; +SCM_API scm_t_option scm_print_opts[]; #define SCM_PRINT_CLOSURE (SCM_PACK (scm_print_opts[0].val)) #define SCM_PRINT_SOURCE_P ((int) scm_print_opts[1].val) @@ -96,32 +96,32 @@ typedef struct scm_print_state { SCM ref_vect; } scm_print_state; -extern SCM scm_print_state_vtable; +SCM_API SCM scm_print_state_vtable; -extern scm_t_bits scm_tc16_port_with_ps; +SCM_API scm_t_bits scm_tc16_port_with_ps; -extern SCM scm_print_options (SCM setting); -SCM scm_make_print_state (void); -void scm_free_print_state (SCM print_state); -extern void scm_intprint (long n, int radix, SCM port); -extern void scm_ipruk (char *hdr, SCM ptr, SCM port); -extern void scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate); -extern void scm_print_symbol_name (const char *str, size_t len, SCM port); -extern void scm_prin1 (SCM exp, SCM port, int writingp); -extern void scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate); -extern SCM scm_write (SCM obj, SCM port); -extern SCM scm_display (SCM obj, SCM port); -extern SCM scm_simple_format (SCM port, SCM message, SCM args); -extern SCM scm_newline (SCM port); -extern SCM scm_write_char (SCM chr, SCM port); -extern SCM scm_printer_apply (SCM proc, SCM exp, SCM port, scm_print_state *); -extern SCM scm_port_with_print_state (SCM port, SCM pstate); -extern SCM scm_get_print_state (SCM port); -extern int scm_valid_oport_value_p (SCM val); -extern void scm_init_print (void); +SCM_API SCM scm_print_options (SCM setting); +SCM_API SCM scm_make_print_state (void); +SCM_API void scm_free_print_state (SCM print_state); +SCM_API void scm_intprint (long n, int radix, SCM port); +SCM_API void scm_ipruk (char *hdr, SCM ptr, SCM port); +SCM_API void scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate); +SCM_API void scm_print_symbol_name (const char *str, size_t len, SCM port); +SCM_API void scm_prin1 (SCM exp, SCM port, int writingp); +SCM_API void scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate); +SCM_API SCM scm_write (SCM obj, SCM port); +SCM_API SCM scm_display (SCM obj, SCM port); +SCM_API SCM scm_simple_format (SCM port, SCM message, SCM args); +SCM_API SCM scm_newline (SCM port); +SCM_API SCM scm_write_char (SCM chr, SCM port); +SCM_API SCM scm_printer_apply (SCM proc, SCM exp, SCM port, scm_print_state *); +SCM_API SCM scm_port_with_print_state (SCM port, SCM pstate); +SCM_API SCM scm_get_print_state (SCM port); +SCM_API int scm_valid_oport_value_p (SCM val); +SCM_API void scm_init_print (void); #ifdef GUILE_DEBUG -extern SCM scm_current_pstate (void); +SCM_API SCM scm_current_pstate (void); #endif #endif /* SCM_PRINT_H */ diff --git a/libguile/procprop.h b/libguile/procprop.h index f5db1d4bf..e72bd4473 100644 --- a/libguile/procprop.h +++ b/libguile/procprop.h @@ -50,18 +50,18 @@ -extern SCM scm_sym_name; -extern SCM scm_sym_arity; -extern SCM scm_sym_system_procedure; +SCM_API SCM scm_sym_name; +SCM_API SCM scm_sym_arity; +SCM_API SCM scm_sym_system_procedure; -extern SCM scm_i_procedure_arity (SCM proc); -extern SCM scm_procedure_properties (SCM proc); -extern SCM scm_set_procedure_properties_x (SCM proc, SCM new_val); -extern SCM scm_procedure_property (SCM p, SCM k); -extern SCM scm_set_procedure_property_x (SCM p, SCM k, SCM v); -extern void scm_init_procprop (void); +SCM_API SCM scm_i_procedure_arity (SCM proc); +SCM_API SCM scm_procedure_properties (SCM proc); +SCM_API SCM scm_set_procedure_properties_x (SCM proc, SCM new_val); +SCM_API SCM scm_procedure_property (SCM p, SCM k); +SCM_API SCM scm_set_procedure_property_x (SCM p, SCM k, SCM v); +SCM_API void scm_init_procprop (void); #endif /* SCM_PROCPROP_H */ diff --git a/libguile/procs.h b/libguile/procs.h index 0cb2586dc..90ecb5c72 100644 --- a/libguile/procs.h +++ b/libguile/procs.h @@ -152,35 +152,35 @@ typedef struct #define SCM_PROCEDURE(obj) SCM_CELL_OBJECT_1 (obj) #define SCM_SETTER(obj) SCM_CELL_OBJECT_2 (obj) -extern scm_t_subr_entry *scm_subr_table; -extern long scm_subr_table_size; -extern long scm_subr_table_room; +SCM_API scm_t_subr_entry *scm_subr_table; +SCM_API long scm_subr_table_size; +SCM_API long scm_subr_table_room; -extern void scm_mark_subr_table (void); -extern void scm_free_subr_entry (SCM subr); -extern SCM scm_c_make_subr (const char *name, long type, SCM (*fcn)()); -extern SCM scm_c_make_subr_with_generic (const char *name, long type, - SCM (*fcn)(), SCM *gf); -extern SCM scm_c_define_subr (const char *name, long type, SCM (*fcn)()); -extern SCM scm_c_define_subr_with_generic (const char *name, long type, - SCM (*fcn)(), SCM *gf); -extern SCM scm_makcclo (SCM proc, size_t len); -extern SCM scm_procedure_p (SCM obj); -extern SCM scm_closure_p (SCM obj); -extern SCM scm_thunk_p (SCM obj); -extern int scm_subr_p (SCM obj); -extern SCM scm_procedure_documentation (SCM proc); -extern SCM scm_procedure_with_setter_p (SCM obj); -extern SCM scm_make_procedure_with_setter (SCM procedure, SCM setter); -extern SCM scm_procedure (SCM proc); -extern SCM scm_setter (SCM proc); -extern void scm_init_subr_table (void); -extern void scm_init_procs (void); +SCM_API void scm_mark_subr_table (void); +SCM_API void scm_free_subr_entry (SCM subr); +SCM_API SCM scm_c_make_subr (const char *name, long type, SCM (*fcn)()); +SCM_API SCM scm_c_make_subr_with_generic (const char *name, long type, + SCM (*fcn)(), SCM *gf); +SCM_API SCM scm_c_define_subr (const char *name, long type, SCM (*fcn)()); +SCM_API SCM scm_c_define_subr_with_generic (const char *name, long type, + SCM (*fcn)(), SCM *gf); +SCM_API SCM scm_makcclo (SCM proc, size_t len); +SCM_API SCM scm_procedure_p (SCM obj); +SCM_API SCM scm_closure_p (SCM obj); +SCM_API SCM scm_thunk_p (SCM obj); +SCM_API int scm_subr_p (SCM obj); +SCM_API SCM scm_procedure_documentation (SCM proc); +SCM_API SCM scm_procedure_with_setter_p (SCM obj); +SCM_API SCM scm_make_procedure_with_setter (SCM procedure, SCM setter); +SCM_API SCM scm_procedure (SCM proc); +SCM_API SCM scm_setter (SCM proc); +SCM_API void scm_init_subr_table (void); +SCM_API void scm_init_procs (void); #ifdef GUILE_DEBUG -extern SCM scm_make_cclo (SCM proc, SCM len); +SCM_API SCM scm_make_cclo (SCM proc, SCM len); #endif /*GUILE_DEBUG*/ #endif /* SCM_PROCS_H */ diff --git a/libguile/properties.h b/libguile/properties.h index 2c59c03d0..456cf4551 100644 --- a/libguile/properties.h +++ b/libguile/properties.h @@ -48,12 +48,12 @@ #include "libguile/__scm.h" -SCM scm_primitive_make_property (SCM not_found_proc); -SCM scm_primitive_property_ref (SCM prop, SCM obj); -SCM scm_primitive_property_set_x (SCM prop, SCM obj, SCM val); -SCM scm_primitive_property_del_x (SCM prop, SCM obj); +SCM_API SCM scm_primitive_make_property (SCM not_found_proc); +SCM_API SCM scm_primitive_property_ref (SCM prop, SCM obj); +SCM_API SCM scm_primitive_property_set_x (SCM prop, SCM obj, SCM val); +SCM_API SCM scm_primitive_property_del_x (SCM prop, SCM obj); -void scm_init_properties (void); +SCM_API void scm_init_properties (void); #endif /* SCM_PROPERTIES_H */ diff --git a/libguile/ramap.h b/libguile/ramap.h index c9c4e17c0..d52133c40 100644 --- a/libguile/ramap.h +++ b/libguile/ramap.h @@ -50,28 +50,28 @@ -extern int scm_ra_matchp (SCM ra0, SCM ras); -extern int scm_ramapc (int (*cproc) (), SCM data, SCM ra0, SCM lra, - const char *what); -extern int scm_array_fill_int (SCM ra, SCM fill, SCM ignore); -extern SCM scm_array_fill_x (SCM ra, SCM fill); -extern SCM scm_array_copy_x (SCM src, SCM dst); -extern int scm_ra_eqp (SCM ra0, SCM ras); -extern int scm_ra_lessp (SCM ra0, SCM ras); -extern int scm_ra_leqp (SCM ra0, SCM ras); -extern int scm_ra_grp (SCM ra0, SCM ras); -extern int scm_ra_greqp (SCM ra0, SCM ras); -extern int scm_ra_sum (SCM ra0, SCM ras); -extern int scm_ra_difference (SCM ra0, SCM ras); -extern int scm_ra_product (SCM ra0, SCM ras); -extern int scm_ra_divide (SCM ra0, SCM ras); -extern int scm_array_identity (SCM src, SCM dst); -extern SCM scm_array_map_x (SCM ra0, SCM proc, SCM lra); -extern SCM scm_array_for_each (SCM proc, SCM ra0, SCM lra); -extern SCM scm_array_index_map_x (SCM ra, SCM proc); -extern SCM scm_raequal (SCM ra0, SCM ra1); -extern SCM scm_array_equal_p (SCM ra0, SCM ra1); -extern void scm_init_ramap (void); +SCM_API int scm_ra_matchp (SCM ra0, SCM ras); +SCM_API int scm_ramapc (int (*cproc) (), SCM data, SCM ra0, SCM lra, + const char *what); +SCM_API int scm_array_fill_int (SCM ra, SCM fill, SCM ignore); +SCM_API SCM scm_array_fill_x (SCM ra, SCM fill); +SCM_API SCM scm_array_copy_x (SCM src, SCM dst); +SCM_API int scm_ra_eqp (SCM ra0, SCM ras); +SCM_API int scm_ra_lessp (SCM ra0, SCM ras); +SCM_API int scm_ra_leqp (SCM ra0, SCM ras); +SCM_API int scm_ra_grp (SCM ra0, SCM ras); +SCM_API int scm_ra_greqp (SCM ra0, SCM ras); +SCM_API int scm_ra_sum (SCM ra0, SCM ras); +SCM_API int scm_ra_difference (SCM ra0, SCM ras); +SCM_API int scm_ra_product (SCM ra0, SCM ras); +SCM_API int scm_ra_divide (SCM ra0, SCM ras); +SCM_API int scm_array_identity (SCM src, SCM dst); +SCM_API SCM scm_array_map_x (SCM ra0, SCM proc, SCM lra); +SCM_API SCM scm_array_for_each (SCM proc, SCM ra0, SCM lra); +SCM_API SCM scm_array_index_map_x (SCM ra, SCM proc); +SCM_API SCM scm_raequal (SCM ra0, SCM ra1); +SCM_API SCM scm_array_equal_p (SCM ra0, SCM ra1); +SCM_API void scm_init_ramap (void); #endif /* SCM_RAMAP_H */ diff --git a/libguile/random.h b/libguile/random.h index 1de0380ed..410ad1a19 100644 --- a/libguile/random.h +++ b/libguile/random.h @@ -74,7 +74,7 @@ typedef struct scm_t_rng { scm_t_rstate *(*copy_rstate) (scm_t_rstate *state); } scm_t_rng; -extern scm_t_rng scm_the_rng; +SCM_API scm_t_rng scm_the_rng; /* @@ -86,44 +86,44 @@ typedef struct scm_t_i_rstate { unsigned long c; } scm_t_i_rstate; -extern unsigned long scm_i_uniform32 (scm_t_i_rstate *); -extern void scm_i_init_rstate (scm_t_i_rstate *, char *seed, int n); -extern scm_t_i_rstate *scm_i_copy_rstate (scm_t_i_rstate *); +SCM_API unsigned long scm_i_uniform32 (scm_t_i_rstate *); +SCM_API void scm_i_init_rstate (scm_t_i_rstate *, char *seed, int n); +SCM_API scm_t_i_rstate *scm_i_copy_rstate (scm_t_i_rstate *); /* * Random number library functions */ -extern scm_t_rstate *scm_c_make_rstate (char *, int); -extern scm_t_rstate *scm_c_default_rstate (void); +SCM_API scm_t_rstate *scm_c_make_rstate (char *, int); +SCM_API scm_t_rstate *scm_c_default_rstate (void); #define scm_c_uniform32(RSTATE) scm_the_rng.random_bits (RSTATE) -extern double scm_c_uniform01 (scm_t_rstate *); -extern double scm_c_normal01 (scm_t_rstate *); -extern double scm_c_exp1 (scm_t_rstate *); -extern unsigned long scm_c_random (scm_t_rstate *, unsigned long m); -extern SCM scm_c_random_bignum (scm_t_rstate *, SCM m); +SCM_API double scm_c_uniform01 (scm_t_rstate *); +SCM_API double scm_c_normal01 (scm_t_rstate *); +SCM_API double scm_c_exp1 (scm_t_rstate *); +SCM_API unsigned long scm_c_random (scm_t_rstate *, unsigned long m); +SCM_API SCM scm_c_random_bignum (scm_t_rstate *, SCM m); /* * Scheme level interface */ -extern scm_t_bits scm_tc16_rstate; +SCM_API scm_t_bits scm_tc16_rstate; #define SCM_RSTATEP(obj) SCM_TYP16_PREDICATE (scm_tc16_rstate, obj) #define SCM_RSTATE(obj) ((scm_t_rstate *) SCM_CELL_WORD_1 (obj)) -extern unsigned char scm_masktab[256]; +SCM_API unsigned char scm_masktab[256]; -extern SCM scm_var_random_state; -extern SCM scm_random (SCM n, SCM state); -extern SCM scm_copy_random_state (SCM state); -extern SCM scm_seed_to_random_state (SCM seed); -extern SCM scm_random_uniform (SCM state); -extern SCM scm_random_solid_sphere_x (SCM v, SCM state); -extern SCM scm_random_hollow_sphere_x (SCM v, SCM state); -extern SCM scm_random_normal (SCM state); -extern SCM scm_random_normal_vector_x (SCM v, SCM state); -extern SCM scm_random_exp (SCM state); -extern void scm_init_random (void); +SCM_API SCM scm_var_random_state; +SCM_API SCM scm_random (SCM n, SCM state); +SCM_API SCM scm_copy_random_state (SCM state); +SCM_API SCM scm_seed_to_random_state (SCM seed); +SCM_API SCM scm_random_uniform (SCM state); +SCM_API SCM scm_random_solid_sphere_x (SCM v, SCM state); +SCM_API SCM scm_random_hollow_sphere_x (SCM v, SCM state); +SCM_API SCM scm_random_normal (SCM state); +SCM_API SCM scm_random_normal_vector_x (SCM v, SCM state); +SCM_API SCM scm_random_exp (SCM state); +SCM_API void scm_init_random (void); #endif /* SCM_RANDOM_H */ diff --git a/libguile/rdelim.h b/libguile/rdelim.h index 6a987cc7d..c336e38ae 100644 --- a/libguile/rdelim.h +++ b/libguile/rdelim.h @@ -48,13 +48,13 @@ #include "libguile/__scm.h" -extern SCM scm_read_delimited_x (SCM delims, SCM buf, SCM gobble, SCM port, - SCM offset, SCM length); -extern SCM scm_read_line (SCM port); -extern SCM scm_write_line (SCM obj, SCM port); -extern SCM scm_init_rdelim_builtins (void); +SCM_API SCM scm_read_delimited_x (SCM delims, SCM buf, SCM gobble, SCM port, + SCM offset, SCM length); +SCM_API SCM scm_read_line (SCM port); +SCM_API SCM scm_write_line (SCM obj, SCM port); +SCM_API SCM scm_init_rdelim_builtins (void); -void scm_init_rdelim (void); +SCM_API void scm_init_rdelim (void); #endif /* SCM_RDELIM_H */ diff --git a/libguile/read.h b/libguile/read.h index ccdc4a2c3..f1e0bf51f 100644 --- a/libguile/read.h +++ b/libguile/read.h @@ -69,7 +69,7 @@ #define SCM_WHITE_SPACES SCM_SINGLE_SPACES: case '\t' -extern scm_t_option scm_read_opts[]; +SCM_API scm_t_option scm_read_opts[]; #define SCM_COPY_SOURCE_P scm_read_opts[0].val #define SCM_RECORD_POSITIONS_P scm_read_opts[1].val @@ -79,17 +79,17 @@ extern scm_t_option scm_read_opts[]; -extern SCM scm_read_options (SCM setting); -extern SCM scm_read (SCM port); -extern char * scm_grow_tok_buf (SCM * tok_buf); -extern int scm_flush_ws (SCM port, const char *eoferr); -extern int scm_casei_streq (char * s1, char * s2); -extern SCM scm_lreadr (SCM * tok_buf, SCM port, SCM *copy); -extern size_t scm_read_token (int ic, SCM * tok_buf, SCM port, int weird); -extern SCM scm_lreadparen (SCM * tok_buf, SCM port, char *name, SCM *copy); -extern SCM scm_lreadrecparen (SCM * tok_buf, SCM port, char *name, SCM *copy); -extern SCM scm_read_hash_extend (SCM chr, SCM proc); -extern void scm_init_read (void); +SCM_API SCM scm_read_options (SCM setting); +SCM_API SCM scm_read (SCM port); +SCM_API char * scm_grow_tok_buf (SCM * tok_buf); +SCM_API int scm_flush_ws (SCM port, const char *eoferr); +SCM_API int scm_casei_streq (char * s1, char * s2); +SCM_API SCM scm_lreadr (SCM * tok_buf, SCM port, SCM *copy); +SCM_API size_t scm_read_token (int ic, SCM * tok_buf, SCM port, int weird); +SCM_API SCM scm_lreadparen (SCM * tok_buf, SCM port, char *name, SCM *copy); +SCM_API SCM scm_lreadrecparen (SCM * tok_buf, SCM port, char *name, SCM *copy); +SCM_API SCM scm_read_hash_extend (SCM chr, SCM proc); +SCM_API void scm_init_read (void); #endif /* SCM_READ_H */ diff --git a/libguile/regex-posix.h b/libguile/regex-posix.h index 02b6e02a8..68c7aeb52 100644 --- a/libguile/regex-posix.h +++ b/libguile/regex-posix.h @@ -48,14 +48,14 @@ #include "libguile/__scm.h" -extern scm_t_bits scm_tc16_regex; +SCM_API scm_t_bits scm_tc16_regex; #define SCM_RGX(X) ((regex_t *) SCM_CELL_WORD_1 (X)) #define SCM_RGXP(X) (!SCM_IMP (X) && (SCM_CELL_TYPE (X) == scm_tc16_regex)) -extern SCM scm_make_regexp (SCM pat, SCM flags); -SCM scm_regexp_p (SCM x); -extern SCM scm_regexp_exec (SCM rx, SCM str, SCM start, SCM flags); -extern void scm_init_regex_posix (void); +SCM_API SCM scm_make_regexp (SCM pat, SCM flags); +SCM_API SCM scm_regexp_p (SCM x); +SCM_API SCM scm_regexp_exec (SCM rx, SCM str, SCM start, SCM flags); +SCM_API void scm_init_regex_posix (void); #endif /* SCM_REGEX_POSIX_H */ diff --git a/libguile/root.h b/libguile/root.h index 995ff14d3..ca4a7ef62 100644 --- a/libguile/root.h +++ b/libguile/root.h @@ -72,11 +72,11 @@ #define SCM_NUM_PROTECTS 13 #endif -extern SCM scm_sys_protects[]; +SCM_API SCM scm_sys_protects[]; -extern scm_t_bits scm_tc16_root; +SCM_API scm_t_bits scm_tc16_root; #define SCM_ROOTP(obj) SCM_TYP16_PREDICATE (scm_tc16_root, obj) #define SCM_ROOT_STATE(root) ((scm_root_state *) SCM_CELL_WORD_1 (root)) @@ -134,22 +134,22 @@ typedef struct scm_root_state #define scm_root ((scm_root_state *) SCM_THREAD_LOCAL_DATA) #define scm_set_root(new_root) SCM_SET_THREAD_LOCAL_DATA (new_root) #else /* USE_THREADS */ -extern struct scm_root_state *scm_root; +SCM_API struct scm_root_state *scm_root; #define scm_set_root(new_root) (scm_root = (new_root)) #endif /* USE_THREADS */ -extern SCM scm_make_root (SCM parent); -extern SCM scm_internal_cwdr (scm_t_catch_body body, - void *body_data, - scm_t_catch_handler handler, - void *handler_data, - SCM_STACKITEM *stack_start); -extern SCM scm_call_with_dynamic_root (SCM thunk, SCM handler); -extern SCM scm_dynamic_root (void); -extern SCM scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler); -extern void scm_init_root (void); +SCM_API SCM scm_make_root (SCM parent); +SCM_API SCM scm_internal_cwdr (scm_t_catch_body body, + void *body_data, + scm_t_catch_handler handler, + void *handler_data, + SCM_STACKITEM *stack_start); +SCM_API SCM scm_call_with_dynamic_root (SCM thunk, SCM handler); +SCM_API SCM scm_dynamic_root (void); +SCM_API SCM scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler); +SCM_API void scm_init_root (void); #endif /* SCM_ROOT_H */ diff --git a/libguile/rw.h b/libguile/rw.h index d9ad59026..4868ecf75 100644 --- a/libguile/rw.h +++ b/libguile/rw.h @@ -48,13 +48,13 @@ #include "libguile/__scm.h" -extern SCM scm_read_string_x_partial (SCM str, SCM port_or_fdes, SCM start, +SCM_API SCM scm_read_string_x_partial (SCM str, SCM port_or_fdes, SCM start, + SCM end); +SCM_API SCM scm_write_string_partial (SCM str, SCM port_or_fdes, SCM start, SCM end); -extern SCM scm_write_string_partial (SCM str, SCM port_or_fdes, SCM start, - SCM end); -SCM scm_init_rw_builtins (void); -void scm_init_rw (void); +SCM_API SCM scm_init_rw_builtins (void); +SCM_API void scm_init_rw (void); #endif /* SCM_RW_H */ diff --git a/libguile/scmsigs.h b/libguile/scmsigs.h index 5c9893e30..a9391b515 100644 --- a/libguile/scmsigs.h +++ b/libguile/scmsigs.h @@ -50,18 +50,18 @@ -extern SCM scm_sigaction (SCM signum, SCM handler, SCM flags); -extern SCM scm_restore_signals (void); -extern SCM scm_alarm (SCM i); -extern SCM scm_setitimer (SCM which_timer, - SCM interval_seconds, SCM interval_microseconds, - SCM value_seconds, SCM value_microseconds); -extern SCM scm_getitimer (SCM which_timer); -extern SCM scm_pause (void); -extern SCM scm_sleep (SCM i); -extern SCM scm_usleep (SCM i); -extern SCM scm_raise (SCM sig); -extern void scm_init_scmsigs (void); +SCM_API SCM scm_sigaction (SCM signum, SCM handler, SCM flags); +SCM_API SCM scm_restore_signals (void); +SCM_API SCM scm_alarm (SCM i); +SCM_API SCM scm_setitimer (SCM which_timer, + SCM interval_seconds, SCM interval_microseconds, + SCM value_seconds, SCM value_microseconds); +SCM_API SCM scm_getitimer (SCM which_timer); +SCM_API SCM scm_pause (void); +SCM_API SCM scm_sleep (SCM i); +SCM_API SCM scm_usleep (SCM i); +SCM_API SCM scm_raise (SCM sig); +SCM_API void scm_init_scmsigs (void); #endif /* SCM_SCMSIGS_H */ diff --git a/libguile/script.h b/libguile/script.h index d71ddca92..7ec1910fc 100644 --- a/libguile/script.h +++ b/libguile/script.h @@ -49,18 +49,18 @@ #include "libguile/__scm.h" -extern char *scm_find_executable (const char *name); -extern char *scm_find_impl_file (char *exec_path, - const char *generic_name, - const char *initname, - const char *sep); -extern char **scm_get_meta_args (int argc, char **argv); -extern int scm_count_argv (char **argv); -extern void scm_shell_usage (int fatal, char *message); -extern SCM scm_compile_shell_switches (int argc, char **argv); -extern void scm_shell (int argc, char **argv); -extern char *scm_usage_name; -extern void scm_init_script (void); +SCM_API char *scm_find_executable (const char *name); +SCM_API char *scm_find_impl_file (char *exec_path, + const char *generic_name, + const char *initname, + const char *sep); +SCM_API char **scm_get_meta_args (int argc, char **argv); +SCM_API int scm_count_argv (char **argv); +SCM_API void scm_shell_usage (int fatal, char *message); +SCM_API SCM scm_compile_shell_switches (int argc, char **argv); +SCM_API void scm_shell (int argc, char **argv); +SCM_API char *scm_usage_name; +SCM_API void scm_init_script (void); #endif /* SCM_SCRIPT_H */ diff --git a/libguile/simpos.h b/libguile/simpos.h index 4bae4e520..a5e2e47d6 100644 --- a/libguile/simpos.h +++ b/libguile/simpos.h @@ -50,10 +50,10 @@ -extern SCM scm_system (SCM cmd); -extern SCM scm_getenv (SCM nam); -extern SCM scm_primitive_exit (SCM status); -extern void scm_init_simpos (void); +SCM_API SCM scm_system (SCM cmd); +SCM_API SCM scm_getenv (SCM nam); +SCM_API SCM scm_primitive_exit (SCM status); +SCM_API void scm_init_simpos (void); #endif /* SCM_SIMPOS_H */ diff --git a/libguile/smob.h b/libguile/smob.h index 679966c2f..e804a60dc 100644 --- a/libguile/smob.h +++ b/libguile/smob.h @@ -127,16 +127,16 @@ do { \ #define SCM_SMOB_APPLY_2(x,a1,a2) (SCM_SMOB_DESCRIPTOR (x).apply_2 (x, (a1), (a2))) #define SCM_SMOB_APPLY_3(x,a1,a2,rst) (SCM_SMOB_DESCRIPTOR (x).apply_3 (x, (a1), (a2), (rst))) -extern long scm_numsmob; -extern scm_smob_descriptor scm_smobs[]; +SCM_API long scm_numsmob; +SCM_API scm_smob_descriptor scm_smobs[]; -extern SCM scm_mark0 (SCM ptr); -extern SCM scm_markcdr (SCM ptr); -extern size_t scm_free0 (SCM ptr); -extern size_t scm_smob_free (SCM obj); -extern int scm_smob_print (SCM exp, SCM port, scm_print_state *pstate); +SCM_API SCM scm_mark0 (SCM ptr); +SCM_API SCM scm_markcdr (SCM ptr); +SCM_API size_t scm_free0 (SCM ptr); +SCM_API size_t scm_smob_free (SCM obj); +SCM_API int scm_smob_print (SCM exp, SCM port, scm_print_state *pstate); /* The following set of functions is the standard way to create new * SMOB types. @@ -146,23 +146,23 @@ extern int scm_smob_print (SCM exp, SCM port, scm_print_state *pstate); * values using `scm_set_smob_xxx'. */ -extern scm_t_bits scm_make_smob_type (char *name, size_t size); +SCM_API scm_t_bits scm_make_smob_type (char *name, size_t size); -extern void scm_set_smob_mark (scm_t_bits tc, SCM (*mark) (SCM)); -extern void scm_set_smob_free (scm_t_bits tc, size_t (*free) (SCM)); -extern void scm_set_smob_print (scm_t_bits tc, - int (*print) (SCM, SCM, scm_print_state*)); -extern void scm_set_smob_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM)); -extern void scm_set_smob_apply (scm_t_bits tc, - SCM (*apply) (), - unsigned int req, - unsigned int opt, - unsigned int rst); +SCM_API void scm_set_smob_mark (scm_t_bits tc, SCM (*mark) (SCM)); +SCM_API void scm_set_smob_free (scm_t_bits tc, size_t (*free) (SCM)); +SCM_API void scm_set_smob_print (scm_t_bits tc, + int (*print) (SCM, SCM, scm_print_state*)); +SCM_API void scm_set_smob_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM)); +SCM_API void scm_set_smob_apply (scm_t_bits tc, + SCM (*apply) (), + unsigned int req, + unsigned int opt, + unsigned int rst); /* Function for creating smobs */ -extern SCM scm_make_smob (scm_t_bits tc); -extern void scm_smob_prehistory (void); +SCM_API SCM scm_make_smob (scm_t_bits tc); +SCM_API void scm_smob_prehistory (void); #endif /* SCM_SMOB_H */ diff --git a/libguile/socket.h b/libguile/socket.h index 3d355796d..c40b925bf 100644 --- a/libguile/socket.h +++ b/libguile/socket.h @@ -50,34 +50,34 @@ -extern SCM scm_htons (SCM in); -extern SCM scm_ntohs (SCM in); -extern SCM scm_htonl (SCM in); -extern SCM scm_ntohl (SCM in); -extern SCM scm_gethost (SCM name); -extern SCM scm_inet_aton (SCM address); -extern SCM scm_inet_ntoa (SCM inetid); -extern SCM scm_inet_netof (SCM address); -extern SCM scm_lnaof (SCM address); -extern SCM scm_inet_makeaddr (SCM net, SCM lna); -extern SCM scm_inet_pton (SCM family, SCM address); -extern SCM scm_inet_ntop (SCM family, SCM address); -extern SCM scm_socket (SCM family, SCM style, SCM proto); -extern SCM scm_socketpair (SCM family, SCM style, SCM proto); -extern SCM scm_getsockopt (SCM sfd, SCM level, SCM optname); -extern SCM scm_setsockopt (SCM sfd, SCM level, SCM optname, SCM value); -extern SCM scm_shutdown (SCM sfd, SCM how); -extern SCM scm_connect (SCM sockfd, SCM fam, SCM address, SCM args); -extern SCM scm_bind (SCM sockfd, SCM fam, SCM address, SCM args); -extern SCM scm_listen (SCM sfd, SCM backlog); -extern SCM scm_accept (SCM sockfd); -extern SCM scm_getsockname (SCM sockfd); -extern SCM scm_getpeername (SCM sockfd); -extern SCM scm_recv (SCM sockfd, SCM buff_or_size, SCM flags); -extern SCM scm_send (SCM sockfd, SCM message, SCM flags); -extern SCM scm_recvfrom (SCM sockfd, SCM buff_or_size, SCM flags, SCM offset, SCM length); -extern SCM scm_sendto (SCM sockfd, SCM message, SCM fam, SCM address, SCM args_and_flags); -extern void scm_init_socket (void); +SCM_API SCM scm_htons (SCM in); +SCM_API SCM scm_ntohs (SCM in); +SCM_API SCM scm_htonl (SCM in); +SCM_API SCM scm_ntohl (SCM in); +SCM_API SCM scm_gethost (SCM name); +SCM_API SCM scm_inet_aton (SCM address); +SCM_API SCM scm_inet_ntoa (SCM inetid); +SCM_API SCM scm_inet_netof (SCM address); +SCM_API SCM scm_lnaof (SCM address); +SCM_API SCM scm_inet_makeaddr (SCM net, SCM lna); +SCM_API SCM scm_inet_pton (SCM family, SCM address); +SCM_API SCM scm_inet_ntop (SCM family, SCM address); +SCM_API SCM scm_socket (SCM family, SCM style, SCM proto); +SCM_API SCM scm_socketpair (SCM family, SCM style, SCM proto); +SCM_API SCM scm_getsockopt (SCM sfd, SCM level, SCM optname); +SCM_API SCM scm_setsockopt (SCM sfd, SCM level, SCM optname, SCM value); +SCM_API SCM scm_shutdown (SCM sfd, SCM how); +SCM_API SCM scm_connect (SCM sockfd, SCM fam, SCM address, SCM args); +SCM_API SCM scm_bind (SCM sockfd, SCM fam, SCM address, SCM args); +SCM_API SCM scm_listen (SCM sfd, SCM backlog); +SCM_API SCM scm_accept (SCM sockfd); +SCM_API SCM scm_getsockname (SCM sockfd); +SCM_API SCM scm_getpeername (SCM sockfd); +SCM_API SCM scm_recv (SCM sockfd, SCM buff_or_size, SCM flags); +SCM_API SCM scm_send (SCM sockfd, SCM message, SCM flags); +SCM_API SCM scm_recvfrom (SCM sockfd, SCM buff_or_size, SCM flags, SCM offset, SCM length); +SCM_API SCM scm_sendto (SCM sockfd, SCM message, SCM fam, SCM address, SCM args_and_flags); +SCM_API void scm_init_socket (void); #endif /* SCM_SOCKET_H */ diff --git a/libguile/sort.h b/libguile/sort.h index ed98a3212..9f16f59bb 100644 --- a/libguile/sort.h +++ b/libguile/sort.h @@ -50,20 +50,20 @@ -extern SCM scm_restricted_vector_sort_x (SCM vec, - SCM less, - SCM startpos, - SCM endpos); -extern SCM scm_sorted_p (SCM ls, SCM less); -extern SCM scm_merge (SCM ls1, SCM ls2, SCM less); -extern SCM scm_merge_x (SCM ls1, SCM ls2, SCM less); -extern SCM scm_sort (SCM ls, SCM less); -extern SCM scm_sort_x (SCM ls, SCM less); -extern SCM scm_stable_sort (SCM ls, SCM less); -extern SCM scm_stable_sort_x (SCM ls, SCM less); -extern SCM scm_sort_list (SCM ls, SCM less); -extern SCM scm_sort_list_x (SCM ls, SCM less); -extern void scm_init_sort (void); +SCM_API SCM scm_restricted_vector_sort_x (SCM vec, + SCM less, + SCM startpos, + SCM endpos); +SCM_API SCM scm_sorted_p (SCM ls, SCM less); +SCM_API SCM scm_merge (SCM ls1, SCM ls2, SCM less); +SCM_API SCM scm_merge_x (SCM ls1, SCM ls2, SCM less); +SCM_API SCM scm_sort (SCM ls, SCM less); +SCM_API SCM scm_sort_x (SCM ls, SCM less); +SCM_API SCM scm_stable_sort (SCM ls, SCM less); +SCM_API SCM scm_stable_sort_x (SCM ls, SCM less); +SCM_API SCM scm_sort_list (SCM ls, SCM less); +SCM_API SCM scm_sort_list_x (SCM ls, SCM less); +SCM_API void scm_init_sort (void); #endif /* SCM_SORT_H */ diff --git a/libguile/srcprop.h b/libguile/srcprop.h index ed0ea217b..795aaf435 100644 --- a/libguile/srcprop.h +++ b/libguile/srcprop.h @@ -77,7 +77,7 @@ do { \ /* {Source properties} */ -extern scm_t_bits scm_tc16_srcprops; +SCM_API scm_t_bits scm_tc16_srcprops; typedef struct scm_t_srcprops { @@ -122,23 +122,23 @@ typedef struct scm_t_srcprops_chunk #define PROCTRACEP(x) (!SCM_FALSEP (scm_procedure_property (x, scm_sym_trace))) -extern SCM scm_sym_filename; -extern SCM scm_sym_copy; -extern SCM scm_sym_line; -extern SCM scm_sym_column; -extern SCM scm_sym_breakpoint; +SCM_API SCM scm_sym_filename; +SCM_API SCM scm_sym_copy; +SCM_API SCM scm_sym_line; +SCM_API SCM scm_sym_column; +SCM_API SCM scm_sym_breakpoint; -extern SCM scm_srcprops_to_plist (SCM obj); -extern SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist); -extern SCM scm_source_property (SCM obj, SCM key); -extern SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum); -extern SCM scm_source_properties (SCM obj); -extern SCM scm_set_source_properties_x (SCM obj, SCM props); -extern void scm_finish_srcprop (void); -extern void scm_init_srcprop (void); +SCM_API SCM scm_srcprops_to_plist (SCM obj); +SCM_API SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist); +SCM_API SCM scm_source_property (SCM obj, SCM key); +SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum); +SCM_API SCM scm_source_properties (SCM obj); +SCM_API SCM scm_set_source_properties_x (SCM obj, SCM props); +SCM_API void scm_finish_srcprop (void); +SCM_API void scm_init_srcprop (void); #endif /* SCM_SRCPROP_H */ diff --git a/libguile/stackchk.h b/libguile/stackchk.h index 8617e1ca2..eb03b106f 100644 --- a/libguile/stackchk.h +++ b/libguile/stackchk.h @@ -83,14 +83,14 @@ # define SCM_CHECK_STACK /**/ #endif /* STACK_CHECKING */ -extern int scm_stack_checking_enabled_p; +SCM_API int scm_stack_checking_enabled_p; -extern void scm_report_stack_overflow (void); -extern long scm_stack_size (SCM_STACKITEM *start); -extern void scm_stack_report (void); -extern void scm_init_stackchk (void); +SCM_API void scm_report_stack_overflow (void); +SCM_API long scm_stack_size (SCM_STACKITEM *start); +SCM_API void scm_stack_report (void); +SCM_API void scm_init_stackchk (void); #endif /* SCM_STACKCHK_H */ diff --git a/libguile/stacks.h b/libguile/stacks.h index 747a3daec..f49e34b82 100644 --- a/libguile/stacks.h +++ b/libguile/stacks.h @@ -73,7 +73,7 @@ typedef struct scm_t_stack { scm_t_info_frame tail[1]; } scm_t_stack; -extern SCM scm_t_stackype; +SCM_API SCM scm_t_stackype; #define SCM_STACKP(obj) (SCM_STRUCTP (obj) && SCM_EQ_P (SCM_STRUCT_VTABLE (obj), scm_t_stackype)) #define SCM_STACK_LENGTH(stack) (SCM_STACK (stack) -> length) @@ -115,26 +115,26 @@ extern SCM scm_t_stackype; -SCM scm_stack_p (SCM obj); -SCM scm_make_stack (SCM obj, SCM args); -SCM scm_stack_id (SCM stack); -SCM scm_stack_ref (SCM stack, SCM i); -SCM scm_stack_length (SCM stack); +SCM_API SCM scm_stack_p (SCM obj); +SCM_API SCM scm_make_stack (SCM obj, SCM args); +SCM_API SCM scm_stack_id (SCM stack); +SCM_API SCM scm_stack_ref (SCM stack, SCM i); +SCM_API SCM scm_stack_length (SCM stack); -SCM scm_frame_p (SCM obj); -SCM scm_last_stack_frame (SCM obj); -SCM scm_frame_number (SCM frame); -SCM scm_frame_source (SCM frame); -SCM scm_frame_procedure (SCM frame); -SCM scm_frame_arguments (SCM frame); -SCM scm_frame_previous (SCM frame); -SCM scm_frame_next (SCM frame); -SCM scm_frame_real_p (SCM frame); -SCM scm_frame_procedure_p (SCM frame); -SCM scm_frame_evaluating_args_p (SCM frame); -SCM scm_frame_overflow_p (SCM frame); +SCM_API SCM scm_frame_p (SCM obj); +SCM_API SCM scm_last_stack_frame (SCM obj); +SCM_API SCM scm_frame_number (SCM frame); +SCM_API SCM scm_frame_source (SCM frame); +SCM_API SCM scm_frame_procedure (SCM frame); +SCM_API SCM scm_frame_arguments (SCM frame); +SCM_API SCM scm_frame_previous (SCM frame); +SCM_API SCM scm_frame_next (SCM frame); +SCM_API SCM scm_frame_real_p (SCM frame); +SCM_API SCM scm_frame_procedure_p (SCM frame); +SCM_API SCM scm_frame_evaluating_args_p (SCM frame); +SCM_API SCM scm_frame_overflow_p (SCM frame); -void scm_init_stacks (void); +SCM_API void scm_init_stacks (void); #endif /* SCM_STACKS_H */ diff --git a/libguile/stime.h b/libguile/stime.h index 788e85422..db40e74c6 100644 --- a/libguile/stime.h +++ b/libguile/stime.h @@ -49,19 +49,19 @@ #include "libguile/__scm.h" -long scm_c_get_internal_run_time (void); -extern SCM scm_get_internal_real_time (void); -extern SCM scm_get_internal_run_time (void); -extern SCM scm_current_time (void); -extern SCM scm_gettimeofday (void); -extern SCM scm_localtime (SCM time, SCM zone); -extern SCM scm_gmtime (SCM time); -extern SCM scm_mktime (SCM sbd_time, SCM zone); -extern SCM scm_tzset (void); -extern SCM scm_times (void); -extern SCM scm_strftime (SCM format, SCM stime); -extern SCM scm_strptime (SCM format, SCM string); -extern void scm_init_stime (void); +SCM_API long scm_c_get_internal_run_time (void); +SCM_API SCM scm_get_internal_real_time (void); +SCM_API SCM scm_get_internal_run_time (void); +SCM_API SCM scm_current_time (void); +SCM_API SCM scm_gettimeofday (void); +SCM_API SCM scm_localtime (SCM time, SCM zone); +SCM_API SCM scm_gmtime (SCM time); +SCM_API SCM scm_mktime (SCM sbd_time, SCM zone); +SCM_API SCM scm_tzset (void); +SCM_API SCM scm_times (void); +SCM_API SCM scm_strftime (SCM format, SCM stime); +SCM_API SCM scm_strptime (SCM format, SCM string); +SCM_API void scm_init_stime (void); #endif /* SCM_STIME_H */ diff --git a/libguile/strings.h b/libguile/strings.h index 2c943d17c..9104a42e4 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -60,23 +60,23 @@ -extern SCM scm_string_p (SCM x); -extern SCM scm_string (SCM chrs); -extern SCM scm_makfromstrs (int argc, char **argv); -extern SCM scm_take_str (char *s, size_t len); -extern SCM scm_take0str (char *s); -extern SCM scm_mem2string (const char *src, size_t len); -extern SCM scm_str2string (const char *src); -extern SCM scm_makfrom0str (const char *src); -extern SCM scm_makfrom0str_opt (const char *src); -extern SCM scm_allocate_string (size_t len); -extern SCM scm_make_string (SCM k, SCM chr); -extern SCM scm_string_length (SCM str); -extern SCM scm_string_ref (SCM str, SCM k); -extern SCM scm_string_set_x (SCM str, SCM k, SCM chr); -extern SCM scm_substring (SCM str, SCM start, SCM end); -extern SCM scm_string_append (SCM args); -extern void scm_init_strings (void); +SCM_API SCM scm_string_p (SCM x); +SCM_API SCM scm_string (SCM chrs); +SCM_API SCM scm_makfromstrs (int argc, char **argv); +SCM_API SCM scm_take_str (char *s, size_t len); +SCM_API SCM scm_take0str (char *s); +SCM_API SCM scm_mem2string (const char *src, size_t len); +SCM_API SCM scm_str2string (const char *src); +SCM_API SCM scm_makfrom0str (const char *src); +SCM_API SCM scm_makfrom0str_opt (const char *src); +SCM_API SCM scm_allocate_string (size_t len); +SCM_API SCM scm_make_string (SCM k, SCM chr); +SCM_API SCM scm_string_length (SCM str); +SCM_API SCM scm_string_ref (SCM str, SCM k); +SCM_API SCM scm_string_set_x (SCM str, SCM k, SCM chr); +SCM_API SCM scm_substring (SCM str, SCM start, SCM end); +SCM_API SCM scm_string_append (SCM args); +SCM_API void scm_init_strings (void); diff --git a/libguile/strop.h b/libguile/strop.h index 0f1ceb1a8..863428db6 100644 --- a/libguile/strop.h +++ b/libguile/strop.h @@ -50,24 +50,24 @@ -extern SCM scm_string_index (SCM str, SCM chr, SCM frm, SCM to); -extern SCM scm_string_rindex (SCM str, SCM chr, SCM frm, SCM to); -extern SCM scm_substring_move_x (SCM str1, SCM start1, SCM end1, - SCM str2, SCM start2); -extern SCM scm_substring_fill_x (SCM str, SCM start, SCM end, SCM fill); -extern SCM scm_string_null_p (SCM str); -extern SCM scm_string_to_list (SCM str); -extern SCM scm_string_copy (SCM str); -extern SCM scm_string_fill_x (SCM str, SCM chr); -extern void scm_init_strop (void); -extern SCM scm_string_upcase_x (SCM v); -extern SCM scm_string_upcase (SCM v); -extern SCM scm_string_downcase_x (SCM v); -extern SCM scm_string_downcase (SCM v); -extern SCM scm_string_capitalize_x (SCM v); -extern SCM scm_string_capitalize (SCM v); -extern SCM scm_string_split (SCM str, SCM chr); -extern SCM scm_string_ci_to_symbol (SCM v); +SCM_API SCM scm_string_index (SCM str, SCM chr, SCM frm, SCM to); +SCM_API SCM scm_string_rindex (SCM str, SCM chr, SCM frm, SCM to); +SCM_API SCM scm_substring_move_x (SCM str1, SCM start1, SCM end1, + SCM str2, SCM start2); +SCM_API SCM scm_substring_fill_x (SCM str, SCM start, SCM end, SCM fill); +SCM_API SCM scm_string_null_p (SCM str); +SCM_API SCM scm_string_to_list (SCM str); +SCM_API SCM scm_string_copy (SCM str); +SCM_API SCM scm_string_fill_x (SCM str, SCM chr); +SCM_API void scm_init_strop (void); +SCM_API SCM scm_string_upcase_x (SCM v); +SCM_API SCM scm_string_upcase (SCM v); +SCM_API SCM scm_string_downcase_x (SCM v); +SCM_API SCM scm_string_downcase (SCM v); +SCM_API SCM scm_string_capitalize_x (SCM v); +SCM_API SCM scm_string_capitalize (SCM v); +SCM_API SCM scm_string_split (SCM str, SCM chr); +SCM_API SCM scm_string_ci_to_symbol (SCM v); #define scm_substring_move_left_x scm_substring_move_x #define scm_substring_move_right_x scm_substring_move_x diff --git a/libguile/strorder.h b/libguile/strorder.h index 3660c61a3..2583e81d0 100644 --- a/libguile/strorder.h +++ b/libguile/strorder.h @@ -50,17 +50,17 @@ -extern SCM scm_string_equal_p (SCM s1, SCM s2); -extern SCM scm_string_ci_equal_p (SCM s1, SCM s2); -extern SCM scm_string_less_p (SCM s1, SCM s2); -extern SCM scm_string_leq_p (SCM s1, SCM s2); -extern SCM scm_string_gr_p (SCM s1, SCM s2); -extern SCM scm_string_geq_p (SCM s1, SCM s2); -extern SCM scm_string_ci_less_p (SCM s1, SCM s2); -extern SCM scm_string_ci_leq_p (SCM s1, SCM s2); -extern SCM scm_string_ci_gr_p (SCM s1, SCM s2); -extern SCM scm_string_ci_geq_p (SCM s1, SCM s2); -extern void scm_init_strorder (void); +SCM_API SCM scm_string_equal_p (SCM s1, SCM s2); +SCM_API SCM scm_string_ci_equal_p (SCM s1, SCM s2); +SCM_API SCM scm_string_less_p (SCM s1, SCM s2); +SCM_API SCM scm_string_leq_p (SCM s1, SCM s2); +SCM_API SCM scm_string_gr_p (SCM s1, SCM s2); +SCM_API SCM scm_string_geq_p (SCM s1, SCM s2); +SCM_API SCM scm_string_ci_less_p (SCM s1, SCM s2); +SCM_API SCM scm_string_ci_leq_p (SCM s1, SCM s2); +SCM_API SCM scm_string_ci_gr_p (SCM s1, SCM s2); +SCM_API SCM scm_string_ci_geq_p (SCM s1, SCM s2); +SCM_API void scm_init_strorder (void); #endif /* SCM_STRORDER_H */ diff --git a/libguile/strports.h b/libguile/strports.h index 777281118..22e9168a2 100644 --- a/libguile/strports.h +++ b/libguile/strports.h @@ -62,22 +62,22 @@ -extern scm_t_bits scm_tc16_strport; +SCM_API scm_t_bits scm_tc16_strport; -extern SCM scm_mkstrport (SCM pos, SCM str, long modes, const char * caller); -extern SCM scm_strport_to_string (SCM port); -extern SCM scm_object_to_string (SCM obj, SCM printer); -extern SCM scm_call_with_output_string (SCM proc); -extern SCM scm_call_with_input_string (SCM str, SCM proc); -extern SCM scm_open_input_string (SCM str); -extern SCM scm_open_output_string (void); -extern SCM scm_get_output_string (SCM port); -extern SCM scm_c_read_string (const char *expr); -extern SCM scm_c_eval_string (const char *expr); -extern SCM scm_eval_string (SCM string); -extern void scm_init_strports (void); +SCM_API SCM scm_mkstrport (SCM pos, SCM str, long modes, const char * caller); +SCM_API SCM scm_strport_to_string (SCM port); +SCM_API SCM scm_object_to_string (SCM obj, SCM printer); +SCM_API SCM scm_call_with_output_string (SCM proc); +SCM_API SCM scm_call_with_input_string (SCM str, SCM proc); +SCM_API SCM scm_open_input_string (SCM str); +SCM_API SCM scm_open_output_string (void); +SCM_API SCM scm_get_output_string (SCM port); +SCM_API SCM scm_c_read_string (const char *expr); +SCM_API SCM scm_c_eval_string (const char *expr); +SCM_API SCM scm_eval_string (SCM string); +SCM_API void scm_init_strports (void); #endif /* SCM_STRPORTS_H */ diff --git a/libguile/struct.h b/libguile/struct.h index a36adf0a4..20687e38a 100644 --- a/libguile/struct.h +++ b/libguile/struct.h @@ -99,35 +99,35 @@ typedef size_t (*scm_t_struct_free) (scm_t_bits * vtable, scm_t_bits * data); #define SCM_SET_STRUCT_TABLE_NAME(X, NAME) SCM_SETCAR (X, NAME) #define SCM_STRUCT_TABLE_CLASS(X) SCM_CDR (X) #define SCM_SET_STRUCT_TABLE_CLASS(X, CLASS) SCM_SETCDR (X, CLASS) -extern SCM scm_struct_table; +SCM_API SCM scm_struct_table; #define SCM_STRUCT_GC_CHAIN(X) SCM_CELL_OBJECT_3 (X) #define SCM_SET_STRUCT_GC_CHAIN(X, Y) SCM_SET_CELL_OBJECT_3 (X, Y) -extern SCM scm_structs_to_free; +SCM_API SCM scm_structs_to_free; -extern scm_t_bits * scm_alloc_struct (int n_words, int n_extra, char * who); -extern size_t scm_struct_free_0 (scm_t_bits * vtable, scm_t_bits * data); -extern size_t scm_struct_free_light (scm_t_bits * vtable, scm_t_bits * data); -extern size_t scm_struct_free_standard (scm_t_bits * vtable, scm_t_bits * data); -extern size_t scm_struct_free_entity (scm_t_bits * vtable, scm_t_bits * data); -extern SCM scm_make_struct_layout (SCM fields); -extern SCM scm_struct_p (SCM x); -extern SCM scm_struct_vtable_p (SCM x); -extern SCM scm_make_struct (SCM vtable, SCM tail_array_size, SCM init); -extern SCM scm_make_vtable_vtable (SCM extra_fields, SCM tail_array_size, SCM init); -extern SCM scm_struct_ref (SCM handle, SCM pos); -extern SCM scm_struct_set_x (SCM handle, SCM pos, SCM val); -extern SCM scm_struct_vtable (SCM handle); -extern SCM scm_struct_vtable_tag (SCM handle); -extern unsigned long scm_struct_ihashq (SCM obj, unsigned long n); -extern SCM scm_struct_create_handle (SCM obj); -extern SCM scm_struct_vtable_name (SCM vtable); -extern SCM scm_set_struct_vtable_name_x (SCM vtable, SCM name); -extern void scm_print_struct (SCM exp, SCM port, scm_print_state *); -extern void scm_struct_prehistory (void); -extern void scm_init_struct (void); +SCM_API scm_t_bits * scm_alloc_struct (int n_words, int n_extra, char * who); +SCM_API size_t scm_struct_free_0 (scm_t_bits * vtable, scm_t_bits * data); +SCM_API size_t scm_struct_free_light (scm_t_bits * vtable, scm_t_bits * data); +SCM_API size_t scm_struct_free_standard (scm_t_bits * vtable, scm_t_bits * data); +SCM_API size_t scm_struct_free_entity (scm_t_bits * vtable, scm_t_bits * data); +SCM_API SCM scm_make_struct_layout (SCM fields); +SCM_API SCM scm_struct_p (SCM x); +SCM_API SCM scm_struct_vtable_p (SCM x); +SCM_API SCM scm_make_struct (SCM vtable, SCM tail_array_size, SCM init); +SCM_API SCM scm_make_vtable_vtable (SCM extra_fields, SCM tail_array_size, SCM init); +SCM_API SCM scm_struct_ref (SCM handle, SCM pos); +SCM_API SCM scm_struct_set_x (SCM handle, SCM pos, SCM val); +SCM_API SCM scm_struct_vtable (SCM handle); +SCM_API SCM scm_struct_vtable_tag (SCM handle); +SCM_API unsigned long scm_struct_ihashq (SCM obj, unsigned long n); +SCM_API SCM scm_struct_create_handle (SCM obj); +SCM_API SCM scm_struct_vtable_name (SCM vtable); +SCM_API SCM scm_set_struct_vtable_name_x (SCM vtable, SCM name); +SCM_API void scm_print_struct (SCM exp, SCM port, scm_print_state *); +SCM_API void scm_struct_prehistory (void); +SCM_API void scm_init_struct (void); #endif /* SCM_STRUCT_H */ diff --git a/libguile/symbols.h b/libguile/symbols.h index e68ee1f9f..3a0269ff2 100644 --- a/libguile/symbols.h +++ b/libguile/symbols.h @@ -71,25 +71,25 @@ #ifdef GUILE_DEBUG -extern SCM scm_sys_symbols (void); +SCM_API SCM scm_sys_symbols (void); #endif -extern SCM scm_mem2symbol (const char*, size_t); -extern SCM scm_str2symbol (const char*); +SCM_API SCM scm_mem2symbol (const char*, size_t); +SCM_API SCM scm_str2symbol (const char*); -extern SCM scm_symbol_p (SCM x); -extern SCM scm_symbol_to_string (SCM s); -extern SCM scm_string_to_symbol (SCM s); +SCM_API SCM scm_symbol_p (SCM x); +SCM_API SCM scm_symbol_to_string (SCM s); +SCM_API SCM scm_string_to_symbol (SCM s); -extern SCM scm_symbol_fref (SCM s); -extern SCM scm_symbol_pref (SCM s); -extern SCM scm_symbol_fset_x (SCM s, SCM val); -extern SCM scm_symbol_pset_x (SCM s, SCM val); +SCM_API SCM scm_symbol_fref (SCM s); +SCM_API SCM scm_symbol_pref (SCM s); +SCM_API SCM scm_symbol_fset_x (SCM s, SCM val); +SCM_API SCM scm_symbol_pset_x (SCM s, SCM val); -extern SCM scm_symbol_hash (SCM s); -extern SCM scm_gensym (SCM prefix); +SCM_API SCM scm_symbol_hash (SCM s); +SCM_API SCM scm_gensym (SCM prefix); -extern void scm_symbols_prehistory (void); -extern void scm_init_symbols (void); +SCM_API void scm_symbols_prehistory (void); +SCM_API void scm_init_symbols (void); #endif /* SCM_SYMBOLS_H */ diff --git a/libguile/tags.h b/libguile/tags.h index e8e160dad..160987bf1 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -417,7 +417,7 @@ enum scm_tags #define SCM_MAKISYM(n) SCM_PACK (((n) << 9) + 0x74L) #define SCM_MAKIFLAG(n) SCM_PACK (((n) << 9) + 0x174L) -extern char *scm_isymnames[]; /* defined in print.c */ +SCM_API char *scm_isymnames[]; /* defined in print.c */ /* This table must agree with the declarations * in repl.c: {Names of immediate symbols}. diff --git a/libguile/threads.h b/libguile/threads.h index 223732a44..cbd60f075 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -53,9 +53,9 @@ /* smob tags for the thread datatypes */ -extern scm_t_bits scm_tc16_thread; -extern scm_t_bits scm_tc16_mutex; -extern scm_t_bits scm_tc16_condvar; +SCM_API scm_t_bits scm_tc16_thread; +SCM_API scm_t_bits scm_tc16_mutex; +SCM_API scm_t_bits scm_tc16_condvar; #define SCM_THREADP(x) SCM_TYP16_PREDICATE (scm_tc16_thread, x) #define SCM_THREAD_DATA(x) ((void *) SCM_CELL_WORD_1 (x)) @@ -67,38 +67,38 @@ extern scm_t_bits scm_tc16_condvar; #define SCM_CONDVAR_DATA(x) ((void *) SCM_CELL_WORD_1 (x)) /* Initialize implementation specific details of the threads support */ -void scm_threads_init (SCM_STACKITEM *); -void scm_threads_mark_stacks (void); -void scm_init_threads (SCM_STACKITEM *); +SCM_API void scm_threads_init (SCM_STACKITEM *); +SCM_API void scm_threads_mark_stacks (void); +SCM_API void scm_init_threads (SCM_STACKITEM *); /* */ -SCM scm_threads_make_mutex (void); -SCM scm_threads_lock_mutex (SCM); -SCM scm_threads_unlock_mutex (SCM); -SCM scm_threads_monitor (void); +SCM_API SCM scm_threads_make_mutex (void); +SCM_API SCM scm_threads_lock_mutex (SCM); +SCM_API SCM scm_threads_unlock_mutex (SCM); +SCM_API SCM scm_threads_monitor (void); -SCM scm_spawn_thread (scm_t_catch_body body, void *body_data, - scm_t_catch_handler handler, void *handler_data); +SCM_API SCM scm_spawn_thread (scm_t_catch_body body, void *body_data, + scm_t_catch_handler handler, void *handler_data); /* These are versions of the ordinary sleep and usleep functions, that play nicely with the thread system. */ -unsigned long scm_thread_sleep (unsigned long); -unsigned long scm_thread_usleep (unsigned long); +SCM_API unsigned long scm_thread_sleep (unsigned long); +SCM_API unsigned long scm_thread_usleep (unsigned long); /* The C versions of the Scheme-visible thread functions. */ #ifdef USE_COOP_THREADS -extern SCM scm_single_thread_p (void); +SCM_API SCM scm_single_thread_p (void); #endif -extern SCM scm_yield (void); -extern SCM scm_call_with_new_thread (SCM argl); -extern SCM scm_join_thread (SCM t); -extern SCM scm_make_mutex (void); -extern SCM scm_lock_mutex (SCM m); -extern SCM scm_unlock_mutex (SCM m); -extern SCM scm_make_condition_variable (void); -extern SCM scm_wait_condition_variable (SCM cond, SCM mutex); -extern SCM scm_signal_condition_variable (SCM cond); +SCM_API SCM scm_yield (void); +SCM_API SCM scm_call_with_new_thread (SCM argl); +SCM_API SCM scm_join_thread (SCM t); +SCM_API SCM scm_make_mutex (void); +SCM_API SCM scm_lock_mutex (SCM m); +SCM_API SCM scm_unlock_mutex (SCM m); +SCM_API SCM scm_make_condition_variable (void); +SCM_API SCM scm_wait_condition_variable (SCM cond, SCM mutex); +SCM_API SCM scm_signal_condition_variable (SCM cond); #ifdef USE_COOP_THREADS #include "libguile/coop-defs.h" diff --git a/libguile/throw.h b/libguile/throw.h index 6b6b3d79c..f85dc92b1 100644 --- a/libguile/throw.h +++ b/libguile/throw.h @@ -54,23 +54,23 @@ typedef SCM (*scm_t_catch_body) (void *data); typedef SCM (*scm_t_catch_handler) (void *data, SCM tag, SCM throw_args); -extern SCM scm_internal_catch (SCM tag, - scm_t_catch_body body, - void *body_data, - scm_t_catch_handler handler, - void *handler_data); +SCM_API SCM scm_internal_catch (SCM tag, + scm_t_catch_body body, + void *body_data, + scm_t_catch_handler handler, + void *handler_data); -extern SCM scm_internal_lazy_catch (SCM tag, - scm_t_catch_body body, - void *body_data, - scm_t_catch_handler handler, - void *handler_data); +SCM_API SCM scm_internal_lazy_catch (SCM tag, + scm_t_catch_body body, + void *body_data, + scm_t_catch_handler handler, + void *handler_data); -extern SCM scm_internal_stack_catch (SCM tag, - scm_t_catch_body body, - void *body_data, - scm_t_catch_handler handler, - void *handler_data); +SCM_API SCM scm_internal_stack_catch (SCM tag, + scm_t_catch_body body, + void *body_data, + scm_t_catch_handler handler, + void *handler_data); /* The first argument to scm_body_thunk should be a pointer to one of these. See the implementation of catch in throw.c. */ @@ -86,22 +86,22 @@ struct scm_body_thunk_data SCM body_proc; }; -extern SCM scm_body_thunk (void *); +SCM_API SCM scm_body_thunk (void *); -extern SCM scm_handle_by_proc (void *, SCM, SCM); -extern SCM scm_handle_by_proc_catching_all (void *, SCM, SCM); -extern SCM scm_handle_by_message (void *, SCM, SCM); -extern SCM scm_handle_by_message_noexit (void *, SCM, SCM); -extern SCM scm_handle_by_throw (void *, SCM, SCM); -extern int scm_exit_status (SCM args); +SCM_API SCM scm_handle_by_proc (void *, SCM, SCM); +SCM_API SCM scm_handle_by_proc_catching_all (void *, SCM, SCM); +SCM_API SCM scm_handle_by_message (void *, SCM, SCM); +SCM_API SCM scm_handle_by_message_noexit (void *, SCM, SCM); +SCM_API SCM scm_handle_by_throw (void *, SCM, SCM); +SCM_API int scm_exit_status (SCM args); -extern SCM scm_catch (SCM tag, SCM thunk, SCM handler); -extern SCM scm_lazy_catch (SCM tag, SCM thunk, SCM handler); -extern SCM scm_ithrow (SCM key, SCM args, int noreturn); +SCM_API SCM scm_catch (SCM tag, SCM thunk, SCM handler); +SCM_API SCM scm_lazy_catch (SCM tag, SCM thunk, SCM handler); +SCM_API SCM scm_ithrow (SCM key, SCM args, int noreturn); -extern SCM scm_throw (SCM key, SCM args); -extern void scm_init_throw (void); +SCM_API SCM scm_throw (SCM key, SCM args); +SCM_API void scm_init_throw (void); #endif /* SCM_THROW_H */ diff --git a/libguile/unif.h b/libguile/unif.h index 24da36e72..b5d393a12 100644 --- a/libguile/unif.h +++ b/libguile/unif.h @@ -73,7 +73,7 @@ typedef struct scm_t_array_dim long inc; } scm_t_array_dim; -extern scm_t_bits scm_tc16_array; +SCM_API scm_t_bits scm_tc16_array; #define SCM_ARRAY_FLAG_CONTIGUOUS (1 << 16) @@ -107,42 +107,42 @@ extern scm_t_bits scm_tc16_array; -extern size_t scm_uniform_element_size (SCM obj); -extern SCM scm_make_uve (long k, SCM prot); -extern SCM scm_uniform_vector_length (SCM v); -extern SCM scm_array_p (SCM v, SCM prot); -extern SCM scm_array_rank (SCM ra); -extern SCM scm_array_dimensions (SCM ra); -extern SCM scm_shared_array_root (SCM ra); -extern SCM scm_shared_array_offset (SCM ra); -extern SCM scm_shared_array_increments (SCM ra); -extern long scm_aind (SCM ra, SCM args, const char *what); -extern SCM scm_make_ra (int ndim); -extern SCM scm_shap2ra (SCM args, const char *what); -extern SCM scm_dimensions_to_uniform_array (SCM dims, SCM prot, SCM fill); -extern void scm_ra_set_contp (SCM ra); -extern SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims); -extern SCM scm_transpose_array (SCM ra, SCM args); -extern SCM scm_enclose_array (SCM ra, SCM axes); -extern SCM scm_array_in_bounds_p (SCM v, SCM args); -extern SCM scm_uniform_vector_ref (SCM v, SCM args); -extern SCM scm_cvref (SCM v, unsigned long pos, SCM last); -extern SCM scm_array_set_x (SCM v, SCM obj, SCM args); -extern SCM scm_array_contents (SCM ra, SCM strict); -extern SCM scm_ra2contig (SCM ra, int copy); -extern SCM scm_uniform_array_read_x (SCM ra, SCM port_or_fd, SCM start, SCM end); -extern SCM scm_uniform_array_write (SCM v, SCM port_or_fd, SCM start, SCM end); -extern SCM scm_bit_count (SCM item, SCM seq); -extern SCM scm_bit_position (SCM item, SCM v, SCM k); -extern SCM scm_bit_set_star_x (SCM v, SCM kv, SCM obj); -extern SCM scm_bit_count_star (SCM v, SCM kv, SCM obj); -extern SCM scm_bit_invert_x (SCM v); -extern SCM scm_istr2bve (char *str, long len); -extern SCM scm_t_arrayo_list (SCM v); -extern SCM scm_list_to_uniform_array (SCM ndim, SCM prot, SCM lst); -extern int scm_raprin1 (SCM exp, SCM port, scm_print_state *pstate); -extern SCM scm_array_prototype (SCM ra); -extern void scm_init_unif (void); +SCM_API size_t scm_uniform_element_size (SCM obj); +SCM_API SCM scm_make_uve (long k, SCM prot); +SCM_API SCM scm_uniform_vector_length (SCM v); +SCM_API SCM scm_array_p (SCM v, SCM prot); +SCM_API SCM scm_array_rank (SCM ra); +SCM_API SCM scm_array_dimensions (SCM ra); +SCM_API SCM scm_shared_array_root (SCM ra); +SCM_API SCM scm_shared_array_offset (SCM ra); +SCM_API SCM scm_shared_array_increments (SCM ra); +SCM_API long scm_aind (SCM ra, SCM args, const char *what); +SCM_API SCM scm_make_ra (int ndim); +SCM_API SCM scm_shap2ra (SCM args, const char *what); +SCM_API SCM scm_dimensions_to_uniform_array (SCM dims, SCM prot, SCM fill); +SCM_API void scm_ra_set_contp (SCM ra); +SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims); +SCM_API SCM scm_transpose_array (SCM ra, SCM args); +SCM_API SCM scm_enclose_array (SCM ra, SCM axes); +SCM_API SCM scm_array_in_bounds_p (SCM v, SCM args); +SCM_API SCM scm_uniform_vector_ref (SCM v, SCM args); +SCM_API SCM scm_cvref (SCM v, unsigned long pos, SCM last); +SCM_API SCM scm_array_set_x (SCM v, SCM obj, SCM args); +SCM_API SCM scm_array_contents (SCM ra, SCM strict); +SCM_API SCM scm_ra2contig (SCM ra, int copy); +SCM_API SCM scm_uniform_array_read_x (SCM ra, SCM port_or_fd, SCM start, SCM end); +SCM_API SCM scm_uniform_array_write (SCM v, SCM port_or_fd, SCM start, SCM end); +SCM_API SCM scm_bit_count (SCM item, SCM seq); +SCM_API SCM scm_bit_position (SCM item, SCM v, SCM k); +SCM_API SCM scm_bit_set_star_x (SCM v, SCM kv, SCM obj); +SCM_API SCM scm_bit_count_star (SCM v, SCM kv, SCM obj); +SCM_API SCM scm_bit_invert_x (SCM v); +SCM_API SCM scm_istr2bve (char *str, long len); +SCM_API SCM scm_t_arrayo_list (SCM v); +SCM_API SCM scm_list_to_uniform_array (SCM ndim, SCM prot, SCM lst); +SCM_API int scm_raprin1 (SCM exp, SCM port, scm_print_state *pstate); +SCM_API SCM scm_array_prototype (SCM ra); +SCM_API void scm_init_unif (void); #endif /* SCM_UNIF_H */ diff --git a/libguile/values.h b/libguile/values.h index 2c2fce0ef..acc7e90a3 100644 --- a/libguile/values.h +++ b/libguile/values.h @@ -48,13 +48,13 @@ #include "libguile/__scm.h" -extern SCM scm_values_vtable; +SCM_API SCM scm_values_vtable; #define SCM_VALUESP(x) (SCM_STRUCTP (x)\ && SCM_EQ_P (scm_struct_vtable (x), scm_values_vtable)) -extern SCM scm_values (SCM args); -extern void scm_init_values (void); +SCM_API SCM scm_values (SCM args); +SCM_API void scm_init_values (void); #endif /* SCM_VALUES_H */ diff --git a/libguile/variable.h b/libguile/variable.h index 6a6a8a04d..5be7d067d 100644 --- a/libguile/variable.h +++ b/libguile/variable.h @@ -60,16 +60,16 @@ -extern SCM scm_make_variable (SCM init); -extern SCM scm_make_undefined_variable (void); -extern SCM scm_variable_p (SCM obj); -extern SCM scm_variable_ref (SCM var); -extern SCM scm_variable_set_x (SCM var, SCM val); -extern SCM scm_variable_bound_p (SCM var); +SCM_API SCM scm_make_variable (SCM init); +SCM_API SCM scm_make_undefined_variable (void); +SCM_API SCM scm_variable_p (SCM obj); +SCM_API SCM scm_variable_ref (SCM var); +SCM_API SCM scm_variable_set_x (SCM var, SCM val); +SCM_API SCM scm_variable_bound_p (SCM var); -extern void scm_i_variable_print (SCM var, SCM port, scm_print_state *pstate); +SCM_API void scm_i_variable_print (SCM var, SCM port, scm_print_state *pstate); -extern void scm_init_variable (void); +SCM_API void scm_init_variable (void); #endif /* SCM_VARIABLE_H */ diff --git a/libguile/vectors.h b/libguile/vectors.h index 0d98f9c5c..746a7686a 100644 --- a/libguile/vectors.h +++ b/libguile/vectors.h @@ -73,22 +73,22 @@ -extern SCM scm_c_make_vector (unsigned long int k, SCM fill); +SCM_API SCM scm_c_make_vector (unsigned long int k, SCM fill); -extern SCM scm_vector_p (SCM x); -extern SCM scm_vector_length (SCM v); -extern SCM scm_vector (SCM l); -extern SCM scm_vector_ref (SCM v, SCM k); -extern SCM scm_vector_set_x (SCM v, SCM k, SCM obj); -extern SCM scm_make_vector (SCM k, SCM fill); -extern SCM scm_vector_to_list (SCM v); -extern SCM scm_vector_fill_x (SCM v, SCM fill_x); -extern SCM scm_vector_equal_p (SCM x, SCM y); -extern SCM scm_vector_move_left_x (SCM vec1, SCM start1, SCM end1, - SCM vec2, SCM start2); -extern SCM scm_vector_move_right_x (SCM vec1, SCM start1, SCM end1, - SCM vec2, SCM start2); -extern void scm_init_vectors (void); +SCM_API SCM scm_vector_p (SCM x); +SCM_API SCM scm_vector_length (SCM v); +SCM_API SCM scm_vector (SCM l); +SCM_API SCM scm_vector_ref (SCM v, SCM k); +SCM_API SCM scm_vector_set_x (SCM v, SCM k, SCM obj); +SCM_API SCM scm_make_vector (SCM k, SCM fill); +SCM_API SCM scm_vector_to_list (SCM v); +SCM_API SCM scm_vector_fill_x (SCM v, SCM fill_x); +SCM_API SCM scm_vector_equal_p (SCM x, SCM y); +SCM_API SCM scm_vector_move_left_x (SCM vec1, SCM start1, SCM end1, + SCM vec2, SCM start2); +SCM_API SCM scm_vector_move_right_x (SCM vec1, SCM start1, SCM end1, + SCM vec2, SCM start2); +SCM_API void scm_init_vectors (void); #endif /* SCM_VECTORS_H */ diff --git a/libguile/vports.h b/libguile/vports.h index 90c628fb5..8dd2b67c6 100644 --- a/libguile/vports.h +++ b/libguile/vports.h @@ -50,8 +50,8 @@ -extern SCM scm_make_soft_port (SCM pv, SCM modes); -extern void scm_init_vports (void); +SCM_API SCM scm_make_soft_port (SCM pv, SCM modes); +SCM_API void scm_init_vports (void); #endif /* SCM_VPORTS_H */ diff --git a/libguile/weaks.h b/libguile/weaks.h index bfafba674..690ba6c41 100644 --- a/libguile/weaks.h +++ b/libguile/weaks.h @@ -60,21 +60,21 @@ #define SCM_WVECT_GC_CHAIN(X) (SCM_CELL_OBJECT_3 (X)) #define SCM_SET_WVECT_GC_CHAIN(X, o) (SCM_SET_CELL_OBJECT_3 ((X), (o))) -extern SCM scm_weak_vectors; +SCM_API SCM scm_weak_vectors; -extern SCM scm_make_weak_vector (SCM k, SCM fill); -extern SCM scm_weak_vector (SCM l); -extern SCM scm_weak_vector_p (SCM x); -extern SCM scm_make_weak_key_hash_table (SCM k); -extern SCM scm_make_weak_value_hash_table (SCM k); -extern SCM scm_make_doubly_weak_hash_table (SCM k); -extern SCM scm_weak_key_hash_table_p (SCM x); -extern SCM scm_weak_value_hash_table_p (SCM x); -extern SCM scm_doubly_weak_hash_table_p (SCM x); -extern void scm_weaks_prehistory (void); -extern void scm_init_weaks (void); +SCM_API SCM scm_make_weak_vector (SCM k, SCM fill); +SCM_API SCM scm_weak_vector (SCM l); +SCM_API SCM scm_weak_vector_p (SCM x); +SCM_API SCM scm_make_weak_key_hash_table (SCM k); +SCM_API SCM scm_make_weak_value_hash_table (SCM k); +SCM_API SCM scm_make_doubly_weak_hash_table (SCM k); +SCM_API SCM scm_weak_key_hash_table_p (SCM x); +SCM_API SCM scm_weak_value_hash_table_p (SCM x); +SCM_API SCM scm_doubly_weak_hash_table_p (SCM x); +SCM_API void scm_weaks_prehistory (void); +SCM_API void scm_init_weaks (void); #endif /* SCM_WEAKS_H */ From cb0abacf36ddbcf48e635bcc6bbbc783cecd024c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:19:42 +0000 Subject: [PATCH 094/281] Put `-no-undefined' into LDFLAGS to support linkers which do not allow unresolved symbols inside shared libraries. --- srfi/Makefile.am | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/srfi/Makefile.am b/srfi/Makefile.am index 01e16aa99..00ec079bd 100644 --- a/srfi/Makefile.am +++ b/srfi/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = gnu ## Prevent automake from adding extra -I options -DEFS = @DEFS@ +DEFS = @DEFS@ @EXTRA_DEFS@ ## Check for headers in $(srcdir)/.., so that #include ## will find MUMBLE.h in this dir when we're ## building. @@ -34,10 +34,12 @@ lib_LTLIBRARIES = libguile-srfi-srfi-13-14.la libguile-srfi-srfi-4.la BUILT_SOURCES = srfi-13.x srfi-14.x srfi-4.x libguile_srfi_srfi_13_14_la_SOURCES = srfi-13.x srfi-13.c srfi-14.x srfi-14.c\ srfi-13.h srfi-14.h -libguile_srfi_srfi_13_14_la_LDFLAGS = -version-info 0:0 -export-dynamic +libguile_srfi_srfi_13_14_la_LDFLAGS = -version-info 0:0 -export-dynamic -no-undefined +libguile_srfi_srfi_13_14_la_LIBADD = $(top_srcdir)/libguile/libguile.la libguile_srfi_srfi_4_la_SOURCES = srfi-4.x srfi-4.c srfi-4.h -libguile_srfi_srfi_4_la_LDFLAGS = -version-info 0:0 -export-dynamic +libguile_srfi_srfi_4_la_LDFLAGS = -version-info 0:0 -export-dynamic -no-undefined +libguile_srfi_srfi_4_la_LIBADD = $(top_srcdir)/libguile/libguile.la srfidir = $(datadir)/guile/$(VERSION)/srfi srfi_DATA = srfi-1.scm \ From 88a934718716ccfa73925b9f30593a8f6e52d6ee Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:21:17 +0000 Subject: [PATCH 095/281] Defined SCM_SRFI1314_API. Prefixed each exported symbol with SCM_SRFI1314_API. --- srfi/srfi-13.h | 166 ++++++++++++++++++++++++++----------------------- srfi/srfi-14.h | 110 +++++++++++++++++--------------- 2 files changed, 150 insertions(+), 126 deletions(-) diff --git a/srfi/srfi-13.h b/srfi/srfi-13.h index 5a66015c2..0c81a43a5 100644 --- a/srfi/srfi-13.h +++ b/srfi/srfi-13.h @@ -46,84 +46,96 @@ * If you do not wish that, delete this exception notice. */ -void scm_init_srfi_13 (void); -void scm_init_srfi_13_14 (void); +/* SCM_SRFI1314_API is a macro prepended to all function and data definitions + which should be exported or imported in the resulting dynamic link + library in the Win32 port. */ -SCM scm_string_any (SCM pred, SCM s, SCM start, SCM end); -SCM scm_string_every (SCM pred, SCM s, SCM start, SCM end); -SCM scm_string_tabulate (SCM proc, SCM len); -SCM scm_string_to_listS (SCM str, SCM start, SCM end); -SCM scm_reverse_list_to_string (SCM chrs); -SCM scm_string_join (SCM ls, SCM delimiter, SCM grammar); -SCM scm_string_copyS (SCM str, SCM start, SCM end); -SCM scm_substring_shared (SCM str, SCM start, SCM end); -SCM scm_string_copy_x (SCM target, SCM tstart, SCM s, SCM start, SCM end); -SCM scm_string_take (SCM s, SCM n); -SCM scm_string_drop (SCM s, SCM n); -SCM scm_string_take_right (SCM s, SCM n); -SCM scm_string_drop_right (SCM s, SCM n); -SCM scm_string_pad (SCM s, SCM len, SCM chr, SCM start, SCM end); -SCM scm_string_pad_right (SCM s, SCM len, SCM chr, SCM start, SCM end); -SCM scm_string_trim (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_trim_right (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_trim_both (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_fill_xS (SCM str, SCM chr, SCM start, SCM end); -SCM scm_string_compare (SCM s1, SCM s2, SCM proc_lt, SCM proc_eq, SCM proc_gt, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_compare_ci (SCM s1, SCM s2, SCM proc_lt, SCM proc_eq, SCM proc_gt, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_eq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_neq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_lt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_gt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_le (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ge (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ci_eq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ci_neq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ci_lt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ci_gt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ci_le (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_ci_ge (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_prefix_length (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_prefix_length_ci (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_suffix_length (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_suffix_length_ci (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_prefix_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_prefix_ci_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_suffix_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_suffix_ci_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_indexS (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_index_right (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_skip (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_skip_right (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_count (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_contains (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_contains_ci (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_upcase_xS (SCM str, SCM start, SCM end); -SCM scm_string_upcaseS (SCM str, SCM start, SCM end); -SCM scm_string_downcase_xS (SCM str, SCM start, SCM end); -SCM scm_string_downcaseS (SCM str, SCM start, SCM end); -SCM scm_string_titlecase_x (SCM str, SCM start, SCM end); -SCM scm_string_titlecase (SCM str, SCM start, SCM end); -SCM scm_string_reverse (SCM str, SCM start, SCM end); -SCM scm_string_reverse_x (SCM str, SCM start, SCM end); -SCM scm_string_append_shared (SCM ls); -SCM scm_string_concatenate (SCM ls); -SCM scm_string_concatenate_shared (SCM ls); -SCM scm_string_concatenate_reverse (SCM ls, SCM final_string, SCM end); -SCM scm_string_concatenate_reverse_shared (SCM ls, SCM final_string, SCM end); -SCM scm_string_map (SCM proc, SCM s, SCM start, SCM end); -SCM scm_string_map_x (SCM proc, SCM s, SCM start, SCM end); -SCM scm_string_fold (SCM kons, SCM knil, SCM s, SCM start, SCM end); -SCM scm_string_fold_right (SCM kons, SCM knil, SCM s, SCM start, SCM end); -SCM scm_string_unfold (SCM p, SCM f, SCM g, SCM seed, SCM base, SCM make_final); -SCM scm_string_unfold_right (SCM p, SCM f, SCM g, SCM seed, SCM base, SCM make_final); -SCM scm_string_for_each (SCM proc, SCM s, SCM start, SCM end); -SCM scm_string_for_each_index (SCM proc, SCM s, SCM start, SCM end); -SCM scm_xsubstring (SCM s, SCM from, SCM to, SCM start, SCM end); -SCM scm_string_xcopy_x (SCM target, SCM tstart, SCM s, SCM sfrom, SCM sto, SCM start, SCM end); -SCM scm_string_replace (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); -SCM scm_string_tokenize (SCM s, SCM token_char, SCM start, SCM end); -SCM scm_string_filter (SCM s, SCM char_pred, SCM start, SCM end); -SCM scm_string_delete (SCM s, SCM char_pred, SCM start, SCM end); +#if defined (__SCM_SRFI1314_IMPORT__) +# define SCM_SRFI1314_API __declspec (dllimport) extern +#elif defined (__SCM_SRFI1314_EXPORT__) || defined (DLL_EXPORT) +# define SCM_SRFI1314_API __declspec (dllexport) extern +#else +# define SCM_SRFI1314_API extern +#endif + +SCM_SRFI1314_API void scm_init_srfi_13 (void); +SCM_SRFI1314_API void scm_init_srfi_13_14 (void); + +SCM_SRFI1314_API SCM scm_string_any (SCM pred, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_every (SCM pred, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_tabulate (SCM proc, SCM len); +SCM_SRFI1314_API SCM scm_string_to_listS (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_reverse_list_to_string (SCM chrs); +SCM_SRFI1314_API SCM scm_string_join (SCM ls, SCM delimiter, SCM grammar); +SCM_SRFI1314_API SCM scm_string_copyS (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_substring_shared (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_copy_x (SCM target, SCM tstart, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_take (SCM s, SCM n); +SCM_SRFI1314_API SCM scm_string_drop (SCM s, SCM n); +SCM_SRFI1314_API SCM scm_string_take_right (SCM s, SCM n); +SCM_SRFI1314_API SCM scm_string_drop_right (SCM s, SCM n); +SCM_SRFI1314_API SCM scm_string_pad (SCM s, SCM len, SCM chr, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_pad_right (SCM s, SCM len, SCM chr, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_trim (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_trim_right (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_trim_both (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_fill_xS (SCM str, SCM chr, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_compare (SCM s1, SCM s2, SCM proc_lt, SCM proc_eq, SCM proc_gt, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_compare_ci (SCM s1, SCM s2, SCM proc_lt, SCM proc_eq, SCM proc_gt, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_eq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_neq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_lt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_gt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_le (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ge (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ci_eq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ci_neq (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ci_lt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ci_gt (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ci_le (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_ci_ge (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_prefix_length (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_prefix_length_ci (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_suffix_length (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_suffix_length_ci (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_prefix_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_prefix_ci_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_suffix_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_suffix_ci_p (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_indexS (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_index_right (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_skip (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_skip_right (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_count (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_contains (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_contains_ci (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_upcase_xS (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_upcaseS (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_downcase_xS (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_downcaseS (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_titlecase_x (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_titlecase (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_reverse (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_reverse_x (SCM str, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_append_shared (SCM ls); +SCM_SRFI1314_API SCM scm_string_concatenate (SCM ls); +SCM_SRFI1314_API SCM scm_string_concatenate_shared (SCM ls); +SCM_SRFI1314_API SCM scm_string_concatenate_reverse (SCM ls, SCM final_string, SCM end); +SCM_SRFI1314_API SCM scm_string_concatenate_reverse_shared (SCM ls, SCM final_string, SCM end); +SCM_SRFI1314_API SCM scm_string_map (SCM proc, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_map_x (SCM proc, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_fold (SCM kons, SCM knil, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_fold_right (SCM kons, SCM knil, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_unfold (SCM p, SCM f, SCM g, SCM seed, SCM base, SCM make_final); +SCM_SRFI1314_API SCM scm_string_unfold_right (SCM p, SCM f, SCM g, SCM seed, SCM base, SCM make_final); +SCM_SRFI1314_API SCM scm_string_for_each (SCM proc, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_for_each_index (SCM proc, SCM s, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_xsubstring (SCM s, SCM from, SCM to, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_xcopy_x (SCM target, SCM tstart, SCM s, SCM sfrom, SCM sto, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_replace (SCM s1, SCM s2, SCM start1, SCM end1, SCM start2, SCM end2); +SCM_SRFI1314_API SCM scm_string_tokenize (SCM s, SCM token_char, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_filter (SCM s, SCM char_pred, SCM start, SCM end); +SCM_SRFI1314_API SCM scm_string_delete (SCM s, SCM char_pred, SCM start, SCM end); diff --git a/srfi/srfi-14.h b/srfi/srfi-14.h index cef7e5089..fbf935e30 100644 --- a/srfi/srfi-14.h +++ b/srfi/srfi-14.h @@ -46,6 +46,18 @@ * If you do not wish that, delete this exception notice. */ +/* SCM_SRFI1314_API is a macro prepended to all function and data definitions + which should be exported or imported in the resulting dynamic link + library in the Win32 port. */ + +#if defined (__SCM_SRFI1314_IMPORT__) +# define SCM_SRFI1314_API __declspec (dllimport) extern +#elif defined (__SCM_SRFI1314_EXPORT__) || defined (DLL_EXPORT) +# define SCM_SRFI1314_API __declspec (dllexport) extern +#else +# define SCM_SRFI1314_API extern +#endif + #define SCM_CHARSET_SIZE 256 /* We expect 8-bit bytes here. Shoule be no problem in the year @@ -61,56 +73,56 @@ #define SCM_CHARSETP(x) (!SCM_IMP (x) && (SCM_TYP16 (x) == scm_tc16_charset)) /* Smob type code for character sets. */ -extern int scm_tc16_charset; +SCM_SRFI1314_API int scm_tc16_charset; -void scm_c_init_srfi_14 (void); -void scm_init_srfi_14 (void); +SCM_SRFI1314_API void scm_c_init_srfi_14 (void); +SCM_SRFI1314_API void scm_init_srfi_14 (void); -SCM scm_char_set_p (SCM obj); -SCM scm_char_set_eq (SCM char_sets); -SCM scm_char_set_leq (SCM char_sets); -SCM scm_char_set_hash (SCM cs, SCM bound); -SCM scm_char_set_cursor (SCM cs); -SCM scm_char_set_ref (SCM cs, SCM cursor); -SCM scm_char_set_cursor_next (SCM cs, SCM cursor); -SCM scm_end_of_char_set_p (SCM cursor); -SCM scm_char_set_fold (SCM kons, SCM knil, SCM cs); -SCM scm_char_set_unfold (SCM p, SCM f, SCM g, SCM seed, SCM base_cs); -SCM scm_char_set_unfold_x (SCM p, SCM f, SCM g, SCM seed, SCM base_cs); -SCM scm_char_set_for_each (SCM proc, SCM cs); -SCM scm_char_set_map (SCM proc, SCM cs); -SCM scm_char_set_copy (SCM cs); -SCM scm_char_set (SCM rest); -SCM scm_list_to_char_set (SCM list, SCM base_cs); -SCM scm_list_to_char_set_x (SCM list, SCM base_cs); -SCM scm_string_to_char_set (SCM str, SCM base_cs); -SCM scm_string_to_char_set_x (SCM str, SCM base_cs); -SCM scm_char_set_filter (SCM pred, SCM cs, SCM base_cs); -SCM scm_char_set_filter_x (SCM pred, SCM cs, SCM base_cs); -SCM scm_ucs_range_to_char_set (SCM lower, SCM upper, SCM error, SCM base_cs); -SCM scm_ucs_range_to_char_set_x (SCM lower, SCM upper, SCM error, SCM base_cs); -SCM scm_char_set_size (SCM cs); -SCM scm_char_set_count (SCM pred, SCM cs); -SCM scm_char_set_to_list (SCM cs); -SCM scm_char_set_to_string (SCM cs); -SCM scm_char_set_contains_p (SCM cs, SCM ch); -SCM scm_char_set_every (SCM pred, SCM cs); -SCM scm_char_set_any (SCM pred, SCM cs); -SCM scm_char_set_adjoin (SCM cs, SCM rest); -SCM scm_char_set_delete (SCM cs, SCM rest); -SCM scm_char_set_adjoin_x (SCM cs, SCM rest); -SCM scm_char_set_delete_x (SCM cs, SCM rest); -SCM scm_char_set_complement (SCM cs); -SCM scm_char_set_union (SCM rest); -SCM scm_char_set_intersection (SCM rest); -SCM scm_char_set_difference (SCM cs1, SCM rest); -SCM scm_char_set_xor (SCM rest); -SCM scm_char_set_diff_plus_intersection (SCM cs1, SCM rest); -SCM scm_char_set_complement_x (SCM cs); -SCM scm_char_set_union_x (SCM cs1, SCM rest); -SCM scm_char_set_intersection_x (SCM cs1, SCM rest); -SCM scm_char_set_difference_x (SCM cs1, SCM rest); -SCM scm_char_set_xor_x (SCM cs1, SCM rest); -SCM scm_char_set_diff_plus_intersection_x (SCM cs1, SCM cs2, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_p (SCM obj); +SCM_SRFI1314_API SCM scm_char_set_eq (SCM char_sets); +SCM_SRFI1314_API SCM scm_char_set_leq (SCM char_sets); +SCM_SRFI1314_API SCM scm_char_set_hash (SCM cs, SCM bound); +SCM_SRFI1314_API SCM scm_char_set_cursor (SCM cs); +SCM_SRFI1314_API SCM scm_char_set_ref (SCM cs, SCM cursor); +SCM_SRFI1314_API SCM scm_char_set_cursor_next (SCM cs, SCM cursor); +SCM_SRFI1314_API SCM scm_end_of_char_set_p (SCM cursor); +SCM_SRFI1314_API SCM scm_char_set_fold (SCM kons, SCM knil, SCM cs); +SCM_SRFI1314_API SCM scm_char_set_unfold (SCM p, SCM f, SCM g, SCM seed, SCM base_cs); +SCM_SRFI1314_API SCM scm_char_set_unfold_x (SCM p, SCM f, SCM g, SCM seed, SCM base_cs); +SCM_SRFI1314_API SCM scm_char_set_for_each (SCM proc, SCM cs); +SCM_SRFI1314_API SCM scm_char_set_map (SCM proc, SCM cs); +SCM_SRFI1314_API SCM scm_char_set_copy (SCM cs); +SCM_SRFI1314_API SCM scm_char_set (SCM rest); +SCM_SRFI1314_API SCM scm_list_to_char_set (SCM list, SCM base_cs); +SCM_SRFI1314_API SCM scm_list_to_char_set_x (SCM list, SCM base_cs); +SCM_SRFI1314_API SCM scm_string_to_char_set (SCM str, SCM base_cs); +SCM_SRFI1314_API SCM scm_string_to_char_set_x (SCM str, SCM base_cs); +SCM_SRFI1314_API SCM scm_char_set_filter (SCM pred, SCM cs, SCM base_cs); +SCM_SRFI1314_API SCM scm_char_set_filter_x (SCM pred, SCM cs, SCM base_cs); +SCM_SRFI1314_API SCM scm_ucs_range_to_char_set (SCM lower, SCM upper, SCM error, SCM base_cs); +SCM_SRFI1314_API SCM scm_ucs_range_to_char_set_x (SCM lower, SCM upper, SCM error, SCM base_cs); +SCM_SRFI1314_API SCM scm_char_set_size (SCM cs); +SCM_SRFI1314_API SCM scm_char_set_count (SCM pred, SCM cs); +SCM_SRFI1314_API SCM scm_char_set_to_list (SCM cs); +SCM_SRFI1314_API SCM scm_char_set_to_string (SCM cs); +SCM_SRFI1314_API SCM scm_char_set_contains_p (SCM cs, SCM ch); +SCM_SRFI1314_API SCM scm_char_set_every (SCM pred, SCM cs); +SCM_SRFI1314_API SCM scm_char_set_any (SCM pred, SCM cs); +SCM_SRFI1314_API SCM scm_char_set_adjoin (SCM cs, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_delete (SCM cs, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_adjoin_x (SCM cs, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_delete_x (SCM cs, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_complement (SCM cs); +SCM_SRFI1314_API SCM scm_char_set_union (SCM rest); +SCM_SRFI1314_API SCM scm_char_set_intersection (SCM rest); +SCM_SRFI1314_API SCM scm_char_set_difference (SCM cs1, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_xor (SCM rest); +SCM_SRFI1314_API SCM scm_char_set_diff_plus_intersection (SCM cs1, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_complement_x (SCM cs); +SCM_SRFI1314_API SCM scm_char_set_union_x (SCM cs1, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_intersection_x (SCM cs1, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_difference_x (SCM cs1, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_xor_x (SCM cs1, SCM rest); +SCM_SRFI1314_API SCM scm_char_set_diff_plus_intersection_x (SCM cs1, SCM cs2, SCM rest); #endif /* SCM_SRFI_14_H */ From 064a03fd191f8a384421fcd4e0302a43b91b1eb1 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:21:25 +0000 Subject: [PATCH 096/281] Defined SCM_SRFI4_API. Prefixed each exported symbol with SCM_SRFI4_API. --- srfi/srfi-4.h | 174 +++++++++++++++++++++++++++----------------------- 1 file changed, 93 insertions(+), 81 deletions(-) diff --git a/srfi/srfi-4.h b/srfi/srfi-4.h index 2b8df5161..f53784d60 100644 --- a/srfi/srfi-4.h +++ b/srfi/srfi-4.h @@ -46,96 +46,108 @@ * If you do not wish that, delete this exception notice. */ -SCM scm_u8vector_p (SCM obj); -SCM scm_make_u8vector (SCM n, SCM fill); -SCM scm_u8vector (SCM l); -SCM scm_u8vector_length (SCM uvec); -SCM scm_u8vector_ref (SCM uvec, SCM index); -SCM scm_u8vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_u8vector_to_list (SCM uvec); -SCM scm_list_to_u8vector (SCM l); +/* SCM_SRFI4_API is a macro prepended to all function and data definitions + which should be exported or imported in the resulting dynamic link + library in the Win32 port. */ -SCM scm_s8vector_p (SCM obj); -SCM scm_make_s8vector (SCM n, SCM fill); -SCM scm_s8vector (SCM l); -SCM scm_s8vector_length (SCM uvec); -SCM scm_s8vector_ref (SCM uvec, SCM index); -SCM scm_s8vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_s8vector_to_list (SCM uvec); -SCM scm_list_to_s8vector (SCM l); +#if defined (__SCM_SRFI4_IMPORT__) +# define SCM_SRFI4_API __declspec (dllimport) extern +#elif defined (__SCM_SRFI4_EXPORT__) || defined (DLL_EXPORT) +# define SCM_SRFI4_API __declspec (dllexport) extern +#else +# define SCM_SRFI4_API extern +#endif -SCM scm_u16vector_p (SCM obj); -SCM scm_make_u16vector (SCM n, SCM fill); -SCM scm_u16vector (SCM l); -SCM scm_u16vector_length (SCM uvec); -SCM scm_u16vector_ref (SCM uvec, SCM index); -SCM scm_u16vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_u16vector_to_list (SCM uvec); -SCM scm_list_to_u16vector (SCM l); +SCM_SRFI4_API SCM scm_u8vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_u8vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_u8vector (SCM l); +SCM_SRFI4_API SCM scm_u8vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_u8vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_u8vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_u8vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_u8vector (SCM l); -SCM scm_s16vector_p (SCM obj); -SCM scm_make_s16vector (SCM n, SCM fill); -SCM scm_s16vector (SCM l); -SCM scm_s16vector_length (SCM uvec); -SCM scm_s16vector_ref (SCM uvec, SCM index); -SCM scm_s16vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_s16vector_to_list (SCM uvec); -SCM scm_list_to_s16vector (SCM l); +SCM_SRFI4_API SCM scm_s8vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_s8vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_s8vector (SCM l); +SCM_SRFI4_API SCM scm_s8vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_s8vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_s8vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_s8vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_s8vector (SCM l); -SCM scm_u32vector_p (SCM obj); -SCM scm_make_u32vector (SCM n, SCM fill); -SCM scm_u32vector (SCM l); -SCM scm_u32vector_length (SCM uvec); -SCM scm_u32vector_ref (SCM uvec, SCM index); -SCM scm_u32vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_u32vector_to_list (SCM uvec); -SCM scm_list_to_u32vector (SCM l); +SCM_SRFI4_API SCM scm_u16vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_u16vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_u16vector (SCM l); +SCM_SRFI4_API SCM scm_u16vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_u16vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_u16vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_u16vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_u16vector (SCM l); -SCM scm_s32vector_p (SCM obj); -SCM scm_make_s32vector (SCM n, SCM fill); -SCM scm_s32vector (SCM l); -SCM scm_s32vector_length (SCM uvec); -SCM scm_s32vector_ref (SCM uvec, SCM index); -SCM scm_s32vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_s32vector_to_list (SCM uvec); -SCM scm_list_to_s32vector (SCM l); +SCM_SRFI4_API SCM scm_s16vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_s16vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_s16vector (SCM l); +SCM_SRFI4_API SCM scm_s16vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_s16vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_s16vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_s16vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_s16vector (SCM l); -SCM scm_u64vector_p (SCM obj); -SCM scm_make_u64vector (SCM n, SCM fill); -SCM scm_u64vector (SCM l); -SCM scm_u64vector_length (SCM uvec); -SCM scm_u64vector_ref (SCM uvec, SCM index); -SCM scm_u64vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_u64vector_to_list (SCM uvec); -SCM scm_list_to_u64vector (SCM l); +SCM_SRFI4_API SCM scm_u32vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_u32vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_u32vector (SCM l); +SCM_SRFI4_API SCM scm_u32vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_u32vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_u32vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_u32vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_u32vector (SCM l); -SCM scm_s64vector_p (SCM obj); -SCM scm_make_s64vector (SCM n, SCM fill); -SCM scm_s64vector (SCM l); -SCM scm_s64vector_length (SCM uvec); -SCM scm_s64vector_ref (SCM uvec, SCM index); -SCM scm_s64vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_s64vector_to_list (SCM uvec); -SCM scm_list_to_s64vector (SCM l); +SCM_SRFI4_API SCM scm_s32vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_s32vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_s32vector (SCM l); +SCM_SRFI4_API SCM scm_s32vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_s32vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_s32vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_s32vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_s32vector (SCM l); -SCM scm_f32vector_p (SCM obj); -SCM scm_make_f32vector (SCM n, SCM fill); -SCM scm_f32vector (SCM l); -SCM scm_f32vector_length (SCM uvec); -SCM scm_f32vector_ref (SCM uvec, SCM index); -SCM scm_f32vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_f32vector_to_list (SCM uvec); -SCM scm_list_to_f32vector (SCM l); +SCM_SRFI4_API SCM scm_u64vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_u64vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_u64vector (SCM l); +SCM_SRFI4_API SCM scm_u64vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_u64vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_u64vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_u64vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_u64vector (SCM l); -SCM scm_f64vector_p (SCM obj); -SCM scm_make_f64vector (SCM n, SCM fill); -SCM scm_f64vector (SCM l); -SCM scm_f64vector_length (SCM uvec); -SCM scm_f64vector_ref (SCM uvec, SCM index); -SCM scm_f64vector_set_x (SCM uvec, SCM index, SCM value); -SCM scm_f64vector_to_list (SCM uvec); -SCM scm_list_to_f64vector (SCM l); +SCM_SRFI4_API SCM scm_s64vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_s64vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_s64vector (SCM l); +SCM_SRFI4_API SCM scm_s64vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_s64vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_s64vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_s64vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_s64vector (SCM l); -void scm_init_srfi_4 (void); +SCM_SRFI4_API SCM scm_f32vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_f32vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_f32vector (SCM l); +SCM_SRFI4_API SCM scm_f32vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_f32vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_f32vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_f32vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_f32vector (SCM l); + +SCM_SRFI4_API SCM scm_f64vector_p (SCM obj); +SCM_SRFI4_API SCM scm_make_f64vector (SCM n, SCM fill); +SCM_SRFI4_API SCM scm_f64vector (SCM l); +SCM_SRFI4_API SCM scm_f64vector_length (SCM uvec); +SCM_SRFI4_API SCM scm_f64vector_ref (SCM uvec, SCM index); +SCM_SRFI4_API SCM scm_f64vector_set_x (SCM uvec, SCM index, SCM value); +SCM_SRFI4_API SCM scm_f64vector_to_list (SCM uvec); +SCM_SRFI4_API SCM scm_list_to_f64vector (SCM l); + +SCM_SRFI4_API void scm_init_srfi_4 (void); #endif /* SCM_SRFI_4_H */ From f712d833cc21f113317961a17e551f860f8cea97 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:21:34 +0000 Subject: [PATCH 097/281] *** empty log message *** --- libguile/ChangeLog | 76 ++++++++++++++++++++++++++++++++++++++++++++++ srfi/ChangeLog | 13 ++++++++ 2 files changed, 89 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index d958496f6..998b53f47 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,79 @@ +2001-11-02 Marius Vollmer + + Support for native Win32. Thanks to Stefan Jahn! + + * Makefile.am: Add win32-uname.c, win32-uname.h, win32-dirent.c + and win32-dirent.h to extra source and header files. These + include the uname() and the POSIX dirent interface implementation + for M$-Windows. Put `-no-undefined' into LDFLAGS to support + linkers which do not allow unresolved symbols inside shared + libraries. Corrected `guile_filter_doc_snarfage$(EXEEXT)' + dependency. + + * __scm.h: Defined SCM_API. This macro gets prepended to all + function and data definitions which should be exported or imported + in the resulting dynamic link library in the Win32 port. + + * __scm.h, alist.h, arbiters.h, async.h, backtrace.h, boolean.h, + chars.h, continuations.h, coop-defs.h, coop-threads.h, + debug-malloc.h, debug.h, deprecation.h, dynl.h, dynwind.h, + environments.h, eq.h, error.h, eval.h, evalext.h, extensions.h, + feature.h, filesys.h, fluids.h, fports.h, gc.h, gdb_interface.h, + gdbint.h, gh.h, goops.h, gsubr.h, guardians.h, hash.h, hashtab.h, + hooks.h, init.h, ioext.h, iselect.h, keywords.h, lang.h, list.h, + load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h, + objects.h, objprop.h, options.h, pairs.h, ports.h, posix.h, print.h, + procprop.h, procs.h, properties.h, ramap.h, random.h, rdelim.h, + read.h, regex-posix.h, root.h, rw.h, scmsigs.h, script.h, simpos.h, + smob.h, socket.h, sort.h, srcprop.h, stackchk.h, stacks.h, stime.h, + strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h, + tags.h, threads.h, throw.h, unif.h, values.h, variable.h, vectors.h, + vports.h, weaks.h: + Prefixed each each exported symbol with SCM_API. + + * continuations.c: Added comment about the use of the extern + declarations of {get,set}context() functions used in the ia64 port. + + * continuations.h, gc.c: `__libc_ia64_register_backing_store_base' + is meant to be a `unsigned long *'. + + * filesys.c: Include `direct.h' if possible. Use local + `win32-dirent.h' for the native M$-Windows port. Define S_IS*() + macros for M$-Windows. Implementation of `fstat_Win32()' which is + able to differentiate between sockets and other file descriptors. + Use this function as wrapper in `scm_fstat()'. Fixed typo in + `scm_dirname()'. + + * fports.c: Include `io.h' is possible. Put `*fp' into referring + statement block in `scm_fport_buffer_add()'. + Some corrections in `getflags()'. + + * gdb_interface.h (GDB_INTERFACE): Also support __CYGWIN__. + + * guile.c: Make sure to define __SCM_IMPORT__ for shared library + build on Win32. Disable preloaded symbols on Win2 platforms. + + * ioext.c, ports.c: Include `io.h' is possible. + + * mkstemp.c: Include `process.h' is possible. + + * net_db.c: Disable extern declaration of `h_errno' for __CYGWIN__, + too. + Put `scm_return_entry()' into HAVE_GETSERVENT conditional. + + * posix.c: Remove unnecessary dirent includes and defines. Include + local `win32-uname.h' for MinGW. Extern declaration of + `mkstemp()' for systems where it does not exists. Make + `getlogin()' available on M$-Windows. + + * scmsigs.c: Made `usleep()' avalable on MinGW. + + * stime.c: On M$-Windows `tzname[]' is known to be `_tzname[]'. + + * win32-dirent.c: Include "win32-dirent.h", not "dirent.h". + + * win32-uname.c: Include "win32-uname.h", not "uname.h". + 2001-10-28 Mikael Djurfeldt * unif.c (scm_uniform_array_read_x, scm_uniform_array_write): diff --git a/srfi/ChangeLog b/srfi/ChangeLog index a6a49435e..8b7fdbb23 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,16 @@ +2001-11-02 Marius Vollmer + + Support for native Win32. Thanks to Stefan Jahn! + + * Makefile.am: Put `-no-undefined' into LDFLAGS to support linkers + which do not allow unresolved symbols inside shared libraries. + + * srfi-13.h, srfi-14.h: Defined SCM_SRFI1314_API. Prefixed each + exported symbol with SCM_SRFI1314_API. + + * srfi-4.h: Defined SCM_SRFI4_API. Prefixed each exported + symbol with SCM_SRFI4_API. + 2001-10-21 Mikael Djurfeldt * srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm, From 4aa104a48505b27970b370d00cbc125e06a38736 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 2 Nov 2001 00:37:07 +0000 Subject: [PATCH 098/281] *** empty log message *** --- NEWS | 15 +++++++++++++++ THANKS | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/NEWS b/NEWS index 0634cd840..eb766c7e5 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,21 @@ compare their values. This is no longer done. Variables are now only This function creates a scheme string from a 0-terminated C string. The input string is copied. +** Declarations of exported features are marked with SCM_API. + +Every declaration of a feature that belongs to the exported Guile API +has been marked by adding the macro "SCM_API" to the start of the +declaration. This macro can expand into different things, the most +common of which is just "extern" for Unix platforms. On Win32, it can +be used to control which symbols are exported from a DLL. + +If you `#define __SCM_IMPORT__' before including , SCM_API +will expand into "__declspec (dllimport) extern", which is needed for +linking to the Guile DLL in Windows. + +There are also __SCM_RL_IMPORT__, __SCM_SRFI1314_IMPORT__, and +__SCM_SRFI4_IMPORT__, for the corresponding libraries. + Changes since Guile 1.4: * Changes to the distribution diff --git a/THANKS b/THANKS index b32f84671..167327846 100644 --- a/THANKS +++ b/THANKS @@ -5,6 +5,10 @@ The Guile maintainer committee consists of Contributors since the last release: + Rob Browning + Stefan Jahn + Thien-Thi Nguyen + For fixes or providing information which led to a fix: Martin Baulig From ebd3a55a52c30d29121685bfe19648708b067b2e Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 2 Nov 2001 01:42:06 +0000 Subject: [PATCH 099/281] Add SCM_API patch incorporation; associate mvo w/ it. --- TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO b/TODO index 98f85a45f..a8198082f 100644 --- a/TODO +++ b/TODO @@ -63,6 +63,8 @@ that user-visible changes are reflected in NEWS. * Before releasing 1.8.0: +- incorporate SCM_API patch(es) by Stefan Jahn [mvo] + - For GOOPS: [ttn] - rewrite method cache management in C - rewrite core macros (define-class et al) in C From 08112c957b93167b622a5502fb95ac683246becf Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Fri, 2 Nov 2001 12:31:50 +0000 Subject: [PATCH 100/281] * unif.c (scm_ra2contig): Fixed memory overwrite bug. --- libguile/ChangeLog | 4 ++++ libguile/unif.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 998b53f47..35da7eb44 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,7 @@ +2001-11-02 Mikael Djurfeldt + + * unif.c (scm_ra2contig): Fixed memory overwrite bug. + 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! diff --git a/libguile/unif.c b/libguile/unif.c index 2ace9239e..392e376b2 100644 --- a/libguile/unif.c +++ b/libguile/unif.c @@ -1472,7 +1472,7 @@ scm_ra2contig (SCM ra, int copy) SCM_ARRAY_DIMS (ret)[k].inc = inc; inc *= SCM_ARRAY_DIMS (ra)[k].ubnd - SCM_ARRAY_DIMS (ra)[k].lbnd + 1; } - SCM_ARRAY_V (ret) = scm_make_uve ((inc - 1), scm_array_prototype (ra)); + SCM_ARRAY_V (ret) = scm_make_uve (inc, scm_array_prototype (ra)); if (copy) scm_array_copy_x (ra, ret); return ret; From 7663c008a575968cf83b42a832d7038e7cc9938d Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Fri, 2 Nov 2001 13:55:38 +0000 Subject: [PATCH 101/281] * print.c (scm_iprin1): Mark print state as revealed when dispatching to generic write or display. --- libguile/ChangeLog | 3 +++ libguile/print.c | 1 + 2 files changed, 4 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 35da7eb44..a8d09e2ad 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,8 @@ 2001-11-02 Mikael Djurfeldt + * print.c (scm_iprin1): Mark print state as revealed when + dispatching to generic write or display. + * unif.c (scm_ra2contig): Fixed memory overwrite bug. 2001-11-02 Marius Vollmer diff --git a/libguile/print.c b/libguile/print.c index 31b12e5ce..369b112bb 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -462,6 +462,7 @@ scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate) SCM_NEWSMOB (pwps, scm_tc16_port_with_ps, SCM_UNPACK (scm_cons (port, pstate->handle))); + pstate->revealed = 1; scm_call_generic_2 (print, exp, pwps); } else From b8113bc8dcd06cb745dd3a0d10387a79b42b422a Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 3 Nov 2001 18:45:33 +0000 Subject: [PATCH 102/281] (scm_m_begin): Allow `(begin)`, with no subforms. (SCM_CEVAL): Evaluate an empty `begin' to SCM_UNSPECIFIED. --- libguile/eval.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libguile/eval.c b/libguile/eval.c index c6a209cb2..420328e2a 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -528,7 +528,7 @@ SCM_GLOBAL_SYMBOL (scm_sym_begin, s_begin); SCM scm_m_begin (SCM xorig, SCM env SCM_UNUSED) { - SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 1, scm_s_expression, s_begin); + SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 0, scm_s_expression, s_begin); return scm_cons (SCM_IM_BEGIN, SCM_CDR (xorig)); } @@ -1961,6 +1961,9 @@ dispatch: goto carloop; case SCM_BIT8(SCM_IM_BEGIN): + if (SCM_NULLP (SCM_CDR (x))) + RETURN (SCM_UNSPECIFIED); + /* (currently unused) cdrxnoap: */ PREP_APPLY (SCM_UNDEFINED, SCM_EOL); From 4e21fa609606c1fbce5bfb2f2ab6fa06d9483873 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 3 Nov 2001 18:46:31 +0000 Subject: [PATCH 103/281] *** empty log message *** --- NEWS | 5 +++++ libguile/ChangeLog | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/NEWS b/NEWS index eb766c7e5..75987bfda 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,11 @@ Previously, comparing two variables with `equal?' would recursivly compare their values. This is no longer done. Variables are now only `equal?' if they are `eq?'. +** `(begin)' is now valid. + +You can now use an empty `begin' form. It will yield # +when evaluated and simply be ignored in a definition context. + * Changes to the C interface ** New function: scm_str2string diff --git a/libguile/ChangeLog b/libguile/ChangeLog index a8d09e2ad..38f136a3c 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-03 Marius Vollmer + + * eval.c (scm_m_begin): Allow `(begin)`, with no subforms. + (SCM_CEVAL): Evaluate an empty `begin' to SCM_UNSPECIFIED. + 2001-11-02 Mikael Djurfeldt * print.c (scm_iprin1): Mark print state as revealed when From 56b0cb03ebaa313d364eb264a5f6397d34b2e30a Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 3 Nov 2001 23:06:40 +0000 Subject: [PATCH 104/281] (libguile_srfi_srfi_4_la_LIBADD, libguile_srfi_srfi_13_14_la_LIBADD): Refer to build directory, not the source directory, for libguile.la. Thanks to Ken Raeburn. --- srfi/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srfi/Makefile.am b/srfi/Makefile.am index 00ec079bd..996b6aace 100644 --- a/srfi/Makefile.am +++ b/srfi/Makefile.am @@ -35,11 +35,11 @@ BUILT_SOURCES = srfi-13.x srfi-14.x srfi-4.x libguile_srfi_srfi_13_14_la_SOURCES = srfi-13.x srfi-13.c srfi-14.x srfi-14.c\ srfi-13.h srfi-14.h libguile_srfi_srfi_13_14_la_LDFLAGS = -version-info 0:0 -export-dynamic -no-undefined -libguile_srfi_srfi_13_14_la_LIBADD = $(top_srcdir)/libguile/libguile.la +libguile_srfi_srfi_13_14_la_LIBADD = ../libguile/libguile.la libguile_srfi_srfi_4_la_SOURCES = srfi-4.x srfi-4.c srfi-4.h libguile_srfi_srfi_4_la_LDFLAGS = -version-info 0:0 -export-dynamic -no-undefined -libguile_srfi_srfi_4_la_LIBADD = $(top_srcdir)/libguile/libguile.la +libguile_srfi_srfi_4_la_LIBADD = ../libguile/libguile.la srfidir = $(datadir)/guile/$(VERSION)/srfi srfi_DATA = srfi-1.scm \ From 836b65573dc133159a9635b0387e679d7efc101e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 3 Nov 2001 23:06:47 +0000 Subject: [PATCH 105/281] *** empty log message *** --- srfi/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 8b7fdbb23..3504a15b0 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,9 @@ +2001-11-03 Marius Vollmer + + * Makefile.am (libguile_srfi_srfi_4_la_LIBADD, + libguile_srfi_srfi_13_14_la_LIBADD): Refer to build directory, not + the source directory, for libguile.la. Thanks to Ken Raeburn. + 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! From 8f99e3f38b575f8001cdc92241959c30930c6828 Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Sun, 4 Nov 2001 15:52:30 +0000 Subject: [PATCH 106/281] 2001-11-04 Stefan Jahn * NEWS: Corrected remarks about SCM_API. * configure.in: Defining USE_DLL_IMPORT definition to indicate usage of DLL import macros in `libguile/__scm.h'. (LIBOBJS): Removed `fileblocks.o' from the list of object files. Somehow Jim Blandy's patch from 1997 did not survive. 2001-11-04 Stefan Jahn * configure.in (EXTRA_DEFS): Follow-up patch. Using SCM_IMPORT instead of __SCM_IMPORT__. * readline.c (scm_readline_init_ports): Disable input/output stream redirection for Win32. The readline package for Win32 does not support this. The guile-readline library works fine for command line editing. * readline.h (SCM_RL_API): Renamed __FOO__ macros into FOO. 2001-11-04 Stefan Jahn * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL) here (was at guile_LDADD) which describes the dependency correctly and allows a clean build on Win32. * __scm.h (SCM_API): Follow-up patch. Renamed __FOO__ macros into FOO. * __scm.h: USE_DLL_IMPORT indicates the usage of the DLL import macros for external libraries (libcrypt, libqthreads, libreadline and libregex). * coop-defs.h: Include for `struct timeval'. * posix.c (flock): Added support for flock() in M$-Windows. * guile.c (SCM_IMPORT): Follow-up patch. Use SCM_IMPORT instead of __SCM_IMPORT__. * fports.c (getflags): Differentiate reading and writing pipes descriptors. * filesys.c (S_IS*): Redefine all of the S_IS*() macros for M$-Windows. * coop.c (coop_condition_variable_timed_wait_mutex): Use conditionalized error code if `ETIMEDOUT' is not available. (scm_thread_usleep): Remove bogus declaration of `struct timeval timeout'. * numbers.c (PTRDIFF_MIN): Moved this definition where it actually belongs. That is because NO_PREPRO_MAGIC gets undefined after each inclusion of `num2integral.i.c'. (SIZE_MAX): Define NO_PREPRO_MAGIC if SIZE_MAX is undefined. 2001-11-04 Stefan Jahn * md/Makefile.am (EXTRA_DIST): Added `i386.asm'. * md/i386.asm: New file. Contains the Intel syntax version for nasm/tasm/masm of the file `i386.s'. * qt.h.in: Definition of QT_API, QT_IMPORT and QT_EXPORT. Prefixed each symbols which is meant to go into a DLL. * Makefile.am (libqthreads_la_LDFLAGS): Put `-no-undefined' into LDFLAGS to support linkers which do not allow unresolved symbols inside shared libraries. (EXTRA_DIST): Add `libqthreads.def', which is an export file definition for M$-Windows. It defines exported symbols. This is necessary because the M$VC linker does not know how to export assembler symbols into a DLL. 2001-11-04 Stefan Jahn * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch. Renamed __FOO__ macros into FOO. 2001-11-04 Stefan Jahn * tests/ports.test: Run (close-port) before (delete-file) if necessary/advisory. --- ChangeLog | 15 ++++- NEWS | 6 +- configure.in | 13 +++-- guile-readline/ChangeLog | 12 ++++ guile-readline/configure.in | 2 +- guile-readline/readline.c | 24 +++++++- guile-readline/readline.h | 8 +-- libguile/ChangeLog | 36 ++++++++++++ libguile/Makefile.am | 6 +- libguile/__scm.h | 16 +++++- libguile/coop-defs.h | 4 ++ libguile/coop.c | 9 ++- libguile/filesys.c | 63 ++++++++++++++++---- libguile/fports.c | 3 +- libguile/guile.c | 2 +- libguile/num2integral.i.c | 8 +-- libguile/numbers.c | 33 +++++------ libguile/posix.c | 68 +++++++++++++++++++++- qt/ChangeLog | 18 ++++++ qt/Makefile.am | 4 +- qt/libqthreads.def | 10 ++++ qt/md/Makefile.am | 2 +- qt/md/i386.asm | 112 ++++++++++++++++++++++++++++++++++++ qt/md/i386.h | 4 +- qt/qt.h.in | 20 +++++-- srfi/ChangeLog | 5 ++ srfi/srfi-13.h | 8 +-- srfi/srfi-14.h | 4 +- srfi/srfi-4.h | 4 +- test-suite/ChangeLog | 5 ++ test-suite/tests/ports.test | 5 +- 31 files changed, 447 insertions(+), 82 deletions(-) create mode 100644 qt/libqthreads.def create mode 100644 qt/md/i386.asm diff --git a/ChangeLog b/ChangeLog index aee0757db..ead195902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-11-04 Stefan Jahn + + * NEWS: Corrected remarks about SCM_API. + + * configure.in: Defining USE_DLL_IMPORT definition to indicate + usage of DLL import macros in `libguile/__scm.h'. + (LIBOBJS): Removed `fileblocks.o' from the list of object files. + Somehow Jim Blandy's patch from 1997 did not survive. + 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! @@ -6,9 +15,9 @@ build systems which do not have symbolic links. * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls on Win32 platforms. - Checking for `ws2_32.dll', `winsock2.h', add `uname.o' and - `dirent.o' and define extra compiler flags necessary to build - clean dlls. + Checking for `ws2_32.dll', `winsock2.h', add `win32-uname.o' + and `win32-dirent.o' and define extra compiler flags necessary + to build clean dlls. Check for `regcomp()' inside `-lregex'. 2001-10-26 Thien-Thi Nguyen diff --git a/NEWS b/NEWS index 75987bfda..f8fb643b7 100644 --- a/NEWS +++ b/NEWS @@ -32,12 +32,12 @@ declaration. This macro can expand into different things, the most common of which is just "extern" for Unix platforms. On Win32, it can be used to control which symbols are exported from a DLL. -If you `#define __SCM_IMPORT__' before including , SCM_API +If you `#define SCM_IMPORT' before including , SCM_API will expand into "__declspec (dllimport) extern", which is needed for linking to the Guile DLL in Windows. -There are also __SCM_RL_IMPORT__, __SCM_SRFI1314_IMPORT__, and -__SCM_SRFI4_IMPORT__, for the corresponding libraries. +There are also SCM_RL_IMPORT, QT_IMPORT, SCM_SRFI1314_IMPORT, and +SCM_SRFI4_IMPORT, for the corresponding libraries. Changes since Guile 1.4: diff --git a/configure.in b/configure.in index 1a95617a9..01f5b6525 100644 --- a/configure.in +++ b/configure.in @@ -228,19 +228,18 @@ dnl dnl Check for Winsock and other functionality on Win32 (*not* CygWin) dnl EXTRA_DEFS="" -EXTRA_LIB_DEFS="" if test "$MINGW32" = "yes" ; then AC_CHECK_HEADER(winsock2.h, [AC_DEFINE([HAVE_WINSOCK2_H], 1, [Define if you have the header file.])]) AC_CHECK_LIB(ws2_32, main) - LIBOBJS="$LIBOBJS uname.o dirent.o" + LIBOBJS="$LIBOBJS win32-uname.o win32-dirent.o" if test $enable_shared = yes ; then - EXTRA_DEFS="-D__SCM_IMPORT__ -D__REGEX_IMPORT__ -D__CRYPT_IMPORT__" - EXTRA_LIB_DEFS="-D__REGEX_IMPORT__ -D__CRYPT_IMPORT__" + EXTRA_DEFS="-DSCM_IMPORT" + AC_DEFINE(USE_DLL_IMPORT, 1, + [Define if you need additional CPP macros on Win32 platforms.]) fi fi AC_SUBST(EXTRA_DEFS) -AC_SUBST(EXTRA_LIB_DEFS) dnl Check for dynamic linking @@ -614,6 +613,10 @@ esac AC_PROG_AWK +## Remove fileblocks.o from the object list. This file gets added by +## the Autoconf macro AC_STRUCT_ST_BLOCKS. But there is no need. +LIBOBJS="`echo ${LIBOBJS} | sed 's/fileblocks\.o//g'`" + ## If we're creating a shared library (using libtool!), then we'll ## need to generate a list of .lo files corresponding to the .o files ## given in LIBOBJS. We'll call it LIBLOBJS. diff --git a/guile-readline/ChangeLog b/guile-readline/ChangeLog index 4c23f0457..1173e7709 100644 --- a/guile-readline/ChangeLog +++ b/guile-readline/ChangeLog @@ -1,3 +1,15 @@ +2001-11-04 Stefan Jahn + + * configure.in (EXTRA_DEFS): Follow-up patch. Using SCM_IMPORT + instead of __SCM_IMPORT__. + + * readline.c (scm_readline_init_ports): Disable input/output + stream redirection for Win32. The readline package for Win32 + does not support this. The guile-readline library works fine + for command line editing. + + * readline.h (SCM_RL_API): Renamed __FOO__ macros into FOO. + 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! diff --git a/guile-readline/configure.in b/guile-readline/configure.in index c6162e033..eb7b1b02b 100644 --- a/guile-readline/configure.in +++ b/guile-readline/configure.in @@ -20,7 +20,7 @@ AC_MINGW32 EXTRA_DEFS="" if test "$MINGW32" = "yes" ; then if test $enable_shared = yes ; then - EXTRA_DEFS="-D__SCM_IMPORT__ -D__READLINE_IMPORT__" + EXTRA_DEFS="-DSCM_IMPORT" fi fi AC_SUBST(EXTRA_DEFS) diff --git a/guile-readline/readline.c b/guile-readline/readline.c index 6fcd656bf..0802fa3dc 100644 --- a/guile-readline/readline.c +++ b/guile-readline/readline.c @@ -212,8 +212,10 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0, (void *) SCM_UNPACK (text), handle_error, 0); +#ifndef __MINGW32__ fclose (rl_instream); fclose (rl_outstream); +#endif --in_readline; return ans; @@ -246,8 +248,10 @@ handle_error (void *data, SCM tag, SCM args) rl_free_line_state (); rl_cleanup_after_signal (); fputc ('\n', rl_outstream); /* We don't want next output on this line */ +#ifndef __MINGW32__ fclose (rl_instream); fclose (rl_outstream); +#endif --in_readline; scm_handle_by_throw (data, tag, args); return SCM_UNSPECIFIED; /* never reached */ @@ -317,8 +321,10 @@ scm_readline_init_ports (SCM inp, SCM outp) } input_port = inp; +#ifndef __MINGW32__ rl_instream = stream_from_fport (inp, "r", s_scm_readline); rl_outstream = stream_from_fport (outp, "w", s_scm_readline); +#endif } @@ -482,10 +488,13 @@ find_matching_paren(int k) static int match_paren (int x, int k) { - int tmp, fno; + int tmp; +#ifndef __MINGW32__ + int fno; SELECT_TYPE readset; struct timeval timeout; - +#endif + rl_insert (x, k); if (!SCM_READLINE_BOUNCE_PARENS) return 0; @@ -495,13 +504,15 @@ match_paren (int x, int k) && rl_line_buffer[rl_point - 2] == '\\') return 0; +#ifndef __MINGW32__ tmp = 1000 * SCM_READLINE_BOUNCE_PARENS; timeout.tv_sec = tmp / 1000000; timeout.tv_usec = tmp % 1000000; FD_ZERO (&readset); fno = fileno (rl_instream); FD_SET (fno, &readset); - +#endif + if (rl_point > 1) { tmp = rl_point; @@ -509,7 +520,12 @@ match_paren (int x, int k) if (rl_point > -1) { rl_redisplay (); +#ifndef __MINGW32__ scm_internal_select (fno + 1, &readset, NULL, NULL, &timeout); +#else + WaitForSingleObject (GetStdHandle(STD_INPUT_HANDLE), + SCM_READLINE_BOUNCE_PARENS); +#endif } rl_point = tmp; } @@ -545,7 +561,9 @@ scm_init_readline () #include "guile-readline/readline.x" scm_readline_completion_function_var = scm_c_define ("*readline-completion-function*", SCM_BOOL_F); +#ifndef __MINGW32__ rl_getc_function = current_input_getc; +#endif rl_redisplay_function = redisplay; #if defined (_RL_FUNCTION_TYPEDEF) rl_completion_entry_function = (rl_compentry_func_t*) completion_function; diff --git a/guile-readline/readline.h b/guile-readline/readline.h index 327708270..1fc51de4f 100644 --- a/guile-readline/readline.h +++ b/guile-readline/readline.h @@ -24,10 +24,10 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_RL_IMPORT__) -# define SCM_RL_API __declspec (dllimport) -#elif defined (__SCM_RL_EXPORT__) || defined (DLL_EXPORT) -# define SCM_RL_API __declspec (dllexport) +#if defined (SCM_RL_IMPORT) +# define SCM_RL_API __declspec (dllimport) extern +#elif defined (SCM_RL_EXPORT) || defined (DLL_EXPORT) +# define SCM_RL_API __declspec (dllexport) extern #else # define SCM_RL_API extern #endif diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 38f136a3c..e0c7f9996 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,39 @@ +2001-11-04 Stefan Jahn + + * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL) + here (was at guile_LDADD) which describes the dependency + correctly and allows a clean build on Win32. + + * __scm.h (SCM_API): Follow-up patch. Renamed __FOO__ macros + into FOO. + + * __scm.h: USE_DLL_IMPORT indicates the usage of the DLL + import macros for external libraries (libcrypt, libqthreads, + libreadline and libregex). + + * coop-defs.h: Include for `struct timeval'. + + * posix.c (flock): Added support for flock() in M$-Windows. + + * guile.c (SCM_IMPORT): Follow-up patch. Use SCM_IMPORT instead + of __SCM_IMPORT__. + + * fports.c (getflags): Differentiate reading and writing pipes + descriptors. + + * filesys.c (S_IS*): Redefine all of the S_IS*() macros for + M$-Windows. + + * coop.c (coop_condition_variable_timed_wait_mutex): Use + conditionalized error code if `ETIMEDOUT' is not available. + (scm_thread_usleep): Remove bogus declaration of `struct timeval + timeout'. + + * numbers.c (PTRDIFF_MIN): Moved this definition where it actually + belongs. That is because NO_PREPRO_MAGIC gets undefined after + each inclusion of `num2integral.i.c'. + (SIZE_MAX): Define NO_PREPRO_MAGIC if SIZE_MAX is undefined. + 2001-11-03 Marius Vollmer * eval.c (scm_m_begin): Allow `(begin)`, with no subforms. diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 16ab8213d..517bbda74 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = gnu ## Prevent automake from adding extra -I options -DEFS = @DEFS@ @EXTRA_LIB_DEFS@ +DEFS = @DEFS@ ## Check for headers in $(srcdir)/.., so that #include ## will find MUMBLE.h in this dir when we're ## building. @@ -35,7 +35,7 @@ lib_LTLIBRARIES = libguile.la bin_PROGRAMS = guile guile_filter_doc_snarfage guile_SOURCES = guile.c -guile_LDADD = libguile.la ${THREAD_LIBS_LOCAL} +guile_LDADD = libguile.la guile_LDFLAGS = @DLPREOPEN@ guile_filter_doc_snarfage_SOURCES = c-tokenize.c @@ -115,7 +115,7 @@ noinst_HEADERS = coop-threads.c coop-threads.h coop.c \ num2integral.i.c num2float.i.c win32-uname.h win32-dirent.h libguile_la_DEPENDENCIES = @LIBLOBJS@ -libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) +libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) $(THREAD_LIBS_LOCAL) libguile_la_LDFLAGS = -version-info @LIBGUILE_INTERFACE_CURRENT@:@LIBGUILE_INTERFACE_REVISION@:@LIBGUILE_INTERFACE_AGE@ -export-dynamic -no-undefined # These are headers visible as diff --git a/libguile/__scm.h b/libguile/__scm.h index b24158b51..2ae4cdf29 100644 --- a/libguile/__scm.h +++ b/libguile/__scm.h @@ -159,11 +159,11 @@ /* SCM_API is a macro prepended to all function and data definitions which should be exported or imported in the resulting dynamic link - library in the Win32 port. */ + library (DLL) in the Win32 port. */ -#if defined (__SCM_IMPORT__) +#if defined (SCM_IMPORT) # define SCM_API __declspec (dllimport) extern -#elif defined (__SCM_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_EXPORT) || defined (DLL_EXPORT) # define SCM_API __declspec (dllexport) extern #else # define SCM_API extern @@ -334,6 +334,16 @@ typedef long ptrdiff_t; +/* Define some additional CPP macros on Win32 platforms. */ +#if USE_DLL_IMPORT +# define __REGEX_IMPORT__ 1 +# define __CRYPT_IMPORT__ 1 +# define __READLINE_IMPORT__ 1 +# define QT_IMPORT 1 +#endif + + + #include "libguile/tags.h" diff --git a/libguile/coop-defs.h b/libguile/coop-defs.h index b9c5b4f9c..3863b1690 100644 --- a/libguile/coop-defs.h +++ b/libguile/coop-defs.h @@ -63,6 +63,10 @@ #include "libguile/iselect.h" #endif +#if HAVE_WINSOCK2_H +#include +#endif + #ifdef GUILE_PTHREAD_COMPAT #include #endif diff --git a/libguile/coop.c b/libguile/coop.c index 987a71f9a..ca057b423 100644 --- a/libguile/coop.c +++ b/libguile/coop.c @@ -40,7 +40,7 @@ * If you do not wish that, delete this exception notice. */ -/* $Id: coop.c,v 1.28 2001-10-06 16:30:20 mdj Exp $ */ +/* $Id: coop.c,v 1.29 2001-11-04 15:52:29 ela Exp $ */ /* Cooperative thread library, based on QuickThreads */ @@ -422,7 +422,13 @@ coop_condition_variable_timed_wait_mutex (coop_c *c, const struct timespec *abstime) { coop_t *old, *t; +#ifdef ETIMEDOUT int res = ETIMEDOUT; +#elif defined (WSAETIMEDOUT) + int res = WSAETIMEDOUT; +#else + int res = 0; +#endif /* coop_mutex_unlock (m); */ t = coop_qget (&(m->waiting)); @@ -842,7 +848,6 @@ scm_thread_usleep (unsigned long usec) { /* We're so cheap. */ scm_thread_sleep (usec / 1000000); - struct timeval timeout; return 0; /* Maybe we should calculate actual time slept, but this is faster... :) */ } diff --git a/libguile/filesys.c b/libguile/filesys.c index 93015d8df..806c8c10f 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -128,17 +128,60 @@ /* The MinGW gcc does not define the S_ISSOCK macro. Any other native Windows compiler like BorlandC or MSVC has none of these macros defined. */ #ifdef __MINGW32__ -# define _S_IFSOCK 0xC000 -# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK) -#endif -#if defined (__BORLANDC__) || defined (_MSC_VER) -# define _S_IFBLK 0x3000 -# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK) + +# ifdef _S_IFIFO +# undef _S_IFIFO +# endif +# ifdef _S_IFCHR +# undef _S_IFCHR +# endif +# ifdef _S_IFBLK +# undef _S_IFBLK +# endif +# ifdef _S_IFDIR +# undef _S_IFDIR +# endif +# ifdef _S_IFREG +# undef _S_IFREG +# endif +# ifdef _S_IFSOCK +# undef _S_IFSOCK +# endif + +# define _S_IFIFO 0x1000 /* FIFO */ +# define _S_IFCHR 0x2000 /* Character */ +# define _S_IFBLK 0x3000 /* Block */ +# define _S_IFDIR 0x4000 /* Directory */ +# define _S_IFREG 0x8000 /* Regular */ +# define _S_IFSOCK 0xC000 /* Socket */ + +# ifdef S_ISBLK +# undef S_ISBLK +# endif +# ifdef S_ISFIFO +# undef S_ISFIFO +# endif +# ifdef S_ISCHR +# undef S_ISCHR +# endif +# ifdef S_ISDIR +# undef S_ISDIR +# endif +# ifdef S_ISREG +# undef S_ISREG +# endif +# ifdef S_ISSOCK +# undef S_ISSOCK +# endif + +# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK) # define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) -# define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR) -# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) -# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG) -#endif +# define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR) +# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) +# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG) +# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK) + +#endif /* __MINGW32__ */ /* Some more definitions for the native Windows port. */ #ifdef __MINGW32__ diff --git a/libguile/fports.c b/libguile/fports.c index 6c1106052..426db6f55 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -380,7 +380,8 @@ static int getflags (int fdes) { /* Or an anonymous pipe handle ? */ if (buf.st_mode & _S_IFIFO) - flags = O_RDWR; + flags = PeekNamedPipe ((HANDLE) _get_osfhandle (fdes), NULL, 0, + NULL, NULL, NULL) ? O_RDONLY : O_WRONLY; /* stdin ? */ else if (fdes == fileno (stdin) && isatty (fdes)) flags = O_RDONLY; diff --git a/libguile/guile.c b/libguile/guile.c index 18df2af30..ae17a9606 100644 --- a/libguile/guile.c +++ b/libguile/guile.c @@ -47,7 +47,7 @@ system. For now, please don't put interesting code in here. */ #ifdef __MINGW32__ -# define __SCM_IMPORT__ 1 +# define SCM_IMPORT 1 #endif #include diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index 09a6e03fa..fa1d8c6ec 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -93,13 +93,13 @@ INTEGRAL2NUM (ITYPE n) #define NEED_CHECK #else #ifdef UNSIGNED - /*#if MAX_VALUE > SCM_MOST_POSITIVE_FIXNUM*/ +#if MAX_VALUE>SCM_MOST_POSITIVE_FIXNUM #define NEED_CHECK - /*#endif*/ +#endif #else - /*#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM*/ +#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM #define NEED_CHECK - /*#endif*/ +#endif #endif #endif diff --git a/libguile/numbers.c b/libguile/numbers.c index 0786697b6..e9760b812 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4258,22 +4258,6 @@ scm_i_big2dbl (SCM b) # endif #endif -#ifndef SIZE_MAX -#define SIZE_MAX ((size_t) (-1)) -#endif - -#ifndef PTRDIFF_MIN -/* the below is not really guaranteed to work (I think), but probably does: */ -#define PTRDIFF_MIN ((ptrdiff_t) ((ptrdiff_t)1 << (sizeof (ptrdiff_t)*8 - 1))) -/* this prevents num2integral.c.i from using PTRDIFF_MIN in - preprocessor expressions. */ -#define NO_PREPRO_MAGIC -#endif - -#ifndef PTRDIFF_MAX -#define PTRDIFF_MAX (~ PTRDIFF_MIN) -#endif - #define NUM2INTEGRAL scm_num2short #define INTEGRAL2NUM scm_short2num #define INTEGRAL2BIG scm_i_short2big @@ -4322,6 +4306,18 @@ scm_i_big2dbl (SCM b) #define MAX_VALUE ULONG_MAX #include "libguile/num2integral.i.c" +#ifndef PTRDIFF_MIN +/* the below is not really guaranteed to work (I think), but probably does: */ +#define PTRDIFF_MIN ((ptrdiff_t) ((ptrdiff_t)1 << (sizeof (ptrdiff_t)*8 - 1))) +/* this prevents num2integral.c.i from using PTRDIFF_MIN in + preprocessor expressions. */ +#define NO_PREPRO_MAGIC +#endif + +#ifndef PTRDIFF_MAX +#define PTRDIFF_MAX (~ PTRDIFF_MIN) +#endif + #define NUM2INTEGRAL scm_num2ptrdiff #define INTEGRAL2NUM scm_ptrdiff2num #define INTEGRAL2BIG scm_i_ptrdiff2big @@ -4330,6 +4326,11 @@ scm_i_big2dbl (SCM b) #define MAX_VALUE PTRDIFF_MAX #include "libguile/num2integral.i.c" +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t) (-1)) +#define NO_PREPRO_MAGIC +#endif + #define NUM2INTEGRAL scm_num2size #define INTEGRAL2NUM scm_size2num #define INTEGRAL2BIG scm_i_size2big diff --git a/libguile/posix.c b/libguile/posix.c index 70b30f6fd..033678947 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1502,7 +1502,73 @@ SCM_DEFINE (scm_getpass, "getpass", 1, 0, 0, #undef FUNC_NAME #endif /* HAVE_GETPASS */ -#if HAVE_FLOCK +/* Wrapper function for flock() support under M$-Windows. */ +#ifdef __MINGW32__ +# include +# include +# include +# ifndef _LK_UNLCK + /* Current MinGW package fails to define this. *sigh* */ +# define _LK_UNLCK 0 +# endif +# define LOCK_EX 1 +# define LOCK_UN 2 +# define LOCK_SH 4 +# define LOCK_NB 8 + +static int flock (int fd, int operation) +{ + long pos, len; + int ret, err; + + /* Disable invalid arguments. */ + if (((operation & (LOCK_EX | LOCK_SH)) == (LOCK_EX | LOCK_SH)) || + ((operation & (LOCK_EX | LOCK_UN)) == (LOCK_EX | LOCK_UN)) || + ((operation & (LOCK_SH | LOCK_UN)) == (LOCK_SH | LOCK_UN))) + { + errno = EINVAL; + return -1; + } + + /* Determine mode of operation and discard unsupported ones. */ + if (operation == (LOCK_NB | LOCK_EX)) + operation = _LK_NBLCK; + else if (operation & LOCK_UN) + operation = _LK_UNLCK; + else if (operation == LOCK_EX) + operation = _LK_LOCK; + else + { + errno = EINVAL; + return -1; + } + + /* Save current file pointer and seek to beginning. */ + if ((pos = lseek (fd, 0, SEEK_CUR)) == -1 || (len = filelength (fd)) == -1) + return -1; + lseek (fd, 0L, SEEK_SET); + + /* Deadlock if necessary. */ + do + { + ret = _locking (fd, operation, len); + } + while (ret == -1 && errno == EDEADLOCK); + + /* Produce meaningful error message. */ + if (errno == EACCES && operation == _LK_NBLCK) + err = EDEADLOCK; + else + err = errno; + + /* Return to saved file position pointer. */ + lseek (fd, pos, SEEK_SET); + errno = err; + return ret; +} +#endif /* __MINGW32__ */ + +#if HAVE_FLOCK || defined (__MINGW32__) SCM_DEFINE (scm_flock, "flock", 2, 0, 0, (SCM file, SCM operation), "Apply or remove an advisory lock on an open file.\n" diff --git a/qt/ChangeLog b/qt/ChangeLog index 2d8c015e9..be11f91c3 100644 --- a/qt/ChangeLog +++ b/qt/ChangeLog @@ -1,3 +1,21 @@ +2001-11-04 Stefan Jahn + + * md/Makefile.am (EXTRA_DIST): Added `i386.asm'. + + * md/i386.asm: New file. Contains the Intel syntax version for + nasm/tasm/masm of the file `i386.s'. + + * qt.h.in: Definition of QT_API, QT_IMPORT and QT_EXPORT. + Prefixed each symbols which is meant to go into a DLL. + + * Makefile.am (libqthreads_la_LDFLAGS): Put `-no-undefined' + into LDFLAGS to support linkers which do not allow unresolved + symbols inside shared libraries. + (EXTRA_DIST): Add `libqthreads.def', which is an export file + definition for M$-Windows. It defines exported symbols. This is + necessary because the M$VC linker does not know how to export + assembler symbols into a DLL. + 2001-08-25 Marius Vollmer * Makefile.am, md/Makefile.am, time/Makefile.am: diff --git a/qt/Makefile.am b/qt/Makefile.am index 926f15575..25f05a657 100644 --- a/qt/Makefile.am +++ b/qt/Makefile.am @@ -34,7 +34,7 @@ INCLUDES = -I.. -I$(srcdir)/.. libqthreads_la_SOURCES = qt.c copyright.h libqthreads_la_LIBADD = qtmds.lo qtmdc.lo libqthreads_la_DEPENDENCIES = qtmds.lo qtmdc.lo -libqthreads_la_LDFLAGS = -rpath $(libdir) -version-info @LIBGUILEQTHREADS_INTERFACE_CURRENT@:@LIBGUILEQTHREADS_INTERFACE_REVISION@:@LIBGUILEQTHREADS_INTERFACE_AGE@ -export-dynamic +libqthreads_la_LDFLAGS = -rpath $(libdir) -version-info @LIBGUILEQTHREADS_INTERFACE_CURRENT@:@LIBGUILEQTHREADS_INTERFACE_REVISION@:@LIBGUILEQTHREADS_INTERFACE_AGE@ -export-dynamic -no-undefined OMIT_DEPENDENCIES = axp.h hppa.h i386.h ksr.h m88k.h mips.h sparc.h vax.h @@ -48,4 +48,4 @@ qtdmdb.s: ${LN_S} ${srcdir}/${qtdmdb_s} qtdmdb.s EXTRA_DIST = CHANGES README.MISC README.PORT b.h meas.c stp.c stp.h \ - Makefile.base config + Makefile.base config libqthreads.def diff --git a/qt/libqthreads.def b/qt/libqthreads.def new file mode 100644 index 000000000..c7cfcd5f2 --- /dev/null +++ b/qt/libqthreads.def @@ -0,0 +1,10 @@ +LIBRARY libqthreads +DESCRIPTION "libqthreads: QuickThreads Library" +EXPORTS + qt_abort + qt_block + qt_blocki + qt_error + qt_null + qt_vargs + qt_vstart diff --git a/qt/md/Makefile.am b/qt/md/Makefile.am index 66e2ea8bd..46fffd152 100644 --- a/qt/md/Makefile.am +++ b/qt/md/Makefile.am @@ -27,4 +27,4 @@ hppa-cnx.Makefile hppa.Makefile hppa.h hppa.s hppa_b.s i386.README \ i386.h i386.s i386_b.s ksr1.Makefile ksr1.h ksr1.s ksr1_b.s \ m88k.Makefile m88k.c m88k.h m88k.s m88k_b.s mips-irix5.s mips.h mips.s \ mips_b.s null.README null.c solaris.README sparc.h sparc.s sparc_b.s \ -vax.h vax.s vax_b.s +vax.h vax.s vax_b.s i386.asm diff --git a/qt/md/i386.asm b/qt/md/i386.asm new file mode 100644 index 000000000..b79f165df --- /dev/null +++ b/qt/md/i386.asm @@ -0,0 +1,112 @@ +;; i386.asm -- assembly support. + +;; +;; QuickThreads -- Threads-building toolkit. +;; Copyright (c) 2001 Free Software Foundation, Inc. +;; +;; Permission to use, copy, modify and distribute this software and +;; its documentation for any purpose and without fee is hereby +;; granted, provided that the above copyright notice and this notice +;; appear in all copies. This software is provided as a +;; proof-of-concept and for demonstration purposes; there is no +;; representation about the suitability of this software for any +;; purpose. + +;; NOTE: double-labeled `_name' and `name' for System V compatability. +;; NOTE: Comment lines start like this one, or with '//' ONLY. Sorry! + +;; Callee-save: %esi, %edi, %ebx, %ebp +;; Caller-save: %eax, %ecx +;; Can't tell: %edx (seems to work w/o saving it.) +;; +;; Assignment: +;; +;; See ``i386.h'' for the somewhat unconventional stack layout. + + + .386p + .model flat + .code + + public _qt_abort + public qt_abort + public _qt_block + public qt_block + public _qt_blocki + public qt_blocki + +;; These all have the type signature +;; +;; void *blocking (helper, arg0, arg1, new) +;; +;; On procedure entry, the helper is at 4(sp), args at 8(sp) and +;; 12(sp) and the new thread's sp at 16(sp). It *appears* that the +;; calling convention for the 8X86 requires the caller to save all +;; floating-point registers, this makes our life easy. + +;; Halt the currently-running thread. Save it's callee-save regs on +;; to the stack, 32 bytes. Switch to the new stack (next == 16+32(sp)) +;; and call the user function (f == 4+32(sp) with arguments: old sp +;; arg1 (8+32(sp)) and arg2 (12+32(sp)). When the user function is +;; done, restore the new thread's state and return. +;; +;; `qt_abort' is (currently) an alias for `qt_block' because most of +;; the work is shared. We could save the insns up to `qt_common' by +;; replicating, but w/o replicating we need an inital subtract (to +;; offset the stack as if it had been a qt_block) and then a jump +;; to qt_common. For the cost of a jump, we might as well just do +;; all the work. +;; +;; The helper function (4(sp)) can return a void* that is returned +;; by the call to `qt_blockk{,i}'. Since we don't touch %eax in +;; between, we get that ``for free''. + +_qt_abort: +qt_abort: +_qt_block: +qt_block: +_qt_blocki: +qt_blocki: + push ebp ; Save callee-save, sp-=4. + push esi ; Save callee-save, sp-=4. + push edi ; Save callee-save, sp-=4. + push ebx ; Save callee-save, sp-=4. + mov eax, esp ; Remember old stack pointer. + +qt_common: + mov esp, [esp+32] ; Move to new thread. + push [eax+28] ; Push arg 2. + push [eax+24] ; Push arg 1. + push eax ; Push arg 0. + mov ebx, [eax+20] ; Get function to call. + call ebx ; Call f. + add esp, 12 ; Pop args. + + pop ebx ; Restore callee-save, sp+=4. + pop edi ; Restore callee-save, sp+=4. + pop esi ; Restore callee-save, sp+=4. + pop ebp ; Restore callee-save, sp+=4. + ret ; Resume the stopped function. + hlt + + +;; Start a varargs thread. + + public _qt_vstart + public qt_vstart + +_qt_vstart: +qt_vstart: + push edi ; Push `pt' arg to `startup'. + call ebp ; Call `startup'. + pop eax ; Clean up the stack. + + call ebx ; Call the user's function. + + push eax ; Push return from user's. + push edi ; Push `pt' arg to `cleanup'. + call esi ; Call `cleanup'. + + hlt ; `cleanup' never returns. + + end diff --git a/qt/md/i386.h b/qt/md/i386.h index 158fe2703..d7feba010 100644 --- a/qt/md/i386.h +++ b/qt/md/i386.h @@ -58,7 +58,7 @@ typedef unsigned long qt_word_t; /* What to do to start a varargs thread running. */ -extern void qt_vstart (void); +QT_API void qt_vstart (void); /* Hold 4 saved regs plus two return pcs (qt_error, qt_start) plus @@ -101,7 +101,7 @@ extern void qt_vstart (void); pop off (preincrement, postdecrement). */ #define QT_GROW_DOWN -extern void qt_error (void); +QT_API void qt_error (void); /* Push on the error return address. */ #define QT_ARGS_MD(sto) \ diff --git a/qt/qt.h.in b/qt/qt.h.in index bd79e78d0..6399a89d1 100644 --- a/qt/qt.h.in +++ b/qt/qt.h.in @@ -1,6 +1,14 @@ #ifndef QT_H #define QT_H +#if defined (QT_IMPORT) +# define QT_API __declspec (dllimport) extern +#elif defined (QT_EXPORT) || defined (DLL_EXPORT) +# define QT_API __declspec (dllexport) extern +#else +# define QT_API extern +#endif + #ifdef __cplusplus extern "C" { #endif @@ -126,7 +134,7 @@ typedef void (qt_cleanup_t)(void *pt, void *vuserf_return); #define QT_VADJ(sp) (((char *)sp) + QT_VSTKBASE) #endif -extern qt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs, +QT_API qt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs, void *pt, qt_startup_t *startup, qt_vuserf_t *vuserf, qt_cleanup_t *cleanup); @@ -137,8 +145,8 @@ extern qt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs, #endif -extern void qt_null (void); -extern void qt_error (void); +QT_API void qt_null (void); +QT_API void qt_error (void); /* Save the state of the thread and call the helper function using the stack of the new thread. */ @@ -149,7 +157,7 @@ typedef void *(qt_block_t)(qt_helper_t *helper, void *a0, void *a1, /* Rearrange the parameters so that things passed to the helper function are already in the right argument registers. */ #ifndef QT_ABORT -extern void qt_abort (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); +QT_API void qt_abort (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); /* The following does, technically, `return' a value, but the user had better not rely on it, since the function never returns. */ @@ -158,14 +166,14 @@ extern void qt_abort (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); #endif #ifndef QT_BLOCK -extern void *qt_block (qt_helper_t *h, void *a0, void *a1, +QT_API void *qt_block (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); #define QT_BLOCK(h, a0, a1, newthread) \ (qt_block (h, a0, a1, newthread)) #endif #ifndef QT_BLOCKI -extern void *qt_blocki (qt_helper_t *h, void *a0, void *a1, +QT_API void *qt_blocki (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); #define QT_BLOCKI(h, a0, a1, newthread) \ (qt_blocki (h, a0, a1, newthread)) diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 3504a15b0..34bd08a47 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,8 @@ +2001-11-04 Stefan Jahn + + * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch. Renamed + __FOO__ macros into FOO. + 2001-11-03 Marius Vollmer * Makefile.am (libguile_srfi_srfi_4_la_LIBADD, diff --git a/srfi/srfi-13.h b/srfi/srfi-13.h index 0c81a43a5..1127cde26 100644 --- a/srfi/srfi-13.h +++ b/srfi/srfi-13.h @@ -50,9 +50,9 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_SRFI1314_IMPORT__) +#if defined (SCM_SRFI1314_IMPORT) # define SCM_SRFI1314_API __declspec (dllimport) extern -#elif defined (__SCM_SRFI1314_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_SRFI1314_EXPORT) || defined (DLL_EXPORT) # define SCM_SRFI1314_API __declspec (dllexport) extern #else # define SCM_SRFI1314_API extern @@ -137,8 +137,4 @@ SCM_SRFI1314_API SCM scm_string_tokenize (SCM s, SCM token_char, SCM start, SCM SCM_SRFI1314_API SCM scm_string_filter (SCM s, SCM char_pred, SCM start, SCM end); SCM_SRFI1314_API SCM scm_string_delete (SCM s, SCM char_pred, SCM start, SCM end); - - - - #endif /* SCM_SRFI_13_H */ diff --git a/srfi/srfi-14.h b/srfi/srfi-14.h index fbf935e30..816ef0aa3 100644 --- a/srfi/srfi-14.h +++ b/srfi/srfi-14.h @@ -50,9 +50,9 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_SRFI1314_IMPORT__) +#if defined (SCM_SRFI1314_IMPORT) # define SCM_SRFI1314_API __declspec (dllimport) extern -#elif defined (__SCM_SRFI1314_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_SRFI1314_EXPORT) || defined (DLL_EXPORT) # define SCM_SRFI1314_API __declspec (dllexport) extern #else # define SCM_SRFI1314_API extern diff --git a/srfi/srfi-4.h b/srfi/srfi-4.h index f53784d60..0a522991e 100644 --- a/srfi/srfi-4.h +++ b/srfi/srfi-4.h @@ -50,9 +50,9 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_SRFI4_IMPORT__) +#if defined (SCM_SRFI4_IMPORT) # define SCM_SRFI4_API __declspec (dllimport) extern -#elif defined (__SCM_SRFI4_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_SRFI4_EXPORT) || defined (DLL_EXPORT) # define SCM_SRFI4_API __declspec (dllexport) extern #else # define SCM_SRFI4_API extern diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 5fae02107..b91212dad 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,8 @@ +2001-11-04 Stefan Jahn + + * tests/ports.test: Run (close-port) before (delete-file) if + necessary/advisory. + 2001-10-26 Dirk Herrmann * tests/eval.test: Added tests for promises. diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index 956aac191..cc46ee855 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -91,6 +91,7 @@ (seek port -2 SEEK_END) (pass-if "file: r/w 4" (char=? (read-char port) #\s)) + (close-port port) (delete-file filename)) ;;; Unbuffered input/output port with seeking. @@ -110,6 +111,7 @@ (seek port -2 SEEK_END) (pass-if "file: ub r/w 4" (char=? (read-char port) #\s)) + (close-port port) (delete-file filename)) ;;; Buffered output-only and input-only ports with seeking. @@ -155,7 +157,8 @@ (pass-if "file: read back NUL 2" (char=? (string-ref line 3) #\nul)) (pass-if "file: EOF" - (eof-object? (read-char port)))) + (eof-object? (read-char port))) + (close-port port)) (delete-file filename)) ;;; line buffering mode. From 0233bfc11b16178b4453fa941bf824270399c6a7 Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Mon, 5 Nov 2001 21:12:33 +0000 Subject: [PATCH 107/281] 2001-11-05 Stefan Jahn * struct.c (s_scm_struct_vtable_p): Corrected docstring. --- libguile/ChangeLog | 4 ++++ libguile/struct.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index e0c7f9996..e8ccfeabb 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,7 @@ +2001-11-05 Stefan Jahn + + * struct.c (s_scm_struct_vtable_p): Corrected docstring. + 2001-11-04 Stefan Jahn * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL) diff --git a/libguile/struct.c b/libguile/struct.c index 37cc7422d..27eecebe4 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -240,7 +240,7 @@ scm_struct_init (SCM handle, SCM layout, scm_t_bits * mem, int tail_elts, SCM in SCM_DEFINE (scm_struct_p, "struct?", 1, 0, 0, (SCM x), - "Return @code{#t} iff @var{obj} is a structure object, else\n" + "Return @code{#t} iff @var{x} is a structure object, else\n" "@code{#f}.") #define FUNC_NAME s_scm_struct_p { @@ -250,7 +250,7 @@ SCM_DEFINE (scm_struct_p, "struct?", 1, 0, 0, SCM_DEFINE (scm_struct_vtable_p, "struct-vtable?", 1, 0, 0, (SCM x), - "Return @code{#t} iff obj is a vtable structure.") + "Return @code{#t} iff @var{x} is a vtable structure.") #define FUNC_NAME s_scm_struct_vtable_p { SCM layout; From 46356d040695c011e4db1acc859a5f3fb037020e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 5 Nov 2001 23:07:24 +0000 Subject: [PATCH 108/281] Document `--debug' and `--no-debug'. --- doc/ref/scripts.texi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/ref/scripts.texi b/doc/ref/scripts.texi index e3f09f471..d8134deee 100644 --- a/doc/ref/scripts.texi +++ b/doc/ref/scripts.texi @@ -94,6 +94,17 @@ the feature identifier for the loaded SRFIs is recognized by guile --use-srfi=8,13 @end example +@item --debug +Start with the debugging evaluator and enable backtraces. Using the +debugging evaluator will give you better error messages but it will +slow down execution. By default, the debugging evaluator is only used +when entering an interactive session. When executing a script with +@code{-s} or @code{-c}, the normal, faster evaluator is used by default. + +@item --no-debug +Do not use the debugging evaluator, even when entering an interactive +session. + @item -h@r{, }--help Display help on invoking Guile, and then exit. From eef6519bde94d5e5ba0feff2d3d40aedd7fd0ad1 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 5 Nov 2001 23:09:10 +0000 Subject: [PATCH 109/281] (turn-on-debugging): New function, to be used by scm_compile_shell_switches. --- ice-9/boot-9.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index c7ed61a0b..16254d32d 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -629,6 +629,12 @@ ;; This is mostly for the internal use of the code generated by ;; scm_compile_shell_switches. + +(define (turn-on-debugging) + (debug-enable 'debug) + (debug-enable 'backtrace) + (read-enable 'positions)) + (define (load-user-init) (let* ((home (or (getenv "HOME") (false-if-exception (passwd:dir (getpwuid (getuid)))) From 52ce56fc79f06b4f6990fc1a0818f885bc182bc0 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 5 Nov 2001 23:09:17 +0000 Subject: [PATCH 110/281] Do not enable debugging and recording of source positions. --- ice-9/debug.scm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ice-9/debug.scm b/ice-9/debug.scm index 56729952d..41ef0ecce 100644 --- a/ice-9/debug.scm +++ b/ice-9/debug.scm @@ -157,8 +157,3 @@ using `trace-stack', you will need to remove it twice." ;;; ;;; XXX - Still needed? (module-set! the-root-module 'debug-options debug-options) - - - -(debug-enable 'debug) -(read-enable 'positions) From 3682a51a3553a5196995c94077b73b85f4e600f8 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 5 Nov 2001 23:11:50 +0000 Subject: [PATCH 111/281] (scm_shell_usage, scm_compile_shell_switches): Prepend a call to turn-on-debugging when --debug has been given instead of turning it on directly. Also, handle new `--no-debug' option, which might suppress the call to turn-on-debugging. --- libguile/script.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/libguile/script.c b/libguile/script.c index 2f740659c..948662a04 100644 --- a/libguile/script.c +++ b/libguile/script.c @@ -384,6 +384,9 @@ scm_shell_usage (int fatal, char *message) " command line arguments\n" " -ds do -s script at this point\n" " --debug start with debugging evaluator and backtraces\n" + " --no-debug start with normal evaluator\n" + " Default is to enable debugging for interactive\n" + " use, but not for `-s' and `-c'.\n" " -q inhibit loading of user init file\n" " --emacs enable Emacs protocol (experimental)\n" " --use-srfi=LS load SRFI modules for the SRFIs in LS,\n" @@ -403,6 +406,7 @@ SCM_SYMBOL (sym_load, "load"); SCM_SYMBOL (sym_eval_string, "eval-string"); SCM_SYMBOL (sym_command_line, "command-line"); SCM_SYMBOL (sym_begin, "begin"); +SCM_SYMBOL (sym_turn_on_debugging, "turn-on-debugging"); SCM_SYMBOL (sym_load_user_init, "load-user-init"); SCM_SYMBOL (sym_top_repl, "top-repl"); SCM_SYMBOL (sym_quit, "quit"); @@ -433,6 +437,9 @@ scm_compile_shell_switches (int argc, char **argv) int interactive = 1; /* Should we go interactive when done? */ int inhibit_user_init = 0; /* Don't load user init file */ int use_emacs_interface = 0; + int turn_on_debugging = 0; + int dont_turn_on_debugging = 0; + int i; char *argv0 = guile; @@ -524,12 +531,16 @@ scm_compile_shell_switches (int argc, char **argv) tail); } - else if (! strcmp (argv[i], "--debug")) /* debug eval + backtraces */ + else if (! strcmp (argv[i], "--debug")) { - SCM_DEVAL_P = 1; - SCM_BACKTRACE_P = 1; - SCM_RECORD_POSITIONS_P = 1; - SCM_RESET_DEBUG_MODE; + turn_on_debugging = 1; + dont_turn_on_debugging = 0; + } + + else if (! strcmp (argv[i], "--no-debug")) + { + dont_turn_on_debugging = 1; + turn_on_debugging = 0; } else if (! strcmp (argv[i], "--emacs")) /* use emacs protocol */ @@ -644,10 +655,17 @@ scm_compile_shell_switches (int argc, char **argv) tail = scm_cons (scm_cons (sym_load_user_init, SCM_EOL), tail); } + /* If debugging was requested, or we are interactive and debugging + was not explicitely turned off, turn on debugging. */ + if (turn_on_debugging || (interactive && !dont_turn_on_debugging)) + { + tail = scm_cons (scm_cons (sym_turn_on_debugging, SCM_EOL), tail); + } + { SCM val = scm_cons (sym_begin, tail); -#if 0 +#if 1 scm_write (val, SCM_UNDEFINED); scm_newline (SCM_UNDEFINED); #endif From 7ab89df17c244946d122406165bd9765c0e5bd8d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 5 Nov 2001 23:12:20 +0000 Subject: [PATCH 112/281] *** empty log message *** --- doc/ref/ChangeLog | 4 ++++ ice-9/ChangeLog | 8 ++++++++ libguile/ChangeLog | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 23bf1e09b..2729127f0 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,7 @@ +2001-11-06 Marius Vollmer + + * scripts.texi: Document `--debug' and `--no-debug'. + 2001-10-27 Gary Houston * guile.texi, scsh.texi: removed obsolete guile-scsh material diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index c18e49fa2..72bb1f0ec 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,11 @@ +2001-11-06 Marius Vollmer + + * boot-9.scm (turn-on-debugging): New function, to be used by + scm_compile_shell_switches. + + * debug.scm: Do not enable debugging and recording of source + positions. + 2001-10-21 Mikael Djurfeldt * slib.scm (array-indexes): New procedure. diff --git a/libguile/ChangeLog b/libguile/ChangeLog index e8ccfeabb..e648ea2ca 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,10 @@ +2001-11-06 Marius Vollmer + + * script.c (scm_shell_usage, scm_compile_shell_switches): Prepend + a call to turn-on-debugging when --debug has been given instead of + turning it on directly. Also, handle new `--no-debug' option, + which might suppress the call to turn-on-debugging. + 2001-11-05 Stefan Jahn * struct.c (s_scm_struct_vtable_p): Corrected docstring. From f12ef3fda6ecdab215927d9a266fb78bf071f14b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 5 Nov 2001 23:23:13 +0000 Subject: [PATCH 113/281] *** empty log message *** --- NEWS | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS b/NEWS index f8fb643b7..855b2a58b 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,20 @@ Please send Guile bug reports to bug-guile@gnu.org. Changes since the stable branch: +* Changes to the standalone interpreter + +** New command line option `--no-debug'. + +Specifying `--no-debug' on the command line will keep the debugging +evaluator turned off, even for interactive sessions. + +** User-init file ~/.guile is now loaded with the debugging evaluator. + +Previously, the normal evaluator would have been used. Using the +debugging evaluator gives better error messages. + +* Changes to Scheme functions and syntax + ** Variables have no longer a special behavior for `equal?'. Previously, comparing two variables with `equal?' would recursivly From 53e82297cd7dbcea76ad01f020f3bb1cbd229e7b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 6 Nov 2001 12:53:22 +0000 Subject: [PATCH 114/281] Turn off debugging output in scm_compile_shell_switches. --- libguile/script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/script.c b/libguile/script.c index 948662a04..72fc04180 100644 --- a/libguile/script.c +++ b/libguile/script.c @@ -665,7 +665,7 @@ scm_compile_shell_switches (int argc, char **argv) { SCM val = scm_cons (sym_begin, tail); -#if 1 +#if 0 scm_write (val, SCM_UNDEFINED); scm_newline (SCM_UNDEFINED); #endif From 188e14055c1657d742a4c0f99587fff3f64e2350 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 21:38:35 +0000 Subject: [PATCH 115/281] (SCM_API patch): Renamed to "add DLL support". New owner. (sync srfi-modules.texi): New. --- TODO | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index a8198082f..398469964 100644 --- a/TODO +++ b/TODO @@ -63,7 +63,9 @@ that user-visible changes are reflected in NEWS. * Before releasing 1.8.0: -- incorporate SCM_API patch(es) by Stefan Jahn [mvo] +- add DLL support [ela] <-- set by ttn (my bad) + +- sync srfi-modules.texi [ttn] - For GOOPS: [ttn] - rewrite method cache management in C From ee4beedcf4232c3f81f0cc9ffd0678289b1641ec Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:21:29 +0000 Subject: [PATCH 116/281] (time-monotonic->time-monotonic): Spurious; remove from exports. --- srfi/srfi-19.scm | 1 - 1 file changed, 1 deletion(-) diff --git a/srfi/srfi-19.scm b/srfi/srfi-19.scm index 639408858..9b8418a99 100644 --- a/srfi/srfi-19.scm +++ b/srfi/srfi-19.scm @@ -133,7 +133,6 @@ modified-julian-day->time-tai modified-julian-day->time-utc time-monotonic->date - time-monotonic->time-monotonic time-monotonic->time-tai time-monotonic->time-tai! time-monotonic->time-utc From 23b1bf4b7ab26be9564856a4c494385f2b1601a2 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:22:38 +0000 Subject: [PATCH 117/281] *** empty log message *** --- srfi/ChangeLog | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 34bd08a47..287f65bf6 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,6 +1,11 @@ +2001-11-06 Thien-Thi Nguyen + + * srfi-19.scm (time-monotonic->time-monotonic): Spurious; + remove from exports. + 2001-11-04 Stefan Jahn - * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch. Renamed + * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch. Renamed __FOO__ macros into FOO. 2001-11-03 Marius Vollmer @@ -12,14 +17,14 @@ 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! - - * Makefile.am: Put `-no-undefined' into LDFLAGS to support linkers + + * Makefile.am: Put `-no-undefined' into LDFLAGS to support linkers which do not allow unresolved symbols inside shared libraries. - * srfi-13.h, srfi-14.h: Defined SCM_SRFI1314_API. Prefixed each + * srfi-13.h, srfi-14.h: Defined SCM_SRFI1314_API. Prefixed each exported symbol with SCM_SRFI1314_API. - * srfi-4.h: Defined SCM_SRFI4_API. Prefixed each exported + * srfi-4.h: Defined SCM_SRFI4_API. Prefixed each exported symbol with SCM_SRFI4_API. 2001-10-21 Mikael Djurfeldt From 12991fed11be03134d2d871fc84c77b39a3ca815 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:35:53 +0000 Subject: [PATCH 118/281] (SRFI-19, SRFI-19 Constants, SRFI-19 Current time and clock resolution, SRFI-19 Time object and accessors, SRFI-19 Time comparison procedures, SRFI-19 Time arithmetic procedures, SRFI-19 Date object and accessors, SRFI-19 Time/Date/Julian Day/Modified Julian Day converters, SRFI-19 Date to string/string to date converters): New nodes. --- doc/ref/srfi-modules.texi | 183 +++++++++++++++++++++++++++++++++++--- 1 file changed, 170 insertions(+), 13 deletions(-) diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index 56e4ff718..26b8f3f45 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -39,7 +39,7 @@ SRFI support in Guile is currently implemented partly in the core library, and partly as add-on modules. That means that some SRFIs are automatically available when the interpreter is started, whereas the other SRFIs require you to use the appropriate support module -explicitly. +explicitly. There are several reasons for this inconsistency. First, the feature checking syntactic form @code{cond-expand} (@pxref{SRFI-0}) must be @@ -128,7 +128,7 @@ this form. Currently, the feature identifiers @code{guile}, @code{r5rs} and @code{srfi-0} are supported. The other SRFIs are not in that list by default, because the SRFI modules must be explicitly used before their -exported bindings can be used. +exported bindings can be used. So if a Scheme program wishes to use SRFI-8, it has two possibilities: First, it can check whether the running Scheme implementation is Guile, @@ -507,16 +507,16 @@ be applied to tge list elements in left-to-right order. @deffn procedure append-map f lst1 lst2 @dots{} @deffnx procedure append-map! f lst1 lst2 @dots{} -Equivalent to +Equivalent to @lisp -(apply append (map f clist1 clist2 ...)) +(apply append (map f clist1 clist2 ...)) @end lisp -and +and @lisp -(apply append! (map f clist1 clist2 ...)) +(apply append! (map f clist1 clist2 ...)) @end lisp Map @var{f} over the elements of the lists, just as in the @code{map} @@ -848,7 +848,7 @@ returns the value of @var{x}. (and-let* ((x 1) (y #f)) 42) @result{} #f -(and-let* ((x 1) (y #t)) x) +(and-let* ((x 1) (y #t)) x) @result{} 1 @end lisp @@ -1026,7 +1026,7 @@ Usage example: @example guile> (use-modules (srfi srfi-9)) -guile> (define-record-type :foo (make-foo x) foo? +guile> (define-record-type :foo (make-foo x) foo? (x get-x) (y get-y set-y!)) guile> (define f (make-foo 1)) guile> f @@ -1189,7 +1189,7 @@ guile> (string-concatenate '("Hello" " " "World!")) @end example @node SRFI-13 Predicates -@subsection Predicates +@subsection Predicates In addition to the primitives @code{string?} and @code{string-null?}, which are already in the Guile core, the string predicates @@ -1471,7 +1471,7 @@ returning the index of the first (last) occurence of a character which equals @var{char_pred}, if it is character, @item -satisifies the predicate @var{char_pred}, if it is a +satisifies the predicate @var{char_pred}, if it is a procedure, @item @@ -1649,7 +1649,7 @@ values from the initial @var{seed}: @var{seed}, (@var{g} @dots{} @item @var{p} tells us when to stop - when it returns true when applied to one of these seed values. -@item @var{f} maps each seed value to the corresponding +@item @var{f} maps each seed value to the corresponding character in the result string. These chars are assembled into the string in a left-to-right (right-to-left) order. @item @var{base} is the optional initial/leftmost (rightmost) @@ -1888,11 +1888,11 @@ initializing it with @var{knil}. @deffnx primitive char-set-unfold! p f g seed base_cs This is a fundamental constructor for character sets. @itemize @bullet -@item @var{g} is used to generate a series of ``seed'' values +@item @var{g} is used to generate a series of ``seed'' values from the initial seed: @var{seed}, (@var{g} @var{seed}), (@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}), @dots{} @item @var{p} tells us when to stop -- when it returns true -when applied to one of the seed values. +when applied to one of the seed values. @item @var{f} maps each seed value to a character. These characters are added to the base character set @var{base_cs} to form the result; @var{base_cs} defaults to the empty set. @@ -2239,3 +2239,160 @@ procedure is to create a new object (a @dfn{procedure with setter}) via the @code{getter-with-setter} procedure. This procedure is also specified in the SRFI. Using it avoids the described problems. + +@node SRFI-19 +@section SRFI-19 - Time/Date Library + +This is an implementation of SRFI-19: Time/Date Library + +It depends on SRFIs: 6 (@pxref{SRFI-6}), 8 (@pxref{SRFI-8}), +9 (@pxref{SRFI-9}). + +This section documents constants and procedure signatures. + +@menu +* SRFI-19 Constants:: +* SRFI-19 Current time and clock resolution:: +* SRFI-19 Time object and accessors:: +* SRFI-19 Time comparison procedures:: +* SRFI-19 Time arithmetic procedures:: +* SRFI-19 Date object and accessors:: +* SRFI-19 Time/Date/Julian Day/Modified Julian Day converters:: +* SRFI-19 Date to string/string to date converters:: +@end menu + +@node SRFI-19 Constants +@subsection SRFI-19 Constants + +All these are bound to their symbol names: + +@example + time-duration + time-monotonic + time-process + time-tai + time-thread + time-utc +@end example + +@node SRFI-19 Current time and clock resolution +@subsection SRFI-19 Current time and clock resolution + +@example + (current-date . tz-offset) + (current-julian-day) + (current-modified-julian-day) + (current-time . clock-type) + (time-resolution . clock-type) +@end example + +@node SRFI-19 Time object and accessors +@subsection SRFI-19 Time object and accessors + +@example + (make-time type nanosecond second) + (time? obj) + (time-type time) + (time-nanosecond time) + (time-second time) + (set-time-type! time type) + (set-time-nanosecond! time nsec) + (set-time-second! time sec) + (copy-time time) +@end example + +@node SRFI-19 Time comparison procedures +@subsection SRFI-19 Time comparison procedures + +Args are all @code{time} values. + +@example + (time<=? t1 t2) + (time=? t1 t2) + (time>? t1 t2) +@end example + +@node SRFI-19 Time arithmetic procedures +@subsection SRFI-19 Time arithmetic procedures + +The @code{foo!} variants modify in place. Time difference +is expressed in @code{time-duration} values. + +@example + (time-difference t1 t2) + (time-difference! t1 t2) + (add-duration time duration) + (add-duration! time duration) + (subtract-duration time duration) + (subtract-duration! time duration) + @end example + +@node SRFI-19 Date object and accessors +@subsection SRFI-19 Date object and accessors + +@example + (make-date nsecs seconds minutes hours + date month year offset) + (date? obj) + (date-nanosecond date) + (date-second date) + (date-minute date) + (date-hour date) + (date-day date) + (date-month date) + (date-year date) + (date-zone-offset date) + (date-year-day date) + (date-week-day date) + (date-week-number date day-of-week-starting-week) +@end example + +@node SRFI-19 Time/Date/Julian Day/Modified Julian Day converters +@subsection SRFI-19 Time/Date/Julian Day/Modified Julian Day converters + +@example + (date->julian-day date) + (date->modified-julian-day date) + (date->time-monotonic date) + (date->time-tai date) + (date->time-utc date) + (julian-day->date jdn . tz-offset) + (julian-day->time-monotonic jdn) + (julian-day->time-tai jdn) + (julian-day->time-utc jdn) + (modified-julian-day->date jdn . tz-offset) + (modified-julian-day->time-monotonic jdn) + (modified-julian-day->time-tai jdn) + (modified-julian-day->time-utc jdn) + (time-monotonic->date time . tz-offset) + (time-monotonic->time-tai time-in) + (time-monotonic->time-tai! time-in) + (time-monotonic->time-utc time-in) + (time-monotonic->time-utc! time-in) + (time-tai->date time . tz-offset) + (time-tai->julian-day time) + (time-tai->modified-julian-day time) + (time-tai->time-monotonic time-in) + (time-tai->time-monotonic! time-in) + (time-tai->time-utc time-in) + (time-tai->time-utc! time-in) + (time-utc->date time . tz-offset) + (time-utc->julian-day time) + (time-utc->modified-julian-day time) + (time-utc->time-monotonic time-in) + (time-utc->time-monotonic! time-in) + (time-utc->time-tai time-in) + (time-utc->time-tai! time-in) +@end example + +@node SRFI-19 Date to string/string to date converters +@subsection SRFI-19 Date to string/string to date converters + +@example + (date->string date . format-string) + (string->date input-string template-string) +@end example + +@c srfi-modules.texi ends here From ca26b87dd48e5eeef74f4654432eb4aac2741714 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:38:48 +0000 Subject: [PATCH 119/281] *** empty log message *** --- doc/ref/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 2729127f0..fbf9e6018 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,12 @@ +2001-11-06 Thien-Thi Nguyen + + * srfi-modules.texi (SRFI-19, SRFI-19 Constants, SRFI-19 Current + time and clock resolution, SRFI-19 Time object and accessors, + SRFI-19 Time comparison procedures, SRFI-19 Time arithmetic + procedures, SRFI-19 Date object and accessors, SRFI-19 + Time/Date/Julian Day/Modified Julian Day converters, SRFI-19 Date + to string/string to date converters): New nodes. + 2001-11-06 Marius Vollmer * scripts.texi: Document `--debug' and `--no-debug'. From bfc9c8e088236173ba701373fdc66d4c26379b5d Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:43:41 +0000 Subject: [PATCH 120/281] (SRFI Support): Add "SRFI-19" to menu. --- doc/ref/srfi-modules.texi | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index 26b8f3f45..c620050f0 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -27,6 +27,7 @@ get the relevant SRFI documents from the SRFI home page * SRFI-14:: Character-set library. * SRFI-16:: case-lambda * SRFI-17:: Generalized set! +* SRFI-19:: Time/Date library. @end menu From 523ebf43bd45596c64b57c3899ef224487407743 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:46:48 +0000 Subject: [PATCH 121/281] (sync srfi-modules.texi): Done. --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 398469964..8fd602b0d 100644 --- a/TODO +++ b/TODO @@ -65,7 +65,7 @@ that user-visible changes are reflected in NEWS. - add DLL support [ela] <-- set by ttn (my bad) -- sync srfi-modules.texi [ttn] ++ sync srfi-modules.texi [ttn] - For GOOPS: [ttn] - rewrite method cache management in C From 04bbd6ce0912ebbf6f1d60d0720d7d3d553e1208 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 6 Nov 2001 22:48:30 +0000 Subject: [PATCH 122/281] *** empty log message *** --- ChangeLog | 10 +++++++--- doc/ref/ChangeLog | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ead195902..b1f97975a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-11-06 Thien-Thi Nguyen + + * TODO (sync srfi-modules.texi): New, done. + 2001-11-04 Stefan Jahn * NEWS: Corrected remarks about SCM_API. @@ -10,13 +14,13 @@ 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! - + * check-guile.in: Replaced `ln -s' by `@LN_S@' to supports build systems which do not have symbolic links. * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls on Win32 platforms. - Checking for `ws2_32.dll', `winsock2.h', add `win32-uname.o' - and `win32-dirent.o' and define extra compiler flags necessary + Checking for `ws2_32.dll', `winsock2.h', add `win32-uname.o' + and `win32-dirent.o' and define extra compiler flags necessary to build clean dlls. Check for `regcomp()' inside `-lregex'. diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index fbf9e6018..52476be8e 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -6,6 +6,7 @@ procedures, SRFI-19 Date object and accessors, SRFI-19 Time/Date/Julian Day/Modified Julian Day converters, SRFI-19 Date to string/string to date converters): New nodes. + (SRFI Support): Add "SRFI-19" to menu. 2001-11-06 Marius Vollmer From d5b7b584328e7c7ab5ba42f70071302cb5b90f40 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 7 Nov 2001 00:37:39 +0000 Subject: [PATCH 123/281] (9): New. --- BUGS | 63 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/BUGS b/BUGS index 914dad17e..8be27f547 100644 --- a/BUGS +++ b/BUGS @@ -67,9 +67,9 @@ fixed: not-yet currently: > (let name ((var init) ...) body ...) -> +> > to -> +> > (letrec ((name (lambda (var ...) body ...))) > (name init ...)) @@ -89,7 +89,7 @@ fixed: 2001-10-14 (1.5.x, 1.7.x) Keith Wright sez: > Before getting into philosophy, I want to mention that while poking > around and rethinking I found the following Bug. -> +> > guile> (version) > "1.5.2" > guile> #E3 @@ -98,9 +98,9 @@ Keith Wright sez: > ERROR: read:uniform-vector list not found > ABORT: (misc-error) > guile> 3 -> -> This violates both R5RS 7.1 ``Case is insignificant'' and -> +> +> This violates both R5RS 7.1 ``Case is insignificant'' and +> > > From: guile-1.5.2/doc/ref/guile.info-3 Line 568 > > > > The codes for indicating exactness (which can, incidentally, be @@ -124,19 +124,19 @@ fixed: 2001-10-14 (1.5.x, 1.7.x) (see bug 5) Keith Wright sez: > The saga continues... -> +> > > > The codes for indicating exactness (which can, incidentally, be > > > applied to all numerical values) are: > > > > > > * `#e', `#E' -- the number is exact -> +> > guile> #E3 ==> 3 > guile> #E3.0 > ERROR: In procedure scm_lreadr: > ERROR: unknown # object -> +> > Better change the reference manual s/, incidentally,/'t/. -> +> > (That's a joke son. The Scheme language requires #e in front > of any number to at least do nothing successfully.) @@ -153,7 +153,7 @@ fixed: not-yet Keith Wright sez: > I got guile-1.5.4 and installed it on one machine with no problem. > On another I did ./configure;make as before and it died with: -> +> > > ... > > on.doc vports.doc weaks.doc symbols-deprecated.doc regex-posix.doc ramap.doc unif.doc filesys.doc posix.doc net_db.doc socket.doc | ./guile-snarf-docs-texi > guile.texi \ > > || { rm guile.texi; false; } @@ -163,9 +163,48 @@ Keith Wright sez: > > make[1]: *** [guile-procedures.txt] Error 1 > > make[1]: Leaving directory `/home/kwright/build/guile-1.5.4/libguile' > > make: *** [all-recursive] Error 1 -> +> > I get the impression that it is supposed to build without 'makeinfo', > if this is not so it should be mentioned in the README or INSTALL. + +bug 9 -- sibling threads not infinite looping +reported-by: giraud@tif.inria.fr / 2001-09-24 +fixed: not-yet + +Manuel Giraud sez: +> I've configure guile-1.5.4 '--with-threads' and '--with-modules' on a +> "classical" Linux box and used this code that crash silently : +> +> (use-modules (ice-9 threads)) +> +> (begin-thread +> (let loop () +> (display "a") +> (newline) +> (loop))) +> +> (begin-thread +> (let loop () +> (display "b") +> (newline) +> (loop))) + +mdj sez: ++ 2001-10-06 Mikael Djurfeldt ++ ++ These changes fixes a race condition in the Guile coop - pthread ++ compatibility code. ++ ++ * coop.c (mother_awake_p): New variable. ++ (coop_create): Set mother_awake_p before creating or signalling ++ mother; wait until mother is going to sleep before returning. ++ (mother): Reset mother_awake_p before going to sleep. ++ + +ttn sez: +crash still occurs w/ "guile -s bug.scm" (cvs checkout on 2001/11/06). +however, "guile -l bug.scm" works as expected. + [BUGS ends here] From 70debc22969e0b2a51bfaa419c2b373d0addbbf1 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 7 Nov 2001 00:40:15 +0000 Subject: [PATCH 124/281] *** empty log message *** --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index b1f97975a..5cc300c29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * TODO (sync srfi-modules.texi): New, done. + * BUGS (9): New. + 2001-11-04 Stefan Jahn * NEWS: Corrected remarks about SCM_API. From 3989f08206a8f4860f9513d77c6efc36aa2fa166 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 7 Nov 2001 02:55:05 +0000 Subject: [PATCH 125/281] (10): New. --- BUGS | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/BUGS b/BUGS index 8be27f547..632157fb2 100644 --- a/BUGS +++ b/BUGS @@ -206,5 +206,31 @@ ttn sez: crash still occurs w/ "guile -s bug.scm" (cvs checkout on 2001/11/06). however, "guile -l bug.scm" works as expected. + +bug 10 -- embedded libltdl masks system version unconditionally +reported-by: grib@linuxdevel.com / 2001-11-04 +fixed: not-yet + +Bill Gribble sez: +> The guideline for when to use the convenience version of libltdl is +> this: +> +> > In general you can safely use the convenience library in +> > programs which don't depend on other libraries that might +> > use libltdl too. +> +> So guile's use of the convenience library embodies an assumption about +> programs which use guile: that they will not use libltdl except through +> guile's wrapper (dynamic-link and friends). +> +> It seems like this is a bad assumption for guile to make, since it is +> intended to be used as an extension language for many different kinds of +> programs and not to put a priori restrictions on what they can do. +> Especially when those restrictions are not documented. +> +> I would suggest that prior to the guile-1.6 release the use of the +> convenience ltdl library be removed, instead depending on an installed +> version of libltdl. + [BUGS ends here] From 2ca222c2e93e3cd58ad95b984feb2c74d0310284 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 7 Nov 2001 02:55:40 +0000 Subject: [PATCH 126/281] *** empty log message *** --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5cc300c29..ca58f5095 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ * TODO (sync srfi-modules.texi): New, done. - * BUGS (9): New. + * BUGS (9, 10): New. 2001-11-04 Stefan Jahn From b4e15479e93409413bb1dab28c53d9e80302b1ee Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Wed, 7 Nov 2001 15:08:45 +0000 Subject: [PATCH 127/281] 2001-11-07 Stefan Jahn * configure.in: Include `win32-socket.o' in the list of object files if networking is enabled on Win32. 2001-11-07 Stefan Jahn * win32-socket.[ch]: New files. Defines Winsock-API error codes and makes them available through Guile. That is because the Winsock-API does not store its errors in `errno' and thus cannot return error messages via `strerror (errno)'. * socket.c (scm_init_socket): Initialize `win32-socket' part here under M$-Windows. * numbers.h: Added missing declaration of `scm_sys_check_number_conversions()'. * error.c: Local definition of SCM_I_STRERROR and SCM_I_ERRNO and use in `(strerror)' and `(system-error)'. * Makefile.am (EXTRA_libguile_la_SOURCES): Added `win32-socket.[ch]' to extra source and header files. --- ChangeLog | 5 + configure.in | 5 +- libguile/ChangeLog | 19 ++ libguile/Makefile.am | 6 +- libguile/error.c | 17 +- libguile/numbers.c | 2 +- libguile/numbers.h | 4 + libguile/socket.c | 8 + libguile/win32-dirent.h | 6 +- libguile/win32-socket.c | 403 ++++++++++++++++++++++++++++++++++++++++ libguile/win32-socket.h | 56 ++++++ libguile/win32-uname.h | 8 +- 12 files changed, 525 insertions(+), 14 deletions(-) create mode 100644 libguile/win32-socket.c create mode 100644 libguile/win32-socket.h diff --git a/ChangeLog b/ChangeLog index ca58f5095..d33eb782d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-07 Stefan Jahn + + * configure.in: Include `win32-socket.o' in the list of object + files if networking is enabled on Win32. + 2001-11-06 Thien-Thi Nguyen * TODO (sync srfi-modules.texi): New, done. diff --git a/configure.in b/configure.in index 01f5b6525..07a4ee4df 100644 --- a/configure.in +++ b/configure.in @@ -233,7 +233,10 @@ if test "$MINGW32" = "yes" ; then [Define if you have the header file.])]) AC_CHECK_LIB(ws2_32, main) LIBOBJS="$LIBOBJS win32-uname.o win32-dirent.o" - if test $enable_shared = yes ; then + if test "$enable_networking" = yes ; then + LIBOBJS="$LIBOBJS win32-socket.o" + fi + if test "$enable_shared" = yes ; then EXTRA_DEFS="-DSCM_IMPORT" AC_DEFINE(USE_DLL_IMPORT, 1, [Define if you need additional CPP macros on Win32 platforms.]) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index e648ea2ca..660d22307 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,22 @@ +2001-11-07 Stefan Jahn + + * win32-socket.[ch]: New files. Defines Winsock-API error codes + and makes them available through Guile. That is because the + Winsock-API does not store its errors in `errno' and thus cannot + return error messages via `strerror (errno)'. + + * socket.c (scm_init_socket): Initialize `win32-socket' part + here under M$-Windows. + + * numbers.h: Added missing declaration of + `scm_sys_check_number_conversions()'. + + * error.c: Local definition of SCM_I_STRERROR and SCM_I_ERRNO + and use in `(strerror)' and `(system-error)'. + + * Makefile.am (EXTRA_libguile_la_SOURCES): Added + `win32-socket.[ch]' to extra source and header files. + 2001-11-06 Marius Vollmer * script.c (scm_shell_usage, scm_compile_shell_switches): Prepend diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 517bbda74..d894befda 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -94,7 +94,8 @@ EXTRA_libguile_la_SOURCES = _scm.h \ alloca.c inet_aton.c memmove.c putenv.c strerror.c \ threads.c regex-posix.c \ filesys.c posix.c net_db.c socket.c \ - ramap.c unif.c debug-malloc.c mkstemp.c win32-uname.c win32-dirent.c + ramap.c unif.c debug-malloc.c mkstemp.c \ + win32-uname.c win32-dirent.c win32-socket.c ## In next release, threads will be factored out of libguile. ## Until then, the machine specific headers is a temporary kludge. @@ -112,7 +113,8 @@ install-exec-hook: ## Perhaps we can deal with them normally once the merge seems to be ## working. noinst_HEADERS = coop-threads.c coop-threads.h coop.c \ - num2integral.i.c num2float.i.c win32-uname.h win32-dirent.h + num2integral.i.c num2float.i.c \ + win32-uname.h win32-dirent.h win32-socket.h libguile_la_DEPENDENCIES = @LIBLOBJS@ libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) $(THREAD_LIBS_LOCAL) diff --git a/libguile/error.c b/libguile/error.c index fd9b2a0d9..e17231f88 100644 --- a/libguile/error.c +++ b/libguile/error.c @@ -151,6 +151,17 @@ SCM_DEFINE (scm_error_scm, "scm-error", 5, 0, 0, } #undef FUNC_NAME +#ifdef __MINGW32__ +# include "win32-socket.h" +# define SCM_I_STRERROR(err) \ + ((err >= WSABASEERR) ? scm_i_socket_strerror (err) : strerror (err)) +# define SCM_I_ERRNO() \ + (errno ? errno : scm_i_socket_errno ()) +#else +# define SCM_I_STRERROR(err) strerror (err) +# define SCM_I_ERRNO() errno +#endif /* __MINGW32__ */ + SCM_DEFINE (scm_strerror, "strerror", 1, 0, 0, (SCM err), "Return the Unix error message corresponding to @var{err}, which\n" @@ -158,7 +169,7 @@ SCM_DEFINE (scm_strerror, "strerror", 1, 0, 0, #define FUNC_NAME s_scm_strerror { SCM_VALIDATE_INUM (1,err); - return scm_makfrom0str (strerror (SCM_INUM (err))); + return scm_makfrom0str (SCM_I_STRERROR (SCM_INUM (err))); } #undef FUNC_NAME @@ -166,12 +177,12 @@ SCM_GLOBAL_SYMBOL (scm_system_error_key, "system-error"); void scm_syserror (const char *subr) { - int save_errno = errno; + int save_errno = SCM_I_ERRNO (); scm_error (scm_system_error_key, subr, "~A", - scm_cons (scm_makfrom0str (strerror (save_errno)), SCM_EOL), + scm_cons (scm_makfrom0str (SCM_I_STRERROR (save_errno)), SCM_EOL), scm_cons (SCM_MAKINUM (save_errno), SCM_EOL)); } diff --git a/libguile/numbers.c b/libguile/numbers.c index e9760b812..62fb3d918 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4448,7 +4448,7 @@ check_handler (void *data, SCM tag, SCM throw_args) } SCM_DEFINE (scm_sys_check_number_conversions, "%check-number-conversions", 0, 0, 0, - (), + (void), "Number conversion sanity checking.") #define FUNC_NAME s_scm_sys_check_number_conversions { diff --git a/libguile/numbers.h b/libguile/numbers.h index 023288ead..ddd716e9a 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -333,6 +333,10 @@ SCM_API float scm_num2float (SCM num, unsigned long int pos, SCM_API double scm_num2double (SCM num, unsigned long int pos, const char *s_caller); +#ifdef GUILE_DEBUG +SCM_API SCM scm_sys_check_number_conversions (void); +#endif + SCM_API void scm_init_numbers (void); #endif /* SCM_NUMBERS_H */ diff --git a/libguile/socket.c b/libguile/socket.c index 44539bce9..7dc729ca1 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -54,6 +54,10 @@ #include "libguile/validate.h" #include "libguile/socket.h" +#ifdef __MINGW32__ +#include "win32-socket.h" +#endif + #ifdef HAVE_STRING_H #include #endif @@ -1383,6 +1387,10 @@ scm_init_socket () scm_c_define ("MSG_DONTROUTE", SCM_MAKINUM (MSG_DONTROUTE)); #endif +#ifdef __MINGW32__ + scm_i_init_socket_Win32 (); +#endif + scm_add_feature ("socket"); #ifndef SCM_MAGIC_SNARFER diff --git a/libguile/win32-dirent.h b/libguile/win32-dirent.h index ffc5e2a2d..07f902aff 100644 --- a/libguile/win32-dirent.h +++ b/libguile/win32-dirent.h @@ -1,7 +1,7 @@ /* classes: h_files */ -#ifndef SCM_DIRENT_H -#define SCM_DIRENT_H +#ifndef SCM_WIN32_DIRENT_H +#define SCM_WIN32_DIRENT_H /* Copyright (C) 2001 Free Software Foundation, Inc. * @@ -85,4 +85,4 @@ void seekdir (DIR * dir, off_t offset); off_t telldir (DIR * dir); int dirfd (DIR * dir); -#endif /* SCM_DIRENT_H */ +#endif /* SCM_WIN32_DIRENT_H */ diff --git a/libguile/win32-socket.c b/libguile/win32-socket.c new file mode 100644 index 000000000..8456ad321 --- /dev/null +++ b/libguile/win32-socket.c @@ -0,0 +1,403 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + + + + +#include "libguile/__scm.h" +#include "libguile/modules.h" +#include "libguile/numbers.h" + +#include + +#include "win32-socket.h" + +/* Winsock API error description structure. The error description is + necessary because there is no error list available. */ +typedef struct +{ + int error; /* Error code. */ + char *str; /* Error description. */ + int replace; /* Possible error code replacement. */ + char *replace_str; /* Replacement symbol. */ + char *correct_str; /* Original symbol. */ +} +socket_error_t; + +/* Define replacement symbols for most of the WSA* error codes. */ +#ifndef EWOULDBLOCK +# define EWOULDBLOCK WSAEWOULDBLOCK +#endif +#ifndef EINPROGRESS +# define EINPROGRESS WSAEINPROGRESS +#endif +#ifndef EALREADY +# define EALREADY WSAEALREADY +#endif +#ifndef EDESTADDRREQ +# define EDESTADDRREQ WSAEDESTADDRREQ +#endif +#ifndef EMSGSIZE +# define EMSGSIZE WSAEMSGSIZE +#endif +#ifndef EPROTOTYPE +# define EPROTOTYPE WSAEPROTOTYPE +#endif +#ifndef ENOTSOCK +# define ENOTSOCK WSAENOTSOCK +#endif +#ifndef ENOPROTOOPT +# define ENOPROTOOPT WSAENOPROTOOPT +#endif +#ifndef EPROTONOSUPPORT +# define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#endif +#ifndef ESOCKTNOSUPPORT +# define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#endif +#ifndef EOPNOTSUPP +# define EOPNOTSUPP WSAEOPNOTSUPP +#endif +#ifndef EPFNOSUPPORT +# define EPFNOSUPPORT WSAEPFNOSUPPORT +#endif +#ifndef EAFNOSUPPORT +# define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif +#ifndef EADDRINUSE +# define EADDRINUSE WSAEADDRINUSE +#endif +#ifndef EADDRNOTAVAIL +# define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#endif +#ifndef ENETDOWN +# define ENETDOWN WSAENETDOWN +#endif +#ifndef ENETUNREACH +# define ENETUNREACH WSAENETUNREACH +#endif +#ifndef ENETRESET +# define ENETRESET WSAENETRESET +#endif +#ifndef ECONNABORTED +# define ECONNABORTED WSAECONNABORTED +#endif +#ifndef ECONNRESET +# define ECONNRESET WSAECONNRESET +#endif +#ifndef ENOBUFS +# define ENOBUFS WSAENOBUFS +#endif +#ifndef EISCONN +# define EISCONN WSAEISCONN +#endif +#ifndef ENOTCONN +# define ENOTCONN WSAENOTCONN +#endif +#ifndef ESHUTDOWN +# define ESHUTDOWN WSAESHUTDOWN +#endif +#ifndef ETOOMANYREFS +# define ETOOMANYREFS WSAETOOMANYREFS +#endif +#ifndef ETIMEDOUT +# define ETIMEDOUT WSAETIMEDOUT +#endif +#ifndef ECONNREFUSED +# define ECONNREFUSED WSAECONNREFUSED +#endif +#ifndef ELOOP +# define ELOOP WSAELOOP +#endif +#ifndef EHOSTDOWN +# define EHOSTDOWN WSAEHOSTDOWN +#endif +#ifndef EHOSTUNREACH +# define EHOSTUNREACH WSAEHOSTUNREACH +#endif +#ifndef EPROCLIM +# define EPROCLIM WSAEPROCLIM +#endif +#ifndef EUSERS +# define EUSERS WSAEUSERS +#endif +#ifndef EDQUOT +# define EDQUOT WSAEDQUOT +#endif +#ifndef ESTALE +# define ESTALE WSAESTALE +#endif +#ifndef EREMOTE +# define EREMOTE WSAEREMOTE +#endif + +/* List of error structures. */ +static socket_error_t socket_errno [] = { + /* 000 */ { 0, NULL, 0, NULL, NULL }, + /* 001 */ { 0, NULL, 0, NULL, NULL }, + /* 002 */ { 0, NULL, 0, NULL, NULL }, + /* 003 */ { 0, NULL, 0, NULL, NULL }, + /* 004 */ { WSAEINTR, "Interrupted function call", EINTR, NULL, "WSAEINTR" }, + /* 005 */ { 0, NULL, 0, NULL, NULL }, + /* 006 */ { 0, NULL, 0, NULL, NULL }, + /* 007 */ { 0, NULL, 0, NULL, NULL }, + /* 008 */ { 0, NULL, 0, NULL, NULL }, + /* 009 */ { WSAEBADF, "Bad file number", EBADF, NULL, "WSAEBADF" }, + /* 010 */ { 0, NULL, 0, NULL, NULL }, + /* 011 */ { 0, NULL, 0, NULL, NULL }, + /* 012 */ { 0, NULL, 0, NULL, NULL }, + /* 013 */ { WSAEACCES, "Permission denied", EACCES, NULL, "WSAEACCES" }, + /* 014 */ { WSAEFAULT, "Bad address", EFAULT, NULL, "WSAEFAULT" }, + /* 015 */ { 0, NULL, 0, NULL, NULL }, + /* 016 */ { 0, NULL, 0, NULL, NULL }, + /* 017 */ { 0, NULL, 0, NULL, NULL }, + /* 018 */ { 0, NULL, 0, NULL, NULL }, + /* 019 */ { 0, NULL, 0, NULL, NULL }, + /* 020 */ { 0, NULL, 0, NULL, NULL }, + /* 021 */ { 0, NULL, 0, NULL, NULL }, + /* 022 */ { WSAEINVAL, "Invalid argument", EINVAL, NULL, "WSAEINVAL" }, + /* 023 */ { 0, NULL, 0, NULL, NULL }, + /* 024 */ { WSAEMFILE, "Too many open files", EMFILE, NULL, "WSAEMFILE" }, + /* 025 */ { 0, NULL, 0, NULL, NULL }, + /* 026 */ { 0, NULL, 0, NULL, NULL }, + /* 027 */ { 0, NULL, 0, NULL, NULL }, + /* 028 */ { 0, NULL, 0, NULL, NULL }, + /* 029 */ { 0, NULL, 0, NULL, NULL }, + /* 030 */ { 0, NULL, 0, NULL, NULL }, + /* 031 */ { 0, NULL, 0, NULL, NULL }, + /* 032 */ { 0, NULL, 0, NULL, NULL }, + /* 033 */ { 0, NULL, 0, NULL, NULL }, + /* 034 */ { 0, NULL, 0, NULL, NULL }, + /* 035 */ { WSAEWOULDBLOCK, "Resource temporarily unavailable", + EWOULDBLOCK, "EWOULDBLOCK", "WSAEWOULDBLOCK" }, + /* 036 */ { WSAEINPROGRESS, "Operation now in progress", + EINPROGRESS, "EINPROGRESS", "WSAEINPROGRESS" }, + /* 037 */ { WSAEALREADY, "Operation already in progress", + EALREADY, "EALREADY", "WSAEALREADY" }, + /* 038 */ { WSAENOTSOCK, "Socket operation on non-socket", + ENOTSOCK, "ENOTSOCK", "WSAENOTSOCK"}, + /* 039 */ { WSAEDESTADDRREQ, "Destination address required", + EDESTADDRREQ, "EDESTADDRREQ", "WSAEDESTADDRREQ" }, + /* 040 */ { WSAEMSGSIZE, "Message too long", + EMSGSIZE, "EMSGSIZE", "WSAEMSGSIZE" }, + /* 041 */ { WSAEPROTOTYPE, "Protocol wrong type for socket", + EPROTOTYPE, "EPROTOTYPE", "WSAEPROTOTYPE" }, + /* 042 */ { WSAENOPROTOOPT, "Bad protocol option", + ENOPROTOOPT, "ENOPROTOOPT", "WSAENOPROTOOPT" }, + /* 043 */ { WSAEPROTONOSUPPORT, "Protocol not supported", + EPROTONOSUPPORT, "EPROTONOSUPPORT", "WSAEPROTONOSUPPORT" }, + /* 044 */ { WSAESOCKTNOSUPPORT, "Socket type not supported", + ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "WSAESOCKTNOSUPPORT" }, + /* 045 */ { WSAEOPNOTSUPP, "Operation not supported", + EOPNOTSUPP, "EOPNOTSUPP", "WSAEOPNOTSUPP" }, + /* 046 */ { WSAEPFNOSUPPORT, "Protocol family not supported", + EPFNOSUPPORT, "EPFNOSUPPORT", "WSAEPFNOSUPPORT" }, + /* 047 */ { WSAEAFNOSUPPORT, + "Address family not supported by protocol family", + EAFNOSUPPORT, "EAFNOSUPPORT", "WSAEAFNOSUPPORT" }, + /* 048 */ { WSAEADDRINUSE, "Address already in use", + EADDRINUSE, "EADDRINUSE", "WSAEADDRINUSE" }, + /* 049 */ { WSAEADDRNOTAVAIL, "Cannot assign requested address", + EADDRNOTAVAIL, "EADDRNOTAVAIL", "WSAEADDRNOTAVAIL" }, + /* 050 */ { WSAENETDOWN, "Network is down", + ENETDOWN, "ENETDOWN", "WSAENETDOWN" }, + /* 051 */ { WSAENETUNREACH, "Network is unreachable", + ENETUNREACH, "ENETUNREACH", "WSAENETUNREACH" }, + /* 052 */ { WSAENETRESET, "Network dropped connection on reset", + ENETRESET, "ENETRESET", "WSAENETRESET" }, + /* 053 */ { WSAECONNABORTED, "Software caused connection abort", + ECONNABORTED, "ECONNABORTED", "WSAECONNABORTED" }, + /* 054 */ { WSAECONNRESET, "Connection reset by peer", + ECONNRESET, "ECONNRESET", "WSAECONNRESET" }, + /* 055 */ { WSAENOBUFS, "No buffer space available", + ENOBUFS, "ENOBUFS", "WSAENOBUFS" }, + /* 056 */ { WSAEISCONN, "Socket is already connected", + EISCONN, "EISCONN", "WSAEISCONN" }, + /* 057 */ { WSAENOTCONN, "Socket is not connected", + ENOTCONN, "ENOTCONN", "WSAENOTCONN" }, + /* 058 */ { WSAESHUTDOWN, "Cannot send after socket shutdown", + ESHUTDOWN, "ESHUTDOWN", "WSAESHUTDOWN" }, + /* 059 */ { WSAETOOMANYREFS, "Too many references; can't splice", + ETOOMANYREFS, "ETOOMANYREFS", "WSAETOOMANYREFS" }, + /* 060 */ { WSAETIMEDOUT, "Connection timed out", + ETIMEDOUT, "ETIMEDOUT", "WSAETIMEDOUT" }, + /* 061 */ { WSAECONNREFUSED, "Connection refused", + ECONNREFUSED, "ECONNREFUSED", "WSAECONNREFUSED" }, + /* 062 */ { WSAELOOP, "Too many levels of symbolic links", + ELOOP, "ELOOP", "WSAELOOP" }, + /* 063 */ { WSAENAMETOOLONG, "File name too long", + ENAMETOOLONG, NULL, "WSAENAMETOOLONG" }, + /* 064 */ { WSAEHOSTDOWN, "Host is down", + EHOSTDOWN, "EHOSTDOWN", "WSAEHOSTDOWN" }, + /* 065 */ { WSAEHOSTUNREACH, "No route to host", + EHOSTUNREACH, "EHOSTUNREACH", "WSAEHOSTUNREACH" }, + /* 066 */ { WSAENOTEMPTY, "Directory not empty", + ENOTEMPTY, NULL, "WSAENOTEMPTY" }, + /* 067 */ { WSAEPROCLIM, "Too many processes", + EPROCLIM, "EPROCLIM", "WSAEPROCLIM" }, + /* 068 */ { WSAEUSERS, "Too many users", + EUSERS, "EUSERS", "WSAEUSERS" }, + /* 069 */ { WSAEDQUOT, "Disc quota exceeded", + EDQUOT, "EDQUOT", "WSAEDQUOT" }, + /* 070 */ { WSAESTALE, "Stale NFS file handle", + ESTALE, "ESTALE", "WSAESTALE" }, + /* 071 */ { WSAEREMOTE, "Too many levels of remote in path", + EREMOTE, "EREMOTE", "WSAEREMOTE" }, + /* 072 */ { 0, NULL, 0, NULL, NULL }, + /* 073 */ { 0, NULL, 0, NULL, NULL }, + /* 074 */ { 0, NULL, 0, NULL, NULL }, + /* 075 */ { 0, NULL, 0, NULL, NULL }, + /* 076 */ { 0, NULL, 0, NULL, NULL }, + /* 077 */ { 0, NULL, 0, NULL, NULL }, + /* 078 */ { 0, NULL, 0, NULL, NULL }, + /* 079 */ { 0, NULL, 0, NULL, NULL }, + /* 080 */ { 0, NULL, 0, NULL, NULL }, + /* 081 */ { 0, NULL, 0, NULL, NULL }, + /* 082 */ { 0, NULL, 0, NULL, NULL }, + /* 083 */ { 0, NULL, 0, NULL, NULL }, + /* 084 */ { 0, NULL, 0, NULL, NULL }, + /* 085 */ { 0, NULL, 0, NULL, NULL }, + /* 086 */ { 0, NULL, 0, NULL, NULL }, + /* 087 */ { 0, NULL, 0, NULL, NULL }, + /* 088 */ { 0, NULL, 0, NULL, NULL }, + /* 089 */ { 0, NULL, 0, NULL, NULL }, + /* 090 */ { 0, NULL, 0, NULL, NULL }, + /* 091 */ { WSASYSNOTREADY, "Network subsystem is unavailable", + 0, NULL, "WSASYSNOTREADY" }, + /* 092 */ { WSAVERNOTSUPPORTED, "WINSOCK.DLL version out of range", + 0, NULL, "WSAVERNOTSUPPORTED" }, + /* 093 */ { WSANOTINITIALISED, "Successful WSAStartup not yet performed", + 0, NULL, "WSANOTINITIALISED" }, + /* 094 */ { 0, NULL, 0, NULL, NULL }, + /* 095 */ { 0, NULL, 0, NULL, NULL }, + /* 096 */ { 0, NULL, 0, NULL, NULL }, + /* 097 */ { 0, NULL, 0, NULL, NULL }, + /* 098 */ { 0, NULL, 0, NULL, NULL }, + /* 099 */ { 0, NULL, 0, NULL, NULL }, + /* 100 */ { 0, NULL, 0, NULL, NULL }, + /* 101 */ { WSAEDISCON, "Graceful shutdown in progress", + 0, NULL, "WSAEDISCON" }, + /* 102 */ { WSAENOMORE, "No more services", + 0, NULL, "WSAENOMORE" }, + /* 103 */ { WSAECANCELLED, "Service lookup cancelled", + 0, NULL, "WSAECANCELLED" }, + /* 104 */ { WSAEINVALIDPROCTABLE, "Invalid procedure call table", + 0, NULL, "WSAEINVALIDPROCTABLE" }, + /* 105 */ { WSAEINVALIDPROVIDER, "Invalid service provider", + 0, NULL, "WSAEINVALIDPROVIDER" }, + /* 106 */ { WSAEPROVIDERFAILEDINIT, "Service provider failure", + 0, NULL, "WSAEPROVIDERFAILEDINIT" }, + /* 107 */ { WSASYSCALLFAILURE, "System call failed", + 0, NULL, "WSASYSCALLFAILURE" }, + /* 108 */ { WSASERVICE_NOT_FOUND, "No such service", + 0, NULL, "WSASERVICE_NOT_FOUND" }, + /* 109 */ { WSATYPE_NOT_FOUND, "Class not found", + 0, NULL, "WSATYPE_NOT_FOUND" }, + /* 110 */ { WSA_E_NO_MORE, "No more services", + 0, NULL, "WSA_E_NO_MORE" }, + /* 111 */ { WSA_E_CANCELLED, "Service lookup cancelled", + 0, NULL, "WSA_E_CANCELLED" }, + /* 112 */ { WSAEREFUSED, "Database query refused", + 0, NULL, "WSAEREFUSED" }, + /* end */ { -1, NULL, -1, NULL, NULL } +}; + +/* Extended list of error structures. */ +static socket_error_t socket_h_errno [] = { + /* 000 */ { 0, NULL, 0, NULL, NULL }, + /* 001 */ { WSAHOST_NOT_FOUND, "Host not found", + HOST_NOT_FOUND, "HOST_NOT_FOUND", "WSAHOST_NOT_FOUND" }, + /* 002 */ { WSATRY_AGAIN, "Non-authoritative host not found", + TRY_AGAIN, "TRY_AGAIN", "WSATRY_AGAIN" }, + /* 003 */ { WSANO_RECOVERY, "This is a non-recoverable error", + NO_RECOVERY, "NO_RECOVERY", "WSANO_RECOVERY" }, + /* 004 */ { WSANO_DATA, "Valid name, no data record of requested type", + NO_DATA, "NO_DATA", "WSANO_DATA" }, + /* 005 */ { WSANO_ADDRESS, "No address, look for MX record", + NO_ADDRESS, "NO_ADDRESS", "WSANO_ADDRESS" }, + /* end */ { -1, NULL, -1, NULL, NULL } +}; + +/* Returns the result of @code{WSAGetLastError()}. */ +int +scm_i_socket_errno (void) +{ + return WSAGetLastError (); +} + +/* Returns a valid error message for Winsock-API error codes obtained via + @code{WSAGetLastError()} or NULL otherwise. */ +char * +scm_i_socket_strerror (int error) +{ + if (error >= WSABASEERR && error <= (WSABASEERR + 112)) + return socket_errno[error - WSABASEERR].str; + else if (error >= (WSABASEERR + 1000) && error <= (WSABASEERR + 1005)) + return socket_h_errno[error - (WSABASEERR + 1000)].str; + return NULL; +} + +/* Define both the original and replacement error symbol is possible. Thus + the user is able to check symbolic errors after unsuccessful networking + function calls. */ +static void +scm_socket_symbols_Win32 (socket_error_t * e) +{ + while (e->error != -1) + { + if (e->error) + { + if (e->correct_str) + scm_c_define (e->correct_str, SCM_MAKINUM (e->error)); + if (e->replace && e->replace_str) + scm_c_define (e->replace_str, SCM_MAKINUM (e->replace)); + } + e++; + } +} + +/* Initialize Winsock API under M$-Windows. */ +void +scm_i_init_socket_Win32 (void) +{ + scm_socket_symbols_Win32 (socket_errno); + scm_socket_symbols_Win32 (socket_h_errno); +} diff --git a/libguile/win32-socket.h b/libguile/win32-socket.h new file mode 100644 index 000000000..83e1030dd --- /dev/null +++ b/libguile/win32-socket.h @@ -0,0 +1,56 @@ +/* classes: h_files */ + +#ifndef SCM_WIN32_SOCKET_H +#define SCM_WIN32_SOCKET_H + +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + + +#if HAVE_WINSOCK2_H +# include +#endif + +int scm_i_socket_errno (void); +char * scm_i_socket_strerror (int error); +void scm_i_init_socket_Win32 (void); + +#endif /* SCM_WIN32_SOCKET_H */ diff --git a/libguile/win32-uname.h b/libguile/win32-uname.h index a61b5ca5a..40411400a 100644 --- a/libguile/win32-uname.h +++ b/libguile/win32-uname.h @@ -1,7 +1,7 @@ /* classes: h_files */ -#ifndef SCM_UNAME_H -#define SCM_UNAME_H +#ifndef SCM_WIN32_UNAME_H +#define SCM_WIN32_UNAME_H /* Copyright (C) 2001 Free Software Foundation, Inc. * @@ -70,6 +70,6 @@ struct utsname char domainname[_UTSNAME_DOMAIN_LENGTH]; }; -int uname (struct utsname *uts); +int uname (struct utsname * uts); -#endif /* SCM_UNAME_H */ +#endif /* SCM_WIN32_UNAME_H */ From 22ad074858deca1c87bd9ebcd868ec353a5d65a4 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 10 Nov 2001 22:44:30 +0000 Subject: [PATCH 128/281] (11): New. --- BUGS | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/BUGS b/BUGS index 632157fb2..9342b1af8 100644 --- a/BUGS +++ b/BUGS @@ -232,5 +232,38 @@ Bill Gribble sez: > convenience ltdl library be removed, instead depending on an installed > version of libltdl. + +bug 11 -- (ice-9 optargs) #:rest arg polluted by keys/values +reported-by: ttn / 2001-11-09 +fixed: not-yet + +ttn sez: +> the following code displays +> +> (# ()) +> (# (1)) +> (# ((1 2 3))) +> (# JAY KAY (#:j JAY #:k KAY)) +> (# JAY KAY (#:j JAY #:k KAY 1)) +> (# JAY KAY (#:j JAY #:k KAY (1 2 3))) +> +> but `x' should be the same for both `good' and `blah': +> +> (use-modules (ice-9 optargs) (ice-9 rdelim)) +> +> (define* (good #:rest x) +> (write-line (list good x))) +> +> (good) +> (good 1) +> (good '(1 2 3)) +> +> (define* (blah #:key (j 'j) (k 'k) #:rest x) +> (write-line (list blah j k x))) +> +> (blah #:j 'JAY #:k 'KAY) +> (blah #:j 'JAY #:k 'KAY 1) +> (blah #:j 'JAY #:k 'KAY '(1 2 3)) + [BUGS ends here] From a0a9b9ad4263e129e46e31a8c0c2e7775b037ee9 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 10 Nov 2001 22:45:18 +0000 Subject: [PATCH 129/281] *** empty log message *** --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index d33eb782d..1cf6eabc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-11-10 Thien-Thi Nguyen + + * BUGS (11): New. + 2001-11-07 Stefan Jahn * configure.in: Include `win32-socket.o' in the list of object From 9401323e63278a7053c54565e8d688f6cbe34f54 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sun, 11 Nov 2001 15:01:52 +0000 Subject: [PATCH 130/281] * Documentation work. --- doc/maint/ChangeLog | 10 + doc/maint/docstring.el | 35 +- doc/maint/guile.texi | 5412 ++++++++++++++++++----------------- doc/ref/ChangeLog | 58 + doc/ref/Makefile.am | 4 +- doc/ref/appendices.texi | 0 doc/ref/debugging.texi | 179 ++ doc/ref/guile.texi | 115 +- doc/ref/indices.texi | 4 +- doc/ref/intro.texi | 113 +- doc/ref/new-docstrings.texi | 69 + doc/ref/posix.texi | 39 +- doc/ref/preface.texi | 87 +- doc/ref/program.texi | 199 ++ doc/ref/scheme-binding.texi | 2 +- doc/ref/scheme-control.texi | 138 + doc/ref/scheme-data.texi | 70 +- doc/ref/scheme-debug.texi | 4 +- doc/ref/scheme-indices.texi | 4 +- doc/ref/scheme-io.texi | 234 +- doc/ref/scheme-memory.texi | 2 +- doc/ref/scheme-options.texi | 4 +- doc/ref/scm.texi | 355 --- libguile/ChangeLog | 25 + libguile/dynwind.c | 4 +- libguile/extensions.c | 64 +- libguile/filesys.c | 7 +- libguile/guardians.c | 2 +- libguile/hashtab.c | 2 +- libguile/modules.c | 2 +- libguile/ports.c | 6 +- libguile/posix.c | 2 +- libguile/random.c | 14 +- libguile/scmsigs.c | 8 +- libguile/strings.c | 2 +- libguile/strop.c | 2 +- libguile/struct.c | 4 +- libguile/unif.c | 2 +- libguile/variable.c | 10 +- srfi/ChangeLog | 6 + srfi/srfi-13.c | 4 +- srfi/srfi-14.c | 8 +- 42 files changed, 3992 insertions(+), 3319 deletions(-) delete mode 100644 doc/ref/appendices.texi create mode 100644 doc/ref/debugging.texi create mode 100644 doc/ref/program.texi diff --git a/doc/maint/ChangeLog b/doc/maint/ChangeLog index 0572b38f3..44731b76b 100644 --- a/doc/maint/ChangeLog +++ b/doc/maint/ChangeLog @@ -1,3 +1,13 @@ +2001-11-07 Neil Jerram + + * guile.texi: Replaced by libguile version (after automatically + updating docstrings in the reference manual). + + * docstring.el (docstring-manual-directory): Added "/ref" to end. + (docstring-manual-files): Now calculated automatically, since by + definition all the .texi files in doc/ref are reference manual + files. + 2001-04-03 Martin Grabmueller * guile.texi: Automated docstring merging. diff --git a/doc/maint/docstring.el b/doc/maint/docstring.el index b346b96bd..731c62e90 100644 --- a/doc/maint/docstring.el +++ b/doc/maint/docstring.el @@ -57,7 +57,7 @@ ;;; Code: -(defvar docstring-manual-directory (expand-file-name "~/Guile/cvs/guile-core/doc") +(defvar docstring-manual-directory (expand-file-name "~/Guile/cvs/guile-core/doc/ref") "*The directory containing the Texinfo source for the Guile reference manual.") (defvar docstring-tracking-root (expand-file-name "~/Guile/cvs/guile-core/doc/maint") @@ -72,37 +72,8 @@ for module (a b c) is expected to be in the file For each entry in this list, the snarfed docstring file for module (a b c) is looked for in the file /a/b/c.texi.") -(defvar docstring-manual-files '("appendices.texi" - "deprecated.texi" - "expect.texi" - "gh.texi" - "goops.texi" - "guile.texi" - "indices.texi" - "intro.texi" - "posix.texi" - "scheme-binding.texi" - "scheme-control.texi" - "scheme-data.texi" - "scheme-debug.texi" - "scheme-evaluation.texi" - "scheme-ideas.texi" - "scheme-indices.texi" - "scheme-intro.texi" - "scheme-io.texi" - "scheme-memory.texi" - "scheme-modules.texi" - "scheme-options.texi" - "scheme-procedures.texi" - "scheme-reading.texi" - "scheme-scheduling.texi" - "scheme-translation.texi" - "scheme-utility.texi" - "scm.texi" - "scripts.texi" - "scsh.texi" - "slib.texi" - "tcltk.texi") +(defvar docstring-manual-files + (directory-files docstring-manual-directory nil "\\.texi$" t) "List of Texinfo source files that comprise the Guile reference manual.") (defvar docstring-new-docstrings-file "new-docstrings.texi" diff --git a/doc/maint/guile.texi b/doc/maint/guile.texi index 622fbba08..8b6b5efe5 100644 --- a/doc/maint/guile.texi +++ b/doc/maint/guile.texi @@ -1,7 +1,7 @@ @paragraphindent 0 acons -@c snarfed from alist.c:60 +@c snarfed from alist.c:58 @deffn primitive acons key value alist Adds a new key-value pair to @var{alist}. A new pair is created whose car is @var{key} and whose cdr is @var{value}, and the @@ -10,28 +10,28 @@ function is @emph{not} destructive; @var{alist} is not modified. @end deffn sloppy-assq -@c snarfed from alist.c:83 +@c snarfed from alist.c:81 @deffn primitive sloppy-assq key alist Behaves like @code{assq} but does not do any error checking. Recommended only for use in Guile internals. @end deffn sloppy-assv -@c snarfed from alist.c:101 +@c snarfed from alist.c:99 @deffn primitive sloppy-assv key alist Behaves like @code{assv} but does not do any error checking. Recommended only for use in Guile internals. @end deffn sloppy-assoc -@c snarfed from alist.c:119 +@c snarfed from alist.c:117 @deffn primitive sloppy-assoc key alist Behaves like @code{assoc} but does not do any error checking. Recommended only for use in Guile internals. @end deffn assq -@c snarfed from alist.c:146 +@c snarfed from alist.c:144 @deffn primitive assq key alist @deffnx primitive assv key alist @deffnx primitive assoc key alist @@ -45,19 +45,19 @@ return the entire alist entry found (i.e. both the key and the value). @end deffn assv -@c snarfed from alist.c:167 +@c snarfed from alist.c:165 @deffn primitive assv key alist Behaves like @code{assq} but uses @code{eqv?} for key comparison. @end deffn assoc -@c snarfed from alist.c:188 +@c snarfed from alist.c:186 @deffn primitive assoc key alist Behaves like @code{assq} but uses @code{equal?} for key comparison. @end deffn assq-ref -@c snarfed from alist.c:232 +@c snarfed from alist.c:230 @deffn primitive assq-ref alist key @deffnx primitive assv-ref alist key @deffnx primitive assoc-ref alist key @@ -74,19 +74,19 @@ where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}. @end deffn assv-ref -@c snarfed from alist.c:249 +@c snarfed from alist.c:247 @deffn primitive assv-ref alist key Behaves like @code{assq-ref} but uses @code{eqv?} for key comparison. @end deffn assoc-ref -@c snarfed from alist.c:266 +@c snarfed from alist.c:264 @deffn primitive assoc-ref alist key Behaves like @code{assq-ref} but uses @code{equal?} for key comparison. @end deffn assq-set! -@c snarfed from alist.c:295 +@c snarfed from alist.c:293 @deffn primitive assq-set! alist key val @deffnx primitive assv-set! alist key value @deffnx primitive assoc-set! alist key value @@ -101,19 +101,19 @@ association list. @end deffn assv-set! -@c snarfed from alist.c:313 +@c snarfed from alist.c:311 @deffn primitive assv-set! alist key val Behaves like @code{assq-set!} but uses @code{eqv?} for key comparison. @end deffn assoc-set! -@c snarfed from alist.c:331 +@c snarfed from alist.c:329 @deffn primitive assoc-set! alist key val Behaves like @code{assq-set!} but uses @code{equal?} for key comparison. @end deffn assq-remove! -@c snarfed from alist.c:355 +@c snarfed from alist.c:353 @deffn primitive assq-remove! alist key @deffnx primitive assv-remove! alist key @deffnx primitive assoc-remove! alist key @@ -122,19 +122,19 @@ the resulting alist. @end deffn assv-remove! -@c snarfed from alist.c:371 +@c snarfed from alist.c:369 @deffn primitive assv-remove! alist key Behaves like @code{assq-remove!} but uses @code{eqv?} for key comparison. @end deffn assoc-remove! -@c snarfed from alist.c:387 +@c snarfed from alist.c:385 @deffn primitive assoc-remove! alist key Behaves like @code{assq-remove!} but uses @code{equal?} for key comparison. @end deffn make-arbiter -@c snarfed from arbiters.c:84 +@c snarfed from arbiters.c:82 @deffn primitive make-arbiter name Return an object of type arbiter and name @var{name}. Its state is initially unlocked. Arbiters are a way to achieve @@ -142,71 +142,71 @@ process synchronization. @end deffn try-arbiter -@c snarfed from arbiters.c:94 +@c snarfed from arbiters.c:92 @deffn primitive try-arbiter arb Return @code{#t} and lock the arbiter @var{arb} if the arbiter was unlocked. Otherwise, return @code{#f}. @end deffn release-arbiter -@c snarfed from arbiters.c:115 +@c snarfed from arbiters.c:113 @deffn primitive release-arbiter arb Return @code{#t} and unlock the arbiter @var{arb} if the arbiter was locked. Otherwise, return @code{#f}. @end deffn async -@c snarfed from async.c:290 +@c snarfed from async.c:288 @deffn primitive async thunk Create a new async for the procedure @var{thunk}. @end deffn system-async -@c snarfed from async.c:300 +@c snarfed from async.c:298 @deffn primitive system-async thunk Create a new async for the procedure @var{thunk}. Also add it to the system's list of active async objects. @end deffn async-mark -@c snarfed from async.c:311 +@c snarfed from async.c:309 @deffn primitive async-mark a Mark the async @var{a} for future execution. @end deffn system-async-mark -@c snarfed from async.c:327 +@c snarfed from async.c:325 @deffn primitive system-async-mark a Mark the async @var{a} for future execution. @end deffn run-asyncs -@c snarfed from async.c:347 +@c snarfed from async.c:345 @deffn primitive run-asyncs list_of_a Execute all thunks from the asyncs of the list @var{list_of_a}. @end deffn noop -@c snarfed from async.c:381 +@c snarfed from async.c:379 @deffn primitive noop . args Do nothing. When called without arguments, return @code{#f}, otherwise return the first argument. @end deffn unmask-signals -@c snarfed from async.c:433 +@c snarfed from async.c:431 @deffn primitive unmask-signals Unmask signals. The returned value is not specified. @end deffn mask-signals -@c snarfed from async.c:444 +@c snarfed from async.c:442 @deffn primitive mask-signals Mask signals. The returned value is not specified. @end deffn display-error -@c snarfed from backtrace.c:262 +@c snarfed from backtrace.c:265 @deffn primitive display-error stack port subr message args rest Display an error message to the output port @var{port}. @var{stack} is the saved stack for the error, @var{subr} is @@ -218,7 +218,7 @@ ignored. @end deffn display-application -@c snarfed from backtrace.c:399 +@c snarfed from backtrace.c:402 @deffn primitive display-application frame [port [indent]] Display a procedure application @var{frame} to the output port @var{port}. @var{indent} specifies the indentation of the @@ -226,7 +226,7 @@ output. @end deffn display-backtrace -@c snarfed from backtrace.c:619 +@c snarfed from backtrace.c:713 @deffn primitive display-backtrace stack port [first [depth]] Display a backtrace to the output port @var{port}. @var{stack} is the stack to take the backtrace from, @var{first} specifies @@ -236,136 +236,136 @@ which means that default values will be used. @end deffn backtrace -@c snarfed from backtrace.c:642 +@c snarfed from backtrace.c:736 @deffn primitive backtrace Display a backtrace of the stack saved by the last error to the current output port. @end deffn not -@c snarfed from boolean.c:56 +@c snarfed from boolean.c:54 @deffn primitive not x Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}. @end deffn boolean? -@c snarfed from boolean.c:66 +@c snarfed from boolean.c:64 @deffn primitive boolean? obj Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}. @end deffn char? -@c snarfed from chars.c:56 +@c snarfed from chars.c:54 @deffn primitive char? x Return @code{#t} iff @var{x} is a character, else @code{#f}. @end deffn char=? -@c snarfed from chars.c:65 +@c snarfed from chars.c:63 @deffn primitive char=? x y Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}. @end deffn char? -@c snarfed from chars.c:102 +@c snarfed from chars.c:100 @deffn primitive char>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence, else @code{#f}. @end deffn char>=? -@c snarfed from chars.c:114 +@c snarfed from chars.c:112 @deffn primitive char>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence, else @code{#f}. @end deffn char-ci=? -@c snarfed from chars.c:126 +@c snarfed from chars.c:124 @deffn primitive char-ci=? x y Return @code{#t} iff @var{x} is the same character as @var{y} ignoring case, else @code{#f}. @end deffn char-ci? -@c snarfed from chars.c:162 +@c snarfed from chars.c:160 @deffn primitive char-ci>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn char-ci>=? -@c snarfed from chars.c:174 +@c snarfed from chars.c:172 @deffn primitive char-ci>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn char-alphabetic? -@c snarfed from chars.c:187 +@c snarfed from chars.c:185 @deffn primitive char-alphabetic? chr Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}. Alphabetic means the same thing as the isalpha C library function. @end deffn char-numeric? -@c snarfed from chars.c:198 +@c snarfed from chars.c:196 @deffn primitive char-numeric? chr Return @code{#t} iff @var{chr} is numeric, else @code{#f}. Numeric means the same thing as the isdigit C library function. @end deffn char-whitespace? -@c snarfed from chars.c:209 +@c snarfed from chars.c:207 @deffn primitive char-whitespace? chr Return @code{#t} iff @var{chr} is whitespace, else @code{#f}. Whitespace means the same thing as the isspace C library function. @end deffn char-upper-case? -@c snarfed from chars.c:222 +@c snarfed from chars.c:220 @deffn primitive char-upper-case? chr Return @code{#t} iff @var{chr} is uppercase, else @code{#f}. Uppercase means the same thing as the isupper C library function. @end deffn char-lower-case? -@c snarfed from chars.c:234 +@c snarfed from chars.c:232 @deffn primitive char-lower-case? chr Return @code{#t} iff @var{chr} is lowercase, else @code{#f}. Lowercase means the same thing as the islower C library function. @end deffn char-is-both? -@c snarfed from chars.c:248 +@c snarfed from chars.c:246 @deffn primitive char-is-both? chr Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}. Uppercase and lowercase are as defined by the isupper and islower @@ -373,32 +373,32 @@ C library functions. @end deffn char->integer -@c snarfed from chars.c:262 +@c snarfed from chars.c:260 @deffn primitive char->integer chr Return the number corresponding to ordinal position of @var{chr} in the ASCII sequence. @end deffn integer->char -@c snarfed from chars.c:274 +@c snarfed from chars.c:272 @deffn primitive integer->char n Return the character at position @var{n} in the ASCII sequence. @end deffn char-upcase -@c snarfed from chars.c:285 +@c snarfed from chars.c:283 @deffn primitive char-upcase chr Return the uppercase character version of @var{chr}. @end deffn char-downcase -@c snarfed from chars.c:296 +@c snarfed from chars.c:294 @deffn primitive char-downcase chr Return the lowercase character version of @var{chr}. @end deffn debug-options-interface -@c snarfed from debug.c:80 +@c snarfed from debug.c:79 @deffn primitive debug-options-interface [setting] Option interface for the debug options. Instead of using this procedure directly, use the procedures @code{debug-enable}, @@ -406,49 +406,49 @@ this procedure directly, use the procedures @code{debug-enable}, @end deffn with-traps -@c snarfed from debug.c:128 +@c snarfed from debug.c:127 @deffn primitive with-traps thunk Call @var{thunk} with traps enabled. @end deffn memoized? -@c snarfed from debug.c:170 +@c snarfed from debug.c:169 @deffn primitive memoized? obj Return @code{#t} if @var{obj} is memoized. @end deffn unmemoize -@c snarfed from debug.c:376 +@c snarfed from debug.c:333 @deffn primitive unmemoize m Unmemoize the memoized expression @var{m}, @end deffn memoized-environment -@c snarfed from debug.c:386 +@c snarfed from debug.c:343 @deffn primitive memoized-environment m Return the environment of the memoized expression @var{m}. @end deffn procedure-name -@c snarfed from debug.c:396 +@c snarfed from debug.c:353 @deffn primitive procedure-name proc Return the name of the procedure @var{proc} @end deffn procedure-source -@c snarfed from debug.c:422 +@c snarfed from debug.c:379 @deffn primitive procedure-source proc Return the source of the procedure @var{proc}. @end deffn procedure-environment -@c snarfed from debug.c:455 +@c snarfed from debug.c:412 @deffn primitive procedure-environment proc Return the environment of the procedure @var{proc}. @end deffn local-eval -@c snarfed from debug.c:487 +@c snarfed from debug.c:444 @deffn primitive local-eval exp [env] Evaluate @var{exp} in its environment. If @var{env} is supplied, it is the environment in which to evaluate @var{exp}. Otherwise, @@ -457,50 +457,13 @@ is implicit). @end deffn debug-object? -@c snarfed from debug.c:574 +@c snarfed from debug.c:531 @deffn primitive debug-object? obj Return @code{#t} if @var{obj} is a debug object. @end deffn - issue-deprecation-warning -@c snarfed from deprecation.c:78 -@deffn primitive issue-deprecation-warning . msgs -Output @var{msgs} to @code{(current-error-port)} when this -is the first call to @code{issue-deprecation-warning} with -this specific @var{msg}. Do nothing otherwise. -The argument @var{msgs} should be a list of strings; -they are printed in turn, each one followed by a newline. -@end deffn - - include-deprecated-features -@c snarfed from deprecation.c:120 -@deffn primitive include-deprecated-features -Return @code{#t} iff deprecated features should be included -in public interfaces. -@end deffn - - c-registered-modules -@c snarfed from dynl.c:183 -@deffn primitive c-registered-modules -Return a list of the object code modules that have been imported into -the current Guile process. Each element of the list is a pair whose -car is the name of the module, and whose cdr is the function handle -for that module's initializer function. The name is the string that -has been passed to scm_register_module_xxx. -@end deffn - - c-clear-registered-modules -@c snarfed from dynl.c:204 -@deffn primitive c-clear-registered-modules -Destroy the list of modules registered with the current Guile process. -The return value is unspecified. @strong{Warning:} this function does -not actually unlink or deallocate these modules, but only destroys the -records of which modules have been loaded. It should therefore be used -only by module bookkeeping operations. -@end deffn - dynamic-link -@c snarfed from dynl.c:357 +@c snarfed from dynl.c:264 @deffn primitive dynamic-link filename Open the dynamic library called @var{filename}. A library handle representing the opened library is returned; this handle @@ -509,14 +472,14 @@ functions. @end deffn dynamic-object? -@c snarfed from dynl.c:373 +@c snarfed from dynl.c:279 @deffn primitive dynamic-object? obj Return @code{#t} if @var{obj} is a dynamic library handle, or @code{#f} otherwise. @end deffn dynamic-unlink -@c snarfed from dynl.c:386 +@c snarfed from dynl.c:292 @deffn primitive dynamic-unlink dobj Unlink the indicated object file from the application. The argument @var{dobj} must have been obtained by a call to @@ -525,7 +488,7 @@ called on @var{dobj}, its content is no longer accessible. @end deffn dynamic-func -@c snarfed from dynl.c:413 +@c snarfed from dynl.c:319 @deffn primitive dynamic-func name dobj Search the dynamic object @var{dobj} for the C function indicated by the string @var{name} and return some Scheme @@ -539,7 +502,7 @@ needed or not and will add it when necessary. @end deffn dynamic-call -@c snarfed from dynl.c:453 +@c snarfed from dynl.c:358 @deffn primitive dynamic-call func dobj Call the C function indicated by @var{func} and @var{dobj}. The function is passed no arguments and its return value is @@ -556,7 +519,7 @@ Interrupts are deferred while the C function is executing (with @end deffn dynamic-args-call -@c snarfed from dynl.c:481 +@c snarfed from dynl.c:386 @deffn primitive dynamic-args-call func dobj args Call the C function indicated by @var{func} and @var{dobj}, just like @code{dynamic-call}, but pass it some arguments and @@ -574,7 +537,7 @@ converted to a Scheme number and returned from the call to @end deffn dynamic-wind -@c snarfed from dynwind.c:121 +@c snarfed from dynwind.c:119 @deffn primitive dynamic-wind in_guard thunk out_guard All three arguments must be 0-argument procedures. @var{in_guard} is called, then @var{thunk}, then @@ -841,7 +804,7 @@ Change @var{env}'s imported environment to @var{imported}. @end deffn make-import-environment -@c snarfed from environments.c:1846 +@c snarfed from environments.c:1850 @deffn primitive make-import-environment imports conflict_proc Return a new environment @var{imp} whose bindings are the union of the bindings from the environments in @var{imports}; @@ -871,28 +834,28 @@ if one of its imported environments changes. @end deffn import-environment? -@c snarfed from environments.c:1875 +@c snarfed from environments.c:1879 @deffn primitive import-environment? object Return @code{#t} if object is an import environment, or @code{#f} otherwise. @end deffn import-environment-imports -@c snarfed from environments.c:1886 +@c snarfed from environments.c:1890 @deffn primitive import-environment-imports env Return the list of environments imported by the import environment @var{env}. @end deffn import-environment-set-imports! -@c snarfed from environments.c:1899 +@c snarfed from environments.c:1903 @deffn primitive import-environment-set-imports! env imports Change @var{env}'s list of imported environments to @var{imports}, and check for conflicts. @end deffn make-export-environment -@c snarfed from environments.c:2164 +@c snarfed from environments.c:2171 @deffn primitive make-export-environment private signature Return a new environment @var{exp} containing only those bindings in private whose symbols are present in @@ -941,38 +904,38 @@ if the bindings in private change. @end deffn export-environment? -@c snarfed from environments.c:2199 +@c snarfed from environments.c:2206 @deffn primitive export-environment? object Return @code{#t} if object is an export environment, or @code{#f} otherwise. @end deffn export-environment-private -@c snarfed from environments.c:2209 +@c snarfed from environments.c:2216 @deffn primitive export-environment-private env Return the private environment of export environment @var{env}. @end deffn export-environment-set-private! -@c snarfed from environments.c:2221 +@c snarfed from environments.c:2228 @deffn primitive export-environment-set-private! env private Change the private environment of export environment @var{env}. @end deffn export-environment-signature -@c snarfed from environments.c:2243 +@c snarfed from environments.c:2250 @deffn primitive export-environment-signature env Return the signature of export environment @var{env}. @end deffn export-environment-set-signature! -@c snarfed from environments.c:2317 +@c snarfed from environments.c:2324 @deffn primitive export-environment-set-signature! env signature Change the signature of export environment @var{env}. @end deffn eq? -@c snarfed from eq.c:64 +@c snarfed from eq.c:62 @deffn primitive eq? x y Return @code{#t} iff @var{x} references the same object as @var{y}. @code{eq?} is similar to @code{eqv?} except that in some cases it is @@ -981,7 +944,7 @@ capable of discerning distinctions finer than those detectable by @end deffn eqv? -@c snarfed from eq.c:78 +@c snarfed from eq.c:76 @deffn primitive eqv? x y The @code{eqv?} procedure defines a useful equivalence relation on objects. Briefly, it returns @code{#t} if @var{x} and @var{y} should normally be @@ -991,7 +954,7 @@ and inexact numbers. @end deffn equal? -@c snarfed from eq.c:127 +@c snarfed from eq.c:125 @deffn primitive equal? x y Return @code{#t} iff @var{x} and @var{y} are recursively @code{eqv?} equivalent. @code{equal?} recursively compares the contents of pairs, @@ -1002,7 +965,7 @@ terminate if its arguments are circular data structures. @end deffn scm-error -@c snarfed from error.c:114 +@c snarfed from error.c:117 @deffn primitive scm-error key subr message args data Raise an error with key @var{key}. @var{subr} can be a string naming the procedure associated with the error, or @code{#f}. @@ -1020,14 +983,14 @@ it will usually be @code{#f}. @end deffn strerror -@c snarfed from error.c:156 +@c snarfed from error.c:157 @deffn primitive strerror err Return the Unix error message corresponding to @var{err}, which must be an integer value. @end deffn apply:nconc2last -@c snarfed from eval.c:3256 +@c snarfed from eval.c:3326 @deffn primitive apply:nconc2last lst Given a list (@var{arg1} @dots{} @var{args}), this function conses the @var{arg1} @dots{} arguments onto the front of @@ -1039,7 +1002,7 @@ destroys its argument, so use with care. @end deffn force -@c snarfed from eval.c:3789 +@c snarfed from eval.c:3861 @deffn primitive force x If the promise @var{x} has not been computed yet, compute and return @var{x}, otherwise just return the previously computed @@ -1047,14 +1010,14 @@ value. @end deffn promise? -@c snarfed from eval.c:3812 +@c snarfed from eval.c:3884 @deffn primitive promise? obj Return true if @var{obj} is a promise, i.e. a delayed computation -(@pxref{Delayed evaluation,,,r4rs.info,The Revised^4 Report on Scheme}). +(@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). @end deffn cons-source -@c snarfed from eval.c:3824 +@c snarfed from eval.c:3896 @deffn primitive cons-source xorig x y Create and return a new pair whose car and cdr are @var{x} and @var{y}. Any source properties associated with @var{xorig} are also associated @@ -1062,7 +1025,7 @@ with the new pair. @end deffn copy-tree -@c snarfed from eval.c:3846 +@c snarfed from eval.c:3918 @deffn primitive copy-tree obj Recursively copy the data tree that is bound to @var{obj}, and return a pointer to the new data structure. @code{copy-tree} recurses down the @@ -1072,14 +1035,14 @@ any other object. @end deffn primitive-eval -@c snarfed from eval.c:3938 +@c snarfed from eval.c:4011 @deffn primitive primitive-eval exp Evaluate @var{exp} in the top-level environment specified by the current module. @end deffn eval -@c snarfed from eval.c:4007 +@c snarfed from eval.c:4080 @deffn primitive eval exp module Evaluate @var{exp}, a list representing a Scheme expression, in the top-level environment specified by @var{module}. @@ -1088,18 +1051,8 @@ While @var{exp} is evaluated (using @var{primitive-eval}), is reset to its previous value when @var{eval} returns. @end deffn - eval2 -@c snarfed from eval.c:4051 -@deffn primitive eval2 obj env_thunk -Evaluate @var{exp}, a Scheme expression, in the environment -designated by @var{lookup}, a symbol-lookup function. -Do not use this version of eval, it does not play well -with the module system. Use @code{eval} or -@code{primitive-eval} instead. -@end deffn - eval-options-interface -@c snarfed from eval.c:1697 +@c snarfed from eval.c:1747 @deffn primitive eval-options-interface [setting] Option interface for the evaluation options. Instead of using this procedure directly, use the procedures @code{eval-enable}, @@ -1107,25 +1060,64 @@ this procedure directly, use the procedures @code{eval-enable}, @end deffn evaluator-traps-interface -@c snarfed from eval.c:1714 +@c snarfed from eval.c:1764 @deffn primitive evaluator-traps-interface [setting] Option interface for the evaluator trap options. @end deffn defined? -@c snarfed from evalext.c:74 +@c snarfed from evalext.c:75 @deffn primitive defined? sym [env] -Return @code{#t} if @var{sym} is defined in the top-level environment. +Return @code{#t} if @var{sym} is defined in the lexical environment @var{env}. When @var{env} is not specified, look in the top-level environment as defined by the current module. @end deffn map-in-order -@c snarfed from evalext.c:146 +@c snarfed from evalext.c:144 @deffn primitive map-in-order -scm_map +implemented by the C function "scm_map" +@end deffn + + load-extension +@c snarfed from extensions.c:153 +@deffn primitive load-extension lib init +Load and initilize the extension designated by LIB and INIT. +When there is no pre-registered function for LIB/INIT, this is +equivalent to + +@lisp +(dynamic-call INIT (dynamic-link LIB)) +@end lisp + +When there is a pre-registered function, that function is called +instead. + +Normally, there is no pre-registered function. This option exists +only for situations where dynamic linking is unavailable or unwanted. +In that case, you would statically link your program with the desired +library, and register its init function right after Guile has been +initialized. + +LIB should be a string denoting a shared library without any file type +suffix such as ".so". The suffix is provided automatically. It +should also not contain any directory components. Libraries that +implement Guile Extensions should be put into the normal locations for +shared libraries. We recommend to use the naming convention +libguile-bla-blum for a extension related to a module `(bla blum)'. + +The normal way for a extension to be used is to write a small Scheme +file that defines a module, and to load the extension into this +module. When the module is auto-loaded, the extension is loaded as +well. For example, + +@lisp +(define-module (bla blum)) + +(load-extension "libguile-bla-blum" "bla_init_blum") +@end lisp @end deffn program-arguments -@c snarfed from feature.c:79 +@c snarfed from feature.c:77 @deffn primitive program-arguments @deffnx procedure command-line Return the list of command line arguments passed to Guile, as a list of @@ -1134,373 +1126,8 @@ strings. The list includes the invoked program name, which is usually options like @code{-e} and @code{-l}. @end deffn - chown -@c snarfed from filesys.c:140 -@deffn primitive chown object owner group -Change the ownership and group of the file referred to by @var{object} to -the integer values @var{owner} and @var{group}. @var{object} can be -a string containing a file name or, if the platform -supports fchown, a port or integer file descriptor -which is open on the file. The return value -is unspecified. - -If @var{object} is a symbolic link, either the -ownership of the link or the ownership of the referenced file will be -changed depending on the operating system (lchown is -unsupported at present). If @var{owner} or @var{group} is specified -as @code{-1}, then that ID is not changed. -@end deffn - - chmod -@c snarfed from filesys.c:180 -@deffn primitive chmod object mode -Changes the permissions of the file referred to by @var{obj}. -@var{obj} can be a string containing a file name or a port or integer file -descriptor which is open on a file (in which case @code{fchmod} is used -as the underlying system call). -@var{mode} specifies -the new permissions as a decimal number, e.g., @code{(chmod "foo" #o755)}. -The return value is unspecified. -@end deffn - - umask -@c snarfed from filesys.c:214 -@deffn primitive umask [mode] -If @var{mode} is omitted, retuns a decimal number representing the current -file creation mask. Otherwise the file creation mask is set to -@var{mode} and the previous value is returned. - -E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18. -@end deffn - - open-fdes -@c snarfed from filesys.c:237 -@deffn primitive open-fdes path flags [mode] -Similar to @code{open} but return a file descriptor instead of -a port. -@end deffn - - open -@c snarfed from filesys.c:280 -@deffn primitive open path flags [mode] -Open the file named by @var{path} for reading and/or writing. -@var{flags} is an integer specifying how the file should be opened. -@var{mode} is an integer specifying the permission bits of the file, if -it needs to be created, before the umask is applied. The default is 666 -(Unix itself has no default). - -@var{flags} can be constructed by combining variables using @code{logior}. -Basic flags are: - -@defvar O_RDONLY -Open the file read-only. -@end defvar -@defvar O_WRONLY -Open the file write-only. -@end defvar -@defvar O_RDWR -Open the file read/write. -@end defvar -@defvar O_APPEND -Append to the file instead of truncating. -@end defvar -@defvar O_CREAT -Create the file if it does not already exist. -@end defvar - -See the Unix documentation of the @code{open} system call -for additional flags. -@end deffn - - close -@c snarfed from filesys.c:318 -@deffn primitive close fd_or_port -Similar to close-port (@pxref{Generic Port Operations, close-port}), -but also works on file descriptors. A side -effect of closing a file descriptor is that any ports using that file -descriptor are moved to a different file descriptor and have -their revealed counts set to zero. -@end deffn - - close-fdes -@c snarfed from filesys.c:346 -@deffn primitive close-fdes fd -A simple wrapper for the @code{close} system call. -Close file descriptor @var{fd}, which must be an integer. -Unlike close (@pxref{Ports and File Descriptors, close}), -the file descriptor will be closed even if a port is using it. -The return value is unspecified. -@end deffn - - stat -@c snarfed from filesys.c:524 -@deffn primitive stat object -Return an object containing various information about the file -determined by @var{obj}. @var{obj} can be a string containing -a file name or a port or integer file descriptor which is open -on a file (in which case @code{fstat} is used as the underlying -system call). - -The object returned by @code{stat} can be passed as a single -parameter to the following procedures, all of which return -integers: - -@table @code -@item stat:dev -The device containing the file. -@item stat:ino -The file serial number, which distinguishes this file from all -other files on the same device. -@item stat:mode -The mode of the file. This includes file type information and -the file permission bits. See @code{stat:type} and -@code{stat:perms} below. -@item stat:nlink -The number of hard links to the file. -@item stat:uid -The user ID of the file's owner. -@item stat:gid -The group ID of the file. -@item stat:rdev -Device ID; this entry is defined only for character or block -special files. -@item stat:size -The size of a regular file in bytes. -@item stat:atime -The last access time for the file. -@item stat:mtime -The last modification time for the file. -@item stat:ctime -The last modification time for the attributes of the file. -@item stat:blksize -The optimal block size for reading or writing the file, in -bytes. -@item stat:blocks -The amount of disk space that the file occupies measured in -units of 512 byte blocks. -@end table - -In addition, the following procedures return the information -from stat:mode in a more convenient form: - -@table @code -@item stat:type -A symbol representing the type of file. Possible values are -regular, directory, symlink, block-special, char-special, fifo, -socket and unknown -@item stat:perms -An integer representing the access permission bits. -@end table -@end deffn - - link -@c snarfed from filesys.c:570 -@deffn primitive link oldpath newpath -Creates a new name @var{newpath} in the file system for the -file named by @var{oldpath}. If @var{oldpath} is a symbolic -link, the link may or may not be followed depending on the -system. -@end deffn - - rename-file -@c snarfed from filesys.c:592 -@deffn primitive rename-file oldname newname -Renames the file specified by @var{oldname} to @var{newname}. -The return value is unspecified. -@end deffn - - delete-file -@c snarfed from filesys.c:621 -@deffn primitive delete-file str -Deletes (or "unlinks") the file specified by @var{path}. -@end deffn - - mkdir -@c snarfed from filesys.c:640 -@deffn primitive mkdir path [mode] -Create a new directory named by @var{path}. If @var{mode} is omitted -then the permissions of the directory file are set using the current -umask. Otherwise they are set to the decimal value specified with -@var{mode}. The return value is unspecified. -@end deffn - - rmdir -@c snarfed from filesys.c:669 -@deffn primitive rmdir path -Remove the existing directory named by @var{path}. The directory must -be empty for this to succeed. The return value is unspecified. -@end deffn - - directory-stream? -@c snarfed from filesys.c:695 -@deffn primitive directory-stream? obj -Return a boolean indicating whether @var{object} is a directory -stream as returned by @code{opendir}. -@end deffn - - opendir -@c snarfed from filesys.c:706 -@deffn primitive opendir dirname -Open the directory specified by @var{path} and return a directory -stream. -@end deffn - - readdir -@c snarfed from filesys.c:724 -@deffn primitive readdir port -Return (as a string) the next directory entry from the directory stream -@var{stream}. If there is no remaining entry to be read then the -end of file object is returned. -@end deffn - - rewinddir -@c snarfed from filesys.c:747 -@deffn primitive rewinddir port -Reset the directory port @var{stream} so that the next call to -@code{readdir} will return the first directory entry. -@end deffn - - closedir -@c snarfed from filesys.c:764 -@deffn primitive closedir port -Close the directory stream @var{stream}. -The return value is unspecified. -@end deffn - - chdir -@c snarfed from filesys.c:814 -@deffn primitive chdir str -Change the current working directory to @var{path}. -The return value is unspecified. -@end deffn - - getcwd -@c snarfed from filesys.c:831 -@deffn primitive getcwd -Return the name of the current working directory. -@end deffn - - select -@c snarfed from filesys.c:1028 -@deffn primitive select reads writes excepts [secs [usecs]] -This procedure has a variety of uses: waiting for the ability -to provide input, accept output, or the existance of -exceptional conditions on a collection of ports or file -descriptors, or waiting for a timeout to occur. -It also returns if interrupted by a signal. - -@var{reads}, @var{writes} and @var{excepts} can be lists or -vectors, with each member a port or a file descriptor. -The value returned is a list of three corresponding -lists or vectors containing only the members which meet the -specified requirement. The ability of port buffers to -provide input or accept output is taken into account. -Ordering of the input lists or vectors is not preserved. - -The optional arguments @var{secs} and @var{usecs} specify the -timeout. Either @var{secs} can be specified alone, as -either an integer or a real number, or both @var{secs} and -@var{usecs} can be specified as integers, in which case -@var{usecs} is an additional timeout expressed in -microseconds. If @var{secs} is omitted or is @code{#f} then -select will wait for as long as it takes for one of the other -conditions to be satisfied. - -The scsh version of @code{select} differs as follows: -Only vectors are accepted for the first three arguments. -The @var{usecs} argument is not supported. -Multiple values are returned instead of a list. -Duplicates in the input vectors appear only once in output. -An additional @code{select!} interface is provided. -@end deffn - - fcntl -@c snarfed from filesys.c:1173 -@deffn primitive fcntl object cmd [value] -Apply @var{command} to the specified file descriptor or the underlying -file descriptor of the specified port. @var{value} is an optional -integer argument. - -Values for @var{command} are: - -@table @code -@item F_DUPFD -Duplicate a file descriptor -@item F_GETFD -Get flags associated with the file descriptor. -@item F_SETFD -Set flags associated with the file descriptor to @var{value}. -@item F_GETFL -Get flags associated with the open file. -@item F_SETFL -Set flags associated with the open file to @var{value} -@item F_GETOWN -Get the process ID of a socket's owner, for @code{SIGIO} signals. -@item F_SETOWN -Set the process that owns a socket to @var{value}, for @code{SIGIO} signals. -@item FD_CLOEXEC -The value used to indicate the "close on exec" flag with @code{F_GETFL} or -@code{F_SETFL}. -@end table -@end deffn - - fsync -@c snarfed from filesys.c:1209 -@deffn primitive fsync object -Copies any unwritten data for the specified output file descriptor to disk. -If @var{port/fd} is a port, its buffer is flushed before the underlying -file descriptor is fsync'd. -The return value is unspecified. -@end deffn - - symlink -@c snarfed from filesys.c:1236 -@deffn primitive symlink oldpath newpath -Create a symbolic link named @var{path-to} with the value (i.e., pointing to) -@var{path-from}. The return value is unspecified. -@end deffn - - readlink -@c snarfed from filesys.c:1257 -@deffn primitive readlink path -Return the value of the symbolic link named by @var{path} (a -string), i.e., the file that the link points to. -@end deffn - - lstat -@c snarfed from filesys.c:1287 -@deffn primitive lstat str -Similar to @code{stat}, but does not follow symbolic links, i.e., -it will return information about a symbolic link itself, not the -file it points to. @var{path} must be a string. -@end deffn - - copy-file -@c snarfed from filesys.c:1312 -@deffn primitive copy-file oldfile newfile -Copy the file specified by @var{path-from} to @var{path-to}. -The return value is unspecified. -@end deffn - - dirname -@c snarfed from filesys.c:1359 -@deffn primitive dirname filename -Return the directory name component of the file name -@var{filename}. If @var{filename} does not contain a directory -component, @code{.} is returned. -@end deffn - - basename -@c snarfed from filesys.c:1392 -@deffn primitive basename filename [suffix] -Return the base name of the file name @var{filename}. The -base name is the file name without any directory components. -If @var{suffix} is privided, and is equal to the end of -@var{basename}, it is removed also. -@end deffn - make-fluid -@c snarfed from fluids.c:124 +@c snarfed from fluids.c:123 @deffn primitive make-fluid Return a newly created fluid. Fluids are objects of a certain type (a smob) that can hold one SCM @@ -1512,14 +1139,14 @@ in its own dynamic root, you can use fluids for thread local storage. @end deffn fluid? -@c snarfed from fluids.c:137 +@c snarfed from fluids.c:136 @deffn primitive fluid? obj Return @code{#t} iff @var{obj} is a fluid; otherwise, return @code{#f}. @end deffn fluid-ref -@c snarfed from fluids.c:148 +@c snarfed from fluids.c:147 @deffn primitive fluid-ref fluid Return the value associated with @var{fluid} in the current dynamic root. If @var{fluid} has not been set, then return @@ -1527,13 +1154,13 @@ dynamic root. If @var{fluid} has not been set, then return @end deffn fluid-set! -@c snarfed from fluids.c:165 +@c snarfed from fluids.c:163 @deffn primitive fluid-set! fluid value Set the value associated with @var{fluid} in the current dynamic root. @end deffn with-fluids* -@c snarfed from fluids.c:224 +@c snarfed from fluids.c:222 @deffn primitive with-fluids* fluids values thunk Set @var{fluids} to @var{values} temporary, and call @var{thunk}. @var{fluids} must be a list of fluids and @var{values} must be the same @@ -1542,7 +1169,7 @@ one after another. @var{thunk} must be a procedure with no argument. @end deffn setvbuf -@c snarfed from fports.c:148 +@c snarfed from fports.c:155 @deffn primitive setvbuf port mode [size] Set the buffering mode for @var{port}. @var{mode} can be: @table @code @@ -1557,13 +1184,13 @@ If @var{size} is omitted, a default size will be used. @end deffn file-port? -@c snarfed from fports.c:229 +@c snarfed from fports.c:237 @deffn primitive file-port? obj Determine whether @var{obj} is a port that is related to a file. @end deffn open-file -@c snarfed from fports.c:283 +@c snarfed from fports.c:291 @deffn primitive open-file filename mode Open the file whose name is @var{filename}, and return a port representing that file. The attributes of the port are @@ -1605,35 +1232,28 @@ requested, @code{open-file} throws an exception. @end deffn gc-stats -@c snarfed from gc.c:749 +@c snarfed from gc.c:796 @deffn primitive gc-stats Return an association list of statistics about Guile's current use of storage. @end deffn object-address -@c snarfed from gc.c:846 +@c snarfed from gc.c:893 @deffn primitive object-address obj Return an integer that for the lifetime of @var{obj} is uniquely returned by this function for @var{obj} @end deffn gc -@c snarfed from gc.c:857 +@c snarfed from gc.c:904 @deffn primitive gc Scans all of SCM objects and reclaims for further use those that are no longer accessible. @end deffn - unhash-name -@c snarfed from gc.c:2306 -@deffn primitive unhash-name name -Flushes the glocs for @var{name}, or all glocs if @var{name} -is @code{#t}. -@end deffn - %compute-slots -@c snarfed from goops.c:290 +@c snarfed from goops.c:291 @deffn primitive %compute-slots class Return a list consisting of the names of all slots belonging to class @var{class}, i. e. the slots of @var{class} and of all of @@ -1641,7 +1261,7 @@ its superclasses. @end deffn get-keyword -@c snarfed from goops.c:375 +@c snarfed from goops.c:376 @deffn primitive get-keyword key l default_value Determine an associated value for the keyword @var{key} from the list @var{l}. The list @var{l} has to consist of an even @@ -1652,276 +1272,292 @@ If @var{l} does not hold a value for @var{key}, the value @end deffn %initialize-object -@c snarfed from goops.c:398 +@c snarfed from goops.c:399 @deffn primitive %initialize-object obj initargs Initialize the object @var{obj} with the given arguments @var{initargs}. @end deffn %prep-layout! -@c snarfed from goops.c:479 +@c snarfed from goops.c:480 @deffn primitive %prep-layout! class + @end deffn %inherit-magic! -@c snarfed from goops.c:542 +@c snarfed from goops.c:557 @deffn primitive %inherit-magic! class dsupers + @end deffn instance? -@c snarfed from goops.c:783 +@c snarfed from goops.c:800 @deffn primitive instance? obj Return @code{#t} if @var{obj} is an instance. @end deffn class-name -@c snarfed from goops.c:798 +@c snarfed from goops.c:815 @deffn primitive class-name obj Return the class name of @var{obj}. @end deffn class-direct-supers -@c snarfed from goops.c:808 +@c snarfed from goops.c:825 @deffn primitive class-direct-supers obj Return the direct superclasses of the class @var{obj}. @end deffn class-direct-slots -@c snarfed from goops.c:818 +@c snarfed from goops.c:835 @deffn primitive class-direct-slots obj Return the direct slots of the class @var{obj}. @end deffn class-direct-subclasses -@c snarfed from goops.c:828 +@c snarfed from goops.c:845 @deffn primitive class-direct-subclasses obj Return the direct subclasses of the class @var{obj}. @end deffn class-direct-methods -@c snarfed from goops.c:838 +@c snarfed from goops.c:855 @deffn primitive class-direct-methods obj Return the direct methods of the class @var{obj} @end deffn class-precedence-list -@c snarfed from goops.c:848 +@c snarfed from goops.c:865 @deffn primitive class-precedence-list obj Return the class precedence list of the class @var{obj}. @end deffn class-slots -@c snarfed from goops.c:858 +@c snarfed from goops.c:875 @deffn primitive class-slots obj Return the slot list of the class @var{obj}. @end deffn class-environment -@c snarfed from goops.c:868 +@c snarfed from goops.c:885 @deffn primitive class-environment obj Return the environment of the class @var{obj}. @end deffn generic-function-name -@c snarfed from goops.c:879 +@c snarfed from goops.c:896 @deffn primitive generic-function-name obj Return the name of the generic function @var{obj}. @end deffn generic-function-methods -@c snarfed from goops.c:889 +@c snarfed from goops.c:906 @deffn primitive generic-function-methods obj Return the methods of the generic function @var{obj}. @end deffn method-generic-function -@c snarfed from goops.c:900 +@c snarfed from goops.c:917 @deffn primitive method-generic-function obj Return the generic function fot the method @var{obj}. @end deffn method-specializers -@c snarfed from goops.c:910 +@c snarfed from goops.c:927 @deffn primitive method-specializers obj Return specializers of the method @var{obj}. @end deffn method-procedure -@c snarfed from goops.c:920 +@c snarfed from goops.c:937 @deffn primitive method-procedure obj Return the procedure of the method @var{obj}. @end deffn accessor-method-slot-definition -@c snarfed from goops.c:930 +@c snarfed from goops.c:947 @deffn primitive accessor-method-slot-definition obj Return the slot definition of the accessor @var{obj}. @end deffn %tag-body -@c snarfed from goops.c:940 +@c snarfed from goops.c:957 @deffn primitive %tag-body body Internal GOOPS magic---don't use this function! @end deffn make-unbound -@c snarfed from goops.c:955 +@c snarfed from goops.c:972 @deffn primitive make-unbound Return the unbound value. @end deffn unbound? -@c snarfed from goops.c:964 +@c snarfed from goops.c:981 @deffn primitive unbound? obj Return @code{#t} if @var{obj} is unbound. @end deffn assert-bound -@c snarfed from goops.c:974 +@c snarfed from goops.c:991 @deffn primitive assert-bound value obj Return @var{value} if it is bound, and invoke the @var{slot-unbound} method of @var{obj} if it is not. @end deffn @@assert-bound-ref -@c snarfed from goops.c:986 +@c snarfed from goops.c:1003 @deffn primitive @@assert-bound-ref obj index Like @code{assert-bound}, but use @var{index} for accessing the value from @var{obj}. @end deffn %fast-slot-ref -@c snarfed from goops.c:998 +@c snarfed from goops.c:1015 @deffn primitive %fast-slot-ref obj index Return the slot value with index @var{index} from @var{obj}. @end deffn %fast-slot-set! -@c snarfed from goops.c:1015 +@c snarfed from goops.c:1033 @deffn primitive %fast-slot-set! obj index value Set the slot with index @var{index} in @var{obj} to @var{value}. @end deffn slot-ref-using-class -@c snarfed from goops.c:1143 +@c snarfed from goops.c:1163 @deffn primitive slot-ref-using-class class obj slot_name + @end deffn slot-set-using-class! -@c snarfed from goops.c:1162 +@c snarfed from goops.c:1182 @deffn primitive slot-set-using-class! class obj slot_name value + @end deffn slot-bound-using-class? -@c snarfed from goops.c:1176 +@c snarfed from goops.c:1196 @deffn primitive slot-bound-using-class? class obj slot_name + @end deffn slot-exists-using-class? -@c snarfed from goops.c:1191 +@c snarfed from goops.c:1211 @deffn primitive slot-exists-using-class? class obj slot_name + @end deffn slot-ref -@c snarfed from goops.c:1207 +@c snarfed from goops.c:1227 @deffn primitive slot-ref obj slot_name Return the value from @var{obj}'s slot with the name @var{slot_name}. @end deffn slot-set! -@c snarfed from goops.c:1224 +@c snarfed from goops.c:1244 @deffn primitive slot-set! obj slot_name value Set the slot named @var{slot_name} of @var{obj} to @var{value}. @end deffn slot-bound? -@c snarfed from goops.c:1241 +@c snarfed from goops.c:1261 @deffn primitive slot-bound? obj slot_name Return @code{#t} if the slot named @var{slot_name} of @var{obj} is bound. @end deffn slot-exists? -@c snarfed from goops.c:1259 +@c snarfed from goops.c:1279 @deffn primitive slot-exists? obj slot_name Return @code{#t} if @var{obj} has a slot named @var{slot_name}. @end deffn %allocate-instance -@c snarfed from goops.c:1302 +@c snarfed from goops.c:1323 @deffn primitive %allocate-instance class initargs Create a new instance of class @var{class} and initialize it from the arguments @var{initargs}. @end deffn %set-object-setter! -@c snarfed from goops.c:1375 +@c snarfed from goops.c:1396 @deffn primitive %set-object-setter! obj setter + @end deffn %modify-instance -@c snarfed from goops.c:1400 +@c snarfed from goops.c:1421 @deffn primitive %modify-instance old new + @end deffn %modify-class -@c snarfed from goops.c:1426 +@c snarfed from goops.c:1447 @deffn primitive %modify-class old new + @end deffn %invalidate-class -@c snarfed from goops.c:1450 +@c snarfed from goops.c:1471 @deffn primitive %invalidate-class class + @end deffn %invalidate-method-cache! -@c snarfed from goops.c:1571 +@c snarfed from goops.c:1598 @deffn primitive %invalidate-method-cache! gf + @end deffn generic-capability? -@c snarfed from goops.c:1597 +@c snarfed from goops.c:1624 @deffn primitive generic-capability? proc + @end deffn enable-primitive-generic! -@c snarfed from goops.c:1610 +@c snarfed from goops.c:1637 @deffn primitive enable-primitive-generic! . subrs + @end deffn primitive-generic-generic -@c snarfed from goops.c:1630 +@c snarfed from goops.c:1658 @deffn primitive primitive-generic-generic subr + @end deffn make -@c snarfed from goops.c:1989 +@c snarfed from goops.c:2019 @deffn primitive make . args Make a new object. @var{args} must contain the class and all necessary initialization information. @end deffn find-method -@c snarfed from goops.c:2082 +@c snarfed from goops.c:2112 @deffn primitive find-method . l + @end deffn %method-more-specific? -@c snarfed from goops.c:2102 +@c snarfed from goops.c:2132 @deffn primitive %method-more-specific? m1 m2 targs + @end deffn %goops-loaded -@c snarfed from goops.c:2634 +@c snarfed from goops.c:2660 @deffn primitive %goops-loaded Announce that GOOPS is loaded and perform initialization on the C level which depends on the loaded GOOPS modules. @end deffn make-guardian -@c snarfed from guardians.c:336 +@c snarfed from guardians.c:331 @deffn primitive make-guardian [greedy_p] Create a new guardian. A guardian protects a set of objects from garbage collection, @@ -1951,19 +1587,19 @@ paper still (mostly) accurately describes the interface). @end deffn guardian-destroyed? -@c snarfed from guardians.c:364 +@c snarfed from guardians.c:359 @deffn primitive guardian-destroyed? guardian Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}. @end deffn guardian-greedy? -@c snarfed from guardians.c:382 +@c snarfed from guardians.c:377 @deffn primitive guardian-greedy? guardian Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}. @end deffn destroy-guardian! -@c snarfed from guardians.c:393 +@c snarfed from guardians.c:388 @deffn primitive destroy-guardian! guardian Destroys @var{guardian}, by making it impossible to put any more objects in it or get any objects from it. It also unguards any @@ -1971,7 +1607,7 @@ objects guarded by @var{guardian}. @end deffn hashq -@c snarfed from hash.c:202 +@c snarfed from hash.c:200 @deffn primitive hashq key size Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eq?} is @@ -1986,7 +1622,7 @@ different values, since @code{foo} will be garbage collected. @end deffn hashv -@c snarfed from hash.c:238 +@c snarfed from hash.c:236 @deffn primitive hashv key size Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eqv?} is @@ -2001,7 +1637,7 @@ different values, since @code{foo} will be garbage collected. @end deffn hash -@c snarfed from hash.c:261 +@c snarfed from hash.c:259 @deffn primitive hash key size Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{equal?} @@ -2131,7 +1767,7 @@ Remove @var{key} (and any value associated with it) from @end deffn hashx-get-handle -@c snarfed from hashtab.c:428 +@c snarfed from hashtab.c:422 @deffn primitive hashx-get-handle hash assoc table key This behaves the same way as the corresponding @code{-get-handle} function, but uses @var{hash} as a hash @@ -2142,7 +1778,7 @@ table size. @code{assoc} must be an associator function, like @end deffn hashx-create-handle! -@c snarfed from hashtab.c:447 +@c snarfed from hashtab.c:441 @deffn primitive hashx-create-handle! hash assoc table key init This behaves the same way as the corresponding @code{-create-handle} function, but uses @var{hash} as a hash @@ -2153,7 +1789,7 @@ table size. @code{assoc} must be an associator function, like @end deffn hashx-ref -@c snarfed from hashtab.c:470 +@c snarfed from hashtab.c:464 @deffn primitive hashx-ref hash assoc table key [dflt] This behaves the same way as the corresponding @code{ref} function, but uses @var{hash} as a hash function and @@ -2167,7 +1803,7 @@ equivalent to @code{hashx-ref hashq assq table key}. @end deffn hashx-set! -@c snarfed from hashtab.c:496 +@c snarfed from hashtab.c:490 @deffn primitive hashx-set! hash assoc table key val This behaves the same way as the corresponding @code{set!} function, but uses @var{hash} as a hash function and @@ -2181,7 +1817,7 @@ equivalent to @code{hashx-set! hashq assq table key}. @end deffn hash-fold -@c snarfed from hashtab.c:534 +@c snarfed from hashtab.c:528 @deffn primitive hash-fold proc init table An iterator over hash-table elements. Accumulates and returns a result by applying PROC successively. @@ -2193,70 +1829,66 @@ For example, @code{(hash-fold acons () tab)} will convert a hash table into an a-list of key-value pairs. @end deffn - make-hook-with-name -@c snarfed from hooks.c:217 -@deffn primitive make-hook-with-name name [n_args] -Create a named hook with the name @var{name} for storing -procedures of arity @var{n_args}. @var{n_args} defaults to -zero. -@end deffn - make-hook -@c snarfed from hooks.c:232 +@c snarfed from hooks.c:179 @deffn primitive make-hook [n_args] -Create a hook for storing procedure of arity -@var{n_args}. @var{n_args} defaults to zero. +Create a hook for storing procedure of arity @var{n_args}. +@var{n_args} defaults to zero. The returned value is a hook +object to be used with the other hook procedures. @end deffn hook? -@c snarfed from hooks.c:242 +@c snarfed from hooks.c:202 @deffn primitive hook? x Return @code{#t} if @var{x} is a hook, @code{#f} otherwise. @end deffn hook-empty? -@c snarfed from hooks.c:253 +@c snarfed from hooks.c:213 @deffn primitive hook-empty? hook Return @code{#t} if @var{hook} is an empty hook, @code{#f} otherwise. @end deffn add-hook! -@c snarfed from hooks.c:266 +@c snarfed from hooks.c:227 @deffn primitive add-hook! hook proc [append_p] Add the procedure @var{proc} to the hook @var{hook}. The procedure is added to the end if @var{append_p} is true, -otherwise it is added to the front. +otherwise it is added to the front. The return value of this +procedure is not specified. @end deffn remove-hook! -@c snarfed from hooks.c:292 +@c snarfed from hooks.c:254 @deffn primitive remove-hook! hook proc -Remove the procedure @var{proc} from the hook @var{hook}. +Remove the procedure @var{proc} from the hook @var{hook}. The +return value of this procedure is not specified. @end deffn reset-hook! -@c snarfed from hooks.c:305 +@c snarfed from hooks.c:268 @deffn primitive reset-hook! hook -Remove all procedures from the hook @var{hook}. +Remove all procedures from the hook @var{hook}. The return +value of this procedure is not specified. @end deffn run-hook -@c snarfed from hooks.c:319 +@c snarfed from hooks.c:282 @deffn primitive run-hook hook . args Apply all procedures from the hook @var{hook} to the arguments @var{args}. The order of the procedure application is first to -last. +last. The return value of this procedure is not specified. @end deffn hook->list -@c snarfed from hooks.c:346 +@c snarfed from hooks.c:309 @deffn primitive hook->list hook Convert the procedure list of @var{hook} to a list. @end deffn ftell -@c snarfed from ioext.c:71 +@c snarfed from ioext.c:73 @deffn primitive ftell fd_port Return an integer representing the current position of @var{fd/port}, measured from the beginning. Equivalent to: @@ -2267,7 +1899,7 @@ Return an integer representing the current position of @end deffn redirect-port -@c snarfed from ioext.c:89 +@c snarfed from ioext.c:91 @deffn primitive redirect-port old new This procedure takes two ports and duplicates the underlying file descriptor from @var{old-port} into @var{new-port}. The @@ -2285,7 +1917,7 @@ revealed counts. @end deffn dup->fdes -@c snarfed from ioext.c:128 +@c snarfed from ioext.c:130 @deffn primitive dup->fdes fd_or_port [fd] Return a new integer file descriptor referring to the open file designated by @var{fd_or_port}, which must be either an open @@ -2293,7 +1925,7 @@ file port or a file descriptor. @end deffn dup2 -@c snarfed from ioext.c:175 +@c snarfed from ioext.c:177 @deffn primitive dup2 oldfd newfd A simple wrapper for the @code{dup2} system call. Copies the file descriptor @var{oldfd} to descriptor @@ -2306,21 +1938,21 @@ The return value is unspecified. @end deffn fileno -@c snarfed from ioext.c:194 +@c snarfed from ioext.c:196 @deffn primitive fileno port Return the integer file descriptor underlying @var{port}. Does not change its revealed count. @end deffn isatty? -@c snarfed from ioext.c:210 +@c snarfed from ioext.c:216 @deffn primitive isatty? port Return @code{#t} if @var{port} is using a serial non--file device, otherwise @code{#f}. @end deffn fdopen -@c snarfed from ioext.c:232 +@c snarfed from ioext.c:238 @deffn primitive fdopen fdes modes Return a new port based on the file descriptor @var{fdes}. Modes are given by the string @var{modes}. The revealed count @@ -2329,7 +1961,7 @@ same as that accepted by @ref{File Ports, open-file}. @end deffn primitive-move->fdes -@c snarfed from ioext.c:257 +@c snarfed from ioext.c:262 @deffn primitive primitive-move->fdes port fd Moves the underlying file descriptor for @var{port} to the integer value @var{fdes} without changing the revealed count of @var{port}. @@ -2340,7 +1972,7 @@ required value or @code{#t} if it was moved. @end deffn fdes->ports -@c snarfed from ioext.c:291 +@c snarfed from ioext.c:296 @deffn primitive fdes->ports fd Return a list of existing ports which have @var{fdes} as an underlying file descriptor, without changing their revealed @@ -2348,7 +1980,7 @@ counts. @end deffn make-keyword-from-dash-symbol -@c snarfed from keywords.c:71 +@c snarfed from keywords.c:74 @deffn primitive make-keyword-from-dash-symbol symbol Make a keyword object from a @var{symbol} that starts with a dash. @end deffn @@ -2368,7 +2000,7 @@ This is the inverse of @code{make-keyword-from-dash-symbol}. @end deffn nil-cons -@c snarfed from lang.c:71 +@c snarfed from lang.c:69 @deffn primitive nil-cons x y Create a new cons cell with @var{x} as the car and @var{y} as the cdr, but convert @var{y} to Scheme's end-of-list if it is @@ -2376,48 +2008,42 @@ a LISP nil. @end deffn nil-car -@c snarfed from lang.c:86 +@c snarfed from lang.c:84 @deffn primitive nil-car x Return the car of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn nil-cdr -@c snarfed from lang.c:99 +@c snarfed from lang.c:97 @deffn primitive nil-cdr x Return the cdr of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn null -@c snarfed from lang.c:114 +@c snarfed from lang.c:112 @deffn primitive null x Return LISP's @code{t} if @var{x} is nil in the LISP sense, return LISP's nil otherwise. @end deffn nil-eq -@c snarfed from lang.c:143 +@c snarfed from lang.c:141 @deffn primitive nil-eq x y Compare @var{x} and @var{y} and return LISP's t if they are @code{eq?}, return LISP's nil otherwise. @end deffn list -@c snarfed from list.c:84 +@c snarfed from list.c:128 @deffn primitive list . objs Return a list containing @var{objs}, the arguments to @code{list}. @end deffn - list* -@c snarfed from list.c:94 -@deffn primitive list* -scm_cons_star -@end deffn - cons* -@c snarfed from list.c:105 +@c snarfed from list.c:143 @deffn primitive cons* arg . rest Like @code{list}, but the last arg provides the tail of the constructed list, returning @code{(cons @var{arg1} (cons @@ -2428,25 +2054,25 @@ Schemes and in Common LISP. @end deffn null? -@c snarfed from list.c:129 +@c snarfed from list.c:167 @deffn primitive null? x Return @code{#t} iff @var{x} is the empty list, else @code{#f}. @end deffn list? -@c snarfed from list.c:139 +@c snarfed from list.c:177 @deffn primitive list? x Return @code{#t} iff @var{x} is a proper list, else @code{#f}. @end deffn length -@c snarfed from list.c:180 +@c snarfed from list.c:218 @deffn primitive length lst Return the number of elements in list @var{lst}. @end deffn append -@c snarfed from list.c:209 +@c snarfed from list.c:247 @deffn primitive append . args Return a list consisting of the elements the lists passed as arguments. @@ -2466,34 +2092,34 @@ if the last argument is not a proper list. @end deffn append! -@c snarfed from list.c:243 +@c snarfed from list.c:281 @deffn primitive append! . lists A destructive version of @code{append} (@pxref{Pairs and -Lists,,,r4rs, The Revised^4 Report on Scheme}). The cdr field +Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field of each list's final pair is changed to point to the head of the next list, so no consing is performed. Return a pointer to the mutated list. @end deffn last-pair -@c snarfed from list.c:269 +@c snarfed from list.c:307 @deffn primitive last-pair lst Return a pointer to the last pair in @var{lst}, signalling an error if @var{lst} is circular. @end deffn reverse -@c snarfed from list.c:299 +@c snarfed from list.c:337 @deffn primitive reverse lst Return a new list that contains the elements of @var{lst} but in reverse order. @end deffn reverse! -@c snarfed from list.c:333 +@c snarfed from list.c:371 @deffn primitive reverse! lst [new_tail] -A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r4rs, -The Revised^4 Report on Scheme}). The cdr of each cell in @var{lst} is +A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, +The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is modified to point to the previous list element. Return a pointer to the head of the reversed list. @@ -2506,25 +2132,25 @@ of the modified list is not lost, it is wise to save the return value of @end deffn list-ref -@c snarfed from list.c:359 +@c snarfed from list.c:397 @deffn primitive list-ref list k Return the @var{k}th element from @var{list}. @end deffn list-set! -@c snarfed from list.c:383 +@c snarfed from list.c:421 @deffn primitive list-set! list k val Set the @var{k}th element of @var{list} to @var{val}. @end deffn list-cdr-ref -@c snarfed from list.c:406 +@c snarfed from list.c:444 @deffn primitive list-cdr-ref -scm_list_tail +implemented by the C function "scm_list_tail" @end deffn list-tail -@c snarfed from list.c:415 +@c snarfed from list.c:453 @deffn primitive list-tail lst k @deffnx primitive list-cdr-ref lst k Return the "tail" of @var{lst} beginning with its @var{k}th element. @@ -2536,50 +2162,26 @@ or returning the results of cdring @var{k} times down @var{lst}. @end deffn list-cdr-set! -@c snarfed from list.c:431 +@c snarfed from list.c:469 @deffn primitive list-cdr-set! list k val Set the @var{k}th cdr of @var{list} to @var{val}. @end deffn list-head -@c snarfed from list.c:460 +@c snarfed from list.c:498 @deffn primitive list-head lst k Copy the first @var{k} elements from @var{lst} into a new list, and return it. @end deffn list-copy -@c snarfed from list.c:484 +@c snarfed from list.c:522 @deffn primitive list-copy lst Return a (newly-created) copy of @var{lst}. @end deffn - sloppy-memq -@c snarfed from list.c:518 -@deffn primitive sloppy-memq x lst -This procedure behaves like @code{memq}, but does no type or error checking. -Its use is recommended only in writing Guile internals, -not for high-level Scheme programs. -@end deffn - - sloppy-memv -@c snarfed from list.c:535 -@deffn primitive sloppy-memv x lst -This procedure behaves like @code{memv}, but does no type or error checking. -Its use is recommended only in writing Guile internals, -not for high-level Scheme programs. -@end deffn - - sloppy-member -@c snarfed from list.c:552 -@deffn primitive sloppy-member x lst -This procedure behaves like @code{member}, but does no type or error checking. -Its use is recommended only in writing Guile internals, -not for high-level Scheme programs. -@end deffn - memq -@c snarfed from list.c:592 +@c snarfed from list.c:576 @deffn primitive memq x lst Return the first sublist of @var{lst} whose car is @code{eq?} to @var{x} where the sublists of @var{lst} are the non-empty @@ -2590,7 +2192,7 @@ returned. @end deffn memv -@c snarfed from list.c:609 +@c snarfed from list.c:592 @deffn primitive memv x lst Return the first sublist of @var{lst} whose car is @code{eqv?} to @var{x} where the sublists of @var{lst} are the non-empty @@ -2601,7 +2203,7 @@ returned. @end deffn member -@c snarfed from list.c:630 +@c snarfed from list.c:613 @deffn primitive member x lst Return the first sublist of @var{lst} whose car is @code{equal?} to @var{x} where the sublists of @var{lst} are @@ -2612,7 +2214,7 @@ empty list) is returned. @end deffn delq! -@c snarfed from list.c:656 +@c snarfed from list.c:638 @deffn primitive delq! item lst @deffnx primitive delv! item lst @deffnx primitive delete! item lst @@ -2625,21 +2227,21 @@ destructive list functions, these functions cannot modify the binding of @end deffn delv! -@c snarfed from list.c:680 +@c snarfed from list.c:662 @deffn primitive delv! item lst Destructively remove all elements from @var{lst} that are @code{eqv?} to @var{item}. @end deffn delete! -@c snarfed from list.c:705 +@c snarfed from list.c:687 @deffn primitive delete! item lst Destructively remove all elements from @var{lst} that are @code{equal?} to @var{item}. @end deffn delq -@c snarfed from list.c:734 +@c snarfed from list.c:716 @deffn primitive delq item lst Return a newly-created copy of @var{lst} with elements @code{eq?} to @var{item} removed. This procedure mirrors @@ -2648,7 +2250,7 @@ Return a newly-created copy of @var{lst} with elements @end deffn delv -@c snarfed from list.c:747 +@c snarfed from list.c:729 @deffn primitive delv item lst Return a newly-created copy of @var{lst} with elements @code{eqv?} to @var{item} removed. This procedure mirrors @@ -2657,7 +2259,7 @@ Return a newly-created copy of @var{lst} with elements @end deffn delete -@c snarfed from list.c:760 +@c snarfed from list.c:742 @deffn primitive delete item lst Return a newly-created copy of @var{lst} with elements @code{equal?} to @var{item} removed. This procedure mirrors @@ -2666,7 +2268,7 @@ against @var{item} with @code{equal?}. @end deffn delq1! -@c snarfed from list.c:773 +@c snarfed from list.c:755 @deffn primitive delq1! item lst Like @code{delq!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @@ -2674,7 +2276,7 @@ Like @code{delq!}, but only deletes the first occurrence of @end deffn delv1! -@c snarfed from list.c:801 +@c snarfed from list.c:783 @deffn primitive delv1! item lst Like @code{delv!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @@ -2682,7 +2284,7 @@ Like @code{delv!}, but only deletes the first occurrence of @end deffn delete1! -@c snarfed from list.c:829 +@c snarfed from list.c:811 @deffn primitive delete1! item lst Like @code{delete!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @@ -2690,7 +2292,7 @@ Like @code{delete!}, but only deletes the first occurrence of @end deffn primitive-load -@c snarfed from load.c:112 +@c snarfed from load.c:110 @deffn primitive primitive-load filename Load the file named @var{filename} and evaluate its contents in the top-level environment. The load paths are not searched; @@ -2702,7 +2304,7 @@ documentation for @code{%load-hook} later in this section. @end deffn %package-data-dir -@c snarfed from load.c:147 +@c snarfed from load.c:150 @deffn primitive %package-data-dir Return the name of the directory where Scheme packages, modules and libraries are kept. On most Unix systems, this will be @@ -2710,21 +2312,21 @@ libraries are kept. On most Unix systems, this will be @end deffn %library-dir -@c snarfed from load.c:159 +@c snarfed from load.c:162 @deffn primitive %library-dir Return the directory where the Guile Scheme library files are installed. E.g., may return "/usr/share/guile/1.3.5". @end deffn %site-dir -@c snarfed from load.c:171 +@c snarfed from load.c:174 @deffn primitive %site-dir Return the directory where the Guile site files are installed. E.g., may return "/usr/share/guile/site". @end deffn parse-path -@c snarfed from load.c:223 +@c snarfed from load.c:226 @deffn primitive parse-path path [tail] Parse @var{path}, which is expected to be a colon-separated string, into a list and return the resulting list with @@ -2733,7 +2335,7 @@ is returned. @end deffn search-path -@c snarfed from load.c:273 +@c snarfed from load.c:276 @deffn primitive search-path path filename [extensions] Search @var{path} for a directory containing a file named @var{filename}. The file must be readable, and not a directory. @@ -2745,7 +2347,7 @@ concatenated with each @var{extension}. @end deffn %search-load-path -@c snarfed from load.c:420 +@c snarfed from load.c:423 @deffn primitive %search-load-path filename Search @var{%load-path} for the file named @var{filename}, which must be readable by the current user. If @var{filename} @@ -2757,7 +2359,7 @@ will try each extension automatically. @end deffn primitive-load-path -@c snarfed from load.c:441 +@c snarfed from load.c:444 @deffn primitive primitive-load-path filename Search @var{%load-path} for the file named @var{filename} and load it into the top-level environment. If @var{filename} is a @@ -2765,17 +2367,8 @@ relative pathname and is not found in the list of search paths, an error is signalled. @end deffn - read-and-eval! -@c snarfed from load.c:476 -@deffn primitive read-and-eval! [port] -Read a form from @var{port} (standard input by default), and evaluate it -(memoizing it in the process) in the top-level environment. If no data -is left to be read from @var{port}, an @code{end-of-file} error is -signalled. -@end deffn - procedure->syntax -@c snarfed from macros.c:106 +@c snarfed from macros.c:104 @deffn primitive procedure->syntax code Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, returns the @@ -2784,7 +2377,7 @@ environment. @end deffn procedure->macro -@c snarfed from macros.c:129 +@c snarfed from macros.c:127 @deffn primitive procedure->macro code Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the @@ -2803,7 +2396,7 @@ passed to @var{code}. For example: @end deffn procedure->memoizing-macro -@c snarfed from macros.c:152 +@c snarfed from macros.c:150 @deffn primitive procedure->memoizing-macro code Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the @@ -2822,14 +2415,14 @@ passed to @var{proc}. For example: @end deffn macro? -@c snarfed from macros.c:164 +@c snarfed from macros.c:162 @deffn primitive macro? obj Return @code{#t} if @var{obj} is a regular macro, a memoizing macro or a syntax transformer. @end deffn macro-type -@c snarfed from macros.c:182 +@c snarfed from macros.c:180 @deffn primitive macro-type m Return one of the symbols @code{syntax}, @code{macro} or @code{macro!}, depending on whether @var{m} is a syntax @@ -2839,32 +2432,32 @@ returned. @end deffn macro-name -@c snarfed from macros.c:200 +@c snarfed from macros.c:198 @deffn primitive macro-name m Return the name of the macro @var{m}. @end deffn macro-transformer -@c snarfed from macros.c:211 +@c snarfed from macros.c:209 @deffn primitive macro-transformer m Return the transformer of the macro @var{m}. @end deffn current-module -@c snarfed from modules.c:78 +@c snarfed from modules.c:69 @deffn primitive current-module Return the current module. @end deffn set-current-module -@c snarfed from modules.c:95 +@c snarfed from modules.c:81 @deffn primitive set-current-module module Set the current module to @var{module} and return the previous current module. @end deffn interaction-environment -@c snarfed from modules.c:128 +@c snarfed from modules.c:104 @deffn primitive interaction-environment Return a specifier for the environment that contains implementation--defined bindings, typically a superset of those @@ -2873,153 +2466,90 @@ return the environment in which the implementation would evaluate expressions dynamically typed by the user. @end deffn + env-module +@c snarfed from modules.c:253 +@deffn primitive env-module env +Return the module of @var{ENV}, a lexical environment. +@end deffn + standard-eval-closure -@c snarfed from modules.c:312 +@c snarfed from modules.c:330 @deffn primitive standard-eval-closure module Return an eval closure for the module @var{module}. @end deffn - gethost -@c snarfed from net_db.c:146 -@deffn primitive gethost [host] -@deffnx procedure gethostbyname hostname -@deffnx procedure gethostbyaddr address -Look up a host by name or address, returning a host object. The -@code{gethost} procedure will accept either a string name or an integer -address; if given no arguments, it behaves like @code{gethostent} (see -below). If a name or address is supplied but the address can not be -found, an error will be thrown to one of the keys: -@code{host-not-found}, @code{try-again}, @code{no-recovery} or -@code{no-data}, corresponding to the equivalent @code{h_error} values. -Unusual conditions may result in errors thrown to the -@code{system-error} or @code{misc_error} keys. + standard-interface-eval-closure +@c snarfed from modules.c:341 +@deffn primitive standard-interface-eval-closure module +Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added. @end deffn - getnet -@c snarfed from net_db.c:227 -@deffn primitive getnet [net] -@deffnx procedure getnetbyname net-name -@deffnx procedure getnetbyaddr net-number -Look up a network by name or net number in the network database. The -@var{net-name} argument must be a string, and the @var{net-number} -argument must be an integer. @code{getnet} will accept either type of -argument, behaving like @code{getnetent} (see below) if no arguments are -given. -@end deffn - - getproto -@c snarfed from net_db.c:277 -@deffn primitive getproto [protocol] -@deffnx procedure getprotobyname name -@deffnx procedure getprotobynumber number -Look up a network protocol by name or by number. @code{getprotobyname} -takes a string argument, and @code{getprotobynumber} takes an integer -argument. @code{getproto} will accept either type, behaving like -@code{getprotoent} (see below) if no arguments are supplied. -@end deffn - - getserv -@c snarfed from net_db.c:344 -@deffn primitive getserv [name [protocol]] -@deffnx procedure getservbyname name protocol -@deffnx procedure getservbyport port protocol -Look up a network service by name or by service number, and return a -network service object. The @var{protocol} argument specifies the name -of the desired protocol; if the protocol found in the network service -database does not match this name, a system error is signalled. - -The @code{getserv} procedure will take either a service name or number -as its first argument; if given no arguments, it behaves like -@code{getservent} (see below). -@end deffn - - sethost -@c snarfed from net_db.c:383 -@deffn primitive sethost [stayopen] -If @var{stayopen} is omitted, this is equivalent to @code{endhostent}. -Otherwise it is equivalent to @code{sethostent stayopen}. -@end deffn - - setnet -@c snarfed from net_db.c:399 -@deffn primitive setnet [stayopen] -If @var{stayopen} is omitted, this is equivalent to @code{endnetent}. -Otherwise it is equivalent to @code{setnetent stayopen}. -@end deffn - - setproto -@c snarfed from net_db.c:415 -@deffn primitive setproto [stayopen] -If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}. -Otherwise it is equivalent to @code{setprotoent stayopen}. -@end deffn - - setserv -@c snarfed from net_db.c:431 -@deffn primitive setserv [stayopen] -If @var{stayopen} is omitted, this is equivalent to @code{endservent}. -Otherwise it is equivalent to @code{setservent stayopen}. + %get-pre-modules-obarray +@c snarfed from modules.c:564 +@deffn primitive %get-pre-modules-obarray +Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system. @end deffn exact? -@c snarfed from numbers.c:107 +@c snarfed from numbers.c:97 @deffn primitive exact? x Return @code{#t} if @var{x} is an exact number, @code{#f} otherwise. @end deffn odd? -@c snarfed from numbers.c:124 +@c snarfed from numbers.c:114 @deffn primitive odd? n Return @code{#t} if @var{n} is an odd number, @code{#f} otherwise. @end deffn even? -@c snarfed from numbers.c:141 +@c snarfed from numbers.c:131 @deffn primitive even? n Return @code{#t} if @var{n} is an even number, @code{#f} otherwise. @end deffn logand -@c snarfed from numbers.c:756 +@c snarfed from numbers.c:744 @deffn primitive logand n1 n2 -Return the integer which is the bit-wise AND of the two integer -arguments. +Return the bitwise AND of the integer arguments. @lisp -(number->string (logand #b1100 #b1010) 2) - @result{} "1000" +(logand) @result{} -1 +(logand 7) @result{} 7 +(logand #b111 #b011 #b001) @result{} 1 @end lisp @end deffn logior -@c snarfed from numbers.c:843 +@c snarfed from numbers.c:830 @deffn primitive logior n1 n2 -Return the integer which is the bit-wise OR of the two integer -arguments. +Return the bitwise OR of the integer arguments. @lisp -(number->string (logior #b1100 #b1010) 2) - @result{} "1110" +(logior) @result{} 0 +(logior 7) @result{} 7 +(logior #b000 #b001 #b011) @result{} 3 @end lisp @end deffn logxor -@c snarfed from numbers.c:929 +@c snarfed from numbers.c:917 @deffn primitive logxor n1 n2 -Return the integer which is the bit-wise XOR of the two integer -arguments. - +Return the bitwise XOR of the integer arguments. A bit is +set in the result if it is set in an odd number of arguments. @lisp -(number->string (logxor #b1100 #b1010) 2) - @result{} "110" +(logxor) @result{} 0 +(logxor 7) @result{} 7 +(logxor #b000 #b001 #b011) @result{} 2 +(logxor #b000 #b001 #b011 #b011) @result{} 1 @end lisp @end deffn logtest -@c snarfed from numbers.c:998 +@c snarfed from numbers.c:986 @deffn primitive logtest j k @lisp (logtest j k) @equiv{} (not (zero? (logand j k))) @@ -3030,7 +2560,7 @@ arguments. @end deffn logbit? -@c snarfed from numbers.c:1055 +@c snarfed from numbers.c:1043 @deffn primitive logbit? index j @lisp (logbit? index j) @equiv{} (logtest (integer-expt 2 index) j) @@ -3044,7 +2574,7 @@ arguments. @end deffn lognot -@c snarfed from numbers.c:1104 +@c snarfed from numbers.c:1092 @deffn primitive lognot n Return the integer which is the 2s-complement of the integer argument. @@ -3058,7 +2588,7 @@ argument. @end deffn integer-expt -@c snarfed from numbers.c:1121 +@c snarfed from numbers.c:1109 @deffn primitive integer-expt n k Return @var{n} raised to the non-negative integer exponent @var{k}. @@ -3072,7 +2602,7 @@ Return @var{n} raised to the non-negative integer exponent @end deffn ash -@c snarfed from numbers.c:1168 +@c snarfed from numbers.c:1164 @deffn primitive ash n cnt The function ash performs an arithmetic shift left by @var{cnt} bits (or shift right, if @var{cnt} is negative). 'Arithmetic' @@ -3092,7 +2622,7 @@ Formally, the function returns an integer equivalent to @end deffn bit-extract -@c snarfed from numbers.c:1221 +@c snarfed from numbers.c:1217 @deffn primitive bit-extract n start end Return the integer composed of the @var{start} (inclusive) through @var{end} (exclusive) bits of @var{n}. The @@ -3107,7 +2637,7 @@ through @var{end} (exclusive) bits of @var{n}. The @end deffn logcount -@c snarfed from numbers.c:1293 +@c snarfed from numbers.c:1289 @deffn primitive logcount n Return the number of bits in integer @var{n}. If integer is positive, the 1-bits in its binary representation are counted. @@ -3125,7 +2655,7 @@ representation are counted. If 0, 0 is returned. @end deffn integer-length -@c snarfed from numbers.c:1344 +@c snarfed from numbers.c:1340 @deffn primitive integer-length n Return the number of bits neccessary to represent @var{n}. @@ -3140,7 +2670,7 @@ Return the number of bits neccessary to represent @var{n}. @end deffn number->string -@c snarfed from numbers.c:2290 +@c snarfed from numbers.c:2175 @deffn primitive number->string n [radix] Return a string holding the external representation of the number @var{n} in the given @var{radix}. If @var{n} is @@ -3148,7 +2678,7 @@ inexact, a radix of 10 will be used. @end deffn string->number -@c snarfed from numbers.c:2875 +@c snarfed from numbers.c:2810 @deffn primitive string->number string [radix] Return a number of the maximally precise representation expressed by the given @var{string}. @var{radix} must be an @@ -3161,13 +2691,13 @@ syntactically valid notation for a number, then @end deffn number? -@c snarfed from numbers.c:2942 +@c snarfed from numbers.c:2879 @deffn primitive number? -scm_number_p +implemented by the C function "scm_number_p" @end deffn complex? -@c snarfed from numbers.c:2954 +@c snarfed from numbers.c:2891 @deffn primitive complex? x Return @code{#t} if @var{x} is a complex number, @code{#f} else. Note that the sets of real, rational and integer @@ -3177,13 +2707,13 @@ rational or integer number. @end deffn real? -@c snarfed from numbers.c:2962 +@c snarfed from numbers.c:2899 @deffn primitive real? -scm_real_p +implemented by the C function "scm_real_p" @end deffn rational? -@c snarfed from numbers.c:2975 +@c snarfed from numbers.c:2912 @deffn primitive rational? x Return @code{#t} if @var{x} is a rational number, @code{#f} else. Note that the set of integer values forms a subset of @@ -3194,28 +2724,28 @@ precision. @end deffn integer? -@c snarfed from numbers.c:2996 +@c snarfed from numbers.c:2933 @deffn primitive integer? x Return @code{#t} if @var{x} is an integer number, @code{#f} else. @end deffn inexact? -@c snarfed from numbers.c:3021 +@c snarfed from numbers.c:2958 @deffn primitive inexact? x Return @code{#t} if @var{x} is an inexact number, @code{#f} else. @end deffn $expt -@c snarfed from numbers.c:4073 +@c snarfed from numbers.c:4003 @deffn primitive $expt x y Return @var{x} raised to the power of @var{y}. This procedure does not accept complex arguments. @end deffn $atan2 -@c snarfed from numbers.c:4089 +@c snarfed from numbers.c:4019 @deffn primitive $atan2 x y Return the arc tangent of the two arguments @var{x} and @var{y}. This is similar to calculating the arc tangent of @@ -3225,86 +2755,92 @@ procedure does not accept complex arguments. @end deffn make-rectangular -@c snarfed from numbers.c:4102 +@c snarfed from numbers.c:4032 @deffn primitive make-rectangular real imaginary Return a complex number constructed of the given @var{real} and @var{imaginary} parts. @end deffn make-polar -@c snarfed from numbers.c:4115 +@c snarfed from numbers.c:4045 @deffn primitive make-polar x y Return the complex number @var{x} * e^(i * @var{y}). @end deffn inexact->exact -@c snarfed from numbers.c:4233 +@c snarfed from numbers.c:4180 @deffn primitive inexact->exact z Return an exact number that is numerically closest to @var{z}. @end deffn class-of -@c snarfed from objects.c:88 +@c snarfed from objects.c:86 @deffn primitive class-of x Return the class of @var{x}. @end deffn entity? -@c snarfed from objects.c:359 +@c snarfed from objects.c:360 @deffn primitive entity? obj Return @code{#t} if @var{obj} is an entity. @end deffn operator? -@c snarfed from objects.c:368 +@c snarfed from objects.c:369 @deffn primitive operator? obj Return @code{#t} if @var{obj} is an operator. @end deffn + valid-object-procedure? +@c snarfed from objects.c:385 +@deffn primitive valid-object-procedure? proc +Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}. +@end deffn + set-object-procedure! -@c snarfed from objects.c:380 +@c snarfed from objects.c:407 @deffn primitive set-object-procedure! obj proc -Return the object procedure of @var{obj} to @var{proc}. +Set the object procedure of @var{obj} to @var{proc}. @var{obj} must be either an entity or an operator. @end deffn make-class-object -@c snarfed from objects.c:440 +@c snarfed from objects.c:467 @deffn primitive make-class-object metaclass layout Create a new class object of class @var{metaclass}, with the slot layout specified by @var{layout}. @end deffn make-subclass-object -@c snarfed from objects.c:455 +@c snarfed from objects.c:482 @deffn primitive make-subclass-object class layout Create a subclass object of @var{class}, with the slot layout specified by @var{layout}. @end deffn object-properties -@c snarfed from objprop.c:62 +@c snarfed from objprop.c:60 @deffn primitive object-properties obj @deffnx primitive procedure-properties obj Return @var{obj}'s property list. @end deffn set-object-properties! -@c snarfed from objprop.c:73 +@c snarfed from objprop.c:71 @deffn primitive set-object-properties! obj alist @deffnx primitive set-procedure-properties! obj alist Set @var{obj}'s property list to @var{alist}. @end deffn object-property -@c snarfed from objprop.c:85 +@c snarfed from objprop.c:83 @deffn primitive object-property obj key @deffnx primitive procedure-property obj key Return the property of @var{obj} with name @var{key}. @end deffn set-object-property! -@c snarfed from objprop.c:98 +@c snarfed from objprop.c:96 @deffn primitive set-object-property! obj key value @deffnx primitive set-procedure-property! obj key value In @var{obj}'s property list, set the property named @var{key} @@ -3312,7 +2848,7 @@ to @var{value}. @end deffn cons -@c snarfed from pairs.c:61 +@c snarfed from pairs.c:80 @deffn primitive cons x y Return a newly allocated pair whose car is @var{x} and whose cdr is @var{y}. The pair is guaranteed to be different (in the @@ -3320,28 +2856,28 @@ sense of @code{eq?}) from every previously existing object. @end deffn pair? -@c snarfed from pairs.c:94 +@c snarfed from pairs.c:113 @deffn primitive pair? x Return @code{#t} if @var{x} is a pair; otherwise return @code{#f}. @end deffn set-car! -@c snarfed from pairs.c:105 +@c snarfed from pairs.c:124 @deffn primitive set-car! pair value Stores @var{value} in the car field of @var{pair}. The value returned by @code{set-car!} is unspecified. @end deffn set-cdr! -@c snarfed from pairs.c:118 +@c snarfed from pairs.c:137 @deffn primitive set-cdr! pair value Stores @var{value} in the cdr field of @var{pair}. The value returned by @code{set-cdr!} is unspecified. @end deffn char-ready? -@c snarfed from ports.c:246 +@c snarfed from ports.c:253 @deffn primitive char-ready? [port] Return @code{#t} if a character is ready on input @var{port} and return @code{#f} otherwise. If @code{char-ready?} returns @@ -3359,14 +2895,26 @@ interactive port that has no ready characters.} @end deffn drain-input -@c snarfed from ports.c:312 +@c snarfed from ports.c:330 @deffn primitive drain-input port -Drain @var{port}'s read buffers (including any pushed-back -characters) and return the content as a single string. +This procedure clears a port's input buffers, similar +to the way that force-output clears the output buffer. The +contents of the buffers are returned as a single string, e.g., + +@lisp +(define p (open-input-file ...)) +(drain-input p) => empty string, nothing buffered yet. +(unread-char (read-char p) p) +(drain-input p) => initial chars from p, up to the buffer size. +@end lisp + +Draining the buffers may be useful for cleanly finishing +buffered I/O so that the file descriptor can be used directly +for further input. @end deffn current-input-port -@c snarfed from ports.c:339 +@c snarfed from ports.c:357 @deffn primitive current-input-port Return the current input port. This is the default port used by many input procedures. Initially, @code{current-input-port} @@ -3374,7 +2922,7 @@ returns the @dfn{standard input} in Unix and C terminology. @end deffn current-output-port -@c snarfed from ports.c:351 +@c snarfed from ports.c:369 @deffn primitive current-output-port Return the current output port. This is the default port used by many output procedures. Initially, @@ -3383,21 +2931,21 @@ Unix and C terminology. @end deffn current-error-port -@c snarfed from ports.c:361 +@c snarfed from ports.c:379 @deffn primitive current-error-port Return the port to which errors and warnings should be sent (the @dfn{standard error} in Unix and C terminology). @end deffn current-load-port -@c snarfed from ports.c:371 +@c snarfed from ports.c:389 @deffn primitive current-load-port Return the current-load-port. The load port is used internally by @code{primitive-load}. @end deffn set-current-input-port -@c snarfed from ports.c:384 +@c snarfed from ports.c:402 @deffn primitive set-current-input-port port @deffnx primitive set-current-output-port port @deffnx primitive set-current-error-port port @@ -3407,32 +2955,32 @@ so that they use the supplied @var{port} for input or output. @end deffn set-current-output-port -@c snarfed from ports.c:397 +@c snarfed from ports.c:415 @deffn primitive set-current-output-port port Set the current default output port to @var{port}. @end deffn set-current-error-port -@c snarfed from ports.c:411 +@c snarfed from ports.c:429 @deffn primitive set-current-error-port port Set the current default error port to @var{port}. @end deffn port-revealed -@c snarfed from ports.c:556 +@c snarfed from ports.c:574 @deffn primitive port-revealed port Return the revealed count for @var{port}. @end deffn set-port-revealed! -@c snarfed from ports.c:569 +@c snarfed from ports.c:587 @deffn primitive set-port-revealed! port rcount Sets the revealed count for a port to a given value. The return value is unspecified. @end deffn port-mode -@c snarfed from ports.c:612 +@c snarfed from ports.c:630 @deffn primitive port-mode port Return the port modes associated with the open port @var{port}. These will not necessarily be identical to the modes used when @@ -3441,7 +2989,7 @@ used only during port creation are not retained. @end deffn close-port -@c snarfed from ports.c:649 +@c snarfed from ports.c:667 @deffn primitive close-port port Close the specified port object. Return @code{#t} if it successfully closes a port or @code{#f} if it was already @@ -3452,7 +3000,7 @@ descriptors. @end deffn close-input-port -@c snarfed from ports.c:677 +@c snarfed from ports.c:695 @deffn primitive close-input-port port Close the specified input port object. The routine has no effect if the file has already been closed. An exception may be raised if an @@ -3463,7 +3011,7 @@ which can close file descriptors. @end deffn close-output-port -@c snarfed from ports.c:692 +@c snarfed from ports.c:710 @deffn primitive close-output-port port Close the specified output port object. The routine has no effect if the file has already been closed. An exception may be raised if an @@ -3474,7 +3022,7 @@ which can close file descriptors. @end deffn port-for-each -@c snarfed from ports.c:709 +@c snarfed from ports.c:727 @deffn primitive port-for-each proc Apply @var{proc} to each port in the Guile port table in turn. The return value is unspecified. More specifically, @@ -3484,19 +3032,8 @@ Changes to the port table while @var{port-for-each} is running have no effect as far as @var{port-for-each} is concerned. @end deffn - close-all-ports-except -@c snarfed from ports.c:752 -@deffn primitive close-all-ports-except . ports -[DEPRECATED] Close all open file ports used by the interpreter -except for those supplied as arguments. This procedure -was intended to be used before an exec call to close file descriptors -which are not needed in the new process. However it has the -undesirable side-effect of flushing buffes, so it's deprecated. -Use port-for-each instead. -@end deffn - input-port? -@c snarfed from ports.c:791 +@c snarfed from ports.c:768 @deffn primitive input-port? x Return @code{#t} if @var{x} is an input port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @@ -3504,7 +3041,7 @@ Return @code{#t} if @var{x} is an input port, otherwise return @end deffn output-port? -@c snarfed from ports.c:804 +@c snarfed from ports.c:779 @deffn primitive output-port? x Return @code{#t} if @var{x} is an output port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @@ -3512,7 +3049,7 @@ Return @code{#t} if @var{x} is an output port, otherwise return @end deffn port? -@c snarfed from ports.c:819 +@c snarfed from ports.c:791 @deffn primitive port? x Return a boolean indicating whether @var{x} is a port. Equivalent to @code{(or (input-port? @var{x}) (output-port? @@ -3520,21 +3057,21 @@ Equivalent to @code{(or (input-port? @var{x}) (output-port? @end deffn port-closed? -@c snarfed from ports.c:829 +@c snarfed from ports.c:801 @deffn primitive port-closed? port Return @code{#t} if @var{port} is closed or @code{#f} if it is open. @end deffn eof-object? -@c snarfed from ports.c:840 +@c snarfed from ports.c:812 @deffn primitive eof-object? x Return @code{#t} if @var{x} is an end-of-file object; otherwise return @code{#f}. @end deffn force-output -@c snarfed from ports.c:854 +@c snarfed from ports.c:826 @deffn primitive force-output [port] Flush the specified output port, or the current output port if @var{port} is omitted. The current output buffer contents are passed to the @@ -3546,14 +3083,14 @@ The return value is unspecified. @end deffn flush-all-ports -@c snarfed from ports.c:872 +@c snarfed from ports.c:844 @deffn primitive flush-all-ports Equivalent to calling @code{force-output} on all open output ports. The return value is unspecified. @end deffn read-char -@c snarfed from ports.c:890 +@c snarfed from ports.c:862 @deffn primitive read-char [port] Return the next character available from @var{port}, updating @var{port} to point to the following character. If no more @@ -3561,7 +3098,7 @@ characters are available, the end-of-file object is returned. @end deffn peek-char -@c snarfed from ports.c:1207 +@c snarfed from ports.c:1188 @deffn primitive peek-char [port] Return the next character available from @var{port}, @emph{without} updating @var{port} to point to the following @@ -3578,7 +3115,7 @@ to @code{read-char} would have hung.} @end deffn unread-char -@c snarfed from ports.c:1228 +@c snarfed from ports.c:1209 @deffn primitive unread-char cobj [port] Place @var{char} in @var{port} so that it will be read by the next read operation. If called multiple times, the unread characters @@ -3587,7 +3124,7 @@ not supplied, the current input port is used. @end deffn unread-string -@c snarfed from ports.c:1251 +@c snarfed from ports.c:1232 @deffn primitive unread-string str port Place the string @var{str} in @var{port} so that its characters will be read in subsequent read operations. If called multiple times, the @@ -3596,7 +3133,7 @@ unread characters will be read again in last-in first-out order. If @end deffn seek -@c snarfed from ports.c:1290 +@c snarfed from ports.c:1271 @deffn primitive seek fd_port offset whence Sets the current position of @var{fd/port} to the integer @var{offset}, which is interpreted according to the value of @@ -3624,7 +3161,7 @@ that the current position of a port can be obtained using: @end deffn truncate-file -@c snarfed from ports.c:1331 +@c snarfed from ports.c:1326 @deffn primitive truncate-file object [length] Truncates the object referred to by @var{object} to at most @var{length} bytes. @var{object} can be a string containing a @@ -3635,19 +3172,19 @@ position. The return value is unspecified. @end deffn port-line -@c snarfed from ports.c:1385 +@c snarfed from ports.c:1379 @deffn primitive port-line port Return the current line number for @var{port}. @end deffn set-port-line! -@c snarfed from ports.c:1396 +@c snarfed from ports.c:1390 @deffn primitive set-port-line! port line Set the current line number for @var{port} to @var{line}. @end deffn port-column -@c snarfed from ports.c:1417 +@c snarfed from ports.c:1411 @deffn primitive port-column port @deffnx primitive port-line port Return the current column number or line number of @var{port}, @@ -3661,7 +3198,7 @@ what non-programmers will find most natural.) @end deffn set-port-column! -@c snarfed from ports.c:1430 +@c snarfed from ports.c:1424 @deffn primitive set-port-column! port column @deffnx primitive set-port-line! port line Set the current column or line number of @var{port}, using the @@ -3669,7 +3206,7 @@ current input port if none is specified. @end deffn port-filename -@c snarfed from ports.c:1445 +@c snarfed from ports.c:1439 @deffn primitive port-filename port Return the filename associated with @var{port}. This function returns the strings "standard input", "standard output" and "standard error" @@ -3677,7 +3214,7 @@ when called on the current input, output and error ports respectively. @end deffn set-port-filename! -@c snarfed from ports.c:1459 +@c snarfed from ports.c:1453 @deffn primitive set-port-filename! port filename Change the filename associated with @var{port}, using the current input port if none is specified. Note that this does not change the port's @@ -3686,7 +3223,7 @@ source of data, but only the value that is returned by @end deffn %make-void-port -@c snarfed from ports.c:1551 +@c snarfed from ports.c:1547 @deffn primitive %make-void-port mode Create and return a new void port. A void port acts like /dev/null. The @var{mode} argument @@ -3694,620 +3231,8 @@ specifies the input/output modes for this port: see the documentation for @code{open-file} in @ref{File Ports}. @end deffn - pipe -@c snarfed from posix.c:201 -@deffn primitive pipe -Return a newly created pipe: a pair of ports which are linked -together on the local machine. The @emph{car} is the input -port and the @emph{cdr} is the output port. Data written (and -flushed) to the output port can be read from the input port. -Pipes are commonly used for communication with a newly forked -child process. The need to flush the output port can be -avoided by making it unbuffered using @code{setvbuf}. - -Writes occur atomically provided the size of the data in bytes -is not greater than the value of @code{PIPE_BUF}. Note that -the output port is likely to block if too much data (typically -equal to @code{PIPE_BUF}) has been written but not yet read -from the input port. -@end deffn - - getgroups -@c snarfed from posix.c:222 -@deffn primitive getgroups -Return a vector of integers representing the current -supplimentary group IDs. -@end deffn - - getpw -@c snarfed from posix.c:255 -@deffn primitive getpw [user] -Look up an entry in the user database. @var{obj} can be an integer, -a string, or omitted, giving the behaviour of getpwuid, getpwnam -or getpwent respectively. -@end deffn - - setpw -@c snarfed from posix.c:308 -@deffn primitive setpw [arg] -If called with a true argument, initialize or reset the password data -stream. Otherwise, close the stream. The @code{setpwent} and -@code{endpwent} procedures are implemented on top of this. -@end deffn - - getgr -@c snarfed from posix.c:327 -@deffn primitive getgr [name] -Look up an entry in the group database. @var{obj} can be an integer, -a string, or omitted, giving the behaviour of getgrgid, getgrnam -or getgrent respectively. -@end deffn - - setgr -@c snarfed from posix.c:368 -@deffn primitive setgr [arg] -If called with a true argument, initialize or reset the group data -stream. Otherwise, close the stream. The @code{setgrent} and -@code{endgrent} procedures are implemented on top of this. -@end deffn - - kill -@c snarfed from posix.c:404 -@deffn primitive kill pid sig -Sends a signal to the specified process or group of processes. - -@var{pid} specifies the processes to which the signal is sent: - -@table @r -@item @var{pid} greater than 0 -The process whose identifier is @var{pid}. -@item @var{pid} equal to 0 -All processes in the current process group. -@item @var{pid} less than -1 -The process group whose identifier is -@var{pid} -@item @var{pid} equal to -1 -If the process is privileged, all processes except for some special -system processes. Otherwise, all processes with the current effective -user ID. -@end table - -@var{sig} should be specified using a variable corresponding to -the Unix symbolic name, e.g., - -@defvar SIGHUP -Hang-up signal. -@end defvar - -@defvar SIGINT -Interrupt signal. -@end defvar -@end deffn - - waitpid -@c snarfed from posix.c:452 -@deffn primitive waitpid pid [options] -This procedure collects status information from a child process which -has terminated or (optionally) stopped. Normally it will -suspend the calling process until this can be done. If more than one -child process is eligible then one will be chosen by the operating system. - -The value of @var{pid} determines the behaviour: - -@table @r -@item @var{pid} greater than 0 -Request status information from the specified child process. -@item @var{pid} equal to -1 or WAIT_ANY -Request status information for any child process. -@item @var{pid} equal to 0 or WAIT_MYPGRP -Request status information for any child process in the current process -group. -@item @var{pid} less than -1 -Request status information for any child process whose process group ID -is -@var{PID}. -@end table - -The @var{options} argument, if supplied, should be the bitwise OR of the -values of zero or more of the following variables: - -@defvar WNOHANG -Return immediately even if there are no child processes to be collected. -@end defvar - -@defvar WUNTRACED -Report status information for stopped processes as well as terminated -processes. -@end defvar - -The return value is a pair containing: - -@enumerate -@item -The process ID of the child process, or 0 if @code{WNOHANG} was -specified and no process was collected. -@item -The integer status value. -@end enumerate -@end deffn - - status:exit-val -@c snarfed from posix.c:479 -@deffn primitive status:exit-val status -Return the exit status value, as would be set if a process -ended normally through a call to @code{exit} or @code{_exit}, -if any, otherwise @code{#f}. -@end deffn - - status:term-sig -@c snarfed from posix.c:499 -@deffn primitive status:term-sig status -Return the signal number which terminated the process, if any, -otherwise @code{#f}. -@end deffn - - status:stop-sig -@c snarfed from posix.c:517 -@deffn primitive status:stop-sig status -Return the signal number which stopped the process, if any, -otherwise @code{#f}. -@end deffn - - getppid -@c snarfed from posix.c:535 -@deffn primitive getppid -Return an integer representing the process ID of the parent -process. -@end deffn - - getuid -@c snarfed from posix.c:546 -@deffn primitive getuid -Return an integer representing the current real user ID. -@end deffn - - getgid -@c snarfed from posix.c:557 -@deffn primitive getgid -Return an integer representing the current real group ID. -@end deffn - - geteuid -@c snarfed from posix.c:571 -@deffn primitive geteuid -Return an integer representing the current effective user ID. -If the system does not support effective IDs, then the real ID -is returned. @code{(feature? 'EIDs)} reports whether the -system supports effective IDs. -@end deffn - - getegid -@c snarfed from posix.c:589 -@deffn primitive getegid -Return an integer representing the current effective group ID. -If the system does not support effective IDs, then the real ID -is returned. @code{(feature? 'EIDs)} reports whether the -system supports effective IDs. -@end deffn - - setuid -@c snarfed from posix.c:605 -@deffn primitive setuid id -Sets both the real and effective user IDs to the integer @var{id}, provided -the process has appropriate privileges. -The return value is unspecified. -@end deffn - - setgid -@c snarfed from posix.c:619 -@deffn primitive setgid id -Sets both the real and effective group IDs to the integer @var{id}, provided -the process has appropriate privileges. -The return value is unspecified. -@end deffn - - seteuid -@c snarfed from posix.c:635 -@deffn primitive seteuid id -Sets the effective user ID to the integer @var{id}, provided the process -has appropriate privileges. If effective IDs are not supported, the -real ID is set instead -- @code{(feature? 'EIDs)} reports whether the -system supports effective IDs. -The return value is unspecified. -@end deffn - - setegid -@c snarfed from posix.c:659 -@deffn primitive setegid id -Sets the effective group ID to the integer @var{id}, provided the process -has appropriate privileges. If effective IDs are not supported, the -real ID is set instead -- @code{(feature? 'EIDs)} reports whether the -system supports effective IDs. -The return value is unspecified. -@end deffn - - getpgrp -@c snarfed from posix.c:681 -@deffn primitive getpgrp -Return an integer representing the current process group ID. -This is the POSIX definition, not BSD. -@end deffn - - setpgid -@c snarfed from posix.c:697 -@deffn primitive setpgid pid pgid -Move the process @var{pid} into the process group @var{pgid}. @var{pid} or -@var{pgid} must be integers: they can be zero to indicate the ID of the -current process. -Fails on systems that do not support job control. -The return value is unspecified. -@end deffn - - setsid -@c snarfed from posix.c:716 -@deffn primitive setsid -Creates a new session. The current process becomes the session leader -and is put in a new process group. The process will be detached -from its controlling terminal if it has one. -The return value is an integer representing the new process group ID. -@end deffn - - ttyname -@c snarfed from posix.c:730 -@deffn primitive ttyname port -Return a string with the name of the serial terminal device -underlying @var{port}. -@end deffn - - ctermid -@c snarfed from posix.c:753 -@deffn primitive ctermid -Return a string containing the file name of the controlling -terminal for the current process. -@end deffn - - tcgetpgrp -@c snarfed from posix.c:776 -@deffn primitive tcgetpgrp port -Return the process group ID of the foreground process group -associated with the terminal open on the file descriptor -underlying @var{port}. - -If there is no foreground process group, the return value is a -number greater than 1 that does not match the process group ID -of any existing process group. This can happen if all of the -processes in the job that was formerly the foreground job have -terminated, and no other job has yet been moved into the -foreground. -@end deffn - - tcsetpgrp -@c snarfed from posix.c:800 -@deffn primitive tcsetpgrp port pgid -Set the foreground process group ID for the terminal used by the file -descriptor underlying @var{port} to the integer @var{pgid}. -The calling process -must be a member of the same session as @var{pgid} and must have the same -controlling terminal. The return value is unspecified. -@end deffn - - execl -@c snarfed from posix.c:860 -@deffn primitive execl filename . args -Executes the file named by @var{path} as a new process image. -The remaining arguments are supplied to the process; from a C program -they are accessable as the @code{argv} argument to @code{main}. -Conventionally the first @var{arg} is the same as @var{path}. -All arguments must be strings. - -If @var{arg} is missing, @var{path} is executed with a null -argument list, which may have system-dependent side-effects. - -This procedure is currently implemented using the @code{execv} system -call, but we call it @code{execl} because of its Scheme calling interface. -@end deffn - - execlp -@c snarfed from posix.c:881 -@deffn primitive execlp filename . args -Similar to @code{execl}, however if -@var{filename} does not contain a slash -then the file to execute will be located by searching the -directories listed in the @code{PATH} environment variable. - -This procedure is currently implemented using the @code{execvp} system -call, but we call it @code{execlp} because of its Scheme calling interface. -@end deffn - - execle -@c snarfed from posix.c:932 -@deffn primitive execle filename env . args -Similar to @code{execl}, but the environment of the new process is -specified by @var{env}, which must be a list of strings as returned by the -@code{environ} procedure. - -This procedure is currently implemented using the @code{execve} system -call, but we call it @code{execle} because of its Scheme calling interface. -@end deffn - - primitive-fork -@c snarfed from posix.c:956 -@deffn primitive primitive-fork -Creates a new "child" process by duplicating the current "parent" process. -In the child the return value is 0. In the parent the return value is -the integer process ID of the child. - -This procedure has been renamed from @code{fork} to avoid a naming conflict -with the scsh fork. -@end deffn - - uname -@c snarfed from posix.c:971 -@deffn primitive uname -Return an object with some information about the computer -system the program is running on. -@end deffn - - environ -@c snarfed from posix.c:1001 -@deffn primitive environ [env] -If @var{env} is omitted, return the current environment (in the -Unix sense) as a list of strings. Otherwise set the current -environment, which is also the default environment for child -processes, to the supplied list of strings. Each member of -@var{env} should be of the form @code{NAME=VALUE} and values of -@code{NAME} should not be duplicated. If @var{env} is supplied -then the return value is unspecified. -@end deffn - - tmpnam -@c snarfed from posix.c:1039 -@deffn primitive tmpnam -Return a name in the file system that does not match any -existing file. However there is no guarantee that another -process will not create the file after @code{tmpnam} is called. -Care should be taken if opening the file, e.g., use the -@code{O_EXCL} open flag or use @code{mkstemp!} instead. -@end deffn - - mkstemp! -@c snarfed from posix.c:1061 -@deffn primitive mkstemp! tmpl -Create a new unique file in the file system and returns a new -buffered port open for reading and writing to the file. -@var{tmpl} is a string specifying where the file should be -created: it must end with @code{XXXXXX} and will be changed in -place to return the name of the temporary file. -@end deffn - - utime -@c snarfed from posix.c:1087 -@deffn primitive utime pathname [actime [modtime]] -@code{utime} sets the access and modification times for the -file named by @var{path}. If @var{actime} or @var{modtime} is -not supplied, then the current time is used. @var{actime} and -@var{modtime} must be integer time values as returned by the -@code{current-time} procedure. -@lisp -(utime "foo" (- (current-time) 3600)) -@end lisp -will set the access time to one hour in the past and the -modification time to the current time. -@end deffn - - access? -@c snarfed from posix.c:1136 -@deffn primitive access? path how -Return @code{#t} if @var{path} corresponds to an existing file -and the current process has the type of access specified by -@var{how}, otherwise @code{#f}. @var{how} should be specified -using the values of the variables listed below. Multiple -values can be combined using a bitwise or, in which case -@code{#t} will only be returned if all accesses are granted. - -Permissions are checked using the real id of the current -process, not the effective id, although it's the effective id -which determines whether the access would actually be granted. - -@defvar R_OK -test for read permission. -@end defvar -@defvar W_OK -test for write permission. -@end defvar -@defvar X_OK -test for execute permission. -@end defvar -@defvar F_OK -test for existence of the file. -@end defvar -@end deffn - - getpid -@c snarfed from posix.c:1151 -@deffn primitive getpid -Return an integer representing the current process ID. -@end deffn - - putenv -@c snarfed from posix.c:1168 -@deffn primitive putenv str -Modifies the environment of the current process, which is -also the default environment inherited by child processes. - -If @var{string} is of the form @code{NAME=VALUE} then it will be written -directly into the environment, replacing any existing environment string -with -name matching @code{NAME}. If @var{string} does not contain an equal -sign, then any existing string with name matching @var{string} will -be removed. - -The return value is unspecified. -@end deffn - - setlocale -@c snarfed from posix.c:1199 -@deffn primitive setlocale category [locale] -If @var{locale} is omitted, return the current value of the -specified locale category as a system-dependent string. -@var{category} should be specified using the values -@code{LC_COLLATE}, @code{LC_ALL} etc. - -Otherwise the specified locale category is set to the string -@var{locale} and the new value is returned as a -system-dependent string. If @var{locale} is an empty string, -the locale will be set using envirionment variables. -@end deffn - - mknod -@c snarfed from posix.c:1240 -@deffn primitive mknod path type perms dev -Creates a new special file, such as a file corresponding to a device. -@var{path} specifies the name of the file. @var{type} should -be one of the following symbols: -regular, directory, symlink, block-special, char-special, -fifo, or socket. @var{perms} (an integer) specifies the file permissions. -@var{dev} (an integer) specifies which device the special file refers -to. Its exact interpretation depends on the kind of special file -being created. - -E.g., -@lisp -(mknod "/dev/fd0" 'block-special #o660 (+ (* 2 256) 2)) -@end lisp - -The return value is unspecified. -@end deffn - - nice -@c snarfed from posix.c:1287 -@deffn primitive nice incr -Increment the priority of the current process by @var{incr}. A higher -priority value means that the process runs less often. -The return value is unspecified. -@end deffn - - sync -@c snarfed from posix.c:1302 -@deffn primitive sync -Flush the operating system disk buffers. -The return value is unspecified. -@end deffn - - crypt -@c snarfed from posix.c:1315 -@deffn primitive crypt key salt -Encrypt @var{key} using @var{salt} as the salt value to the -crypt(3) library call -@end deffn - - chroot -@c snarfed from posix.c:1338 -@deffn primitive chroot path -Change the root directory to that specified in @var{path}. -This directory will be used for path names beginning with -@file{/}. The root directory is inherited by all children -of the current process. Only the superuser may change the -root directory. -@end deffn - - getlogin -@c snarfed from posix.c:1356 -@deffn primitive getlogin -Return a string containing the name of the user logged in on -the controlling terminal of the process, or @code{#f} if this -information cannot be obtained. -@end deffn - - cuserid -@c snarfed from posix.c:1374 -@deffn primitive cuserid -Return a string containing a user name associated with the -effective user id of the process. Return @code{#f} if this -information cannot be obtained. -@end deffn - - getpriority -@c snarfed from posix.c:1399 -@deffn primitive getpriority which who -Return the scheduling priority of the process, process group -or user, as indicated by @var{which} and @var{who}. @var{which} -is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} -or @code{PRIO_USER}, and @var{who} is interpreted relative to -@var{which} (a process identifier for @code{PRIO_PROCESS}, -process group identifier for @code{PRIO_PGRP}, and a user -identifier for @code{PRIO_USER}. A zero value of @var{who} -denotes the current process, process group, or user. Return -the highest priority (lowest numerical value) of any of the -specified processes. -@end deffn - - setpriority -@c snarfed from posix.c:1433 -@deffn primitive setpriority which who prio -Set the scheduling priority of the process, process group -or user, as indicated by @var{which} and @var{who}. @var{which} -is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} -or @code{PRIO_USER}, and @var{who} is interpreted relative to -@var{which} (a process identifier for @code{PRIO_PROCESS}, -process group identifier for @code{PRIO_PGRP}, and a user -identifier for @code{PRIO_USER}. A zero value of @var{who} -denotes the current process, process group, or user. -@var{prio} is a value in the range -20 and 20, the default -priority is 0; lower priorities cause more favorable -scheduling. Sets the priority of all of the specified -processes. Only the super-user may lower priorities. -The return value is not specified. -@end deffn - - getpass -@c snarfed from posix.c:1458 -@deffn primitive getpass prompt -Display @var{prompt} to the standard error output and read -a password from @file{/dev/tty}. If this file is not -accessible, it reads from standard input. The password may be -up to 127 characters in length. Additional characters and the -terminating newline character are discarded. While reading -the password, echoing and the generation of signals by special -characters is disabled. -@end deffn - - flock -@c snarfed from posix.c:1497 -@deffn primitive flock file operation -Apply or remove an advisory lock on an open file. -@var{operation} specifies the action to be done: -@table @code -@item LOCK_SH -Shared lock. More than one process may hold a shared lock -for a given file at a given time. -@item LOCK_EX -Exclusive lock. Only one process may hold an exclusive lock -for a given file at a given time. -@item LOCK_UN -Unlock the file. -@item LOCK_NB -Don't block when locking. May be specified by bitwise OR'ing -it to one of the other operations. -@end table -The return value is not specified. @var{file} may be an open -file descriptor or an open file descriptior port. -@end deffn - - sethostname -@c snarfed from posix.c:1523 -@deffn primitive sethostname name -Set the host name of the current processor to @var{name}. May -only be used by the superuser. The return value is not -specified. -@end deffn - - gethostname -@c snarfed from posix.c:1539 -@deffn primitive gethostname -Return the host name of the current processor. -@end deffn - print-options-interface -@c snarfed from print.c:142 +@c snarfed from print.c:141 @deffn primitive print-options-interface [setting] Option interface for the print options. Instead of using this procedure directly, use the procedures @@ -4332,76 +3257,76 @@ containing the formatted text. Does not add a trailing newline. @end deffn newline -@c snarfed from print.c:974 +@c snarfed from print.c:995 @deffn primitive newline [port] Send a newline to @var{port}. @end deffn write-char -@c snarfed from print.c:989 +@c snarfed from print.c:1010 @deffn primitive write-char chr [port] Send character @var{chr} to @var{port}. @end deffn port-with-print-state -@c snarfed from print.c:1043 +@c snarfed from print.c:1064 @deffn primitive port-with-print-state port pstate Create a new port which behaves like @var{port}, but with an included print state @var{pstate}. @end deffn get-print-state -@c snarfed from print.c:1058 +@c snarfed from print.c:1079 @deffn primitive get-print-state port Return the print state of the port @var{port}. If @var{port} has no associated print state, @code{#f} is returned. @end deffn procedure-properties -@c snarfed from procprop.c:180 +@c snarfed from procprop.c:176 @deffn primitive procedure-properties proc Return @var{obj}'s property list. @end deffn set-procedure-properties! -@c snarfed from procprop.c:193 +@c snarfed from procprop.c:189 @deffn primitive set-procedure-properties! proc new_val Set @var{obj}'s property list to @var{alist}. @end deffn procedure-property -@c snarfed from procprop.c:206 +@c snarfed from procprop.c:202 @deffn primitive procedure-property p k Return the property of @var{obj} with name @var{key}. @end deffn set-procedure-property! -@c snarfed from procprop.c:229 +@c snarfed from procprop.c:225 @deffn primitive set-procedure-property! p k v In @var{obj}'s property list, set the property named @var{key} to @var{value}. @end deffn procedure? -@c snarfed from procs.c:196 +@c snarfed from procs.c:195 @deffn primitive procedure? obj Return @code{#t} if @var{obj} is a procedure. @end deffn closure? -@c snarfed from procs.c:223 +@c snarfed from procs.c:222 @deffn primitive closure? obj Return @code{#t} if @var{obj} is a closure. @end deffn thunk? -@c snarfed from procs.c:232 +@c snarfed from procs.c:231 @deffn primitive thunk? obj Return @code{#t} if @var{obj} is a thunk. @end deffn procedure-documentation -@c snarfed from procs.c:282 +@c snarfed from procs.c:281 @deffn primitive procedure-documentation proc Return the documentation string associated with @code{proc}. By convention, if a procedure contains more than one expression and the @@ -4410,28 +3335,28 @@ documentation for that procedure. @end deffn procedure-with-setter? -@c snarfed from procs.c:318 +@c snarfed from procs.c:317 @deffn primitive procedure-with-setter? obj Return @code{#t} if @var{obj} is a procedure with an associated setter procedure. @end deffn make-procedure-with-setter -@c snarfed from procs.c:328 +@c snarfed from procs.c:327 @deffn primitive make-procedure-with-setter procedure setter Create a new procedure which behaves like @var{procedure}, but with the associated setter @var{setter}. @end deffn procedure -@c snarfed from procs.c:347 +@c snarfed from procs.c:346 @deffn primitive procedure proc Return the procedure of @var{proc}, which must be either a procedure with setter, or an operator struct. @end deffn primitive-make-property -@c snarfed from properties.c:66 +@c snarfed from properties.c:64 @deffn primitive primitive-make-property not_found_proc Create a @dfn{property token} that can be used with @code{primitive-property-ref} and @code{primitive-property-set!}. @@ -4440,7 +3365,7 @@ See @code{primitive-property-ref} for the significance of @end deffn primitive-property-ref -@c snarfed from properties.c:84 +@c snarfed from properties.c:82 @deffn primitive primitive-property-ref prop obj Return the property @var{prop} of @var{obj}. When no value has yet been associated with @var{prop} and @var{obj}, call @@ -4452,90 +3377,19 @@ default value of @var{prop}. @end deffn primitive-property-set! -@c snarfed from properties.c:115 +@c snarfed from properties.c:113 @deffn primitive primitive-property-set! prop obj val Associate @var{code} with @var{prop} and @var{obj}. @end deffn primitive-property-del! -@c snarfed from properties.c:136 +@c snarfed from properties.c:134 @deffn primitive primitive-property-del! prop obj Remove any value associated with @var{prop} and @var{obj}. @end deffn - array-fill! -@c snarfed from ramap.c:467 -@deffn primitive array-fill! ra fill -Stores @var{fill} in every element of @var{array}. The value returned -is unspecified. -@end deffn - - array-copy-in-order! -@c snarfed from ramap.c:832 -@deffn primitive array-copy-in-order! -scm_array_copy_x -@end deffn - - array-copy! -@c snarfed from ramap.c:841 -@deffn primitive array-copy! src dst -@deffnx primitive array-copy-in-order! src dst -Copies every element from vector or array @var{source} to the -corresponding element of @var{destination}. @var{destination} must have -the same rank as @var{source}, and be at least as large in each -dimension. The order is unspecified. -@end deffn - - array-map-in-order! -@c snarfed from ramap.c:1515 -@deffn primitive array-map-in-order! -scm_array_map_x -@end deffn - - array-map! -@c snarfed from ramap.c:1526 -@deffn primitive array-map! ra0 proc . lra -@deffnx primitive array-map-in-order! ra0 proc . lra -@var{array1}, @dots{} must have the same number of dimensions as -@var{array0} and have a range for each index which includes the range -for the corresponding index in @var{array0}. @var{proc} is applied to -each tuple of elements of @var{array1} @dots{} and the result is stored -as the corresponding element in @var{array0}. The value returned is -unspecified. The order of application is unspecified. -@end deffn - - array-for-each -@c snarfed from ramap.c:1673 -@deffn primitive array-for-each proc ra0 . lra -@var{proc} is applied to each tuple of elements of @var{array0} @dots{} -in row-major order. The value returned is unspecified. -@end deffn - - array-index-map! -@c snarfed from ramap.c:1701 -@deffn primitive array-index-map! ra proc -applies @var{proc} to the indices of each element of @var{array} in -turn, storing the result in the corresponding element. The value -returned and the order of application are unspecified. - -One can implement @var{array-indexes} as -@lisp -(define (array-indexes array) - (let ((ra (apply make-array #f (array-shape array)))) - (array-index-map! ra (lambda x x)) - ra)) -@end lisp -Another example: -@lisp -(define (apl:index-generator n) - (let ((v (make-uniform-vector n 1))) - (array-index-map! v (lambda (i) i)) - v)) -@end lisp -@end deffn - random -@c snarfed from random.c:370 +@c snarfed from random.c:376 @deffn primitive random n [state] Return a number in [0,N). @@ -4552,26 +3406,26 @@ as a side effect of the random operation. @end deffn copy-random-state -@c snarfed from random.c:393 +@c snarfed from random.c:399 @deffn primitive copy-random-state [state] Return a copy of the random state @var{state}. @end deffn seed->random-state -@c snarfed from random.c:405 +@c snarfed from random.c:411 @deffn primitive seed->random-state seed Return a new random state using @var{seed}. @end deffn random:uniform -@c snarfed from random.c:419 +@c snarfed from random.c:425 @deffn primitive random:uniform [state] Return a uniformly distributed inexact real random number in [0,1). @end deffn random:normal -@c snarfed from random.c:434 +@c snarfed from random.c:440 @deffn primitive random:normal [state] Return an inexact real in a normal distribution. The distribution used has mean 0 and standard deviation 1. For a @@ -4580,7 +3434,7 @@ normal distribution with mean m and standard deviation d use @end deffn random:solid-sphere! -@c snarfed from random.c:490 +@c snarfed from random.c:496 @deffn primitive random:solid-sphere! v [state] Fills vect with inexact real random numbers the sum of whose squares is less than 1.0. @@ -4591,7 +3445,7 @@ The sum of the squares of the numbers is returned. @end deffn random:hollow-sphere! -@c snarfed from random.c:513 +@c snarfed from random.c:519 @deffn primitive random:hollow-sphere! v [state] Fills vect with inexact real random numbers the sum of whose squares is equal to 1.0. @@ -4602,7 +3456,7 @@ unit n-shere. @end deffn random:normal-vector! -@c snarfed from random.c:531 +@c snarfed from random.c:537 @deffn primitive random:normal-vector! v [state] Fills vect with inexact real random numbers that are independent and standard normally distributed @@ -4610,7 +3464,7 @@ independent and standard normally distributed @end deffn random:exp -@c snarfed from random.c:556 +@c snarfed from random.c:562 @deffn primitive random:exp [state] Return an inexact real in an exponential distribution with mean 1. For an exponential distribution with mean u use (* u @@ -4661,7 +3515,7 @@ used. This function is equivalent to: @end deffn read-options-interface -@c snarfed from read.c:84 +@c snarfed from read.c:82 @deffn primitive read-options-interface [setting] Option interface for the read options. Instead of using this procedure directly, use the procedures @code{read-enable}, @@ -4669,7 +3523,7 @@ this procedure directly, use the procedures @code{read-enable}, @end deffn read -@c snarfed from read.c:104 +@c snarfed from read.c:102 @deffn primitive read [port] Read an s-expression from the input port @var{port}, or from the current input port if @var{port} is not specified. @@ -4677,7 +3531,7 @@ Any whitespace before the next token is discarded. @end deffn read-hash-extend -@c snarfed from read.c:746 +@c snarfed from read.c:769 @deffn primitive read-hash-extend chr proc Install the procedure @var{proc} for reading expressions starting with the character sequence @code{#} and @var{chr}. @@ -4686,67 +3540,8 @@ starting with the character sequence @code{#} and @var{chr}. returned will be the return value of @code{read}. @end deffn - regexp? -@c snarfed from regex-posix.c:139 -@deffn primitive regexp? obj -Return @code{#t} if @var{obj} is a compiled regular expression, -or @code{#f} otherwise. -@end deffn - - make-regexp -@c snarfed from regex-posix.c:184 -@deffn primitive make-regexp pat . flags -Compile the regular expression described by @var{pat}, and -return the compiled regexp structure. If @var{pat} does not -describe a legal regular expression, @code{make-regexp} throws -a @code{regular-expression-syntax} error. - -The @var{flags} arguments change the behavior of the compiled -regular expression. The following flags may be supplied: - -@table @code -@item regexp/icase -Consider uppercase and lowercase letters to be the same when -matching. -@item regexp/newline -If a newline appears in the target string, then permit the -@samp{^} and @samp{$} operators to match immediately after or -immediately before the newline, respectively. Also, the -@samp{.} and @samp{[^...]} operators will never match a newline -character. The intent of this flag is to treat the target -string as a buffer containing many lines of text, and the -regular expression as a pattern that may match a single one of -those lines. -@item regexp/basic -Compile a basic (``obsolete'') regexp instead of the extended -(``modern'') regexps that are the default. Basic regexps do -not consider @samp{|}, @samp{+} or @samp{?} to be special -characters, and require the @samp{@{...@}} and @samp{(...)} -metacharacters to be backslash-escaped (@pxref{Backslash -Escapes}). There are several other differences between basic -and extended regular expressions, but these are the most -significant. -@item regexp/extended -Compile an extended regular expression rather than a basic -regexp. This is the default behavior; this flag will not -usually be needed. If a call to @code{make-regexp} includes -both @code{regexp/basic} and @code{regexp/extended} flags, the -one which comes last will override the earlier one. -@end table -@end deffn - - regexp-exec -@c snarfed from regex-posix.c:232 -@deffn primitive regexp-exec rx str [start [flags]] -Match the compiled regular expression @var{rx} against -@code{str}. If the optional integer @var{start} argument is -provided, begin matching from that position in the string. -Return a match structure describing the results of the match, -or @code{#f} if no match could be found. -@end deffn - call-with-dynamic-root -@c snarfed from root.c:358 +@c snarfed from root.c:352 @deffn primitive call-with-dynamic-root thunk handler Evaluate @code{(thunk)} in a new dynamic context, returning its value. @@ -4793,7 +3588,7 @@ be under a new dynamic root.) @end deffn dynamic-root -@c snarfed from root.c:371 +@c snarfed from root.c:365 @deffn primitive dynamic-root Return an object representing the current dynamic root. @@ -4803,11 +3598,13 @@ in no way depend on this. @end deffn read-string!/partial -@c snarfed from rw.c:110 +@c snarfed from rw.c:121 @deffn primitive read-string!/partial str [port_or_fdes [start [end]]] -Read characters from an fport or file descriptor into a -string @var{str}. This procedure is scsh-compatible -and can efficiently read large strings. It will: +Read characters from a port or file descriptor into a +string @var{str}. A port must have an underlying file +descriptor --- a so-called fport. This procedure is +scsh-compatible and can efficiently read large strings. +It will: @itemize @item @@ -4819,12 +3616,16 @@ defaults to 0 and @var{end} defaults to use the current input port if @var{port_or_fdes} is not supplied. @item -read any characters that are currently available, -without waiting for the rest (short reads are possible). - +return fewer than the requested number of characters in some +cases, e.g., on end of file, if interrupted by a signal, or if +not all the characters are immediately available. @item -wait for as long as it needs to for the first character to -become available, unless the port is in non-blocking mode +wait indefinitely for some input if no characters are +currently available, +unless the port is in non-blocking mode. +@item +read characters from the port's input buffers if available, +instead from the underlying file descriptor. @item return @code{#f} if end-of-file is encountered before reading any characters, otherwise return the number of characters @@ -4834,12 +3635,58 @@ return 0 if the port is in non-blocking mode and no characters are immediately available. @item return 0 if the request is for 0 bytes, with no -end-of-file check +end-of-file check. +@end itemize +@end deffn + + write-string/partial +@c snarfed from rw.c:215 +@deffn primitive write-string/partial str [port_or_fdes [start [end]]] +Write characters from a string @var{str} to a port or file +descriptor. A port must have an underlying file descriptor +--- a so-called fport. This procedure is +scsh-compatible and can efficiently write large strings. +It will: + +@itemize +@item +attempt to write the entire string, unless the @var{start} +and/or @var{end} arguments are supplied. i.e., @var{start} +defaults to 0 and @var{end} defaults to +@code{(string-length str)} +@item +use the current output port if @var{port_of_fdes} is not +supplied. +@item +in the case of a buffered port, store the characters in the +port's output buffer, if all will fit. If they will not fit +then any existing buffered characters will be flushed +before attempting +to write the new characters directly to the underlying file +descriptor. If the port is in non-blocking mode and +buffered characters can not be flushed immediately, then an +@code{EAGAIN} system-error exception will be raised (Note: +scsh does not support the use of non-blocking buffered ports.) +@item +write fewer than the requested number of +characters in some cases, e.g., if interrupted by a signal or +if not all of the output can be accepted immediately. +@item +wait indefinitely for at least one character +from @var{str} to be accepted by the port, unless the port is +in non-blocking mode. +@item +return the number of characters accepted by the port. +@item +return 0 if the port is in non-blocking mode and can not accept +at least one character from @var{str} immediately +@item +return 0 immediately if the request size is 0 bytes. @end itemize @end deffn sigaction -@c snarfed from scmsigs.c:201 +@c snarfed from scmsigs.c:211 @deffn primitive sigaction signum [handler [flags]] Install or report the signal handler for a specified signal. @@ -4870,14 +3717,14 @@ structures. @end deffn restore-signals -@c snarfed from scmsigs.c:360 +@c snarfed from scmsigs.c:374 @deffn primitive restore-signals Return all signal handlers to the values they had before any call to @code{sigaction} was made. The return value is unspecified. @end deffn alarm -@c snarfed from scmsigs.c:399 +@c snarfed from scmsigs.c:413 @deffn primitive alarm i Set a timer to raise a @code{SIGALRM} signal after the specified number of seconds (an integer). It's advisable to install a signal @@ -4890,8 +3737,44 @@ if any. The new value replaces the previous alarm. If there was no previous alarm, the return value is zero. @end deffn + setitimer +@c snarfed from scmsigs.c:443 +@deffn primitive setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds +Set the timer specified by @var{which_timer} according to the given +@var{interval_seconds}, @var{interval_microseconds}, +@var{value_seconds}, and @var{value_microseconds} values. + +Return information about the timer's previous setting. +Errors are handled as described in the guile info pages under ``POSIX +Interface Conventions''. + +The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, +and @code{ITIMER_PROF}. + +The return value will be a list of two cons pairs representing the +current state of the given timer. The first pair is the seconds and +microseconds of the timer @code{it_interval}, and the second pair is +the seconds and microseconds of the timer @code{it_value}. +@end deffn + + getitimer +@c snarfed from scmsigs.c:484 +@deffn primitive getitimer which_timer +Return information about the timer specified by @var{which_timer} +Errors are handled as described in the guile info pages under ``POSIX +Interface Conventions''. + +The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, +and @code{ITIMER_PROF}. + +The return value will be a list of two cons pairs representing the +current state of the given timer. The first pair is the seconds and +microseconds of the timer @code{it_interval}, and the second pair is +the seconds and microseconds of the timer @code{it_value}. +@end deffn + pause -@c snarfed from scmsigs.c:414 +@c snarfed from scmsigs.c:511 @deffn primitive pause Pause the current process (thread?) until a signal arrives whose action is to either terminate the current process or invoke a @@ -4899,7 +3782,7 @@ handler procedure. The return value is unspecified. @end deffn sleep -@c snarfed from scmsigs.c:427 +@c snarfed from scmsigs.c:524 @deffn primitive sleep i Wait for the given number of seconds (an integer) or until a signal arrives. The return value is zero if the time elapses or the number @@ -4907,21 +3790,21 @@ of seconds remaining otherwise. @end deffn usleep -@c snarfed from scmsigs.c:445 +@c snarfed from scmsigs.c:542 @deffn primitive usleep i Sleep for I microseconds. @code{usleep} is not available on all platforms. @end deffn raise -@c snarfed from scmsigs.c:474 +@c snarfed from scmsigs.c:571 @deffn primitive raise sig Sends a specified signal @var{sig} to the current process, where @var{sig} is as described for the kill procedure. @end deffn system -@c snarfed from simpos.c:78 +@c snarfed from simpos.c:76 @deffn primitive system [cmd] Execute @var{cmd} using the operating system's "command processor". Under Unix this is usually the default shell @@ -4934,7 +3817,7 @@ indicating whether the command processor is available. @end deffn getenv -@c snarfed from simpos.c:106 +@c snarfed from simpos.c:103 @deffn primitive getenv nam Looks up the string @var{name} in the current environment. The return value is @code{#f} unless a string of the form @code{NAME=VALUE} is @@ -4942,431 +3825,15 @@ found, in which case the string @code{VALUE} is returned. @end deffn primitive-exit -@c snarfed from simpos.c:122 +@c snarfed from simpos.c:118 @deffn primitive primitive-exit [status] Terminate the current process without unwinding the Scheme stack. This is would typically be useful after a fork. The exit status is @var{status} if supplied, otherwise zero. @end deffn - htons -@c snarfed from socket.c:89 -@deffn primitive htons value -Convert a 16 bit quantity from host to network byte ordering. -@var{value} is packed into 2 bytes, which are then converted -and returned as a new integer. -@end deffn - - ntohs -@c snarfed from socket.c:106 -@deffn primitive ntohs value -Convert a 16 bit quantity from network to host byte ordering. -@var{value} is packed into 2 bytes, which are then converted -and returned as a new integer. -@end deffn - - htonl -@c snarfed from socket.c:123 -@deffn primitive htonl value -Convert a 32 bit quantity from host to network byte ordering. -@var{value} is packed into 4 bytes, which are then converted -and returned as a new integer. -@end deffn - - ntohl -@c snarfed from socket.c:136 -@deffn primitive ntohl value -Convert a 32 bit quantity from network to host byte ordering. -@var{value} is packed into 4 bytes, which are then converted -and returned as a new integer. -@end deffn - - inet-aton -@c snarfed from socket.c:156 -@deffn primitive inet-aton address -Convert an IPv4 Internet address from printable string -(dotted decimal notation) to an integer. E.g., - -@lisp -(inet-aton "127.0.0.1") @result{} 2130706433 -@end lisp -@end deffn - - inet-ntoa -@c snarfed from socket.c:176 -@deffn primitive inet-ntoa inetid -Convert an IPv4 Internet address to a printable -(dotted decimal notation) string. E.g., - -@lisp -(inet-ntoa 2130706433) @result{} "127.0.0.1" -@end lisp -@end deffn - - inet-netof -@c snarfed from socket.c:196 -@deffn primitive inet-netof address -Return the network number part of the given IPv4 -Internet address. E.g., - -@lisp -(inet-netof 2130706433) @result{} 127 -@end lisp -@end deffn - - inet-lnaof -@c snarfed from socket.c:214 -@deffn primitive inet-lnaof address -Return the local-address-with-network part of the given -IPv4 Internet address, using the obsolete class A/B/C system. -E.g., - -@lisp -(inet-lnaof 2130706433) @result{} 1 -@end lisp -@end deffn - - inet-makeaddr -@c snarfed from socket.c:232 -@deffn primitive inet-makeaddr net lna -Make an IPv4 Internet address by combining the network number -@var{net} with the local-address-within-network number -@var{lna}. E.g., - -@lisp -(inet-makeaddr 127 1) @result{} 2130706433 -@end lisp -@end deffn - - inet-pton -@c snarfed from socket.c:350 -@deffn primitive inet-pton family address -Convert a string containing a printable network address to -an integer address. Note that unlike the C version of this -function, -the result is an integer with normal host byte ordering. -@var{family} can be @code{AF_INET} or @code{AF_INET6}. E.g., - -@lisp -(inet-pton AF_INET "127.0.0.1") @result{} 2130706433 -(inet-pton AF_INET6 "::1") @result{} 1 -@end lisp -@end deffn - - inet-ntop -@c snarfed from socket.c:385 -@deffn primitive inet-ntop family address -Convert a network address into a printable string. -Note that unlike the C version of this function, -the input is an integer with normal host byte ordering. -@var{family} can be @code{AF_INET} or @code{AF_INET6}. E.g., - -@lisp -(inet-ntop AF_INET 2130706433) @result{} "127.0.0.1" -(inet-ntop AF_INET6 (- (expt 2 128) 1)) @result{} -ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff -@end lisp -@end deffn - - socket -@c snarfed from socket.c:430 -@deffn primitive socket family style proto -Return a new socket port of the type specified by @var{family}, -@var{style} and @var{proto}. All three parameters are -integers. Supported values for @var{family} are -@code{AF_UNIX}, @code{AF_INET} and @code{AF_INET6}. -Typical values for @var{style} are @code{SOCK_STREAM}, -@code{SOCK_DGRAM} and @code{SOCK_RAW}. - -@var{proto} can be obtained from a protocol name using -@code{getprotobyname}. A value of zero specifies the default -protocol, which is usually right. - -A single socket port cannot by used for communication until it -has been connected to another socket. -@end deffn - - socketpair -@c snarfed from socket.c:452 -@deffn primitive socketpair family style proto -Return a pair of connected (but unnamed) socket ports of the -type specified by @var{family}, @var{style} and @var{proto}. -Many systems support only socket pairs of the @code{AF_UNIX} -family. Zero is likely to be the only meaningful value for -@var{proto}. -@end deffn - - getsockopt -@c snarfed from socket.c:481 -@deffn primitive getsockopt sock level optname -Return the value of a particular socket option for the socket -port @var{sock}. @var{level} is an integer code for type of -option being requested, e.g., @code{SOL_SOCKET} for -socket-level options. @var{optname} is an integer code for the -option required and should be specified using one of the -symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc. - -The returned value is typically an integer but @code{SO_LINGER} -returns a pair of integers. -@end deffn - - setsockopt -@c snarfed from socket.c:549 -@deffn primitive setsockopt sock level optname value -Set the value of a particular socket option for the socket -port @var{sock}. @var{level} is an integer code for type of option -being set, e.g., @code{SOL_SOCKET} for socket-level options. -@var{optname} is an -integer code for the option to set and should be specified using one of -the symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc. -@var{value} is the value to which the option should be set. For -most options this must be an integer, but for @code{SO_LINGER} it must -be a pair. - -The return value is unspecified. -@end deffn - - shutdown -@c snarfed from socket.c:653 -@deffn primitive shutdown sock how -Sockets can be closed simply by using @code{close-port}. The -@code{shutdown} procedure allows reception or tranmission on a -connection to be shut down individually, according to the parameter -@var{how}: - -@table @asis -@item 0 -Stop receiving data for this socket. If further data arrives, reject it. -@item 1 -Stop trying to transmit data from this socket. Discard any -data waiting to be sent. Stop looking for acknowledgement of -data already sent; don't retransmit it if it is lost. -@item 2 -Stop both reception and transmission. -@end table - -The return value is unspecified. -@end deffn - - connect -@c snarfed from socket.c:797 -@deffn primitive connect sock fam address . args -Initiate a connection from a socket using a specified address -family to the address -specified by @var{address} and possibly @var{args}. -The format required for @var{address} -and @var{args} depends on the family of the socket. - -For a socket of family @code{AF_UNIX}, -only @var{address} is specified and must be a string with the -filename where the socket is to be created. - -For a socket of family @code{AF_INET}, -@var{address} must be an integer IPv4 host address and -@var{args} must be a single integer port number. - -For a socket of family @code{AF_INET6}, -@var{address} must be an integer IPv6 host address and -@var{args} may be up to three integers: -port [flowinfo] [scope_id], -where flowinfo and scope_id default to zero. - -The return value is unspecified. -@end deffn - - bind -@c snarfed from socket.c:857 -@deffn primitive bind sock fam address . args -Assign an address to the socket port @var{sock}. -Generally this only needs to be done for server sockets, -so they know where to look for incoming connections. A socket -without an address will be assigned one automatically when it -starts communicating. - -The format of @var{address} and @var{args} depends -on the family of the socket. - -For a socket of family @code{AF_UNIX}, only @var{address} -is specified and must be a string with the filename where -the socket is to be created. - -For a socket of family @code{AF_INET}, @var{address} -must be an integer IPv4 address and @var{args} -must be a single integer port number. - -The values of the following variables can also be used for -@var{address}: - -@defvar INADDR_ANY -Allow connections from any address. -@end defvar - -@defvar INADDR_LOOPBACK -The address of the local host using the loopback device. -@end defvar - -@defvar INADDR_BROADCAST -The broadcast address on the local network. -@end defvar - -@defvar INADDR_NONE -No address. -@end defvar - -For a socket of family @code{AF_INET6}, @var{address} -must be an integer IPv6 address and @var{args} -may be up to three integers: -port [flowinfo] [scope_id], -where flowinfo and scope_id default to zero. - -The return value is unspecified. -@end deffn - - listen -@c snarfed from socket.c:891 -@deffn primitive listen sock backlog -Enable @var{sock} to accept connection -requests. @var{backlog} is an integer specifying -the maximum length of the queue for pending connections. -If the queue fills, new clients will fail to connect until -the server calls @code{accept} to accept a connection from -the queue. - -The return value is unspecified. -@end deffn - - accept -@c snarfed from socket.c:997 -@deffn primitive accept sock -Accept a connection on a bound, listening socket. -If there -are no pending connections in the queue, wait until -one is available unless the non-blocking option has been -set on the socket. - -The return value is a -pair in which the @emph{car} is a new socket port for the -connection and -the @emph{cdr} is an object with address information about the -client which initiated the connection. - -@var{sock} does not become part of the -connection and will continue to accept new requests. -@end deffn - - getsockname -@c snarfed from socket.c:1024 -@deffn primitive getsockname sock -Return the address of @var{sock}, in the same form as the -object returned by @code{accept}. On many systems the address -of a socket in the @code{AF_FILE} namespace cannot be read. -@end deffn - - getpeername -@c snarfed from socket.c:1046 -@deffn primitive getpeername sock -Return the address that @var{sock} -is connected to, in the same form as the object returned by -@code{accept}. On many systems the address of a socket in the -@code{AF_FILE} namespace cannot be read. -@end deffn - - recv! -@c snarfed from socket.c:1081 -@deffn primitive recv! sock buf [flags] -Receive data from a socket port. -@var{sock} must already -be bound to the address from which data is to be received. -@var{buf} is a string into which -the data will be written. The size of @var{buf} limits -the amount of -data which can be received: in the case of packet -protocols, if a packet larger than this limit is encountered -then some data -will be irrevocably lost. - -The optional @var{flags} argument is a value or -bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. - -The value returned is the number of bytes read from the -socket. - -Note that the data is read directly from the socket file -descriptor: -any unread buffered port data is ignored. -@end deffn - - send -@c snarfed from socket.c:1114 -@deffn primitive send sock message [flags] -Transmit the string @var{message} on a socket port @var{sock}. -@var{sock} must already be bound to a destination address. The -value returned is the number of bytes transmitted -- -it's possible for -this to be less than the length of @var{message} -if the socket is -set to be non-blocking. The optional @var{flags} argument -is a value or -bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. - -Note that the data is written directly to the socket -file descriptor: -any unflushed buffered port data is ignored. -@end deffn - - recvfrom! -@c snarfed from socket.c:1154 -@deffn primitive recvfrom! sock str [flags [start [end]]] -Return data from the socket port @var{sock} and also -information about where the data was received from. -@var{sock} must already be bound to the address from which -data is to be received. @code{str}, is a string into which the -data will be written. The size of @var{str} limits the amount -of data which can be received: in the case of packet protocols, -if a packet larger than this limit is encountered then some -data will be irrevocably lost. - -The optional @var{flags} argument is a value or bitwise OR of -@code{MSG_OOB}, @code{MSG_PEEK}, @code{MSG_DONTROUTE} etc. - -The value returned is a pair: the @emph{car} is the number of -bytes read from the socket and the @emph{cdr} an address object -in the same form as returned by @code{accept}. The address -will given as @code{#f} if not available, as is usually the -case for stream sockets. - -The @var{start} and @var{end} arguments specify a substring of -@var{str} to which the data should be written. - -Note that the data is read directly from the socket file -descriptor: any unread buffered port data is ignored. -@end deffn - - sendto -@c snarfed from socket.c:1212 -@deffn primitive sendto sock message fam address . args_and_flags -Transmit the string @var{message} on the socket port -@var{sock}. The -destination address is specified using the @var{fam}, -@var{address} and -@var{args_and_flags} arguments, in a similar way to the -@code{connect} procedure. @var{args_and_flags} contains -the usual connection arguments optionally followed by -a flags argument, which is a value or -bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. - -The value returned is the number of bytes transmitted -- -it's possible for -this to be less than the length of @var{message} if the -socket is -set to be non-blocking. -Note that the data is written directly to the socket -file descriptor: -any unflushed buffered port data is ignored. -@end deffn - restricted-vector-sort! -@c snarfed from sort.c:425 +@c snarfed from sort.c:421 @deffn primitive restricted-vector-sort! vec less startpos endpos Sort the vector @var{vec}, using @var{less} for comparing the vector elements. @var{startpos} and @var{endpos} delimit @@ -5375,7 +3842,7 @@ is not specified. @end deffn sorted? -@c snarfed from sort.c:456 +@c snarfed from sort.c:452 @deffn primitive sorted? items less Return @code{#t} iff @var{items} is a list or a vector such that for all 1 <= i <= m, the predicate @var{less} returns true when @@ -5383,7 +3850,7 @@ applied to all elements i - 1 and i @end deffn merge -@c snarfed from sort.c:528 +@c snarfed from sort.c:524 @deffn primitive merge alist blist less Takes two lists @var{alist} and @var{blist} such that @code{(sorted? alist less?)} and @code{(sorted? blist less?)} and @@ -5394,7 +3861,7 @@ Note: this does _not_ accept vectors. @end deffn merge! -@c snarfed from sort.c:641 +@c snarfed from sort.c:637 @deffn primitive merge! alist blist less Takes two lists @var{alist} and @var{blist} such that @code{(sorted? alist less?)} and @code{(sorted? blist less?)} and @@ -5406,7 +3873,7 @@ Note: this does _not_ accept vectors. @end deffn sort! -@c snarfed from sort.c:717 +@c snarfed from sort.c:713 @deffn primitive sort! items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence @@ -5416,7 +3883,7 @@ This is not a stable sort. @end deffn sort -@c snarfed from sort.c:751 +@c snarfed from sort.c:747 @deffn primitive sort items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence @@ -5424,7 +3891,7 @@ elements. This is not a stable sort. @end deffn stable-sort! -@c snarfed from sort.c:847 +@c snarfed from sort.c:843 @deffn primitive stable-sort! items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. @@ -5434,7 +3901,7 @@ This is a stable sort. @end deffn stable-sort -@c snarfed from sort.c:887 +@c snarfed from sort.c:883 @deffn primitive stable-sort items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. @@ -5442,7 +3909,7 @@ This is a stable sort. @end deffn sort-list! -@c snarfed from sort.c:933 +@c snarfed from sort.c:929 @deffn primitive sort-list! items less Sort the list @var{items}, using @var{less} for comparing the list elements. The sorting is destructive, that means that the @@ -5451,82 +3918,104 @@ This is a stable sort. @end deffn sort-list -@c snarfed from sort.c:947 +@c snarfed from sort.c:943 @deffn primitive sort-list items less Sort the list @var{items}, using @var{less} for comparing the list elements. This is a stable sort. @end deffn source-properties -@c snarfed from srcprop.c:172 +@c snarfed from srcprop.c:170 @deffn primitive source-properties obj Return the source property association list of @var{obj}. @end deffn set-source-properties! -@c snarfed from srcprop.c:195 +@c snarfed from srcprop.c:193 @deffn primitive set-source-properties! obj plist Install the association list @var{plist} as the source property list for @var{obj}. @end deffn source-property -@c snarfed from srcprop.c:215 +@c snarfed from srcprop.c:213 @deffn primitive source-property obj key Return the source property specified by @var{key} from @var{obj}'s source property list. @end deffn set-source-property! -@c snarfed from srcprop.c:248 +@c snarfed from srcprop.c:246 @deffn primitive set-source-property! obj key datum Set the source property of object @var{obj}, which is specified by @var{key} to @var{datum}. Normally, the key will be a symbol. @end deffn stack? -@c snarfed from stacks.c:407 +@c snarfed from stacks.c:411 @deffn primitive stack? obj Return @code{#t} if @var{obj} is a calling stack. @end deffn make-stack -@c snarfed from stacks.c:421 +@c snarfed from stacks.c:442 @deffn primitive make-stack obj . args Create a new stack. If @var{obj} is @code{#t}, the current evaluation stack is used for creating the stack frames, otherwise the frames are taken from @var{obj} (which must be either a debug object or a continuation). -@var{args} must be a list of integers and specifies how the -resulting stack will be narrowed. + +@var{args} should be a list containing any combination of +integer, procedure and @code{#t} values. + +These values specify various ways of cutting away uninteresting +stack frames from the top and bottom of the stack that +@code{make-stack} returns. They come in pairs like this: +@code{(@var{inner_cut_1} @var{outer_cut_1} @var{inner_cut_2} +@var{outer_cut_2} @dots{})}. + +Each @var{inner_cut_N} can be @code{#t}, an integer, or a +procedure. @code{#t} means to cut away all frames up to but +excluding the first user module frame. An integer means to cut +away exactly that number of frames. A procedure means to cut +away all frames up to but excluding the application frame whose +procedure matches the specified one. + +Each @var{outer_cut_N} can be an integer or a procedure. An +integer means to cut away that number of frames. A procedure +means to cut away frames down to but excluding the application +frame whose procedure matches the specified one. + +If the @var{outer_cut_N} of the last pair is missing, it is +taken as 0. @end deffn stack-id -@c snarfed from stacks.c:512 +@c snarfed from stacks.c:534 @deffn primitive stack-id stack Return the identifier given to @var{stack} by @code{start-stack}. @end deffn stack-ref -@c snarfed from stacks.c:548 -@deffn primitive stack-ref stack i -Return the @var{i}'th frame from @var{stack}. +@c snarfed from stacks.c:575 +@deffn primitive stack-ref stack index +Return the @var{index}'th frame from @var{stack}. @end deffn stack-length -@c snarfed from stacks.c:562 +@c snarfed from stacks.c:591 @deffn primitive stack-length stack Return the length of @var{stack}. @end deffn frame? -@c snarfed from stacks.c:575 +@c snarfed from stacks.c:604 @deffn primitive frame? obj Return @code{#t} if @var{obj} is a stack frame. @end deffn last-stack-frame -@c snarfed from stacks.c:586 +@c snarfed from stacks.c:615 @deffn primitive last-stack-frame obj Return a stack which consists of a single frame, which is the last stack frame for @var{obj}. @var{obj} must be either a @@ -5534,77 +4023,77 @@ debug object or a continuation. @end deffn frame-number -@c snarfed from stacks.c:627 +@c snarfed from stacks.c:657 @deffn primitive frame-number frame Return the frame number of @var{frame}. @end deffn frame-source -@c snarfed from stacks.c:637 +@c snarfed from stacks.c:667 @deffn primitive frame-source frame Return the source of @var{frame}. @end deffn frame-procedure -@c snarfed from stacks.c:648 +@c snarfed from stacks.c:678 @deffn primitive frame-procedure frame Return the procedure for @var{frame}, or @code{#f} if no procedure is associated with @var{frame}. @end deffn frame-arguments -@c snarfed from stacks.c:660 +@c snarfed from stacks.c:690 @deffn primitive frame-arguments frame Return the arguments of @var{frame}. @end deffn frame-previous -@c snarfed from stacks.c:671 +@c snarfed from stacks.c:701 @deffn primitive frame-previous frame Return the previous frame of @var{frame}, or @code{#f} if @var{frame} is the first frame in its stack. @end deffn frame-next -@c snarfed from stacks.c:687 +@c snarfed from stacks.c:717 @deffn primitive frame-next frame Return the next frame of @var{frame}, or @code{#f} if @var{frame} is the last frame in its stack. @end deffn frame-real? -@c snarfed from stacks.c:702 +@c snarfed from stacks.c:732 @deffn primitive frame-real? frame Return @code{#t} if @var{frame} is a real frame. @end deffn frame-procedure? -@c snarfed from stacks.c:712 +@c snarfed from stacks.c:742 @deffn primitive frame-procedure? frame Return @code{#t} if a procedure is associated with @var{frame}. @end deffn frame-evaluating-args? -@c snarfed from stacks.c:722 +@c snarfed from stacks.c:752 @deffn primitive frame-evaluating-args? frame Return @code{#t} if @var{frame} contains evaluated arguments. @end deffn frame-overflow? -@c snarfed from stacks.c:732 +@c snarfed from stacks.c:762 @deffn primitive frame-overflow? frame Return @code{#t} if @var{frame} is an overflow frame. @end deffn get-internal-real-time -@c snarfed from stime.c:142 +@c snarfed from stime.c:143 @deffn primitive get-internal-real-time Return the number of time units since the interpreter was started. @end deffn times -@c snarfed from stime.c:187 +@c snarfed from stime.c:188 @deffn primitive times Return an object with information about real and processor time. The following procedures accept such an object as an @@ -5630,7 +4119,7 @@ terminated child processes. @end deffn get-internal-run-time -@c snarfed from stime.c:219 +@c snarfed from stime.c:220 @deffn primitive get-internal-run-time Return the number of time units of processor time used by the interpreter. Both @emph{system} and @emph{user} time are @@ -5638,14 +4127,14 @@ included but subprocesses are not. @end deffn current-time -@c snarfed from stime.c:229 +@c snarfed from stime.c:230 @deffn primitive current-time Return the number of seconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. @end deffn gettimeofday -@c snarfed from stime.c:247 +@c snarfed from stime.c:248 @deffn primitive gettimeofday Return a pair containing the number of seconds and microseconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note: @@ -5706,7 +4195,7 @@ is the formatted string. @end deffn strptime -@c snarfed from stime.c:669 +@c snarfed from stime.c:668 @deffn primitive strptime format string Performs the reverse action to @code{strftime}, parsing @var{string} according to the specification supplied in @@ -5727,21 +4216,14 @@ Return @code{#t} iff @var{obj} is a string, else returns @code{#f}. @end deffn - read-only-string? -@c snarfed from strings.c:78 -@deffn primitive read-only-string? obj -Return @code{#t} if @var{obj} is either a string or a symbol, -otherwise return @code{#f}. -@end deffn - list->string -@c snarfed from strings.c:87 +@c snarfed from strings.c:70 @deffn primitive list->string -scm_string +implemented by the C function "scm_string" @end deffn string -@c snarfed from strings.c:93 +@c snarfed from strings.c:76 @deffn primitive string . chrs @deffnx primitive list->string chrs Return a newly allocated string composed of the arguments, @@ -5749,7 +4231,7 @@ Return a newly allocated string composed of the arguments, @end deffn make-string -@c snarfed from strings.c:246 +@c snarfed from strings.c:214 @deffn primitive make-string k [chr] Return a newly allocated string of length @var{k}. If @var{chr} is given, then all elements of @@ -5758,20 +4240,20 @@ of the @var{string} are unspecified. @end deffn string-length -@c snarfed from strings.c:279 +@c snarfed from strings.c:247 @deffn primitive string-length string Return the number of characters in @var{string}. @end deffn string-ref -@c snarfed from strings.c:290 +@c snarfed from strings.c:258 @deffn primitive string-ref str k Return character @var{k} of @var{str} using zero-origin indexing. @var{k} must be a valid index of @var{str}. @end deffn string-set! -@c snarfed from strings.c:307 +@c snarfed from strings.c:275 @deffn primitive string-set! str k chr Store @var{chr} in element @var{k} of @var{str} and return an unspecified value. @var{k} must be a valid index of @@ -5779,7 +4261,7 @@ an unspecified value. @var{k} must be a valid index of @end deffn substring -@c snarfed from strings.c:330 +@c snarfed from strings.c:294 @deffn primitive substring str start [end] Return a newly allocated string formed from the characters of @var{str} beginning with index @var{start} (inclusive) and @@ -5791,26 +4273,14 @@ exact integers satisfying: @end deffn string-append -@c snarfed from strings.c:353 +@c snarfed from strings.c:320 @deffn primitive string-append . args Return a newly allocated string whose characters form the concatenation of the given strings, @var{args}. @end deffn - make-shared-substring -@c snarfed from strings.c:393 -@deffn primitive make-shared-substring str [start [end]] -Return a shared substring of @var{str}. The arguments are the -same as for the @code{substring} function: the shared substring -returned includes all of the text from @var{str} between -indexes @var{start} (inclusive) and @var{end} (exclusive). If -@var{end} is omitted, it defaults to the end of @var{str}. The -shared substring returned by @code{make-shared-substring} -occupies the same storage space as @var{str}. -@end deffn - string-index -@c snarfed from strop.c:116 +@c snarfed from strop.c:138 @deffn primitive string-index str chr [frm [to]] Return the index of the first occurrence of @var{chr} in @var{str}. The optional integer arguments @var{frm} and @@ -5831,7 +4301,7 @@ procedure essentially implements the @code{index} or @end deffn string-rindex -@c snarfed from strop.c:146 +@c snarfed from strop.c:168 @deffn primitive string-rindex str chr [frm [to]] Like @code{string-index}, but search from the right of the string rather than from the left. This procedure essentially @@ -5851,24 +4321,24 @@ the C library. @end deffn substring-move-left! -@c snarfed from strop.c:163 +@c snarfed from strop.c:185 @deffn primitive substring-move-left! -scm_substring_move_x +implemented by the C function "scm_substring_move_x" @end deffn substring-move-right! -@c snarfed from strop.c:164 +@c snarfed from strop.c:186 @deffn primitive substring-move-right! -scm_substring_move_x +implemented by the C function "scm_substring_move_x" @end deffn substring-move! -@c snarfed from strop.c:238 +@c snarfed from strop.c:260 @deffn primitive substring-move! str1 start1 end1 str2 start2 @deffnx primitive substring-move-left! str1 start1 end1 str2 start2 @deffnx primitive substring-move-right! str1 start1 end1 str2 start2 Copy the substring of @var{str1} bounded by @var{start1} and @var{end1} -into @var{str2} beginning at position @var{end2}. +into @var{str2} beginning at position @var{start2}. @code{substring-move-right!} begins copying from the rightmost character and moves left, and @code{substring-move-left!} copies from the leftmost character moving right. @@ -5886,7 +4356,7 @@ are different strings, it does not matter which function you use. @end deffn substring-fill! -@c snarfed from strop.c:274 +@c snarfed from strop.c:296 @deffn primitive substring-fill! str start end fill Change every character in @var{str} between @var{start} and @var{end} to @var{fill}. @@ -5900,7 +4370,7 @@ y @end deffn string-null? -@c snarfed from strop.c:299 +@c snarfed from strop.c:321 @deffn primitive string-null? str Return @code{#t} if @var{str}'s length is nonzero, and @code{#f} otherwise. @@ -5912,7 +4382,7 @@ y @result{} "foo" @end deffn string->list -@c snarfed from strop.c:313 +@c snarfed from strop.c:335 @deffn primitive string->list str Return a newly allocated list of the characters that make up the given string @var{str}. @code{string->list} and @@ -5921,20 +4391,20 @@ concerned. @end deffn string-copy -@c snarfed from strop.c:338 +@c snarfed from strop.c:364 @deffn primitive string-copy str Return a newly allocated copy of the given @var{string}. @end deffn string-fill! -@c snarfed from strop.c:351 +@c snarfed from strop.c:377 @deffn primitive string-fill! str chr Store @var{char} in every element of the given @var{string} and return an unspecified value. @end deffn string-upcase! -@c snarfed from strop.c:386 +@c snarfed from strop.c:412 @deffn primitive string-upcase! str Destructively upcase every character in @var{str} and return @var{str}. @@ -5946,14 +4416,14 @@ y @result{} "ARRDEFG" @end deffn string-upcase -@c snarfed from strop.c:399 +@c snarfed from strop.c:425 @deffn primitive string-upcase str Return a freshly allocated string containing the characters of @var{str} in upper case. @end deffn string-downcase! -@c snarfed from strop.c:431 +@c snarfed from strop.c:457 @deffn primitive string-downcase! str Destructively downcase every character in @var{str} and return @var{str}. @@ -5965,14 +4435,14 @@ y @result{} "arrdefg" @end deffn string-downcase -@c snarfed from strop.c:444 +@c snarfed from strop.c:470 @deffn primitive string-downcase str Return a freshly allocation string containing the characters in @var{str} in lower case. @end deffn string-capitalize! -@c snarfed from strop.c:488 +@c snarfed from strop.c:515 @deffn primitive string-capitalize! str Upcase the first character of every word in @var{str} destructively and return @var{str}. @@ -5985,15 +4455,38 @@ y @result{} "Hello World" @end deffn string-capitalize -@c snarfed from strop.c:502 +@c snarfed from strop.c:529 @deffn primitive string-capitalize str Return a freshly allocated string with the characters in @var{str}, where the first character of every word is capitalized. @end deffn + string-split +@c snarfed from strop.c:558 +@deffn primitive string-split str chr +Split the string @var{str} into the a list of the substrings delimited +by appearances of the character @var{chr}. Note that an empty substring +between separator characters will result in an empty string in the +result list. + +@lisp +(string-split "root:x:0:0:root:/root:/bin/bash" #:) +@result{} +("root" "x" "0" "0" "root" "/root" "/bin/bash") + +(string-split "::" #:) +@result{} +("" "" "") + +(string-split "" #:) +@result{} +("") +@end lisp +@end deffn + string-ci->symbol -@c snarfed from strop.c:516 +@c snarfed from strop.c:593 @deffn primitive string-ci->symbol str Return the symbol whose name is @var{str}. @var{str} is converted to lowercase before the conversion is done, if Guile @@ -6001,7 +4494,7 @@ is currently reading symbols case--insensitively. @end deffn string=? -@c snarfed from strorder.c:64 +@c snarfed from strorder.c:62 @deffn primitive string=? s1 s2 Lexicographic equality predicate; return @code{#t} if the two strings are the same length and contain the same characters in @@ -6014,7 +4507,7 @@ characters. @end deffn string-ci=? -@c snarfed from strorder.c:99 +@c snarfed from strorder.c:97 @deffn primitive string-ci=? s1 s2 Case-insensitive string equality predicate; return @code{#t} if the two strings are the same length and their component @@ -6023,35 +4516,35 @@ return @code{#f}. @end deffn string? -@c snarfed from strorder.c:184 +@c snarfed from strorder.c:182 @deffn primitive string>? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @var{s2}. @end deffn string>=? -@c snarfed from strorder.c:198 +@c snarfed from strorder.c:196 @deffn primitive string>=? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or equal to @var{s2}. @end deffn string-ci? -@c snarfed from strorder.c:267 +@c snarfed from strorder.c:265 @deffn primitive string-ci>? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @@ -6075,7 +4568,7 @@ Case insensitive lexicographic ordering predicate; return @end deffn string-ci>=? -@c snarfed from strorder.c:282 +@c snarfed from strorder.c:280 @deffn primitive string-ci>=? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or @@ -6083,7 +4576,7 @@ equal to @var{s2} regardless of case. @end deffn object->string -@c snarfed from strports.c:318 +@c snarfed from strports.c:321 @deffn primitive object->string obj [printer] Return a Scheme string obtained by printing @var{obj}. Printing function can be specified by the optional second @@ -6091,7 +4584,7 @@ argument @var{printer} (default: @code{write}). @end deffn call-with-output-string -@c snarfed from strports.c:352 +@c snarfed from strports.c:345 @deffn primitive call-with-output-string proc Calls the one-argument procedure @var{proc} with a newly created output port. When the function returns, the string composed of the characters @@ -6099,7 +4592,7 @@ written into the port is returned. @end deffn call-with-input-string -@c snarfed from strports.c:371 +@c snarfed from strports.c:364 @deffn primitive call-with-input-string string proc Calls the one-argument procedure @var{proc} with a newly created input port from which @var{string}'s contents may be @@ -6107,7 +4600,7 @@ read. The value yielded by the @var{proc} is returned. @end deffn open-input-string -@c snarfed from strports.c:384 +@c snarfed from strports.c:377 @deffn primitive open-input-string str Take a string and return an input port that delivers characters from the string. The port can be closed by @@ -6116,7 +4609,7 @@ by the garbage collector if it becomes inaccessible. @end deffn open-output-string -@c snarfed from strports.c:398 +@c snarfed from strports.c:391 @deffn primitive open-output-string Return an output port that will accumulate characters for retrieval by @code{get-output-string}. The port can be closed @@ -6126,7 +4619,7 @@ inaccessible. @end deffn get-output-string -@c snarfed from strports.c:415 +@c snarfed from strports.c:408 @deffn primitive get-output-string port Given an output port created by @code{open-output-string}, return a string consisting of the characters that have been @@ -6134,7 +4627,7 @@ output to the port so far. @end deffn eval-string -@c snarfed from strports.c:456 +@c snarfed from strports.c:467 @deffn primitive eval-string string Evaluate @var{string} as the text representation of a Scheme form or forms, and return whatever value they produce. @@ -6143,7 +4636,7 @@ procedure @code{interaction-environment}. @end deffn make-struct-layout -@c snarfed from struct.c:79 +@c snarfed from struct.c:77 @deffn primitive make-struct-layout fields Return a new structure layout object. @@ -6158,14 +4651,14 @@ indicate that the field is a tail-array. @end deffn struct? -@c snarfed from struct.c:246 +@c snarfed from struct.c:244 @deffn primitive struct? x Return @code{#t} iff @var{obj} is a structure object, else @code{#f}. @end deffn struct-vtable? -@c snarfed from struct.c:255 +@c snarfed from struct.c:253 @deffn primitive struct-vtable? x Return @code{#t} iff obj is a vtable structure. @end deffn @@ -6201,7 +4694,7 @@ For more information, see the documentation for @code{make-vtable-vtable}. @end deffn make-vtable-vtable -@c snarfed from struct.c:523 +@c snarfed from struct.c:524 @deffn primitive make-vtable-vtable user_fields tail_array_size . init Return a new, self-describing vtable structure. @@ -6262,7 +4755,7 @@ ball @result{} # @end deffn struct-ref -@c snarfed from struct.c:565 +@c snarfed from struct.c:567 @deffn primitive struct-ref handle pos @deffnx primitive struct-set! struct n value Access (or modify) the @var{n}th field of @var{struct}. @@ -6274,7 +4767,7 @@ integer value small enough to fit in one machine word. @end deffn struct-set! -@c snarfed from struct.c:643 +@c snarfed from struct.c:645 @deffn primitive struct-set! handle pos val Set the slot of the structure @var{handle} with index @var{pos} to @var{val}. Signal an error if the slot can not be written @@ -6282,42 +4775,42 @@ to. @end deffn struct-vtable -@c snarfed from struct.c:713 +@c snarfed from struct.c:715 @deffn primitive struct-vtable handle Return the vtable structure that describes the type of @var{struct}. @end deffn struct-vtable-tag -@c snarfed from struct.c:724 +@c snarfed from struct.c:726 @deffn primitive struct-vtable-tag handle Return the vtable tag of the structure @var{handle}. @end deffn struct-vtable-name -@c snarfed from struct.c:763 +@c snarfed from struct.c:765 @deffn primitive struct-vtable-name vtable Return the name of the vtable @var{vtable}. @end deffn set-struct-vtable-name! -@c snarfed from struct.c:773 +@c snarfed from struct.c:775 @deffn primitive set-struct-vtable-name! vtable name Set the name of the vtable @var{vtable} to @var{name}. @end deffn symbol? -@c snarfed from symbols.c:422 +@c snarfed from symbols.c:152 @deffn primitive symbol? obj Return @code{#t} if @var{obj} is a symbol, otherwise return @code{#f}. @end deffn symbol->string -@c snarfed from symbols.c:453 +@c snarfed from symbols.c:183 @deffn primitive symbol->string s Return the name of @var{symbol} as a string. If the symbol was part of an object returned as the value of a literal expression -(section @pxref{Literal expressions,,,r4rs, The Revised^4 +(section @pxref{Literal expressions,,,r5rs, The Revised^5 Report on Scheme}) or by a call to the @code{read} procedure, and its name contains alphabetic characters, then the string returned will contain characters in the implementation's @@ -6341,7 +4834,7 @@ standard case is lower case: @end deffn string->symbol -@c snarfed from symbols.c:483 +@c snarfed from symbols.c:216 @deffn primitive string->symbol string Return the symbol whose name is @var{string}. This procedure can create symbols with names containing special characters or @@ -6365,114 +4858,8 @@ standard case is lower case: @end lisp @end deffn - string->obarray-symbol -@c snarfed from symbols.c:505 -@deffn primitive string->obarray-symbol o s [softp] -Intern a new symbol in @var{obarray}, a symbol table, with name -@var{string}. - -If @var{obarray} is @code{#f}, use the default system symbol table. If -@var{obarray} is @code{#t}, the symbol should not be interned in any -symbol table; merely return the pair (@var{symbol} -. @var{#}). - -The @var{soft?} argument determines whether new symbol table entries -should be created when the specified symbol is not already present in -@var{obarray}. If @var{soft?} is specified and is a true value, then -new entries should not be added for symbols not already present in the -table; instead, simply return @code{#f}. -@end deffn - - intern-symbol -@c snarfed from symbols.c:537 -@deffn primitive intern-symbol o s -Add a new symbol to @var{obarray} with name @var{string}, bound to an -unspecified initial value. The symbol table is not modified if a symbol -with this name is already present. -@end deffn - - unintern-symbol -@c snarfed from symbols.c:574 -@deffn primitive unintern-symbol o s -Remove the symbol with name @var{string} from @var{obarray}. This -function returns @code{#t} if the symbol was present and @code{#f} -otherwise. -@end deffn - - symbol-binding -@c snarfed from symbols.c:615 -@deffn primitive symbol-binding o s -Look up in @var{obarray} the symbol whose name is @var{string}, and -return the value to which it is bound. If @var{obarray} is @code{#f}, -use the global symbol table. If @var{string} is not interned in -@var{obarray}, an error is signalled. -@end deffn - - symbol-interned? -@c snarfed from symbols.c:632 -@deffn primitive symbol-interned? o s -Return @code{#t} if @var{obarray} contains a symbol with name -@var{string}, and @code{#f} otherwise. -@end deffn - - symbol-bound? -@c snarfed from symbols.c:655 -@deffn primitive symbol-bound? o s -Return @code{#t} if @var{obarray} contains a symbol with name -@var{string} bound to a defined value. This differs from -@var{symbol-interned?} in that the mere mention of a symbol -usually causes it to be interned; @code{symbol-bound?} -determines whether a symbol has been given any meaningful -value. -@end deffn - - symbol-set! -@c snarfed from symbols.c:673 -@deffn primitive symbol-set! o s v -Find the symbol in @var{obarray} whose name is @var{string}, and rebind -it to @var{value}. An error is signalled if @var{string} is not present -in @var{obarray}. -@end deffn - - symbol-fref -@c snarfed from symbols.c:690 -@deffn primitive symbol-fref s -Return the contents of @var{symbol}'s @dfn{function slot}. -@end deffn - - symbol-pref -@c snarfed from symbols.c:701 -@deffn primitive symbol-pref s -Return the @dfn{property list} currently associated with @var{symbol}. -@end deffn - - symbol-fset! -@c snarfed from symbols.c:712 -@deffn primitive symbol-fset! s val -Change the binding of @var{symbol}'s function slot. -@end deffn - - symbol-pset! -@c snarfed from symbols.c:724 -@deffn primitive symbol-pset! s val -Change the binding of @var{symbol}'s property slot. -@end deffn - - symbol-hash -@c snarfed from symbols.c:738 -@deffn primitive symbol-hash symbol -Return a hash value for @var{symbol}. -@end deffn - - builtin-bindings -@c snarfed from symbols.c:775 -@deffn primitive builtin-bindings -Create and return a copy of the global symbol table, removing all -unbound symbols. -@end deffn - gensym -@c snarfed from symbols.c:796 +@c snarfed from symbols.c:235 @deffn primitive gensym [prefix] Create a new symbol with a name constructed from a prefix and a counter value. The string @var{prefix} can be specified as @@ -6481,20 +4868,38 @@ is increased by 1 at each call. There is no provision for resetting the counter. @end deffn - gentemp -@c snarfed from symbols.c:835 -@deffn primitive gentemp [prefix [obarray]] -Create a new symbol with a name unique in an obarray. -The name is constructed from an optional string @var{prefix} -and a counter value. The default prefix is @code{t}. The -@var{obarray} is specified as a second optional argument. -Default is the system obarray where all normal symbols are -interned. The counter is increased by 1 at each -call. There is no provision for resetting the counter. + symbol-hash +@c snarfed from symbols.c:266 +@deffn primitive symbol-hash symbol +Return a hash value for @var{symbol}. +@end deffn + + symbol-fref +@c snarfed from symbols.c:276 +@deffn primitive symbol-fref s +Return the contents of @var{symbol}'s @dfn{function slot}. +@end deffn + + symbol-pref +@c snarfed from symbols.c:287 +@deffn primitive symbol-pref s +Return the @dfn{property list} currently associated with @var{symbol}. +@end deffn + + symbol-fset! +@c snarfed from symbols.c:298 +@deffn primitive symbol-fset! s val +Change the binding of @var{symbol}'s function slot. +@end deffn + + symbol-pset! +@c snarfed from symbols.c:310 +@deffn primitive symbol-pset! s val +Change the binding of @var{symbol}'s property slot. @end deffn catch -@c snarfed from throw.c:535 +@c snarfed from throw.c:533 @deffn primitive catch key thunk handler Invoke @var{thunk} in the dynamic context of @var{handler} for exceptions matching @var{key}. If thunk throws to the symbol @@ -6517,15 +4922,16 @@ match this call to @code{catch}. @end deffn lazy-catch -@c snarfed from throw.c:562 +@c snarfed from throw.c:561 @deffn primitive lazy-catch key thunk handler This behaves exactly like @code{catch}, except that it does -not unwind the stack (this is the major difference), and if -handler returns, its value is returned from the throw. +not unwind the stack before invoking @var{handler}. +The @var{handler} procedure is not allowed to return: +it must throw to another catch, or otherwise exit non-locally. @end deffn throw -@c snarfed from throw.c:595 +@c snarfed from throw.c:594 @deffn primitive throw key . args Invoke the catch form matching @var{key}, passing @var{args} to the @var{handler}. @@ -6536,295 +4942,8 @@ Invoke the catch form matching @var{key}, passing @var{args} to the If there is no handler at all, Guile prints an error and then exits. @end deffn - uniform-vector-length -@c snarfed from unif.c:255 -@deffn primitive uniform-vector-length v -Return the number of elements in @var{uve}. -@end deffn - - array? -@c snarfed from unif.c:289 -@deffn primitive array? v [prot] -Return @code{#t} if the @var{obj} is an array, and @code{#f} if -not. The @var{prototype} argument is used with uniform arrays -and is described elsewhere. -@end deffn - - array-rank -@c snarfed from unif.c:360 -@deffn primitive array-rank ra -Return the number of dimensions of @var{obj}. If @var{obj} is -not an array, @code{0} is returned. -@end deffn - - array-dimensions -@c snarfed from unif.c:398 -@deffn primitive array-dimensions ra -@code{Array-dimensions} is similar to @code{array-shape} but replaces -elements with a @code{0} minimum with one greater than the maximum. So: -@lisp -(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5) -@end lisp -@end deffn - - shared-array-root -@c snarfed from unif.c:445 -@deffn primitive shared-array-root ra -Return the root vector of a shared array. -@end deffn - - shared-array-offset -@c snarfed from unif.c:456 -@deffn primitive shared-array-offset ra -Return the root vector index of the first element in the array. -@end deffn - - shared-array-increments -@c snarfed from unif.c:467 -@deffn primitive shared-array-increments ra -For each dimension, return the distance between elements in the root vector. -@end deffn - - dimensions->uniform-array -@c snarfed from unif.c:586 -@deffn primitive dimensions->uniform-array dims prot [fill] -@deffnx primitive make-uniform-vector length prototype [fill] -Create and return a uniform array or vector of type -corresponding to @var{prototype} with dimensions @var{dims} or -length @var{length}. If @var{fill} is supplied, it's used to -fill the array, otherwise @var{prototype} is used. -@end deffn - - make-shared-array -@c snarfed from unif.c:672 -@deffn primitive make-shared-array oldra mapfunc . dims -@code{make-shared-array} can be used to create shared subarrays of other -arrays. The @var{mapper} is a function that translates coordinates in -the new array into coordinates in the old array. A @var{mapper} must be -linear, and its range must stay within the bounds of the old array, but -it can be otherwise arbitrary. A simple example: -@lisp -(define fred (make-array #f 8 8)) -(define freds-diagonal - (make-shared-array fred (lambda (i) (list i i)) 8)) -(array-set! freds-diagonal 'foo 3) -(array-ref fred 3 3) @result{} foo -(define freds-center - (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) -(array-ref freds-center 0 0) @result{} foo -@end lisp -@end deffn - - transpose-array -@c snarfed from unif.c:804 -@deffn primitive transpose-array ra . args -Return an array sharing contents with @var{array}, but with -dimensions arranged in a different order. There must be one -@var{dim} argument for each dimension of @var{array}. -@var{dim0}, @var{dim1}, @dots{} should be integers between 0 -and the rank of the array to be returned. Each integer in that -range must appear at least once in the argument list. - -The values of @var{dim0}, @var{dim1}, @dots{} correspond to -dimensions in the array to be returned, their positions in the -argument list to dimensions of @var{array}. Several @var{dim}s -may have the same value, in which case the returned array will -have smaller rank than @var{array}. - -@lisp -(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d)) -(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d) -(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{} - #2((a 4) (b 5) (c 6)) -@end lisp -@end deffn - - enclose-array -@c snarfed from unif.c:913 -@deffn primitive enclose-array ra . axes -@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than -the rank of @var{array}. @var{enclose-array} returns an array -resembling an array of shared arrays. The dimensions of each shared -array are the same as the @var{dim}th dimensions of the original array, -the dimensions of the outer array are the same as those of the original -array that did not match a @var{dim}. - -An enclosed array is not a general Scheme array. Its elements may not -be set using @code{array-set!}. Two references to the same element of -an enclosed array will be @code{equal?} but will not in general be -@code{eq?}. The value returned by @var{array-prototype} when given an -enclosed array is unspecified. - -examples: -@lisp -(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{} - # - -(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{} - # -@end lisp -@end deffn - - array-in-bounds? -@c snarfed from unif.c:997 -@deffn primitive array-in-bounds? v . args -Return @code{#t} if its arguments would be acceptable to -@code{array-ref}. -@end deffn - - array-ref -@c snarfed from unif.c:1076 -@deffn primitive array-ref -scm_uniform_vector_ref -@end deffn - - uniform-vector-ref -@c snarfed from unif.c:1083 -@deffn primitive uniform-vector-ref v args -@deffnx primitive array-ref v . args -Return the element at the @code{(index1, index2)} element in -@var{array}. -@end deffn - - uniform-array-set1! -@c snarfed from unif.c:1252 -@deffn primitive uniform-array-set1! -scm_array_set_x -@end deffn - - array-set! -@c snarfed from unif.c:1261 -@deffn primitive array-set! v obj . args -@deffnx primitive uniform-array-set1! v obj args -Sets the element at the @code{(index1, index2)} element in @var{array} to -@var{new-value}. The value returned by array-set! is unspecified. -@end deffn - - array-contents -@c snarfed from unif.c:1376 -@deffn primitive array-contents ra [strict] -@deffnx primitive array-contents array strict -If @var{array} may be @dfn{unrolled} into a one dimensional shared array -without changing their order (last subscript changing fastest), then -@code{array-contents} returns that shared array, otherwise it returns -@code{#f}. All arrays made by @var{make-array} and -@var{make-uniform-array} may be unrolled, some arrays made by -@var{make-shared-array} may not be. - -If the optional argument @var{strict} is provided, a shared array will -be returned only if its elements are stored internally contiguous in -memory. -@end deffn - - uniform-array-read! -@c snarfed from unif.c:1490 -@deffn primitive uniform-array-read! ra [port_or_fd [start [end]]] -@deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end] -Attempts to read all elements of @var{ura}, in lexicographic order, as -binary objects from @var{port-or-fdes}. -If an end of file is encountered during -uniform-array-read! the objects up to that point only are put into @var{ura} -(starting at the beginning) and the remainder of the array is -unchanged. - -The optional arguments @var{start} and @var{end} allow -a specified region of a vector (or linearized array) to be read, -leaving the remainder of the vector unchanged. - -@code{uniform-array-read!} returns the number of objects read. -@var{port-or-fdes} may be omitted, in which case it defaults to the value -returned by @code{(current-input-port)}. -@end deffn - - uniform-array-write -@c snarfed from unif.c:1653 -@deffn primitive uniform-array-write v [port_or_fd [start [end]]] -@deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end] -Writes all elements of @var{ura} as binary objects to -@var{port-or-fdes}. - -The optional arguments @var{start} -and @var{end} allow -a specified region of a vector (or linearized array) to be written. - -The number of objects actually written is returned. -@var{port-or-fdes} may be -omitted, in which case it defaults to the value returned by -@code{(current-output-port)}. -@end deffn - - bit-count -@c snarfed from unif.c:1778 -@deffn primitive bit-count b bitvector -Return the number of occurrences of the boolean @var{b} in -@var{bitvector}. -@end deffn - - bit-position -@c snarfed from unif.c:1817 -@deffn primitive bit-position item v k -Return the minimum index of an occurrence of @var{bool} in -@var{bv} which is at least @var{k}. If no @var{bool} occurs -within the specified range @code{#f} is returned. -@end deffn - - bit-set*! -@c snarfed from unif.c:1885 -@deffn primitive bit-set*! v kv obj -If uve is a bit-vector @var{bv} and uve must be of the same -length. If @var{bool} is @code{#t}, uve is OR'ed into -@var{bv}; If @var{bool} is @code{#f}, the inversion of uve is -AND'ed into @var{bv}. - -If uve is a unsigned integer vector all the elements of uve -must be between 0 and the @code{length} of @var{bv}. The bits -of @var{bv} corresponding to the indexes in uve are set to -@var{bool}. The return value is unspecified. -@end deffn - - bit-count* -@c snarfed from unif.c:1939 -@deffn primitive bit-count* v kv obj -Return -@lisp -(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t). -@end lisp -@var{bv} is not modified. -@end deffn - - bit-invert! -@c snarfed from unif.c:2003 -@deffn primitive bit-invert! v -Modifies @var{bv} by replacing each element with its negation. -@end deffn - - array->list -@c snarfed from unif.c:2082 -@deffn primitive array->list v -Return a list consisting of all the elements, in order, of -@var{array}. -@end deffn - - list->uniform-array -@c snarfed from unif.c:2183 -@deffn primitive list->uniform-array ndim prot lst -@deffnx procedure list->uniform-vector prot lst -Return a uniform array of the type indicated by prototype -@var{prot} with elements the same as those of @var{lst}. -Elements must be of the appropriate type, no coercions are -done. -@end deffn - - array-prototype -@c snarfed from unif.c:2534 -@deffn primitive array-prototype ra -Return an object that would produce an array of the same type -as @var{array}, if used as the @var{prototype} for -@code{make-uniform-array}. -@end deffn - values -@c snarfed from values.c:80 +@c snarfed from values.c:77 @deffn primitive values . args Delivers all of its arguments to its continuation. Except for continuations created by the @code{call-with-values} procedure, @@ -6834,34 +4953,26 @@ were not created by @code{call-with-values} is unspecified. @end deffn make-variable -@c snarfed from variable.c:99 -@deffn primitive make-variable init [name_hint] -Return a variable object initialized to value @var{init}. -If given, uses @var{name-hint} as its internal (debugging) -name, otherwise just treat it as an anonymous variable. -Remember, of course, that multiple bindings to the same -variable may exist, so @var{name-hint} is just that---a hint. +@c snarfed from variable.c:81 +@deffn primitive make-variable init +Return a variable initialized to value @var{init}. @end deffn make-undefined-variable -@c snarfed from variable.c:119 -@deffn primitive make-undefined-variable [name_hint] -Return a variable object initialized to an undefined value. -If given, uses @var{name-hint} as its internal (debugging) -name, otherwise just treat it as an anonymous variable. -Remember, of course, that multiple bindings to the same -variable may exist, so @var{name-hint} is just that---a hint. +@c snarfed from variable.c:91 +@deffn primitive make-undefined-variable +Return a variable that is initially unbound. @end deffn variable? -@c snarfed from variable.c:136 +@c snarfed from variable.c:102 @deffn primitive variable? obj Return @code{#t} iff @var{obj} is a variable object, else -return @code{#f} +return @code{#f}. @end deffn variable-ref -@c snarfed from variable.c:148 +@c snarfed from variable.c:114 @deffn primitive variable-ref var Dereference @var{var} and return its value. @var{var} must be a variable object; see @code{make-variable} @@ -6869,43 +4980,35 @@ and @code{make-undefined-variable}. @end deffn variable-set! -@c snarfed from variable.c:162 +@c snarfed from variable.c:130 @deffn primitive variable-set! var val Set the value of the variable @var{var} to @var{val}. @var{var} must be a variable object, @var{val} can be any value. Return an unspecified value. @end deffn - builtin-variable -@c snarfed from variable.c:176 -@deffn primitive builtin-variable name -Return the built-in variable with the name @var{name}. -@var{name} must be a symbol (not a string). -Then use @code{variable-ref} to access its value. -@end deffn - variable-bound? -@c snarfed from variable.c:204 +@c snarfed from variable.c:142 @deffn primitive variable-bound? var Return @code{#t} iff @var{var} is bound to a value. Throws an error if @var{var} is not a variable object. @end deffn vector? -@c snarfed from vectors.c:142 +@c snarfed from vectors.c:58 @deffn primitive vector? obj Return @code{#t} if @var{obj} is a vector, otherwise return @code{#f}. @end deffn list->vector -@c snarfed from vectors.c:161 +@c snarfed from vectors.c:75 @deffn primitive list->vector -scm_vector +implemented by the C function "scm_vector" @end deffn vector -@c snarfed from vectors.c:178 +@c snarfed from vectors.c:92 @deffn primitive vector . l @deffnx primitive list->vector l Return a newly allocated vector whose elements contain the @@ -6917,7 +5020,7 @@ given arguments. Analogous to @code{list}. @end deffn make-vector -@c snarfed from vectors.c:264 +@c snarfed from vectors.c:178 @deffn primitive make-vector k [fill] Return a newly allocated vector of @var{k} elements. If a second argument is given, then each element is initialized to @@ -6926,7 +5029,7 @@ unspecified. @end deffn vector->list -@c snarfed from vectors.c:321 +@c snarfed from vectors.c:235 @deffn primitive vector->list v Return a newly allocated list of the objects contained in the elements of @var{vector}. @@ -6938,20 +5041,20 @@ elements of @var{vector}. @end deffn vector-fill! -@c snarfed from vectors.c:338 +@c snarfed from vectors.c:252 @deffn primitive vector-fill! v fill Store @var{fill} in every element of @var{vector}. The value returned by @code{vector-fill!} is unspecified. @end deffn vector-move-left! -@c snarfed from vectors.c:365 +@c snarfed from vectors.c:279 @deffn primitive vector-move-left! vec1 start1 end1 vec2 start2 Vector version of @code{substring-move-left!}. @end deffn vector-move-right! -@c snarfed from vectors.c:388 +@c snarfed from vectors.c:302 @deffn primitive vector-move-right! vec1 start1 end1 vec2 start2 Vector version of @code{substring-move-right!}. @end deffn @@ -6960,18 +5063,25 @@ Vector version of @code{substring-move-right!}. @c snarfed from version.c:59 @deffn primitive major-version Return a string containing Guile's major version number. -E.g., "1". +E.g., the 1 in "1.6.5". @end deffn minor-version -@c snarfed from version.c:71 +@c snarfed from version.c:72 @deffn primitive minor-version Return a string containing Guile's minor version number. -E.g., "3.5". +E.g., the 6 in "1.6.5". +@end deffn + + micro-version +@c snarfed from version.c:85 +@deffn primitive micro-version +Return a string containing Guile's micro version number. +E.g., the 5 in "1.6.5". @end deffn version -@c snarfed from version.c:90 +@c snarfed from version.c:105 @deffn primitive version @deffnx primitive major-version @deffnx primitive minor-version @@ -6986,7 +5096,7 @@ version numbers, respectively. @end deffn make-soft-port -@c snarfed from vports.c:190 +@c snarfed from vports.c:185 @deffn primitive make-soft-port pv modes Return a port capable of receiving or delivering characters as specified by the @var{modes} string (@pxref{File Ports, @@ -7012,7 +5122,7 @@ be procedures. Thunks 2 and 4 can instead be @code{#f} if there is no useful operation for them to perform. If thunk 3 returns @code{#f} or an @code{eof-object} -(@pxref{Input, eof-object?, ,r4rs, The Revised^4 Report on +(@pxref{Input, eof-object?, ,r5rs, The Revised^5 Report on Scheme}) it indicates that the port has reached end-of-file. For example: @@ -7032,7 +5142,7 @@ For example: @end deffn make-weak-vector -@c snarfed from weaks.c:63 +@c snarfed from weaks.c:115 @deffn primitive make-weak-vector size [fill] Return a weak vector with @var{size} elements. If the optional argument @var{fill} is given, all entries in the vector will be @@ -7041,13 +5151,13 @@ empty list. @end deffn list->weak-vector -@c snarfed from weaks.c:80 +@c snarfed from weaks.c:123 @deffn primitive list->weak-vector -scm_weak_vector +implemented by the C function "scm_weak_vector" @end deffn weak-vector -@c snarfed from weaks.c:88 +@c snarfed from weaks.c:131 @deffn primitive weak-vector . l @deffnx primitive list->weak-vector l Construct a weak vector from a list: @code{weak-vector} uses @@ -7057,14 +5167,14 @@ the same way @code{list->vector} would. @end deffn weak-vector? -@c snarfed from weaks.c:116 +@c snarfed from weaks.c:159 @deffn primitive weak-vector? obj Return @code{#t} if @var{obj} is a weak vector. Note that all weak hashes are also weak vectors. @end deffn make-weak-key-hash-table -@c snarfed from weaks.c:138 +@c snarfed from weaks.c:177 @deffn primitive make-weak-key-hash-table size @deffnx primitive make-weak-value-hash-table size @deffnx primitive make-doubly-weak-hash-table size @@ -7077,21 +5187,21 @@ would modify regular hash tables. (@pxref{Hash Tables}) @end deffn make-weak-value-hash-table -@c snarfed from weaks.c:155 +@c snarfed from weaks.c:188 @deffn primitive make-weak-value-hash-table size Return a hash table with weak values with @var{size} buckets. (@pxref{Hash Tables}) @end deffn make-doubly-weak-hash-table -@c snarfed from weaks.c:173 +@c snarfed from weaks.c:199 @deffn primitive make-doubly-weak-hash-table size Return a hash table with weak keys and values with @var{size} buckets. (@pxref{Hash Tables}) @end deffn weak-key-hash-table? -@c snarfed from weaks.c:192 +@c snarfed from weaks.c:213 @deffn primitive weak-key-hash-table? obj @deffnx primitive weak-value-hash-table? obj @deffnx primitive doubly-weak-hash-table? obj @@ -7101,13 +5211,1919 @@ nor a weak value hash table. @end deffn weak-value-hash-table? -@c snarfed from weaks.c:202 +@c snarfed from weaks.c:223 @deffn primitive weak-value-hash-table? obj Return @code{#t} if @var{obj} is a weak value hash table. @end deffn doubly-weak-hash-table? -@c snarfed from weaks.c:212 +@c snarfed from weaks.c:233 @deffn primitive doubly-weak-hash-table? obj Return @code{#t} if @var{obj} is a doubly weak hash table. @end deffn + + regexp? +@c snarfed from regex-posix.c:137 +@deffn primitive regexp? obj +Return @code{#t} if @var{obj} is a compiled regular expression, +or @code{#f} otherwise. +@end deffn + + make-regexp +@c snarfed from regex-posix.c:182 +@deffn primitive make-regexp pat . flags +Compile the regular expression described by @var{pat}, and +return the compiled regexp structure. If @var{pat} does not +describe a legal regular expression, @code{make-regexp} throws +a @code{regular-expression-syntax} error. + +The @var{flags} arguments change the behavior of the compiled +regular expression. The following flags may be supplied: + +@table @code +@item regexp/icase +Consider uppercase and lowercase letters to be the same when +matching. +@item regexp/newline +If a newline appears in the target string, then permit the +@samp{^} and @samp{$} operators to match immediately after or +immediately before the newline, respectively. Also, the +@samp{.} and @samp{[^...]} operators will never match a newline +character. The intent of this flag is to treat the target +string as a buffer containing many lines of text, and the +regular expression as a pattern that may match a single one of +those lines. +@item regexp/basic +Compile a basic (``obsolete'') regexp instead of the extended +(``modern'') regexps that are the default. Basic regexps do +not consider @samp{|}, @samp{+} or @samp{?} to be special +characters, and require the @samp{@{...@}} and @samp{(...)} +metacharacters to be backslash-escaped (@pxref{Backslash +Escapes}). There are several other differences between basic +and extended regular expressions, but these are the most +significant. +@item regexp/extended +Compile an extended regular expression rather than a basic +regexp. This is the default behavior; this flag will not +usually be needed. If a call to @code{make-regexp} includes +both @code{regexp/basic} and @code{regexp/extended} flags, the +one which comes last will override the earlier one. +@end table +@end deffn + + regexp-exec +@c snarfed from regex-posix.c:243 +@deffn primitive regexp-exec rx str [start [flags]] +Match the compiled regular expression @var{rx} against +@code{str}. If the optional integer @var{start} argument is +provided, begin matching from that position in the string. +Return a match structure describing the results of the match, +or @code{#f} if no match could be found. + +The @var{flags} arguments change the matching behavior. +The following flags may be supplied: + +@table @code +@item regexp/notbol +Operator @samp{^} always fails (unless @code{regexp/newline} +is used). Use this when the beginning of the string should +not be considered the beginning of a line. +@item regexp/noteol +Operator @samp{$} always fails (unless @code{regexp/newline} +is used). Use this when the end of the string should not be +considered the end of a line. +@end table +@end deffn + + array-fill! +@c snarfed from ramap.c:462 +@deffn primitive array-fill! ra fill +Stores @var{fill} in every element of @var{array}. The value returned +is unspecified. +@end deffn + + array-copy-in-order! +@c snarfed from ramap.c:827 +@deffn primitive array-copy-in-order! +implemented by the C function "scm_array_copy_x" +@end deffn + + array-copy! +@c snarfed from ramap.c:836 +@deffn primitive array-copy! src dst +@deffnx primitive array-copy-in-order! src dst +Copies every element from vector or array @var{source} to the +corresponding element of @var{destination}. @var{destination} must have +the same rank as @var{source}, and be at least as large in each +dimension. The order is unspecified. +@end deffn + + array-map-in-order! +@c snarfed from ramap.c:1510 +@deffn primitive array-map-in-order! +implemented by the C function "scm_array_map_x" +@end deffn + + array-map! +@c snarfed from ramap.c:1521 +@deffn primitive array-map! ra0 proc . lra +@deffnx primitive array-map-in-order! ra0 proc . lra +@var{array1}, @dots{} must have the same number of dimensions as +@var{array0} and have a range for each index which includes the range +for the corresponding index in @var{array0}. @var{proc} is applied to +each tuple of elements of @var{array1} @dots{} and the result is stored +as the corresponding element in @var{array0}. The value returned is +unspecified. The order of application is unspecified. +@end deffn + + array-for-each +@c snarfed from ramap.c:1668 +@deffn primitive array-for-each proc ra0 . lra +@var{proc} is applied to each tuple of elements of @var{array0} @dots{} +in row-major order. The value returned is unspecified. +@end deffn + + array-index-map! +@c snarfed from ramap.c:1696 +@deffn primitive array-index-map! ra proc +applies @var{proc} to the indices of each element of @var{array} in +turn, storing the result in the corresponding element. The value +returned and the order of application are unspecified. + +One can implement @var{array-indexes} as +@lisp +(define (array-indexes array) + (let ((ra (apply make-array #f (array-shape array)))) + (array-index-map! ra (lambda x x)) + ra)) +@end lisp +Another example: +@lisp +(define (apl:index-generator n) + (let ((v (make-uniform-vector n 1))) + (array-index-map! v (lambda (i) i)) + v)) +@end lisp +@end deffn + + uniform-vector-length +@c snarfed from unif.c:257 +@deffn primitive uniform-vector-length v +Return the number of elements in @var{uve}. +@end deffn + + array? +@c snarfed from unif.c:291 +@deffn primitive array? v [prot] +Return @code{#t} if the @var{obj} is an array, and @code{#f} if +not. The @var{prototype} argument is used with uniform arrays +and is described elsewhere. +@end deffn + + array-rank +@c snarfed from unif.c:362 +@deffn primitive array-rank ra +Return the number of dimensions of @var{obj}. If @var{obj} is +not an array, @code{0} is returned. +@end deffn + + array-dimensions +@c snarfed from unif.c:400 +@deffn primitive array-dimensions ra +@code{Array-dimensions} is similar to @code{array-shape} but replaces +elements with a @code{0} minimum with one greater than the maximum. So: +@lisp +(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5) +@end lisp +@end deffn + + shared-array-root +@c snarfed from unif.c:447 +@deffn primitive shared-array-root ra +Return the root vector of a shared array. +@end deffn + + shared-array-offset +@c snarfed from unif.c:458 +@deffn primitive shared-array-offset ra +Return the root vector index of the first element in the array. +@end deffn + + shared-array-increments +@c snarfed from unif.c:469 +@deffn primitive shared-array-increments ra +For each dimension, return the distance between elements in the root vector. +@end deffn + + dimensions->uniform-array +@c snarfed from unif.c:589 +@deffn primitive dimensions->uniform-array dims prot [fill] +@deffnx primitive make-uniform-vector length prototype [fill] +Create and return a uniform array or vector of type +corresponding to @var{prototype} with dimensions @var{dims} or +length @var{length}. If @var{fill} is supplied, it's used to +fill the array, otherwise @var{prototype} is used. +@end deffn + + make-shared-array +@c snarfed from unif.c:678 +@deffn primitive make-shared-array oldra mapfunc . dims +@code{make-shared-array} can be used to create shared subarrays of other +arrays. The @var{mapper} is a function that translates coordinates in +the new array into coordinates in the old array. A @var{mapper} must be +linear, and its range must stay within the bounds of the old array, but +it can be otherwise arbitrary. A simple example: +@lisp +(define fred (make-array #f 8 8)) +(define freds-diagonal + (make-shared-array fred (lambda (i) (list i i)) 8)) +(array-set! freds-diagonal 'foo 3) +(array-ref fred 3 3) @result{} foo +(define freds-center + (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) +(array-ref freds-center 0 0) @result{} foo +@end lisp +@end deffn + + transpose-array +@c snarfed from unif.c:810 +@deffn primitive transpose-array ra . args +Return an array sharing contents with @var{array}, but with +dimensions arranged in a different order. There must be one +@var{dim} argument for each dimension of @var{array}. +@var{dim0}, @var{dim1}, @dots{} should be integers between 0 +and the rank of the array to be returned. Each integer in that +range must appear at least once in the argument list. + +The values of @var{dim0}, @var{dim1}, @dots{} correspond to +dimensions in the array to be returned, their positions in the +argument list to dimensions of @var{array}. Several @var{dim}s +may have the same value, in which case the returned array will +have smaller rank than @var{array}. + +@lisp +(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d)) +(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d) +(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{} + #2((a 4) (b 5) (c 6)) +@end lisp +@end deffn + + enclose-array +@c snarfed from unif.c:919 +@deffn primitive enclose-array ra . axes +@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than +the rank of @var{array}. @var{enclose-array} returns an array +resembling an array of shared arrays. The dimensions of each shared +array are the same as the @var{dim}th dimensions of the original array, +the dimensions of the outer array are the same as those of the original +array that did not match a @var{dim}. + +An enclosed array is not a general Scheme array. Its elements may not +be set using @code{array-set!}. Two references to the same element of +an enclosed array will be @code{equal?} but will not in general be +@code{eq?}. The value returned by @var{array-prototype} when given an +enclosed array is unspecified. + +examples: +@lisp +(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{} + # + +(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{} + # +@end lisp +@end deffn + + array-in-bounds? +@c snarfed from unif.c:1003 +@deffn primitive array-in-bounds? v . args +Return @code{#t} if its arguments would be acceptable to +@code{array-ref}. +@end deffn + + array-ref +@c snarfed from unif.c:1082 +@deffn primitive array-ref +implemented by the C function "scm_uniform_vector_ref" +@end deffn + + uniform-vector-ref +@c snarfed from unif.c:1089 +@deffn primitive uniform-vector-ref v args +@deffnx primitive array-ref v . args +Return the element at the @code{(index1, index2)} element in +@var{array}. +@end deffn + + uniform-array-set1! +@c snarfed from unif.c:1258 +@deffn primitive uniform-array-set1! +implemented by the C function "scm_array_set_x" +@end deffn + + array-set! +@c snarfed from unif.c:1267 +@deffn primitive array-set! v obj . args +@deffnx primitive uniform-array-set1! v obj args +Sets the element at the @code{(index1, index2)} element in @var{array} to +@var{new-value}. The value returned by array-set! is unspecified. +@end deffn + + array-contents +@c snarfed from unif.c:1383 +@deffn primitive array-contents ra [strict] +@deffnx primitive array-contents array strict +If @var{array} may be @dfn{unrolled} into a one dimensional shared array +without changing their order (last subscript changing fastest), then +@code{array-contents} returns that shared array, otherwise it returns +@code{#f}. All arrays made by @var{make-array} and +@var{make-uniform-array} may be unrolled, some arrays made by +@var{make-shared-array} may not be. + +If the optional argument @var{strict} is provided, a shared array will +be returned only if its elements are stored internally contiguous in +memory. +@end deffn + + uniform-array-read! +@c snarfed from unif.c:1497 +@deffn primitive uniform-array-read! ra [port_or_fd [start [end]]] +@deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end] +Attempts to read all elements of @var{ura}, in lexicographic order, as +binary objects from @var{port-or-fdes}. +If an end of file is encountered during +uniform-array-read! the objects up to that point only are put into @var{ura} +(starting at the beginning) and the remainder of the array is +unchanged. + +The optional arguments @var{start} and @var{end} allow +a specified region of a vector (or linearized array) to be read, +leaving the remainder of the vector unchanged. + +@code{uniform-array-read!} returns the number of objects read. +@var{port-or-fdes} may be omitted, in which case it defaults to the value +returned by @code{(current-input-port)}. +@end deffn + + uniform-array-write +@c snarfed from unif.c:1662 +@deffn primitive uniform-array-write v [port_or_fd [start [end]]] +@deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end] +Writes all elements of @var{ura} as binary objects to +@var{port-or-fdes}. + +The optional arguments @var{start} +and @var{end} allow +a specified region of a vector (or linearized array) to be written. + +The number of objects actually written is returned. +@var{port-or-fdes} may be +omitted, in which case it defaults to the value returned by +@code{(current-output-port)}. +@end deffn + + bit-count +@c snarfed from unif.c:1789 +@deffn primitive bit-count b bitvector +Return the number of occurrences of the boolean @var{b} in +@var{bitvector}. +@end deffn + + bit-position +@c snarfed from unif.c:1828 +@deffn primitive bit-position item v k +Return the minimum index of an occurrence of @var{bool} in +@var{bv} which is at least @var{k}. If no @var{bool} occurs +within the specified range @code{#f} is returned. +@end deffn + + bit-set*! +@c snarfed from unif.c:1896 +@deffn primitive bit-set*! v kv obj +If uve is a bit-vector @var{bv} and uve must be of the same +length. If @var{bool} is @code{#t}, uve is OR'ed into +@var{bv}; If @var{bool} is @code{#f}, the inversion of uve is +AND'ed into @var{bv}. + +If uve is a unsigned integer vector all the elements of uve +must be between 0 and the @code{length} of @var{bv}. The bits +of @var{bv} corresponding to the indexes in uve are set to +@var{bool}. The return value is unspecified. +@end deffn + + bit-count* +@c snarfed from unif.c:1950 +@deffn primitive bit-count* v kv obj +Return +@lisp +(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t). +@end lisp +@var{bv} is not modified. +@end deffn + + bit-invert! +@c snarfed from unif.c:2014 +@deffn primitive bit-invert! v +Modifies @var{bv} by replacing each element with its negation. +@end deffn + + array->list +@c snarfed from unif.c:2093 +@deffn primitive array->list v +Return a list consisting of all the elements, in order, of +@var{array}. +@end deffn + + list->uniform-array +@c snarfed from unif.c:2194 +@deffn primitive list->uniform-array ndim prot lst +@deffnx procedure list->uniform-vector prot lst +Return a uniform array of the type indicated by prototype +@var{prot} with elements the same as those of @var{lst}. +Elements must be of the appropriate type, no coercions are +done. +@end deffn + + array-prototype +@c snarfed from unif.c:2545 +@deffn primitive array-prototype ra +Return an object that would produce an array of the same type +as @var{array}, if used as the @var{prototype} for +@code{make-uniform-array}. +@end deffn + + chown +@c snarfed from filesys.c:170 +@deffn primitive chown object owner group +Change the ownership and group of the file referred to by @var{object} to +the integer values @var{owner} and @var{group}. @var{object} can be +a string containing a file name or, if the platform +supports fchown, a port or integer file descriptor +which is open on the file. The return value +is unspecified. + +If @var{object} is a symbolic link, either the +ownership of the link or the ownership of the referenced file will be +changed depending on the operating system (lchown is +unsupported at present). If @var{owner} or @var{group} is specified +as @code{-1}, then that ID is not changed. +@end deffn + + chmod +@c snarfed from filesys.c:210 +@deffn primitive chmod object mode +Changes the permissions of the file referred to by @var{obj}. +@var{obj} can be a string containing a file name or a port or integer file +descriptor which is open on a file (in which case @code{fchmod} is used +as the underlying system call). +@var{mode} specifies +the new permissions as a decimal number, e.g., @code{(chmod "foo" #o755)}. +The return value is unspecified. +@end deffn + + umask +@c snarfed from filesys.c:243 +@deffn primitive umask [mode] +If @var{mode} is omitted, retuns a decimal number representing the current +file creation mask. Otherwise the file creation mask is set to +@var{mode} and the previous value is returned. + +E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18. +@end deffn + + open-fdes +@c snarfed from filesys.c:266 +@deffn primitive open-fdes path flags [mode] +Similar to @code{open} but return a file descriptor instead of +a port. +@end deffn + + open +@c snarfed from filesys.c:308 +@deffn primitive open path flags [mode] +Open the file named by @var{path} for reading and/or writing. +@var{flags} is an integer specifying how the file should be opened. +@var{mode} is an integer specifying the permission bits of the file, if +it needs to be created, before the umask is applied. The default is 666 +(Unix itself has no default). + +@var{flags} can be constructed by combining variables using @code{logior}. +Basic flags are: + +@defvar O_RDONLY +Open the file read-only. +@end defvar +@defvar O_WRONLY +Open the file write-only. +@end defvar +@defvar O_RDWR +Open the file read/write. +@end defvar +@defvar O_APPEND +Append to the file instead of truncating. +@end defvar +@defvar O_CREAT +Create the file if it does not already exist. +@end defvar + +See the Unix documentation of the @code{open} system call +for additional flags. +@end deffn + + close +@c snarfed from filesys.c:346 +@deffn primitive close fd_or_port +Similar to close-port (@pxref{Generic Port Operations, close-port}), +but also works on file descriptors. A side +effect of closing a file descriptor is that any ports using that file +descriptor are moved to a different file descriptor and have +their revealed counts set to zero. +@end deffn + + close-fdes +@c snarfed from filesys.c:374 +@deffn primitive close-fdes fd +A simple wrapper for the @code{close} system call. +Close file descriptor @var{fd}, which must be an integer. +Unlike close (@pxref{Ports and File Descriptors, close}), +the file descriptor will be closed even if a port is using it. +The return value is unspecified. +@end deffn + + stat +@c snarfed from filesys.c:577 +@deffn primitive stat object +Return an object containing various information about the file +determined by @var{obj}. @var{obj} can be a string containing +a file name or a port or integer file descriptor which is open +on a file (in which case @code{fstat} is used as the underlying +system call). + +The object returned by @code{stat} can be passed as a single +parameter to the following procedures, all of which return +integers: + +@table @code +@item stat:dev +The device containing the file. +@item stat:ino +The file serial number, which distinguishes this file from all +other files on the same device. +@item stat:mode +The mode of the file. This includes file type information and +the file permission bits. See @code{stat:type} and +@code{stat:perms} below. +@item stat:nlink +The number of hard links to the file. +@item stat:uid +The user ID of the file's owner. +@item stat:gid +The group ID of the file. +@item stat:rdev +Device ID; this entry is defined only for character or block +special files. +@item stat:size +The size of a regular file in bytes. +@item stat:atime +The last access time for the file. +@item stat:mtime +The last modification time for the file. +@item stat:ctime +The last modification time for the attributes of the file. +@item stat:blksize +The optimal block size for reading or writing the file, in +bytes. +@item stat:blocks +The amount of disk space that the file occupies measured in +units of 512 byte blocks. +@end table + +In addition, the following procedures return the information +from stat:mode in a more convenient form: + +@table @code +@item stat:type +A symbol representing the type of file. Possible values are +regular, directory, symlink, block-special, char-special, fifo, +socket and unknown +@item stat:perms +An integer representing the access permission bits. +@end table +@end deffn + + link +@c snarfed from filesys.c:640 +@deffn primitive link oldpath newpath +Creates a new name @var{newpath} in the file system for the +file named by @var{oldpath}. If @var{oldpath} is a symbolic +link, the link may or may not be followed depending on the +system. +@end deffn + + rename-file +@c snarfed from filesys.c:661 +@deffn primitive rename-file oldname newname +Renames the file specified by @var{oldname} to @var{newname}. +The return value is unspecified. +@end deffn + + delete-file +@c snarfed from filesys.c:688 +@deffn primitive delete-file str +Deletes (or "unlinks") the file specified by @var{path}. +@end deffn + + mkdir +@c snarfed from filesys.c:706 +@deffn primitive mkdir path [mode] +Create a new directory named by @var{path}. If @var{mode} is omitted +then the permissions of the directory file are set using the current +umask. Otherwise they are set to the decimal value specified with +@var{mode}. The return value is unspecified. +@end deffn + + rmdir +@c snarfed from filesys.c:734 +@deffn primitive rmdir path +Remove the existing directory named by @var{path}. The directory must +be empty for this to succeed. The return value is unspecified. +@end deffn + + directory-stream? +@c snarfed from filesys.c:759 +@deffn primitive directory-stream? obj +Return a boolean indicating whether @var{object} is a directory +stream as returned by @code{opendir}. +@end deffn + + opendir +@c snarfed from filesys.c:770 +@deffn primitive opendir dirname +Open the directory specified by @var{path} and return a directory +stream. +@end deffn + + readdir +@c snarfed from filesys.c:787 +@deffn primitive readdir port +Return (as a string) the next directory entry from the directory stream +@var{stream}. If there is no remaining entry to be read then the +end of file object is returned. +@end deffn + + rewinddir +@c snarfed from filesys.c:810 +@deffn primitive rewinddir port +Reset the directory port @var{stream} so that the next call to +@code{readdir} will return the first directory entry. +@end deffn + + closedir +@c snarfed from filesys.c:827 +@deffn primitive closedir port +Close the directory stream @var{stream}. +The return value is unspecified. +@end deffn + + chdir +@c snarfed from filesys.c:877 +@deffn primitive chdir str +Change the current working directory to @var{path}. +The return value is unspecified. +@end deffn + + getcwd +@c snarfed from filesys.c:893 +@deffn primitive getcwd +Return the name of the current working directory. +@end deffn + + select +@c snarfed from filesys.c:1089 +@deffn primitive select reads writes excepts [secs [usecs]] +This procedure has a variety of uses: waiting for the ability +to provide input, accept output, or the existance of +exceptional conditions on a collection of ports or file +descriptors, or waiting for a timeout to occur. +It also returns if interrupted by a signal. + +@var{reads}, @var{writes} and @var{excepts} can be lists or +vectors, with each member a port or a file descriptor. +The value returned is a list of three corresponding +lists or vectors containing only the members which meet the +specified requirement. The ability of port buffers to +provide input or accept output is taken into account. +Ordering of the input lists or vectors is not preserved. + +The optional arguments @var{secs} and @var{usecs} specify the +timeout. Either @var{secs} can be specified alone, as +either an integer or a real number, or both @var{secs} and +@var{usecs} can be specified as integers, in which case +@var{usecs} is an additional timeout expressed in +microseconds. If @var{secs} is omitted or is @code{#f} then +select will wait for as long as it takes for one of the other +conditions to be satisfied. + +The scsh version of @code{select} differs as follows: +Only vectors are accepted for the first three arguments. +The @var{usecs} argument is not supported. +Multiple values are returned instead of a list. +Duplicates in the input vectors appear only once in output. +An additional @code{select!} interface is provided. +@end deffn + + fcntl +@c snarfed from filesys.c:1235 +@deffn primitive fcntl object cmd [value] +Apply @var{command} to the specified file descriptor or the underlying +file descriptor of the specified port. @var{value} is an optional +integer argument. + +Values for @var{command} are: + +@table @code +@item F_DUPFD +Duplicate a file descriptor +@item F_GETFD +Get flags associated with the file descriptor. +@item F_SETFD +Set flags associated with the file descriptor to @var{value}. +@item F_GETFL +Get flags associated with the open file. +@item F_SETFL +Set flags associated with the open file to @var{value} +@item F_GETOWN +Get the process ID of a socket's owner, for @code{SIGIO} signals. +@item F_SETOWN +Set the process that owns a socket to @var{value}, for @code{SIGIO} signals. +@item FD_CLOEXEC +The value used to indicate the "close on exec" flag with @code{F_GETFL} or +@code{F_SETFL}. +@end table +@end deffn + + fsync +@c snarfed from filesys.c:1272 +@deffn primitive fsync object +Copies any unwritten data for the specified output file descriptor to disk. +If @var{port/fd} is a port, its buffer is flushed before the underlying +file descriptor is fsync'd. +The return value is unspecified. +@end deffn + + symlink +@c snarfed from filesys.c:1299 +@deffn primitive symlink oldpath newpath +Create a symbolic link named @var{path-to} with the value (i.e., pointing to) +@var{path-from}. The return value is unspecified. +@end deffn + + readlink +@c snarfed from filesys.c:1318 +@deffn primitive readlink path +Return the value of the symbolic link named by @var{path} (a +string), i.e., the file that the link points to. +@end deffn + + lstat +@c snarfed from filesys.c:1347 +@deffn primitive lstat str +Similar to @code{stat}, but does not follow symbolic links, i.e., +it will return information about a symbolic link itself, not the +file it points to. @var{path} must be a string. +@end deffn + + copy-file +@c snarfed from filesys.c:1371 +@deffn primitive copy-file oldfile newfile +Copy the file specified by @var{path-from} to @var{path-to}. +The return value is unspecified. +@end deffn + + dirname +@c snarfed from filesys.c:1416 +@deffn primitive dirname filename +Return the directory name component of the file name +@var{filename}. If @var{filename} does not contain a directory +component, @code{.} is returned. +@end deffn + + basename +@c snarfed from filesys.c:1459 +@deffn primitive basename filename [suffix] +Return the base name of the file name @var{filename}. The +base name is the file name without any directory components. +If @var{suffix} is privided, and is equal to the end of +@var{basename}, it is removed also. +@end deffn + + pipe +@c snarfed from posix.c:200 +@deffn primitive pipe +Return a newly created pipe: a pair of ports which are linked +together on the local machine. The @emph{car} is the input +port and the @emph{cdr} is the output port. Data written (and +flushed) to the output port can be read from the input port. +Pipes are commonly used for communication with a newly forked +child process. The need to flush the output port can be +avoided by making it unbuffered using @code{setvbuf}. + +Writes occur atomically provided the size of the data in bytes +is not greater than the value of @code{PIPE_BUF}. Note that +the output port is likely to block if too much data (typically +equal to @code{PIPE_BUF}) has been written but not yet read +from the input port. +@end deffn + + getgroups +@c snarfed from posix.c:221 +@deffn primitive getgroups +Return a vector of integers representing the current +supplimentary group IDs. +@end deffn + + getpw +@c snarfed from posix.c:254 +@deffn primitive getpw [user] +Look up an entry in the user database. @var{obj} can be an integer, +a string, or omitted, giving the behaviour of getpwuid, getpwnam +or getpwent respectively. +@end deffn + + setpw +@c snarfed from posix.c:307 +@deffn primitive setpw [arg] +If called with a true argument, initialize or reset the password data +stream. Otherwise, close the stream. The @code{setpwent} and +@code{endpwent} procedures are implemented on top of this. +@end deffn + + getgr +@c snarfed from posix.c:326 +@deffn primitive getgr [name] +Look up an entry in the group database. @var{obj} can be an integer, +a string, or omitted, giving the behaviour of getgrgid, getgrnam +or getgrent respectively. +@end deffn + + setgr +@c snarfed from posix.c:366 +@deffn primitive setgr [arg] +If called with a true argument, initialize or reset the group data +stream. Otherwise, close the stream. The @code{setgrent} and +@code{endgrent} procedures are implemented on top of this. +@end deffn + + kill +@c snarfed from posix.c:402 +@deffn primitive kill pid sig +Sends a signal to the specified process or group of processes. + +@var{pid} specifies the processes to which the signal is sent: + +@table @r +@item @var{pid} greater than 0 +The process whose identifier is @var{pid}. +@item @var{pid} equal to 0 +All processes in the current process group. +@item @var{pid} less than -1 +The process group whose identifier is -@var{pid} +@item @var{pid} equal to -1 +If the process is privileged, all processes except for some special +system processes. Otherwise, all processes with the current effective +user ID. +@end table + +@var{sig} should be specified using a variable corresponding to +the Unix symbolic name, e.g., + +@defvar SIGHUP +Hang-up signal. +@end defvar + +@defvar SIGINT +Interrupt signal. +@end defvar +@end deffn + + waitpid +@c snarfed from posix.c:455 +@deffn primitive waitpid pid [options] +This procedure collects status information from a child process which +has terminated or (optionally) stopped. Normally it will +suspend the calling process until this can be done. If more than one +child process is eligible then one will be chosen by the operating system. + +The value of @var{pid} determines the behaviour: + +@table @r +@item @var{pid} greater than 0 +Request status information from the specified child process. +@item @var{pid} equal to -1 or WAIT_ANY +Request status information for any child process. +@item @var{pid} equal to 0 or WAIT_MYPGRP +Request status information for any child process in the current process +group. +@item @var{pid} less than -1 +Request status information for any child process whose process group ID +is -@var{PID}. +@end table + +The @var{options} argument, if supplied, should be the bitwise OR of the +values of zero or more of the following variables: + +@defvar WNOHANG +Return immediately even if there are no child processes to be collected. +@end defvar + +@defvar WUNTRACED +Report status information for stopped processes as well as terminated +processes. +@end defvar + +The return value is a pair containing: + +@enumerate +@item +The process ID of the child process, or 0 if @code{WNOHANG} was +specified and no process was collected. +@item +The integer status value. +@end enumerate +@end deffn + + status:exit-val +@c snarfed from posix.c:483 +@deffn primitive status:exit-val status +Return the exit status value, as would be set if a process +ended normally through a call to @code{exit} or @code{_exit}, +if any, otherwise @code{#f}. +@end deffn + + status:term-sig +@c snarfed from posix.c:503 +@deffn primitive status:term-sig status +Return the signal number which terminated the process, if any, +otherwise @code{#f}. +@end deffn + + status:stop-sig +@c snarfed from posix.c:521 +@deffn primitive status:stop-sig status +Return the signal number which stopped the process, if any, +otherwise @code{#f}. +@end deffn + + getppid +@c snarfed from posix.c:541 +@deffn primitive getppid +Return an integer representing the process ID of the parent +process. +@end deffn + + getuid +@c snarfed from posix.c:553 +@deffn primitive getuid +Return an integer representing the current real user ID. +@end deffn + + getgid +@c snarfed from posix.c:564 +@deffn primitive getgid +Return an integer representing the current real group ID. +@end deffn + + geteuid +@c snarfed from posix.c:578 +@deffn primitive geteuid +Return an integer representing the current effective user ID. +If the system does not support effective IDs, then the real ID +is returned. @code{(feature? 'EIDs)} reports whether the +system supports effective IDs. +@end deffn + + getegid +@c snarfed from posix.c:595 +@deffn primitive getegid +Return an integer representing the current effective group ID. +If the system does not support effective IDs, then the real ID +is returned. @code{(feature? 'EIDs)} reports whether the +system supports effective IDs. +@end deffn + + setuid +@c snarfed from posix.c:611 +@deffn primitive setuid id +Sets both the real and effective user IDs to the integer @var{id}, provided +the process has appropriate privileges. +The return value is unspecified. +@end deffn + + setgid +@c snarfed from posix.c:625 +@deffn primitive setgid id +Sets both the real and effective group IDs to the integer @var{id}, provided +the process has appropriate privileges. +The return value is unspecified. +@end deffn + + seteuid +@c snarfed from posix.c:641 +@deffn primitive seteuid id +Sets the effective user ID to the integer @var{id}, provided the process +has appropriate privileges. If effective IDs are not supported, the +real ID is set instead -- @code{(feature? 'EIDs)} reports whether the +system supports effective IDs. +The return value is unspecified. +@end deffn + + setegid +@c snarfed from posix.c:667 +@deffn primitive setegid id +Sets the effective group ID to the integer @var{id}, provided the process +has appropriate privileges. If effective IDs are not supported, the +real ID is set instead -- @code{(feature? 'EIDs)} reports whether the +system supports effective IDs. +The return value is unspecified. +@end deffn + + getpgrp +@c snarfed from posix.c:691 +@deffn primitive getpgrp +Return an integer representing the current process group ID. +This is the POSIX definition, not BSD. +@end deffn + + setpgid +@c snarfed from posix.c:709 +@deffn primitive setpgid pid pgid +Move the process @var{pid} into the process group @var{pgid}. @var{pid} or +@var{pgid} must be integers: they can be zero to indicate the ID of the +current process. +Fails on systems that do not support job control. +The return value is unspecified. +@end deffn + + setsid +@c snarfed from posix.c:728 +@deffn primitive setsid +Creates a new session. The current process becomes the session leader +and is put in a new process group. The process will be detached +from its controlling terminal if it has one. +The return value is an integer representing the new process group ID. +@end deffn + + ttyname +@c snarfed from posix.c:743 +@deffn primitive ttyname port +Return a string with the name of the serial terminal device +underlying @var{port}. +@end deffn + + ctermid +@c snarfed from posix.c:767 +@deffn primitive ctermid +Return a string containing the file name of the controlling +terminal for the current process. +@end deffn + + tcgetpgrp +@c snarfed from posix.c:790 +@deffn primitive tcgetpgrp port +Return the process group ID of the foreground process group +associated with the terminal open on the file descriptor +underlying @var{port}. + +If there is no foreground process group, the return value is a +number greater than 1 that does not match the process group ID +of any existing process group. This can happen if all of the +processes in the job that was formerly the foreground job have +terminated, and no other job has yet been moved into the +foreground. +@end deffn + + tcsetpgrp +@c snarfed from posix.c:814 +@deffn primitive tcsetpgrp port pgid +Set the foreground process group ID for the terminal used by the file +descriptor underlying @var{port} to the integer @var{pgid}. +The calling process +must be a member of the same session as @var{pgid} and must have the same +controlling terminal. The return value is unspecified. +@end deffn + + execl +@c snarfed from posix.c:874 +@deffn primitive execl filename . args +Executes the file named by @var{path} as a new process image. +The remaining arguments are supplied to the process; from a C program +they are accessable as the @code{argv} argument to @code{main}. +Conventionally the first @var{arg} is the same as @var{path}. +All arguments must be strings. + +If @var{arg} is missing, @var{path} is executed with a null +argument list, which may have system-dependent side-effects. + +This procedure is currently implemented using the @code{execv} system +call, but we call it @code{execl} because of its Scheme calling interface. +@end deffn + + execlp +@c snarfed from posix.c:894 +@deffn primitive execlp filename . args +Similar to @code{execl}, however if +@var{filename} does not contain a slash +then the file to execute will be located by searching the +directories listed in the @code{PATH} environment variable. + +This procedure is currently implemented using the @code{execvp} system +call, but we call it @code{execlp} because of its Scheme calling interface. +@end deffn + + execle +@c snarfed from posix.c:944 +@deffn primitive execle filename env . args +Similar to @code{execl}, but the environment of the new process is +specified by @var{env}, which must be a list of strings as returned by the +@code{environ} procedure. + +This procedure is currently implemented using the @code{execve} system +call, but we call it @code{execle} because of its Scheme calling interface. +@end deffn + + primitive-fork +@c snarfed from posix.c:968 +@deffn primitive primitive-fork +Creates a new "child" process by duplicating the current "parent" process. +In the child the return value is 0. In the parent the return value is +the integer process ID of the child. + +This procedure has been renamed from @code{fork} to avoid a naming conflict +with the scsh fork. +@end deffn + + uname +@c snarfed from posix.c:988 +@deffn primitive uname +Return an object with some information about the computer +system the program is running on. +@end deffn + + environ +@c snarfed from posix.c:1018 +@deffn primitive environ [env] +If @var{env} is omitted, return the current environment (in the +Unix sense) as a list of strings. Otherwise set the current +environment, which is also the default environment for child +processes, to the supplied list of strings. Each member of +@var{env} should be of the form @code{NAME=VALUE} and values of +@code{NAME} should not be duplicated. If @var{env} is supplied +then the return value is unspecified. +@end deffn + + tmpnam +@c snarfed from posix.c:1056 +@deffn primitive tmpnam +Return a name in the file system that does not match any +existing file. However there is no guarantee that another +process will not create the file after @code{tmpnam} is called. +Care should be taken if opening the file, e.g., use the +@code{O_EXCL} open flag or use @code{mkstemp!} instead. +@end deffn + + mkstemp! +@c snarfed from posix.c:1082 +@deffn primitive mkstemp! tmpl +Create a new unique file in the file system and returns a new +buffered port open for reading and writing to the file. +@var{tmpl} is a string specifying where the file should be +created: it must end with @code{XXXXXX} and will be changed in +place to return the name of the temporary file. +@end deffn + + utime +@c snarfed from posix.c:1107 +@deffn primitive utime pathname [actime [modtime]] +@code{utime} sets the access and modification times for the +file named by @var{path}. If @var{actime} or @var{modtime} is +not supplied, then the current time is used. @var{actime} and +@var{modtime} must be integer time values as returned by the +@code{current-time} procedure. +@lisp +(utime "foo" (- (current-time) 3600)) +@end lisp +will set the access time to one hour in the past and the +modification time to the current time. +@end deffn + + access? +@c snarfed from posix.c:1155 +@deffn primitive access? path how +Return @code{#t} if @var{path} corresponds to an existing file +and the current process has the type of access specified by +@var{how}, otherwise @code{#f}. @var{how} should be specified +using the values of the variables listed below. Multiple +values can be combined using a bitwise or, in which case +@code{#t} will only be returned if all accesses are granted. + +Permissions are checked using the real id of the current +process, not the effective id, although it's the effective id +which determines whether the access would actually be granted. + +@defvar R_OK +test for read permission. +@end defvar +@defvar W_OK +test for write permission. +@end defvar +@defvar X_OK +test for execute permission. +@end defvar +@defvar F_OK +test for existence of the file. +@end defvar +@end deffn + + getpid +@c snarfed from posix.c:1169 +@deffn primitive getpid +Return an integer representing the current process ID. +@end deffn + + putenv +@c snarfed from posix.c:1186 +@deffn primitive putenv str +Modifies the environment of the current process, which is +also the default environment inherited by child processes. + +If @var{string} is of the form @code{NAME=VALUE} then it will be written +directly into the environment, replacing any existing environment string +with +name matching @code{NAME}. If @var{string} does not contain an equal +sign, then any existing string with name matching @var{string} will +be removed. + +The return value is unspecified. +@end deffn + + setlocale +@c snarfed from posix.c:1217 +@deffn primitive setlocale category [locale] +If @var{locale} is omitted, return the current value of the +specified locale category as a system-dependent string. +@var{category} should be specified using the values +@code{LC_COLLATE}, @code{LC_ALL} etc. + +Otherwise the specified locale category is set to the string +@var{locale} and the new value is returned as a +system-dependent string. If @var{locale} is an empty string, +the locale will be set using envirionment variables. +@end deffn + + mknod +@c snarfed from posix.c:1257 +@deffn primitive mknod path type perms dev +Creates a new special file, such as a file corresponding to a device. +@var{path} specifies the name of the file. @var{type} should +be one of the following symbols: +regular, directory, symlink, block-special, char-special, +fifo, or socket. @var{perms} (an integer) specifies the file permissions. +@var{dev} (an integer) specifies which device the special file refers +to. Its exact interpretation depends on the kind of special file +being created. + +E.g., +@lisp +(mknod "/dev/fd0" 'block-special #o660 (+ (* 2 256) 2)) +@end lisp + +The return value is unspecified. +@end deffn + + nice +@c snarfed from posix.c:1303 +@deffn primitive nice incr +Increment the priority of the current process by @var{incr}. A higher +priority value means that the process runs less often. +The return value is unspecified. +@end deffn + + sync +@c snarfed from posix.c:1318 +@deffn primitive sync +Flush the operating system disk buffers. +The return value is unspecified. +@end deffn + + crypt +@c snarfed from posix.c:1331 +@deffn primitive crypt key salt +Encrypt @var{key} using @var{salt} as the salt value to the +crypt(3) library call. +@end deffn + + chroot +@c snarfed from posix.c:1352 +@deffn primitive chroot path +Change the root directory to that specified in @var{path}. +This directory will be used for path names beginning with +@file{/}. The root directory is inherited by all children +of the current process. Only the superuser may change the +root directory. +@end deffn + + getlogin +@c snarfed from posix.c:1384 +@deffn primitive getlogin +Return a string containing the name of the user logged in on +the controlling terminal of the process, or @code{#f} if this +information cannot be obtained. +@end deffn + + cuserid +@c snarfed from posix.c:1402 +@deffn primitive cuserid +Return a string containing a user name associated with the +effective user id of the process. Return @code{#f} if this +information cannot be obtained. +@end deffn + + getpriority +@c snarfed from posix.c:1427 +@deffn primitive getpriority which who +Return the scheduling priority of the process, process group +or user, as indicated by @var{which} and @var{who}. @var{which} +is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} +or @code{PRIO_USER}, and @var{who} is interpreted relative to +@var{which} (a process identifier for @code{PRIO_PROCESS}, +process group identifier for @code{PRIO_PGRP}, and a user +identifier for @code{PRIO_USER}. A zero value of @var{who} +denotes the current process, process group, or user. Return +the highest priority (lowest numerical value) of any of the +specified processes. +@end deffn + + setpriority +@c snarfed from posix.c:1461 +@deffn primitive setpriority which who prio +Set the scheduling priority of the process, process group +or user, as indicated by @var{which} and @var{who}. @var{which} +is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} +or @code{PRIO_USER}, and @var{who} is interpreted relative to +@var{which} (a process identifier for @code{PRIO_PROCESS}, +process group identifier for @code{PRIO_PGRP}, and a user +identifier for @code{PRIO_USER}. A zero value of @var{who} +denotes the current process, process group, or user. +@var{prio} is a value in the range -20 and 20, the default +priority is 0; lower priorities cause more favorable +scheduling. Sets the priority of all of the specified +processes. Only the super-user may lower priorities. +The return value is not specified. +@end deffn + + getpass +@c snarfed from posix.c:1486 +@deffn primitive getpass prompt +Display @var{prompt} to the standard error output and read +a password from @file{/dev/tty}. If this file is not +accessible, it reads from standard input. The password may be +up to 127 characters in length. Additional characters and the +terminating newline character are discarded. While reading +the password, echoing and the generation of signals by special +characters is disabled. +@end deffn + + flock +@c snarfed from posix.c:1524 +@deffn primitive flock file operation +Apply or remove an advisory lock on an open file. +@var{operation} specifies the action to be done: +@table @code +@item LOCK_SH +Shared lock. More than one process may hold a shared lock +for a given file at a given time. +@item LOCK_EX +Exclusive lock. Only one process may hold an exclusive lock +for a given file at a given time. +@item LOCK_UN +Unlock the file. +@item LOCK_NB +Don't block when locking. May be specified by bitwise OR'ing +it to one of the other operations. +@end table +The return value is not specified. @var{file} may be an open +file descriptor or an open file descriptior port. +@end deffn + + sethostname +@c snarfed from posix.c:1550 +@deffn primitive sethostname name +Set the host name of the current processor to @var{name}. May +only be used by the superuser. The return value is not +specified. +@end deffn + + gethostname +@c snarfed from posix.c:1565 +@deffn primitive gethostname +Return the host name of the current processor. +@end deffn + + gethost +@c snarfed from net_db.c:149 +@deffn primitive gethost [host] +@deffnx procedure gethostbyname hostname +@deffnx procedure gethostbyaddr address +Look up a host by name or address, returning a host object. The +@code{gethost} procedure will accept either a string name or an integer +address; if given no arguments, it behaves like @code{gethostent} (see +below). If a name or address is supplied but the address can not be +found, an error will be thrown to one of the keys: +@code{host-not-found}, @code{try-again}, @code{no-recovery} or +@code{no-data}, corresponding to the equivalent @code{h_error} values. +Unusual conditions may result in errors thrown to the +@code{system-error} or @code{misc_error} keys. +@end deffn + + getnet +@c snarfed from net_db.c:228 +@deffn primitive getnet [net] +@deffnx procedure getnetbyname net-name +@deffnx procedure getnetbyaddr net-number +Look up a network by name or net number in the network database. The +@var{net-name} argument must be a string, and the @var{net-number} +argument must be an integer. @code{getnet} will accept either type of +argument, behaving like @code{getnetent} (see below) if no arguments are +given. +@end deffn + + getproto +@c snarfed from net_db.c:277 +@deffn primitive getproto [protocol] +@deffnx procedure getprotobyname name +@deffnx procedure getprotobynumber number +Look up a network protocol by name or by number. @code{getprotobyname} +takes a string argument, and @code{getprotobynumber} takes an integer +argument. @code{getproto} will accept either type, behaving like +@code{getprotoent} (see below) if no arguments are supplied. +@end deffn + + getserv +@c snarfed from net_db.c:343 +@deffn primitive getserv [name [protocol]] +@deffnx procedure getservbyname name protocol +@deffnx procedure getservbyport port protocol +Look up a network service by name or by service number, and return a +network service object. The @var{protocol} argument specifies the name +of the desired protocol; if the protocol found in the network service +database does not match this name, a system error is signalled. + +The @code{getserv} procedure will take either a service name or number +as its first argument; if given no arguments, it behaves like +@code{getservent} (see below). +@end deffn + + sethost +@c snarfed from net_db.c:380 +@deffn primitive sethost [stayopen] +If @var{stayopen} is omitted, this is equivalent to @code{endhostent}. +Otherwise it is equivalent to @code{sethostent stayopen}. +@end deffn + + setnet +@c snarfed from net_db.c:396 +@deffn primitive setnet [stayopen] +If @var{stayopen} is omitted, this is equivalent to @code{endnetent}. +Otherwise it is equivalent to @code{setnetent stayopen}. +@end deffn + + setproto +@c snarfed from net_db.c:412 +@deffn primitive setproto [stayopen] +If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}. +Otherwise it is equivalent to @code{setprotoent stayopen}. +@end deffn + + setserv +@c snarfed from net_db.c:428 +@deffn primitive setserv [stayopen] +If @var{stayopen} is omitted, this is equivalent to @code{endservent}. +Otherwise it is equivalent to @code{setservent stayopen}. +@end deffn + + htons +@c snarfed from socket.c:101 +@deffn primitive htons value +Convert a 16 bit quantity from host to network byte ordering. +@var{value} is packed into 2 bytes, which are then converted +and returned as a new integer. +@end deffn + + ntohs +@c snarfed from socket.c:118 +@deffn primitive ntohs value +Convert a 16 bit quantity from network to host byte ordering. +@var{value} is packed into 2 bytes, which are then converted +and returned as a new integer. +@end deffn + + htonl +@c snarfed from socket.c:135 +@deffn primitive htonl value +Convert a 32 bit quantity from host to network byte ordering. +@var{value} is packed into 4 bytes, which are then converted +and returned as a new integer. +@end deffn + + ntohl +@c snarfed from socket.c:148 +@deffn primitive ntohl value +Convert a 32 bit quantity from network to host byte ordering. +@var{value} is packed into 4 bytes, which are then converted +and returned as a new integer. +@end deffn + + inet-aton +@c snarfed from socket.c:168 +@deffn primitive inet-aton address +Convert an IPv4 Internet address from printable string +(dotted decimal notation) to an integer. E.g., + +@lisp +(inet-aton "127.0.0.1") @result{} 2130706433 +@end lisp +@end deffn + + inet-ntoa +@c snarfed from socket.c:187 +@deffn primitive inet-ntoa inetid +Convert an IPv4 Internet address to a printable +(dotted decimal notation) string. E.g., + +@lisp +(inet-ntoa 2130706433) @result{} "127.0.0.1" +@end lisp +@end deffn + + inet-netof +@c snarfed from socket.c:207 +@deffn primitive inet-netof address +Return the network number part of the given IPv4 +Internet address. E.g., + +@lisp +(inet-netof 2130706433) @result{} 127 +@end lisp +@end deffn + + inet-lnaof +@c snarfed from socket.c:225 +@deffn primitive inet-lnaof address +Return the local-address-with-network part of the given +IPv4 Internet address, using the obsolete class A/B/C system. +E.g., + +@lisp +(inet-lnaof 2130706433) @result{} 1 +@end lisp +@end deffn + + inet-makeaddr +@c snarfed from socket.c:243 +@deffn primitive inet-makeaddr net lna +Make an IPv4 Internet address by combining the network number +@var{net} with the local-address-within-network number +@var{lna}. E.g., + +@lisp +(inet-makeaddr 127 1) @result{} 2130706433 +@end lisp +@end deffn + + inet-pton +@c snarfed from socket.c:361 +@deffn primitive inet-pton family address +Convert a string containing a printable network address to +an integer address. Note that unlike the C version of this +function, +the result is an integer with normal host byte ordering. +@var{family} can be @code{AF_INET} or @code{AF_INET6}. E.g., + +@lisp +(inet-pton AF_INET "127.0.0.1") @result{} 2130706433 +(inet-pton AF_INET6 "::1") @result{} 1 +@end lisp +@end deffn + + inet-ntop +@c snarfed from socket.c:396 +@deffn primitive inet-ntop family address +Convert a network address into a printable string. +Note that unlike the C version of this function, +the input is an integer with normal host byte ordering. +@var{family} can be @code{AF_INET} or @code{AF_INET6}. E.g., + +@lisp +(inet-ntop AF_INET 2130706433) @result{} "127.0.0.1" +(inet-ntop AF_INET6 (- (expt 2 128) 1)) @result{} +ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +@end lisp +@end deffn + + socket +@c snarfed from socket.c:441 +@deffn primitive socket family style proto +Return a new socket port of the type specified by @var{family}, +@var{style} and @var{proto}. All three parameters are +integers. Supported values for @var{family} are +@code{AF_UNIX}, @code{AF_INET} and @code{AF_INET6}. +Typical values for @var{style} are @code{SOCK_STREAM}, +@code{SOCK_DGRAM} and @code{SOCK_RAW}. + +@var{proto} can be obtained from a protocol name using +@code{getprotobyname}. A value of zero specifies the default +protocol, which is usually right. + +A single socket port cannot by used for communication until it +has been connected to another socket. +@end deffn + + socketpair +@c snarfed from socket.c:463 +@deffn primitive socketpair family style proto +Return a pair of connected (but unnamed) socket ports of the +type specified by @var{family}, @var{style} and @var{proto}. +Many systems support only socket pairs of the @code{AF_UNIX} +family. Zero is likely to be the only meaningful value for +@var{proto}. +@end deffn + + getsockopt +@c snarfed from socket.c:492 +@deffn primitive getsockopt sock level optname +Return the value of a particular socket option for the socket +port @var{sock}. @var{level} is an integer code for type of +option being requested, e.g., @code{SOL_SOCKET} for +socket-level options. @var{optname} is an integer code for the +option required and should be specified using one of the +symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc. + +The returned value is typically an integer but @code{SO_LINGER} +returns a pair of integers. +@end deffn + + setsockopt +@c snarfed from socket.c:560 +@deffn primitive setsockopt sock level optname value +Set the value of a particular socket option for the socket +port @var{sock}. @var{level} is an integer code for type of option +being set, e.g., @code{SOL_SOCKET} for socket-level options. +@var{optname} is an +integer code for the option to set and should be specified using one of +the symbols @code{SO_DEBUG}, @code{SO_REUSEADDR} etc. +@var{value} is the value to which the option should be set. For +most options this must be an integer, but for @code{SO_LINGER} it must +be a pair. + +The return value is unspecified. +@end deffn + + shutdown +@c snarfed from socket.c:664 +@deffn primitive shutdown sock how +Sockets can be closed simply by using @code{close-port}. The +@code{shutdown} procedure allows reception or tranmission on a +connection to be shut down individually, according to the parameter +@var{how}: + +@table @asis +@item 0 +Stop receiving data for this socket. If further data arrives, reject it. +@item 1 +Stop trying to transmit data from this socket. Discard any +data waiting to be sent. Stop looking for acknowledgement of +data already sent; don't retransmit it if it is lost. +@item 2 +Stop both reception and transmission. +@end table + +The return value is unspecified. +@end deffn + + connect +@c snarfed from socket.c:808 +@deffn primitive connect sock fam address . args +Initiate a connection from a socket using a specified address +family to the address +specified by @var{address} and possibly @var{args}. +The format required for @var{address} +and @var{args} depends on the family of the socket. + +For a socket of family @code{AF_UNIX}, +only @var{address} is specified and must be a string with the +filename where the socket is to be created. + +For a socket of family @code{AF_INET}, +@var{address} must be an integer IPv4 host address and +@var{args} must be a single integer port number. + +For a socket of family @code{AF_INET6}, +@var{address} must be an integer IPv6 host address and +@var{args} may be up to three integers: +port [flowinfo] [scope_id], +where flowinfo and scope_id default to zero. + +The return value is unspecified. +@end deffn + + bind +@c snarfed from socket.c:868 +@deffn primitive bind sock fam address . args +Assign an address to the socket port @var{sock}. +Generally this only needs to be done for server sockets, +so they know where to look for incoming connections. A socket +without an address will be assigned one automatically when it +starts communicating. + +The format of @var{address} and @var{args} depends +on the family of the socket. + +For a socket of family @code{AF_UNIX}, only @var{address} +is specified and must be a string with the filename where +the socket is to be created. + +For a socket of family @code{AF_INET}, @var{address} +must be an integer IPv4 address and @var{args} +must be a single integer port number. + +The values of the following variables can also be used for +@var{address}: + +@defvar INADDR_ANY +Allow connections from any address. +@end defvar + +@defvar INADDR_LOOPBACK +The address of the local host using the loopback device. +@end defvar + +@defvar INADDR_BROADCAST +The broadcast address on the local network. +@end defvar + +@defvar INADDR_NONE +No address. +@end defvar + +For a socket of family @code{AF_INET6}, @var{address} +must be an integer IPv6 address and @var{args} +may be up to three integers: +port [flowinfo] [scope_id], +where flowinfo and scope_id default to zero. + +The return value is unspecified. +@end deffn + + listen +@c snarfed from socket.c:902 +@deffn primitive listen sock backlog +Enable @var{sock} to accept connection +requests. @var{backlog} is an integer specifying +the maximum length of the queue for pending connections. +If the queue fills, new clients will fail to connect until +the server calls @code{accept} to accept a connection from +the queue. + +The return value is unspecified. +@end deffn + + accept +@c snarfed from socket.c:1007 +@deffn primitive accept sock +Accept a connection on a bound, listening socket. +If there +are no pending connections in the queue, wait until +one is available unless the non-blocking option has been +set on the socket. + +The return value is a +pair in which the @emph{car} is a new socket port for the +connection and +the @emph{cdr} is an object with address information about the +client which initiated the connection. + +@var{sock} does not become part of the +connection and will continue to accept new requests. +@end deffn + + getsockname +@c snarfed from socket.c:1034 +@deffn primitive getsockname sock +Return the address of @var{sock}, in the same form as the +object returned by @code{accept}. On many systems the address +of a socket in the @code{AF_FILE} namespace cannot be read. +@end deffn + + getpeername +@c snarfed from socket.c:1056 +@deffn primitive getpeername sock +Return the address that @var{sock} +is connected to, in the same form as the object returned by +@code{accept}. On many systems the address of a socket in the +@code{AF_FILE} namespace cannot be read. +@end deffn + + recv! +@c snarfed from socket.c:1091 +@deffn primitive recv! sock buf [flags] +Receive data from a socket port. +@var{sock} must already +be bound to the address from which data is to be received. +@var{buf} is a string into which +the data will be written. The size of @var{buf} limits +the amount of +data which can be received: in the case of packet +protocols, if a packet larger than this limit is encountered +then some data +will be irrevocably lost. + +The optional @var{flags} argument is a value or +bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. + +The value returned is the number of bytes read from the +socket. + +Note that the data is read directly from the socket file +descriptor: +any unread buffered port data is ignored. +@end deffn + + send +@c snarfed from socket.c:1124 +@deffn primitive send sock message [flags] +Transmit the string @var{message} on a socket port @var{sock}. +@var{sock} must already be bound to a destination address. The +value returned is the number of bytes transmitted -- +it's possible for +this to be less than the length of @var{message} +if the socket is +set to be non-blocking. The optional @var{flags} argument +is a value or +bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. + +Note that the data is written directly to the socket +file descriptor: +any unflushed buffered port data is ignored. +@end deffn + + recvfrom! +@c snarfed from socket.c:1164 +@deffn primitive recvfrom! sock str [flags [start [end]]] +Return data from the socket port @var{sock} and also +information about where the data was received from. +@var{sock} must already be bound to the address from which +data is to be received. @code{str}, is a string into which the +data will be written. The size of @var{str} limits the amount +of data which can be received: in the case of packet protocols, +if a packet larger than this limit is encountered then some +data will be irrevocably lost. + +The optional @var{flags} argument is a value or bitwise OR of +@code{MSG_OOB}, @code{MSG_PEEK}, @code{MSG_DONTROUTE} etc. + +The value returned is a pair: the @emph{car} is the number of +bytes read from the socket and the @emph{cdr} an address object +in the same form as returned by @code{accept}. The address +will given as @code{#f} if not available, as is usually the +case for stream sockets. + +The @var{start} and @var{end} arguments specify a substring of +@var{str} to which the data should be written. + +Note that the data is read directly from the socket file +descriptor: any unread buffered port data is ignored. +@end deffn + + sendto +@c snarfed from socket.c:1222 +@deffn primitive sendto sock message fam address . args_and_flags +Transmit the string @var{message} on the socket port +@var{sock}. The +destination address is specified using the @var{fam}, +@var{address} and +@var{args_and_flags} arguments, in a similar way to the +@code{connect} procedure. @var{args_and_flags} contains +the usual connection arguments optionally followed by +a flags argument, which is a value or +bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. + +The value returned is the number of bytes transmitted -- +it's possible for +this to be less than the length of @var{message} if the +socket is +set to be non-blocking. +Note that the data is written directly to the socket +file descriptor: +any unflushed buffered port data is ignored. +@end deffn diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 52476be8e..cdd5ee958 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,61 @@ +2001-11-08 Neil Jerram + + * guile.texi (Top): Added new chapter `Programming Options'. + + * program.texi: New file. + + * Makefile.am (guile_TEXINFOS): Added program.texi. + +2001-11-07 Neil Jerram + + * scheme-memory.texi, scheme-io.texi, scheme-debug.texi, + scheme-data.texi, scheme-binding.texi, posix.texi, + new-docstrings.texi: Automatic updates from improved libguile + docstrings. + +2001-11-04 Neil Jerram + + * preface.texi: Use MANUAL_EDITION variable. + (Manual Layout): Updated to reflect reorg. + + * guile.texi (MANUAL_EDITION): New variable, with value + incremented from 1.0 to 1.1 to reflect the reorg described here. + (Top): Use MANUAL_EDITION variable. + + * scheme-indices.texi (R5RS Index, Guile Extensions Index): Use + @unnumbered rather than @chapter for these indices. + + * guile.texi (Top): A little top-level reshuffling, with the aims + that: (1) the `Guile Scheme' (reference) part of the manual + becomes the `Guile API Reference', and covers both Scheme and C + interfaces; (2) non-API-reference material such as the `Basic + Ideas in Scheme' chapter is collected together to form a new part + `Programming with Guile'. This new part will contain general + documentation on using and programming Guile in both Scheme and C, + including - for example - awareness of GC when C programming, how + to use the snarf macros, how to debug ... + (Top): Move inclusion of scheme-indices.texi so that all indices + appear together in the printed manual. + + * Makefile.am (guile_TEXINFOS): Removed appendices.texi, added + debugging.texi. + + * appendices.texi: Removed. + + * debugging.texi (Debugger User Interface): New file, same as the + material that used to be in appendices.texi, but now a chapter in + Part II rather than an appendix. + + * appendices.texi (Obtaining and Installing Guile): Moved to + become a chapter in ... + * intro.texi: ... Part I: Introduction to Guile. + + * scm.texi (I/O Extensions): Moved to become a section of ... + * scheme-io.texi (Input and Output): ... this chapter. + + * scm.texi (Handling Errors): Moved to become a section of ... + * scheme-control.texi (Control Mechanisms): ... this chapter. + 2001-11-06 Thien-Thi Nguyen * srfi-modules.texi (SRFI-19, SRFI-19 Constants, SRFI-19 Current diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index 99e06b0a8..5fbacd8a7 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -23,7 +23,7 @@ AUTOMAKE_OPTIONS = gnu info_TEXINFOS = guile.texi -guile_TEXINFOS = preface.texi intro.texi scheme-intro.texi \ +guile_TEXINFOS = preface.texi intro.texi program.texi scheme-intro.texi \ scheme-ideas.texi scheme-data.texi scheme-procedures.texi \ scheme-utility.texi scheme-binding.texi scheme-control.texi \ scheme-io.texi scheme-evaluation.texi scheme-memory.texi \ @@ -31,7 +31,7 @@ guile_TEXINFOS = preface.texi intro.texi scheme-intro.texi \ scheme-translation.texi scheme-debug.texi deprecated.texi \ scheme-reading.texi scheme-indices.texi slib.texi posix.texi \ expect.texi scsh.texi tcltk.texi scripts.texi gh.texi scm.texi \ - appendices.texi indices.texi script-getopt.texi data-rep.texi \ + debugging.texi indices.texi script-getopt.texi data-rep.texi \ extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi # Optionally support building an HTML version of the reference manual. diff --git a/doc/ref/appendices.texi b/doc/ref/appendices.texi deleted file mode 100644 index e69de29bb..000000000 diff --git a/doc/ref/debugging.texi b/doc/ref/debugging.texi new file mode 100644 index 000000000..28607c551 --- /dev/null +++ b/doc/ref/debugging.texi @@ -0,0 +1,179 @@ +@page +@node Debugger User Interface +@chapter Debugger User Interface + +@c --- The title and introduction of this appendix need to +@c distinguish this clearly from the chapter on the internal +@c debugging interface. + +When debugging a program, programmers often find it helpful to examine +the program's internal status while it runs: the values of internal +variables, the choices made in @code{if} and @code{cond} statements, and +so forth. Guile Scheme provides a debugging interface that programmers +can use to single-step through Scheme functions and examine symbol +bindings. This is different from the @ref{Debugging}, which permits +programmers to debug the Guile interpreter itself. Most programmers +will be more interested in debugging their own Scheme programs than the +interpreter which evaluates them. + +[FIXME: should we include examples of traditional debuggers +and explain why they can't be used to debug interpreted Scheme or Lisp?] + +@menu +* Single-Step:: Execute a program or function one step at a time. +* Trace:: Print a report each time a given function is called. +* Backtrace:: See a list of the statements that caused an error. +* Stacks and Frames:: Examine the state of an interrupted program. +@end menu + + +@node Single-Step +@section Single-Step + + +@node Trace +@section Trace + +When a function is @dfn{traced}, it means that every call to that +function is reported to the user during a program run. This can help a +programmer determine whether a function is being called at the wrong +time or with the wrong set of arguments. + +@defun trace function +Enable debug tracing on @code{function}. While a program is being run, Guile +will print a brief report at each call to a traced function, +advising the user which function was called and the arguments that were +passed to it. +@end defun + +@defun untrace function +Disable debug tracing for @code{function}. +@end defun + +Example: + +@lisp +(define (rev ls) + (if (null? ls) + '() + (append (rev (cdr ls)) + (cons (car ls) '())))) @result{} rev + +(trace rev) @result{} (rev) + +(rev '(a b c d e)) +@result{} [rev (a b c d e)] + | [rev (b c d e)] + | | [rev (c d e)] + | | | [rev (d e)] + | | | | [rev (e)] + | | | | | [rev ()] + | | | | | () + | | | | (e) + | | | (e d) + | | (e d c) + | (e d c b) + (e d c b a) + (e d c b a) +@end lisp + +Note the way Guile indents the output, illustrating the depth of +execution at each function call. This can be used to demonstrate, for +example, that Guile implements self-tail-recursion properly: + +@lisp +(define (rev ls sl) + (if (null? ls) + sl + (rev (cdr ls) + (cons (car ls) sl)))) @result{} rev + +(trace rev) @result{} (rev) + +(rev '(a b c d e) '()) +@result{} [rev (a b c d e) ()] + [rev (b c d e) (a)] + [rev (c d e) (b a)] + [rev (d e) (c b a)] + [rev (e) (d c b a)] + [rev () (e d c b a)] + (e d c b a) + (e d c b a) +@end lisp + +Since the tail call is effectively optimized to a @code{goto} statement, +there is no need for Guile to create a new stack frame for each +iteration. Using @code{trace} here helps us see why this is so. + +@node Backtrace +@appendixsec Backtrace + +@node Stacks and Frames +@appendixsec Stacks and Frames + +When a running program is interrupted, usually upon reaching an error or +breakpoint, its state is represented by a @dfn{stack} of suspended +function calls, each of which is called a @dfn{frame}. The programmer +can learn more about the program's state at the point of interruption by +inspecting and modifying these frames. + +@deffn primitive stack? obj +Return @code{#t} if @var{obj} is a calling stack. +@end deffn + +@deffn primitive make-stack +@end deffn + +@deffn syntax start-stack id exp +Evaluate @var{exp} on a new calling stack with identity @var{id}. If +@var{exp} is interrupted during evaluation, backtraces will not display +frames farther back than @var{exp}'s top-level form. This macro is a +way of artificially limiting backtraces and stack procedures, largely as +a convenience to the user. +@end deffn + +@deffn primitive stack-id stack +Return the identifier given to @var{stack} by @code{start-stack}. +@end deffn + +@deffn primitive stack-ref +@end deffn + +@deffn primitive stack-length +@end deffn + +@deffn primitive frame? +@end deffn + +@deffn primitive last-stack-frame +@end deffn + +@deffn primitive frame-number +@end deffn + +@deffn primitive frame-source +@end deffn + +@deffn primitive frame-procedure +@end deffn + +@deffn primitive frame-arguments +@end deffn + +@deffn primitive frame-previous +@end deffn + +@deffn primitive frame-next +@end deffn + +@deffn primitive frame-real? +@end deffn + +@deffn primitive frame-procedure? +@end deffn + +@deffn primitive frame-evaluating-args? +@end deffn + +@deffn primitive frame-overflow +@end deffn diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index 7d5e0ba01..fdd6df748 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -4,6 +4,7 @@ @setfilename guile.info @settitle Guile Reference Manual @set guile +@set MANUAL_EDITION 1.1 @c %**end of header @c Notes: (distilled from Jim's and Tim's notes, and kept up to date) @@ -80,7 +81,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.5 2001-10-27 16:53:34 ghouston Exp $ +@subtitle $Id: guile.texi,v 1.6 2001-11-11 15:01:51 ossau Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -175,8 +176,8 @@ This reference manual documents Guile, GNU's Ubiquitous Intelligent Language for Extensions. It describes how to use Guile in many useful and interesting ways. -This Info file contains edition 1.0 of the reference manual, -corresponding to Guile version @value{VERSION}. +This Info file contains edition @value{MANUAL_EDITION} of the reference +manual, corresponding to Guile version @value{VERSION}. @end ifinfo @menu @@ -190,12 +191,27 @@ Part I: Introduction to Guile * What is Guile?:: And what does it do? * Whirlwind Tour:: An introductory whirlwind tour. +* Obtaining and Installing Guile:: * Reporting Bugs:: Reporting bugs in Guile or this manual. -Part II: Guile Scheme +Part II: Programming with Guile +* Programming Intro:: Intoduction to programming with Guile. +* Programming Options:: Programming Options in Guile. * Scheme Intro:: Introduction to Guile Scheme. * Basic Ideas:: Basic ideas in Scheme. +* Guile Scripting:: How to write Guile scripts. +* Command Line Handling:: Command line options and arguments. +* Libguile Intro:: Using Guile as an extension language. +* Scheme Primitives:: Writing Scheme primitives in C. +* Data Representation:: Data representation in Guile. +* GH:: The deprecated GH interface. +* Debugger User Interface:: +* Further Reading:: Where to find out more about Scheme programming. + +Part III: Guile API Reference + +* Reference Intro:: Introduction to the Guile API reference. * Data Types:: Data types for generic use. * Procedures and Macros:: Procedures and macros. * Utility Functions:: General utility functions. @@ -211,9 +227,8 @@ Part II: Guile Scheme * Translation:: Support for translating other languages. * Debugging:: Internal debugging interface. * Deprecated:: Features that are planned to disappear. -* Further Reading:: Where to find out more about Scheme programming. -Part III: Guile Modules +Part IV: Guile Modules * SLIB:: Using the SLIB Scheme library. * POSIX:: POSIX system calls and networking. @@ -224,26 +239,6 @@ Part III: Guile Modules * Formatted Output:: The @code{format} procedure. * Expect:: Controlling interactive programs with Guile. * The Scheme shell (scsh):: Using scsh interfaces in Guile. -@c * Tcl/Tk Interface:: - -Part IV: Guile Scripting - -* Guile Scripting:: How to write Guile scripts. -* Command Line Handling:: Command line options and arguments. - -Part V: Extending Applications Using Guile - -* Libguile Intro:: Using Guile as an extension language. -* Data Representation:: Data representation in Guile. -* Scheme Primitives:: Writing Scheme primitives in C. -* I/O Extensions:: Using and extending ports in C. -* Handling Errors:: How to handle errors in C code. -* GH:: The deprecated GH interface. - -Appendices - -* Obtaining and Installing Guile:: -* Debugger User Interface:: Indices @@ -258,7 +253,6 @@ Indices @include preface.texi -@c preliminary @iftex @page @unnumbered{Part I: Introduction to Guile} @@ -266,14 +260,37 @@ Indices @include intro.texi -@c programming in Scheme -@iftex @page -@unnumbered{Part II: Guile Scheme} -@end iftex +@node Programming Intro +@unnumbered Part II: Programming with Guile +In this part of the manual, we aim to present a wide ranging picture of +what it means to program using Guile, to provide guidance, practical +guidelines and tips for @emph{how} to program in Guile, and to document +the tools that are available to help you with your programming. For +detailed reference information on the variables, functions etc. that +make up Guile's application programming interface (API), please refer to +Part III (@pxref{Reference Intro,,Part III: Programming with Guile}). + +We begin in the first chapter of this part by looking at the programming +options available. + +@include program.texi @include scheme-intro.texi @include scheme-ideas.texi +@include scripts.texi +@include script-getopt.texi +@include extend.texi +@include scm.texi +@include data-rep.texi +@include gh.texi +@include debugging.texi +@include scheme-reading.texi + +@page +@node Reference Intro +@unnumbered Part III: Guile API Reference + @include scheme-data.texi @include scheme-procedures.texi @include scheme-utility.texi @@ -289,13 +306,10 @@ Indices @include scheme-translation.texi @include scheme-debug.texi @include deprecated.texi -@include scheme-reading.texi -@include scheme-indices.texi -@c Unix system interface @iftex @page -@unnumbered{Part III: Guile Modules} +@unnumbered{Part IV: Guile Modules} @end iftex @include slib.texi @@ -305,43 +319,14 @@ Indices @include misc-modules.texi @include expect.texi @include scsh.texi -@c @include tcltk.texi -@c Guile as an scripting language -@iftex -@page -@unnumbered{Part IV: Guile Scripting} -@end iftex - -@include scripts.texi -@include script-getopt.texi - -@c Guile as an extension language -@iftex -@page -@unnumbered{Part V: Extending Applications Using Guile} -@end iftex - -@include extend.texi -@include data-rep.texi -@include scm.texi -@include gh.texi - -@c Appendices -@iftex -@page -@unnumbered{Appendices} -@end iftex - -@include appendices.texi - -@c Indices @iftex @page @unnumbered{Indices} @end iftex @include indices.texi +@include scheme-indices.texi @contents diff --git a/doc/ref/indices.texi b/doc/ref/indices.texi index a35592e90..11ab7476b 100644 --- a/doc/ref/indices.texi +++ b/doc/ref/indices.texi @@ -1,3 +1,4 @@ +@page @node Concept Index @unnumbered Concept Index @@ -41,9 +42,6 @@ in the section @xref{Transforming Scheme name to C name}. @page -@c Spell out this node fully, because it is the last real node -@c in the top-level menu. Leaving off the pointers here causes -@c spurious makeinfo errors. @node Type Index @unnumbered Type Index diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi index fdbbbf85b..9391a1d48 100644 --- a/doc/ref/intro.texi +++ b/doc/ref/intro.texi @@ -1,4 +1,5 @@ -@c $Id: intro.texi,v 1.2 2001-08-27 21:25:44 ossau Exp $ +@c $Id: intro.texi,v 1.3 2001-11-11 15:01:51 ossau Exp $ + @page @node What is Guile? @@ -50,6 +51,7 @@ can program applications which use Guile in the language of their choice, rather than having the tastes of the application's author imposed on them. + @page @node Whirlwind Tour @chapter A Whirlwind Tour @@ -582,6 +584,7 @@ guile> (exit) $ @end example + @node Writing Extensions for Guile @section Writing Extensions for Guile @@ -624,6 +627,7 @@ by Guile. * A Sample Guile Extension:: @end menu + @node A Sample Guile Extension @subsection A Sample Guile Extension @@ -688,6 +692,7 @@ environment variable. To see how these Guile extensions via shared libraries relate to the module system, see below @xref{Intro to Modules and Extensions}. + @node Guile Modules @section Guile Modules @@ -701,13 +706,13 @@ anyway. Guile will provide reasonable backwards compatability.) Details on the module system beyond this introductory material can be found in @xref{Modules}. - @menu * Intro to Using Guile Modules:: * Intro to Writing New Modules:: * Intro to Modules and Extensions:: @end menu + @node Intro to Using Guile Modules @subsection Intro to Using Existing Modules @@ -848,6 +853,110 @@ There is also a way to manipulate the module system from C but only Scheme files can be autoloaded. Thus, we recommend that you define your modules in Scheme. + +@page +@node Obtaining and Installing Guile +@chapter Obtaining and Installing Guile + +Here is the information you will need to get and install Guile and extra +packages and documentation you might need or find interesting. + +@menu +* The Basic Guile Package:: +* Packages not shipped with Guile:: +@end menu + + +@node The Basic Guile Package +@section The Basic Guile Package + +Guile can be obtained from the main GNU archive site +@url{ftp://prep.ai.mit.edu/pub/gnu} or any of its mirrors. The file +will be named guile-version.tar.gz. The current version is +@value{VERSION}, so the file you should grab is: + +@url{ftp://prep.ai.mit.edu/pub/gnu/guile-@value{VERSION}.tar.gz} + +To unbundle Guile use the instruction +@example +zcat guile-@value{VERSION}.tar.gz | tar xvf - +@end example +which will create a directory called @file{guile-@value{VERSION}} with +all the sources. You can look at the file @file{INSTALL} for detailed +instructions on how to build and install Guile, but you should be able +to just do +@example +cd guile-@value{VERSION} +./configure +make install +@end example + +This will install the Guile executable @file{guile}, the Guile library +@file{libguile.a} and various associated header files and support +libraries. It will also install the Guile tutorial and reference manual. + +@c [[include instructions for getting R5RS]] + +Since this manual frequently refers to the Scheme ``standard'', also +known as R5RS, or the +@iftex +``Revised$^5$ Report on the Algorithmic Language Scheme'', +@end iftex +@ifinfo +``Revised^5 Report on the Algorithmic Language Scheme'', +@end ifinfo +we have included the report in the Guile distribution; +@xref{Top, , Introduction, r5rs, Revised(5) Report on the Algorithmic +Language Scheme}. +This will also be installed in your info directory. + + +@node Packages not shipped with Guile +@section Packages not shipped with Guile + +We ship the Guile tutorial and reference manual with the Guile +distribution. Since the Scheme standard (R5RS) is a stable document, we +ship that too. + +Here are references (usually World Wide Web URLs) to some other freely +redistributable documents and packages which you might find useful if +you are using Guile. + +@table @strong +@item SCSH +the Scheme Shell. Gary Houston has ported SCSH to Guile. The relevant +chapter (@pxref{The Scheme shell (scsh)}) has references to the SCSH web +page with all its documentation. + +@item SLIB +a portable Scheme library maintained by Aubrey Jaffer. SLIB can be +obtained by ftp from @url{ftp://prep.ai.mit.edu/pub/gnu/jacal/}. + +The SLIB package should be unpacked somewhere in Guile's load path. It +will typically be unpacked in @file{/usr/local/share/guile/site}, so +that it will be @file{/usr/local/share/guile/site/slib}. + +Guile might have been installed with a different prefix, in which case +the load path can be checked from inside the interpreter with: + +@smalllisp +guile> %load-path +("/usr/local/share/guile/site" "/usr/local/share/guile/1.3a" "/usr/local/share/guile" ".") +@end smalllisp + +The relevant chapter (@pxref{SLIB}) has details on how to use SLIB with +Guile. + +@item JACAL +a symbolic math package by Aubrey Jaffer. The latest version of Jacal +can be obtained from @url{ftp://prep.ai.mit.edu/pub/gnu/jacal/}, and +should be unpacked in @file{/usr/local/share/guile/site/slib} so that +it will be in @file{/usr/local/share/guile/site/slib/jacal}. + +The relevant section (@pxref{JACAL}) has details on how to use Jacal. +@end table + + @page @node Reporting Bugs @chapter Reporting Bugs diff --git a/doc/ref/new-docstrings.texi b/doc/ref/new-docstrings.texi index 8bce646e6..e795fd3ef 100644 --- a/doc/ref/new-docstrings.texi +++ b/doc/ref/new-docstrings.texi @@ -304,9 +304,11 @@ If @var{l} does not hold a value for @var{key}, the value @end deffn @deffn primitive slot-ref-using-class class obj slot_name + @end deffn @deffn primitive slot-set-using-class! class obj slot_name value + @end deffn @deffn primitive class-of x @@ -319,33 +321,43 @@ on the C level which depends on the loaded GOOPS modules. @end deffn @deffn primitive %method-more-specific? m1 m2 targs + @end deffn @deffn primitive find-method . l + @end deffn @deffn primitive primitive-generic-generic subr + @end deffn @deffn primitive enable-primitive-generic! . subrs + @end deffn @deffn primitive generic-capability? proc + @end deffn @deffn primitive %invalidate-method-cache! gf + @end deffn @deffn primitive %invalidate-class class + @end deffn @deffn primitive %modify-class old new + @end deffn @deffn primitive %modify-instance old new + @end deffn @deffn primitive %set-object-setter! obj setter + @end deffn @deffn primitive %allocate-instance class initargs @@ -367,9 +379,11 @@ Set the slot named @var{slot_name} of @var{obj} to @var{value}. @end deffn @deffn primitive slot-exists-using-class? class obj slot_name + @end deffn @deffn primitive slot-bound-using-class? class obj slot_name + @end deffn @deffn primitive %fast-slot-set! obj index value @@ -460,9 +474,11 @@ Return @code{#t} if @var{obj} is an instance. @end deffn @deffn primitive %inherit-magic! class dsupers + @end deffn @deffn primitive %prep-layout! class + @end deffn @deffn primitive %initialize-object obj initargs @@ -530,3 +546,56 @@ this specific @var{msg}. Do nothing otherwise. The argument @var{msgs} should be a list of strings; they are printed in turn, each one followed by a newline. @end deffn + +@deffn primitive valid-object-procedure? proc +Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}. +@end deffn + +@deffn primitive %get-pre-modules-obarray +Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system. +@end deffn + +@deffn primitive standard-interface-eval-closure module +Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added. +@end deffn + +@deffn primitive env-module env +Return the module of @var{ENV}, a lexical environment. +@end deffn + +@deffn primitive load-extension lib init +Load and initilize the extension designated by LIB and INIT. +When there is no pre-registered function for LIB/INIT, this is +equivalent to + +@lisp +(dynamic-call INIT (dynamic-link LIB)) +@end lisp + +When there is a pre-registered function, that function is called +instead. + +Normally, there is no pre-registered function. This option exists +only for situations where dynamic linking is unavailable or unwanted. +In that case, you would statically link your program with the desired +library, and register its init function right after Guile has been +initialized. + +LIB should be a string denoting a shared library without any file type +suffix such as ".so". The suffix is provided automatically. It +should also not contain any directory components. Libraries that +implement Guile Extensions should be put into the normal locations for +shared libraries. We recommend to use the naming convention +libguile-bla-blum for a extension related to a module `(bla blum)'. + +The normal way for a extension to be used is to write a small Scheme +file that defines a module, and to load the extension into this +module. When the module is auto-loaded, the extension is loaded as +well. For example, + +@lisp +(define-module (bla blum)) + +(load-extension "libguile-bla-blum" "bla_init_blum") +@end lisp +@end deffn diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index 4d4473422..f2237f2c1 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -1457,26 +1457,35 @@ all platforms. @end deffn @deffn primitive setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds - Set the timer specified by @var{which_timer} according to the given @var{interval_seconds}, @var{interval_microseconds}, -@var{value_seconds}, and @var{value_microseconds} values, and return -information about the timer's previous setting. The timers available -are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, and @code{ITIMER_PROF}, -and the return value will be a list of two cons pairs representing the +@var{value_seconds}, and @var{value_microseconds} values. + +Return information about the timer's previous setting. +Errors are handled as described in the guile info pages under ``POSIX +Interface Conventions''. + +The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, +and @code{ITIMER_PROF}. + +The return value will be a list of two cons pairs representing the current state of the given timer. The first pair is the seconds and -microseconds of the timer @code{it_interval}, and the second pair is the -seconds and microseconds of the timer @code{it_value}. +microseconds of the timer @code{it_interval}, and the second pair is +the seconds and microseconds of the timer @code{it_value}. @end deffn @deffn primitive getitimer which_timer -Return information about the timer specified by @var{which_timer}. The -timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, and -@code{ITIMER_PROF}, and the return value will be a list of two cons -pairs representing the current state of the given timer. The first pair -is the seconds and microseconds of the timer @code{it_interval}, and the -second pair is the seconds and microseconds of the timer -@code{it_value}. +Return information about the timer specified by @var{which_timer} +Errors are handled as described in the guile info pages under ``POSIX +Interface Conventions''. + +The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, +and @code{ITIMER_PROF}. + +The return value will be a list of two cons pairs representing the +current state of the given timer. The first pair is the seconds and +microseconds of the timer @code{it_interval}, and the second pair is +the seconds and microseconds of the timer @code{it_value}. @end deffn @@ -2310,7 +2319,7 @@ documentation before using them. @deffn primitive crypt key salt Encrypt @var{key} using @var{salt} as the salt value to the -crypt(3) library call +crypt(3) library call. @end deffn @code{getpass} is no encryption procedure at all, but it is often used diff --git a/doc/ref/preface.texi b/doc/ref/preface.texi index 90e53e9ac..0a6ce32ba 100644 --- a/doc/ref/preface.texi +++ b/doc/ref/preface.texi @@ -6,8 +6,8 @@ This reference manual documents Guile, GNU's Ubiquitous Intelligent Language for Extensions. It describes how to use Guile in many useful and interesting ways. -This is edition 1.0 of the reference manual, and corresponds to Guile -version @value{VERSION}. +This is edition @value{MANUAL_EDITION} of the reference manual, and +corresponds to Guile version @value{VERSION}. @end iftex @@ -74,57 +74,74 @@ do not wish that, delete this exception notice. @chapter Layout of this Manual @end ifnottex -This manual is divided into five parts. +The manual is divided into three parts. @strong{Part I: Introduction to Guile} provides an overview of what Guile is and how you can use it. A whirlwind tour shows how Guile can be used interactively and as a script interpreter, how to link Guile into your own applications, and how to write modules of interpreted and -compiled code for use with Guile. All of the ideas introduced here are -documented in full by the later parts of the manual. +compiled code for use with Guile. Everything introduced here is +documented again and in full by the later parts of the manual. This +part also explains how to obtain and install new versions of Guile, and +how to report bugs effectively. -@strong{Part II: Guile Scheme} documents the core Scheme language and -features that Guile implements. Although the basis for this is the -Scheme language described in R5RS, this part of the manual does not -assume any prior familiarity with R5RS in particular, or with Scheme in -general. Basic Scheme concepts, standard aspects of the Scheme language -and Guile extensions on top of R5RS are all documented from scratch, and -organized by functionality rather than by the defining standards. +@strong{Part II: Programming with Guile} documents all aspects of +practical programming using Guile. This covers both the Scheme level +--- where we provide an introduction to the key ideas of the Scheme +language --- and use of Guile's @code{scm} interface to write new +primitives and objects in C, and to incorporate Guile into a C +application. It also covers the use of Guile as a POSIX compliant +script interpreter, and how to use the Guile debugger. -@strong{Part III: Guile Modules} describes some important modules, +@c @strong{Part V: Extending Applications Using Guile} explains the options +@c available for using Guile as a application extension language. At the +@c simpler end of the scale, an application might use Guile to define some +@c application-specific primitives in C and then load an application Scheme +@c file. In this case most of the application code is written on the +@c Scheme level, and uses the application-specific primitives as an +@c extension to standard Scheme. At the other end of the scale, an +@c application might be predominantly written in C --- with its main +@c control loop implemented in C --- but make occasional forays into Scheme +@c to, say, read configuration data or run user-defined customization code. +@c This part of the manual covers the complete range of application +@c extension options. + +@strong{Part III: Guile API Reference} documents Guile's core API. Most +of the variables and procedures in Guile's core programming interface +are available in both Scheme and C, and are related systematically such +that the C interface can be inferred from the Scheme interface and vice +versa. Therefore this part of the manual documents the Guile API in +functionality-based groups with the Scheme and C interfaces presented +side by side. Where the Scheme and C interfaces for a particular +functional area do differ --- which is sometimes inevitable, given the +differences in the structure of the two languages --- this is pointed +out and explained. In all cases the overriding principle is that all +the reference documentation for a given functional area is grouped +together. + +@c the core Scheme language and features that Guile implements. Although +@c the basis for this is the Scheme language described in R5RS, this part +@c of the manual does not assume any prior familiarity with R5RS in +@c particular, or with Scheme in general. Basic Scheme concepts, standard +@c aspects of the Scheme language and Guile extensions on top of R5RS are +@c all documented from scratch, and organized by functionality rather than +@c by the defining standards. + +@strong{Part IV: Guile Modules} describes some important modules, distributed as part of the Guile distribution, that extend the -functionality provided by the Guile Scheme core, most notably: +functionality provided by the Guile Scheme core. Two important examples +are: @itemize @bullet @item the POSIX module, which provides Scheme level procedures for system and -network programming, conforming to the POSIX standard +network programming that conform to the POSIX standard @item the SLIB module, which makes Aubrey Jaffer's portable Scheme library available for use in Guile. @end itemize -@strong{Part IV: Guile Scripting} documents the use of Guile as a script -interpreter, and illustrates this with a series of examples. - -@strong{Part V: Extending Applications Using Guile} explains the options -available for using Guile as a application extension language. At the -simpler end of the scale, an application might use Guile to define some -application-specific primitives in C and then load an application Scheme -file. In this case most of the application code is written on the -Scheme level, and uses the application-specific primitives as an -extension to standard Scheme. At the other end of the scale, an -application might be predominantly written in C --- with its main -control loop implemented in C --- but make occasional forays into Scheme -to, say, read configuration data or run user-defined customization code. -This part of the manual covers the complete range of application -extension options. - -Finally, the appendices explain how to obtain the latest version of -Guile, how to install it, where to find modules to work with Guile, and -how to use the Guile debugger. - @iftex @section Manual Conventions diff --git a/doc/ref/program.texi b/doc/ref/program.texi new file mode 100644 index 000000000..b6d268981 --- /dev/null +++ b/doc/ref/program.texi @@ -0,0 +1,199 @@ +@page +@node Programming Options +@chapter Programming Options in Guile + +What does it mean to program using Guile? + +If you are an application developer, and want to combine Guile in some +way with your application, there is a range of possibilities available +to you@dots{} + +@itemize @bullet +@item +You could choose to write your whole application in Scheme (or one of +the other high level languages that Guile supports through translation), +and simply use Guile as an interpreter (and hopefully in the future a +compiler) for Scheme. + +@item +You could write a small amount of C code that implements domain-specific +@dfn{primitive} functions for your application and connects these to the +Scheme level of Guile, and then write the rest of your application, +using these application-specific primitives, in Scheme. + +@item +You could write almost all of your application in C, and only call out +to Guile occasionally for specific actions such as reading a +configuration file or executing a user-specified extension. +@end itemize + +Underlying these choices are two basic questions. + +@itemize @bullet +@item +Which parts of the application do you write in C, and which in Scheme +(or another high level translated language)? + +@item +How do you design the interface between the C and Scheme parts of your +application? +@end itemize + +These are of course design questions, and the right design for any given +application will always depend upon the particular requirements that you +are trying to meet. In the Guile world, however, there are some +generally applicable considerations that can help you when searching for +the answers. + +@menu +* Available Functionality:: What functionality is already available? +* Basic Constraints:: Functional and performance constraints. +* Style Choices:: Your preferred programming style. +* Program Control:: What controls program execution? +* User Programming:: How about application users? +@end menu + + +@node Available Functionality +@section What Functionality is Already Available? + +Suppose, for the sake of argument, that you would prefer to write your +whole application in Scheme. Then the API available to you consists of: + +@itemize @bullet +@item +standard Scheme + +@item +plus the extensions to standard Scheme provided by +Guile in its core distribution + +@item +plus any additional functionality that you or others have packaged so +that it can be loaded as a Guile Scheme module. +@end itemize + +A module in the last category can either be a pure Scheme module --- in +other words a collection of utility procedures coded in Scheme --- or a +module that provides a Scheme interface to an extension library coded in +C --- in other words a nice package where someone else has done the work +of wrapping up some useful C code for you. The set of available modules +is growing quickly and already includes such useful examples as +@code{(gtk gtk)}, which makes Gtk+ drawing functions available in +Scheme, and @code{(database postgres)}, which provides SQL access to a +Postgres database. + +In practice, therefore, it is quite feasible that your application can +be implemented by combining together a selection of pre-existing modules +with new application code written in Scheme, and approach may +suffice for the application that you want to write. + +If it does not suffice, because the functionality that your application +needs is not already available in this form (and assuming that it's +impossible or unacceptable for performance reasons to write the new +functionality in Scheme), you will need to write some C code. + +@itemize @bullet +@item +If the required function is already written (e.g. in a library), you +only need a little glue to connect it to the world of Guile. + +@item +If not, you need to write the basic code as well. +@end itemize + +In either case, two general considerations are important. Firstly, what +is the interface by which the functionality is presented to the Scheme +world? Does the interface consist only of function calls (for example, +a simple drawing interface), or does it need to include @dfn{objects} of +some kind that can be passed between C and Scheme and manipulated by +both worlds. Secondly, how does the lifetime and memory management of +objects in the C code relate to the garbage collection governed approach +of Scheme objects? In the case where the basic C code is not already +written, most of the difficulties of memory management can be avoided by +using Guile's C interface features from the start. + +For further information, tips and guidelines on writing C code for +Guile, or for connecting existing C code to the Guile world, see +REFFIXME. + + +@node Basic Constraints +@section Functional and Performance Constraints + + +@node Style Choices +@section Your Preferred Programming Style + + +@node Program Control +@section What Controls Program Execution? + +What indeed? + + +@node User Programming +@section How About Application Users? + +So far we have considered what Guile programming means for an +application developer. But what if you are instead @emph{using} an +existing Guile-based application, and want to know what your +options are for programming and extending this application? + +The answer to this question varies from one application to another, +because the options available depend inevitably on whether the +application developer has provided any hooks for you to hang your own +code on and, if there are such hooks, what they allow you to +do.@footnote{Of course, in the world of free software, you always have +the freedom to modify the application's source code to your own +requirements. Here we are concerned with the extension options that the +application has provided for without your needing to modify its source +code.} For example@dots{} + +@itemize @bullet +@item +If the application permits you to load and execute any Guile code, the +world is your oyster. You can extend the application in any way that +you choose. + +@item +A more cautious application might allow you to load and execute Guile +code, but only in a @dfn{safe} environment, where the interface +available is restricted by the application from the standard Guile API. + +@item +Or a really fearful application might not provide a hook to really +execute user code at all, but just use Scheme syntax as a convenient way +for users to specify application data or configuration options. +@end itemize + +In the last two cases, what you can do is, by definition, restricted by +the application, and you should refer to the application's own manual to +find out your options. + +The most well known example of the first case is Emacs, with its +extension language Emacs Lisp: as well as being a text editor, Emacs +supports the loading and execution of arbitrary Emacs Lisp code. The +result of such openness has been dramatic: Emacs now benefits from +user-contributed Emacs Lisp libraries that extend the basic editing +function to do everything from reading news to psychoanalysis and +playing adventure games. The only limitation is that extensions are +restricted to the functionality provided by Emacs's built-in set of +primitive operations. For example, you can interact and display data by +manipulating the contents of an Emacs buffer, but you can't popup and +draw a window with a layout that is totally different to the Emacs +standard. + +This situation with a Guile application that supports the loading of +arbitrary user code is similar, except perhaps even more so, because +Guile also supports the loading of extension libraries written in C. +This last point enables user code to add new primitive operations to +Guile, and so to bypass the limitation present in Emacs Lisp. + +At this point, the distinction between an application developer and an +application user becomes rather blurred. Instead of seeing yourself as +a user extending an application, you could equally well say that you are +developing a new application of your own using some of the primitive +functionality provided by the original application. As such, all the +discussions of the preceding sections of this chapter are relevant to +how you can proceed with developing your extension. diff --git a/doc/ref/scheme-binding.texi b/doc/ref/scheme-binding.texi index b37bced03..5e476141e 100644 --- a/doc/ref/scheme-binding.texi +++ b/doc/ref/scheme-binding.texi @@ -233,7 +233,7 @@ bound in expression, you can use the @code{bound?} macro from the module @c NJFIXME explain [env] @deffn primitive defined? sym [env] -Return @code{#t} if @var{sym} is defined in the top-level environment. +Return @code{#t} if @var{sym} is defined in the lexical environment @var{env}. When @var{env} is not specified, look in the top-level environment as defined by the current module. @end deffn diff --git a/doc/ref/scheme-control.texi b/doc/ref/scheme-control.texi index dd5f9be53..d7b95151b 100644 --- a/doc/ref/scheme-control.texi +++ b/doc/ref/scheme-control.texi @@ -12,6 +12,7 @@ * Exceptions:: Throwing and catching exceptions. * Error Reporting:: Procedures for signaling errors. * Dynamic Wind:: Guarding against non-local entrance/exit. +* Handling Errors:: How to handle errors in C code. @end menu @@ -818,6 +819,143 @@ a-cont @result{} special-binding @end lisp @end deffn + + +@node Handling Errors +@section How to Handle Errors in C Code + +Error handling is based on @code{catch} and @code{throw}. Errors are +always thrown with a @var{key} and four arguments: + +@itemize @bullet +@item +@var{key}: a symbol which indicates the type of error. The symbols used +by libguile are listed below. + +@item +@var{subr}: the name of the procedure from which the error is thrown, or +@code{#f}. + +@item +@var{message}: a string (possibly language and system dependent) +describing the error. The tokens @code{~A} and @code{~S} can be +embedded within the message: they will be replaced with members of the +@var{args} list when the message is printed. @code{~A} indicates an +argument printed using @code{display}, while @code{~S} indicates an +argument printed using @code{write}. @var{message} can also be +@code{#f}, to allow it to be derived from the @var{key} by the error +handler (may be useful if the @var{key} is to be thrown from both C and +Scheme). + +@item +@var{args}: a list of arguments to be used to expand @code{~A} and +@code{~S} tokens in @var{message}. Can also be @code{#f} if no +arguments are required. + +@item +@var{rest}: a list of any additional objects required. e.g., when the +key is @code{'system-error}, this contains the C errno value. Can also +be @code{#f} if no additional objects are required. +@end itemize + +In addition to @code{catch} and @code{throw}, the following Scheme +facilities are available: + +@deffn primitive scm-error key subr message args rest +Throw an error, with arguments +as described above. +@end deffn + +@deffn procedure error msg arg @dots{} +Throw an error using the key @code{'misc-error}. The error +message is created by displaying @var{msg} and writing the @var{args}. +@end deffn + +The following are the error keys defined by libguile and the situations +in which they are used: + +@itemize @bullet +@item +@code{error-signal}: thrown after receiving an unhandled fatal signal +such as SIGSEV, SIGBUS, SIGFPE etc. The @var{rest} argument in the throw +contains the coded signal number (at present this is not the same as the +usual Unix signal number). + +@item +@code{system-error}: thrown after the operating system indicates an +error condition. The @var{rest} argument in the throw contains the +errno value. + +@item +@code{numerical-overflow}: numerical overflow. + +@item +@code{out-of-range}: the arguments to a procedure do not fall within the +accepted domain. + +@item +@code{wrong-type-arg}: an argument to a procedure has the wrong thpe. + +@item +@code{wrong-number-of-args}: a procedure was called with the wrong number +of arguments. + +@item +@code{memory-allocation-error}: memory allocation error. + +@item +@code{stack-overflow}: stack overflow error. + +@item +@code{regex-error}: errors generated by the regular expression library. + +@item +@code{misc-error}: other errors. +@end itemize + + +@subsection C Support + +SCM scm_error (SCM key, char *subr, char *message, SCM args, SCM rest) + +Throws an error, after converting the char * arguments to Scheme strings. +subr is the Scheme name of the procedure, NULL is converted to #f. +Likewise a NULL message is converted to #f. + +The following procedures invoke scm_error with various error keys and +arguments. The first three call scm_error with the system-error key +and automatically supply errno in the "rest" argument: scm_syserror +generates messages using strerror, scm_sysmissing is used when +facilities are not available. Care should be taken that the errno +value is not reset (e.g. due to an interrupt). + +@itemize @bullet +@item +void scm_syserror (char *subr); +@item +void scm_syserror_msg (char *subr, char *message, SCM args); +@item +void scm_sysmissing (char *subr); +@item +void scm_num_overflow (char *subr); +@item +void scm_out_of_range (char *subr, SCM bad_value); +@item +void scm_wrong_num_args (SCM proc); +@item +void scm_wrong_type_arg (char *subr, int pos, SCM bad_value); +@item +void scm_memory_error (char *subr); +@item +static void scm_regex_error (char *subr, int code); (only used in rgx.c). +@end itemize + +Exception handlers can also be installed from C, using +scm_internal_catch, scm_lazy_catch, or scm_stack_catch from +libguile/throw.c. These have not yet been documented, however the +source contains some useful comments. + + @c Local Variables: @c TeX-master: "guile.texi" @c End: diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 0adf9abfc..235644c63 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -956,32 +956,33 @@ Return the hyperbolic arctangent of @var{x}. @subsection Bitwise Operations @deffn primitive logand n1 n2 -Return the integer which is the bit-wise AND of the two integer -arguments. +Return the bitwise AND of the integer arguments. @lisp -(number->string (logand #b1100 #b1010) 2) - @result{} "1000" +(logand) @result{} -1 +(logand 7) @result{} 7 +(logand #b111 #b011 #b001) @result{} 1 @end lisp @end deffn @deffn primitive logior n1 n2 -Return the integer which is the bit-wise OR of the two integer -arguments. +Return the bitwise OR of the integer arguments. @lisp -(number->string (logior #b1100 #b1010) 2) - @result{} "1110" +(logior) @result{} 0 +(logior 7) @result{} 7 +(logior #b000 #b001 #b011) @result{} 3 @end lisp @end deffn @deffn primitive logxor n1 n2 -Return the integer which is the bit-wise XOR of the two integer -arguments. - +Return the bitwise XOR of the integer arguments. A bit is +set in the result if it is set in an odd number of arguments. @lisp -(number->string (logxor #b1100 #b1010) 2) - @result{} "110" +(logxor) @result{} 0 +(logxor 7) @result{} 7 +(logxor #b000 #b001 #b011) @result{} 2 +(logxor #b000 #b001 #b011 #b011) @result{} 1 @end lisp @end deffn @@ -1468,16 +1469,17 @@ Split the string @var{str} into the a list of the substrings delimited by appearances of the character @var{chr}. Note that an empty substring between separator characters will result in an empty string in the result list. + @lisp -(string-split "root:x:0:0:root:/root:/bin/bash" #\:) +(string-split "root:x:0:0:root:/root:/bin/bash" #:) @result{} ("root" "x" "0" "0" "root" "/root" "/bin/bash") -(string-split "::" #\:) +(string-split "::" #:) @result{} ("" "" "") -(string-split "" #\:) +(string-split "" #:) @result{} ("") @end lisp @@ -1554,7 +1556,7 @@ y @deffnx primitive substring-move-left! str1 start1 end1 str2 start2 @deffnx primitive substring-move-right! str1 start1 end1 str2 start2 Copy the substring of @var{str1} bounded by @var{start1} and @var{end1} -into @var{str2} beginning at position @var{end2}. +into @var{str2} beginning at position @var{start2}. @code{substring-move-right!} begins copying from the rightmost character and moves left, and @code{substring-move-left!} copies from the leftmost character moving right. @@ -1916,6 +1918,20 @@ Match the compiled regular expression @var{rx} against provided, begin matching from that position in the string. Return a match structure describing the results of the match, or @code{#f} if no match could be found. + +The @var{flags} arguments change the matching behavior. +The following flags may be supplied: + +@table @code +@item regexp/notbol +Operator @samp{^} always fails (unless @code{regexp/newline} +is used). Use this when the beginning of the string should +not be considered the beginning of a line. +@item regexp/noteol +Operator @samp{$} always fails (unless @code{regexp/newline} +is used). Use this when the end of the string should not be +considered the end of a line. +@end table @end deffn @deffn primitive regexp? obj @@ -2394,7 +2410,7 @@ part of an object returned as the value of a literal expression Report on Scheme}) or by a call to the @code{read} procedure, and its name contains alphabetic characters, then the string returned will contain characters in the implementation's -preferred standard case--some implementations will prefer +preferred standard case---some implementations will prefer upper case, others lower case. If the symbol was returned by @code{string->symbol}, the case of characters in the string returned will be the same as the case in the string that was @@ -2541,20 +2557,12 @@ Return the built-in variable with the name @var{name}. Then use @code{variable-ref} to access its value. @end deffn -@deffn primitive make-undefined-variable [name-hint] -Return a variable object initialized to an undefined value. -If given, uses @var{name-hint} as its internal (debugging) -name, otherwise just treat it as an anonymous variable. -Remember, of course, that multiple bindings to the same -variable may exist, so @var{name-hint} is just that---a hint. +@deffn primitive make-undefined-variable +Return a variable that is initially unbound. @end deffn -@deffn primitive make-variable init [name-hint] -Return a variable object initialized to value @var{init}. -If given, uses @var{name-hint} as its internal (debugging) -name, otherwise just treat it as an anonymous variable. -Remember, of course, that multiple bindings to the same -variable may exist, so @var{name-hint} is just that---a hint. +@deffn primitive make-variable init +Return a variable initialized to value @var{init}. @end deffn @deffn primitive variable-bound? var @@ -2576,7 +2584,7 @@ value. Return an unspecified value. @deffn primitive variable? obj Return @code{#t} iff @var{obj} is a variable object, else -return @code{#f} +return @code{#f}. @end deffn diff --git a/doc/ref/scheme-debug.texi b/doc/ref/scheme-debug.texi index d9387f5d0..170d7e382 100644 --- a/doc/ref/scheme-debug.texi +++ b/doc/ref/scheme-debug.texi @@ -173,8 +173,8 @@ Return the identifier given to @var{stack} by @code{start-stack}. Return the length of @var{stack}. @end deffn -@deffn primitive stack-ref stack i -Return the @var{i}'th frame from @var{stack}. +@deffn primitive stack-ref stack index +Return the @var{index}'th frame from @var{stack}. @end deffn @deffn primitive stack? obj diff --git a/doc/ref/scheme-indices.texi b/doc/ref/scheme-indices.texi index 03a21bb30..46a87b3d8 100644 --- a/doc/ref/scheme-indices.texi +++ b/doc/ref/scheme-indices.texi @@ -1,13 +1,13 @@ @page @node R5RS Index -@chapter R5RS Index +@unnumbered R5RS Index @printindex rn @page @node Guile Extensions Index -@chapter Guile Extensions Index +@unnumbered Guile Extensions Index @printindex ge diff --git a/doc/ref/scheme-io.texi b/doc/ref/scheme-io.texi index 07a258868..a121823a5 100644 --- a/doc/ref/scheme-io.texi +++ b/doc/ref/scheme-io.texi @@ -12,6 +12,7 @@ * Block Reading and Writing:: Reading and writing blocks of text. * Default Ports:: Defaults for input, output and errors. * Port Types:: Types of port and how to make them. +* I/O Extensions:: Using and extending ports in C. @end menu @@ -119,8 +120,20 @@ unread characters will be read again in last-in first-out order. If @end deffn @deffn primitive drain-input port -Drain @var{port}'s read buffers (including any pushed-back -characters) and return the content as a single string. +This procedure clears a port's input buffers, similar +to the way that force-output clears the output buffer. The +contents of the buffers are returned as a single string, e.g., + +@lisp +(define p (open-input-file ...)) +(drain-input p) => empty string, nothing buffered yet. +(unread-char (read-char p) p) +(drain-input p) => initial chars from p, up to the buffer size. +@end lisp + +Draining the buffers may be useful for cleanly finishing +buffered I/O so that the file descriptor can be used directly +for further input. @end deffn @deffn primitive port-column port @@ -419,7 +432,7 @@ The Block-string-I/O module can be accessed with: It currently contains procedures that help to implement the @code{(scsh rw)} module in guile-scsh. -@deffn primitive read-string!/partial str [port_or_fdes start end] +@deffn primitive read-string!/partial str [port_or_fdes [start [end]]] Read characters from a port or file descriptor into a string @var{str}. A port must have an underlying file descriptor --- a so-called fport. This procedure is @@ -830,6 +843,221 @@ modes for this port: see the documentation for @code{open-file} in @end deffn +@node I/O Extensions +@section Using and Extending Ports in C + +@menu +* C Port Interface:: Using ports from C. +* Port Implementation:: How to implement a new port type in C. +@end menu + + +@node C Port Interface +@subsection C Port Interface + +This section describes how to use Scheme ports from C. + +@subsubsection Port basics + +There are two main data structures. A port type object (ptob) is of +type @code{scm_ptob_descriptor}. A port instance is of type +@code{scm_port}. Given an @code{SCM} variable which points to a port, +the corresponding C port object can be obtained using the +@code{SCM_PTAB_ENTRY} macro. The ptob can be obtained by using +@code{SCM_PTOBNUM} to give an index into the @code{scm_ptobs} +global array. + +@subsubsection Port buffers + +An input port always has a read buffer and an output port always has a +write buffer. However the size of these buffers is not guaranteed to be +more than one byte (e.g., the @code{shortbuf} field in @code{scm_port} +which is used when no other buffer is allocated). The way in which the +buffers are allocated depends on the implementation of the ptob. For +example in the case of an fport, buffers may be allocated with malloc +when the port is created, but in the case of an strport the underlying +string is used as the buffer. + +@subsubsection The @code{rw_random} flag + +Special treatment is required for ports which can be seeked at random. +Before various operations, such as seeking the port or changing from +input to output on a bidirectional port or vice versa, the port +implemention must be given a chance to update its state. The write +buffer is updated by calling the @code{flush} ptob procedure and the +input buffer is updated by calling the @code{end_input} ptob procedure. +In the case of an fport, @code{flush} causes buffered output to be +written to the file descriptor, while @code{end_input} causes the +descriptor position to be adjusted to account for buffered input which +was never read. + +The special treatment must be performed if the @code{rw_random} flag in +the port is non-zero. + +@subsubsection The @code{rw_active} variable + +The @code{rw_active} variable in the port is only used if +@code{rw_random} is set. It's defined as an enum with the following +values: + +@table @code +@item SCM_PORT_READ +the read buffer may have unread data. + +@item SCM_PORT_WRITE +the write buffer may have unwritten data. + +@item SCM_PORT_NEITHER +neither the write nor the read buffer has data. +@end table + +@subsubsection Reading from a port. + +To read from a port, it's possible to either call existing libguile +procedures such as @code{scm_getc} and @code{scm_read_line} or to read +data from the read buffer directly. Reading from the buffer involves +the following steps: + +@enumerate +@item +Flush output on the port, if @code{rw_active} is @code{SCM_PORT_WRITE}. + +@item +Fill the read buffer, if it's empty, using @code{scm_fill_input}. + +@item Read the data from the buffer and update the read position in +the buffer. Steps 2) and 3) may be repeated as many times as required. + +@item Set rw_active to @code{SCM_PORT_READ} if @code{rw_random} is set. + +@item update the port's line and column counts. +@end enumerate + +@subsubsection Writing to a port. + +To write data to a port, calling @code{scm_lfwrite} should be sufficient for +most purposes. This takes care of the following steps: + +@enumerate +@item +End input on the port, if @code{rw_active} is @code{SCM_PORT_READ}. + +@item +Pass the data to the ptob implementation using the @code{write} ptob +procedure. The advantage of using the ptob @code{write} instead of +manipulating the write buffer directly is that it allows the data to be +written in one operation even if the port is using the single-byte +@code{shortbuf}. + +@item +Set @code{rw_active} to @code{SCM_PORT_WRITE} if @code{rw_random} +is set. +@end enumerate + + +@node Port Implementation +@subsection Port Implementation + +This section describes how to implement a new port type in C. + +As described in the previous section, a port type object (ptob) is +a structure of type @code{scm_ptob_descriptor}. A ptob is created by +calling @code{scm_make_port_type}. + +All of the elements of the ptob, apart from @code{name}, are procedures +which collectively implement the port behaviour. Creating a new port +type mostly involves writing these procedures. + +@code{scm_make_port_type} initializes three elements of the structure +(@code{name}, @code{fill_input} and @code{write}) from its arguments. +The remaining elements are initialized with default values and can be +set later if required. + +@table @code +@item name +A pointer to a NUL terminated string: the name of the port type. This +is the only element of @code{scm_ptob_descriptor} which is not +a procedure. Set via the first argument to @code{scm_make_port_type}. + +@item mark +Called during garbage collection to mark any SCM objects that a port +object may contain. It doesn't need to be set unless the port has +@code{SCM} components. Set using @code{scm_set_port_mark}. + +@item free +Called when the port is collected during gc. It +should free any resources used by the port. +Set using @code{scm_set_port_free}. + +@item print +Called when @code{write} is called on the port object, to print a +port description. e.g., for an fport it may produce something like: +@code{#}. Set using @code{scm_set_port_print}. + +@item equalp +Not used at present. Set using @code{scm_set_port_equalp}. + +@item close +Called when the port is closed, unless it was collected during gc. It +should free any resources used by the port. +Set using @code{scm_set_port_close}. + +@item write +Accept data which is to be written using the port. The port implementation +may choose to buffer the data instead of processing it directly. +Set via the third argument to @code{scm_make_port_type}. + +@item flush +Complete the processing of buffered output data. Reset the value of +@code{rw_active} to @code{SCM_PORT_NEITHER}. +Set using @code{scm_set_port_flush}. + +@item end_input +Perform any synchronisation required when switching from input to output +on the port. Reset the value of @code{rw_active} to @code{SCM_PORT_NEITHER}. +Set using @code{scm_set_port_end_input}. + +@item fill_input +Read new data into the read buffer and return the first character. It +can be assumed that the read buffer is empty when this procedure is called. +Set via the second argument to @code{scm_make_port_type}. + +@item input_waiting +Return a lower bound on the number of bytes that could be read from the +port without blocking. It can be assumed that the current state of +@code{rw_active} is @code{SCM_PORT_NEITHER}. +Set using @code{scm_set_port_input_waiting}. + +@item seek +Set the current position of the port. The procedure can not make +any assumptions about the value of @code{rw_active} when it's +called. It can reset the buffers first if desired by using something +like: + +@example + if (pt->rw_active == SCM_PORT_READ) + scm_end_input (object); + else if (pt->rw_active == SCM_PORT_WRITE) + ptob->flush (object); +@end example + +However note that this will have the side effect of discarding any data +in the unread-char buffer, in addition to any side effects from the +@code{end_input} and @code{flush} ptob procedures. This is undesirable +when seek is called to measure the current position of the port, i.e., +@code{(seek p 0 SEEK_CUR)}. The libguile fport and string port +implementations take care to avoid this problem. + +The procedure is set using @code{scm_set_port_seek}. + +@item truncate +Truncate the port data to be specified length. It can be assumed that the +current state of @code{rw_active} is @code{SCM_PORT_NEITHER}. +Set using @code{scm_set_port_truncate}. + +@end table + + @c Local Variables: @c TeX-master: "guile.texi" @c End: diff --git a/doc/ref/scheme-memory.texi b/doc/ref/scheme-memory.texi index 6a1f21e9c..e29fd8607 100644 --- a/doc/ref/scheme-memory.texi +++ b/doc/ref/scheme-memory.texi @@ -202,7 +202,7 @@ Return @code{#t} if @var{obj} is an operator. @end deffn @deffn primitive set-object-procedure! obj proc -Return the object procedure of @var{obj} to @var{proc}. +Set the object procedure of @var{obj} to @var{proc}. @var{obj} must be either an entity or an operator. @end deffn diff --git a/doc/ref/scheme-options.texi b/doc/ref/scheme-options.texi index d591008fe..d009a4d01 100644 --- a/doc/ref/scheme-options.texi +++ b/doc/ref/scheme-options.texi @@ -335,8 +335,8 @@ Guile's configuration at run time. @deffnx primitive major-version @deffnx primitive minor-version @deffnx primitive micro-version -Return a string describing Guile's version number, or its major or minor -version numbers, respectively. +Return a string describing Guile's version number, or its major, minor +and micro version numbers, respectively. @lisp (version) @result{} "1.6.5" diff --git a/doc/ref/scm.texi b/doc/ref/scm.texi index 2cda191d8..948823afb 100644 --- a/doc/ref/scm.texi +++ b/doc/ref/scm.texi @@ -101,358 +101,3 @@ argumements, both required and optional; if the Scheme procedure takes a ``rest'' argument, that will be a final argument to the C function. The C function's arguments, as well as its return type, will be @code{SCM}. -@c @node Exceptions to the regularity -@c @section Exceptions to the regularity -@c -@c There are some exceptions to the regular structure described above. - - -@page -@node I/O Extensions -@chapter Using and Extending Ports in C - -@menu -* C Port Interface:: Using ports from C. -* Port Implementation:: How to implement a new port type in C. -@end menu - - -@node C Port Interface -@section C Port Interface - -This section describes how to use Scheme ports from C. - -@subsection Port basics - -There are two main data structures. A port type object (ptob) is of -type @code{scm_ptob_descriptor}. A port instance is of type -@code{scm_port}. Given an @code{SCM} variable which points to a port, -the corresponding C port object can be obtained using the -@code{SCM_PTAB_ENTRY} macro. The ptob can be obtained by using -@code{SCM_PTOBNUM} to give an index into the @code{scm_ptobs} -global array. - -@subsection Port buffers - -An input port always has a read buffer and an output port always has a -write buffer. However the size of these buffers is not guaranteed to be -more than one byte (e.g., the @code{shortbuf} field in @code{scm_port} -which is used when no other buffer is allocated). The way in which the -buffers are allocated depends on the implementation of the ptob. For -example in the case of an fport, buffers may be allocated with malloc -when the port is created, but in the case of an strport the underlying -string is used as the buffer. - -@subsection The @code{rw_random} flag - -Special treatment is required for ports which can be seeked at random. -Before various operations, such as seeking the port or changing from -input to output on a bidirectional port or vice versa, the port -implemention must be given a chance to update its state. The write -buffer is updated by calling the @code{flush} ptob procedure and the -input buffer is updated by calling the @code{end_input} ptob procedure. -In the case of an fport, @code{flush} causes buffered output to be -written to the file descriptor, while @code{end_input} causes the -descriptor position to be adjusted to account for buffered input which -was never read. - -The special treatment must be performed if the @code{rw_random} flag in -the port is non-zero. - -@subsection The @code{rw_active} variable - -The @code{rw_active} variable in the port is only used if -@code{rw_random} is set. It's defined as an enum with the following -values: - -@table @code -@item SCM_PORT_READ -the read buffer may have unread data. - -@item SCM_PORT_WRITE -the write buffer may have unwritten data. - -@item SCM_PORT_NEITHER -neither the write nor the read buffer has data. -@end table - -@subsection Reading from a port. - -To read from a port, it's possible to either call existing libguile -procedures such as @code{scm_getc} and @code{scm_read_line} or to read -data from the read buffer directly. Reading from the buffer involves -the following steps: - -@enumerate -@item -Flush output on the port, if @code{rw_active} is @code{SCM_PORT_WRITE}. - -@item -Fill the read buffer, if it's empty, using @code{scm_fill_input}. - -@item Read the data from the buffer and update the read position in -the buffer. Steps 2) and 3) may be repeated as many times as required. - -@item Set rw_active to @code{SCM_PORT_READ} if @code{rw_random} is set. - -@item update the port's line and column counts. -@end enumerate - -@subsection Writing to a port. - -To write data to a port, calling @code{scm_lfwrite} should be sufficient for -most purposes. This takes care of the following steps: - -@enumerate -@item -End input on the port, if @code{rw_active} is @code{SCM_PORT_READ}. - -@item -Pass the data to the ptob implementation using the @code{write} ptob -procedure. The advantage of using the ptob @code{write} instead of -manipulating the write buffer directly is that it allows the data to be -written in one operation even if the port is using the single-byte -@code{shortbuf}. - -@item -Set @code{rw_active} to @code{SCM_PORT_WRITE} if @code{rw_random} -is set. -@end enumerate - - -@node Port Implementation -@section Port Implementation - -This section describes how to implement a new port type in C. - -As described in the previous section, a port type object (ptob) is -a structure of type @code{scm_ptob_descriptor}. A ptob is created by -calling @code{scm_make_port_type}. - -All of the elements of the ptob, apart from @code{name}, are procedures -which collectively implement the port behaviour. Creating a new port -type mostly involves writing these procedures. - -@code{scm_make_port_type} initializes three elements of the structure -(@code{name}, @code{fill_input} and @code{write}) from its arguments. -The remaining elements are initialized with default values and can be -set later if required. - -@table @code -@item name -A pointer to a NUL terminated string: the name of the port type. This -is the only element of @code{scm_ptob_descriptor} which is not -a procedure. Set via the first argument to @code{scm_make_port_type}. - -@item mark -Called during garbage collection to mark any SCM objects that a port -object may contain. It doesn't need to be set unless the port has -@code{SCM} components. Set using @code{scm_set_port_mark}. - -@item free -Called when the port is collected during gc. It -should free any resources used by the port. -Set using @code{scm_set_port_free}. - -@item print -Called when @code{write} is called on the port object, to print a -port description. e.g., for an fport it may produce something like: -@code{#}. Set using @code{scm_set_port_print}. - -@item equalp -Not used at present. Set using @code{scm_set_port_equalp}. - -@item close -Called when the port is closed, unless it was collected during gc. It -should free any resources used by the port. -Set using @code{scm_set_port_close}. - -@item write -Accept data which is to be written using the port. The port implementation -may choose to buffer the data instead of processing it directly. -Set via the third argument to @code{scm_make_port_type}. - -@item flush -Complete the processing of buffered output data. Reset the value of -@code{rw_active} to @code{SCM_PORT_NEITHER}. -Set using @code{scm_set_port_flush}. - -@item end_input -Perform any synchronisation required when switching from input to output -on the port. Reset the value of @code{rw_active} to @code{SCM_PORT_NEITHER}. -Set using @code{scm_set_port_end_input}. - -@item fill_input -Read new data into the read buffer and return the first character. It -can be assumed that the read buffer is empty when this procedure is called. -Set via the second argument to @code{scm_make_port_type}. - -@item input_waiting -Return a lower bound on the number of bytes that could be read from the -port without blocking. It can be assumed that the current state of -@code{rw_active} is @code{SCM_PORT_NEITHER}. -Set using @code{scm_set_port_input_waiting}. - -@item seek -Set the current position of the port. The procedure can not make -any assumptions about the value of @code{rw_active} when it's -called. It can reset the buffers first if desired by using something -like: - -@example - if (pt->rw_active == SCM_PORT_READ) - scm_end_input (object); - else if (pt->rw_active == SCM_PORT_WRITE) - ptob->flush (object); -@end example - -However note that this will have the side effect of discarding any data -in the unread-char buffer, in addition to any side effects from the -@code{end_input} and @code{flush} ptob procedures. This is undesirable -when seek is called to measure the current position of the port, i.e., -@code{(seek p 0 SEEK_CUR)}. The libguile fport and string port -implementations take care to avoid this problem. - -The procedure is set using @code{scm_set_port_seek}. - -@item truncate -Truncate the port data to be specified length. It can be assumed that the -current state of @code{rw_active} is @code{SCM_PORT_NEITHER}. -Set using @code{scm_set_port_truncate}. - -@end table - - -@node Handling Errors -@chapter How to Handle Errors in C Code - -Error handling is based on @code{catch} and @code{throw}. Errors are -always thrown with a @var{key} and four arguments: - -@itemize @bullet -@item -@var{key}: a symbol which indicates the type of error. The symbols used -by libguile are listed below. - -@item -@var{subr}: the name of the procedure from which the error is thrown, or -@code{#f}. - -@item -@var{message}: a string (possibly language and system dependent) -describing the error. The tokens @code{~A} and @code{~S} can be -embedded within the message: they will be replaced with members of the -@var{args} list when the message is printed. @code{~A} indicates an -argument printed using @code{display}, while @code{~S} indicates an -argument printed using @code{write}. @var{message} can also be -@code{#f}, to allow it to be derived from the @var{key} by the error -handler (may be useful if the @var{key} is to be thrown from both C and -Scheme). - -@item -@var{args}: a list of arguments to be used to expand @code{~A} and -@code{~S} tokens in @var{message}. Can also be @code{#f} if no -arguments are required. - -@item -@var{rest}: a list of any additional objects required. e.g., when the -key is @code{'system-error}, this contains the C errno value. Can also -be @code{#f} if no additional objects are required. -@end itemize - -In addition to @code{catch} and @code{throw}, the following Scheme -facilities are available: - -@deffn primitive scm-error key subr message args rest -Throw an error, with arguments -as described above. -@end deffn - -@deffn procedure error msg arg @dots{} -Throw an error using the key @code{'misc-error}. The error -message is created by displaying @var{msg} and writing the @var{args}. -@end deffn - -The following are the error keys defined by libguile and the situations -in which they are used: - -@itemize @bullet -@item -@code{error-signal}: thrown after receiving an unhandled fatal signal -such as SIGSEV, SIGBUS, SIGFPE etc. The @var{rest} argument in the throw -contains the coded signal number (at present this is not the same as the -usual Unix signal number). - -@item -@code{system-error}: thrown after the operating system indicates an -error condition. The @var{rest} argument in the throw contains the -errno value. - -@item -@code{numerical-overflow}: numerical overflow. - -@item -@code{out-of-range}: the arguments to a procedure do not fall within the -accepted domain. - -@item -@code{wrong-type-arg}: an argument to a procedure has the wrong thpe. - -@item -@code{wrong-number-of-args}: a procedure was called with the wrong number -of arguments. - -@item -@code{memory-allocation-error}: memory allocation error. - -@item -@code{stack-overflow}: stack overflow error. - -@item -@code{regex-error}: errors generated by the regular expression library. - -@item -@code{misc-error}: other errors. -@end itemize - - -@section C Support - -SCM scm_error (SCM key, char *subr, char *message, SCM args, SCM rest) - -Throws an error, after converting the char * arguments to Scheme strings. -subr is the Scheme name of the procedure, NULL is converted to #f. -Likewise a NULL message is converted to #f. - -The following procedures invoke scm_error with various error keys and -arguments. The first three call scm_error with the system-error key -and automatically supply errno in the "rest" argument: scm_syserror -generates messages using strerror, scm_sysmissing is used when -facilities are not available. Care should be taken that the errno -value is not reset (e.g. due to an interrupt). - -@itemize @bullet -@item -void scm_syserror (char *subr); -@item -void scm_syserror_msg (char *subr, char *message, SCM args); -@item -void scm_sysmissing (char *subr); -@item -void scm_num_overflow (char *subr); -@item -void scm_out_of_range (char *subr, SCM bad_value); -@item -void scm_wrong_num_args (SCM proc); -@item -void scm_wrong_type_arg (char *subr, int pos, SCM bad_value); -@item -void scm_memory_error (char *subr); -@item -static void scm_regex_error (char *subr, int code); (only used in rgx.c). -@end itemize - -Exception handlers can also be installed from C, using -scm_internal_catch, scm_lazy_catch, or scm_stack_catch from -libguile/throw.c. These have not yet been documented, however the -source contains some useful comments. diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 660d22307..0d958e2ae 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,28 @@ +2001-11-07 Neil Jerram + + * extensions.c (scm_load_extension): Canonicalize docstring + whitespace. + + * unif.c (scm_uniform_array_write), ports.c + (scm_current_output_port, scm_force_output), dynwind.c + (scm_dynamic_wind), scmsigs.c (scm_setitimer, scm_getitimer), + filesys.c (scm_open, scm_lstat), struct.c + (scm_make_struct_layout), random.c (scm_random, + scm_random_solid_sphere_x, scm_random_hollow_sphere_x, strop.c + (scm_i_index): Remove superfluous whitespace from end of docstring + lines. + + * filesys.c (scm_select), guardians.c (scm_guardian_greedy_p), + strings.c (scm_make_string), variable.c (scm_make_variable, + scm_make_undefined_variable, scm_variable_p, scm_variable_set_x, + scm_variable_bound_p), scmsigs.c (scm_setitimer, scm_getitimer), + posix.c (scm_crypt), struct.c (scm_make_vtable_vtable), hashtab.c + (scm_hash_fold), ports.c (scm_port_for_each): Remove superfluous + newline at end of docstrings. + + * modules.c (scm_set_current_module): Add missing newline to + docstring. + 2001-11-07 Stefan Jahn * win32-socket.[ch]: New files. Defines Winsock-API error codes diff --git a/libguile/dynwind.c b/libguile/dynwind.c index d093861cf..5970dc455 100644 --- a/libguile/dynwind.c +++ b/libguile/dynwind.c @@ -82,7 +82,7 @@ SCM_DEFINE (scm_dynamic_wind, "dynamic-wind", 3, 0, 0, "@lisp\n" "(define x 'normal-binding)\n" "@result{} x\n" - "(define a-cont (call-with-current-continuation \n" + "(define a-cont (call-with-current-continuation\n" " (lambda (escape)\n" " (let ((old-x x))\n" " (dynamic-wind\n" @@ -101,7 +101,7 @@ SCM_DEFINE (scm_dynamic_wind, "dynamic-wind", 3, 0, 0, " ;;\n" " (lambda () (set! x old-x)))))))\n" "\n" - ";; Prints: \n" + ";; Prints:\n" "special-binding\n" ";; Evaluates to:\n" "@result{} a-cont\n" diff --git a/libguile/extensions.c b/libguile/extensions.c index b549f0fc7..48e39420c 100644 --- a/libguile/extensions.c +++ b/libguile/extensions.c @@ -117,36 +117,40 @@ scm_c_load_extension (const char *lib, const char *init) SCM_DEFINE (scm_load_extension, "load-extension", 2, 0, 0, (SCM lib, SCM init), - "Load and initilize the extension designated by LIB and INIT." -"When there is no pre-registered function for LIB/INIT, this is " -"equivalent to " -" " -" (dynamic-call INIT (dynamic-link LIB)) " -" " -"When there is a pre-registered function, that function is called " -"instead. " -" " -"Normally, there is no pre-registered function. This option exists " -"only for situations where dynamic linking is unavailable or unwanted. " -"In that case, you would statically link your program with the desired " -"library, and register its init function right after Guile has been " -"initialized. " -" " -"LIB should be a string denoting a shared library without any file type " -"suffix such as \".so\". The suffix is provided automatically. It " -"should also not contain any directory components. Libraries that " -"implement Guile Extensions should be put into the normal locations for " -"shared libraries. We recommend to use the naming convention " -"libguile-bla-blum for a extension related to a module `(bla blum)'. " -" " -"The normal way for a extension to be used is to write a small Scheme " -"file that defines a module, and to load the extension into this " -"module. When the module is auto-loaded, the extension is loaded as " -"well. For example, " -" " -" (define-module (bla blum)) " -" " -" (load-extension \"libguile-bla-blum\" \"bla_init_blum\")") + "Load and initilize the extension designated by LIB and INIT.\n" + "When there is no pre-registered function for LIB/INIT, this is\n" + "equivalent to\n" + "\n" + "@lisp\n" + "(dynamic-call INIT (dynamic-link LIB))\n" + "@end lisp\n" + "\n" + "When there is a pre-registered function, that function is called\n" + "instead.\n" + "\n" + "Normally, there is no pre-registered function. This option exists\n" + "only for situations where dynamic linking is unavailable or unwanted.\n" + "In that case, you would statically link your program with the desired\n" + "library, and register its init function right after Guile has been\n" + "initialized.\n" + "\n" + "LIB should be a string denoting a shared library without any file type\n" + "suffix such as \".so\". The suffix is provided automatically. It\n" + "should also not contain any directory components. Libraries that\n" + "implement Guile Extensions should be put into the normal locations for\n" + "shared libraries. We recommend to use the naming convention\n" + "libguile-bla-blum for a extension related to a module `(bla blum)'.\n" + "\n" + "The normal way for a extension to be used is to write a small Scheme\n" + "file that defines a module, and to load the extension into this\n" + "module. When the module is auto-loaded, the extension is loaded as\n" + "well. For example,\n" + "\n" + "@lisp\n" + "(define-module (bla blum))\n" + "\n" + "(load-extension \"libguile-bla-blum\" \"bla_init_blum\")\n" + "@end lisp") #define FUNC_NAME s_scm_load_extension { SCM_VALIDATE_STRING (1, lib); diff --git a/libguile/filesys.c b/libguile/filesys.c index 806c8c10f..f891be40e 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -336,7 +336,7 @@ SCM_DEFINE (scm_open, "open", 2, 1, 0, "Open the file read-only.\n" "@end defvar\n" "@defvar O_WRONLY\n" - "Open the file write-only. \n" + "Open the file write-only.\n" "@end defvar\n" "@defvar O_RDWR\n" "Open the file read/write.\n" @@ -1129,8 +1129,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, "The @var{usecs} argument is not supported.\n" "Multiple values are returned instead of a list.\n" "Duplicates in the input vectors appear only once in output.\n" - "An additional @code{select!} interface is provided.\n" - ) + "An additional @code{select!} interface is provided.") #define FUNC_NAME s_scm_select { struct timeval timeout; @@ -1387,7 +1386,7 @@ SCM_DEFINE (scm_readlink, "readlink", 1, 0, 0, SCM_DEFINE (scm_lstat, "lstat", 1, 0, 0, (SCM str), "Similar to @code{stat}, but does not follow symbolic links, i.e.,\n" - "it will return information about a symbolic link itself, not the \n" + "it will return information about a symbolic link itself, not the\n" "file it points to. @var{path} must be a string.") #define FUNC_NAME s_scm_lstat { diff --git a/libguile/guardians.c b/libguile/guardians.c index 4703bee74..ad9832539 100644 --- a/libguile/guardians.c +++ b/libguile/guardians.c @@ -374,7 +374,7 @@ SCM_DEFINE (scm_guardian_destroyed_p, "guardian-destroyed?", 1, 0, 0, SCM_DEFINE (scm_guardian_greedy_p, "guardian-greedy?", 1, 0, 0, (SCM guardian), - "Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.\n") + "Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.") #define FUNC_NAME s_scm_guardian_greedy_p { return SCM_BOOL (GREEDY_P (GUARDIAN_DATA (guardian))); diff --git a/libguile/hashtab.c b/libguile/hashtab.c index dc5545390..4cf250fae 100644 --- a/libguile/hashtab.c +++ b/libguile/hashtab.c @@ -525,7 +525,7 @@ SCM_DEFINE (scm_hash_fold, "hash-fold", 3, 0, 0, "prior-result is either INIT (for the first application of PROC)\n" "or the return value of the previous application of PROC.\n" "For example, @code{(hash-fold acons () tab)} will convert a hash\n" - "table into an a-list of key-value pairs.\n") + "table into an a-list of key-value pairs.") #define FUNC_NAME s_scm_hash_fold { SCM_VALIDATE_PROC (1,proc); diff --git a/libguile/modules.c b/libguile/modules.c index 1c458683e..f304df3df 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -77,7 +77,7 @@ static void scm_post_boot_init_modules (void); SCM_DEFINE (scm_set_current_module, "set-current-module", 1, 0, 0, (SCM module), - "Set the current module to @var{module} and return" + "Set the current module to @var{module} and return\n" "the previous current module.") #define FUNC_NAME s_scm_set_current_module { diff --git a/libguile/ports.c b/libguile/ports.c index 7a02b1308..0250f503c 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -364,7 +364,7 @@ SCM_DEFINE (scm_current_input_port, "current-input-port", 0, 0, 0, SCM_DEFINE (scm_current_output_port, "current-output-port", 0, 0, 0, (), "Return the current output port. This is the default port used\n" - "by many output procedures. Initially, \n" + "by many output procedures. Initially,\n" "@code{current-output-port} returns the @dfn{standard output} in\n" "Unix and C terminology.") #define FUNC_NAME s_scm_current_output_port @@ -724,7 +724,7 @@ SCM_DEFINE (scm_port_for_each, "port-for-each", 1, 0, 0, "@var{proc} is applied exactly once to every port that exists\n" "in the system at the time @var{port-for-each} is invoked.\n" "Changes to the port table while @var{port-for-each} is running\n" - "have no effect as far as @var{port-for-each} is concerned.\n") + "have no effect as far as @var{port-for-each} is concerned.") #define FUNC_NAME s_scm_port_for_each { long i; @@ -819,7 +819,7 @@ SCM_DEFINE (scm_eof_object_p, "eof-object?", 1, 0, 0, SCM_DEFINE (scm_force_output, "force-output", 0, 1, 0, (SCM port), "Flush the specified output port, or the current output port if @var{port}\n" - "is omitted. The current output buffer contents are passed to the \n" + "is omitted. The current output buffer contents are passed to the\n" "underlying port implementation (e.g., in the case of fports, the\n" "data will be written to the file and the output buffer will be cleared.)\n" "It has no effect on an unbuffered port.\n\n" diff --git a/libguile/posix.c b/libguile/posix.c index 033678947..acec88b08 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1328,7 +1328,7 @@ SCM_DEFINE (scm_sync, "sync", 0, 0, 0, SCM_DEFINE (scm_crypt, "crypt", 2, 0, 0, (SCM key, SCM salt), "Encrypt @var{key} using @var{salt} as the salt value to the\n" - "crypt(3) library call\n") + "crypt(3) library call.") #define FUNC_NAME s_scm_crypt { char * p; diff --git a/libguile/random.c b/libguile/random.c index 4883ff16f..ba64d1ab2 100644 --- a/libguile/random.c +++ b/libguile/random.c @@ -364,9 +364,9 @@ SCM_DEFINE (scm_random, "random", 1, 1, 0, (SCM n, SCM state), "Return a number in [0,N).\n" "\n" - "Accepts a positive integer or real n and returns a \n" - "number of the same type between zero (inclusive) and \n" - "N (exclusive). The values returned have a uniform \n" + "Accepts a positive integer or real n and returns a\n" + "number of the same type between zero (inclusive) and\n" + "N (exclusive). The values returned have a uniform\n" "distribution.\n" "\n" "The optional argument @var{state} must be of the type produced\n" @@ -490,8 +490,8 @@ SCM_DEFINE (scm_random_solid_sphere_x, "random:solid-sphere!", 1, 1, 0, (SCM v, SCM state), "Fills vect with inexact real random numbers\n" "the sum of whose squares is less than 1.0.\n" - "Thinking of vect as coordinates in space of \n" - "dimension n = (vector-length vect), the coordinates \n" + "Thinking of vect as coordinates in space of\n" + "dimension n = (vector-length vect), the coordinates\n" "are uniformly distributed within the unit n-shere.\n" "The sum of the squares of the numbers is returned.") #define FUNC_NAME s_scm_random_solid_sphere_x @@ -513,9 +513,9 @@ SCM_DEFINE (scm_random_hollow_sphere_x, "random:hollow-sphere!", 1, 1, 0, (SCM v, SCM state), "Fills vect with inexact real random numbers\n" "the sum of whose squares is equal to 1.0.\n" - "Thinking of vect as coordinates in space of \n" + "Thinking of vect as coordinates in space of\n" "dimension n = (vector-length vect), the coordinates\n" - "are uniformly distributed over the surface of the \n" + "are uniformly distributed over the surface of the\n" "unit n-shere.") #define FUNC_NAME s_scm_random_hollow_sphere_x { diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 55439f2e5..5ee384995 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -434,13 +434,13 @@ SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0, "Errors are handled as described in the guile info pages under ``POSIX\n" "Interface Conventions''.\n" "\n" - "The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, \n" + "The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL},\n" "and @code{ITIMER_PROF}.\n" "\n" "The return value will be a list of two cons pairs representing the\n" "current state of the given timer. The first pair is the seconds and\n" "microseconds of the timer @code{it_interval}, and the second pair is\n" - "the seconds and microseconds of the timer @code{it_value}.\n") + "the seconds and microseconds of the timer @code{it_value}.") #define FUNC_NAME s_scm_setitimer { int rv; @@ -475,13 +475,13 @@ SCM_DEFINE (scm_getitimer, "getitimer", 1, 0, 0, "Errors are handled as described in the guile info pages under ``POSIX\n" "Interface Conventions''.\n" "\n" - "The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, \n" + "The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL},\n" "and @code{ITIMER_PROF}.\n" "\n" "The return value will be a list of two cons pairs representing the\n" "current state of the given timer. The first pair is the seconds and\n" "microseconds of the timer @code{it_interval}, and the second pair is\n" - "the seconds and microseconds of the timer @code{it_value}.\n") + "the seconds and microseconds of the timer @code{it_value}.") #define FUNC_NAME s_scm_getitimer { int rv; diff --git a/libguile/strings.c b/libguile/strings.c index 41cb50005..eef9f4a7f 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -211,7 +211,7 @@ SCM_DEFINE (scm_make_string, "make-string", 1, 1, 0, "Return a newly allocated string of\n" "length @var{k}. If @var{chr} is given, then all elements of\n" "the string are initialized to @var{chr}, otherwise the contents\n" - "of the @var{string} are unspecified.\n") + "of the @var{string} are unspecified.") #define FUNC_NAME s_scm_make_string { if (SCM_INUMP (k)) diff --git a/libguile/strop.c b/libguile/strop.c index a173cacea..9369c3ec8 100644 --- a/libguile/strop.c +++ b/libguile/strop.c @@ -64,7 +64,7 @@ If you do not wish that, delete this exception notice. */ /* xSCM_DEFINE (scm_i_index, "i-index", 2, 2, 0, (SCM str, SCM chr, SCM frm, SCM to), - "@deftypefn {Internal C Function} {static int} scm_i_index (SCM *@var{str}, \n" + "@deftypefn {Internal C Function} {static int} scm_i_index (SCM *@var{str},\n" "SCM @var{chr}, int @var{direction}, SCM @var{sub_start}, SCM @var{sub_end}, char *@var{why}) "This is a workhorse function that performs either an @code{index} or\n" "@code{rindex} function, depending on the value of @var{direction}." diff --git a/libguile/struct.c b/libguile/struct.c index 27eecebe4..f24fefdb2 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -72,7 +72,7 @@ SCM_DEFINE (scm_make_struct_layout, "make-struct-layout", 1, 0, 0, "type, the second a field protection. Allowed types are 'p' for\n" "GC-protected Scheme data, 'u' for unprotected binary data, and 's' for\n" "a field that points to the structure itself. Allowed protections\n" - "are 'w' for mutable fields, 'r' for read-only fields, and 'o' for opaque \n" + "are 'w' for mutable fields, 'r' for read-only fields, and 'o' for opaque\n" "fields. The last field protection specification may be capitalized to\n" "indicate that the field is a tail-array.") #define FUNC_NAME s_scm_make_struct_layout @@ -521,7 +521,7 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1, "(define (make-ball type owner) (make-struct type 0 owner))\n\n" "(define ball (make-ball green 'Nisse))\n" "ball @result{} #\n" - "@end lisp\n") + "@end lisp") #define FUNC_NAME s_scm_make_vtable_vtable { SCM fields; diff --git a/libguile/unif.c b/libguile/unif.c index 392e376b2..138fe36a8 100644 --- a/libguile/unif.c +++ b/libguile/unif.c @@ -1656,7 +1656,7 @@ SCM_DEFINE (scm_uniform_array_write, "uniform-array-write", 1, 3, 0, "The optional arguments @var{start}\n" "and @var{end} allow\n" "a specified region of a vector (or linearized array) to be written.\n\n" - "The number of objects actually written is returned. \n" + "The number of objects actually written is returned.\n" "@var{port-or-fdes} may be\n" "omitted, in which case it defaults to the value returned by\n" "@code{(current-output-port)}.") diff --git a/libguile/variable.c b/libguile/variable.c index 7a4763b00..b0e9b61d9 100644 --- a/libguile/variable.c +++ b/libguile/variable.c @@ -78,7 +78,7 @@ make_variable (SCM init) SCM_DEFINE (scm_make_variable, "make-variable", 1, 0, 0, (SCM init), - "Return a variable initialized to value @var{init}.\n") + "Return a variable initialized to value @var{init}.") #define FUNC_NAME s_scm_make_variable { return make_variable (init); @@ -88,7 +88,7 @@ SCM_DEFINE (scm_make_variable, "make-variable", 1, 0, 0, SCM_DEFINE (scm_make_undefined_variable, "make-undefined-variable", 0, 0, 0, (), - "Return a variable that is initially unbound.\n") + "Return a variable that is initially unbound.") #define FUNC_NAME s_scm_make_undefined_variable { return make_variable (SCM_UNDEFINED); @@ -99,7 +99,7 @@ SCM_DEFINE (scm_make_undefined_variable, "make-undefined-variable", 0, 0, 0, SCM_DEFINE (scm_variable_p, "variable?", 1, 0, 0, (SCM obj), "Return @code{#t} iff @var{obj} is a variable object, else\n" - "return @code{#f}\n") + "return @code{#f}.") #define FUNC_NAME s_scm_variable_p { return SCM_BOOL (SCM_VARIABLEP (obj)); @@ -127,7 +127,7 @@ SCM_DEFINE (scm_variable_set_x, "variable-set!", 2, 0, 0, (SCM var, SCM val), "Set the value of the variable @var{var} to @var{val}.\n" "@var{var} must be a variable object, @var{val} can be any\n" - "value. Return an unspecified value.\n") + "value. Return an unspecified value.") #define FUNC_NAME s_scm_variable_set_x { SCM_VALIDATE_VARIABLE (1, var); @@ -139,7 +139,7 @@ SCM_DEFINE (scm_variable_set_x, "variable-set!", 2, 0, 0, SCM_DEFINE (scm_variable_bound_p, "variable-bound?", 1, 0, 0, (SCM var), "Return @code{#t} iff @var{var} is bound to a value.\n" - "Throws an error if @var{var} is not a variable object.\n") + "Throws an error if @var{var} is not a variable object.") #define FUNC_NAME s_scm_variable_bound_p { SCM_VALIDATE_VARIABLE (1, var); diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 287f65bf6..85125714f 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,9 @@ +2001-11-07 Neil Jerram + + * srfi-13.c (scm_string_unfold, scm_string_unfold_right), + srfi-14.c (scm_char_set_unfold, scm_char_set_unfold_x): Remove + superfluous whitespace at end of docstring lines. + 2001-11-06 Thien-Thi Nguyen * srfi-19.scm (time-monotonic->time-monotonic): Spurious; diff --git a/srfi/srfi-13.c b/srfi/srfi-13.c index 231e2adaa..3d32cf744 100644 --- a/srfi/srfi-13.c +++ b/srfi/srfi-13.c @@ -2521,7 +2521,7 @@ SCM_DEFINE (scm_string_unfold, "string-unfold", 4, 2, 0, "@dots{}\n" "@item @var{p} tells us when to stop -- when it returns true\n" "when applied to one of these seed values.\n" - "@item @var{f} maps each seed value to the corresponding \n" + "@item @var{f} maps each seed value to the corresponding\n" "character in the result string. These chars are assembled\n" "into the string in a left-to-right order.\n" "@item @var{base} is the optional initial/leftmost portion\n" @@ -2583,7 +2583,7 @@ SCM_DEFINE (scm_string_unfold_right, "string-unfold-right", 4, 2, 0, "@dots{}\n" "@item @var{p} tells us when to stop -- when it returns true\n" "when applied to one of these seed values.\n" - "@item @var{f} maps each seed value to the corresponding \n" + "@item @var{f} maps each seed value to the corresponding\n" "character in the result string. These chars are assembled\n" "into the string in a right-to-left order.\n" "@item @var{base} is the optional initial/rightmost portion\n" diff --git a/srfi/srfi-14.c b/srfi/srfi-14.c index c5a491786..1f3abae7d 100644 --- a/srfi/srfi-14.c +++ b/srfi/srfi-14.c @@ -317,11 +317,11 @@ SCM_DEFINE (scm_char_set_unfold, "char-set-unfold", 4, 1, 0, (SCM p, SCM f, SCM g, SCM seed, SCM base_cs), "This is a fundamental constructor for character sets.\n" "@itemize @bullet\n" - "@item @var{g} is used to generate a series of ``seed'' values \n" + "@item @var{g} is used to generate a series of ``seed'' values\n" "from the initial seed: @var{seed}, (@var{g} @var{seed}),\n" "(@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}), @dots{}\n" "@item @var{p} tells us when to stop -- when it returns true\n" - "when applied to one of the seed values. \n" + "when applied to one of the seed values.\n" "@item @var{f} maps each seed value to a character. These\n" "characters are added to the base character set @var{base_cs} to\n" "form the result; @var{base_cs} defaults to the empty set.\n" @@ -362,10 +362,10 @@ SCM_DEFINE (scm_char_set_unfold_x, "char-set-unfold!", 5, 0, 0, "This is a fundamental constructor for character sets.\n" "@itemize @bullet\n" "@item @var{g} is used to generate a series of ``seed'' values\n" - "from the initial seed: @var{seed}, (@var{g} @var{seed}), \n" + "from the initial seed: @var{seed}, (@var{g} @var{seed}),\n" "(@var{g}^2 @var{seed}), (@var{g}^3 @var{seed}), @dots{}\n" "@item @var{p} tells us when to stop -- when it returns true\n" - "when applied to one of the seed values. \n" + "when applied to one of the seed values.\n" "@item @var{f} maps each seed value to a character. These\n" "characters are added to the base character set @var{base_cs} to\n" "form the result; @var{base_cs} defaults to the empty set.\n" From 9c4c86c62360018380215adcd0338aa237364000 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 11 Nov 2001 20:49:24 +0000 Subject: [PATCH 131/281] (scm_string_null_p): Docfix; nfc. --- libguile/strop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/strop.c b/libguile/strop.c index 9369c3ec8..ec92ef340 100644 --- a/libguile/strop.c +++ b/libguile/strop.c @@ -312,7 +312,7 @@ SCM_DEFINE (scm_substring_fill_x, "substring-fill!", 4, 0, 0, SCM_DEFINE (scm_string_null_p, "string-null?", 1, 0, 0, (SCM str), - "Return @code{#t} if @var{str}'s length is nonzero, and\n" + "Return @code{#t} if @var{str}'s length is zero, and\n" "@code{#f} otherwise.\n" "@lisp\n" "(string-null? \"\") @result{} #t\n" From d6b8cf1192f004254e2f54052dc1a55eeb01039a Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 11 Nov 2001 20:51:44 +0000 Subject: [PATCH 132/281] *** empty log message *** --- libguile/ChangeLog | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 0d958e2ae..aa26023c4 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-11 Thien-Thi Nguyen + + * strop.c (scm_string_null_p): Docfix; nfc. + Thanks to Scott Lenser. + 2001-11-07 Neil Jerram * extensions.c (scm_load_extension): Canonicalize docstring @@ -33,13 +38,13 @@ * socket.c (scm_init_socket): Initialize `win32-socket' part here under M$-Windows. - * numbers.h: Added missing declaration of + * numbers.h: Added missing declaration of `scm_sys_check_number_conversions()'. * error.c: Local definition of SCM_I_STRERROR and SCM_I_ERRNO and use in `(strerror)' and `(system-error)'. - * Makefile.am (EXTRA_libguile_la_SOURCES): Added + * Makefile.am (EXTRA_libguile_la_SOURCES): Added `win32-socket.[ch]' to extra source and header files. 2001-11-06 Marius Vollmer @@ -56,10 +61,10 @@ 2001-11-04 Stefan Jahn * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL) - here (was at guile_LDADD) which describes the dependency + here (was at guile_LDADD) which describes the dependency correctly and allows a clean build on Win32. - * __scm.h (SCM_API): Follow-up patch. Renamed __FOO__ macros + * __scm.h (SCM_API): Follow-up patch. Renamed __FOO__ macros into FOO. * __scm.h: USE_DLL_IMPORT indicates the usage of the DLL @@ -104,7 +109,7 @@ 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! - + * Makefile.am: Add win32-uname.c, win32-uname.h, win32-dirent.c and win32-dirent.h to extra source and header files. These include the uname() and the POSIX dirent interface implementation @@ -113,18 +118,18 @@ libraries. Corrected `guile_filter_doc_snarfage$(EXEEXT)' dependency. - * __scm.h: Defined SCM_API. This macro gets prepended to all - function and data definitions which should be exported or imported + * __scm.h: Defined SCM_API. This macro gets prepended to all + function and data definitions which should be exported or imported in the resulting dynamic link library in the Win32 port. * __scm.h, alist.h, arbiters.h, async.h, backtrace.h, boolean.h, - chars.h, continuations.h, coop-defs.h, coop-threads.h, + chars.h, continuations.h, coop-defs.h, coop-threads.h, debug-malloc.h, debug.h, deprecation.h, dynl.h, dynwind.h, environments.h, eq.h, error.h, eval.h, evalext.h, extensions.h, feature.h, filesys.h, fluids.h, fports.h, gc.h, gdb_interface.h, gdbint.h, gh.h, goops.h, gsubr.h, guardians.h, hash.h, hashtab.h, hooks.h, init.h, ioext.h, iselect.h, keywords.h, lang.h, list.h, - load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h, + load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h, objects.h, objprop.h, options.h, pairs.h, ports.h, posix.h, print.h, procprop.h, procs.h, properties.h, ramap.h, random.h, rdelim.h, read.h, regex-posix.h, root.h, rw.h, scmsigs.h, script.h, simpos.h, @@ -134,7 +139,7 @@ vports.h, weaks.h: Prefixed each each exported symbol with SCM_API. - * continuations.c: Added comment about the use of the extern + * continuations.c: Added comment about the use of the extern declarations of {get,set}context() functions used in the ia64 port. * continuations.h, gc.c: `__libc_ia64_register_backing_store_base' @@ -150,7 +155,7 @@ * fports.c: Include `io.h' is possible. Put `*fp' into referring statement block in `scm_fport_buffer_add()'. Some corrections in `getflags()'. - + * gdb_interface.h (GDB_INTERFACE): Also support __CYGWIN__. * guile.c: Make sure to define __SCM_IMPORT__ for shared library @@ -377,7 +382,7 @@ These changes fixes a race condition in the Guile coop - pthread compatibility code. - + * coop.c (mother_awake_p): New variable. (coop_create): Set mother_awake_p before creating or signalling mother; wait until mother is going to sleep before returning. From 813b3dd465bd05b227dec775517e7f77a6698784 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 00:58:33 +0000 Subject: [PATCH 133/281] check for sizes of short, size_t, uintptr_t, and ptrdiff_t. Checking for a size also checks automatically for the existence of the type, so we don't check for the existence of uintptr_t, ptrdiff_t and long long ourselves. --- configure.in | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 07a4ee4df..1cbecb350 100644 --- a/configure.in +++ b/configure.in @@ -176,8 +176,10 @@ AC_C_CONST AC_C_INLINE AC_C_BIGENDIAN +AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(size_t) dnl Check for integral types that can represent the range of pointers. dnl If these types don't exist on this platform, they are replaced by @@ -185,17 +187,10 @@ dnl "unsigned long" and "long", respectively. AC_CHECK_HEADERS(stdint.h) AC_CHECK_HEADERS(inttypes.h) -AC_CHECK_TYPES([uintptr_t, ptrdiff_t]) +AC_CHECK_SIZEOF(uintptr_t) +AC_CHECK_SIZEOF(ptrdiff_t) -AC_CACHE_CHECK([for long longs], scm_cv_long_longs, - AC_TRY_COMPILE(, - [long long a], - scm_cv_long_longs=yes, - scm_cv_long_longs=no)) -if test "$scm_cv_long_longs" = yes; then - AC_DEFINE(HAVE_LONG_LONGS) - AC_CHECK_SIZEOF(long long) -fi +AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(void *) From 35656ebcef3f1537bffdb5c7250bd4d001abb341 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 00:58:48 +0000 Subject: [PATCH 134/281] *** empty log message *** --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1cf6eabc9..8599d90bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-11-12 Marius Vollmer + + * configure.in: Check for sizes of short, size_t, uintptr_t, and + ptrdiff_t. Checking for a size also checks automatically for the + existence of the type, so we don't check for the existence of + uintptr_t, ptrdiff_t and long long ourselves. + 2001-11-10 Thien-Thi Nguyen * BUGS (11): New. From fdf773fa8f5079ea9194d6a0ed01631d4ccd99a9 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 01:00:40 +0000 Subject: [PATCH 135/281] Define HAVE_UINTPTR_T, HAVE_PTRDIFF_T and HAVE_LONG_LONG depending on whether their size is non-zero. --- libguile/__scm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libguile/__scm.h b/libguile/__scm.h index 2ae4cdf29..29abc9d09 100644 --- a/libguile/__scm.h +++ b/libguile/__scm.h @@ -293,6 +293,19 @@ * - ... add more */ +#if SIZEOF_UINTPTR_T != 0 +#define HAVE_UINTPTR_T +#endif + +#if SIZEOF_PTRDIFF_T != 0 +#define HAVE_PTRDIFF_T +#endif + +#if SIZEOF_LONG_LONG != 0 +#define HAVE_LONG_LONGS +#define HAVE_LONG_LONG +#endif + #ifndef HAVE_PTRDIFF_T typedef long ptrdiff_t; #endif From 3d2e8ceb97e7f8ba975d73028f8b7a258d349556 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 01:12:37 +0000 Subject: [PATCH 136/281] * numbers.c: Document macros to define when including num2integral.i.c. MAX_VALUE and MIN_VALU are no longer used, we now rely on SIZEOF_ macros that have been figured out at configure time. * num2integral.i.c: Adapt to new interface. (NUM2INTEGRAL): Test whether a fixnum can be represented in the target type by casting it and checking whether it is still the same. Do not try to handle bignums for integral types that are smaller than fixnums. When handling bignums, collect the magnituse first into a unsigned type, and correctly check for overflow. (INTEGRAL2BIG): Do not use MIN_VALUE explicitely by observing that only -MIN_VALUE can still be negative of all negative numbers (in twos-complement). --- libguile/num2integral.i.c | 100 +++++++++++++++++++------------------- libguile/numbers.c | 81 +++++++++++++++++------------- 2 files changed, 97 insertions(+), 84 deletions(-) diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index fa1d8c6ec..b6e8a9b5f 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -1,5 +1,19 @@ /* this file is #include'd (many times) by numbers.c */ +#ifndef UNSIGNED_ITYPE +#ifdef UNSIGNED +#define UNSIGNED_ITYPE ITYPE +#else +#define UNSIGNED_ITYPE unsigned ITYPE +#endif +#endif + +#define UNSIGNED_ITYPE_MAX (~((UNSIGNED_ITYPE)0)) + +#ifndef SIZEOF_ITYPE +#define SIZEOF_ITYPE (2*SIZEOF_SCM_T_BITS) +#endif + ITYPE NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) { @@ -19,11 +33,7 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) return (ITYPE) n; else { /* an inum can be out of range, so check */ - if (n > (scm_t_signed_bits)MAX_VALUE -#ifndef UNSIGNED - || n < (scm_t_signed_bits)MIN_VALUE -#endif - ) + if (((ITYPE)n) != n) scm_out_of_range (s_caller, num); else return (ITYPE) n; @@ -31,8 +41,9 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) } else if (SCM_BIGP (num)) { /* bignum */ - - ITYPE res = 0; +#if SIZEOF_ITYPE >= SIZEOF_SCM_T_BITS + + UNSIGNED_ITYPE pos_res = 0; size_t l; #ifdef UNSIGNED @@ -42,22 +53,17 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) for (l = SCM_NUMDIGS (num); l--;) { - ITYPE new = SCM_I_BIGUP (ITYPE, res) + SCM_BDIGITS (num)[l]; - if (new < res -#ifndef UNSIGNED - && !(new == MIN_VALUE && l == 0) -#endif - ) + if (pos_res > SCM_BIGDN (UNSIGNED_ITYPE_MAX)) scm_out_of_range (s_caller, num); - res = new; + pos_res = SCM_I_BIGUP (ITYPE, pos_res) + SCM_BDIGITS (num)[l]; } #ifdef UNSIGNED - return res; + return pos_res; #else if (SCM_BIGSIGN (num)) { - res = -res; + ITYPE res = -((ITYPE)pos_res); if (res <= 0) return res; else @@ -65,12 +71,18 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) } else { + ITYPE res = (ITYPE)pos_res; if (res >= 0) return res; else scm_out_of_range (s_caller, num); } #endif + +#else /* SIZEOF_ITYPE >= SIZEOF_SCM_T_BITS */ + scm_out_of_range (s_caller, num); +#endif + } else scm_wrong_type_arg (s_caller, pos, num); @@ -79,43 +91,22 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) SCM INTEGRAL2NUM (ITYPE n) { - /* Determine at compile time whether we need to porferm the FIXABLE - test or not. This is not done to get more optimal code out of - the compiler (it can figure this out on its already), but to - avoid a spurious warning. + /* If we know the size of the type, determine at compile time + whether we need to perform the FIXABLE test or not. This is not + done to get more optimal code out of the compiler (it can figure + this out on its own already), but to avoid a spurious warning. + If we don't know the size, assume that the test must be done. */ -#ifdef NEED_CHECK -#undef NEED_CHECK -#endif - -#ifdef NO_PREPRO_MAGIC -#define NEED_CHECK -#else -#ifdef UNSIGNED -#if MAX_VALUE>SCM_MOST_POSITIVE_FIXNUM -#define NEED_CHECK -#endif -#else -#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM -#define NEED_CHECK -#endif -#endif -#endif - +#if SIZEOF_ITYPE >= SIZEOF_SCM_T_BITS #ifndef UNSIGNED -#ifdef NEED_CHECK if (SCM_FIXABLE (n)) -#endif #else -#ifdef NEED_CHECK if (SCM_POSFIXABLE (n)) #endif #endif return SCM_MAKINUM ((scm_t_signed_bits) n); -#undef NEED_CHECK - #ifdef SCM_BIGDIG return INTEGRAL2BIG (n); #else @@ -142,10 +133,17 @@ INTEGRAL2BIG (ITYPE n) #endif #ifndef UNSIGNED - if (n == MIN_VALUE) - /* special case */ - n_digits = - (sizeof (ITYPE) + sizeof (SCM_BIGDIG) - 1) / sizeof (SCM_BIGDIG); + /* If n is still negative here, it must be the minimum value of the + type (assuming twos-complement, but we are tied to that anyway). + If this is the case, we can not count the number of digits by + right-shifting n until it is zero. + */ + if (n < 0) + { + /* special case */ + n_digits = + (sizeof (ITYPE) + sizeof (SCM_BIGDIG) - 1) / sizeof (SCM_BIGDIG); + } else #endif { @@ -175,11 +173,13 @@ INTEGRAL2BIG (ITYPE n) #undef INTEGRAL2NUM #undef INTEGRAL2BIG #undef NUM2INTEGRAL +#ifdef UNSIGNED #undef UNSIGNED +#endif #undef ITYPE -#undef MIN_VALUE -#undef MAX_VALUE -#undef NO_PREPRO_MAGIC +#undef SIZEOF_ITYPE +#undef UNSIGNED_ITYPE +#undef UNSIGNED_ITYPE_MAX /* Local Variables: diff --git a/libguile/numbers.c b/libguile/numbers.c index 62fb3d918..154974d24 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4258,12 +4258,47 @@ scm_i_big2dbl (SCM b) # endif #endif +/* Parameters for creating integer conversion routines. + + Define the following preprocessor macros before including + "libguile/num2integral.i.c": + + NUM2INTEGRAL - the name of the function for converting from a + Scheme object to the integral type. This function + will be defined when including "num2integral.i.c". + + INTEGRAL2NUM - the name of the function for converting from the + integral type to a Scheme object. This function + will be defined. + + INTEGRAL2BIG - the name of an internal function that createas a + bignum from the integral type. This function will + be defined. The name should start with "scm_i_". + + ITYPE - the name of the integral type. + + UNSIGNED - Define this when ITYPE is an unsigned type. Do not + define it otherwise. + + UNSIGNED_ITYPE + - the name of the the unsigned variant of the + integral type. If you don't define this, it defaults + to "unsigned ITYPE" for signed types and simply "ITYPE" + for unsigned ones. + + SIZEOF_ITYPE - an expression giving the size of the integral type in + bytes. This expression must be computable by the + preprocessor. If you don't know a value for this, + don't define it. The purpose of this parameter is + mainly to suppress some warnings. The generated + code will work correctly without it. +*/ + #define NUM2INTEGRAL scm_num2short #define INTEGRAL2NUM scm_short2num #define INTEGRAL2BIG scm_i_short2big #define ITYPE short -#define MIN_VALUE SHRT_MIN -#define MAX_VALUE SHRT_MAX +#define SIZEOF_ITYPE SIZEOF_SHORT #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2ushort @@ -4271,15 +4306,14 @@ scm_i_big2dbl (SCM b) #define INTEGRAL2BIG scm_i_ushort2big #define UNSIGNED #define ITYPE unsigned short -#define MAX_VALUE USHRT_MAX +#define SIZEOF_ITYPE SIZEOF_SHORT #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2int #define INTEGRAL2NUM scm_int2num #define INTEGRAL2BIG scm_i_int2big #define ITYPE int -#define MIN_VALUE INT_MIN -#define MAX_VALUE INT_MAX +#define SIZEOF_ITYPE SIZEOF_INT #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2uint @@ -4287,15 +4321,14 @@ scm_i_big2dbl (SCM b) #define INTEGRAL2BIG scm_i_uint2big #define UNSIGNED #define ITYPE unsigned int -#define MAX_VALUE UINT_MAX +#define SIZEOF_ITYPE SIZEOF_INT #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2long #define INTEGRAL2NUM scm_long2num #define INTEGRAL2BIG scm_i_long2big #define ITYPE long -#define MIN_VALUE LONG_MIN -#define MAX_VALUE LONG_MAX +#define SIZEOF_ITYPE SIZEOF_LONG #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2ulong @@ -4303,40 +4336,23 @@ scm_i_big2dbl (SCM b) #define INTEGRAL2BIG scm_i_ulong2big #define UNSIGNED #define ITYPE unsigned long -#define MAX_VALUE ULONG_MAX +#define SIZEOF_ITYPE SIZEOF_LONG #include "libguile/num2integral.i.c" -#ifndef PTRDIFF_MIN -/* the below is not really guaranteed to work (I think), but probably does: */ -#define PTRDIFF_MIN ((ptrdiff_t) ((ptrdiff_t)1 << (sizeof (ptrdiff_t)*8 - 1))) -/* this prevents num2integral.c.i from using PTRDIFF_MIN in - preprocessor expressions. */ -#define NO_PREPRO_MAGIC -#endif - -#ifndef PTRDIFF_MAX -#define PTRDIFF_MAX (~ PTRDIFF_MIN) -#endif - #define NUM2INTEGRAL scm_num2ptrdiff #define INTEGRAL2NUM scm_ptrdiff2num #define INTEGRAL2BIG scm_i_ptrdiff2big #define ITYPE ptrdiff_t -#define MIN_VALUE PTRDIFF_MIN -#define MAX_VALUE PTRDIFF_MAX +#define UNSIGNED_ITYPE size_t +#define SIZEOF_ITYPE SIZEOF_PTRDIFF_T #include "libguile/num2integral.i.c" -#ifndef SIZE_MAX -#define SIZE_MAX ((size_t) (-1)) -#define NO_PREPRO_MAGIC -#endif - #define NUM2INTEGRAL scm_num2size #define INTEGRAL2NUM scm_size2num #define INTEGRAL2BIG scm_i_size2big #define UNSIGNED #define ITYPE size_t -#define MAX_VALUE SIZE_MAX +#define SIZEOF_ITYPE SIZEOF_SIZE_T #include "libguile/num2integral.i.c" #ifdef HAVE_LONG_LONGS @@ -4349,9 +4365,7 @@ scm_i_big2dbl (SCM b) #define INTEGRAL2NUM scm_long_long2num #define INTEGRAL2BIG scm_i_long_long2big #define ITYPE long long -#define MIN_VALUE LLONG_MIN -#define MAX_VALUE LLONG_MAX -#define NO_PREPRO_MAGIC +#define SIZEOF_ITYPE SIZEOF_LONG_LONG #include "libguile/num2integral.i.c" #define NUM2INTEGRAL scm_num2ulong_long @@ -4359,8 +4373,7 @@ scm_i_big2dbl (SCM b) #define INTEGRAL2BIG scm_i_ulong_long2big #define UNSIGNED #define ITYPE unsigned long long -#define MAX_VALUE ULLONG_MAX -#define NO_PREPRO_MAGIC +#define SIZEOF_ITYPE SIZEOF_LONG_LONG #include "libguile/num2integral.i.c" #endif /* HAVE_LONG_LONGS */ From 08ae8768723322b57147baaf01e7a37796b15c53 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 01:13:00 +0000 Subject: [PATCH 137/281] (SIZEOF_SCM_T_BITS): Define it appropriately. --- libguile/tags.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libguile/tags.h b/libguile/tags.h index 160987bf1..3f937afa1 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -65,12 +65,14 @@ #ifdef HAVE_UINTPTR_T typedef uintptr_t scm_t_bits; typedef intptr_t scm_t_signed_bits; +#define SIZEOF_SCM_T_BITS SIZEOF_UINTPTR_T #define SCM_T_BITS_MAX UINTPTR_MAX #define SCM_T_SIGNED_BITS_MAX INTPTR_MAX #define SCM_T_SIGNED_BITS_MIN INTPTR_MIN #else typedef unsigned long scm_t_bits; typedef signed long scm_t_signed_bits; +#define SIZEOF_SCM_T_BITS SIZEOF_LONG #define SCM_T_BITS_MAX ULONG_MAX #define SCM_T_SIGNED_BITS_MAX LONG_MAX #define SCM_T_SIGNED_BITS_MIN LONG_MIN From 1f5376556fb96f5f56ed8fed3b536b07fdc53d8d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 01:14:17 +0000 Subject: [PATCH 138/281] Use HAVE_LONG_LONG instead of HAVE_LONG_LONGS and test it with `#ifdef' instead of `#if'. --- srfi/srfi-4.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/srfi/srfi-4.c b/srfi/srfi-4.c index c90b36675..9ecd8b167 100644 --- a/srfi/srfi-4.c +++ b/srfi/srfi-4.c @@ -56,7 +56,7 @@ typedef unsigned short int_u16; typedef signed short int_s16; typedef unsigned int int_u32; typedef signed int int_s32; -#if HAVE_LONG_LONGS +#ifdef HAVE_LONG_LONG #if SIZEOF_LONG == 8 typedef unsigned long int_u64; typedef signed long int_s64; @@ -64,7 +64,7 @@ typedef signed long int_s64; typedef unsigned long long int_u64; typedef signed long long int_s64; #endif /* SIZEOF_LONG */ -#endif /* HAVE_LONG_LONGS */ +#endif /* HAVE_LONG_LONG */ typedef float float_f32; typedef double float_f64; @@ -245,7 +245,7 @@ uvec_print (SCM uvec, SCM port, scm_print_state *pstate SCM_UNUSED) break; } -#if HAVE_LONG_LONGS +#ifdef HAVE_LONG_LONG case SCM_UVEC_U64: { int_u64 * p = (int_u64 *) SCM_UVEC_BASE (uvec); @@ -1427,7 +1427,7 @@ SCM_DEFINE (scm_list_to_s32vector, "list->s32vector", 1, 0, 0, #undef FUNC_NAME -#if HAVE_LONG_LONGS +#ifdef HAVE_LONG_LONG /* ================================================================ */ /* U64 procedures. */ @@ -1770,7 +1770,7 @@ SCM_DEFINE (scm_list_to_s64vector, "list->s64vector", 1, 0, 0, } #undef FUNC_NAME -#endif /* HAVE_LONG_LONGS */ +#endif /* HAVE_LONG_LONG */ /* ================================================================ */ From 5d8fc6409af52aa8089f2ddcec4245da9784b042 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 01:14:26 +0000 Subject: [PATCH 139/281] *** empty log message *** --- libguile/ChangeLog | 23 +++++++++++++++++++++++ srfi/ChangeLog | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index aa26023c4..e7a380456 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,26 @@ +2001-11-12 Marius Vollmer + + * numbers.c: Document macros to define when including + num2integral.i.c. MAX_VALUE and MIN_VALU are no longer used, we + now rely on SIZEOF_ macros that have been figured out at + configure time. + + * num2integral.i.c: Adapt to new interface. + (NUM2INTEGRAL): Test whether a fixnum can be represented in the + target type by casting it and checking whether it is still the + same. Do not try to handle bignums for integral types that are + smaller than fixnums. When handling bignums, collect the + magnituse first into a unsigned type, and correctly check for + overflow. + (INTEGRAL2BIG): Do not use MIN_VALUE explicitely by observing that + only -MIN_VALUE can still be negative of all negative numbers (in + twos-complement). + + * tags.h (SIZEOF_SCM_T_BITS): Define it appropriately. + + * __scm.h: Define HAVE_UINTPTR_T, HAVE_PTRDIFF_T and + HAVE_LONG_LONG depending on whether their size is non-zero. + 2001-11-11 Thien-Thi Nguyen * strop.c (scm_string_null_p): Docfix; nfc. diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 85125714f..ab14c474e 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,8 @@ +2001-11-12 Marius Vollmer + + * srfi-4.c: Use HAVE_LONG_LONG instead of HAVE_LONG_LONGS and test + it with `#ifdef' instead of `#if'. + 2001-11-07 Neil Jerram * srfi-13.c (scm_string_unfold, scm_string_unfold_right), From 0bc9a83a58f531e70eac63b50dc39803b0bdfc31 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 01:30:23 +0000 Subject: [PATCH 140/281] *** empty log message *** --- devel/translation/lisp-and-scheme.text | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 devel/translation/lisp-and-scheme.text diff --git a/devel/translation/lisp-and-scheme.text b/devel/translation/lisp-and-scheme.text new file mode 100644 index 000000000..e69de29bb From 1d61174a12efeca36d88786018f834ab3addec5e Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 12 Nov 2001 07:19:16 +0000 Subject: [PATCH 141/281] Restrict documentation change log waiver to only apply to ChangeLog files. --- HACKING | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/HACKING b/HACKING index dd491b11b..23e01b956 100644 --- a/HACKING +++ b/HACKING @@ -448,12 +448,10 @@ alias for scm_map that guarantees the order in which we process list elements, but we're not changing scm_map at all --- it's appropriate to use the Scheme name in the log entry. -- There's no need to keep a change log for documentation files. This -is because documentation is not susceptible to bugs that are hard to -fix. Documentation does not consist of parts that must interact in a -precisely engineered fashion; to correct an error, you need not know -the history of the erroneous passage. (This is copied from the GNU -coding standards.) +- There's no need to keep a change log for a ChangeLog file. For any +other kind of file (including documentation, since our documentation +is indeed precisely engineered -- we surpass GNU standards here), add +an appropriate ChangeLog entry when you change it. Simple! - Make sure you have papers from people before integrating their changes or contributions. This is very frustrating, but very From bca0bf8def7dcdf5994f8aec90336e74022e8bf0 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 12 Nov 2001 07:21:24 +0000 Subject: [PATCH 142/281] *** empty log message *** --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8599d90bd..1ccaca3bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-11 Thien-Thi Nguyen + + * HACKING: Restrict documentation change log + waiver to only apply to ChangeLog files. + 2001-11-12 Marius Vollmer * configure.in: Check for sizes of short, size_t, uintptr_t, and From 697440cbc0ccae1475c2145c1c2822c286c0c3ba Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 12 Nov 2001 08:09:46 +0000 Subject: [PATCH 143/281] (guile-core-dir): New var. (docstring-manual-directory, docstring-tracking-root, docstring-snarfed-roots): Rework to construct using new var. --- doc/maint/docstring.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/maint/docstring.el b/doc/maint/docstring.el index 731c62e90..e0c05fa58 100644 --- a/doc/maint/docstring.el +++ b/doc/maint/docstring.el @@ -57,17 +57,21 @@ ;;; Code: -(defvar docstring-manual-directory (expand-file-name "~/Guile/cvs/guile-core/doc/ref") +(defvar guile-core-dir (or (getenv "GUILE_MAINTAINER_GUILE_CORE_DIR") + "~/Guile/cvs/guile-core")) + +(defvar docstring-manual-directory (expand-file-name "doc/ref" guile-core-dir) "*The directory containing the Texinfo source for the Guile reference manual.") -(defvar docstring-tracking-root (expand-file-name "~/Guile/cvs/guile-core/doc/maint") +(defvar docstring-tracking-root (expand-file-name "doc/maint" guile-core-dir) "*Root directory for docstring tracking files. The tracking file for module (a b c) is expected to be in the file /a/b/c.texi.") -(defvar docstring-snarfed-roots (list (expand-file-name "~/Guile/cvs/guile-core/libguile") - (expand-file-name "~/Guile/cvs/guile-core/ice-9") - (expand-file-name "~/Guile/cvs/guile-core/oop")) +(defvar docstring-snarfed-roots (mapcar + #'(lambda (frag) + (expand-file-name frag guile-core-dir)) + '("libguile" "ice-9" "oop")) "*List of possible root directories for snarfed docstring files. For each entry in this list, the snarfed docstring file for module (a b c) is looked for in the file /a/b/c.texi.") @@ -255,7 +259,7 @@ to which new docstrings should be added.") (setq action nil issue (if manual-location 'consider-removal - nil))) + nil))) ((null manual-location) (setq action 'add-to-manual issue nil)) @@ -493,7 +497,7 @@ new snarfed docstring file.\n\n") (docstring-narrow-to-location manual-location) (add-hook 'ediff-quit-hook 'docstring-widen-ediff-buffers) - + (ediff-buffers3 (nth 0 docstring-ediff-buffers) (nth 1 docstring-ediff-buffers) (nth 2 docstring-ediff-buffers))))) @@ -532,3 +536,5 @@ new snarfed docstring file.\n\n") ;(find-snarfed-docstring '(guile) "primitive sloppy-assq") (provide 'docstring) + +;;; docstring.el ends here From de852d147444f72828e591dc804f5f3847d29514 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 12 Nov 2001 08:37:03 +0000 Subject: [PATCH 144/281] Point to source for docstring.el customization. Add "For Example" section. --- doc/maint/README | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/maint/README b/doc/maint/README index d88589325..33ffdf3a2 100644 --- a/doc/maint/README +++ b/doc/maint/README @@ -8,10 +8,21 @@ in the libguile C source change. - README is this file. -- docstring.el is a helpful Emacs Lisp library. The two key entry - points are `docstring-process-module' and - `docstring-ediff-this-line'. +- docstring.el is a helpful Emacs Lisp library (see source for + customziation). The two key entry points are: + `docstring-process-module' and + `docstring-ediff-this-line'. - guile.texi is a snapshot of the built file guile-core/libguile/guile.texi, copied last time the reference manual was determined to be in sync with the libguile source. + +For example: + +If you've just fixed a docstring in, say, ../libguile/strop.c, do in emacs: + + M-x load-file RET .../doc/maint/docstring.el RET + M-x docstring-process-module RET (guile) RET + +Save all modified .texi files and copy the current ../libguile/guile.texi +to ./guile.texi, then commit. See elisp var `docstring-snarfed-roots'. From cebb2d1f520ad3799b514511cd9b7eff78cb6375 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 22:16:27 +0000 Subject: [PATCH 145/281] Recurse into libltdl directory and invoke autoconf there. --- autogen.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autogen.sh b/autogen.sh index 10bf34a30..9b867aacc 100755 --- a/autogen.sh +++ b/autogen.sh @@ -12,6 +12,10 @@ autoheader autoconf automake --add-missing +# Make sure that libltdl uses the same autoconf version as the rest. +# +( echo "libltdl..."; cd libltdl; autoconf ) + ( echo "guile-readline..."; cd guile-readline; ./autogen.sh ) echo "Now run configure and make." From a714e0ebe23c766c742b4d1d7d4eb6d8eab13fd9 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 12 Nov 2001 22:16:48 +0000 Subject: [PATCH 146/281] *** empty log message *** --- ChangeLog | 5 +++++ THANKS | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1ccaca3bd..ad1318061 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-12 Marius Vollmer + + * autogen.sh: Recurse into libltdl directory and invoke autoconf + there. + 2001-11-11 Thien-Thi Nguyen * HACKING: Restrict documentation change log diff --git a/THANKS b/THANKS index 167327846..319ea677d 100644 --- a/THANKS +++ b/THANKS @@ -18,3 +18,4 @@ For fixes or providing information which led to a fix: Christopher Cramer John Goerzen Ken Raeburn + Momchil Velikov From b56b5983a3fbfed7864106a1408588fd7f715ddb Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Tue, 13 Nov 2001 00:25:46 +0000 Subject: [PATCH 147/281] * Various small doc fixes. --- doc/maint/README | 2 +- doc/ref/ChangeLog | 6 ++++++ doc/ref/scheme-data.texi | 10 +++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/maint/README b/doc/maint/README index 33ffdf3a2..c06599127 100644 --- a/doc/maint/README +++ b/doc/maint/README @@ -9,7 +9,7 @@ in the libguile C source change. - README is this file. - docstring.el is a helpful Emacs Lisp library (see source for - customziation). The two key entry points are: + customization). The two key entry points are: `docstring-process-module' and `docstring-ediff-this-line'. diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index cdd5ee958..04c1c012f 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,9 @@ +2001-11-12 Neil Jerram + + * scheme-data.texi (Vtables, Structure Basics): Automatic doc + updates for struct? and struct-vtable?. + (String Searching): Add missing "for". Thanks to Scott Lenser. + 2001-11-08 Neil Jerram * guile.texi (Top): Added new chapter `Programming Options'. diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 235644c63..8b27b2366 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -1415,7 +1415,7 @@ Return @code{#t} iff @var{obj} is a string, else @code{#f}. @end deffn @deffn primitive string-null? str -Return @code{#t} if @var{str}'s length is nonzero, and +Return @code{#t} if @var{str}'s length is zero, and @code{#f} otherwise. @lisp (string-null? "") @result{} #t @@ -1691,8 +1691,8 @@ equal to @var{s2} regardless of case. @node String Searching @subsection String Searching -When searching the index of a character in a string, these procedures -can be used. +When searching for the index of a character in a string, these +procedures can be used. @deffn primitive string-index str chr [frm [to]] Return the index of the first occurrence of @var{chr} in @@ -3762,7 +3762,7 @@ For more information, see the documentation for @code{make-vtable-vtable}. @end deffn @deffn primitive struct? x -Return @code{#t} iff @var{obj} is a structure object, else +Return @code{#t} iff @var{x} is a structure object, else @code{#f}. @end deffn @@ -3795,7 +3795,7 @@ Return the vtable structure that describes the type of @var{struct}. @end deffn @deffn primitive struct-vtable? x -Return @code{#t} iff obj is a vtable structure. +Return @code{#t} iff @var{x} is a vtable structure. @end deffn If you have a vtable structure, @code{V}, you can create an instance of From 28206d04662df7fe366623228a8953d3ce3f6e0c Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Tue, 13 Nov 2001 00:35:47 +0000 Subject: [PATCH 148/281] * Check in new guile.texi tracking file. --- doc/maint/guile.texi | 138 +++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/doc/maint/guile.texi b/doc/maint/guile.texi index 8b6b5efe5..e39b1edb3 100644 --- a/doc/maint/guile.texi +++ b/doc/maint/guile.texi @@ -983,14 +983,14 @@ it will usually be @code{#f}. @end deffn strerror -@c snarfed from error.c:157 +@c snarfed from error.c:168 @deffn primitive strerror err Return the Unix error message corresponding to @var{err}, which must be an integer value. @end deffn apply:nconc2last -@c snarfed from eval.c:3326 +@c snarfed from eval.c:3329 @deffn primitive apply:nconc2last lst Given a list (@var{arg1} @dots{} @var{args}), this function conses the @var{arg1} @dots{} arguments onto the front of @@ -1002,7 +1002,7 @@ destroys its argument, so use with care. @end deffn force -@c snarfed from eval.c:3861 +@c snarfed from eval.c:3864 @deffn primitive force x If the promise @var{x} has not been computed yet, compute and return @var{x}, otherwise just return the previously computed @@ -1010,14 +1010,14 @@ value. @end deffn promise? -@c snarfed from eval.c:3884 +@c snarfed from eval.c:3887 @deffn primitive promise? obj Return true if @var{obj} is a promise, i.e. a delayed computation (@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). @end deffn cons-source -@c snarfed from eval.c:3896 +@c snarfed from eval.c:3899 @deffn primitive cons-source xorig x y Create and return a new pair whose car and cdr are @var{x} and @var{y}. Any source properties associated with @var{xorig} are also associated @@ -1025,7 +1025,7 @@ with the new pair. @end deffn copy-tree -@c snarfed from eval.c:3918 +@c snarfed from eval.c:3921 @deffn primitive copy-tree obj Recursively copy the data tree that is bound to @var{obj}, and return a pointer to the new data structure. @code{copy-tree} recurses down the @@ -1035,14 +1035,14 @@ any other object. @end deffn primitive-eval -@c snarfed from eval.c:4011 +@c snarfed from eval.c:4014 @deffn primitive primitive-eval exp Evaluate @var{exp} in the top-level environment specified by the current module. @end deffn eval -@c snarfed from eval.c:4080 +@c snarfed from eval.c:4083 @deffn primitive eval exp module Evaluate @var{exp}, a list representing a Scheme expression, in the top-level environment specified by @var{module}. @@ -4372,7 +4372,7 @@ y string-null? @c snarfed from strop.c:321 @deffn primitive string-null? str -Return @code{#t} if @var{str}'s length is nonzero, and +Return @code{#t} if @var{str}'s length is zero, and @code{#f} otherwise. @lisp (string-null? "") @result{} #t @@ -4653,14 +4653,14 @@ indicate that the field is a tail-array. struct? @c snarfed from struct.c:244 @deffn primitive struct? x -Return @code{#t} iff @var{obj} is a structure object, else +Return @code{#t} iff @var{x} is a structure object, else @code{#f}. @end deffn struct-vtable? @c snarfed from struct.c:253 @deffn primitive struct-vtable? x -Return @code{#t} iff obj is a vtable structure. +Return @code{#t} iff @var{x} is a vtable structure. @end deffn make-struct @@ -5654,7 +5654,7 @@ as @var{array}, if used as the @var{prototype} for @end deffn chown -@c snarfed from filesys.c:170 +@c snarfed from filesys.c:213 @deffn primitive chown object owner group Change the ownership and group of the file referred to by @var{object} to the integer values @var{owner} and @var{group}. @var{object} can be @@ -5671,7 +5671,7 @@ as @code{-1}, then that ID is not changed. @end deffn chmod -@c snarfed from filesys.c:210 +@c snarfed from filesys.c:253 @deffn primitive chmod object mode Changes the permissions of the file referred to by @var{obj}. @var{obj} can be a string containing a file name or a port or integer file @@ -5683,7 +5683,7 @@ The return value is unspecified. @end deffn umask -@c snarfed from filesys.c:243 +@c snarfed from filesys.c:286 @deffn primitive umask [mode] If @var{mode} is omitted, retuns a decimal number representing the current file creation mask. Otherwise the file creation mask is set to @@ -5693,14 +5693,14 @@ E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18. @end deffn open-fdes -@c snarfed from filesys.c:266 +@c snarfed from filesys.c:309 @deffn primitive open-fdes path flags [mode] Similar to @code{open} but return a file descriptor instead of a port. @end deffn open -@c snarfed from filesys.c:308 +@c snarfed from filesys.c:351 @deffn primitive open path flags [mode] Open the file named by @var{path} for reading and/or writing. @var{flags} is an integer specifying how the file should be opened. @@ -5732,7 +5732,7 @@ for additional flags. @end deffn close -@c snarfed from filesys.c:346 +@c snarfed from filesys.c:389 @deffn primitive close fd_or_port Similar to close-port (@pxref{Generic Port Operations, close-port}), but also works on file descriptors. A side @@ -5742,7 +5742,7 @@ their revealed counts set to zero. @end deffn close-fdes -@c snarfed from filesys.c:374 +@c snarfed from filesys.c:417 @deffn primitive close-fdes fd A simple wrapper for the @code{close} system call. Close file descriptor @var{fd}, which must be an integer. @@ -5752,7 +5752,7 @@ The return value is unspecified. @end deffn stat -@c snarfed from filesys.c:577 +@c snarfed from filesys.c:620 @deffn primitive stat object Return an object containing various information about the file determined by @var{obj}. @var{obj} can be a string containing @@ -5813,7 +5813,7 @@ An integer representing the access permission bits. @end deffn link -@c snarfed from filesys.c:640 +@c snarfed from filesys.c:683 @deffn primitive link oldpath newpath Creates a new name @var{newpath} in the file system for the file named by @var{oldpath}. If @var{oldpath} is a symbolic @@ -5822,20 +5822,20 @@ system. @end deffn rename-file -@c snarfed from filesys.c:661 +@c snarfed from filesys.c:704 @deffn primitive rename-file oldname newname Renames the file specified by @var{oldname} to @var{newname}. The return value is unspecified. @end deffn delete-file -@c snarfed from filesys.c:688 +@c snarfed from filesys.c:731 @deffn primitive delete-file str Deletes (or "unlinks") the file specified by @var{path}. @end deffn mkdir -@c snarfed from filesys.c:706 +@c snarfed from filesys.c:749 @deffn primitive mkdir path [mode] Create a new directory named by @var{path}. If @var{mode} is omitted then the permissions of the directory file are set using the current @@ -5844,28 +5844,28 @@ umask. Otherwise they are set to the decimal value specified with @end deffn rmdir -@c snarfed from filesys.c:734 +@c snarfed from filesys.c:777 @deffn primitive rmdir path Remove the existing directory named by @var{path}. The directory must be empty for this to succeed. The return value is unspecified. @end deffn directory-stream? -@c snarfed from filesys.c:759 +@c snarfed from filesys.c:802 @deffn primitive directory-stream? obj Return a boolean indicating whether @var{object} is a directory stream as returned by @code{opendir}. @end deffn opendir -@c snarfed from filesys.c:770 +@c snarfed from filesys.c:813 @deffn primitive opendir dirname Open the directory specified by @var{path} and return a directory stream. @end deffn readdir -@c snarfed from filesys.c:787 +@c snarfed from filesys.c:830 @deffn primitive readdir port Return (as a string) the next directory entry from the directory stream @var{stream}. If there is no remaining entry to be read then the @@ -5873,34 +5873,34 @@ end of file object is returned. @end deffn rewinddir -@c snarfed from filesys.c:810 +@c snarfed from filesys.c:853 @deffn primitive rewinddir port Reset the directory port @var{stream} so that the next call to @code{readdir} will return the first directory entry. @end deffn closedir -@c snarfed from filesys.c:827 +@c snarfed from filesys.c:870 @deffn primitive closedir port Close the directory stream @var{stream}. The return value is unspecified. @end deffn chdir -@c snarfed from filesys.c:877 +@c snarfed from filesys.c:920 @deffn primitive chdir str Change the current working directory to @var{path}. The return value is unspecified. @end deffn getcwd -@c snarfed from filesys.c:893 +@c snarfed from filesys.c:936 @deffn primitive getcwd Return the name of the current working directory. @end deffn select -@c snarfed from filesys.c:1089 +@c snarfed from filesys.c:1132 @deffn primitive select reads writes excepts [secs [usecs]] This procedure has a variety of uses: waiting for the ability to provide input, accept output, or the existance of @@ -5934,7 +5934,7 @@ An additional @code{select!} interface is provided. @end deffn fcntl -@c snarfed from filesys.c:1235 +@c snarfed from filesys.c:1278 @deffn primitive fcntl object cmd [value] Apply @var{command} to the specified file descriptor or the underlying file descriptor of the specified port. @var{value} is an optional @@ -5964,7 +5964,7 @@ The value used to indicate the "close on exec" flag with @code{F_GETFL} or @end deffn fsync -@c snarfed from filesys.c:1272 +@c snarfed from filesys.c:1315 @deffn primitive fsync object Copies any unwritten data for the specified output file descriptor to disk. If @var{port/fd} is a port, its buffer is flushed before the underlying @@ -5973,21 +5973,21 @@ The return value is unspecified. @end deffn symlink -@c snarfed from filesys.c:1299 +@c snarfed from filesys.c:1342 @deffn primitive symlink oldpath newpath Create a symbolic link named @var{path-to} with the value (i.e., pointing to) @var{path-from}. The return value is unspecified. @end deffn readlink -@c snarfed from filesys.c:1318 +@c snarfed from filesys.c:1361 @deffn primitive readlink path Return the value of the symbolic link named by @var{path} (a string), i.e., the file that the link points to. @end deffn lstat -@c snarfed from filesys.c:1347 +@c snarfed from filesys.c:1390 @deffn primitive lstat str Similar to @code{stat}, but does not follow symbolic links, i.e., it will return information about a symbolic link itself, not the @@ -5995,14 +5995,14 @@ file it points to. @var{path} must be a string. @end deffn copy-file -@c snarfed from filesys.c:1371 +@c snarfed from filesys.c:1414 @deffn primitive copy-file oldfile newfile Copy the file specified by @var{path-from} to @var{path-to}. The return value is unspecified. @end deffn dirname -@c snarfed from filesys.c:1416 +@c snarfed from filesys.c:1459 @deffn primitive dirname filename Return the directory name component of the file name @var{filename}. If @var{filename} does not contain a directory @@ -6010,7 +6010,7 @@ component, @code{.} is returned. @end deffn basename -@c snarfed from filesys.c:1459 +@c snarfed from filesys.c:1502 @deffn primitive basename filename [suffix] Return the base name of the file name @var{filename}. The base name is the file name without any directory components. @@ -6595,7 +6595,7 @@ characters is disabled. @end deffn flock -@c snarfed from posix.c:1524 +@c snarfed from posix.c:1590 @deffn primitive flock file operation Apply or remove an advisory lock on an open file. @var{operation} specifies the action to be done: @@ -6617,7 +6617,7 @@ file descriptor or an open file descriptior port. @end deffn sethostname -@c snarfed from posix.c:1550 +@c snarfed from posix.c:1616 @deffn primitive sethostname name Set the host name of the current processor to @var{name}. May only be used by the superuser. The return value is not @@ -6625,7 +6625,7 @@ specified. @end deffn gethostname -@c snarfed from posix.c:1565 +@c snarfed from posix.c:1631 @deffn primitive gethostname Return the host name of the current processor. @end deffn @@ -6713,7 +6713,7 @@ Otherwise it is equivalent to @code{setservent stayopen}. @end deffn htons -@c snarfed from socket.c:101 +@c snarfed from socket.c:105 @deffn primitive htons value Convert a 16 bit quantity from host to network byte ordering. @var{value} is packed into 2 bytes, which are then converted @@ -6721,7 +6721,7 @@ and returned as a new integer. @end deffn ntohs -@c snarfed from socket.c:118 +@c snarfed from socket.c:122 @deffn primitive ntohs value Convert a 16 bit quantity from network to host byte ordering. @var{value} is packed into 2 bytes, which are then converted @@ -6729,7 +6729,7 @@ and returned as a new integer. @end deffn htonl -@c snarfed from socket.c:135 +@c snarfed from socket.c:139 @deffn primitive htonl value Convert a 32 bit quantity from host to network byte ordering. @var{value} is packed into 4 bytes, which are then converted @@ -6737,7 +6737,7 @@ and returned as a new integer. @end deffn ntohl -@c snarfed from socket.c:148 +@c snarfed from socket.c:152 @deffn primitive ntohl value Convert a 32 bit quantity from network to host byte ordering. @var{value} is packed into 4 bytes, which are then converted @@ -6745,7 +6745,7 @@ and returned as a new integer. @end deffn inet-aton -@c snarfed from socket.c:168 +@c snarfed from socket.c:172 @deffn primitive inet-aton address Convert an IPv4 Internet address from printable string (dotted decimal notation) to an integer. E.g., @@ -6756,7 +6756,7 @@ Convert an IPv4 Internet address from printable string @end deffn inet-ntoa -@c snarfed from socket.c:187 +@c snarfed from socket.c:191 @deffn primitive inet-ntoa inetid Convert an IPv4 Internet address to a printable (dotted decimal notation) string. E.g., @@ -6767,7 +6767,7 @@ Convert an IPv4 Internet address to a printable @end deffn inet-netof -@c snarfed from socket.c:207 +@c snarfed from socket.c:211 @deffn primitive inet-netof address Return the network number part of the given IPv4 Internet address. E.g., @@ -6778,7 +6778,7 @@ Internet address. E.g., @end deffn inet-lnaof -@c snarfed from socket.c:225 +@c snarfed from socket.c:229 @deffn primitive inet-lnaof address Return the local-address-with-network part of the given IPv4 Internet address, using the obsolete class A/B/C system. @@ -6790,7 +6790,7 @@ E.g., @end deffn inet-makeaddr -@c snarfed from socket.c:243 +@c snarfed from socket.c:247 @deffn primitive inet-makeaddr net lna Make an IPv4 Internet address by combining the network number @var{net} with the local-address-within-network number @@ -6802,7 +6802,7 @@ Make an IPv4 Internet address by combining the network number @end deffn inet-pton -@c snarfed from socket.c:361 +@c snarfed from socket.c:365 @deffn primitive inet-pton family address Convert a string containing a printable network address to an integer address. Note that unlike the C version of this @@ -6817,7 +6817,7 @@ the result is an integer with normal host byte ordering. @end deffn inet-ntop -@c snarfed from socket.c:396 +@c snarfed from socket.c:400 @deffn primitive inet-ntop family address Convert a network address into a printable string. Note that unlike the C version of this function, @@ -6832,7 +6832,7 @@ ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff @end deffn socket -@c snarfed from socket.c:441 +@c snarfed from socket.c:445 @deffn primitive socket family style proto Return a new socket port of the type specified by @var{family}, @var{style} and @var{proto}. All three parameters are @@ -6850,7 +6850,7 @@ has been connected to another socket. @end deffn socketpair -@c snarfed from socket.c:463 +@c snarfed from socket.c:467 @deffn primitive socketpair family style proto Return a pair of connected (but unnamed) socket ports of the type specified by @var{family}, @var{style} and @var{proto}. @@ -6860,7 +6860,7 @@ family. Zero is likely to be the only meaningful value for @end deffn getsockopt -@c snarfed from socket.c:492 +@c snarfed from socket.c:496 @deffn primitive getsockopt sock level optname Return the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of @@ -6874,7 +6874,7 @@ returns a pair of integers. @end deffn setsockopt -@c snarfed from socket.c:560 +@c snarfed from socket.c:564 @deffn primitive setsockopt sock level optname value Set the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of option @@ -6890,7 +6890,7 @@ The return value is unspecified. @end deffn shutdown -@c snarfed from socket.c:664 +@c snarfed from socket.c:668 @deffn primitive shutdown sock how Sockets can be closed simply by using @code{close-port}. The @code{shutdown} procedure allows reception or tranmission on a @@ -6912,7 +6912,7 @@ The return value is unspecified. @end deffn connect -@c snarfed from socket.c:808 +@c snarfed from socket.c:812 @deffn primitive connect sock fam address . args Initiate a connection from a socket using a specified address family to the address @@ -6938,7 +6938,7 @@ The return value is unspecified. @end deffn bind -@c snarfed from socket.c:868 +@c snarfed from socket.c:872 @deffn primitive bind sock fam address . args Assign an address to the socket port @var{sock}. Generally this only needs to be done for server sockets, @@ -6986,7 +6986,7 @@ The return value is unspecified. @end deffn listen -@c snarfed from socket.c:902 +@c snarfed from socket.c:906 @deffn primitive listen sock backlog Enable @var{sock} to accept connection requests. @var{backlog} is an integer specifying @@ -6999,7 +6999,7 @@ The return value is unspecified. @end deffn accept -@c snarfed from socket.c:1007 +@c snarfed from socket.c:1011 @deffn primitive accept sock Accept a connection on a bound, listening socket. If there @@ -7018,7 +7018,7 @@ connection and will continue to accept new requests. @end deffn getsockname -@c snarfed from socket.c:1034 +@c snarfed from socket.c:1038 @deffn primitive getsockname sock Return the address of @var{sock}, in the same form as the object returned by @code{accept}. On many systems the address @@ -7026,7 +7026,7 @@ of a socket in the @code{AF_FILE} namespace cannot be read. @end deffn getpeername -@c snarfed from socket.c:1056 +@c snarfed from socket.c:1060 @deffn primitive getpeername sock Return the address that @var{sock} is connected to, in the same form as the object returned by @@ -7035,7 +7035,7 @@ is connected to, in the same form as the object returned by @end deffn recv! -@c snarfed from socket.c:1091 +@c snarfed from socket.c:1095 @deffn primitive recv! sock buf [flags] Receive data from a socket port. @var{sock} must already @@ -7060,7 +7060,7 @@ any unread buffered port data is ignored. @end deffn send -@c snarfed from socket.c:1124 +@c snarfed from socket.c:1128 @deffn primitive send sock message [flags] Transmit the string @var{message} on a socket port @var{sock}. @var{sock} must already be bound to a destination address. The @@ -7078,7 +7078,7 @@ any unflushed buffered port data is ignored. @end deffn recvfrom! -@c snarfed from socket.c:1164 +@c snarfed from socket.c:1168 @deffn primitive recvfrom! sock str [flags [start [end]]] Return data from the socket port @var{sock} and also information about where the data was received from. @@ -7106,7 +7106,7 @@ descriptor: any unread buffered port data is ignored. @end deffn sendto -@c snarfed from socket.c:1222 +@c snarfed from socket.c:1226 @deffn primitive sendto sock message fam address . args_and_flags Transmit the string @var{message} on the socket port @var{sock}. The From cd99053982a30802b4468adde0e4c8c6725baf3f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 13 Nov 2001 14:28:42 +0000 Subject: [PATCH 149/281] (HAVE_UINTPTR_T, HAVE_PTRDIFF_T, HAVE_LONG_LONG, HAVE_LONG_LONGS): Define to "1" when defining them, to mirror what configure does. --- libguile/__scm.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libguile/__scm.h b/libguile/__scm.h index 29abc9d09..d9e26cada 100644 --- a/libguile/__scm.h +++ b/libguile/__scm.h @@ -294,16 +294,16 @@ */ #if SIZEOF_UINTPTR_T != 0 -#define HAVE_UINTPTR_T +#define HAVE_UINTPTR_T 1 #endif #if SIZEOF_PTRDIFF_T != 0 -#define HAVE_PTRDIFF_T +#define HAVE_PTRDIFF_T 1 #endif #if SIZEOF_LONG_LONG != 0 -#define HAVE_LONG_LONGS -#define HAVE_LONG_LONG +#define HAVE_LONG_LONGS 1 +#define HAVE_LONG_LONG 1 #endif #ifndef HAVE_PTRDIFF_T From 6558eda6e71fd5080773edb6a2b10503514c8af7 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 13 Nov 2001 14:29:02 +0000 Subject: [PATCH 150/281] *** empty log message *** --- THANKS | 1 + libguile/ChangeLog | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/THANKS b/THANKS index 319ea677d..4d9d9f2da 100644 --- a/THANKS +++ b/THANKS @@ -18,4 +18,5 @@ For fixes or providing information which led to a fix: Christopher Cramer John Goerzen Ken Raeburn + Bill Schottstaedt Momchil Velikov diff --git a/libguile/ChangeLog b/libguile/ChangeLog index e7a380456..9a4478ff0 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2001-11-13 Marius Vollmer + + * __scm.h (HAVE_UINTPTR_T, HAVE_PTRDIFF_T, HAVE_LONG_LONG, + HAVE_LONG_LONGS): Define to "1" when defining them, to mirror what + configure does. + 2001-11-12 Marius Vollmer * numbers.c: Document macros to define when including From 0534158ad04e48ab1d2fa1ef016c00736ba005a5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 13 Nov 2001 15:46:29 +0000 Subject: [PATCH 151/281] (scm_substring_move_left_x, scm_substring_move_right_x): Removed. --- libguile/strop.c | 74 +----------------------------------------------- libguile/strop.h | 3 -- 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/libguile/strop.c b/libguile/strop.c index ec92ef340..1271dea08 100644 --- a/libguile/strop.c +++ b/libguile/strop.c @@ -181,83 +181,11 @@ SCM_DEFINE (scm_string_rindex, "string-rindex", 2, 2, 0, } #undef FUNC_NAME - -SCM_REGISTER_PROC(s_substring_move_left_x, "substring-move-left!", 5, 0, 0, scm_substring_move_x); -SCM_REGISTER_PROC(s_substring_move_right_x, "substring-move-right!", 5, 0, 0, scm_substring_move_x); - -/* -@defun substring-move-left! str1 start1 end1 str2 start2 -@end defun -@deftypefn {C Function} SCM scm_substring_move_left_x (SCM @var{str1}, SCM @var{start1}, SCM @var{end1}, SCM @var{str2}, SCM @var{start2}) -[@strong{Note:} this is only valid if you've applied the strop patch]. - -Moves a substring of @var{str1}, from @var{start1} to @var{end1} -(@var{end1} is exclusive), into @var{str2}, starting at -@var{start2}. Allows overlapping strings. - -@lisp -(define x (make-string 10 #\a)) -(define y "bcd") -(substring-move-left! x 2 5 y 0) -y -@result{} "aaa" - -x -@result{} "aaaaaaaaaa" - -(define y "bcdefg") -(substring-move-left! x 2 5 y 0) -y -@result{} "aaaefg" - -(define y "abcdefg") -(substring-move-left! y 2 5 y 3) -y -@result{} "abccccg" -@end lisp -*/ - -/* -@defun substring-move-right! str1 start1 end1 str2 start2 -@end defun -@deftypefn {C Function} SCM scm_substring_move_right_x (SCM @var{str1}, SCM @var{start1}, SCM @var{end1}, SCM @var{str2}, SCM @var{start2}) -[@strong{Note:} this is only valid if you've applied the strop patch, if -it hasn't made it into the guile tree]. - -Does much the same thing as @code{substring-move-left!}, except it -starts moving at the end of the sequence, rather than the beginning. -@lisp -(define y "abcdefg") -(substring-move-right! y 2 5 y 0) -y -@result{} "ededefg" - -(define y "abcdefg") -(substring-move-right! y 2 5 y 3) -y -@result{} "abccdeg" -@end lisp -*/ - SCM_DEFINE (scm_substring_move_x, "substring-move!", 5, 0, 0, (SCM str1, SCM start1, SCM end1, SCM str2, SCM start2), - "@deffnx primitive substring-move-left! str1 start1 end1 str2 start2\n" - "@deffnx primitive substring-move-right! str1 start1 end1 str2 start2\n" "Copy the substring of @var{str1} bounded by @var{start1} and @var{end1}\n" "into @var{str2} beginning at position @var{start2}.\n" - "@code{substring-move-right!} begins copying from the rightmost character\n" - "and moves left, and @code{substring-move-left!} copies from the leftmost\n" - "character moving right.\n\n" - "It is useful to have two functions that copy in different directions so\n" - "that substrings can be copied back and forth within a single string. If\n" - "you wish to copy text from the left-hand side of a string to the\n" - "right-hand side of the same string, and the source and destination\n" - "overlap, you must be careful to copy the rightmost characters of the\n" - "text first, to avoid clobbering your data. Hence, when @var{str1} and\n" - "@var{str2} are the same string, you should use\n" - "@code{substring-move-right!} when moving text from left to right, and\n" - "@code{substring-move-left!} otherwise. If @code{str1} and @samp{str2}\n" - "are different strings, it does not matter which function you use.") + "@var{str1} and @var{str2} can be the same string.") #define FUNC_NAME s_scm_substring_move_x { long s1, s2, e, len; diff --git a/libguile/strop.h b/libguile/strop.h index 863428db6..544a1d1c2 100644 --- a/libguile/strop.h +++ b/libguile/strop.h @@ -69,9 +69,6 @@ SCM_API SCM scm_string_capitalize (SCM v); SCM_API SCM scm_string_split (SCM str, SCM chr); SCM_API SCM scm_string_ci_to_symbol (SCM v); -#define scm_substring_move_left_x scm_substring_move_x -#define scm_substring_move_right_x scm_substring_move_x - #endif /* SCM_STROP_H */ /* From adb8c0f235db6ca404a57eb2bd6fdde175a52168 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 13 Nov 2001 15:46:56 +0000 Subject: [PATCH 152/281] *** empty log message *** --- NEWS | 4 ++++ libguile/ChangeLog | 3 +++ 2 files changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 855b2a58b..bb6b07cdf 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,10 @@ compare their values. This is no longer done. Variables are now only You can now use an empty `begin' form. It will yield # when evaluated and simply be ignored in a definition context. +** Removed: substring-move-left!, substring-move-right! + +Use `substring-move!' instead. + * Changes to the C interface ** New function: scm_str2string diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 9a4478ff0..5d0ffcaa5 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,8 @@ 2001-11-13 Marius Vollmer + * strop.h, strop.c (scm_substring_move_left_x, + scm_substring_move_right_x): Removed. + * __scm.h (HAVE_UINTPTR_T, HAVE_PTRDIFF_T, HAVE_LONG_LONG, HAVE_LONG_LONGS): Define to "1" when defining them, to mirror what configure does. From e713cd28c80a07b233f7f8f2912d4e7f6563583e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 13 Nov 2001 22:15:42 +0000 Subject: [PATCH 153/281] (scm_c_export): Call va_end after collecting the symbols. --- libguile/modules.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libguile/modules.c b/libguile/modules.c index f304df3df..554b9f141 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -191,6 +191,7 @@ scm_c_export (const char *name, ...) *tail = scm_cons (scm_str2symbol (n), SCM_EOL); tail = SCM_CDRLOC (*tail); } + va_end (ap); scm_call_2 (SCM_VARIABLE_REF (module_export_x_var), scm_current_module (), names); } From 409b85880daf08becc8032d9f749b10a31614c75 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 13 Nov 2001 22:17:08 +0000 Subject: [PATCH 154/281] *** empty log message *** --- THANKS | 1 + libguile/ChangeLog | 3 +++ 2 files changed, 4 insertions(+) diff --git a/THANKS b/THANKS index 4d9d9f2da..773a78eb5 100644 --- a/THANKS +++ b/THANKS @@ -17,6 +17,7 @@ For fixes or providing information which led to a fix: Brian Crowder Christopher Cramer John Goerzen + Han-Wen Nienhuys Ken Raeburn Bill Schottstaedt Momchil Velikov diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 5d0ffcaa5..587c1eb50 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,8 @@ 2001-11-13 Marius Vollmer + * modules.c (scm_c_export): Call va_end after collecting the + symbols. + * strop.h, strop.c (scm_substring_move_left_x, scm_substring_move_right_x): Removed. From 72dd0a03e0cb1ed8e16bded7dd948d9b8d966fb6 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Tue, 13 Nov 2001 23:44:29 +0000 Subject: [PATCH 155/281] * Miscellaneous small doc updates and fixes. --- doc/maint/ChangeLog | 5 + doc/maint/guile.texi | 720 +----------------------------------- doc/ref/ChangeLog | 8 + doc/ref/new-docstrings.texi | 4 +- doc/ref/scheme-data.texi | 176 ++++----- doc/ref/scheme-options.texi | 6 +- libguile/ChangeLog | 10 + libguile/extensions.c | 2 +- libguile/hashtab.c | 2 +- libguile/random.c | 4 +- libguile/version.c | 10 +- 11 files changed, 137 insertions(+), 810 deletions(-) diff --git a/doc/maint/ChangeLog b/doc/maint/ChangeLog index 44731b76b..17c3ddba2 100644 --- a/doc/maint/ChangeLog +++ b/doc/maint/ChangeLog @@ -1,3 +1,8 @@ +2001-11-13 Neil Jerram + + * guile.texi: Replaced by libguile version (after automatically + updating docstrings in the reference manual). + 2001-11-07 Neil Jerram * guile.texi: Replaced by libguile version (after automatically diff --git a/doc/maint/guile.texi b/doc/maint/guile.texi index e39b1edb3..fb07f2cba 100644 --- a/doc/maint/guile.texi +++ b/doc/maint/guile.texi @@ -1,7 +1,6 @@ @paragraphindent 0 acons -@c snarfed from alist.c:58 @deffn primitive acons key value alist Adds a new key-value pair to @var{alist}. A new pair is created whose car is @var{key} and whose cdr is @var{value}, and the @@ -10,28 +9,24 @@ function is @emph{not} destructive; @var{alist} is not modified. @end deffn sloppy-assq -@c snarfed from alist.c:81 @deffn primitive sloppy-assq key alist Behaves like @code{assq} but does not do any error checking. Recommended only for use in Guile internals. @end deffn sloppy-assv -@c snarfed from alist.c:99 @deffn primitive sloppy-assv key alist Behaves like @code{assv} but does not do any error checking. Recommended only for use in Guile internals. @end deffn sloppy-assoc -@c snarfed from alist.c:117 @deffn primitive sloppy-assoc key alist Behaves like @code{assoc} but does not do any error checking. Recommended only for use in Guile internals. @end deffn assq -@c snarfed from alist.c:144 @deffn primitive assq key alist @deffnx primitive assv key alist @deffnx primitive assoc key alist @@ -45,19 +40,16 @@ return the entire alist entry found (i.e. both the key and the value). @end deffn assv -@c snarfed from alist.c:165 @deffn primitive assv key alist Behaves like @code{assq} but uses @code{eqv?} for key comparison. @end deffn assoc -@c snarfed from alist.c:186 @deffn primitive assoc key alist Behaves like @code{assq} but uses @code{equal?} for key comparison. @end deffn assq-ref -@c snarfed from alist.c:230 @deffn primitive assq-ref alist key @deffnx primitive assv-ref alist key @deffnx primitive assoc-ref alist key @@ -74,19 +66,16 @@ where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}. @end deffn assv-ref -@c snarfed from alist.c:247 @deffn primitive assv-ref alist key Behaves like @code{assq-ref} but uses @code{eqv?} for key comparison. @end deffn assoc-ref -@c snarfed from alist.c:264 @deffn primitive assoc-ref alist key Behaves like @code{assq-ref} but uses @code{equal?} for key comparison. @end deffn assq-set! -@c snarfed from alist.c:293 @deffn primitive assq-set! alist key val @deffnx primitive assv-set! alist key value @deffnx primitive assoc-set! alist key value @@ -101,19 +90,16 @@ association list. @end deffn assv-set! -@c snarfed from alist.c:311 @deffn primitive assv-set! alist key val Behaves like @code{assq-set!} but uses @code{eqv?} for key comparison. @end deffn assoc-set! -@c snarfed from alist.c:329 @deffn primitive assoc-set! alist key val Behaves like @code{assq-set!} but uses @code{equal?} for key comparison. @end deffn assq-remove! -@c snarfed from alist.c:353 @deffn primitive assq-remove! alist key @deffnx primitive assv-remove! alist key @deffnx primitive assoc-remove! alist key @@ -122,19 +108,16 @@ the resulting alist. @end deffn assv-remove! -@c snarfed from alist.c:369 @deffn primitive assv-remove! alist key Behaves like @code{assq-remove!} but uses @code{eqv?} for key comparison. @end deffn assoc-remove! -@c snarfed from alist.c:385 @deffn primitive assoc-remove! alist key Behaves like @code{assq-remove!} but uses @code{equal?} for key comparison. @end deffn make-arbiter -@c snarfed from arbiters.c:82 @deffn primitive make-arbiter name Return an object of type arbiter and name @var{name}. Its state is initially unlocked. Arbiters are a way to achieve @@ -142,71 +125,60 @@ process synchronization. @end deffn try-arbiter -@c snarfed from arbiters.c:92 @deffn primitive try-arbiter arb Return @code{#t} and lock the arbiter @var{arb} if the arbiter was unlocked. Otherwise, return @code{#f}. @end deffn release-arbiter -@c snarfed from arbiters.c:113 @deffn primitive release-arbiter arb Return @code{#t} and unlock the arbiter @var{arb} if the arbiter was locked. Otherwise, return @code{#f}. @end deffn async -@c snarfed from async.c:288 @deffn primitive async thunk Create a new async for the procedure @var{thunk}. @end deffn system-async -@c snarfed from async.c:298 @deffn primitive system-async thunk Create a new async for the procedure @var{thunk}. Also add it to the system's list of active async objects. @end deffn async-mark -@c snarfed from async.c:309 @deffn primitive async-mark a Mark the async @var{a} for future execution. @end deffn system-async-mark -@c snarfed from async.c:325 @deffn primitive system-async-mark a Mark the async @var{a} for future execution. @end deffn run-asyncs -@c snarfed from async.c:345 @deffn primitive run-asyncs list_of_a Execute all thunks from the asyncs of the list @var{list_of_a}. @end deffn noop -@c snarfed from async.c:379 @deffn primitive noop . args Do nothing. When called without arguments, return @code{#f}, otherwise return the first argument. @end deffn unmask-signals -@c snarfed from async.c:431 @deffn primitive unmask-signals Unmask signals. The returned value is not specified. @end deffn mask-signals -@c snarfed from async.c:442 @deffn primitive mask-signals Mask signals. The returned value is not specified. @end deffn display-error -@c snarfed from backtrace.c:265 @deffn primitive display-error stack port subr message args rest Display an error message to the output port @var{port}. @var{stack} is the saved stack for the error, @var{subr} is @@ -218,7 +190,6 @@ ignored. @end deffn display-application -@c snarfed from backtrace.c:402 @deffn primitive display-application frame [port [indent]] Display a procedure application @var{frame} to the output port @var{port}. @var{indent} specifies the indentation of the @@ -226,7 +197,6 @@ output. @end deffn display-backtrace -@c snarfed from backtrace.c:713 @deffn primitive display-backtrace stack port [first [depth]] Display a backtrace to the output port @var{port}. @var{stack} is the stack to take the backtrace from, @var{first} specifies @@ -236,136 +206,116 @@ which means that default values will be used. @end deffn backtrace -@c snarfed from backtrace.c:736 @deffn primitive backtrace Display a backtrace of the stack saved by the last error to the current output port. @end deffn not -@c snarfed from boolean.c:54 @deffn primitive not x Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}. @end deffn boolean? -@c snarfed from boolean.c:64 @deffn primitive boolean? obj Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}. @end deffn char? -@c snarfed from chars.c:54 @deffn primitive char? x Return @code{#t} iff @var{x} is a character, else @code{#f}. @end deffn char=? -@c snarfed from chars.c:63 @deffn primitive char=? x y Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}. @end deffn char? -@c snarfed from chars.c:100 @deffn primitive char>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence, else @code{#f}. @end deffn char>=? -@c snarfed from chars.c:112 @deffn primitive char>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence, else @code{#f}. @end deffn char-ci=? -@c snarfed from chars.c:124 @deffn primitive char-ci=? x y Return @code{#t} iff @var{x} is the same character as @var{y} ignoring case, else @code{#f}. @end deffn char-ci? -@c snarfed from chars.c:160 @deffn primitive char-ci>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn char-ci>=? -@c snarfed from chars.c:172 @deffn primitive char-ci>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn char-alphabetic? -@c snarfed from chars.c:185 @deffn primitive char-alphabetic? chr Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}. Alphabetic means the same thing as the isalpha C library function. @end deffn char-numeric? -@c snarfed from chars.c:196 @deffn primitive char-numeric? chr Return @code{#t} iff @var{chr} is numeric, else @code{#f}. Numeric means the same thing as the isdigit C library function. @end deffn char-whitespace? -@c snarfed from chars.c:207 @deffn primitive char-whitespace? chr Return @code{#t} iff @var{chr} is whitespace, else @code{#f}. Whitespace means the same thing as the isspace C library function. @end deffn char-upper-case? -@c snarfed from chars.c:220 @deffn primitive char-upper-case? chr Return @code{#t} iff @var{chr} is uppercase, else @code{#f}. Uppercase means the same thing as the isupper C library function. @end deffn char-lower-case? -@c snarfed from chars.c:232 @deffn primitive char-lower-case? chr Return @code{#t} iff @var{chr} is lowercase, else @code{#f}. Lowercase means the same thing as the islower C library function. @end deffn char-is-both? -@c snarfed from chars.c:246 @deffn primitive char-is-both? chr Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}. Uppercase and lowercase are as defined by the isupper and islower @@ -373,32 +323,27 @@ C library functions. @end deffn char->integer -@c snarfed from chars.c:260 @deffn primitive char->integer chr Return the number corresponding to ordinal position of @var{chr} in the ASCII sequence. @end deffn integer->char -@c snarfed from chars.c:272 @deffn primitive integer->char n Return the character at position @var{n} in the ASCII sequence. @end deffn char-upcase -@c snarfed from chars.c:283 @deffn primitive char-upcase chr Return the uppercase character version of @var{chr}. @end deffn char-downcase -@c snarfed from chars.c:294 @deffn primitive char-downcase chr Return the lowercase character version of @var{chr}. @end deffn debug-options-interface -@c snarfed from debug.c:79 @deffn primitive debug-options-interface [setting] Option interface for the debug options. Instead of using this procedure directly, use the procedures @code{debug-enable}, @@ -406,49 +351,41 @@ this procedure directly, use the procedures @code{debug-enable}, @end deffn with-traps -@c snarfed from debug.c:127 @deffn primitive with-traps thunk Call @var{thunk} with traps enabled. @end deffn memoized? -@c snarfed from debug.c:169 @deffn primitive memoized? obj Return @code{#t} if @var{obj} is memoized. @end deffn unmemoize -@c snarfed from debug.c:333 @deffn primitive unmemoize m Unmemoize the memoized expression @var{m}, @end deffn memoized-environment -@c snarfed from debug.c:343 @deffn primitive memoized-environment m Return the environment of the memoized expression @var{m}. @end deffn procedure-name -@c snarfed from debug.c:353 @deffn primitive procedure-name proc Return the name of the procedure @var{proc} @end deffn procedure-source -@c snarfed from debug.c:379 @deffn primitive procedure-source proc Return the source of the procedure @var{proc}. @end deffn procedure-environment -@c snarfed from debug.c:412 @deffn primitive procedure-environment proc Return the environment of the procedure @var{proc}. @end deffn local-eval -@c snarfed from debug.c:444 @deffn primitive local-eval exp [env] Evaluate @var{exp} in its environment. If @var{env} is supplied, it is the environment in which to evaluate @var{exp}. Otherwise, @@ -457,13 +394,11 @@ is implicit). @end deffn debug-object? -@c snarfed from debug.c:531 @deffn primitive debug-object? obj Return @code{#t} if @var{obj} is a debug object. @end deffn dynamic-link -@c snarfed from dynl.c:264 @deffn primitive dynamic-link filename Open the dynamic library called @var{filename}. A library handle representing the opened library is returned; this handle @@ -472,14 +407,12 @@ functions. @end deffn dynamic-object? -@c snarfed from dynl.c:279 @deffn primitive dynamic-object? obj Return @code{#t} if @var{obj} is a dynamic library handle, or @code{#f} otherwise. @end deffn dynamic-unlink -@c snarfed from dynl.c:292 @deffn primitive dynamic-unlink dobj Unlink the indicated object file from the application. The argument @var{dobj} must have been obtained by a call to @@ -488,7 +421,6 @@ called on @var{dobj}, its content is no longer accessible. @end deffn dynamic-func -@c snarfed from dynl.c:319 @deffn primitive dynamic-func name dobj Search the dynamic object @var{dobj} for the C function indicated by the string @var{name} and return some Scheme @@ -502,7 +434,6 @@ needed or not and will add it when necessary. @end deffn dynamic-call -@c snarfed from dynl.c:358 @deffn primitive dynamic-call func dobj Call the C function indicated by @var{func} and @var{dobj}. The function is passed no arguments and its return value is @@ -519,7 +450,6 @@ Interrupts are deferred while the C function is executing (with @end deffn dynamic-args-call -@c snarfed from dynl.c:386 @deffn primitive dynamic-args-call func dobj args Call the C function indicated by @var{func} and @var{dobj}, just like @code{dynamic-call}, but pass it some arguments and @@ -537,7 +467,6 @@ converted to a Scheme number and returned from the call to @end deffn dynamic-wind -@c snarfed from dynwind.c:119 @deffn primitive dynamic-wind in_guard thunk out_guard All three arguments must be 0-argument procedures. @var{in_guard} is called, then @var{thunk}, then @@ -590,21 +519,18 @@ a-cont @end deffn environment? -@c snarfed from environments.c:135 @deffn primitive environment? obj Return @code{#t} if @var{obj} is an environment, or @code{#f} otherwise. @end deffn environment-bound? -@c snarfed from environments.c:146 @deffn primitive environment-bound? env sym Return @code{#t} if @var{sym} is bound in @var{env}, or @code{#f} otherwise. @end deffn environment-ref -@c snarfed from environments.c:161 @deffn primitive environment-ref env sym Return the value of the location bound to @var{sym} in @var{env}. If @var{sym} is unbound in @var{env}, signal an @@ -612,7 +538,6 @@ Return the value of the location bound to @var{sym} in @end deffn environment-fold -@c snarfed from environments.c:231 @deffn primitive environment-fold env proc init Iterate over all the bindings in @var{env}, accumulating some value. @@ -648,7 +573,6 @@ using environment-fold: @end deffn environment-define -@c snarfed from environments.c:266 @deffn primitive environment-define env sym val Bind @var{sym} to a new location containing @var{val} in @var{env}. If @var{sym} is already bound to another location @@ -660,7 +584,6 @@ immutable, signal an @code{environment:immutable-binding} error. @end deffn environment-undefine -@c snarfed from environments.c:292 @deffn primitive environment-undefine env sym Remove any binding for @var{sym} from @var{env}. If @var{sym} is unbound in @var{env}, do nothing. The return value is @@ -670,7 +593,6 @@ immutable, signal an @code{environment:immutable-binding} error. @end deffn environment-set! -@c snarfed from environments.c:320 @deffn primitive environment-set! env sym val If @var{env} binds @var{sym} to some location, change that location's value to @var{val}. The return value is @@ -682,7 +604,6 @@ to an immutable location, signal an @end deffn environment-cell -@c snarfed from environments.c:355 @deffn primitive environment-cell env sym for_write Return the value cell which @var{env} binds to @var{sym}, or @code{#f} if the binding does not live in a value cell. @@ -699,7 +620,6 @@ re-bound to a new value cell, or becomes undefined. @end deffn environment-observe -@c snarfed from environments.c:407 @deffn primitive environment-observe env proc Whenever @var{env}'s bindings change, apply @var{proc} to @var{env}. @@ -710,7 +630,6 @@ token is unspecified. @end deffn environment-observe-weak -@c snarfed from environments.c:424 @deffn primitive environment-observe-weak env proc This function is the same as environment-observe, except that the reference @var{env} retains to @var{proc} is a weak @@ -721,7 +640,6 @@ list of observing procedures. @end deffn environment-unobserve -@c snarfed from environments.c:460 @deffn primitive environment-unobserve token Cancel the observation request which returned the value @var{token}. The return value is unspecified. @@ -732,7 +650,6 @@ bindings change. @end deffn make-leaf-environment -@c snarfed from environments.c:1040 @deffn primitive make-leaf-environment Create a new leaf environment, containing no bindings. All bindings and locations created in the new environment @@ -740,14 +657,12 @@ will be mutable. @end deffn leaf-environment? -@c snarfed from environments.c:1063 @deffn primitive leaf-environment? object Return @code{#t} if object is a leaf environment, or @code{#f} otherwise. @end deffn make-eval-environment -@c snarfed from environments.c:1429 @deffn primitive make-eval-environment local imported Return a new environment object eval whose bindings are the union of the bindings in the environments @var{local} and @@ -773,38 +688,32 @@ In typical use, @var{local} will be a finite environment, and @end deffn eval-environment? -@c snarfed from environments.c:1466 @deffn primitive eval-environment? object Return @code{#t} if object is an eval environment, or @code{#f} otherwise. @end deffn eval-environment-local -@c snarfed from environments.c:1476 @deffn primitive eval-environment-local env Return the local environment of eval environment @var{env}. @end deffn eval-environment-set-local! -@c snarfed from environments.c:1488 @deffn primitive eval-environment-set-local! env local Change @var{env}'s local environment to @var{local}. @end deffn eval-environment-imported -@c snarfed from environments.c:1514 @deffn primitive eval-environment-imported env Return the imported environment of eval environment @var{env}. @end deffn eval-environment-set-imported! -@c snarfed from environments.c:1526 @deffn primitive eval-environment-set-imported! env imported Change @var{env}'s imported environment to @var{imported}. @end deffn make-import-environment -@c snarfed from environments.c:1850 @deffn primitive make-import-environment imports conflict_proc Return a new environment @var{imp} whose bindings are the union of the bindings from the environments in @var{imports}; @@ -834,28 +743,24 @@ if one of its imported environments changes. @end deffn import-environment? -@c snarfed from environments.c:1879 @deffn primitive import-environment? object Return @code{#t} if object is an import environment, or @code{#f} otherwise. @end deffn import-environment-imports -@c snarfed from environments.c:1890 @deffn primitive import-environment-imports env Return the list of environments imported by the import environment @var{env}. @end deffn import-environment-set-imports! -@c snarfed from environments.c:1903 @deffn primitive import-environment-set-imports! env imports Change @var{env}'s list of imported environments to @var{imports}, and check for conflicts. @end deffn make-export-environment -@c snarfed from environments.c:2171 @deffn primitive make-export-environment private signature Return a new environment @var{exp} containing only those bindings in private whose symbols are present in @@ -904,38 +809,32 @@ if the bindings in private change. @end deffn export-environment? -@c snarfed from environments.c:2206 @deffn primitive export-environment? object Return @code{#t} if object is an export environment, or @code{#f} otherwise. @end deffn export-environment-private -@c snarfed from environments.c:2216 @deffn primitive export-environment-private env Return the private environment of export environment @var{env}. @end deffn export-environment-set-private! -@c snarfed from environments.c:2228 @deffn primitive export-environment-set-private! env private Change the private environment of export environment @var{env}. @end deffn export-environment-signature -@c snarfed from environments.c:2250 @deffn primitive export-environment-signature env Return the signature of export environment @var{env}. @end deffn export-environment-set-signature! -@c snarfed from environments.c:2324 @deffn primitive export-environment-set-signature! env signature Change the signature of export environment @var{env}. @end deffn eq? -@c snarfed from eq.c:62 @deffn primitive eq? x y Return @code{#t} iff @var{x} references the same object as @var{y}. @code{eq?} is similar to @code{eqv?} except that in some cases it is @@ -944,7 +843,6 @@ capable of discerning distinctions finer than those detectable by @end deffn eqv? -@c snarfed from eq.c:76 @deffn primitive eqv? x y The @code{eqv?} procedure defines a useful equivalence relation on objects. Briefly, it returns @code{#t} if @var{x} and @var{y} should normally be @@ -954,7 +852,6 @@ and inexact numbers. @end deffn equal? -@c snarfed from eq.c:125 @deffn primitive equal? x y Return @code{#t} iff @var{x} and @var{y} are recursively @code{eqv?} equivalent. @code{equal?} recursively compares the contents of pairs, @@ -965,7 +862,6 @@ terminate if its arguments are circular data structures. @end deffn scm-error -@c snarfed from error.c:117 @deffn primitive scm-error key subr message args data Raise an error with key @var{key}. @var{subr} can be a string naming the procedure associated with the error, or @code{#f}. @@ -983,14 +879,12 @@ it will usually be @code{#f}. @end deffn strerror -@c snarfed from error.c:168 @deffn primitive strerror err Return the Unix error message corresponding to @var{err}, which must be an integer value. @end deffn apply:nconc2last -@c snarfed from eval.c:3329 @deffn primitive apply:nconc2last lst Given a list (@var{arg1} @dots{} @var{args}), this function conses the @var{arg1} @dots{} arguments onto the front of @@ -1002,7 +896,6 @@ destroys its argument, so use with care. @end deffn force -@c snarfed from eval.c:3864 @deffn primitive force x If the promise @var{x} has not been computed yet, compute and return @var{x}, otherwise just return the previously computed @@ -1010,14 +903,12 @@ value. @end deffn promise? -@c snarfed from eval.c:3887 @deffn primitive promise? obj Return true if @var{obj} is a promise, i.e. a delayed computation (@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). @end deffn cons-source -@c snarfed from eval.c:3899 @deffn primitive cons-source xorig x y Create and return a new pair whose car and cdr are @var{x} and @var{y}. Any source properties associated with @var{xorig} are also associated @@ -1025,7 +916,6 @@ with the new pair. @end deffn copy-tree -@c snarfed from eval.c:3921 @deffn primitive copy-tree obj Recursively copy the data tree that is bound to @var{obj}, and return a pointer to the new data structure. @code{copy-tree} recurses down the @@ -1035,14 +925,12 @@ any other object. @end deffn primitive-eval -@c snarfed from eval.c:4014 @deffn primitive primitive-eval exp Evaluate @var{exp} in the top-level environment specified by the current module. @end deffn eval -@c snarfed from eval.c:4083 @deffn primitive eval exp module Evaluate @var{exp}, a list representing a Scheme expression, in the top-level environment specified by @var{module}. @@ -1052,7 +940,6 @@ is reset to its previous value when @var{eval} returns. @end deffn eval-options-interface -@c snarfed from eval.c:1747 @deffn primitive eval-options-interface [setting] Option interface for the evaluation options. Instead of using this procedure directly, use the procedures @code{eval-enable}, @@ -1060,27 +947,23 @@ this procedure directly, use the procedures @code{eval-enable}, @end deffn evaluator-traps-interface -@c snarfed from eval.c:1764 @deffn primitive evaluator-traps-interface [setting] Option interface for the evaluator trap options. @end deffn defined? -@c snarfed from evalext.c:75 @deffn primitive defined? sym [env] Return @code{#t} if @var{sym} is defined in the lexical environment @var{env}. When @var{env} is not specified, look in the top-level environment as defined by the current module. @end deffn map-in-order -@c snarfed from evalext.c:144 @deffn primitive map-in-order implemented by the C function "scm_map" @end deffn load-extension -@c snarfed from extensions.c:153 @deffn primitive load-extension lib init -Load and initilize the extension designated by LIB and INIT. +Load and initialize the extension designated by LIB and INIT. When there is no pre-registered function for LIB/INIT, this is equivalent to @@ -1117,7 +1000,6 @@ well. For example, @end deffn program-arguments -@c snarfed from feature.c:77 @deffn primitive program-arguments @deffnx procedure command-line Return the list of command line arguments passed to Guile, as a list of @@ -1127,7 +1009,6 @@ options like @code{-e} and @code{-l}. @end deffn make-fluid -@c snarfed from fluids.c:123 @deffn primitive make-fluid Return a newly created fluid. Fluids are objects of a certain type (a smob) that can hold one SCM @@ -1139,14 +1020,12 @@ in its own dynamic root, you can use fluids for thread local storage. @end deffn fluid? -@c snarfed from fluids.c:136 @deffn primitive fluid? obj Return @code{#t} iff @var{obj} is a fluid; otherwise, return @code{#f}. @end deffn fluid-ref -@c snarfed from fluids.c:147 @deffn primitive fluid-ref fluid Return the value associated with @var{fluid} in the current dynamic root. If @var{fluid} has not been set, then return @@ -1154,13 +1033,11 @@ dynamic root. If @var{fluid} has not been set, then return @end deffn fluid-set! -@c snarfed from fluids.c:163 @deffn primitive fluid-set! fluid value Set the value associated with @var{fluid} in the current dynamic root. @end deffn with-fluids* -@c snarfed from fluids.c:222 @deffn primitive with-fluids* fluids values thunk Set @var{fluids} to @var{values} temporary, and call @var{thunk}. @var{fluids} must be a list of fluids and @var{values} must be the same @@ -1169,7 +1046,6 @@ one after another. @var{thunk} must be a procedure with no argument. @end deffn setvbuf -@c snarfed from fports.c:155 @deffn primitive setvbuf port mode [size] Set the buffering mode for @var{port}. @var{mode} can be: @table @code @@ -1184,13 +1060,11 @@ If @var{size} is omitted, a default size will be used. @end deffn file-port? -@c snarfed from fports.c:237 @deffn primitive file-port? obj Determine whether @var{obj} is a port that is related to a file. @end deffn open-file -@c snarfed from fports.c:291 @deffn primitive open-file filename mode Open the file whose name is @var{filename}, and return a port representing that file. The attributes of the port are @@ -1232,28 +1106,24 @@ requested, @code{open-file} throws an exception. @end deffn gc-stats -@c snarfed from gc.c:796 @deffn primitive gc-stats Return an association list of statistics about Guile's current use of storage. @end deffn object-address -@c snarfed from gc.c:893 @deffn primitive object-address obj Return an integer that for the lifetime of @var{obj} is uniquely returned by this function for @var{obj} @end deffn gc -@c snarfed from gc.c:904 @deffn primitive gc Scans all of SCM objects and reclaims for further use those that are no longer accessible. @end deffn %compute-slots -@c snarfed from goops.c:291 @deffn primitive %compute-slots class Return a list consisting of the names of all slots belonging to class @var{class}, i. e. the slots of @var{class} and of all of @@ -1261,7 +1131,6 @@ its superclasses. @end deffn get-keyword -@c snarfed from goops.c:376 @deffn primitive get-keyword key l default_value Determine an associated value for the keyword @var{key} from the list @var{l}. The list @var{l} has to consist of an even @@ -1272,292 +1141,245 @@ If @var{l} does not hold a value for @var{key}, the value @end deffn %initialize-object -@c snarfed from goops.c:399 @deffn primitive %initialize-object obj initargs Initialize the object @var{obj} with the given arguments @var{initargs}. @end deffn %prep-layout! -@c snarfed from goops.c:480 @deffn primitive %prep-layout! class @end deffn %inherit-magic! -@c snarfed from goops.c:557 @deffn primitive %inherit-magic! class dsupers @end deffn instance? -@c snarfed from goops.c:800 @deffn primitive instance? obj Return @code{#t} if @var{obj} is an instance. @end deffn class-name -@c snarfed from goops.c:815 @deffn primitive class-name obj Return the class name of @var{obj}. @end deffn class-direct-supers -@c snarfed from goops.c:825 @deffn primitive class-direct-supers obj Return the direct superclasses of the class @var{obj}. @end deffn class-direct-slots -@c snarfed from goops.c:835 @deffn primitive class-direct-slots obj Return the direct slots of the class @var{obj}. @end deffn class-direct-subclasses -@c snarfed from goops.c:845 @deffn primitive class-direct-subclasses obj Return the direct subclasses of the class @var{obj}. @end deffn class-direct-methods -@c snarfed from goops.c:855 @deffn primitive class-direct-methods obj Return the direct methods of the class @var{obj} @end deffn class-precedence-list -@c snarfed from goops.c:865 @deffn primitive class-precedence-list obj Return the class precedence list of the class @var{obj}. @end deffn class-slots -@c snarfed from goops.c:875 @deffn primitive class-slots obj Return the slot list of the class @var{obj}. @end deffn class-environment -@c snarfed from goops.c:885 @deffn primitive class-environment obj Return the environment of the class @var{obj}. @end deffn generic-function-name -@c snarfed from goops.c:896 @deffn primitive generic-function-name obj Return the name of the generic function @var{obj}. @end deffn generic-function-methods -@c snarfed from goops.c:906 @deffn primitive generic-function-methods obj Return the methods of the generic function @var{obj}. @end deffn method-generic-function -@c snarfed from goops.c:917 @deffn primitive method-generic-function obj Return the generic function fot the method @var{obj}. @end deffn method-specializers -@c snarfed from goops.c:927 @deffn primitive method-specializers obj Return specializers of the method @var{obj}. @end deffn method-procedure -@c snarfed from goops.c:937 @deffn primitive method-procedure obj Return the procedure of the method @var{obj}. @end deffn accessor-method-slot-definition -@c snarfed from goops.c:947 @deffn primitive accessor-method-slot-definition obj Return the slot definition of the accessor @var{obj}. @end deffn %tag-body -@c snarfed from goops.c:957 @deffn primitive %tag-body body Internal GOOPS magic---don't use this function! @end deffn make-unbound -@c snarfed from goops.c:972 @deffn primitive make-unbound Return the unbound value. @end deffn unbound? -@c snarfed from goops.c:981 @deffn primitive unbound? obj Return @code{#t} if @var{obj} is unbound. @end deffn assert-bound -@c snarfed from goops.c:991 @deffn primitive assert-bound value obj Return @var{value} if it is bound, and invoke the @var{slot-unbound} method of @var{obj} if it is not. @end deffn @@assert-bound-ref -@c snarfed from goops.c:1003 @deffn primitive @@assert-bound-ref obj index Like @code{assert-bound}, but use @var{index} for accessing the value from @var{obj}. @end deffn %fast-slot-ref -@c snarfed from goops.c:1015 @deffn primitive %fast-slot-ref obj index Return the slot value with index @var{index} from @var{obj}. @end deffn %fast-slot-set! -@c snarfed from goops.c:1033 @deffn primitive %fast-slot-set! obj index value Set the slot with index @var{index} in @var{obj} to @var{value}. @end deffn slot-ref-using-class -@c snarfed from goops.c:1163 @deffn primitive slot-ref-using-class class obj slot_name @end deffn slot-set-using-class! -@c snarfed from goops.c:1182 @deffn primitive slot-set-using-class! class obj slot_name value @end deffn slot-bound-using-class? -@c snarfed from goops.c:1196 @deffn primitive slot-bound-using-class? class obj slot_name @end deffn slot-exists-using-class? -@c snarfed from goops.c:1211 @deffn primitive slot-exists-using-class? class obj slot_name @end deffn slot-ref -@c snarfed from goops.c:1227 @deffn primitive slot-ref obj slot_name Return the value from @var{obj}'s slot with the name @var{slot_name}. @end deffn slot-set! -@c snarfed from goops.c:1244 @deffn primitive slot-set! obj slot_name value Set the slot named @var{slot_name} of @var{obj} to @var{value}. @end deffn slot-bound? -@c snarfed from goops.c:1261 @deffn primitive slot-bound? obj slot_name Return @code{#t} if the slot named @var{slot_name} of @var{obj} is bound. @end deffn slot-exists? -@c snarfed from goops.c:1279 @deffn primitive slot-exists? obj slot_name Return @code{#t} if @var{obj} has a slot named @var{slot_name}. @end deffn %allocate-instance -@c snarfed from goops.c:1323 @deffn primitive %allocate-instance class initargs Create a new instance of class @var{class} and initialize it from the arguments @var{initargs}. @end deffn %set-object-setter! -@c snarfed from goops.c:1396 @deffn primitive %set-object-setter! obj setter @end deffn %modify-instance -@c snarfed from goops.c:1421 @deffn primitive %modify-instance old new @end deffn %modify-class -@c snarfed from goops.c:1447 @deffn primitive %modify-class old new @end deffn %invalidate-class -@c snarfed from goops.c:1471 @deffn primitive %invalidate-class class @end deffn %invalidate-method-cache! -@c snarfed from goops.c:1598 @deffn primitive %invalidate-method-cache! gf @end deffn generic-capability? -@c snarfed from goops.c:1624 @deffn primitive generic-capability? proc @end deffn enable-primitive-generic! -@c snarfed from goops.c:1637 @deffn primitive enable-primitive-generic! . subrs @end deffn primitive-generic-generic -@c snarfed from goops.c:1658 @deffn primitive primitive-generic-generic subr @end deffn make -@c snarfed from goops.c:2019 @deffn primitive make . args Make a new object. @var{args} must contain the class and all necessary initialization information. @end deffn find-method -@c snarfed from goops.c:2112 @deffn primitive find-method . l @end deffn %method-more-specific? -@c snarfed from goops.c:2132 @deffn primitive %method-more-specific? m1 m2 targs @end deffn %goops-loaded -@c snarfed from goops.c:2660 @deffn primitive %goops-loaded Announce that GOOPS is loaded and perform initialization on the C level which depends on the loaded GOOPS modules. @end deffn make-guardian -@c snarfed from guardians.c:331 @deffn primitive make-guardian [greedy_p] Create a new guardian. A guardian protects a set of objects from garbage collection, @@ -1587,19 +1409,16 @@ paper still (mostly) accurately describes the interface). @end deffn guardian-destroyed? -@c snarfed from guardians.c:359 @deffn primitive guardian-destroyed? guardian Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}. @end deffn guardian-greedy? -@c snarfed from guardians.c:377 @deffn primitive guardian-greedy? guardian Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}. @end deffn destroy-guardian! -@c snarfed from guardians.c:388 @deffn primitive destroy-guardian! guardian Destroys @var{guardian}, by making it impossible to put any more objects in it or get any objects from it. It also unguards any @@ -1607,7 +1426,6 @@ objects guarded by @var{guardian}. @end deffn hashq -@c snarfed from hash.c:200 @deffn primitive hashq key size Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eq?} is @@ -1622,7 +1440,6 @@ different values, since @code{foo} will be garbage collected. @end deffn hashv -@c snarfed from hash.c:236 @deffn primitive hashv key size Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eqv?} is @@ -1637,7 +1454,6 @@ different values, since @code{foo} will be garbage collected. @end deffn hash -@c snarfed from hash.c:259 @deffn primitive hash key size Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{equal?} @@ -1646,7 +1462,6 @@ integer in the range 0 to @var{size} - 1. @end deffn hashq-get-handle -@c snarfed from hashtab.c:173 @deffn primitive hashq-get-handle table key This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an @@ -1655,7 +1470,6 @@ Uses @code{eq?} for equality testing. @end deffn hashq-create-handle! -@c snarfed from hashtab.c:185 @deffn primitive hashq-create-handle! table key init This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which @@ -1663,7 +1477,6 @@ associates @var{key} with @var{init}. @end deffn hashq-ref -@c snarfed from hashtab.c:198 @deffn primitive hashq-ref table key [dflt] Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, @@ -1672,21 +1485,18 @@ is supplied). Uses @code{eq?} for equality testing. @end deffn hashq-set! -@c snarfed from hashtab.c:212 @deffn primitive hashq-set! table key val Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{eq?} for equality testing. @end deffn hashq-remove! -@c snarfed from hashtab.c:224 @deffn primitive hashq-remove! table key Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{eq?} for equality tests. @end deffn hashv-get-handle -@c snarfed from hashtab.c:240 @deffn primitive hashv-get-handle table key This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an @@ -1695,7 +1505,6 @@ Uses @code{eqv?} for equality testing. @end deffn hashv-create-handle! -@c snarfed from hashtab.c:252 @deffn primitive hashv-create-handle! table key init This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which @@ -1703,7 +1512,6 @@ associates @var{key} with @var{init}. @end deffn hashv-ref -@c snarfed from hashtab.c:266 @deffn primitive hashv-ref table key [dflt] Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, @@ -1712,21 +1520,18 @@ is supplied). Uses @code{eqv?} for equality testing. @end deffn hashv-set! -@c snarfed from hashtab.c:280 @deffn primitive hashv-set! table key val Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{eqv?} for equality testing. @end deffn hashv-remove! -@c snarfed from hashtab.c:291 @deffn primitive hashv-remove! table key Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{eqv?} for equality tests. @end deffn hash-get-handle -@c snarfed from hashtab.c:306 @deffn primitive hash-get-handle table key This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an @@ -1735,7 +1540,6 @@ Uses @code{equal?} for equality testing. @end deffn hash-create-handle! -@c snarfed from hashtab.c:318 @deffn primitive hash-create-handle! table key init This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which @@ -1743,7 +1547,6 @@ associates @var{key} with @var{init}. @end deffn hash-ref -@c snarfed from hashtab.c:331 @deffn primitive hash-ref table key [dflt] Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, @@ -1752,7 +1555,6 @@ is supplied). Uses @code{equal?} for equality testing. @end deffn hash-set! -@c snarfed from hashtab.c:346 @deffn primitive hash-set! table key val Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{equal?} for equality @@ -1760,14 +1562,12 @@ testing. @end deffn hash-remove! -@c snarfed from hashtab.c:358 @deffn primitive hash-remove! table key Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{equal?} for equality tests. @end deffn hashx-get-handle -@c snarfed from hashtab.c:422 @deffn primitive hashx-get-handle hash assoc table key This behaves the same way as the corresponding @code{-get-handle} function, but uses @var{hash} as a hash @@ -1778,7 +1578,6 @@ table size. @code{assoc} must be an associator function, like @end deffn hashx-create-handle! -@c snarfed from hashtab.c:441 @deffn primitive hashx-create-handle! hash assoc table key init This behaves the same way as the corresponding @code{-create-handle} function, but uses @var{hash} as a hash @@ -1789,7 +1588,6 @@ table size. @code{assoc} must be an associator function, like @end deffn hashx-ref -@c snarfed from hashtab.c:464 @deffn primitive hashx-ref hash assoc table key [dflt] This behaves the same way as the corresponding @code{ref} function, but uses @var{hash} as a hash function and @@ -1803,7 +1601,6 @@ equivalent to @code{hashx-ref hashq assq table key}. @end deffn hashx-set! -@c snarfed from hashtab.c:490 @deffn primitive hashx-set! hash assoc table key val This behaves the same way as the corresponding @code{set!} function, but uses @var{hash} as a hash function and @@ -1817,7 +1614,6 @@ equivalent to @code{hashx-set! hashq assq table key}. @end deffn hash-fold -@c snarfed from hashtab.c:528 @deffn primitive hash-fold proc init table An iterator over hash-table elements. Accumulates and returns a result by applying PROC successively. @@ -1825,12 +1621,11 @@ The arguments to PROC are "(key value prior-result)" where key and value are successive pairs from the hash table TABLE, and prior-result is either INIT (for the first application of PROC) or the return value of the previous application of PROC. -For example, @code{(hash-fold acons () tab)} will convert a hash +For example, @code{(hash-fold acons '() tab)} will convert a hash table into an a-list of key-value pairs. @end deffn make-hook -@c snarfed from hooks.c:179 @deffn primitive make-hook [n_args] Create a hook for storing procedure of arity @var{n_args}. @var{n_args} defaults to zero. The returned value is a hook @@ -1838,20 +1633,17 @@ object to be used with the other hook procedures. @end deffn hook? -@c snarfed from hooks.c:202 @deffn primitive hook? x Return @code{#t} if @var{x} is a hook, @code{#f} otherwise. @end deffn hook-empty? -@c snarfed from hooks.c:213 @deffn primitive hook-empty? hook Return @code{#t} if @var{hook} is an empty hook, @code{#f} otherwise. @end deffn add-hook! -@c snarfed from hooks.c:227 @deffn primitive add-hook! hook proc [append_p] Add the procedure @var{proc} to the hook @var{hook}. The procedure is added to the end if @var{append_p} is true, @@ -1860,21 +1652,18 @@ procedure is not specified. @end deffn remove-hook! -@c snarfed from hooks.c:254 @deffn primitive remove-hook! hook proc Remove the procedure @var{proc} from the hook @var{hook}. The return value of this procedure is not specified. @end deffn reset-hook! -@c snarfed from hooks.c:268 @deffn primitive reset-hook! hook Remove all procedures from the hook @var{hook}. The return value of this procedure is not specified. @end deffn run-hook -@c snarfed from hooks.c:282 @deffn primitive run-hook hook . args Apply all procedures from the hook @var{hook} to the arguments @var{args}. The order of the procedure application is first to @@ -1882,13 +1671,11 @@ last. The return value of this procedure is not specified. @end deffn hook->list -@c snarfed from hooks.c:309 @deffn primitive hook->list hook Convert the procedure list of @var{hook} to a list. @end deffn ftell -@c snarfed from ioext.c:73 @deffn primitive ftell fd_port Return an integer representing the current position of @var{fd/port}, measured from the beginning. Equivalent to: @@ -1899,7 +1686,6 @@ Return an integer representing the current position of @end deffn redirect-port -@c snarfed from ioext.c:91 @deffn primitive redirect-port old new This procedure takes two ports and duplicates the underlying file descriptor from @var{old-port} into @var{new-port}. The @@ -1917,7 +1703,6 @@ revealed counts. @end deffn dup->fdes -@c snarfed from ioext.c:130 @deffn primitive dup->fdes fd_or_port [fd] Return a new integer file descriptor referring to the open file designated by @var{fd_or_port}, which must be either an open @@ -1925,7 +1710,6 @@ file port or a file descriptor. @end deffn dup2 -@c snarfed from ioext.c:177 @deffn primitive dup2 oldfd newfd A simple wrapper for the @code{dup2} system call. Copies the file descriptor @var{oldfd} to descriptor @@ -1938,21 +1722,18 @@ The return value is unspecified. @end deffn fileno -@c snarfed from ioext.c:196 @deffn primitive fileno port Return the integer file descriptor underlying @var{port}. Does not change its revealed count. @end deffn isatty? -@c snarfed from ioext.c:216 @deffn primitive isatty? port Return @code{#t} if @var{port} is using a serial non--file device, otherwise @code{#f}. @end deffn fdopen -@c snarfed from ioext.c:238 @deffn primitive fdopen fdes modes Return a new port based on the file descriptor @var{fdes}. Modes are given by the string @var{modes}. The revealed count @@ -1961,7 +1742,6 @@ same as that accepted by @ref{File Ports, open-file}. @end deffn primitive-move->fdes -@c snarfed from ioext.c:262 @deffn primitive primitive-move->fdes port fd Moves the underlying file descriptor for @var{port} to the integer value @var{fdes} without changing the revealed count of @var{port}. @@ -1972,7 +1752,6 @@ required value or @code{#t} if it was moved. @end deffn fdes->ports -@c snarfed from ioext.c:296 @deffn primitive fdes->ports fd Return a list of existing ports which have @var{fdes} as an underlying file descriptor, without changing their revealed @@ -1980,27 +1759,23 @@ counts. @end deffn make-keyword-from-dash-symbol -@c snarfed from keywords.c:74 @deffn primitive make-keyword-from-dash-symbol symbol Make a keyword object from a @var{symbol} that starts with a dash. @end deffn keyword? -@c snarfed from keywords.c:113 @deffn primitive keyword? obj Return @code{#t} if the argument @var{obj} is a keyword, else @code{#f}. @end deffn keyword-dash-symbol -@c snarfed from keywords.c:124 @deffn primitive keyword-dash-symbol keyword Return the dash symbol for @var{keyword}. This is the inverse of @code{make-keyword-from-dash-symbol}. @end deffn nil-cons -@c snarfed from lang.c:69 @deffn primitive nil-cons x y Create a new cons cell with @var{x} as the car and @var{y} as the cdr, but convert @var{y} to Scheme's end-of-list if it is @@ -2008,42 +1783,36 @@ a LISP nil. @end deffn nil-car -@c snarfed from lang.c:84 @deffn primitive nil-car x Return the car of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn nil-cdr -@c snarfed from lang.c:97 @deffn primitive nil-cdr x Return the cdr of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn null -@c snarfed from lang.c:112 @deffn primitive null x Return LISP's @code{t} if @var{x} is nil in the LISP sense, return LISP's nil otherwise. @end deffn nil-eq -@c snarfed from lang.c:141 @deffn primitive nil-eq x y Compare @var{x} and @var{y} and return LISP's t if they are @code{eq?}, return LISP's nil otherwise. @end deffn list -@c snarfed from list.c:128 @deffn primitive list . objs Return a list containing @var{objs}, the arguments to @code{list}. @end deffn cons* -@c snarfed from list.c:143 @deffn primitive cons* arg . rest Like @code{list}, but the last arg provides the tail of the constructed list, returning @code{(cons @var{arg1} (cons @@ -2054,25 +1823,21 @@ Schemes and in Common LISP. @end deffn null? -@c snarfed from list.c:167 @deffn primitive null? x Return @code{#t} iff @var{x} is the empty list, else @code{#f}. @end deffn list? -@c snarfed from list.c:177 @deffn primitive list? x Return @code{#t} iff @var{x} is a proper list, else @code{#f}. @end deffn length -@c snarfed from list.c:218 @deffn primitive length lst Return the number of elements in list @var{lst}. @end deffn append -@c snarfed from list.c:247 @deffn primitive append . args Return a list consisting of the elements the lists passed as arguments. @@ -2092,7 +1857,6 @@ if the last argument is not a proper list. @end deffn append! -@c snarfed from list.c:281 @deffn primitive append! . lists A destructive version of @code{append} (@pxref{Pairs and Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field @@ -2102,21 +1866,18 @@ the mutated list. @end deffn last-pair -@c snarfed from list.c:307 @deffn primitive last-pair lst Return a pointer to the last pair in @var{lst}, signalling an error if @var{lst} is circular. @end deffn reverse -@c snarfed from list.c:337 @deffn primitive reverse lst Return a new list that contains the elements of @var{lst} but in reverse order. @end deffn reverse! -@c snarfed from list.c:371 @deffn primitive reverse! lst [new_tail] A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is @@ -2132,25 +1893,21 @@ of the modified list is not lost, it is wise to save the return value of @end deffn list-ref -@c snarfed from list.c:397 @deffn primitive list-ref list k Return the @var{k}th element from @var{list}. @end deffn list-set! -@c snarfed from list.c:421 @deffn primitive list-set! list k val Set the @var{k}th element of @var{list} to @var{val}. @end deffn list-cdr-ref -@c snarfed from list.c:444 @deffn primitive list-cdr-ref implemented by the C function "scm_list_tail" @end deffn list-tail -@c snarfed from list.c:453 @deffn primitive list-tail lst k @deffnx primitive list-cdr-ref lst k Return the "tail" of @var{lst} beginning with its @var{k}th element. @@ -2162,26 +1919,22 @@ or returning the results of cdring @var{k} times down @var{lst}. @end deffn list-cdr-set! -@c snarfed from list.c:469 @deffn primitive list-cdr-set! list k val Set the @var{k}th cdr of @var{list} to @var{val}. @end deffn list-head -@c snarfed from list.c:498 @deffn primitive list-head lst k Copy the first @var{k} elements from @var{lst} into a new list, and return it. @end deffn list-copy -@c snarfed from list.c:522 @deffn primitive list-copy lst Return a (newly-created) copy of @var{lst}. @end deffn memq -@c snarfed from list.c:576 @deffn primitive memq x lst Return the first sublist of @var{lst} whose car is @code{eq?} to @var{x} where the sublists of @var{lst} are the non-empty @@ -2192,7 +1945,6 @@ returned. @end deffn memv -@c snarfed from list.c:592 @deffn primitive memv x lst Return the first sublist of @var{lst} whose car is @code{eqv?} to @var{x} where the sublists of @var{lst} are the non-empty @@ -2203,7 +1955,6 @@ returned. @end deffn member -@c snarfed from list.c:613 @deffn primitive member x lst Return the first sublist of @var{lst} whose car is @code{equal?} to @var{x} where the sublists of @var{lst} are @@ -2214,7 +1965,6 @@ empty list) is returned. @end deffn delq! -@c snarfed from list.c:638 @deffn primitive delq! item lst @deffnx primitive delv! item lst @deffnx primitive delete! item lst @@ -2227,21 +1977,18 @@ destructive list functions, these functions cannot modify the binding of @end deffn delv! -@c snarfed from list.c:662 @deffn primitive delv! item lst Destructively remove all elements from @var{lst} that are @code{eqv?} to @var{item}. @end deffn delete! -@c snarfed from list.c:687 @deffn primitive delete! item lst Destructively remove all elements from @var{lst} that are @code{equal?} to @var{item}. @end deffn delq -@c snarfed from list.c:716 @deffn primitive delq item lst Return a newly-created copy of @var{lst} with elements @code{eq?} to @var{item} removed. This procedure mirrors @@ -2250,7 +1997,6 @@ Return a newly-created copy of @var{lst} with elements @end deffn delv -@c snarfed from list.c:729 @deffn primitive delv item lst Return a newly-created copy of @var{lst} with elements @code{eqv?} to @var{item} removed. This procedure mirrors @@ -2259,7 +2005,6 @@ Return a newly-created copy of @var{lst} with elements @end deffn delete -@c snarfed from list.c:742 @deffn primitive delete item lst Return a newly-created copy of @var{lst} with elements @code{equal?} to @var{item} removed. This procedure mirrors @@ -2268,7 +2013,6 @@ against @var{item} with @code{equal?}. @end deffn delq1! -@c snarfed from list.c:755 @deffn primitive delq1! item lst Like @code{delq!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @@ -2276,7 +2020,6 @@ Like @code{delq!}, but only deletes the first occurrence of @end deffn delv1! -@c snarfed from list.c:783 @deffn primitive delv1! item lst Like @code{delv!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @@ -2284,7 +2027,6 @@ Like @code{delv!}, but only deletes the first occurrence of @end deffn delete1! -@c snarfed from list.c:811 @deffn primitive delete1! item lst Like @code{delete!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @@ -2292,7 +2034,6 @@ Like @code{delete!}, but only deletes the first occurrence of @end deffn primitive-load -@c snarfed from load.c:110 @deffn primitive primitive-load filename Load the file named @var{filename} and evaluate its contents in the top-level environment. The load paths are not searched; @@ -2304,7 +2045,6 @@ documentation for @code{%load-hook} later in this section. @end deffn %package-data-dir -@c snarfed from load.c:150 @deffn primitive %package-data-dir Return the name of the directory where Scheme packages, modules and libraries are kept. On most Unix systems, this will be @@ -2312,21 +2052,18 @@ libraries are kept. On most Unix systems, this will be @end deffn %library-dir -@c snarfed from load.c:162 @deffn primitive %library-dir Return the directory where the Guile Scheme library files are installed. E.g., may return "/usr/share/guile/1.3.5". @end deffn %site-dir -@c snarfed from load.c:174 @deffn primitive %site-dir Return the directory where the Guile site files are installed. E.g., may return "/usr/share/guile/site". @end deffn parse-path -@c snarfed from load.c:226 @deffn primitive parse-path path [tail] Parse @var{path}, which is expected to be a colon-separated string, into a list and return the resulting list with @@ -2335,7 +2072,6 @@ is returned. @end deffn search-path -@c snarfed from load.c:276 @deffn primitive search-path path filename [extensions] Search @var{path} for a directory containing a file named @var{filename}. The file must be readable, and not a directory. @@ -2347,7 +2083,6 @@ concatenated with each @var{extension}. @end deffn %search-load-path -@c snarfed from load.c:423 @deffn primitive %search-load-path filename Search @var{%load-path} for the file named @var{filename}, which must be readable by the current user. If @var{filename} @@ -2359,7 +2094,6 @@ will try each extension automatically. @end deffn primitive-load-path -@c snarfed from load.c:444 @deffn primitive primitive-load-path filename Search @var{%load-path} for the file named @var{filename} and load it into the top-level environment. If @var{filename} is a @@ -2368,7 +2102,6 @@ an error is signalled. @end deffn procedure->syntax -@c snarfed from macros.c:104 @deffn primitive procedure->syntax code Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, returns the @@ -2377,7 +2110,6 @@ environment. @end deffn procedure->macro -@c snarfed from macros.c:127 @deffn primitive procedure->macro code Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the @@ -2396,7 +2128,6 @@ passed to @var{code}. For example: @end deffn procedure->memoizing-macro -@c snarfed from macros.c:150 @deffn primitive procedure->memoizing-macro code Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the @@ -2415,14 +2146,12 @@ passed to @var{proc}. For example: @end deffn macro? -@c snarfed from macros.c:162 @deffn primitive macro? obj Return @code{#t} if @var{obj} is a regular macro, a memoizing macro or a syntax transformer. @end deffn macro-type -@c snarfed from macros.c:180 @deffn primitive macro-type m Return one of the symbols @code{syntax}, @code{macro} or @code{macro!}, depending on whether @var{m} is a syntax @@ -2432,32 +2161,27 @@ returned. @end deffn macro-name -@c snarfed from macros.c:198 @deffn primitive macro-name m Return the name of the macro @var{m}. @end deffn macro-transformer -@c snarfed from macros.c:209 @deffn primitive macro-transformer m Return the transformer of the macro @var{m}. @end deffn current-module -@c snarfed from modules.c:69 @deffn primitive current-module Return the current module. @end deffn set-current-module -@c snarfed from modules.c:81 @deffn primitive set-current-module module Set the current module to @var{module} and return the previous current module. @end deffn interaction-environment -@c snarfed from modules.c:104 @deffn primitive interaction-environment Return a specifier for the environment that contains implementation--defined bindings, typically a superset of those @@ -2467,52 +2191,44 @@ evaluate expressions dynamically typed by the user. @end deffn env-module -@c snarfed from modules.c:253 @deffn primitive env-module env Return the module of @var{ENV}, a lexical environment. @end deffn standard-eval-closure -@c snarfed from modules.c:330 @deffn primitive standard-eval-closure module Return an eval closure for the module @var{module}. @end deffn standard-interface-eval-closure -@c snarfed from modules.c:341 @deffn primitive standard-interface-eval-closure module Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added. @end deffn %get-pre-modules-obarray -@c snarfed from modules.c:564 @deffn primitive %get-pre-modules-obarray Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system. @end deffn exact? -@c snarfed from numbers.c:97 @deffn primitive exact? x Return @code{#t} if @var{x} is an exact number, @code{#f} otherwise. @end deffn odd? -@c snarfed from numbers.c:114 @deffn primitive odd? n Return @code{#t} if @var{n} is an odd number, @code{#f} otherwise. @end deffn even? -@c snarfed from numbers.c:131 @deffn primitive even? n Return @code{#t} if @var{n} is an even number, @code{#f} otherwise. @end deffn logand -@c snarfed from numbers.c:744 @deffn primitive logand n1 n2 Return the bitwise AND of the integer arguments. @@ -2524,7 +2240,6 @@ Return the bitwise AND of the integer arguments. @end deffn logior -@c snarfed from numbers.c:830 @deffn primitive logior n1 n2 Return the bitwise OR of the integer arguments. @@ -2536,7 +2251,6 @@ Return the bitwise OR of the integer arguments. @end deffn logxor -@c snarfed from numbers.c:917 @deffn primitive logxor n1 n2 Return the bitwise XOR of the integer arguments. A bit is set in the result if it is set in an odd number of arguments. @@ -2549,7 +2263,6 @@ set in the result if it is set in an odd number of arguments. @end deffn logtest -@c snarfed from numbers.c:986 @deffn primitive logtest j k @lisp (logtest j k) @equiv{} (not (zero? (logand j k))) @@ -2560,7 +2273,6 @@ set in the result if it is set in an odd number of arguments. @end deffn logbit? -@c snarfed from numbers.c:1043 @deffn primitive logbit? index j @lisp (logbit? index j) @equiv{} (logtest (integer-expt 2 index) j) @@ -2574,7 +2286,6 @@ set in the result if it is set in an odd number of arguments. @end deffn lognot -@c snarfed from numbers.c:1092 @deffn primitive lognot n Return the integer which is the 2s-complement of the integer argument. @@ -2588,7 +2299,6 @@ argument. @end deffn integer-expt -@c snarfed from numbers.c:1109 @deffn primitive integer-expt n k Return @var{n} raised to the non-negative integer exponent @var{k}. @@ -2602,7 +2312,6 @@ Return @var{n} raised to the non-negative integer exponent @end deffn ash -@c snarfed from numbers.c:1164 @deffn primitive ash n cnt The function ash performs an arithmetic shift left by @var{cnt} bits (or shift right, if @var{cnt} is negative). 'Arithmetic' @@ -2622,7 +2331,6 @@ Formally, the function returns an integer equivalent to @end deffn bit-extract -@c snarfed from numbers.c:1217 @deffn primitive bit-extract n start end Return the integer composed of the @var{start} (inclusive) through @var{end} (exclusive) bits of @var{n}. The @@ -2637,7 +2345,6 @@ through @var{end} (exclusive) bits of @var{n}. The @end deffn logcount -@c snarfed from numbers.c:1289 @deffn primitive logcount n Return the number of bits in integer @var{n}. If integer is positive, the 1-bits in its binary representation are counted. @@ -2655,7 +2362,6 @@ representation are counted. If 0, 0 is returned. @end deffn integer-length -@c snarfed from numbers.c:1340 @deffn primitive integer-length n Return the number of bits neccessary to represent @var{n}. @@ -2670,7 +2376,6 @@ Return the number of bits neccessary to represent @var{n}. @end deffn number->string -@c snarfed from numbers.c:2175 @deffn primitive number->string n [radix] Return a string holding the external representation of the number @var{n} in the given @var{radix}. If @var{n} is @@ -2678,7 +2383,6 @@ inexact, a radix of 10 will be used. @end deffn string->number -@c snarfed from numbers.c:2810 @deffn primitive string->number string [radix] Return a number of the maximally precise representation expressed by the given @var{string}. @var{radix} must be an @@ -2691,13 +2395,11 @@ syntactically valid notation for a number, then @end deffn number? -@c snarfed from numbers.c:2879 @deffn primitive number? implemented by the C function "scm_number_p" @end deffn complex? -@c snarfed from numbers.c:2891 @deffn primitive complex? x Return @code{#t} if @var{x} is a complex number, @code{#f} else. Note that the sets of real, rational and integer @@ -2707,13 +2409,11 @@ rational or integer number. @end deffn real? -@c snarfed from numbers.c:2899 @deffn primitive real? implemented by the C function "scm_real_p" @end deffn rational? -@c snarfed from numbers.c:2912 @deffn primitive rational? x Return @code{#t} if @var{x} is a rational number, @code{#f} else. Note that the set of integer values forms a subset of @@ -2724,28 +2424,24 @@ precision. @end deffn integer? -@c snarfed from numbers.c:2933 @deffn primitive integer? x Return @code{#t} if @var{x} is an integer number, @code{#f} else. @end deffn inexact? -@c snarfed from numbers.c:2958 @deffn primitive inexact? x Return @code{#t} if @var{x} is an inexact number, @code{#f} else. @end deffn $expt -@c snarfed from numbers.c:4003 @deffn primitive $expt x y Return @var{x} raised to the power of @var{y}. This procedure does not accept complex arguments. @end deffn $atan2 -@c snarfed from numbers.c:4019 @deffn primitive $atan2 x y Return the arc tangent of the two arguments @var{x} and @var{y}. This is similar to calculating the arc tangent of @@ -2755,92 +2451,78 @@ procedure does not accept complex arguments. @end deffn make-rectangular -@c snarfed from numbers.c:4032 @deffn primitive make-rectangular real imaginary Return a complex number constructed of the given @var{real} and @var{imaginary} parts. @end deffn make-polar -@c snarfed from numbers.c:4045 @deffn primitive make-polar x y Return the complex number @var{x} * e^(i * @var{y}). @end deffn inexact->exact -@c snarfed from numbers.c:4180 @deffn primitive inexact->exact z Return an exact number that is numerically closest to @var{z}. @end deffn class-of -@c snarfed from objects.c:86 @deffn primitive class-of x Return the class of @var{x}. @end deffn entity? -@c snarfed from objects.c:360 @deffn primitive entity? obj Return @code{#t} if @var{obj} is an entity. @end deffn operator? -@c snarfed from objects.c:369 @deffn primitive operator? obj Return @code{#t} if @var{obj} is an operator. @end deffn valid-object-procedure? -@c snarfed from objects.c:385 @deffn primitive valid-object-procedure? proc Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}. @end deffn set-object-procedure! -@c snarfed from objects.c:407 @deffn primitive set-object-procedure! obj proc Set the object procedure of @var{obj} to @var{proc}. @var{obj} must be either an entity or an operator. @end deffn make-class-object -@c snarfed from objects.c:467 @deffn primitive make-class-object metaclass layout Create a new class object of class @var{metaclass}, with the slot layout specified by @var{layout}. @end deffn make-subclass-object -@c snarfed from objects.c:482 @deffn primitive make-subclass-object class layout Create a subclass object of @var{class}, with the slot layout specified by @var{layout}. @end deffn object-properties -@c snarfed from objprop.c:60 @deffn primitive object-properties obj @deffnx primitive procedure-properties obj Return @var{obj}'s property list. @end deffn set-object-properties! -@c snarfed from objprop.c:71 @deffn primitive set-object-properties! obj alist @deffnx primitive set-procedure-properties! obj alist Set @var{obj}'s property list to @var{alist}. @end deffn object-property -@c snarfed from objprop.c:83 @deffn primitive object-property obj key @deffnx primitive procedure-property obj key Return the property of @var{obj} with name @var{key}. @end deffn set-object-property! -@c snarfed from objprop.c:96 @deffn primitive set-object-property! obj key value @deffnx primitive set-procedure-property! obj key value In @var{obj}'s property list, set the property named @var{key} @@ -2848,7 +2530,6 @@ to @var{value}. @end deffn cons -@c snarfed from pairs.c:80 @deffn primitive cons x y Return a newly allocated pair whose car is @var{x} and whose cdr is @var{y}. The pair is guaranteed to be different (in the @@ -2856,28 +2537,24 @@ sense of @code{eq?}) from every previously existing object. @end deffn pair? -@c snarfed from pairs.c:113 @deffn primitive pair? x Return @code{#t} if @var{x} is a pair; otherwise return @code{#f}. @end deffn set-car! -@c snarfed from pairs.c:124 @deffn primitive set-car! pair value Stores @var{value} in the car field of @var{pair}. The value returned by @code{set-car!} is unspecified. @end deffn set-cdr! -@c snarfed from pairs.c:137 @deffn primitive set-cdr! pair value Stores @var{value} in the cdr field of @var{pair}. The value returned by @code{set-cdr!} is unspecified. @end deffn char-ready? -@c snarfed from ports.c:253 @deffn primitive char-ready? [port] Return @code{#t} if a character is ready on input @var{port} and return @code{#f} otherwise. If @code{char-ready?} returns @@ -2895,7 +2572,6 @@ interactive port that has no ready characters.} @end deffn drain-input -@c snarfed from ports.c:330 @deffn primitive drain-input port This procedure clears a port's input buffers, similar to the way that force-output clears the output buffer. The @@ -2914,7 +2590,6 @@ for further input. @end deffn current-input-port -@c snarfed from ports.c:357 @deffn primitive current-input-port Return the current input port. This is the default port used by many input procedures. Initially, @code{current-input-port} @@ -2922,7 +2597,6 @@ returns the @dfn{standard input} in Unix and C terminology. @end deffn current-output-port -@c snarfed from ports.c:369 @deffn primitive current-output-port Return the current output port. This is the default port used by many output procedures. Initially, @@ -2931,21 +2605,18 @@ Unix and C terminology. @end deffn current-error-port -@c snarfed from ports.c:379 @deffn primitive current-error-port Return the port to which errors and warnings should be sent (the @dfn{standard error} in Unix and C terminology). @end deffn current-load-port -@c snarfed from ports.c:389 @deffn primitive current-load-port Return the current-load-port. The load port is used internally by @code{primitive-load}. @end deffn set-current-input-port -@c snarfed from ports.c:402 @deffn primitive set-current-input-port port @deffnx primitive set-current-output-port port @deffnx primitive set-current-error-port port @@ -2955,32 +2626,27 @@ so that they use the supplied @var{port} for input or output. @end deffn set-current-output-port -@c snarfed from ports.c:415 @deffn primitive set-current-output-port port Set the current default output port to @var{port}. @end deffn set-current-error-port -@c snarfed from ports.c:429 @deffn primitive set-current-error-port port Set the current default error port to @var{port}. @end deffn port-revealed -@c snarfed from ports.c:574 @deffn primitive port-revealed port Return the revealed count for @var{port}. @end deffn set-port-revealed! -@c snarfed from ports.c:587 @deffn primitive set-port-revealed! port rcount Sets the revealed count for a port to a given value. The return value is unspecified. @end deffn port-mode -@c snarfed from ports.c:630 @deffn primitive port-mode port Return the port modes associated with the open port @var{port}. These will not necessarily be identical to the modes used when @@ -2989,7 +2655,6 @@ used only during port creation are not retained. @end deffn close-port -@c snarfed from ports.c:667 @deffn primitive close-port port Close the specified port object. Return @code{#t} if it successfully closes a port or @code{#f} if it was already @@ -3000,7 +2665,6 @@ descriptors. @end deffn close-input-port -@c snarfed from ports.c:695 @deffn primitive close-input-port port Close the specified input port object. The routine has no effect if the file has already been closed. An exception may be raised if an @@ -3011,7 +2675,6 @@ which can close file descriptors. @end deffn close-output-port -@c snarfed from ports.c:710 @deffn primitive close-output-port port Close the specified output port object. The routine has no effect if the file has already been closed. An exception may be raised if an @@ -3022,7 +2685,6 @@ which can close file descriptors. @end deffn port-for-each -@c snarfed from ports.c:727 @deffn primitive port-for-each proc Apply @var{proc} to each port in the Guile port table in turn. The return value is unspecified. More specifically, @@ -3033,7 +2695,6 @@ have no effect as far as @var{port-for-each} is concerned. @end deffn input-port? -@c snarfed from ports.c:768 @deffn primitive input-port? x Return @code{#t} if @var{x} is an input port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @@ -3041,7 +2702,6 @@ Return @code{#t} if @var{x} is an input port, otherwise return @end deffn output-port? -@c snarfed from ports.c:779 @deffn primitive output-port? x Return @code{#t} if @var{x} is an output port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @@ -3049,7 +2709,6 @@ Return @code{#t} if @var{x} is an output port, otherwise return @end deffn port? -@c snarfed from ports.c:791 @deffn primitive port? x Return a boolean indicating whether @var{x} is a port. Equivalent to @code{(or (input-port? @var{x}) (output-port? @@ -3057,21 +2716,18 @@ Equivalent to @code{(or (input-port? @var{x}) (output-port? @end deffn port-closed? -@c snarfed from ports.c:801 @deffn primitive port-closed? port Return @code{#t} if @var{port} is closed or @code{#f} if it is open. @end deffn eof-object? -@c snarfed from ports.c:812 @deffn primitive eof-object? x Return @code{#t} if @var{x} is an end-of-file object; otherwise return @code{#f}. @end deffn force-output -@c snarfed from ports.c:826 @deffn primitive force-output [port] Flush the specified output port, or the current output port if @var{port} is omitted. The current output buffer contents are passed to the @@ -3083,14 +2739,12 @@ The return value is unspecified. @end deffn flush-all-ports -@c snarfed from ports.c:844 @deffn primitive flush-all-ports Equivalent to calling @code{force-output} on all open output ports. The return value is unspecified. @end deffn read-char -@c snarfed from ports.c:862 @deffn primitive read-char [port] Return the next character available from @var{port}, updating @var{port} to point to the following character. If no more @@ -3098,7 +2752,6 @@ characters are available, the end-of-file object is returned. @end deffn peek-char -@c snarfed from ports.c:1188 @deffn primitive peek-char [port] Return the next character available from @var{port}, @emph{without} updating @var{port} to point to the following @@ -3115,7 +2768,6 @@ to @code{read-char} would have hung.} @end deffn unread-char -@c snarfed from ports.c:1209 @deffn primitive unread-char cobj [port] Place @var{char} in @var{port} so that it will be read by the next read operation. If called multiple times, the unread characters @@ -3124,7 +2776,6 @@ not supplied, the current input port is used. @end deffn unread-string -@c snarfed from ports.c:1232 @deffn primitive unread-string str port Place the string @var{str} in @var{port} so that its characters will be read in subsequent read operations. If called multiple times, the @@ -3133,7 +2784,6 @@ unread characters will be read again in last-in first-out order. If @end deffn seek -@c snarfed from ports.c:1271 @deffn primitive seek fd_port offset whence Sets the current position of @var{fd/port} to the integer @var{offset}, which is interpreted according to the value of @@ -3161,7 +2811,6 @@ that the current position of a port can be obtained using: @end deffn truncate-file -@c snarfed from ports.c:1326 @deffn primitive truncate-file object [length] Truncates the object referred to by @var{object} to at most @var{length} bytes. @var{object} can be a string containing a @@ -3172,19 +2821,16 @@ position. The return value is unspecified. @end deffn port-line -@c snarfed from ports.c:1379 @deffn primitive port-line port Return the current line number for @var{port}. @end deffn set-port-line! -@c snarfed from ports.c:1390 @deffn primitive set-port-line! port line Set the current line number for @var{port} to @var{line}. @end deffn port-column -@c snarfed from ports.c:1411 @deffn primitive port-column port @deffnx primitive port-line port Return the current column number or line number of @var{port}, @@ -3198,7 +2844,6 @@ what non-programmers will find most natural.) @end deffn set-port-column! -@c snarfed from ports.c:1424 @deffn primitive set-port-column! port column @deffnx primitive set-port-line! port line Set the current column or line number of @var{port}, using the @@ -3206,7 +2851,6 @@ current input port if none is specified. @end deffn port-filename -@c snarfed from ports.c:1439 @deffn primitive port-filename port Return the filename associated with @var{port}. This function returns the strings "standard input", "standard output" and "standard error" @@ -3214,7 +2858,6 @@ when called on the current input, output and error ports respectively. @end deffn set-port-filename! -@c snarfed from ports.c:1453 @deffn primitive set-port-filename! port filename Change the filename associated with @var{port}, using the current input port if none is specified. Note that this does not change the port's @@ -3223,7 +2866,6 @@ source of data, but only the value that is returned by @end deffn %make-void-port -@c snarfed from ports.c:1547 @deffn primitive %make-void-port mode Create and return a new void port. A void port acts like /dev/null. The @var{mode} argument @@ -3232,7 +2874,6 @@ documentation for @code{open-file} in @ref{File Ports}. @end deffn print-options-interface -@c snarfed from print.c:141 @deffn primitive print-options-interface [setting] Option interface for the print options. Instead of using this procedure directly, use the procedures @@ -3241,7 +2882,6 @@ and @code{print-options}. @end deffn simple-format -@c snarfed from print.c:909 @deffn primitive simple-format destination message . args Write @var{message} to @var{destination}, defaulting to the current output port. @@ -3257,76 +2897,64 @@ containing the formatted text. Does not add a trailing newline. @end deffn newline -@c snarfed from print.c:995 @deffn primitive newline [port] Send a newline to @var{port}. @end deffn write-char -@c snarfed from print.c:1010 @deffn primitive write-char chr [port] Send character @var{chr} to @var{port}. @end deffn port-with-print-state -@c snarfed from print.c:1064 @deffn primitive port-with-print-state port pstate Create a new port which behaves like @var{port}, but with an included print state @var{pstate}. @end deffn get-print-state -@c snarfed from print.c:1079 @deffn primitive get-print-state port Return the print state of the port @var{port}. If @var{port} has no associated print state, @code{#f} is returned. @end deffn procedure-properties -@c snarfed from procprop.c:176 @deffn primitive procedure-properties proc Return @var{obj}'s property list. @end deffn set-procedure-properties! -@c snarfed from procprop.c:189 @deffn primitive set-procedure-properties! proc new_val Set @var{obj}'s property list to @var{alist}. @end deffn procedure-property -@c snarfed from procprop.c:202 @deffn primitive procedure-property p k Return the property of @var{obj} with name @var{key}. @end deffn set-procedure-property! -@c snarfed from procprop.c:225 @deffn primitive set-procedure-property! p k v In @var{obj}'s property list, set the property named @var{key} to @var{value}. @end deffn procedure? -@c snarfed from procs.c:195 @deffn primitive procedure? obj Return @code{#t} if @var{obj} is a procedure. @end deffn closure? -@c snarfed from procs.c:222 @deffn primitive closure? obj Return @code{#t} if @var{obj} is a closure. @end deffn thunk? -@c snarfed from procs.c:231 @deffn primitive thunk? obj Return @code{#t} if @var{obj} is a thunk. @end deffn procedure-documentation -@c snarfed from procs.c:281 @deffn primitive procedure-documentation proc Return the documentation string associated with @code{proc}. By convention, if a procedure contains more than one expression and the @@ -3335,28 +2963,24 @@ documentation for that procedure. @end deffn procedure-with-setter? -@c snarfed from procs.c:317 @deffn primitive procedure-with-setter? obj Return @code{#t} if @var{obj} is a procedure with an associated setter procedure. @end deffn make-procedure-with-setter -@c snarfed from procs.c:327 @deffn primitive make-procedure-with-setter procedure setter Create a new procedure which behaves like @var{procedure}, but with the associated setter @var{setter}. @end deffn procedure -@c snarfed from procs.c:346 @deffn primitive procedure proc Return the procedure of @var{proc}, which must be either a procedure with setter, or an operator struct. @end deffn primitive-make-property -@c snarfed from properties.c:64 @deffn primitive primitive-make-property not_found_proc Create a @dfn{property token} that can be used with @code{primitive-property-ref} and @code{primitive-property-set!}. @@ -3365,7 +2989,6 @@ See @code{primitive-property-ref} for the significance of @end deffn primitive-property-ref -@c snarfed from properties.c:82 @deffn primitive primitive-property-ref prop obj Return the property @var{prop} of @var{obj}. When no value has yet been associated with @var{prop} and @var{obj}, call @@ -3377,19 +3000,16 @@ default value of @var{prop}. @end deffn primitive-property-set! -@c snarfed from properties.c:113 @deffn primitive primitive-property-set! prop obj val Associate @var{code} with @var{prop} and @var{obj}. @end deffn primitive-property-del! -@c snarfed from properties.c:134 @deffn primitive primitive-property-del! prop obj Remove any value associated with @var{prop} and @var{obj}. @end deffn random -@c snarfed from random.c:376 @deffn primitive random n [state] Return a number in [0,N). @@ -3406,26 +3026,22 @@ as a side effect of the random operation. @end deffn copy-random-state -@c snarfed from random.c:399 @deffn primitive copy-random-state [state] Return a copy of the random state @var{state}. @end deffn seed->random-state -@c snarfed from random.c:411 @deffn primitive seed->random-state seed Return a new random state using @var{seed}. @end deffn random:uniform -@c snarfed from random.c:425 @deffn primitive random:uniform [state] Return a uniformly distributed inexact real random number in [0,1). @end deffn random:normal -@c snarfed from random.c:440 @deffn primitive random:normal [state] Return an inexact real in a normal distribution. The distribution used has mean 0 and standard deviation 1. For a @@ -3434,29 +3050,26 @@ normal distribution with mean m and standard deviation d use @end deffn random:solid-sphere! -@c snarfed from random.c:496 @deffn primitive random:solid-sphere! v [state] Fills vect with inexact real random numbers the sum of whose squares is less than 1.0. Thinking of vect as coordinates in space of dimension n = (vector-length vect), the coordinates -are uniformly distributed within the unit n-shere. +are uniformly distributed within the unit n-sphere. The sum of the squares of the numbers is returned. @end deffn random:hollow-sphere! -@c snarfed from random.c:519 @deffn primitive random:hollow-sphere! v [state] Fills vect with inexact real random numbers the sum of whose squares is equal to 1.0. Thinking of vect as coordinates in space of dimension n = (vector-length vect), the coordinates are uniformly distributed over the surface of the -unit n-shere. +unit n-sphere. @end deffn random:normal-vector! -@c snarfed from random.c:537 @deffn primitive random:normal-vector! v [state] Fills vect with inexact real random numbers that are independent and standard normally distributed @@ -3464,7 +3077,6 @@ independent and standard normally distributed @end deffn random:exp -@c snarfed from random.c:562 @deffn primitive random:exp [state] Return an inexact real in an exponential distribution with mean 1. For an exponential distribution with mean u use (* u @@ -3472,7 +3084,6 @@ Return an inexact real in an exponential distribution with mean @end deffn %read-delimited! -@c snarfed from rdelim.c:78 @deffn primitive %read-delimited! delims str gobble [port [start [end]]] Read characters from @var{port} into @var{str} until one of the characters in the @var{delims} string is encountered. If @@ -3492,7 +3103,6 @@ a delimiter, this value is @code{#f}. @end deffn %read-line -@c snarfed from rdelim.c:223 @deffn primitive %read-line [port] Read a newline-terminated line from @var{port}, allocating storage as necessary. The newline terminator (if any) is removed from the string, @@ -3503,7 +3113,6 @@ delimiter may be either a newline or the @var{eof-object}; if @end deffn write-line -@c snarfed from rdelim.c:277 @deffn primitive write-line obj [port] Display @var{obj} and a newline character to @var{port}. If @var{port} is not specified, @code{(current-output-port)} is @@ -3515,7 +3124,6 @@ used. This function is equivalent to: @end deffn read-options-interface -@c snarfed from read.c:82 @deffn primitive read-options-interface [setting] Option interface for the read options. Instead of using this procedure directly, use the procedures @code{read-enable}, @@ -3523,7 +3131,6 @@ this procedure directly, use the procedures @code{read-enable}, @end deffn read -@c snarfed from read.c:102 @deffn primitive read [port] Read an s-expression from the input port @var{port}, or from the current input port if @var{port} is not specified. @@ -3531,7 +3138,6 @@ Any whitespace before the next token is discarded. @end deffn read-hash-extend -@c snarfed from read.c:769 @deffn primitive read-hash-extend chr proc Install the procedure @var{proc} for reading expressions starting with the character sequence @code{#} and @var{chr}. @@ -3541,7 +3147,6 @@ returned will be the return value of @code{read}. @end deffn call-with-dynamic-root -@c snarfed from root.c:352 @deffn primitive call-with-dynamic-root thunk handler Evaluate @code{(thunk)} in a new dynamic context, returning its value. @@ -3588,7 +3193,6 @@ be under a new dynamic root.) @end deffn dynamic-root -@c snarfed from root.c:365 @deffn primitive dynamic-root Return an object representing the current dynamic root. @@ -3598,7 +3202,6 @@ in no way depend on this. @end deffn read-string!/partial -@c snarfed from rw.c:121 @deffn primitive read-string!/partial str [port_or_fdes [start [end]]] Read characters from a port or file descriptor into a string @var{str}. A port must have an underlying file @@ -3640,7 +3243,6 @@ end-of-file check. @end deffn write-string/partial -@c snarfed from rw.c:215 @deffn primitive write-string/partial str [port_or_fdes [start [end]]] Write characters from a string @var{str} to a port or file descriptor. A port must have an underlying file descriptor @@ -3686,7 +3288,6 @@ return 0 immediately if the request size is 0 bytes. @end deffn sigaction -@c snarfed from scmsigs.c:211 @deffn primitive sigaction signum [handler [flags]] Install or report the signal handler for a specified signal. @@ -3717,14 +3318,12 @@ structures. @end deffn restore-signals -@c snarfed from scmsigs.c:374 @deffn primitive restore-signals Return all signal handlers to the values they had before any call to @code{sigaction} was made. The return value is unspecified. @end deffn alarm -@c snarfed from scmsigs.c:413 @deffn primitive alarm i Set a timer to raise a @code{SIGALRM} signal after the specified number of seconds (an integer). It's advisable to install a signal @@ -3738,7 +3337,6 @@ no previous alarm, the return value is zero. @end deffn setitimer -@c snarfed from scmsigs.c:443 @deffn primitive setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds Set the timer specified by @var{which_timer} according to the given @var{interval_seconds}, @var{interval_microseconds}, @@ -3758,7 +3356,6 @@ the seconds and microseconds of the timer @code{it_value}. @end deffn getitimer -@c snarfed from scmsigs.c:484 @deffn primitive getitimer which_timer Return information about the timer specified by @var{which_timer} Errors are handled as described in the guile info pages under ``POSIX @@ -3774,7 +3371,6 @@ the seconds and microseconds of the timer @code{it_value}. @end deffn pause -@c snarfed from scmsigs.c:511 @deffn primitive pause Pause the current process (thread?) until a signal arrives whose action is to either terminate the current process or invoke a @@ -3782,7 +3378,6 @@ handler procedure. The return value is unspecified. @end deffn sleep -@c snarfed from scmsigs.c:524 @deffn primitive sleep i Wait for the given number of seconds (an integer) or until a signal arrives. The return value is zero if the time elapses or the number @@ -3790,21 +3385,18 @@ of seconds remaining otherwise. @end deffn usleep -@c snarfed from scmsigs.c:542 @deffn primitive usleep i Sleep for I microseconds. @code{usleep} is not available on all platforms. @end deffn raise -@c snarfed from scmsigs.c:571 @deffn primitive raise sig Sends a specified signal @var{sig} to the current process, where @var{sig} is as described for the kill procedure. @end deffn system -@c snarfed from simpos.c:76 @deffn primitive system [cmd] Execute @var{cmd} using the operating system's "command processor". Under Unix this is usually the default shell @@ -3817,7 +3409,6 @@ indicating whether the command processor is available. @end deffn getenv -@c snarfed from simpos.c:103 @deffn primitive getenv nam Looks up the string @var{name} in the current environment. The return value is @code{#f} unless a string of the form @code{NAME=VALUE} is @@ -3825,7 +3416,6 @@ found, in which case the string @code{VALUE} is returned. @end deffn primitive-exit -@c snarfed from simpos.c:118 @deffn primitive primitive-exit [status] Terminate the current process without unwinding the Scheme stack. This is would typically be useful after a fork. The exit status @@ -3833,7 +3423,6 @@ is @var{status} if supplied, otherwise zero. @end deffn restricted-vector-sort! -@c snarfed from sort.c:421 @deffn primitive restricted-vector-sort! vec less startpos endpos Sort the vector @var{vec}, using @var{less} for comparing the vector elements. @var{startpos} and @var{endpos} delimit @@ -3842,7 +3431,6 @@ is not specified. @end deffn sorted? -@c snarfed from sort.c:452 @deffn primitive sorted? items less Return @code{#t} iff @var{items} is a list or a vector such that for all 1 <= i <= m, the predicate @var{less} returns true when @@ -3850,7 +3438,6 @@ applied to all elements i - 1 and i @end deffn merge -@c snarfed from sort.c:524 @deffn primitive merge alist blist less Takes two lists @var{alist} and @var{blist} such that @code{(sorted? alist less?)} and @code{(sorted? blist less?)} and @@ -3861,7 +3448,6 @@ Note: this does _not_ accept vectors. @end deffn merge! -@c snarfed from sort.c:637 @deffn primitive merge! alist blist less Takes two lists @var{alist} and @var{blist} such that @code{(sorted? alist less?)} and @code{(sorted? blist less?)} and @@ -3873,7 +3459,6 @@ Note: this does _not_ accept vectors. @end deffn sort! -@c snarfed from sort.c:713 @deffn primitive sort! items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence @@ -3883,7 +3468,6 @@ This is not a stable sort. @end deffn sort -@c snarfed from sort.c:747 @deffn primitive sort items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence @@ -3891,7 +3475,6 @@ elements. This is not a stable sort. @end deffn stable-sort! -@c snarfed from sort.c:843 @deffn primitive stable-sort! items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. @@ -3901,7 +3484,6 @@ This is a stable sort. @end deffn stable-sort -@c snarfed from sort.c:883 @deffn primitive stable-sort items less Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. @@ -3909,7 +3491,6 @@ This is a stable sort. @end deffn sort-list! -@c snarfed from sort.c:929 @deffn primitive sort-list! items less Sort the list @var{items}, using @var{less} for comparing the list elements. The sorting is destructive, that means that the @@ -3918,47 +3499,40 @@ This is a stable sort. @end deffn sort-list -@c snarfed from sort.c:943 @deffn primitive sort-list items less Sort the list @var{items}, using @var{less} for comparing the list elements. This is a stable sort. @end deffn source-properties -@c snarfed from srcprop.c:170 @deffn primitive source-properties obj Return the source property association list of @var{obj}. @end deffn set-source-properties! -@c snarfed from srcprop.c:193 @deffn primitive set-source-properties! obj plist Install the association list @var{plist} as the source property list for @var{obj}. @end deffn source-property -@c snarfed from srcprop.c:213 @deffn primitive source-property obj key Return the source property specified by @var{key} from @var{obj}'s source property list. @end deffn set-source-property! -@c snarfed from srcprop.c:246 @deffn primitive set-source-property! obj key datum Set the source property of object @var{obj}, which is specified by @var{key} to @var{datum}. Normally, the key will be a symbol. @end deffn stack? -@c snarfed from stacks.c:411 @deffn primitive stack? obj Return @code{#t} if @var{obj} is a calling stack. @end deffn make-stack -@c snarfed from stacks.c:442 @deffn primitive make-stack obj . args Create a new stack. If @var{obj} is @code{#t}, the current evaluation stack is used for creating the stack frames, @@ -3991,31 +3565,26 @@ taken as 0. @end deffn stack-id -@c snarfed from stacks.c:534 @deffn primitive stack-id stack Return the identifier given to @var{stack} by @code{start-stack}. @end deffn stack-ref -@c snarfed from stacks.c:575 @deffn primitive stack-ref stack index Return the @var{index}'th frame from @var{stack}. @end deffn stack-length -@c snarfed from stacks.c:591 @deffn primitive stack-length stack Return the length of @var{stack}. @end deffn frame? -@c snarfed from stacks.c:604 @deffn primitive frame? obj Return @code{#t} if @var{obj} is a stack frame. @end deffn last-stack-frame -@c snarfed from stacks.c:615 @deffn primitive last-stack-frame obj Return a stack which consists of a single frame, which is the last stack frame for @var{obj}. @var{obj} must be either a @@ -4023,77 +3592,65 @@ debug object or a continuation. @end deffn frame-number -@c snarfed from stacks.c:657 @deffn primitive frame-number frame Return the frame number of @var{frame}. @end deffn frame-source -@c snarfed from stacks.c:667 @deffn primitive frame-source frame Return the source of @var{frame}. @end deffn frame-procedure -@c snarfed from stacks.c:678 @deffn primitive frame-procedure frame Return the procedure for @var{frame}, or @code{#f} if no procedure is associated with @var{frame}. @end deffn frame-arguments -@c snarfed from stacks.c:690 @deffn primitive frame-arguments frame Return the arguments of @var{frame}. @end deffn frame-previous -@c snarfed from stacks.c:701 @deffn primitive frame-previous frame Return the previous frame of @var{frame}, or @code{#f} if @var{frame} is the first frame in its stack. @end deffn frame-next -@c snarfed from stacks.c:717 @deffn primitive frame-next frame Return the next frame of @var{frame}, or @code{#f} if @var{frame} is the last frame in its stack. @end deffn frame-real? -@c snarfed from stacks.c:732 @deffn primitive frame-real? frame Return @code{#t} if @var{frame} is a real frame. @end deffn frame-procedure? -@c snarfed from stacks.c:742 @deffn primitive frame-procedure? frame Return @code{#t} if a procedure is associated with @var{frame}. @end deffn frame-evaluating-args? -@c snarfed from stacks.c:752 @deffn primitive frame-evaluating-args? frame Return @code{#t} if @var{frame} contains evaluated arguments. @end deffn frame-overflow? -@c snarfed from stacks.c:762 @deffn primitive frame-overflow? frame Return @code{#t} if @var{frame} is an overflow frame. @end deffn get-internal-real-time -@c snarfed from stime.c:143 @deffn primitive get-internal-real-time Return the number of time units since the interpreter was started. @end deffn times -@c snarfed from stime.c:188 @deffn primitive times Return an object with information about real and processor time. The following procedures accept such an object as an @@ -4119,7 +3676,6 @@ terminated child processes. @end deffn get-internal-run-time -@c snarfed from stime.c:220 @deffn primitive get-internal-run-time Return the number of time units of processor time used by the interpreter. Both @emph{system} and @emph{user} time are @@ -4127,14 +3683,12 @@ included but subprocesses are not. @end deffn current-time -@c snarfed from stime.c:230 @deffn primitive current-time Return the number of seconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. @end deffn gettimeofday -@c snarfed from stime.c:248 @deffn primitive gettimeofday Return a pair containing the number of seconds and microseconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note: @@ -4143,7 +3697,6 @@ operating system. @end deffn localtime -@c snarfed from stime.c:347 @deffn primitive localtime time [zone] Return an object representing the broken down components of @var{time}, an integer like the one returned by @@ -4153,7 +3706,6 @@ optionally specified by @var{zone} (a string), otherwise the @end deffn gmtime -@c snarfed from stime.c:419 @deffn primitive gmtime time Return an object representing the broken down components of @var{time}, an integer like the one returned by @@ -4161,7 +3713,6 @@ Return an object representing the broken down components of @end deffn mktime -@c snarfed from stime.c:481 @deffn primitive mktime sbd_time [zone] @var{bd-time} is an object representing broken down time and @code{zone} is an optional time zone specifier (otherwise the TZ environment variable @@ -4174,7 +3725,6 @@ as @var{bd-time} but with normalized values. @end deffn tzset -@c snarfed from stime.c:554 @deffn primitive tzset Initialize the timezone from the TZ environment variable or the system default. It's not usually necessary to call this procedure @@ -4183,7 +3733,6 @@ timezone. @end deffn strftime -@c snarfed from stime.c:571 @deffn primitive strftime format stime Formats a time specification @var{time} using @var{template}. @var{time} is an object with time components in the form returned by @code{localtime} @@ -4195,7 +3744,6 @@ is the formatted string. @end deffn strptime -@c snarfed from stime.c:668 @deffn primitive strptime format string Performs the reverse action to @code{strftime}, parsing @var{string} according to the specification supplied in @@ -4210,20 +3758,17 @@ which were used for the conversion. @end deffn string? -@c snarfed from strings.c:62 @deffn primitive string? obj Return @code{#t} iff @var{obj} is a string, else returns @code{#f}. @end deffn list->string -@c snarfed from strings.c:70 @deffn primitive list->string implemented by the C function "scm_string" @end deffn string -@c snarfed from strings.c:76 @deffn primitive string . chrs @deffnx primitive list->string chrs Return a newly allocated string composed of the arguments, @@ -4231,7 +3776,6 @@ Return a newly allocated string composed of the arguments, @end deffn make-string -@c snarfed from strings.c:214 @deffn primitive make-string k [chr] Return a newly allocated string of length @var{k}. If @var{chr} is given, then all elements of @@ -4240,20 +3784,17 @@ of the @var{string} are unspecified. @end deffn string-length -@c snarfed from strings.c:247 @deffn primitive string-length string Return the number of characters in @var{string}. @end deffn string-ref -@c snarfed from strings.c:258 @deffn primitive string-ref str k Return character @var{k} of @var{str} using zero-origin indexing. @var{k} must be a valid index of @var{str}. @end deffn string-set! -@c snarfed from strings.c:275 @deffn primitive string-set! str k chr Store @var{chr} in element @var{k} of @var{str} and return an unspecified value. @var{k} must be a valid index of @@ -4261,7 +3802,6 @@ an unspecified value. @var{k} must be a valid index of @end deffn substring -@c snarfed from strings.c:294 @deffn primitive substring str start [end] Return a newly allocated string formed from the characters of @var{str} beginning with index @var{start} (inclusive) and @@ -4273,14 +3813,12 @@ exact integers satisfying: @end deffn string-append -@c snarfed from strings.c:320 @deffn primitive string-append . args Return a newly allocated string whose characters form the concatenation of the given strings, @var{args}. @end deffn string-index -@c snarfed from strop.c:138 @deffn primitive string-index str chr [frm [to]] Return the index of the first occurrence of @var{chr} in @var{str}. The optional integer arguments @var{frm} and @@ -4301,7 +3839,6 @@ procedure essentially implements the @code{index} or @end deffn string-rindex -@c snarfed from strop.c:168 @deffn primitive string-rindex str chr [frm [to]] Like @code{string-index}, but search from the right of the string rather than from the left. This procedure essentially @@ -4321,19 +3858,16 @@ the C library. @end deffn substring-move-left! -@c snarfed from strop.c:185 @deffn primitive substring-move-left! implemented by the C function "scm_substring_move_x" @end deffn substring-move-right! -@c snarfed from strop.c:186 @deffn primitive substring-move-right! implemented by the C function "scm_substring_move_x" @end deffn substring-move! -@c snarfed from strop.c:260 @deffn primitive substring-move! str1 start1 end1 str2 start2 @deffnx primitive substring-move-left! str1 start1 end1 str2 start2 @deffnx primitive substring-move-right! str1 start1 end1 str2 start2 @@ -4356,7 +3890,6 @@ are different strings, it does not matter which function you use. @end deffn substring-fill! -@c snarfed from strop.c:296 @deffn primitive substring-fill! str start end fill Change every character in @var{str} between @var{start} and @var{end} to @var{fill}. @@ -4370,7 +3903,6 @@ y @end deffn string-null? -@c snarfed from strop.c:321 @deffn primitive string-null? str Return @code{#t} if @var{str}'s length is zero, and @code{#f} otherwise. @@ -4382,7 +3914,6 @@ y @result{} "foo" @end deffn string->list -@c snarfed from strop.c:335 @deffn primitive string->list str Return a newly allocated list of the characters that make up the given string @var{str}. @code{string->list} and @@ -4391,20 +3922,17 @@ concerned. @end deffn string-copy -@c snarfed from strop.c:364 @deffn primitive string-copy str Return a newly allocated copy of the given @var{string}. @end deffn string-fill! -@c snarfed from strop.c:377 @deffn primitive string-fill! str chr Store @var{char} in every element of the given @var{string} and return an unspecified value. @end deffn string-upcase! -@c snarfed from strop.c:412 @deffn primitive string-upcase! str Destructively upcase every character in @var{str} and return @var{str}. @@ -4416,14 +3944,12 @@ y @result{} "ARRDEFG" @end deffn string-upcase -@c snarfed from strop.c:425 @deffn primitive string-upcase str Return a freshly allocated string containing the characters of @var{str} in upper case. @end deffn string-downcase! -@c snarfed from strop.c:457 @deffn primitive string-downcase! str Destructively downcase every character in @var{str} and return @var{str}. @@ -4435,14 +3961,12 @@ y @result{} "arrdefg" @end deffn string-downcase -@c snarfed from strop.c:470 @deffn primitive string-downcase str Return a freshly allocation string containing the characters in @var{str} in lower case. @end deffn string-capitalize! -@c snarfed from strop.c:515 @deffn primitive string-capitalize! str Upcase the first character of every word in @var{str} destructively and return @var{str}. @@ -4455,7 +3979,6 @@ y @result{} "Hello World" @end deffn string-capitalize -@c snarfed from strop.c:529 @deffn primitive string-capitalize str Return a freshly allocated string with the characters in @var{str}, where the first character of every word is @@ -4463,7 +3986,6 @@ capitalized. @end deffn string-split -@c snarfed from strop.c:558 @deffn primitive string-split str chr Split the string @var{str} into the a list of the substrings delimited by appearances of the character @var{chr}. Note that an empty substring @@ -4486,7 +4008,6 @@ result list. @end deffn string-ci->symbol -@c snarfed from strop.c:593 @deffn primitive string-ci->symbol str Return the symbol whose name is @var{str}. @var{str} is converted to lowercase before the conversion is done, if Guile @@ -4494,7 +4015,6 @@ is currently reading symbols case--insensitively. @end deffn string=? -@c snarfed from strorder.c:62 @deffn primitive string=? s1 s2 Lexicographic equality predicate; return @code{#t} if the two strings are the same length and contain the same characters in @@ -4507,7 +4027,6 @@ characters. @end deffn string-ci=? -@c snarfed from strorder.c:97 @deffn primitive string-ci=? s1 s2 Case-insensitive string equality predicate; return @code{#t} if the two strings are the same length and their component @@ -4516,35 +4035,30 @@ return @code{#f}. @end deffn string? -@c snarfed from strorder.c:182 @deffn primitive string>? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @var{s2}. @end deffn string>=? -@c snarfed from strorder.c:196 @deffn primitive string>=? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or equal to @var{s2}. @end deffn string-ci? -@c snarfed from strorder.c:265 @deffn primitive string-ci>? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @@ -4568,7 +4080,6 @@ Case insensitive lexicographic ordering predicate; return @end deffn string-ci>=? -@c snarfed from strorder.c:280 @deffn primitive string-ci>=? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or @@ -4576,7 +4087,6 @@ equal to @var{s2} regardless of case. @end deffn object->string -@c snarfed from strports.c:321 @deffn primitive object->string obj [printer] Return a Scheme string obtained by printing @var{obj}. Printing function can be specified by the optional second @@ -4584,7 +4094,6 @@ argument @var{printer} (default: @code{write}). @end deffn call-with-output-string -@c snarfed from strports.c:345 @deffn primitive call-with-output-string proc Calls the one-argument procedure @var{proc} with a newly created output port. When the function returns, the string composed of the characters @@ -4592,7 +4101,6 @@ written into the port is returned. @end deffn call-with-input-string -@c snarfed from strports.c:364 @deffn primitive call-with-input-string string proc Calls the one-argument procedure @var{proc} with a newly created input port from which @var{string}'s contents may be @@ -4600,7 +4108,6 @@ read. The value yielded by the @var{proc} is returned. @end deffn open-input-string -@c snarfed from strports.c:377 @deffn primitive open-input-string str Take a string and return an input port that delivers characters from the string. The port can be closed by @@ -4609,7 +4116,6 @@ by the garbage collector if it becomes inaccessible. @end deffn open-output-string -@c snarfed from strports.c:391 @deffn primitive open-output-string Return an output port that will accumulate characters for retrieval by @code{get-output-string}. The port can be closed @@ -4619,7 +4125,6 @@ inaccessible. @end deffn get-output-string -@c snarfed from strports.c:408 @deffn primitive get-output-string port Given an output port created by @code{open-output-string}, return a string consisting of the characters that have been @@ -4627,7 +4132,6 @@ output to the port so far. @end deffn eval-string -@c snarfed from strports.c:467 @deffn primitive eval-string string Evaluate @var{string} as the text representation of a Scheme form or forms, and return whatever value they produce. @@ -4636,7 +4140,6 @@ procedure @code{interaction-environment}. @end deffn make-struct-layout -@c snarfed from struct.c:77 @deffn primitive make-struct-layout fields Return a new structure layout object. @@ -4651,20 +4154,17 @@ indicate that the field is a tail-array. @end deffn struct? -@c snarfed from struct.c:244 @deffn primitive struct? x Return @code{#t} iff @var{x} is a structure object, else @code{#f}. @end deffn struct-vtable? -@c snarfed from struct.c:253 @deffn primitive struct-vtable? x Return @code{#t} iff @var{x} is a vtable structure. @end deffn make-struct -@c snarfed from struct.c:437 @deffn primitive make-struct vtable tail_array_size . init Create a new structure. @@ -4694,7 +4194,6 @@ For more information, see the documentation for @code{make-vtable-vtable}. @end deffn make-vtable-vtable -@c snarfed from struct.c:524 @deffn primitive make-vtable-vtable user_fields tail_array_size . init Return a new, self-describing vtable structure. @@ -4755,7 +4254,6 @@ ball @result{} # @end deffn struct-ref -@c snarfed from struct.c:567 @deffn primitive struct-ref handle pos @deffnx primitive struct-set! struct n value Access (or modify) the @var{n}th field of @var{struct}. @@ -4767,7 +4265,6 @@ integer value small enough to fit in one machine word. @end deffn struct-set! -@c snarfed from struct.c:645 @deffn primitive struct-set! handle pos val Set the slot of the structure @var{handle} with index @var{pos} to @var{val}. Signal an error if the slot can not be written @@ -4775,38 +4272,32 @@ to. @end deffn struct-vtable -@c snarfed from struct.c:715 @deffn primitive struct-vtable handle Return the vtable structure that describes the type of @var{struct}. @end deffn struct-vtable-tag -@c snarfed from struct.c:726 @deffn primitive struct-vtable-tag handle Return the vtable tag of the structure @var{handle}. @end deffn struct-vtable-name -@c snarfed from struct.c:765 @deffn primitive struct-vtable-name vtable Return the name of the vtable @var{vtable}. @end deffn set-struct-vtable-name! -@c snarfed from struct.c:775 @deffn primitive set-struct-vtable-name! vtable name Set the name of the vtable @var{vtable} to @var{name}. @end deffn symbol? -@c snarfed from symbols.c:152 @deffn primitive symbol? obj Return @code{#t} if @var{obj} is a symbol, otherwise return @code{#f}. @end deffn symbol->string -@c snarfed from symbols.c:183 @deffn primitive symbol->string s Return the name of @var{symbol} as a string. If the symbol was part of an object returned as the value of a literal expression @@ -4834,7 +4325,6 @@ standard case is lower case: @end deffn string->symbol -@c snarfed from symbols.c:216 @deffn primitive string->symbol string Return the symbol whose name is @var{string}. This procedure can create symbols with names containing special characters or @@ -4859,7 +4349,6 @@ standard case is lower case: @end deffn gensym -@c snarfed from symbols.c:235 @deffn primitive gensym [prefix] Create a new symbol with a name constructed from a prefix and a counter value. The string @var{prefix} can be specified as @@ -4869,37 +4358,31 @@ resetting the counter. @end deffn symbol-hash -@c snarfed from symbols.c:266 @deffn primitive symbol-hash symbol Return a hash value for @var{symbol}. @end deffn symbol-fref -@c snarfed from symbols.c:276 @deffn primitive symbol-fref s Return the contents of @var{symbol}'s @dfn{function slot}. @end deffn symbol-pref -@c snarfed from symbols.c:287 @deffn primitive symbol-pref s Return the @dfn{property list} currently associated with @var{symbol}. @end deffn symbol-fset! -@c snarfed from symbols.c:298 @deffn primitive symbol-fset! s val Change the binding of @var{symbol}'s function slot. @end deffn symbol-pset! -@c snarfed from symbols.c:310 @deffn primitive symbol-pset! s val Change the binding of @var{symbol}'s property slot. @end deffn catch -@c snarfed from throw.c:533 @deffn primitive catch key thunk handler Invoke @var{thunk} in the dynamic context of @var{handler} for exceptions matching @var{key}. If thunk throws to the symbol @@ -4922,7 +4405,6 @@ match this call to @code{catch}. @end deffn lazy-catch -@c snarfed from throw.c:561 @deffn primitive lazy-catch key thunk handler This behaves exactly like @code{catch}, except that it does not unwind the stack before invoking @var{handler}. @@ -4931,7 +4413,6 @@ it must throw to another catch, or otherwise exit non-locally. @end deffn throw -@c snarfed from throw.c:594 @deffn primitive throw key . args Invoke the catch form matching @var{key}, passing @var{args} to the @var{handler}. @@ -4943,7 +4424,6 @@ If there is no handler at all, Guile prints an error and then exits. @end deffn values -@c snarfed from values.c:77 @deffn primitive values . args Delivers all of its arguments to its continuation. Except for continuations created by the @code{call-with-values} procedure, @@ -4953,26 +4433,22 @@ were not created by @code{call-with-values} is unspecified. @end deffn make-variable -@c snarfed from variable.c:81 @deffn primitive make-variable init Return a variable initialized to value @var{init}. @end deffn make-undefined-variable -@c snarfed from variable.c:91 @deffn primitive make-undefined-variable Return a variable that is initially unbound. @end deffn variable? -@c snarfed from variable.c:102 @deffn primitive variable? obj Return @code{#t} iff @var{obj} is a variable object, else return @code{#f}. @end deffn variable-ref -@c snarfed from variable.c:114 @deffn primitive variable-ref var Dereference @var{var} and return its value. @var{var} must be a variable object; see @code{make-variable} @@ -4980,7 +4456,6 @@ and @code{make-undefined-variable}. @end deffn variable-set! -@c snarfed from variable.c:130 @deffn primitive variable-set! var val Set the value of the variable @var{var} to @var{val}. @var{var} must be a variable object, @var{val} can be any @@ -4988,27 +4463,23 @@ value. Return an unspecified value. @end deffn variable-bound? -@c snarfed from variable.c:142 @deffn primitive variable-bound? var Return @code{#t} iff @var{var} is bound to a value. Throws an error if @var{var} is not a variable object. @end deffn vector? -@c snarfed from vectors.c:58 @deffn primitive vector? obj Return @code{#t} if @var{obj} is a vector, otherwise return @code{#f}. @end deffn list->vector -@c snarfed from vectors.c:75 @deffn primitive list->vector implemented by the C function "scm_vector" @end deffn vector -@c snarfed from vectors.c:92 @deffn primitive vector . l @deffnx primitive list->vector l Return a newly allocated vector whose elements contain the @@ -5020,7 +4491,6 @@ given arguments. Analogous to @code{list}. @end deffn make-vector -@c snarfed from vectors.c:178 @deffn primitive make-vector k [fill] Return a newly allocated vector of @var{k} elements. If a second argument is given, then each element is initialized to @@ -5029,7 +4499,6 @@ unspecified. @end deffn vector->list -@c snarfed from vectors.c:235 @deffn primitive vector->list v Return a newly allocated list of the objects contained in the elements of @var{vector}. @@ -5041,62 +4510,56 @@ elements of @var{vector}. @end deffn vector-fill! -@c snarfed from vectors.c:252 @deffn primitive vector-fill! v fill Store @var{fill} in every element of @var{vector}. The value returned by @code{vector-fill!} is unspecified. @end deffn vector-move-left! -@c snarfed from vectors.c:279 @deffn primitive vector-move-left! vec1 start1 end1 vec2 start2 Vector version of @code{substring-move-left!}. @end deffn vector-move-right! -@c snarfed from vectors.c:302 @deffn primitive vector-move-right! vec1 start1 end1 vec2 start2 Vector version of @code{substring-move-right!}. @end deffn major-version -@c snarfed from version.c:59 @deffn primitive major-version Return a string containing Guile's major version number. E.g., the 1 in "1.6.5". @end deffn minor-version -@c snarfed from version.c:72 @deffn primitive minor-version Return a string containing Guile's minor version number. E.g., the 6 in "1.6.5". @end deffn micro-version -@c snarfed from version.c:85 @deffn primitive micro-version Return a string containing Guile's micro version number. E.g., the 5 in "1.6.5". @end deffn version -@c snarfed from version.c:105 @deffn primitive version @deffnx primitive major-version @deffnx primitive minor-version -Return a string describing Guile's version number, or its major or minor -version numbers, respectively. +@deffnx primitive micro-version +Return a string describing Guile's version number, or its major, minor +or micro version number, respectively. @lisp -(version) @result{} "1.3a" +(version) @result{} "1.6.0" (major-version) @result{} "1" -(minor-version) @result{} "3a" +(minor-version) @result{} "6" +(micro-version) @result{} "0" @end lisp @end deffn make-soft-port -@c snarfed from vports.c:185 @deffn primitive make-soft-port pv modes Return a port capable of receiving or delivering characters as specified by the @var{modes} string (@pxref{File Ports, @@ -5142,7 +4605,6 @@ For example: @end deffn make-weak-vector -@c snarfed from weaks.c:115 @deffn primitive make-weak-vector size [fill] Return a weak vector with @var{size} elements. If the optional argument @var{fill} is given, all entries in the vector will be @@ -5151,13 +4613,11 @@ empty list. @end deffn list->weak-vector -@c snarfed from weaks.c:123 @deffn primitive list->weak-vector implemented by the C function "scm_weak_vector" @end deffn weak-vector -@c snarfed from weaks.c:131 @deffn primitive weak-vector . l @deffnx primitive list->weak-vector l Construct a weak vector from a list: @code{weak-vector} uses @@ -5167,14 +4627,12 @@ the same way @code{list->vector} would. @end deffn weak-vector? -@c snarfed from weaks.c:159 @deffn primitive weak-vector? obj Return @code{#t} if @var{obj} is a weak vector. Note that all weak hashes are also weak vectors. @end deffn make-weak-key-hash-table -@c snarfed from weaks.c:177 @deffn primitive make-weak-key-hash-table size @deffnx primitive make-weak-value-hash-table size @deffnx primitive make-doubly-weak-hash-table size @@ -5187,21 +4645,18 @@ would modify regular hash tables. (@pxref{Hash Tables}) @end deffn make-weak-value-hash-table -@c snarfed from weaks.c:188 @deffn primitive make-weak-value-hash-table size Return a hash table with weak values with @var{size} buckets. (@pxref{Hash Tables}) @end deffn make-doubly-weak-hash-table -@c snarfed from weaks.c:199 @deffn primitive make-doubly-weak-hash-table size Return a hash table with weak keys and values with @var{size} buckets. (@pxref{Hash Tables}) @end deffn weak-key-hash-table? -@c snarfed from weaks.c:213 @deffn primitive weak-key-hash-table? obj @deffnx primitive weak-value-hash-table? obj @deffnx primitive doubly-weak-hash-table? obj @@ -5211,26 +4666,22 @@ nor a weak value hash table. @end deffn weak-value-hash-table? -@c snarfed from weaks.c:223 @deffn primitive weak-value-hash-table? obj Return @code{#t} if @var{obj} is a weak value hash table. @end deffn doubly-weak-hash-table? -@c snarfed from weaks.c:233 @deffn primitive doubly-weak-hash-table? obj Return @code{#t} if @var{obj} is a doubly weak hash table. @end deffn regexp? -@c snarfed from regex-posix.c:137 @deffn primitive regexp? obj Return @code{#t} if @var{obj} is a compiled regular expression, or @code{#f} otherwise. @end deffn make-regexp -@c snarfed from regex-posix.c:182 @deffn primitive make-regexp pat . flags Compile the regular expression described by @var{pat}, and return the compiled regexp structure. If @var{pat} does not @@ -5272,7 +4723,6 @@ one which comes last will override the earlier one. @end deffn regexp-exec -@c snarfed from regex-posix.c:243 @deffn primitive regexp-exec rx str [start [flags]] Match the compiled regular expression @var{rx} against @code{str}. If the optional integer @var{start} argument is @@ -5296,20 +4746,17 @@ considered the end of a line. @end deffn array-fill! -@c snarfed from ramap.c:462 @deffn primitive array-fill! ra fill Stores @var{fill} in every element of @var{array}. The value returned is unspecified. @end deffn array-copy-in-order! -@c snarfed from ramap.c:827 @deffn primitive array-copy-in-order! implemented by the C function "scm_array_copy_x" @end deffn array-copy! -@c snarfed from ramap.c:836 @deffn primitive array-copy! src dst @deffnx primitive array-copy-in-order! src dst Copies every element from vector or array @var{source} to the @@ -5319,13 +4766,11 @@ dimension. The order is unspecified. @end deffn array-map-in-order! -@c snarfed from ramap.c:1510 @deffn primitive array-map-in-order! implemented by the C function "scm_array_map_x" @end deffn array-map! -@c snarfed from ramap.c:1521 @deffn primitive array-map! ra0 proc . lra @deffnx primitive array-map-in-order! ra0 proc . lra @var{array1}, @dots{} must have the same number of dimensions as @@ -5337,14 +4782,12 @@ unspecified. The order of application is unspecified. @end deffn array-for-each -@c snarfed from ramap.c:1668 @deffn primitive array-for-each proc ra0 . lra @var{proc} is applied to each tuple of elements of @var{array0} @dots{} in row-major order. The value returned is unspecified. @end deffn array-index-map! -@c snarfed from ramap.c:1696 @deffn primitive array-index-map! ra proc applies @var{proc} to the indices of each element of @var{array} in turn, storing the result in the corresponding element. The value @@ -5367,13 +4810,11 @@ Another example: @end deffn uniform-vector-length -@c snarfed from unif.c:257 @deffn primitive uniform-vector-length v Return the number of elements in @var{uve}. @end deffn array? -@c snarfed from unif.c:291 @deffn primitive array? v [prot] Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. The @var{prototype} argument is used with uniform arrays @@ -5381,14 +4822,12 @@ and is described elsewhere. @end deffn array-rank -@c snarfed from unif.c:362 @deffn primitive array-rank ra Return the number of dimensions of @var{obj}. If @var{obj} is not an array, @code{0} is returned. @end deffn array-dimensions -@c snarfed from unif.c:400 @deffn primitive array-dimensions ra @code{Array-dimensions} is similar to @code{array-shape} but replaces elements with a @code{0} minimum with one greater than the maximum. So: @@ -5398,25 +4837,21 @@ elements with a @code{0} minimum with one greater than the maximum. So: @end deffn shared-array-root -@c snarfed from unif.c:447 @deffn primitive shared-array-root ra Return the root vector of a shared array. @end deffn shared-array-offset -@c snarfed from unif.c:458 @deffn primitive shared-array-offset ra Return the root vector index of the first element in the array. @end deffn shared-array-increments -@c snarfed from unif.c:469 @deffn primitive shared-array-increments ra For each dimension, return the distance between elements in the root vector. @end deffn dimensions->uniform-array -@c snarfed from unif.c:589 @deffn primitive dimensions->uniform-array dims prot [fill] @deffnx primitive make-uniform-vector length prototype [fill] Create and return a uniform array or vector of type @@ -5426,7 +4861,6 @@ fill the array, otherwise @var{prototype} is used. @end deffn make-shared-array -@c snarfed from unif.c:678 @deffn primitive make-shared-array oldra mapfunc . dims @code{make-shared-array} can be used to create shared subarrays of other arrays. The @var{mapper} is a function that translates coordinates in @@ -5446,7 +4880,6 @@ it can be otherwise arbitrary. A simple example: @end deffn transpose-array -@c snarfed from unif.c:810 @deffn primitive transpose-array ra . args Return an array sharing contents with @var{array}, but with dimensions arranged in a different order. There must be one @@ -5470,7 +4903,6 @@ have smaller rank than @var{array}. @end deffn enclose-array -@c snarfed from unif.c:919 @deffn primitive enclose-array ra . axes @var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than the rank of @var{array}. @var{enclose-array} returns an array @@ -5496,20 +4928,17 @@ examples: @end deffn array-in-bounds? -@c snarfed from unif.c:1003 @deffn primitive array-in-bounds? v . args Return @code{#t} if its arguments would be acceptable to @code{array-ref}. @end deffn array-ref -@c snarfed from unif.c:1082 @deffn primitive array-ref implemented by the C function "scm_uniform_vector_ref" @end deffn uniform-vector-ref -@c snarfed from unif.c:1089 @deffn primitive uniform-vector-ref v args @deffnx primitive array-ref v . args Return the element at the @code{(index1, index2)} element in @@ -5517,13 +4946,11 @@ Return the element at the @code{(index1, index2)} element in @end deffn uniform-array-set1! -@c snarfed from unif.c:1258 @deffn primitive uniform-array-set1! implemented by the C function "scm_array_set_x" @end deffn array-set! -@c snarfed from unif.c:1267 @deffn primitive array-set! v obj . args @deffnx primitive uniform-array-set1! v obj args Sets the element at the @code{(index1, index2)} element in @var{array} to @@ -5531,7 +4958,6 @@ Sets the element at the @code{(index1, index2)} element in @var{array} to @end deffn array-contents -@c snarfed from unif.c:1383 @deffn primitive array-contents ra [strict] @deffnx primitive array-contents array strict If @var{array} may be @dfn{unrolled} into a one dimensional shared array @@ -5547,7 +4973,6 @@ memory. @end deffn uniform-array-read! -@c snarfed from unif.c:1497 @deffn primitive uniform-array-read! ra [port_or_fd [start [end]]] @deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end] Attempts to read all elements of @var{ura}, in lexicographic order, as @@ -5567,7 +4992,6 @@ returned by @code{(current-input-port)}. @end deffn uniform-array-write -@c snarfed from unif.c:1662 @deffn primitive uniform-array-write v [port_or_fd [start [end]]] @deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end] Writes all elements of @var{ura} as binary objects to @@ -5584,14 +5008,12 @@ omitted, in which case it defaults to the value returned by @end deffn bit-count -@c snarfed from unif.c:1789 @deffn primitive bit-count b bitvector Return the number of occurrences of the boolean @var{b} in @var{bitvector}. @end deffn bit-position -@c snarfed from unif.c:1828 @deffn primitive bit-position item v k Return the minimum index of an occurrence of @var{bool} in @var{bv} which is at least @var{k}. If no @var{bool} occurs @@ -5599,7 +5021,6 @@ within the specified range @code{#f} is returned. @end deffn bit-set*! -@c snarfed from unif.c:1896 @deffn primitive bit-set*! v kv obj If uve is a bit-vector @var{bv} and uve must be of the same length. If @var{bool} is @code{#t}, uve is OR'ed into @@ -5613,7 +5034,6 @@ of @var{bv} corresponding to the indexes in uve are set to @end deffn bit-count* -@c snarfed from unif.c:1950 @deffn primitive bit-count* v kv obj Return @lisp @@ -5623,20 +5043,17 @@ Return @end deffn bit-invert! -@c snarfed from unif.c:2014 @deffn primitive bit-invert! v Modifies @var{bv} by replacing each element with its negation. @end deffn array->list -@c snarfed from unif.c:2093 @deffn primitive array->list v Return a list consisting of all the elements, in order, of @var{array}. @end deffn list->uniform-array -@c snarfed from unif.c:2194 @deffn primitive list->uniform-array ndim prot lst @deffnx procedure list->uniform-vector prot lst Return a uniform array of the type indicated by prototype @@ -5646,7 +5063,6 @@ done. @end deffn array-prototype -@c snarfed from unif.c:2545 @deffn primitive array-prototype ra Return an object that would produce an array of the same type as @var{array}, if used as the @var{prototype} for @@ -5654,7 +5070,6 @@ as @var{array}, if used as the @var{prototype} for @end deffn chown -@c snarfed from filesys.c:213 @deffn primitive chown object owner group Change the ownership and group of the file referred to by @var{object} to the integer values @var{owner} and @var{group}. @var{object} can be @@ -5671,7 +5086,6 @@ as @code{-1}, then that ID is not changed. @end deffn chmod -@c snarfed from filesys.c:253 @deffn primitive chmod object mode Changes the permissions of the file referred to by @var{obj}. @var{obj} can be a string containing a file name or a port or integer file @@ -5683,7 +5097,6 @@ The return value is unspecified. @end deffn umask -@c snarfed from filesys.c:286 @deffn primitive umask [mode] If @var{mode} is omitted, retuns a decimal number representing the current file creation mask. Otherwise the file creation mask is set to @@ -5693,14 +5106,12 @@ E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18. @end deffn open-fdes -@c snarfed from filesys.c:309 @deffn primitive open-fdes path flags [mode] Similar to @code{open} but return a file descriptor instead of a port. @end deffn open -@c snarfed from filesys.c:351 @deffn primitive open path flags [mode] Open the file named by @var{path} for reading and/or writing. @var{flags} is an integer specifying how the file should be opened. @@ -5732,7 +5143,6 @@ for additional flags. @end deffn close -@c snarfed from filesys.c:389 @deffn primitive close fd_or_port Similar to close-port (@pxref{Generic Port Operations, close-port}), but also works on file descriptors. A side @@ -5742,7 +5152,6 @@ their revealed counts set to zero. @end deffn close-fdes -@c snarfed from filesys.c:417 @deffn primitive close-fdes fd A simple wrapper for the @code{close} system call. Close file descriptor @var{fd}, which must be an integer. @@ -5752,7 +5161,6 @@ The return value is unspecified. @end deffn stat -@c snarfed from filesys.c:620 @deffn primitive stat object Return an object containing various information about the file determined by @var{obj}. @var{obj} can be a string containing @@ -5813,7 +5221,6 @@ An integer representing the access permission bits. @end deffn link -@c snarfed from filesys.c:683 @deffn primitive link oldpath newpath Creates a new name @var{newpath} in the file system for the file named by @var{oldpath}. If @var{oldpath} is a symbolic @@ -5822,20 +5229,17 @@ system. @end deffn rename-file -@c snarfed from filesys.c:704 @deffn primitive rename-file oldname newname Renames the file specified by @var{oldname} to @var{newname}. The return value is unspecified. @end deffn delete-file -@c snarfed from filesys.c:731 @deffn primitive delete-file str Deletes (or "unlinks") the file specified by @var{path}. @end deffn mkdir -@c snarfed from filesys.c:749 @deffn primitive mkdir path [mode] Create a new directory named by @var{path}. If @var{mode} is omitted then the permissions of the directory file are set using the current @@ -5844,28 +5248,24 @@ umask. Otherwise they are set to the decimal value specified with @end deffn rmdir -@c snarfed from filesys.c:777 @deffn primitive rmdir path Remove the existing directory named by @var{path}. The directory must be empty for this to succeed. The return value is unspecified. @end deffn directory-stream? -@c snarfed from filesys.c:802 @deffn primitive directory-stream? obj Return a boolean indicating whether @var{object} is a directory stream as returned by @code{opendir}. @end deffn opendir -@c snarfed from filesys.c:813 @deffn primitive opendir dirname Open the directory specified by @var{path} and return a directory stream. @end deffn readdir -@c snarfed from filesys.c:830 @deffn primitive readdir port Return (as a string) the next directory entry from the directory stream @var{stream}. If there is no remaining entry to be read then the @@ -5873,34 +5273,29 @@ end of file object is returned. @end deffn rewinddir -@c snarfed from filesys.c:853 @deffn primitive rewinddir port Reset the directory port @var{stream} so that the next call to @code{readdir} will return the first directory entry. @end deffn closedir -@c snarfed from filesys.c:870 @deffn primitive closedir port Close the directory stream @var{stream}. The return value is unspecified. @end deffn chdir -@c snarfed from filesys.c:920 @deffn primitive chdir str Change the current working directory to @var{path}. The return value is unspecified. @end deffn getcwd -@c snarfed from filesys.c:936 @deffn primitive getcwd Return the name of the current working directory. @end deffn select -@c snarfed from filesys.c:1132 @deffn primitive select reads writes excepts [secs [usecs]] This procedure has a variety of uses: waiting for the ability to provide input, accept output, or the existance of @@ -5934,7 +5329,6 @@ An additional @code{select!} interface is provided. @end deffn fcntl -@c snarfed from filesys.c:1278 @deffn primitive fcntl object cmd [value] Apply @var{command} to the specified file descriptor or the underlying file descriptor of the specified port. @var{value} is an optional @@ -5964,7 +5358,6 @@ The value used to indicate the "close on exec" flag with @code{F_GETFL} or @end deffn fsync -@c snarfed from filesys.c:1315 @deffn primitive fsync object Copies any unwritten data for the specified output file descriptor to disk. If @var{port/fd} is a port, its buffer is flushed before the underlying @@ -5973,21 +5366,18 @@ The return value is unspecified. @end deffn symlink -@c snarfed from filesys.c:1342 @deffn primitive symlink oldpath newpath Create a symbolic link named @var{path-to} with the value (i.e., pointing to) @var{path-from}. The return value is unspecified. @end deffn readlink -@c snarfed from filesys.c:1361 @deffn primitive readlink path Return the value of the symbolic link named by @var{path} (a string), i.e., the file that the link points to. @end deffn lstat -@c snarfed from filesys.c:1390 @deffn primitive lstat str Similar to @code{stat}, but does not follow symbolic links, i.e., it will return information about a symbolic link itself, not the @@ -5995,14 +5385,12 @@ file it points to. @var{path} must be a string. @end deffn copy-file -@c snarfed from filesys.c:1414 @deffn primitive copy-file oldfile newfile Copy the file specified by @var{path-from} to @var{path-to}. The return value is unspecified. @end deffn dirname -@c snarfed from filesys.c:1459 @deffn primitive dirname filename Return the directory name component of the file name @var{filename}. If @var{filename} does not contain a directory @@ -6010,7 +5398,6 @@ component, @code{.} is returned. @end deffn basename -@c snarfed from filesys.c:1502 @deffn primitive basename filename [suffix] Return the base name of the file name @var{filename}. The base name is the file name without any directory components. @@ -6019,7 +5406,6 @@ If @var{suffix} is privided, and is equal to the end of @end deffn pipe -@c snarfed from posix.c:200 @deffn primitive pipe Return a newly created pipe: a pair of ports which are linked together on the local machine. The @emph{car} is the input @@ -6037,14 +5423,12 @@ from the input port. @end deffn getgroups -@c snarfed from posix.c:221 @deffn primitive getgroups Return a vector of integers representing the current supplimentary group IDs. @end deffn getpw -@c snarfed from posix.c:254 @deffn primitive getpw [user] Look up an entry in the user database. @var{obj} can be an integer, a string, or omitted, giving the behaviour of getpwuid, getpwnam @@ -6052,7 +5436,6 @@ or getpwent respectively. @end deffn setpw -@c snarfed from posix.c:307 @deffn primitive setpw [arg] If called with a true argument, initialize or reset the password data stream. Otherwise, close the stream. The @code{setpwent} and @@ -6060,7 +5443,6 @@ stream. Otherwise, close the stream. The @code{setpwent} and @end deffn getgr -@c snarfed from posix.c:326 @deffn primitive getgr [name] Look up an entry in the group database. @var{obj} can be an integer, a string, or omitted, giving the behaviour of getgrgid, getgrnam @@ -6068,7 +5450,6 @@ or getgrent respectively. @end deffn setgr -@c snarfed from posix.c:366 @deffn primitive setgr [arg] If called with a true argument, initialize or reset the group data stream. Otherwise, close the stream. The @code{setgrent} and @@ -6076,7 +5457,6 @@ stream. Otherwise, close the stream. The @code{setgrent} and @end deffn kill -@c snarfed from posix.c:402 @deffn primitive kill pid sig Sends a signal to the specified process or group of processes. @@ -6108,7 +5488,6 @@ Interrupt signal. @end deffn waitpid -@c snarfed from posix.c:455 @deffn primitive waitpid pid [options] This procedure collects status information from a child process which has terminated or (optionally) stopped. Normally it will @@ -6154,7 +5533,6 @@ The integer status value. @end deffn status:exit-val -@c snarfed from posix.c:483 @deffn primitive status:exit-val status Return the exit status value, as would be set if a process ended normally through a call to @code{exit} or @code{_exit}, @@ -6162,40 +5540,34 @@ if any, otherwise @code{#f}. @end deffn status:term-sig -@c snarfed from posix.c:503 @deffn primitive status:term-sig status Return the signal number which terminated the process, if any, otherwise @code{#f}. @end deffn status:stop-sig -@c snarfed from posix.c:521 @deffn primitive status:stop-sig status Return the signal number which stopped the process, if any, otherwise @code{#f}. @end deffn getppid -@c snarfed from posix.c:541 @deffn primitive getppid Return an integer representing the process ID of the parent process. @end deffn getuid -@c snarfed from posix.c:553 @deffn primitive getuid Return an integer representing the current real user ID. @end deffn getgid -@c snarfed from posix.c:564 @deffn primitive getgid Return an integer representing the current real group ID. @end deffn geteuid -@c snarfed from posix.c:578 @deffn primitive geteuid Return an integer representing the current effective user ID. If the system does not support effective IDs, then the real ID @@ -6204,7 +5576,6 @@ system supports effective IDs. @end deffn getegid -@c snarfed from posix.c:595 @deffn primitive getegid Return an integer representing the current effective group ID. If the system does not support effective IDs, then the real ID @@ -6213,7 +5584,6 @@ system supports effective IDs. @end deffn setuid -@c snarfed from posix.c:611 @deffn primitive setuid id Sets both the real and effective user IDs to the integer @var{id}, provided the process has appropriate privileges. @@ -6221,7 +5591,6 @@ The return value is unspecified. @end deffn setgid -@c snarfed from posix.c:625 @deffn primitive setgid id Sets both the real and effective group IDs to the integer @var{id}, provided the process has appropriate privileges. @@ -6229,7 +5598,6 @@ The return value is unspecified. @end deffn seteuid -@c snarfed from posix.c:641 @deffn primitive seteuid id Sets the effective user ID to the integer @var{id}, provided the process has appropriate privileges. If effective IDs are not supported, the @@ -6239,7 +5607,6 @@ The return value is unspecified. @end deffn setegid -@c snarfed from posix.c:667 @deffn primitive setegid id Sets the effective group ID to the integer @var{id}, provided the process has appropriate privileges. If effective IDs are not supported, the @@ -6249,14 +5616,12 @@ The return value is unspecified. @end deffn getpgrp -@c snarfed from posix.c:691 @deffn primitive getpgrp Return an integer representing the current process group ID. This is the POSIX definition, not BSD. @end deffn setpgid -@c snarfed from posix.c:709 @deffn primitive setpgid pid pgid Move the process @var{pid} into the process group @var{pgid}. @var{pid} or @var{pgid} must be integers: they can be zero to indicate the ID of the @@ -6266,7 +5631,6 @@ The return value is unspecified. @end deffn setsid -@c snarfed from posix.c:728 @deffn primitive setsid Creates a new session. The current process becomes the session leader and is put in a new process group. The process will be detached @@ -6275,21 +5639,18 @@ The return value is an integer representing the new process group ID. @end deffn ttyname -@c snarfed from posix.c:743 @deffn primitive ttyname port Return a string with the name of the serial terminal device underlying @var{port}. @end deffn ctermid -@c snarfed from posix.c:767 @deffn primitive ctermid Return a string containing the file name of the controlling terminal for the current process. @end deffn tcgetpgrp -@c snarfed from posix.c:790 @deffn primitive tcgetpgrp port Return the process group ID of the foreground process group associated with the terminal open on the file descriptor @@ -6304,7 +5665,6 @@ foreground. @end deffn tcsetpgrp -@c snarfed from posix.c:814 @deffn primitive tcsetpgrp port pgid Set the foreground process group ID for the terminal used by the file descriptor underlying @var{port} to the integer @var{pgid}. @@ -6314,7 +5674,6 @@ controlling terminal. The return value is unspecified. @end deffn execl -@c snarfed from posix.c:874 @deffn primitive execl filename . args Executes the file named by @var{path} as a new process image. The remaining arguments are supplied to the process; from a C program @@ -6330,7 +5689,6 @@ call, but we call it @code{execl} because of its Scheme calling interface. @end deffn execlp -@c snarfed from posix.c:894 @deffn primitive execlp filename . args Similar to @code{execl}, however if @var{filename} does not contain a slash @@ -6342,7 +5700,6 @@ call, but we call it @code{execlp} because of its Scheme calling interface. @end deffn execle -@c snarfed from posix.c:944 @deffn primitive execle filename env . args Similar to @code{execl}, but the environment of the new process is specified by @var{env}, which must be a list of strings as returned by the @@ -6353,7 +5710,6 @@ call, but we call it @code{execle} because of its Scheme calling interface. @end deffn primitive-fork -@c snarfed from posix.c:968 @deffn primitive primitive-fork Creates a new "child" process by duplicating the current "parent" process. In the child the return value is 0. In the parent the return value is @@ -6364,14 +5720,12 @@ with the scsh fork. @end deffn uname -@c snarfed from posix.c:988 @deffn primitive uname Return an object with some information about the computer system the program is running on. @end deffn environ -@c snarfed from posix.c:1018 @deffn primitive environ [env] If @var{env} is omitted, return the current environment (in the Unix sense) as a list of strings. Otherwise set the current @@ -6383,7 +5737,6 @@ then the return value is unspecified. @end deffn tmpnam -@c snarfed from posix.c:1056 @deffn primitive tmpnam Return a name in the file system that does not match any existing file. However there is no guarantee that another @@ -6393,7 +5746,6 @@ Care should be taken if opening the file, e.g., use the @end deffn mkstemp! -@c snarfed from posix.c:1082 @deffn primitive mkstemp! tmpl Create a new unique file in the file system and returns a new buffered port open for reading and writing to the file. @@ -6403,7 +5755,6 @@ place to return the name of the temporary file. @end deffn utime -@c snarfed from posix.c:1107 @deffn primitive utime pathname [actime [modtime]] @code{utime} sets the access and modification times for the file named by @var{path}. If @var{actime} or @var{modtime} is @@ -6418,7 +5769,6 @@ modification time to the current time. @end deffn access? -@c snarfed from posix.c:1155 @deffn primitive access? path how Return @code{#t} if @var{path} corresponds to an existing file and the current process has the type of access specified by @@ -6446,13 +5796,11 @@ test for existence of the file. @end deffn getpid -@c snarfed from posix.c:1169 @deffn primitive getpid Return an integer representing the current process ID. @end deffn putenv -@c snarfed from posix.c:1186 @deffn primitive putenv str Modifies the environment of the current process, which is also the default environment inherited by child processes. @@ -6468,7 +5816,6 @@ The return value is unspecified. @end deffn setlocale -@c snarfed from posix.c:1217 @deffn primitive setlocale category [locale] If @var{locale} is omitted, return the current value of the specified locale category as a system-dependent string. @@ -6482,7 +5829,6 @@ the locale will be set using envirionment variables. @end deffn mknod -@c snarfed from posix.c:1257 @deffn primitive mknod path type perms dev Creates a new special file, such as a file corresponding to a device. @var{path} specifies the name of the file. @var{type} should @@ -6502,7 +5848,6 @@ The return value is unspecified. @end deffn nice -@c snarfed from posix.c:1303 @deffn primitive nice incr Increment the priority of the current process by @var{incr}. A higher priority value means that the process runs less often. @@ -6510,21 +5855,18 @@ The return value is unspecified. @end deffn sync -@c snarfed from posix.c:1318 @deffn primitive sync Flush the operating system disk buffers. The return value is unspecified. @end deffn crypt -@c snarfed from posix.c:1331 @deffn primitive crypt key salt Encrypt @var{key} using @var{salt} as the salt value to the crypt(3) library call. @end deffn chroot -@c snarfed from posix.c:1352 @deffn primitive chroot path Change the root directory to that specified in @var{path}. This directory will be used for path names beginning with @@ -6534,7 +5876,6 @@ root directory. @end deffn getlogin -@c snarfed from posix.c:1384 @deffn primitive getlogin Return a string containing the name of the user logged in on the controlling terminal of the process, or @code{#f} if this @@ -6542,7 +5883,6 @@ information cannot be obtained. @end deffn cuserid -@c snarfed from posix.c:1402 @deffn primitive cuserid Return a string containing a user name associated with the effective user id of the process. Return @code{#f} if this @@ -6550,7 +5890,6 @@ information cannot be obtained. @end deffn getpriority -@c snarfed from posix.c:1427 @deffn primitive getpriority which who Return the scheduling priority of the process, process group or user, as indicated by @var{which} and @var{who}. @var{which} @@ -6565,7 +5904,6 @@ specified processes. @end deffn setpriority -@c snarfed from posix.c:1461 @deffn primitive setpriority which who prio Set the scheduling priority of the process, process group or user, as indicated by @var{which} and @var{who}. @var{which} @@ -6583,7 +5921,6 @@ The return value is not specified. @end deffn getpass -@c snarfed from posix.c:1486 @deffn primitive getpass prompt Display @var{prompt} to the standard error output and read a password from @file{/dev/tty}. If this file is not @@ -6595,7 +5932,6 @@ characters is disabled. @end deffn flock -@c snarfed from posix.c:1590 @deffn primitive flock file operation Apply or remove an advisory lock on an open file. @var{operation} specifies the action to be done: @@ -6617,7 +5953,6 @@ file descriptor or an open file descriptior port. @end deffn sethostname -@c snarfed from posix.c:1616 @deffn primitive sethostname name Set the host name of the current processor to @var{name}. May only be used by the superuser. The return value is not @@ -6625,13 +5960,11 @@ specified. @end deffn gethostname -@c snarfed from posix.c:1631 @deffn primitive gethostname Return the host name of the current processor. @end deffn gethost -@c snarfed from net_db.c:149 @deffn primitive gethost [host] @deffnx procedure gethostbyname hostname @deffnx procedure gethostbyaddr address @@ -6647,7 +5980,6 @@ Unusual conditions may result in errors thrown to the @end deffn getnet -@c snarfed from net_db.c:228 @deffn primitive getnet [net] @deffnx procedure getnetbyname net-name @deffnx procedure getnetbyaddr net-number @@ -6659,7 +5991,6 @@ given. @end deffn getproto -@c snarfed from net_db.c:277 @deffn primitive getproto [protocol] @deffnx procedure getprotobyname name @deffnx procedure getprotobynumber number @@ -6670,7 +6001,6 @@ argument. @code{getproto} will accept either type, behaving like @end deffn getserv -@c snarfed from net_db.c:343 @deffn primitive getserv [name [protocol]] @deffnx procedure getservbyname name protocol @deffnx procedure getservbyport port protocol @@ -6685,35 +6015,30 @@ as its first argument; if given no arguments, it behaves like @end deffn sethost -@c snarfed from net_db.c:380 @deffn primitive sethost [stayopen] If @var{stayopen} is omitted, this is equivalent to @code{endhostent}. Otherwise it is equivalent to @code{sethostent stayopen}. @end deffn setnet -@c snarfed from net_db.c:396 @deffn primitive setnet [stayopen] If @var{stayopen} is omitted, this is equivalent to @code{endnetent}. Otherwise it is equivalent to @code{setnetent stayopen}. @end deffn setproto -@c snarfed from net_db.c:412 @deffn primitive setproto [stayopen] If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}. Otherwise it is equivalent to @code{setprotoent stayopen}. @end deffn setserv -@c snarfed from net_db.c:428 @deffn primitive setserv [stayopen] If @var{stayopen} is omitted, this is equivalent to @code{endservent}. Otherwise it is equivalent to @code{setservent stayopen}. @end deffn htons -@c snarfed from socket.c:105 @deffn primitive htons value Convert a 16 bit quantity from host to network byte ordering. @var{value} is packed into 2 bytes, which are then converted @@ -6721,7 +6046,6 @@ and returned as a new integer. @end deffn ntohs -@c snarfed from socket.c:122 @deffn primitive ntohs value Convert a 16 bit quantity from network to host byte ordering. @var{value} is packed into 2 bytes, which are then converted @@ -6729,7 +6053,6 @@ and returned as a new integer. @end deffn htonl -@c snarfed from socket.c:139 @deffn primitive htonl value Convert a 32 bit quantity from host to network byte ordering. @var{value} is packed into 4 bytes, which are then converted @@ -6737,7 +6060,6 @@ and returned as a new integer. @end deffn ntohl -@c snarfed from socket.c:152 @deffn primitive ntohl value Convert a 32 bit quantity from network to host byte ordering. @var{value} is packed into 4 bytes, which are then converted @@ -6745,7 +6067,6 @@ and returned as a new integer. @end deffn inet-aton -@c snarfed from socket.c:172 @deffn primitive inet-aton address Convert an IPv4 Internet address from printable string (dotted decimal notation) to an integer. E.g., @@ -6756,7 +6077,6 @@ Convert an IPv4 Internet address from printable string @end deffn inet-ntoa -@c snarfed from socket.c:191 @deffn primitive inet-ntoa inetid Convert an IPv4 Internet address to a printable (dotted decimal notation) string. E.g., @@ -6767,7 +6087,6 @@ Convert an IPv4 Internet address to a printable @end deffn inet-netof -@c snarfed from socket.c:211 @deffn primitive inet-netof address Return the network number part of the given IPv4 Internet address. E.g., @@ -6778,7 +6097,6 @@ Internet address. E.g., @end deffn inet-lnaof -@c snarfed from socket.c:229 @deffn primitive inet-lnaof address Return the local-address-with-network part of the given IPv4 Internet address, using the obsolete class A/B/C system. @@ -6790,7 +6108,6 @@ E.g., @end deffn inet-makeaddr -@c snarfed from socket.c:247 @deffn primitive inet-makeaddr net lna Make an IPv4 Internet address by combining the network number @var{net} with the local-address-within-network number @@ -6802,7 +6119,6 @@ Make an IPv4 Internet address by combining the network number @end deffn inet-pton -@c snarfed from socket.c:365 @deffn primitive inet-pton family address Convert a string containing a printable network address to an integer address. Note that unlike the C version of this @@ -6817,7 +6133,6 @@ the result is an integer with normal host byte ordering. @end deffn inet-ntop -@c snarfed from socket.c:400 @deffn primitive inet-ntop family address Convert a network address into a printable string. Note that unlike the C version of this function, @@ -6832,7 +6147,6 @@ ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff @end deffn socket -@c snarfed from socket.c:445 @deffn primitive socket family style proto Return a new socket port of the type specified by @var{family}, @var{style} and @var{proto}. All three parameters are @@ -6850,7 +6164,6 @@ has been connected to another socket. @end deffn socketpair -@c snarfed from socket.c:467 @deffn primitive socketpair family style proto Return a pair of connected (but unnamed) socket ports of the type specified by @var{family}, @var{style} and @var{proto}. @@ -6860,7 +6173,6 @@ family. Zero is likely to be the only meaningful value for @end deffn getsockopt -@c snarfed from socket.c:496 @deffn primitive getsockopt sock level optname Return the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of @@ -6874,7 +6186,6 @@ returns a pair of integers. @end deffn setsockopt -@c snarfed from socket.c:564 @deffn primitive setsockopt sock level optname value Set the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of option @@ -6890,7 +6201,6 @@ The return value is unspecified. @end deffn shutdown -@c snarfed from socket.c:668 @deffn primitive shutdown sock how Sockets can be closed simply by using @code{close-port}. The @code{shutdown} procedure allows reception or tranmission on a @@ -6912,7 +6222,6 @@ The return value is unspecified. @end deffn connect -@c snarfed from socket.c:812 @deffn primitive connect sock fam address . args Initiate a connection from a socket using a specified address family to the address @@ -6938,7 +6247,6 @@ The return value is unspecified. @end deffn bind -@c snarfed from socket.c:872 @deffn primitive bind sock fam address . args Assign an address to the socket port @var{sock}. Generally this only needs to be done for server sockets, @@ -6986,7 +6294,6 @@ The return value is unspecified. @end deffn listen -@c snarfed from socket.c:906 @deffn primitive listen sock backlog Enable @var{sock} to accept connection requests. @var{backlog} is an integer specifying @@ -6999,7 +6306,6 @@ The return value is unspecified. @end deffn accept -@c snarfed from socket.c:1011 @deffn primitive accept sock Accept a connection on a bound, listening socket. If there @@ -7018,7 +6324,6 @@ connection and will continue to accept new requests. @end deffn getsockname -@c snarfed from socket.c:1038 @deffn primitive getsockname sock Return the address of @var{sock}, in the same form as the object returned by @code{accept}. On many systems the address @@ -7026,7 +6331,6 @@ of a socket in the @code{AF_FILE} namespace cannot be read. @end deffn getpeername -@c snarfed from socket.c:1060 @deffn primitive getpeername sock Return the address that @var{sock} is connected to, in the same form as the object returned by @@ -7035,7 +6339,6 @@ is connected to, in the same form as the object returned by @end deffn recv! -@c snarfed from socket.c:1095 @deffn primitive recv! sock buf [flags] Receive data from a socket port. @var{sock} must already @@ -7060,7 +6363,6 @@ any unread buffered port data is ignored. @end deffn send -@c snarfed from socket.c:1128 @deffn primitive send sock message [flags] Transmit the string @var{message} on a socket port @var{sock}. @var{sock} must already be bound to a destination address. The @@ -7078,7 +6380,6 @@ any unflushed buffered port data is ignored. @end deffn recvfrom! -@c snarfed from socket.c:1168 @deffn primitive recvfrom! sock str [flags [start [end]]] Return data from the socket port @var{sock} and also information about where the data was received from. @@ -7106,7 +6407,6 @@ descriptor: any unread buffered port data is ignored. @end deffn sendto -@c snarfed from socket.c:1226 @deffn primitive sendto sock message fam address . args_and_flags Transmit the string @var{message} on the socket port @var{sock}. The diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 04c1c012f..686de2d83 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,11 @@ +2001-11-13 Neil Jerram + + * new-docstrings.texi, scheme-data.texi: Merge recent doc + improvements from stable branch. + + * scheme-options.texi: Automatic updates from docstring changes in + libguile's C source code. + 2001-11-12 Neil Jerram * scheme-data.texi (Vtables, Structure Basics): Automatic doc diff --git a/doc/ref/new-docstrings.texi b/doc/ref/new-docstrings.texi index e795fd3ef..02a1a4aad 100644 --- a/doc/ref/new-docstrings.texi +++ b/doc/ref/new-docstrings.texi @@ -506,7 +506,7 @@ Internal GOOPS magic---don't use this function! @end deffn @deffn primitive list* -scm_cons_star +implemented by the C function "scm_cons_star" @end deffn @deffn primitive set-current-module module @@ -564,7 +564,7 @@ Return the module of @var{ENV}, a lexical environment. @end deffn @deffn primitive load-extension lib init -Load and initilize the extension designated by LIB and INIT. +Load and initialize the extension designated by LIB and INIT. When there is no pre-registered function for LIB/INIT, this is equivalent to diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 8b27b2366..1583f413f 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -1471,15 +1471,15 @@ between separator characters will result in an empty string in the result list. @lisp -(string-split "root:x:0:0:root:/root:/bin/bash" #:) +(string-split "root:x:0:0:root:/root:/bin/bash" #\:) @result{} ("root" "x" "0" "0" "root" "/root" "/bin/bash") -(string-split "::" #:) +(string-split "::" #\:) @result{} ("" "" "") -(string-split "" #:) +(string-split "" #\:) @result{} ("") @end lisp @@ -2330,7 +2330,7 @@ association lists (@pxref{Association Lists}) or hash tables lot, and does not cause any performance loss. The read syntax for symbols is a sequence of letters, digits, and -@emph{extended alphabetic characters} that begins with a character that +@dfn{extended alphabetic characters} that begins with a character that cannot begin a number is an identifier. In addition, @code{+}, @code{-}, and @code{...} are identifiers. @@ -2826,7 +2826,7 @@ This is the inverse of @code{make-keyword-from-dash-symbol}. Pairs are used to combine two Scheme objects into one compound object. Hence the name: A pair stores a pair of objects. -The data type @emph{pair} is extremely important in Scheme, just like in +The data type @dfn{pair} is extremely important in Scheme, just like in any other Lisp dialect. The reason is that pairs are not only used to make two values available as one object, but that pairs are used for constructing lists of values. Because lists are so important in Scheme, @@ -2863,7 +2863,7 @@ examples is as follows. A new pair is made by calling the procedure @code{cons} with two arguments. Then the argument values are stored into a newly allocated pair, and the pair is returned. The name @code{cons} stands for -@emph{construct}. Use the procedure @code{pair?} to test whether a +"construct". Use the procedure @code{pair?} to test whether a given Scheme object is a pair or not. @rnindex cons @@ -2879,8 +2879,8 @@ Return @code{#t} if @var{x} is a pair; otherwise return @code{#f}. @end deffn -The two parts of a pair are traditionally called @emph{car} and -@emph{cdr}. They can be retrieved with procedures of the same name +The two parts of a pair are traditionally called @dfn{car} and +@dfn{cdr}. They can be retrieved with procedures of the same name (@code{car} and @code{cdr}), and can be modified with the procedures @code{set-car!} and @code{set-cdr!}. Since a very common operation in Scheme programs is to access the car of a pair, or the car of the cdr of @@ -2927,8 +2927,8 @@ by @code{set-cdr!} is unspecified. A very important data type in Scheme---as well as in all other Lisp dialects---is the data type @dfn{list}.@footnote{Strictly speaking, -Scheme does not have a real datatype @emph{list}. Lists are made up of -chained @emph{pairs}, and only exist by definition---a list is a chain +Scheme does not have a real datatype @dfn{list}. Lists are made up of +@dfn{chained pairs}, and only exist by definition---a list is a chain of pairs which looks like a list.} This is the short definition of what a list is: @@ -2955,7 +2955,7 @@ or a pair which has a list in its cdr. * List Constructors:: Creating new lists. * List Selection:: Selecting from lists, getting their length. * Append/Reverse:: Appending and reversing lists. -* List Modifification:: Modifying list structure. +* List Modification:: Modifying existing lists. * List Searching:: Searching for list elements * List Mapping:: Applying procedures to lists. @end menu @@ -3013,7 +3013,7 @@ Return @code{#t} iff @var{x} is a proper list, else @code{#f}. The predicate @code{null?} is often used in list-processing code to tell whether a given list has run out of elements. That is, a loop somehow deals with the elements of a list until the list satisfies -@code{null?}. Then, teh algorithm terminates. +@code{null?}. Then, the algorithm terminates. @rnindex null? @deffn primitive null? x @@ -3161,14 +3161,11 @@ of the modified list is not lost, it is wise to save the return value of @code{reverse!} @end deffn -@node List Modifification +@node List Modification @subsection List Modification -@c FIXME::martin: Review me! - -The following procedures modify existing list. @code{list-set!} and -@code{list-cdr-set!} change which elements a list contains, the various -deletion procedures @code{delq}, @code{delv} etc. +The following procedures modify an existing list, either by changing +elements of the list, or by changing the list structure itself. @deffn primitive list-set! list k val Set the @var{k}th element of @var{list} to @var{val}. @@ -3235,7 +3232,7 @@ Like @code{delete!}, but only deletes the first occurrence of The following procedures search lists for particular elements. They use different comparison predicates for comparing list elements with the -object to be seached. When they fail, they return @code{#f}, otherwise +object to be searched. When they fail, they return @code{#f}, otherwise they return the sublist whose car is equal to the search object, where equality depends on the equality predicate used. @@ -3269,7 +3266,7 @@ the non-empty lists returned by @code{(list-tail @var{lst} empty list) is returned. @end deffn -[FIXME: is there any reason to have the `sloppy' functions available at +[FIXME: Is there any reason to have the `sloppy' functions available at high level at all? Maybe these docs should be relegated to a "Guile Internals" node or something. -twp] @@ -3300,8 +3297,8 @@ List processing is very convenient in Scheme because the process of iterating over the elements of a list can be highly abstracted. The procedures in this section are the most basic iterating procedures for lists. They take a procedure and one or more lists as arguments, and -apply the procedure to each element of the list. They differ in what -the result of the invocation is. +apply the procedure to each element of the list. They differ in their +return value. @rnindex map @c begin (texi-doc-string "guile" "map") @@ -3336,13 +3333,15 @@ return value is not specified. Vectors are sequences of Scheme objects. Unlike lists, the length of a vector, once the vector is created, cannot be changed. The advantage of -vectors over lists is that the time required to access one element of a -vector is constant, whereas lists have an access time linear to the -index of the accessed element in the list. +vectors over lists is that the time required to access one element of a vector +given its @dfn{position} (synonymous with @dfn{index}), a zero-origin number, +is constant, whereas lists have an access time linear to the position of the +accessed element in the list. -Note that the vectors documented in this section can contain any kind of -Scheme object, it is even possible to have different types of objects in -the same vector. +Vectors can contain any kind of Scheme object; it is even possible to have +different types of objects in the same vector. For vectors containing +vectors, you may wish to use arrays, instead. Note, too, that some array +procedures operate happily on vectors (@pxref{Arrays}). @subsection Vector Read Syntax @@ -3353,7 +3352,7 @@ parentheses, all elements of the vector in their respective read syntax, and finally a closing parentheses. The following are examples of the read syntax for vectors; where the first vector only contains numbers and the second three different object types: a string, a symbol and a -number in hexidecimal notation. +number in hexadecimal notation. @lisp #(1 2 3) @@ -3373,8 +3372,8 @@ Return @code{#t} if @var{obj} is a vector, otherwise return @rnindex make-vector @deffn primitive make-vector k [fill] Return a newly allocated vector of @var{k} elements. If a -second argument is given, then each element is initialized to -@var{fill}. Otherwise the initial contents of each element is +second argument is given, then each position is initialized to +@var{fill}. Otherwise the initial contents of each position are unspecified. @end deffn @@ -3382,8 +3381,8 @@ unspecified. @rnindex list->vector @deffn primitive vector . l @deffnx primitive list->vector l -Return a newly allocated vector whose elements contain the -given arguments. Analogous to @code{list}. +Return a newly allocated vector composed of the given arguments. +Analogous to @code{list}. @lisp (vector 'a 'b 'c) @result{} #(a b c) @@ -3392,8 +3391,7 @@ given arguments. Analogous to @code{list}. @rnindex vector->list @deffn primitive vector->list v -Return a newly allocated list of the objects contained in the -elements of @var{vector}. +Return a newly allocated list composed of the elements of @var{v}. @lisp (vector->list '#(dah dah didah)) @result{} (dah dah didah) @@ -3407,35 +3405,37 @@ A vector created by any of the vector constructor procedures (@pxref{Vectors}) documented above can be modified using the following procedures. -According to R5RS, using any of these procedures on literally entered -vectors is an error, because these vectors are considered to be -constant, although Guile currently does not detect this error. +@emph{NOTE:} According to R5RS, using any of these procedures on +literally entered vectors is an error, because these vectors are +considered to be constant, although Guile currently does not detect this +error. @rnindex vector-set! @deffn primitive vector-set! vector k obj +Store @var{obj} in position @var{k} of @var{vector}. @var{k} must be a valid index of @var{vector}. -@code{Vector-set!} stores @var{obj} in element @var{k} of @var{vector}. The value returned by @samp{vector-set!} is unspecified. @lisp (let ((vec (vector 0 '(2 2 2 2) "Anna"))) (vector-set! vec 1 '("Sue" "Sue")) vec) @result{} #(0 ("Sue" "Sue") "Anna") -(vector-set! '#(0 1 2) 1 "doe") @result{} @emph{error} ; constant vector @end lisp @end deffn @rnindex vector-fill! @deffn primitive vector-fill! v fill -Store @var{fill} in every element of @var{vector}. The value +Store @var{fill} in every position of @var{vector}. The value returned by @code{vector-fill!} is unspecified. @end deffn @deffn primitive vector-move-left! vec1 start1 end1 vec2 start2 -Vector version of @code{substring-move-left!}. +Vector version of @code{substring-move-left!} (@pxref{String +Modification}). @end deffn @deffn primitive vector-move-right! vec1 start1 end1 vec2 start2 -Vector version of @code{substring-move-right!}. +Vector version of @code{substring-move-right!} (@pxref{String +Modification}). @end deffn @subsection Vector Selection @@ -3445,14 +3445,13 @@ size or what elements are contained in the vector. @rnindex vector-length @deffn primitive vector-length vector -Returns the number of elements in @var{vector} as an exact integer. +Return the number of elements in @var{vector} as an exact integer. @end deffn @rnindex vector-ref @deffn primitive vector-ref vector k +Return the contents of position @var{k} of @var{vector}. @var{k} must be a valid index of @var{vector}. -@samp{Vector-ref} returns the contents of element @var{k} of -@var{vector}. @lisp (vector-ref '#(1 1 2 3 5 8 13 21) 5) @result{} 8 (vector-ref '#(1 1 2 3 5 8 13 21) @@ -3467,14 +3466,11 @@ Returns the number of elements in @var{vector} as an exact integer. @node Records @section Records -[FIXME: this is pasted in from Tom Lord's original guile.texi and should -be reviewed] - A @dfn{record type} is a first class object representing a user-defined data type. A @dfn{record} is an instance of a record type. @deffn procedure record? obj -Returns @code{#t} if @var{obj} is a record of any type and @code{#f} +Return @code{#t} if @var{obj} is a record of any type and @code{#f} otherwise. Note that @code{record?} may be true of any Scheme value; there is no @@ -3482,17 +3478,17 @@ promise that records are disjoint with other Scheme types. @end deffn @deffn procedure make-record-type type-name field-names -Returns a @dfn{record-type descriptor}, a value representing a new data +Return a @dfn{record-type descriptor}, a value representing a new data type disjoint from all others. The @var{type-name} argument must be a string, but is only used for debugging purposes (such as the printed representation of a record of the new type). The @var{field-names} argument is a list of symbols naming the @dfn{fields} of a record of the new type. It is an error if the list contains any duplicates. It is -unspecified how record-type descriptors are represented.@refill +unspecified how record-type descriptors are represented. @end deffn @deffn procedure record-constructor rtd [field-names] -Returns a procedure for constructing new members of the type represented +Return a procedure for constructing new members of the type represented by @var{rtd}. The returned procedure accepts exactly as many arguments as there are symbols in the given list, @var{field-names}; these are used, in order, as the initial values of those fields in a new record, @@ -3501,28 +3497,28 @@ fields not named in that list are unspecified. The @var{field-names} argument defaults to the list of field names in the call to @code{make-record-type} that created the type represented by @var{rtd}; if the @var{field-names} argument is provided, it is an error if it -contains any duplicates or any symbols not in the default list.@refill +contains any duplicates or any symbols not in the default list. @end deffn @deffn procedure record-predicate rtd -Returns a procedure for testing membership in the type represented by +Return a procedure for testing membership in the type represented by @var{rtd}. The returned procedure accepts exactly one argument and returns a true value if the argument is a member of the indicated record -type; it returns a false value otherwise.@refill +type; it returns a false value otherwise. @end deffn @deffn procedure record-accessor rtd field-name -Returns a procedure for reading the value of a particular field of a +Return a procedure for reading the value of a particular field of a member of the type represented by @var{rtd}. The returned procedure accepts exactly one argument which must be a record of the appropriate type; it returns the current value of the field named by the symbol @var{field-name} in that record. The symbol @var{field-name} must be a member of the list of field-names in the call to @code{make-record-type} -that created the type represented by @var{rtd}.@refill +that created the type represented by @var{rtd}. @end deffn @deffn procedure record-modifier rtd field-name -Returns a procedure for writing the value of a particular field of a +Return a procedure for writing the value of a particular field of a member of the type represented by @var{rtd}. The returned procedure accepts exactly two arguments: first, a record of the appropriate type, and second, an arbitrary Scheme value; it modifies the field named by @@ -3530,31 +3526,31 @@ the symbol @var{field-name} in that record to contain the given value. The returned value of the modifier procedure is unspecified. The symbol @var{field-name} must be a member of the list of field-names in the call to @code{make-record-type} that created the type represented by -@var{rtd}.@refill +@var{rtd}. @end deffn @deffn procedure record-type-descriptor record -Returns a record-type descriptor representing the type of the given +Return a record-type descriptor representing the type of the given record. That is, for example, if the returned descriptor were passed to @code{record-predicate}, the resulting predicate would return a true value when passed the given record. Note that it is not necessarily the case that the returned descriptor is the one that was passed to @code{record-constructor} in the call that created the constructor -procedure that created the given record.@refill +procedure that created the given record. @end deffn @deffn procedure record-type-name rtd -Returns the type-name associated with the type represented by rtd. The +Return the type-name associated with the type represented by rtd. The returned value is @code{eqv?} to the @var{type-name} argument given in the call to @code{make-record-type} that created the type represented by -@var{rtd}.@refill +@var{rtd}. @end deffn @deffn procedure record-type-fields rtd -Returns a list of the symbols naming the fields in members of the type +Return a list of the symbols naming the fields in members of the type represented by @var{rtd}. The returned value is @code{equal?} to the field-names argument given in the call to @code{make-record-type} that -created the type represented by @var{rtd}.@refill +created the type represented by @var{rtd}. @end deffn @@ -3678,7 +3674,7 @@ A pair object in which the first field is held constant could be: "prpw" @end example -Binary fields, (fields of type "u"), hold one @emph{word} each. The +Binary fields, (fields of type "u"), hold one @dfn{word} each. The size of a word is a machine dependent value defined to be equal to the value of the C expression: @code{sizeof (long)}. @@ -3892,7 +3888,7 @@ Return the vtable tag of the structure @var{handle}. @node Conventional Arrays @subsection Conventional Arrays -@dfn{Conventional arrays} are a collection of cells organised into an +@dfn{Conventional arrays} are a collection of cells organized into an arbitrary number of dimensions. Each cell can hold any kind of Scheme value and can be accessed in constant time by supplying an index for each dimension. This contrasts with uniform arrays, which use memory @@ -3901,7 +3897,7 @@ where inserting and deleting cells is more efficient, but more time is usually required to access a particular cell. A conventional array is displayed as @code{#} followed by the @dfn{rank} -(number of dimensions) followed by the cells, organised into dimensions +(number of dimensions) followed by the cells, organized into dimensions using parentheses. The nesting depth of the parentheses is equal to the rank. @@ -3939,8 +3935,13 @@ and is described elsewhere. @end deffn @deffn procedure make-array initial-value bound1 bound2 @dots{} -Creates and returns an array that has as many dimensions as there are -@var{bound}s and fills it with @var{initial-value}. +Create and return an array that has as many dimensions as there are +@var{bound}s and fill it with @var{initial-value}. Each @var{bound} +may be a positive non-zero integer @var{N}, in which case the index for +that dimension can range from 0 through @var{N-1}; or an explicit index +range specifier in the form @code{(LOWER UPPER)}, where both @var{lower} +and @var{upper} are integers, possibly less than zero, and possibly the +same number (however, @var{lower} cannot be greater than @var{upper}). @end deffn @c array-ref's type is `compiled-closure'. There's some weird stuff @@ -3957,9 +3958,10 @@ Return @code{#t} if its arguments would be acceptable to @code{array-ref}. @end deffn +@c fixme: why do these sigs differ? -ttn 2001/07/19 01:14:12 @deffn primitive array-set! v obj . args @deffnx primitive uniform-array-set1! v obj args -Sets the element at the @code{(index1, index2)} element in @var{array} to +Set the element at the @code{(index1, index2)} element in @var{array} to @var{new-value}. The value returned by array-set! is unspecified. @end deffn @@ -4040,7 +4042,7 @@ examples: @end deffn @deffn procedure array-shape array -Returns a list of inclusive bounds of integers. +Return a list of inclusive bounds of integers. @example (array-shape (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) (0 4)) @end example @@ -4066,20 +4068,20 @@ Return a list consisting of all the elements, in order, of @deffn primitive array-copy! src dst @deffnx primitive array-copy-in-order! src dst -Copies every element from vector or array @var{source} to the +Copy every element from vector or array @var{source} to the corresponding element of @var{destination}. @var{destination} must have the same rank as @var{source}, and be at least as large in each dimension. The order is unspecified. @end deffn @deffn primitive array-fill! ra fill -Stores @var{fill} in every element of @var{array}. The value returned +Store @var{fill} in every element of @var{array}. The value returned is unspecified. @end deffn @c begin (texi-doc-string "guile" "array-equal?") @deffn primitive array-equal? ra0 ra1 -Returns @code{#t} iff all arguments are arrays with the same shape, the +Return @code{#t} iff all arguments are arrays with the same shape, the same type, and have corresponding elements which are either @code{equal?} or @code{array-equal?}. This function differs from @code{equal?} in that a one dimensional shared array may be @@ -4114,12 +4116,12 @@ unspecified. The order of application is unspecified. @end deffn @deffn primitive array-for-each proc ra0 . lra -@var{proc} is applied to each tuple of elements of @var{array0} @dots{} +Apply @var{proc} to each tuple of elements of @var{array0} @dots{} in row-major order. The value returned is unspecified. @end deffn @deffn primitive array-index-map! ra proc -applies @var{proc} to the indices of each element of @var{array} in +Apply @var{proc} to the indices of each element of @var{array} in turn, storing the result in the corresponding element. The value returned and the order of application are unspecified. @@ -4197,16 +4199,16 @@ except that a single character from the above table is put between long integers is displayed in the form @code{'#e(3 5 9)}. @deffn primitive array? v [prot] -Returns @code{#t} if the @var{obj} is an array, and @code{#f} if not. +Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. The @var{prototype} argument is used with uniform arrays and is described elsewhere. @end deffn @deffn procedure make-uniform-array prototype bound1 bound2 @dots{} -Creates and returns a uniform array of type corresponding to +Create and return a uniform array of type corresponding to @var{prototype} that has as many dimensions as there are @var{bound}s -and fills it with @var{prototype}. +and fill it with @var{prototype}. @end deffn @deffn primitive array-prototype ra @@ -4224,7 +4226,7 @@ done. @end deffn @deffn primitive uniform-vector-fill! uve fill -Stores @var{fill} in every element of @var{uve}. The value returned is +Store @var{fill} in every element of @var{uve}. The value returned is unspecified. @end deffn @@ -4244,7 +4246,7 @@ fill the array, otherwise @var{prototype} is used. @deffn primitive uniform-array-read! ra [port_or_fd [start [end]]] @deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end] -Attempts to read all elements of @var{ura}, in lexicographic order, as +Attempt to read all elements of @var{ura}, in lexicographic order, as binary objects from @var{port-or-fdes}. If an end of file is encountered during uniform-array-read! the objects up to that point only are put into @var{ura} @@ -4306,7 +4308,7 @@ within the specified range @code{#f} is returned. @end deffn @deffn primitive bit-invert! v -Modifies @var{bv} by replacing each element with its negation. +Modify @var{bv} by replacing each element with its negation. @end deffn @deffn primitive bit-set*! v kv obj @@ -4551,7 +4553,7 @@ use @code{list-copy} to copy the old association list before modifying it. @deffn primitive acons key value alist -Adds a new key-value pair to @var{alist}. A new pair is +Add a new key-value pair to @var{alist}. A new pair is created whose car is @var{key} and whose cdr is @var{value}, and the pair is consed onto @var{alist}, and the new list is returned. This function is @emph{not} destructive; @var{alist} is not modified. @@ -4585,12 +4587,12 @@ is @code{(KEY . VALUE)}, not just the value. @deffn primitive assq key alist @deffnx primitive assv key alist @deffnx primitive assoc key alist -Fetches the entry in @var{alist} that is associated with @var{key}. To +Fetch the entry in @var{alist} that is associated with @var{key}. To decide whether the argument @var{key} matches a particular entry in @var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv} uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key} cannot be found in @var{alist} (according to whichever equality -predicate is in use), then @code{#f} is returned. These functions +predicate is in use), then return @code{#f}. These functions return the entire alist entry found (i.e. both the key and the value). @end deffn diff --git a/doc/ref/scheme-options.texi b/doc/ref/scheme-options.texi index d009a4d01..e4da66355 100644 --- a/doc/ref/scheme-options.texi +++ b/doc/ref/scheme-options.texi @@ -336,13 +336,13 @@ Guile's configuration at run time. @deffnx primitive minor-version @deffnx primitive micro-version Return a string describing Guile's version number, or its major, minor -and micro version numbers, respectively. +or micro version number, respectively. @lisp -(version) @result{} "1.6.5" +(version) @result{} "1.6.0" (major-version) @result{} "1" (minor-version) @result{} "6" -(micro-version) @result{} "5" +(micro-version) @result{} "0" @end lisp @end deffn diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 587c1eb50..4c4d21c7e 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,13 @@ +2001-11-13 Neil Jerram + + * random.c (scm_random_solid_sphere_x, + scm_random_hollow_sphere_x): Correct "shere" typos. + + * hashtab.c (scm_hash_fold): Add missing apostrophe to docstring. + + * version.c (scm_version): Update docstring to include + `micro-version'. + 2001-11-13 Marius Vollmer * modules.c (scm_c_export): Call va_end after collecting the diff --git a/libguile/extensions.c b/libguile/extensions.c index 48e39420c..5200eb440 100644 --- a/libguile/extensions.c +++ b/libguile/extensions.c @@ -117,7 +117,7 @@ scm_c_load_extension (const char *lib, const char *init) SCM_DEFINE (scm_load_extension, "load-extension", 2, 0, 0, (SCM lib, SCM init), - "Load and initilize the extension designated by LIB and INIT.\n" + "Load and initialize the extension designated by LIB and INIT.\n" "When there is no pre-registered function for LIB/INIT, this is\n" "equivalent to\n" "\n" diff --git a/libguile/hashtab.c b/libguile/hashtab.c index 4cf250fae..a6e2908a2 100644 --- a/libguile/hashtab.c +++ b/libguile/hashtab.c @@ -524,7 +524,7 @@ SCM_DEFINE (scm_hash_fold, "hash-fold", 3, 0, 0, "and value are successive pairs from the hash table TABLE, and\n" "prior-result is either INIT (for the first application of PROC)\n" "or the return value of the previous application of PROC.\n" - "For example, @code{(hash-fold acons () tab)} will convert a hash\n" + "For example, @code{(hash-fold acons '() tab)} will convert a hash\n" "table into an a-list of key-value pairs.") #define FUNC_NAME s_scm_hash_fold { diff --git a/libguile/random.c b/libguile/random.c index ba64d1ab2..2db583bb1 100644 --- a/libguile/random.c +++ b/libguile/random.c @@ -492,7 +492,7 @@ SCM_DEFINE (scm_random_solid_sphere_x, "random:solid-sphere!", 1, 1, 0, "the sum of whose squares is less than 1.0.\n" "Thinking of vect as coordinates in space of\n" "dimension n = (vector-length vect), the coordinates\n" - "are uniformly distributed within the unit n-shere.\n" + "are uniformly distributed within the unit n-sphere.\n" "The sum of the squares of the numbers is returned.") #define FUNC_NAME s_scm_random_solid_sphere_x { @@ -516,7 +516,7 @@ SCM_DEFINE (scm_random_hollow_sphere_x, "random:hollow-sphere!", 1, 1, 0, "Thinking of vect as coordinates in space of\n" "dimension n = (vector-length vect), the coordinates\n" "are uniformly distributed over the surface of the\n" - "unit n-shere.") + "unit n-sphere.") #define FUNC_NAME s_scm_random_hollow_sphere_x { SCM_VALIDATE_VECTOR_OR_DVECTOR (1,v); diff --git a/libguile/version.c b/libguile/version.c index 1bf1f6ff2..e1c40b65b 100644 --- a/libguile/version.c +++ b/libguile/version.c @@ -96,12 +96,14 @@ SCM_DEFINE (scm_version, "version", 0, 0, 0, (), "@deffnx primitive major-version\n" "@deffnx primitive minor-version\n" - "Return a string describing Guile's version number, or its major or minor\n" - "version numbers, respectively.\n\n" + "@deffnx primitive micro-version\n" + "Return a string describing Guile's version number, or its major, minor\n" + "or micro version number, respectively.\n\n" "@lisp\n" - "(version) @result{} \"1.3a\"\n" + "(version) @result{} \"1.6.0\"\n" "(major-version) @result{} \"1\"\n" - "(minor-version) @result{} \"3a\"\n" + "(minor-version) @result{} \"6\"\n" + "(micro-version) @result{} \"0\"\n" "@end lisp") #define FUNC_NAME s_scm_version { From 9c4dd6f420ddf1651b6960def38050f294e2e0dc Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 14 Nov 2001 18:24:44 +0000 Subject: [PATCH 156/281] Spell "library" correctly. --- doc/ref/scheme-procedures.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/scheme-procedures.texi b/doc/ref/scheme-procedures.texi index 194d2dd99..4a4830358 100644 --- a/doc/ref/scheme-procedures.texi +++ b/doc/ref/scheme-procedures.texi @@ -126,7 +126,7 @@ elements. @code{let-optional} binds all variables simultaneously, while @code{let-optional*} binds them sequentially, consistent with @code{let} and @code{let*} (@pxref{Local Bindings}). -@deffn {libary syntax} let-optional rest-arg (binding @dots{}) expr @dots{} +@deffn {library syntax} let-optional rest-arg (binding @dots{}) expr @dots{} @deffnx {library syntax} let-optional* rest-arg (binding @dots{}) expr @dots{} These two macros give you an optional argument interface that is very @dfn{Schemey} and introduces no fancy syntax. They are compatible with From ef3946430fd1ff0d44005029ec35b64892cfbbad Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 14 Nov 2001 18:25:48 +0000 Subject: [PATCH 157/281] *** empty log message *** --- doc/ref/ChangeLog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 686de2d83..3fa2b7d7f 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,7 @@ +2001-11-14 Thien-Thi Nguyen + + * scheme-procedures.texi: Spell "library" correctly. + 2001-11-13 Neil Jerram * new-docstrings.texi, scheme-data.texi: Merge recent doc @@ -53,7 +57,7 @@ * Makefile.am (guile_TEXINFOS): Removed appendices.texi, added debugging.texi. - + * appendices.texi: Removed. * debugging.texi (Debugger User Interface): New file, same as the From f056c4e39d7a56aa81159598abedf219bf0b6fd6 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 14 Nov 2001 20:47:40 +0000 Subject: [PATCH 158/281] Initial revision. --- devel/policy/api.text | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 devel/policy/api.text diff --git a/devel/policy/api.text b/devel/policy/api.text new file mode 100644 index 000000000..f59825091 --- /dev/null +++ b/devel/policy/api.text @@ -0,0 +1,76 @@ +* Intro / Index (last modified: $Date: 2001-11-14 20:47:40 $) + +This working document explains the design of the libguile API, +specifically the interface to the C programming language. +Note that this is NOT an API reference manual. + +- Motivation +- History +- Decisions + - gh_ removal + - malloc policy + - [add here] + + +* Motivation + +The file goals.text says: + + Guile's primary aim is to provide a good extension language + which is easy to add to an application written in C for the GNU + system. This means that it must export the features of a higher + level language in a way that makes it easy not to break them + from C code. + +Although it may no longer be a "primary aim", creating a stable API is +important anyway since without something defined, people will take libguile +and use it in ad-hoc ways that may cause them trouble later. + + +* History + +The initial (in ttn's memory, which only goes back to guile-1.3.4) stab at an +API was known as the "gh_ interface", which provided "high-level" abstraction +to libguile w/ the premise of supporting multiple implementations at some +future date. In practice this approach resulted in many gh_* objects being +very slight wrappers for the underlying scm_* objects, so eventually this +maintenance burden outweighed the (as yet unrealized) hope for alternate +implementations, and the gh_ interface was deprecated starting in guile-1.5.x. + +Starting w/ guile-1.7.x, in concurrence w/ an effort to make libguile +available to usloth windows platforms, the naked library was once again +dressed w/ the "SCM_API interface". + + +* Decisions + +** gh_ removal + +At some point, we need to remove gh_ entirely: guile-X.Y.Z. + +** malloc policy + +Here's a proposal by ela: + + I would like to propose the follow gh_() equivalents: + + gh_scm2newstr() -> scm_string2str() in string.[ch] + gh_symbol2newstr() -> scm_symbol2str() in symbol.[ch] + + Both taking the (SCM obj, char *context) and allocating memory via + scm_must_malloc(). Thus the user can safely free the returned strings + with scm_must_free(). The latter feature would be an improvement to the + previous gh_() interface functions, for which the user was told to free() + them directly. This caused problems when libguile.so used libc malloc() + and the calling application used its own standard free(), which might not + be libc free(). + +It seems to address the general question of: How should client programs use +malloc with respect to libguile? Some specific questions: + + * Do you like the names of the functions? Maybe they should be named + scm_c_*() instead of scm_*(). + * Do they make sense? + * Should we provide something like scm_c_free() for pointers returned by + these kind of functions? + From 7d91213b138ce379ca6bb3cb66fedc52806811cf Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 14 Nov 2001 21:31:59 +0000 Subject: [PATCH 159/281] *** empty log message *** --- devel/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/devel/ChangeLog b/devel/ChangeLog index c258badce..c4b074bce 100644 --- a/devel/ChangeLog +++ b/devel/ChangeLog @@ -1,3 +1,16 @@ +2001-11-14 Thien-Thi Nguyen + + * policy/api.text: Initial revision. + +2001-11-12 mvo + + * translation/lisp-and-scheme.text: + *** empty log message *** + +2001-07-07 mvo + + * policy/goals.text: Sneak in the translators... + 2001-06-27 Thien-Thi Nguyen * README: Remove tasks.text. From ddea3325ebe6c1453fa7969ae27bde1a3e4e5327 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 15 Nov 2001 17:19:53 +0000 Subject: [PATCH 160/281] * eval.c (RETURN): Wrap in do{}while(0) in order to make it safely usable as a single statement followed by a ';', for example in an if statement. (SCM_CEVAL, SCM_APPLY): Clean up code using 'RETURN'. --- libguile/ChangeLog | 8 ++++ libguile/eval.c | 105 +++++++++++++++++++++------------------------ 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 4c4d21c7e..1d2388a79 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,11 @@ +2001-11-15 Dirk Herrmann + + * eval.c (RETURN): Wrap in do{}while(0) in order to make it + safely usable as a single statement followed by a ';', for example + in an if statement. + + (SCM_CEVAL, SCM_APPLY): Clean up code using 'RETURN'. + 2001-11-13 Neil Jerram * random.c (scm_random_solid_sphere_x, diff --git a/libguile/eval.c b/libguile/eval.c index 420328e2a..6a05083fa 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -1625,7 +1625,7 @@ scm_eval_body (SCM code, SCM env) #define SCM_APPLY scm_apply #define PREP_APPLY(proc, args) #define ENTER_APPLY -#define RETURN(x) return x; +#define RETURN(x) do { return x; } while (0) #ifdef STACK_CHECKING #ifndef NO_CEVAL_STACK_CHECKING #define EVAL_STACK_CHECKING @@ -1667,7 +1667,7 @@ do { \ }\ } while (0) #undef RETURN -#define RETURN(e) {proc = (e); goto exit;} +#define RETURN(e) do { proc = (e); goto exit; } while (0) #ifdef STACK_CHECKING #ifndef EVAL_STACK_CHECKING #define EVAL_STACK_CHECKING @@ -1917,9 +1917,7 @@ start: { x = val; if (SCM_IMP (x)) - { - RETURN (x); - } + RETURN (x); else /* This gives the possibility for the debugger to modify the source expression before evaluation. */ @@ -1945,7 +1943,7 @@ dispatch: /* Only happens when called at top level. */ x = scm_cons (x, SCM_UNDEFINED); - goto retval; + RETURN (*scm_lookupcar (x, env, 1)); case SCM_BIT8(SCM_IM_AND): x = SCM_CDR (x); @@ -2016,14 +2014,11 @@ dispatch: if (SCM_IMP (SCM_CAR (x))) { x = SCM_CAR (x); - RETURN (SCM_EVALIM (x, env)) + RETURN (SCM_EVALIM (x, env)); } if (SCM_SYMBOLP (SCM_CAR (x))) - { - retval: - RETURN (*scm_lookupcar (x, env, 1)) - } + RETURN (*scm_lookupcar (x, env, 1)); x = SCM_CAR (x); goto loop; /* tail recurse */ @@ -2053,7 +2048,7 @@ dispatch: proc = SCM_CDR (proc); } } - RETURN (SCM_UNSPECIFIED) + RETURN (SCM_UNSPECIFIED); case SCM_BIT8 (SCM_IM_COND): @@ -2072,9 +2067,7 @@ dispatch: { x = SCM_CDR (proc); if (SCM_NULLP (x)) - { - RETURN (t.arg1) - } + RETURN (t.arg1); if (!SCM_EQ_P (scm_sym_arrow, SCM_CAR (x))) { PREP_APPLY (SCM_UNDEFINED, SCM_EOL); @@ -2091,7 +2084,7 @@ dispatch: } x = SCM_CDR (x); } - RETURN (SCM_UNSPECIFIED) + RETURN (SCM_UNSPECIFIED); case SCM_BIT8(SCM_IM_DO): @@ -2130,9 +2123,7 @@ dispatch: if (!SCM_FALSEP (EVALCAR (x, env))) x = SCM_CDR (x); else if (SCM_IMP (x = SCM_CDDR (x))) - { - RETURN (SCM_UNSPECIFIED); - } + RETURN (SCM_UNSPECIFIED); PREP_APPLY (SCM_UNDEFINED, SCM_EOL); goto carloop; @@ -2307,7 +2298,7 @@ dispatch: goto evap1; case (SCM_ISYMNUM (SCM_IM_DELAY)): - RETURN (scm_makprom (scm_closure (SCM_CDR (x), env))) + RETURN (scm_makprom (scm_closure (SCM_CDR (x), env))); case (SCM_ISYMNUM (SCM_IM_DISPATCH)): proc = SCM_CADR (x); /* unevaluated operands */ @@ -2408,7 +2399,7 @@ dispatch: case (SCM_ISYMNUM (SCM_IM_SLOT_REF)): x = SCM_CDR (x); t.arg1 = EVALCAR (x, env); - RETURN (SCM_PACK (SCM_STRUCT_DATA (t.arg1) [SCM_INUM (SCM_CADR (x))])) + RETURN (SCM_PACK (SCM_STRUCT_DATA (t.arg1) [SCM_INUM (SCM_CADR (x))])); case (SCM_ISYMNUM (SCM_IM_SLOT_SET_X)): x = SCM_CDR (x); @@ -2417,7 +2408,7 @@ dispatch: proc = SCM_CDR (x); SCM_STRUCT_DATA (t.arg1) [SCM_INUM (SCM_CAR (x))] = SCM_UNPACK (EVALCAR (proc, env)); - RETURN (SCM_UNSPECIFIED) + RETURN (SCM_UNSPECIFIED); case (SCM_ISYMNUM (SCM_IM_NIL_COND)): proc = SCM_CDR (x); @@ -2440,12 +2431,12 @@ dispatch: case (SCM_ISYMNUM (SCM_IM_NIL_IFY)): x = SCM_CDR (x); RETURN ((SCM_FALSEP (proc = EVALCAR (x, env)) || SCM_NULLP (proc)) - ? scm_lisp_nil - : proc) + ? scm_lisp_nil + : proc); case (SCM_ISYMNUM (SCM_IM_T_IFY)): x = SCM_CDR (x); - RETURN (!SCM_FALSEP (EVALCAR (x, env)) ? scm_lisp_t : scm_lisp_nil) + RETURN (!SCM_FALSEP (EVALCAR (x, env)) ? scm_lisp_t : scm_lisp_nil); case (SCM_ISYMNUM (SCM_IM_0_COND)): proc = SCM_CDR (x); @@ -2469,13 +2460,13 @@ dispatch: x = SCM_CDR (x); RETURN (SCM_FALSEP (proc = EVALCAR (x, env)) ? SCM_INUM0 - : proc) + : proc); case (SCM_ISYMNUM (SCM_IM_1_IFY)): x = SCM_CDR (x); RETURN (!SCM_FALSEP (EVALCAR (x, env)) ? SCM_MAKINUM (1) - : SCM_INUM0) + : SCM_INUM0); case (SCM_ISYMNUM (SCM_IM_BIND)): { @@ -2507,7 +2498,7 @@ dispatch: scm_dynwinds = SCM_CDR (scm_dynwinds); scm_swap_bindings (vars, vals); - RETURN (proc) + RETURN (proc); } case (SCM_ISYMNUM (SCM_IM_CALL_WITH_VALUES)): @@ -2828,7 +2819,7 @@ evapply: RETURN (SCM_SUBRF (proc) (t.arg1, SCM_UNDEFINED)); case scm_tc7_lsubr: #ifdef DEVAL - RETURN (SCM_SUBRF (proc) (debug.info->a.args)) + RETURN (SCM_SUBRF (proc) (debug.info->a.args)); #else RETURN (SCM_SUBRF (proc) (scm_list_1 (t.arg1))); #endif @@ -2931,7 +2922,7 @@ evapply: RETURN (SCM_SUBRF (proc) (t.arg1, arg2)); case scm_tc7_lsubr: #ifdef DEVAL - RETURN (SCM_SUBRF (proc) (debug.info->a.args)) + RETURN (SCM_SUBRF (proc) (debug.info->a.args)); #else RETURN (SCM_SUBRF (proc) (scm_list_2 (t.arg1, arg2))); #endif @@ -3052,33 +3043,33 @@ evapply: arg2 = SCM_CDR (arg2); } while (SCM_NIMP (arg2)); - RETURN (t.arg1) + RETURN (t.arg1); #endif /* BUILTIN_RPASUBR */ case scm_tc7_rpsubr: #ifdef BUILTIN_RPASUBR if (SCM_FALSEP (SCM_SUBRF (proc) (t.arg1, arg2))) - RETURN (SCM_BOOL_F) + RETURN (SCM_BOOL_F); t.arg1 = SCM_CDDR (debug.info->a.args); do { if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, SCM_CAR (t.arg1)))) - RETURN (SCM_BOOL_F) - arg2 = SCM_CAR (t.arg1); + RETURN (SCM_BOOL_F); + arg2 = SCM_CAR (t.arg1); t.arg1 = SCM_CDR (t.arg1); } while (SCM_NIMP (t.arg1)); - RETURN (SCM_BOOL_T) + RETURN (SCM_BOOL_T); #else /* BUILTIN_RPASUBR */ RETURN (SCM_APPLY (proc, t.arg1, scm_acons (arg2, SCM_CDDR (debug.info->a.args), - SCM_EOL))) + SCM_EOL))); #endif /* BUILTIN_RPASUBR */ case scm_tc7_lsubr_2: RETURN (SCM_SUBRF (proc) (t.arg1, arg2, - SCM_CDDR (debug.info->a.args))) + SCM_CDDR (debug.info->a.args))); case scm_tc7_lsubr: - RETURN (SCM_SUBRF (proc) (debug.info->a.args)) + RETURN (SCM_SUBRF (proc) (debug.info->a.args)); case scm_tc7_smob: if (!SCM_SMOB_APPLICABLE_P (proc)) goto badfun; @@ -3113,22 +3104,22 @@ evapply: x = SCM_CDR(x); } while (SCM_NIMP (x)); - RETURN (t.arg1) + RETURN (t.arg1); #endif /* BUILTIN_RPASUBR */ case scm_tc7_rpsubr: #ifdef BUILTIN_RPASUBR if (SCM_FALSEP (SCM_SUBRF (proc) (t.arg1, arg2))) - RETURN (SCM_BOOL_F) + RETURN (SCM_BOOL_F); do { t.arg1 = EVALCAR (x, env); if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, t.arg1))) - RETURN (SCM_BOOL_F) - arg2 = t.arg1; + RETURN (SCM_BOOL_F); + arg2 = t.arg1; x = SCM_CDR (x); } while (SCM_NIMP (x)); - RETURN (SCM_BOOL_T) + RETURN (SCM_BOOL_T); #else /* BUILTIN_RPASUBR */ RETURN (SCM_APPLY (proc, t.arg1, scm_acons (arg2, @@ -3456,20 +3447,20 @@ tail: { case scm_tc7_subr_2o: args = SCM_NULLP (args) ? SCM_UNDEFINED : SCM_CAR (args); - RETURN (SCM_SUBRF (proc) (arg1, args)) + RETURN (SCM_SUBRF (proc) (arg1, args)); case scm_tc7_subr_2: SCM_ASRTGO (!SCM_NULLP (args) && SCM_NULLP (SCM_CDR (args)), wrongnumargs); args = SCM_CAR (args); - RETURN (SCM_SUBRF (proc) (arg1, args)) + RETURN (SCM_SUBRF (proc) (arg1, args)); case scm_tc7_subr_0: SCM_ASRTGO (SCM_UNBNDP (arg1), wrongnumargs); - RETURN (SCM_SUBRF (proc) ()) + RETURN (SCM_SUBRF (proc) ()); case scm_tc7_subr_1: SCM_ASRTGO (!SCM_UNBNDP (arg1), wrongnumargs); case scm_tc7_subr_1o: SCM_ASRTGO (SCM_NULLP (args), wrongnumargs); - RETURN (SCM_SUBRF (proc) (arg1)) + RETURN (SCM_SUBRF (proc) (arg1)); case scm_tc7_cxr: SCM_ASRTGO (!SCM_UNBNDP (arg1) && SCM_NULLP (args), wrongnumargs); if (SCM_SUBRF (proc)) @@ -3484,7 +3475,7 @@ tail: } #ifdef SCM_BIGDIG else if (SCM_BIGP (arg1)) - RETURN (scm_make_real (SCM_DSUBRF (proc) (scm_i_big2dbl (arg1)))) + RETURN (scm_make_real (SCM_DSUBRF (proc) (scm_i_big2dbl (arg1)))); #endif SCM_WTA_DISPATCH_1 (*SCM_SUBR_GENERIC (proc), arg1, SCM_ARG1, SCM_SYMBOL_CHARS (SCM_SNAME (proc))); @@ -3498,26 +3489,26 @@ tail: arg1, SCM_ARG1, SCM_SYMBOL_CHARS (proc)); arg1 = ('a' == *chrs) ? SCM_CAR (arg1) : SCM_CDR (arg1); } - RETURN (arg1) + RETURN (arg1); } case scm_tc7_subr_3: SCM_ASRTGO (!SCM_NULLP (args) && !SCM_NULLP (SCM_CDR (args)) && SCM_NULLP (SCM_CDDR (args)), wrongnumargs); - RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CADR (args))) + RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CADR (args))); case scm_tc7_lsubr: #ifdef DEVAL - RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : debug.vect[0].a.args)) + RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : debug.vect[0].a.args)); #else - RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : scm_cons (arg1, args))) + RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : scm_cons (arg1, args))); #endif case scm_tc7_lsubr_2: SCM_ASRTGO (SCM_CONSP (args), wrongnumargs); - RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CDR (args))) + RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CDR (args))); case scm_tc7_asubr: if (SCM_NULLP (args)) - RETURN (SCM_SUBRF (proc) (arg1, SCM_UNDEFINED)) + RETURN (SCM_SUBRF (proc) (arg1, SCM_UNDEFINED)); while (SCM_NIMP (args)) { SCM_ASSERT (SCM_CONSP (args), args, SCM_ARG2, "apply"); @@ -3588,11 +3579,11 @@ tail: if (!SCM_SMOB_APPLICABLE_P (proc)) goto badproc; if (SCM_UNBNDP (arg1)) - RETURN (SCM_SMOB_APPLY_0 (proc)) + RETURN (SCM_SMOB_APPLY_0 (proc)); else if (SCM_NULLP (args)) - RETURN (SCM_SMOB_APPLY_1 (proc, arg1)) + RETURN (SCM_SMOB_APPLY_1 (proc, arg1)); else if (SCM_NULLP (SCM_CDR (args))) - RETURN (SCM_SMOB_APPLY_2 (proc, arg1, SCM_CAR (args))) + RETURN (SCM_SMOB_APPLY_2 (proc, arg1, SCM_CAR (args))); else RETURN (SCM_SMOB_APPLY_3 (proc, arg1, SCM_CAR (args), SCM_CDR (args))); case scm_tc7_cclo: From 3605ae0dee15da9e234542f06b093b0a325daf15 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 15 Nov 2001 21:11:25 +0000 Subject: [PATCH 161/281] New file. --- devel/build/guile-projects-entry | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 devel/build/guile-projects-entry diff --git a/devel/build/guile-projects-entry b/devel/build/guile-projects-entry new file mode 100644 index 000000000..7559b24d3 --- /dev/null +++ b/devel/build/guile-projects-entry @@ -0,0 +1,15 @@ +;;; $Date: 2001-11-15 21:11:25 $ +((name "guile") + (category "Core") + (keywords "Extension Language " "Scheme " "Interpreter") + (description "GNU Ubiquitous Intelligent Language for Extension") + (location (url "http://www.gnu.org/software/guile/guile.html" + "Guile Homepage")) + (mailing-list (url "http://www.gnu.org/software/guile/mail/mail.html" + "guile-user, guile-devel, etc.")) + (status "version 1.5.4 " + (url "ftp://alpha.gnu.org/gnu/guile/" + "(beta)") + " released 2001-09-28") + (license "GPL, with an exception to allow non-GPL'd programs to " + "link to the library without becoming derivitive works.")) From de057fdc40ef15ef84a690ea36c970a4ade35474 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 15 Nov 2001 23:36:05 +0000 Subject: [PATCH 162/281] Handle command "list" specially: list scripts dir. (help): Make more informative. --- guile-tools.in | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/guile-tools.in b/guile-tools.in index 21bcafa7d..aaa5309cc 100644 --- a/guile-tools.in +++ b/guile-tools.in @@ -17,17 +17,7 @@ # the Free Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA -# Usage: guile-tools --version -# guile-tools --help -# guile-tools [OPTION] PROGRAM [ARGS] -# -# PROGRAM is run w/ ARGS. To see a list of available programs, use -# "guile-tools --help" to find the default scripts directory and then -# do a "ls" on that directory. Or just read the source 14 lines below. -# -# Options (only one of which may be used at a time): -# --scriptsdir DIR -- Look in DIR for scripts -# --guileversion VERS -- Look in $pkgdatadir/VERS/scripts for scripts +# Usage: See `help' func below. # # TODO # - handle pre-install invocation @@ -35,6 +25,22 @@ # # Author: Thien-Thi Nguyen +help () +{ + cat < Date: Thu, 15 Nov 2001 23:39:33 +0000 Subject: [PATCH 163/281] *** empty log message *** --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ad1318061..235e0c8ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-15 Thien-Thi Nguyen + + * guile-tools.in: Handle command "list" specially: list scripts dir. + + (help): Make more informative. + 2001-11-12 Marius Vollmer * autogen.sh: Recurse into libltdl directory and invoke autoconf From cecb4a5e9dbaebcc28f3be0a02feac4263a2cfcc Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Fri, 16 Nov 2001 09:55:54 +0000 Subject: [PATCH 164/281] * These changes add a @deffnx C function declaration and function index entries for each Guile primitive to the copy of the doc snarf output that is used for reference manual synchronization. Online help is unchanged. --- libguile/ChangeLog | 20 +++++++++++ libguile/Makefile.am | 10 ++++-- libguile/guile-snarf-docs-texi.in | 37 -------------------- libguile/snarf.h | 13 ++++---- scripts/ChangeLog | 18 ++++++++++ scripts/snarf-check-and-output-texi | 52 ++++++++++++++++++++++++----- 6 files changed, 96 insertions(+), 54 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 1d2388a79..d89307087 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,23 @@ +2001-11-16 Neil Jerram + + These changes add a @deffnx C function declaration and function + index entries for each Guile primitive to the copy of the doc + snarf output that is used for reference manual synchronization. + Online help is unchanged. + + * snarf.h (SCM_SNARF_DOCS): Output primitive's C function name. + (SCM_DEFINE, SCM_DEFINE1, SCM_REGISTER_PROC): Supply to C function + name to SCM_SNARF_DOCS. + + * guile-snarf-docs-texi.in: Pass the shell script's arguments into + snarf-check-and-output-texi. + + * Makefile.am (guile-procedures.texi): New rule. + (BUILT_SOURCES, guile.texi, guile-procedures.txt, CLEANFILES): + Changed so that the last stage of doc snarfing is now performed + twice, once to produce guile-procedures.txt for online help, and + once to produce guile.texi for reference manual synchronization. + 2001-11-15 Dirk Herrmann * eval.c (RETURN): Wrap in do{}while(0) in order to make it diff --git a/libguile/Makefile.am b/libguile/Makefile.am index d894befda..fd7724ff5 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -88,7 +88,7 @@ DOT_DOC_FILES = alist.doc arbiters.doc async.doc backtrace.doc \ EXTRA_DOT_DOC_FILES = @EXTRA_DOT_DOC_FILES@ BUILT_SOURCES = cpp_err_symbols.c cpp_sig_symbols.c libpath.h scmconfig.h \ - $(DOT_X_FILES) $(EXTRA_DOT_X_FILES) + $(DOT_X_FILES) $(EXTRA_DOT_X_FILES) guile.texi EXTRA_libguile_la_SOURCES = _scm.h \ alloca.c inet_aton.c memmove.c putenv.c strerror.c \ @@ -207,10 +207,14 @@ posix.x: cpp_sig_symbols.c load.x: libpath.h guile.texi: $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) guile-snarf-docs-texi.in guile + cat $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) | ./guile-snarf-docs-texi --manual > $@ \ + || { rm $@; false; } + +guile-procedures.texi: $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) guile-snarf-docs-texi.in guile cat $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) | ./guile-snarf-docs-texi > $@ \ || { rm $@; false; } -guile-procedures.txt: guile.texi +guile-procedures.txt: guile-procedures.texi rm -f $@ makeinfo --force -o $@ $< || test -f $@ @@ -268,6 +272,6 @@ MOSTLYCLEANFILES = \ cpp_err_symbols_here cpp_err_symbols_diff cpp_err_symbols_new \ cpp_sig_symbols_here cpp_sig_symbols_diff cpp_sig_symbols_new -CLEANFILES = libpath.h *.x *.doc guile-procedures.txt guile.texi +CLEANFILES = libpath.h *.x *.doc guile-procedures.txt guile-procedures.texi guile.texi MAINTAINERCLEANFILES = c-tokenize.c diff --git a/libguile/guile-snarf-docs-texi.in b/libguile/guile-snarf-docs-texi.in index 6481534b2..e69de29bb 100755 --- a/libguile/guile-snarf-docs-texi.in +++ b/libguile/guile-snarf-docs-texi.in @@ -1,37 +0,0 @@ -#!/bin/sh -# Massage the snarfed docs to texinfo. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place, Suite 330, -# Boston, MA 02111-1307 USA - -srcdir=@srcdir@ -bindir=`dirname $0` - -bindir=`(cd $bindir; pwd)` -srcdir=`(cd $srcdir; pwd)` - -echo "@paragraphindent 0" - -# run the script that will generate texinfo -main='(module-ref (resolve-module '\''(scripts snarf-check-and-output-texi)) '\''main)' -apply_main="(apply $main (cdr (command-line)))" - -if [ `basename ${bindir}` = libguile ]; then - GUILE_LOAD_PATH=${srcdir}/..; export GUILE_LOAD_PATH -fi - -${bindir}/guile -c "${apply_main}" diff --git a/libguile/snarf.h b/libguile/snarf.h index c44484b3a..4e9448484 100644 --- a/libguile/snarf.h +++ b/libguile/snarf.h @@ -76,13 +76,14 @@ #ifdef SCM_MAGIC_SNARF_INITS # define SCM_SNARF_HERE(X) # define SCM_SNARF_INIT(X) ^^ X -# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) +# define SCM_SNARF_DOCS(TYPE, CNAME, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) #else # ifdef SCM_MAGIC_SNARF_DOCS # define SCM_SNARF_HERE(X) # define SCM_SNARF_INIT(X) -# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) \ +# define SCM_SNARF_DOCS(TYPE, CNAME, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) \ ^^ { \ +cname CNAME ^^ \ fname FNAME ^^ \ type TYPE ^^ \ location __FILE__ __LINE__ ^^ \ @@ -92,7 +93,7 @@ DOCSTRING ^^ } # else # define SCM_SNARF_HERE(X) X # define SCM_SNARF_INIT(X) -# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) +# define SCM_SNARF_DOCS(TYPE, CNAME, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) # endif #endif @@ -105,7 +106,7 @@ SCM_SNARF_INIT(\ scm_c_define_gsubr (s_ ## FNAME, REQ, OPT, VAR, \ (SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME); \ )\ -SCM_SNARF_DOCS(primitive, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) +SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) #define SCM_DEFINE1(FNAME, PRIMNAME, TYPE, ARGLIST, DOCSTRING) \ SCM_SNARF_HERE(\ @@ -113,7 +114,7 @@ static const char s_ ## FNAME [] = PRIMNAME; \ SCM FNAME ARGLIST\ )\ SCM_SNARF_INIT(scm_c_define_subr (s_ ## FNAME, TYPE, FNAME); ) \ -SCM_SNARF_DOCS(1, PRIMNAME, ARGLIST, 2, 0, 0, DOCSTRING) +SCM_SNARF_DOCS(1, FNAME, PRIMNAME, ARGLIST, 2, 0, 0, DOCSTRING) #define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \ SCM_SNARF_HERE(static const char RANAME[]=STR) \ @@ -124,7 +125,7 @@ SCM_SNARF_INIT(scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \ SCM_SNARF_HERE(static const char RANAME[]=STR) \ SCM_SNARF_INIT(scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \ (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN);) \ -SCM_SNARF_DOCS(register, STR, (), REQ, OPT, VAR, \ +SCM_SNARF_DOCS(register, CFN, STR, (), REQ, OPT, VAR, \ "implemented by the C function \"" #CFN "\"") #define SCM_GPROC(RANAME, STR, REQ, OPT, VAR, CFN, GF) \ diff --git a/scripts/ChangeLog b/scripts/ChangeLog index 0aff09883..01dd7eb19 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,21 @@ +2001-11-16 Neil Jerram + + These changes add a @deffnx C function declaration and function + index entries for each Guile primitive to the copy of the doc + snarf output that is used for reference manual synchronization. + Online help is unchanged. + + * snarf-check-and-output-texi (*manual-flag*, + snarf-check-and-output-texi): Handle `--manual' invocation arg + passed through from libguile/Makefile.am. + (*c-function-name*, begin-multiline, do-command): Pick out C + function name from snarfed token stream. + (end-multiline): Add @deffnx C declaration and function index + entries to output. + (*primitive-deffnx-signature*, *primitive-deffnx-sig-length*): + Fluff to help insert the C declaration after any "@deffnx + primitive" lines in the snarfed docstring. + 2001-10-05 Thien-Thi Nguyen * read-scheme-source (quoted?, clump): New procs, exported. diff --git a/scripts/snarf-check-and-output-texi b/scripts/snarf-check-and-output-texi index a300ca78e..f6ca78757 100755 --- a/scripts/snarf-check-and-output-texi +++ b/scripts/snarf-check-and-output-texi @@ -39,7 +39,11 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (define-macro (unless cond . body) `(if (not ,cond) (begin ,@body))) -(define (snarf-check-and-output-texi) +(define *manual-flag* #f) + +(define (snarf-check-and-output-texi . flags) + (if (memq '--manual flags) + (set! *manual-flag* #t)) (process-stream (current-input-port))) (define (process-stream port) @@ -122,6 +126,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (define *file* #f) (define *line* #f) +(define *c-function-name* #f) (define *function-name* #f) (define *snarf-type* #f) (define *args* #f) @@ -131,12 +136,16 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (define (begin-multiline) (set! *file* #f) (set! *line* #f) + (set! *c-function-name* #f) (set! *function-name* #f) (set! *snarf-type* #f) (set! *args* #f) (set! *sig* #f) (set! *docstring* #f)) +(define *primitive-deffnx-signature* "@deffnx primitive ") +(define *primitive-deffnx-sig-length* (string-length *primitive-deffnx-signature*)) + (define (end-multiline) (let* ((req (car *sig*)) (opt (cadr *sig*)) @@ -170,16 +179,40 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (if (not (null? tail)) (begin (format #t "~A" (car tail)) - (loop-tail (cdr tail))))))))))))))) + (loop-tail (cdr tail)))))))))))))) + (scm-deffnx + (if (and *manual-flag* (eq? *snarf-type* 'primitive)) + (with-output-to-string + (lambda () + (format #t "@deffnx function SCM ~A (" *c-function-name*) + (unless (null? *args*) + (format #t "SCM ~A" (car *args*)) + (let loop ((args (cdr *args*))) + (unless (null? args) + (format #t ", SCM ~A" (car args)) + (loop (cdr args))))) + (format #t ")\n"))) + #f))) (format #t "\n ~A\n" *function-name*) (format #t "@c snarfed from ~A:~A\n" *file* *line*) (format #t "@deffn primitive ~A\n" nice-sig) - (let loop ((strings *docstring*)) - (if (not (null? strings)) - (begin - (display (car strings)) - (loop (cdr strings))))) - (display "\n@end deffn\n")))) + (let loop ((strings *docstring*) (scm-deffnx scm-deffnx)) + (cond ((null? strings)) + ((or (not scm-deffnx) + (and (>= (string-length (car strings)) + *primitive-deffnx-sig-length*) + (string=? (substring (car strings) + 0 *primitive-deffnx-sig-length*) + *primitive-deffnx-signature*))) + (display (car strings)) + (loop (cdr strings) scm-deffnx)) + (else (display scm-deffnx) + (loop strings #f)))) + (display "\n") + (when *manual-flag* + (format #t "@findex ~A\n" *function-name*) + (format #t "@findex ~A\n" *c-function-name*)) + (display "@end deffn\n")))) (define (texi-quote s) (let rec ((i 0)) @@ -221,6 +254,9 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (define do-command (match-lambda + (('cname ('id . name)) + (set! *c-function-name* (texi-quote (symbol->string name)))) + (('fname ('string . name)) (set! *function-name* (texi-quote name))) From 8f85c0c6c3eb8de857babc08ca6e832e8a497c44 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Fri, 16 Nov 2001 15:04:17 +0000 Subject: [PATCH 165/281] * Adding C function declarations from the SCM interface to the reference manual documentation. --- doc/maint/ChangeLog | 9 + doc/maint/docstring.el | 30 +- doc/maint/guile.texi | 2244 +++++++++++++++++---------- doc/ref/ChangeLog | 16 + doc/ref/debugging.texi | 34 +- doc/ref/deprecated.texi | 4 +- doc/ref/intro.texi | 6 +- doc/ref/misc-modules.texi | 4 +- doc/ref/new-docstrings.texi | 267 ++-- doc/ref/posix.texi | 599 ++++--- doc/ref/scheme-binding.texi | 3 +- doc/ref/scheme-control.texi | 31 +- doc/ref/scheme-data.texi | 1050 +++++++------ doc/ref/scheme-debug.texi | 92 +- doc/ref/scheme-evaluation.texi | 92 +- doc/ref/scheme-io.texi | 205 ++- doc/ref/scheme-memory.texi | 78 +- doc/ref/scheme-modules.texi | 76 +- doc/ref/scheme-options.texi | 69 +- doc/ref/scheme-procedures.texi | 94 +- doc/ref/scheme-scheduling.texi | 80 +- doc/ref/scheme-translation.texi | 14 +- doc/ref/scheme-utility.texi | 78 +- doc/ref/script-getopt.texi | 4 +- doc/ref/srfi-modules.texi | 460 +++--- libguile/ChangeLog | 25 + libguile/alist.c | 22 +- libguile/eval.c | 2 +- libguile/feature.c | 2 +- libguile/filesys.c | 2 +- libguile/gc.h | 1 - libguile/list.c | 6 +- libguile/macros.c | 2 +- libguile/net_db.c | 16 +- libguile/objprop.c | 4 - libguile/ports.c | 8 +- libguile/posix.c | 2 +- libguile/print.c | 3 +- libguile/ramap.c | 12 +- libguile/sort.c | 7 +- libguile/strings.c | 5 +- libguile/strop.c | 8 +- libguile/struct.c | 2 +- libguile/unif.c | 25 +- libguile/vectors.c | 13 +- libguile/version.c | 6 +- libguile/weaks.c | 10 +- scripts/ChangeLog | 6 + scripts/snarf-check-and-output-texi | 13 +- 49 files changed, 3570 insertions(+), 2271 deletions(-) diff --git a/doc/maint/ChangeLog b/doc/maint/ChangeLog index 17c3ddba2..37e19e73d 100644 --- a/doc/maint/ChangeLog +++ b/doc/maint/ChangeLog @@ -1,3 +1,12 @@ +2001-11-16 Neil Jerram + + * guile.texi: Replaced by regenerated libguile version. + + * docstring.el (make-module-description-list): Exclude @deffn's + with category {C Function}. + (docstring-process-alist): Bind key "d" to + docstring-ediff-this-line in the docstring output buffer. + 2001-11-13 Neil Jerram * guile.texi: Replaced by libguile version (after automatically diff --git a/doc/maint/docstring.el b/doc/maint/docstring.el index e0c05fa58..58d07eaa3 100644 --- a/doc/maint/docstring.el +++ b/doc/maint/docstring.el @@ -217,19 +217,22 @@ to which new docstrings should be added.") (match-end 1)))) (if (string-equal matched "@c module ") (setq module (read (current-buffer))) - (setq matched - (concat (buffer-substring (match-beginning 2) - (match-end 2)) - " " - (buffer-substring (match-beginning 3) - (match-end 3)))) - (message "Found docstring: %S: %s" module matched) - (let ((descriptions (assoc module alist))) - (setq alist - (cons (cons module (cons matched (cdr-safe descriptions))) - (if descriptions - (delete descriptions alist) - alist)))))))) + (let ((type (buffer-substring (match-beginning 2) + (match-end 2)))) + (if (string-equal type "{C Function}") + nil + (setq matched + (concat type + " " + (buffer-substring (match-beginning 3) + (match-end 3)))) + (message "Found docstring: %S: %s" module matched) + (let ((descriptions (assoc module alist))) + (setq alist + (cons (cons module (cons matched (cdr-safe descriptions))) + (if descriptions + (delete descriptions alist) + alist)))))))))) alist)) ;; Return the docstring from the specified LOCATION. LOCATION is a @@ -428,6 +431,7 @@ new snarfed docstring file.\n\n") (insert "\n") (goto-char (point-min)) + (local-set-key "d" 'docstring-ediff-this-line) ;; Popup the issues buffer. (let ((pop-up-frames t)) diff --git a/doc/maint/guile.texi b/doc/maint/guile.texi index fb07f2cba..a099e3dd7 100644 --- a/doc/maint/guile.texi +++ b/doc/maint/guile.texi @@ -1,58 +1,66 @@ @paragraphindent 0 acons -@deffn primitive acons key value alist -Adds a new key-value pair to @var{alist}. A new pair is +@deffn {Scheme Procedure} acons key value alist +@deffnx {C Function} scm_acons (key, value, alist) +Add a new key-value pair to @var{alist}. A new pair is created whose car is @var{key} and whose cdr is @var{value}, and the pair is consed onto @var{alist}, and the new list is returned. This function is @emph{not} destructive; @var{alist} is not modified. @end deffn sloppy-assq -@deffn primitive sloppy-assq key alist +@deffn {Scheme Procedure} sloppy-assq key alist +@deffnx {C Function} scm_sloppy_assq (key, alist) Behaves like @code{assq} but does not do any error checking. Recommended only for use in Guile internals. @end deffn sloppy-assv -@deffn primitive sloppy-assv key alist +@deffn {Scheme Procedure} sloppy-assv key alist +@deffnx {C Function} scm_sloppy_assv (key, alist) Behaves like @code{assv} but does not do any error checking. Recommended only for use in Guile internals. @end deffn sloppy-assoc -@deffn primitive sloppy-assoc key alist +@deffn {Scheme Procedure} sloppy-assoc key alist +@deffnx {C Function} scm_sloppy_assoc (key, alist) Behaves like @code{assoc} but does not do any error checking. Recommended only for use in Guile internals. @end deffn assq -@deffn primitive assq key alist -@deffnx primitive assv key alist -@deffnx primitive assoc key alist -Fetches the entry in @var{alist} that is associated with @var{key}. To +@deffn {Scheme Procedure} assq key alist +@deffnx {Scheme Procedure} assv key alist +@deffnx {Scheme Procedure} assoc key alist +@deffnx {C Function} scm_assq (key, alist) +Fetch the entry in @var{alist} that is associated with @var{key}. To decide whether the argument @var{key} matches a particular entry in @var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv} uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key} cannot be found in @var{alist} (according to whichever equality -predicate is in use), then @code{#f} is returned. These functions +predicate is in use), then return @code{#f}. These functions return the entire alist entry found (i.e. both the key and the value). @end deffn assv -@deffn primitive assv key alist +@deffn {Scheme Procedure} assv key alist +@deffnx {C Function} scm_assv (key, alist) Behaves like @code{assq} but uses @code{eqv?} for key comparison. @end deffn assoc -@deffn primitive assoc key alist +@deffn {Scheme Procedure} assoc key alist +@deffnx {C Function} scm_assoc (key, alist) Behaves like @code{assq} but uses @code{equal?} for key comparison. @end deffn assq-ref -@deffn primitive assq-ref alist key -@deffnx primitive assv-ref alist key -@deffnx primitive assoc-ref alist key +@deffn {Scheme Procedure} assq-ref alist key +@deffnx {Scheme Procedure} assv-ref alist key +@deffnx {Scheme Procedure} assoc-ref alist key +@deffnx {C Function} scm_assq_ref (alist, key) Like @code{assq}, @code{assv} and @code{assoc}, except that only the value associated with @var{key} in @var{alist} is returned. These functions are equivalent to @@ -66,19 +74,22 @@ where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}. @end deffn assv-ref -@deffn primitive assv-ref alist key +@deffn {Scheme Procedure} assv-ref alist key +@deffnx {C Function} scm_assv_ref (alist, key) Behaves like @code{assq-ref} but uses @code{eqv?} for key comparison. @end deffn assoc-ref -@deffn primitive assoc-ref alist key +@deffn {Scheme Procedure} assoc-ref alist key +@deffnx {C Function} scm_assoc_ref (alist, key) Behaves like @code{assq-ref} but uses @code{equal?} for key comparison. @end deffn assq-set! -@deffn primitive assq-set! alist key val -@deffnx primitive assv-set! alist key value -@deffnx primitive assoc-set! alist key value +@deffn {Scheme Procedure} assq-set! alist key val +@deffnx {Scheme Procedure} assv-set! alist key value +@deffnx {Scheme Procedure} assoc-set! alist key value +@deffnx {C Function} scm_assq_set_x (alist, key, val) Reassociate @var{key} in @var{alist} with @var{value}: find any existing @var{alist} entry for @var{key} and associate it with the new @var{value}. If @var{alist} does not contain an entry for @var{key}, @@ -90,96 +101,113 @@ association list. @end deffn assv-set! -@deffn primitive assv-set! alist key val +@deffn {Scheme Procedure} assv-set! alist key val +@deffnx {C Function} scm_assv_set_x (alist, key, val) Behaves like @code{assq-set!} but uses @code{eqv?} for key comparison. @end deffn assoc-set! -@deffn primitive assoc-set! alist key val +@deffn {Scheme Procedure} assoc-set! alist key val +@deffnx {C Function} scm_assoc_set_x (alist, key, val) Behaves like @code{assq-set!} but uses @code{equal?} for key comparison. @end deffn assq-remove! -@deffn primitive assq-remove! alist key -@deffnx primitive assv-remove! alist key -@deffnx primitive assoc-remove! alist key +@deffn {Scheme Procedure} assq-remove! alist key +@deffnx {Scheme Procedure} assv-remove! alist key +@deffnx {Scheme Procedure} assoc-remove! alist key +@deffnx {C Function} scm_assq_remove_x (alist, key) Delete the first entry in @var{alist} associated with @var{key}, and return the resulting alist. @end deffn assv-remove! -@deffn primitive assv-remove! alist key +@deffn {Scheme Procedure} assv-remove! alist key +@deffnx {C Function} scm_assv_remove_x (alist, key) Behaves like @code{assq-remove!} but uses @code{eqv?} for key comparison. @end deffn assoc-remove! -@deffn primitive assoc-remove! alist key +@deffn {Scheme Procedure} assoc-remove! alist key +@deffnx {C Function} scm_assoc_remove_x (alist, key) Behaves like @code{assq-remove!} but uses @code{equal?} for key comparison. @end deffn make-arbiter -@deffn primitive make-arbiter name +@deffn {Scheme Procedure} make-arbiter name +@deffnx {C Function} scm_make_arbiter (name) Return an object of type arbiter and name @var{name}. Its state is initially unlocked. Arbiters are a way to achieve process synchronization. @end deffn try-arbiter -@deffn primitive try-arbiter arb +@deffn {Scheme Procedure} try-arbiter arb +@deffnx {C Function} scm_try_arbiter (arb) Return @code{#t} and lock the arbiter @var{arb} if the arbiter was unlocked. Otherwise, return @code{#f}. @end deffn release-arbiter -@deffn primitive release-arbiter arb +@deffn {Scheme Procedure} release-arbiter arb +@deffnx {C Function} scm_release_arbiter (arb) Return @code{#t} and unlock the arbiter @var{arb} if the arbiter was locked. Otherwise, return @code{#f}. @end deffn async -@deffn primitive async thunk +@deffn {Scheme Procedure} async thunk +@deffnx {C Function} scm_async (thunk) Create a new async for the procedure @var{thunk}. @end deffn system-async -@deffn primitive system-async thunk +@deffn {Scheme Procedure} system-async thunk +@deffnx {C Function} scm_system_async (thunk) Create a new async for the procedure @var{thunk}. Also add it to the system's list of active async objects. @end deffn async-mark -@deffn primitive async-mark a +@deffn {Scheme Procedure} async-mark a +@deffnx {C Function} scm_async_mark (a) Mark the async @var{a} for future execution. @end deffn system-async-mark -@deffn primitive system-async-mark a +@deffn {Scheme Procedure} system-async-mark a +@deffnx {C Function} scm_system_async_mark (a) Mark the async @var{a} for future execution. @end deffn run-asyncs -@deffn primitive run-asyncs list_of_a +@deffn {Scheme Procedure} run-asyncs list_of_a +@deffnx {C Function} scm_run_asyncs (list_of_a) Execute all thunks from the asyncs of the list @var{list_of_a}. @end deffn noop -@deffn primitive noop . args +@deffn {Scheme Procedure} noop . args +@deffnx {C Function} scm_noop (args) Do nothing. When called without arguments, return @code{#f}, otherwise return the first argument. @end deffn unmask-signals -@deffn primitive unmask-signals +@deffn {Scheme Procedure} unmask-signals +@deffnx {C Function} scm_unmask_signals () Unmask signals. The returned value is not specified. @end deffn mask-signals -@deffn primitive mask-signals +@deffn {Scheme Procedure} mask-signals +@deffnx {C Function} scm_mask_signals () Mask signals. The returned value is not specified. @end deffn display-error -@deffn primitive display-error stack port subr message args rest +@deffn {Scheme Procedure} display-error stack port subr message args rest +@deffnx {C Function} scm_display_error (stack, port, subr, message, args, rest) Display an error message to the output port @var{port}. @var{stack} is the saved stack for the error, @var{subr} is the name of the procedure in which the error occured and @@ -190,14 +218,16 @@ ignored. @end deffn display-application -@deffn primitive display-application frame [port [indent]] +@deffn {Scheme Procedure} display-application frame [port [indent]] +@deffnx {C Function} scm_display_application (frame, port, indent) Display a procedure application @var{frame} to the output port @var{port}. @var{indent} specifies the indentation of the output. @end deffn display-backtrace -@deffn primitive display-backtrace stack port [first [depth]] +@deffn {Scheme Procedure} display-backtrace stack port [first [depth]] +@deffnx {C Function} scm_display_backtrace (stack, port, first, depth) Display a backtrace to the output port @var{port}. @var{stack} is the stack to take the backtrace from, @var{first} specifies where in the stack to start and @var{depth} how much frames @@ -206,187 +236,210 @@ which means that default values will be used. @end deffn backtrace -@deffn primitive backtrace +@deffn {Scheme Procedure} backtrace +@deffnx {C Function} scm_backtrace () Display a backtrace of the stack saved by the last error to the current output port. @end deffn not -@deffn primitive not x +@deffn {Scheme Procedure} not x +@deffnx {C Function} scm_not (x) Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}. @end deffn boolean? -@deffn primitive boolean? obj +@deffn {Scheme Procedure} boolean? obj +@deffnx {C Function} scm_boolean_p (obj) Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}. @end deffn char? -@deffn primitive char? x +@deffn {Scheme Procedure} char? x +@deffnx {C Function} scm_char_p (x) Return @code{#t} iff @var{x} is a character, else @code{#f}. @end deffn char=? -@deffn primitive char=? x y +@deffn {Scheme Procedure} char=? x y Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}. @end deffn char? -@deffn primitive char>? x y +@deffn {Scheme Procedure} char>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence, else @code{#f}. @end deffn char>=? -@deffn primitive char>=? x y +@deffn {Scheme Procedure} char>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence, else @code{#f}. @end deffn char-ci=? -@deffn primitive char-ci=? x y +@deffn {Scheme Procedure} char-ci=? x y Return @code{#t} iff @var{x} is the same character as @var{y} ignoring case, else @code{#f}. @end deffn char-ci? -@deffn primitive char-ci>? x y +@deffn {Scheme Procedure} char-ci>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn char-ci>=? -@deffn primitive char-ci>=? x y +@deffn {Scheme Procedure} char-ci>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn char-alphabetic? -@deffn primitive char-alphabetic? chr +@deffn {Scheme Procedure} char-alphabetic? chr +@deffnx {C Function} scm_char_alphabetic_p (chr) Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}. Alphabetic means the same thing as the isalpha C library function. @end deffn char-numeric? -@deffn primitive char-numeric? chr +@deffn {Scheme Procedure} char-numeric? chr +@deffnx {C Function} scm_char_numeric_p (chr) Return @code{#t} iff @var{chr} is numeric, else @code{#f}. Numeric means the same thing as the isdigit C library function. @end deffn char-whitespace? -@deffn primitive char-whitespace? chr +@deffn {Scheme Procedure} char-whitespace? chr +@deffnx {C Function} scm_char_whitespace_p (chr) Return @code{#t} iff @var{chr} is whitespace, else @code{#f}. Whitespace means the same thing as the isspace C library function. @end deffn char-upper-case? -@deffn primitive char-upper-case? chr +@deffn {Scheme Procedure} char-upper-case? chr +@deffnx {C Function} scm_char_upper_case_p (chr) Return @code{#t} iff @var{chr} is uppercase, else @code{#f}. Uppercase means the same thing as the isupper C library function. @end deffn char-lower-case? -@deffn primitive char-lower-case? chr +@deffn {Scheme Procedure} char-lower-case? chr +@deffnx {C Function} scm_char_lower_case_p (chr) Return @code{#t} iff @var{chr} is lowercase, else @code{#f}. Lowercase means the same thing as the islower C library function. @end deffn char-is-both? -@deffn primitive char-is-both? chr +@deffn {Scheme Procedure} char-is-both? chr +@deffnx {C Function} scm_char_is_both_p (chr) Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}. Uppercase and lowercase are as defined by the isupper and islower C library functions. @end deffn char->integer -@deffn primitive char->integer chr +@deffn {Scheme Procedure} char->integer chr +@deffnx {C Function} scm_char_to_integer (chr) Return the number corresponding to ordinal position of @var{chr} in the ASCII sequence. @end deffn integer->char -@deffn primitive integer->char n +@deffn {Scheme Procedure} integer->char n +@deffnx {C Function} scm_integer_to_char (n) Return the character at position @var{n} in the ASCII sequence. @end deffn char-upcase -@deffn primitive char-upcase chr +@deffn {Scheme Procedure} char-upcase chr +@deffnx {C Function} scm_char_upcase (chr) Return the uppercase character version of @var{chr}. @end deffn char-downcase -@deffn primitive char-downcase chr +@deffn {Scheme Procedure} char-downcase chr +@deffnx {C Function} scm_char_downcase (chr) Return the lowercase character version of @var{chr}. @end deffn debug-options-interface -@deffn primitive debug-options-interface [setting] +@deffn {Scheme Procedure} debug-options-interface [setting] +@deffnx {C Function} scm_debug_options (setting) Option interface for the debug options. Instead of using this procedure directly, use the procedures @code{debug-enable}, @code{debug-disable}, @code{debug-set!} and @var{debug-options}. @end deffn with-traps -@deffn primitive with-traps thunk +@deffn {Scheme Procedure} with-traps thunk +@deffnx {C Function} scm_with_traps (thunk) Call @var{thunk} with traps enabled. @end deffn memoized? -@deffn primitive memoized? obj +@deffn {Scheme Procedure} memoized? obj +@deffnx {C Function} scm_memoized_p (obj) Return @code{#t} if @var{obj} is memoized. @end deffn unmemoize -@deffn primitive unmemoize m +@deffn {Scheme Procedure} unmemoize m +@deffnx {C Function} scm_unmemoize (m) Unmemoize the memoized expression @var{m}, @end deffn memoized-environment -@deffn primitive memoized-environment m +@deffn {Scheme Procedure} memoized-environment m +@deffnx {C Function} scm_memoized_environment (m) Return the environment of the memoized expression @var{m}. @end deffn procedure-name -@deffn primitive procedure-name proc +@deffn {Scheme Procedure} procedure-name proc +@deffnx {C Function} scm_procedure_name (proc) Return the name of the procedure @var{proc} @end deffn procedure-source -@deffn primitive procedure-source proc +@deffn {Scheme Procedure} procedure-source proc +@deffnx {C Function} scm_procedure_source (proc) Return the source of the procedure @var{proc}. @end deffn procedure-environment -@deffn primitive procedure-environment proc +@deffn {Scheme Procedure} procedure-environment proc +@deffnx {C Function} scm_procedure_environment (proc) Return the environment of the procedure @var{proc}. @end deffn local-eval -@deffn primitive local-eval exp [env] +@deffn {Scheme Procedure} local-eval exp [env] +@deffnx {C Function} scm_local_eval (exp, env) Evaluate @var{exp} in its environment. If @var{env} is supplied, it is the environment in which to evaluate @var{exp}. Otherwise, @var{exp} must be a memoized code object (in which case, its environment @@ -394,12 +447,14 @@ is implicit). @end deffn debug-object? -@deffn primitive debug-object? obj +@deffn {Scheme Procedure} debug-object? obj +@deffnx {C Function} scm_debug_object_p (obj) Return @code{#t} if @var{obj} is a debug object. @end deffn dynamic-link -@deffn primitive dynamic-link filename +@deffn {Scheme Procedure} dynamic-link filename +@deffnx {C Function} scm_dynamic_link (filename) Open the dynamic library called @var{filename}. A library handle representing the opened library is returned; this handle should be used as the @var{dobj} argument to the following @@ -407,13 +462,15 @@ functions. @end deffn dynamic-object? -@deffn primitive dynamic-object? obj +@deffn {Scheme Procedure} dynamic-object? obj +@deffnx {C Function} scm_dynamic_object_p (obj) Return @code{#t} if @var{obj} is a dynamic library handle, or @code{#f} otherwise. @end deffn dynamic-unlink -@deffn primitive dynamic-unlink dobj +@deffn {Scheme Procedure} dynamic-unlink dobj +@deffnx {C Function} scm_dynamic_unlink (dobj) Unlink the indicated object file from the application. The argument @var{dobj} must have been obtained by a call to @code{dynamic-link}. After @code{dynamic-unlink} has been @@ -421,7 +478,8 @@ called on @var{dobj}, its content is no longer accessible. @end deffn dynamic-func -@deffn primitive dynamic-func name dobj +@deffn {Scheme Procedure} dynamic-func name dobj +@deffnx {C Function} scm_dynamic_func (name, dobj) Search the dynamic object @var{dobj} for the C function indicated by the string @var{name} and return some Scheme handle that can later be used with @code{dynamic-call} to @@ -434,7 +492,8 @@ needed or not and will add it when necessary. @end deffn dynamic-call -@deffn primitive dynamic-call func dobj +@deffn {Scheme Procedure} dynamic-call func dobj +@deffnx {C Function} scm_dynamic_call (func, dobj) Call the C function indicated by @var{func} and @var{dobj}. The function is passed no arguments and its return value is ignored. When @var{function} is something returned by @@ -450,7 +509,8 @@ Interrupts are deferred while the C function is executing (with @end deffn dynamic-args-call -@deffn primitive dynamic-args-call func dobj args +@deffn {Scheme Procedure} dynamic-args-call func dobj args +@deffnx {C Function} scm_dynamic_args_call (func, dobj, args) Call the C function indicated by @var{func} and @var{dobj}, just like @code{dynamic-call}, but pass it some arguments and return its return value. The C function is expected to take @@ -467,7 +527,8 @@ converted to a Scheme number and returned from the call to @end deffn dynamic-wind -@deffn primitive dynamic-wind in_guard thunk out_guard +@deffn {Scheme Procedure} dynamic-wind in_guard thunk out_guard +@deffnx {C Function} scm_dynamic_wind (in_guard, thunk, out_guard) All three arguments must be 0-argument procedures. @var{in_guard} is called, then @var{thunk}, then @var{out_guard}. @@ -519,26 +580,30 @@ a-cont @end deffn environment? -@deffn primitive environment? obj +@deffn {Scheme Procedure} environment? obj +@deffnx {C Function} scm_environment_p (obj) Return @code{#t} if @var{obj} is an environment, or @code{#f} otherwise. @end deffn environment-bound? -@deffn primitive environment-bound? env sym +@deffn {Scheme Procedure} environment-bound? env sym +@deffnx {C Function} scm_environment_bound_p (env, sym) Return @code{#t} if @var{sym} is bound in @var{env}, or @code{#f} otherwise. @end deffn environment-ref -@deffn primitive environment-ref env sym +@deffn {Scheme Procedure} environment-ref env sym +@deffnx {C Function} scm_environment_ref (env, sym) Return the value of the location bound to @var{sym} in @var{env}. If @var{sym} is unbound in @var{env}, signal an @code{environment:unbound} error. @end deffn environment-fold -@deffn primitive environment-fold env proc init +@deffn {Scheme Procedure} environment-fold env proc init +@deffnx {C Function} scm_environment_fold (env, proc, init) Iterate over all the bindings in @var{env}, accumulating some value. For each binding in @var{env}, apply @var{proc} to the symbol @@ -573,7 +638,8 @@ using environment-fold: @end deffn environment-define -@deffn primitive environment-define env sym val +@deffn {Scheme Procedure} environment-define env sym val +@deffnx {C Function} scm_environment_define (env, sym, val) Bind @var{sym} to a new location containing @var{val} in @var{env}. If @var{sym} is already bound to another location in @var{env} and the binding is mutable, that binding is @@ -584,7 +650,8 @@ immutable, signal an @code{environment:immutable-binding} error. @end deffn environment-undefine -@deffn primitive environment-undefine env sym +@deffn {Scheme Procedure} environment-undefine env sym +@deffnx {C Function} scm_environment_undefine (env, sym) Remove any binding for @var{sym} from @var{env}. If @var{sym} is unbound in @var{env}, do nothing. The return value is unspecified. @@ -593,7 +660,8 @@ immutable, signal an @code{environment:immutable-binding} error. @end deffn environment-set! -@deffn primitive environment-set! env sym val +@deffn {Scheme Procedure} environment-set! env sym val +@deffnx {C Function} scm_environment_set_x (env, sym, val) If @var{env} binds @var{sym} to some location, change that location's value to @var{val}. The return value is unspecified. @@ -604,7 +672,8 @@ to an immutable location, signal an @end deffn environment-cell -@deffn primitive environment-cell env sym for_write +@deffn {Scheme Procedure} environment-cell env sym for_write +@deffnx {C Function} scm_environment_cell (env, sym, for_write) Return the value cell which @var{env} binds to @var{sym}, or @code{#f} if the binding does not live in a value cell. The argument @var{for-write} indicates whether the caller @@ -620,7 +689,8 @@ re-bound to a new value cell, or becomes undefined. @end deffn environment-observe -@deffn primitive environment-observe env proc +@deffn {Scheme Procedure} environment-observe env proc +@deffnx {C Function} scm_environment_observe (env, proc) Whenever @var{env}'s bindings change, apply @var{proc} to @var{env}. This function returns an object, token, which you can pass to @@ -630,7 +700,8 @@ token is unspecified. @end deffn environment-observe-weak -@deffn primitive environment-observe-weak env proc +@deffn {Scheme Procedure} environment-observe-weak env proc +@deffnx {C Function} scm_environment_observe_weak (env, proc) This function is the same as environment-observe, except that the reference @var{env} retains to @var{proc} is a weak reference. This means that, if there are no other live, @@ -640,7 +711,8 @@ list of observing procedures. @end deffn environment-unobserve -@deffn primitive environment-unobserve token +@deffn {Scheme Procedure} environment-unobserve token +@deffnx {C Function} scm_environment_unobserve (token) Cancel the observation request which returned the value @var{token}. The return value is unspecified. If a call @code{(environment-observe env proc)} returns @@ -650,20 +722,23 @@ bindings change. @end deffn make-leaf-environment -@deffn primitive make-leaf-environment +@deffn {Scheme Procedure} make-leaf-environment +@deffnx {C Function} scm_make_leaf_environment () Create a new leaf environment, containing no bindings. All bindings and locations created in the new environment will be mutable. @end deffn leaf-environment? -@deffn primitive leaf-environment? object +@deffn {Scheme Procedure} leaf-environment? object +@deffnx {C Function} scm_leaf_environment_p (object) Return @code{#t} if object is a leaf environment, or @code{#f} otherwise. @end deffn make-eval-environment -@deffn primitive make-eval-environment local imported +@deffn {Scheme Procedure} make-eval-environment local imported +@deffnx {C Function} scm_make_eval_environment (local, imported) Return a new environment object eval whose bindings are the union of the bindings in the environments @var{local} and @var{imported}, with bindings from @var{local} taking @@ -688,33 +763,39 @@ In typical use, @var{local} will be a finite environment, and @end deffn eval-environment? -@deffn primitive eval-environment? object +@deffn {Scheme Procedure} eval-environment? object +@deffnx {C Function} scm_eval_environment_p (object) Return @code{#t} if object is an eval environment, or @code{#f} otherwise. @end deffn eval-environment-local -@deffn primitive eval-environment-local env +@deffn {Scheme Procedure} eval-environment-local env +@deffnx {C Function} scm_eval_environment_local (env) Return the local environment of eval environment @var{env}. @end deffn eval-environment-set-local! -@deffn primitive eval-environment-set-local! env local +@deffn {Scheme Procedure} eval-environment-set-local! env local +@deffnx {C Function} scm_eval_environment_set_local_x (env, local) Change @var{env}'s local environment to @var{local}. @end deffn eval-environment-imported -@deffn primitive eval-environment-imported env +@deffn {Scheme Procedure} eval-environment-imported env +@deffnx {C Function} scm_eval_environment_imported (env) Return the imported environment of eval environment @var{env}. @end deffn eval-environment-set-imported! -@deffn primitive eval-environment-set-imported! env imported +@deffn {Scheme Procedure} eval-environment-set-imported! env imported +@deffnx {C Function} scm_eval_environment_set_imported_x (env, imported) Change @var{env}'s imported environment to @var{imported}. @end deffn make-import-environment -@deffn primitive make-import-environment imports conflict_proc +@deffn {Scheme Procedure} make-import-environment imports conflict_proc +@deffnx {C Function} scm_make_import_environment (imports, conflict_proc) Return a new environment @var{imp} whose bindings are the union of the bindings from the environments in @var{imports}; @var{imports} must be a list of environments. That is, @@ -743,25 +824,29 @@ if one of its imported environments changes. @end deffn import-environment? -@deffn primitive import-environment? object +@deffn {Scheme Procedure} import-environment? object +@deffnx {C Function} scm_import_environment_p (object) Return @code{#t} if object is an import environment, or @code{#f} otherwise. @end deffn import-environment-imports -@deffn primitive import-environment-imports env +@deffn {Scheme Procedure} import-environment-imports env +@deffnx {C Function} scm_import_environment_imports (env) Return the list of environments imported by the import environment @var{env}. @end deffn import-environment-set-imports! -@deffn primitive import-environment-set-imports! env imports +@deffn {Scheme Procedure} import-environment-set-imports! env imports +@deffnx {C Function} scm_import_environment_set_imports_x (env, imports) Change @var{env}'s list of imported environments to @var{imports}, and check for conflicts. @end deffn make-export-environment -@deffn primitive make-export-environment private signature +@deffn {Scheme Procedure} make-export-environment private signature +@deffnx {C Function} scm_make_export_environment (private, signature) Return a new environment @var{exp} containing only those bindings in private whose symbols are present in @var{signature}. The @var{private} argument must be an @@ -809,33 +894,38 @@ if the bindings in private change. @end deffn export-environment? -@deffn primitive export-environment? object +@deffn {Scheme Procedure} export-environment? object +@deffnx {C Function} scm_export_environment_p (object) Return @code{#t} if object is an export environment, or @code{#f} otherwise. @end deffn export-environment-private -@deffn primitive export-environment-private env +@deffn {Scheme Procedure} export-environment-private env +@deffnx {C Function} scm_export_environment_private (env) Return the private environment of export environment @var{env}. @end deffn export-environment-set-private! -@deffn primitive export-environment-set-private! env private +@deffn {Scheme Procedure} export-environment-set-private! env private +@deffnx {C Function} scm_export_environment_set_private_x (env, private) Change the private environment of export environment @var{env}. @end deffn export-environment-signature -@deffn primitive export-environment-signature env +@deffn {Scheme Procedure} export-environment-signature env +@deffnx {C Function} scm_export_environment_signature (env) Return the signature of export environment @var{env}. @end deffn export-environment-set-signature! -@deffn primitive export-environment-set-signature! env signature +@deffn {Scheme Procedure} export-environment-set-signature! env signature +@deffnx {C Function} scm_export_environment_set_signature_x (env, signature) Change the signature of export environment @var{env}. @end deffn eq? -@deffn primitive eq? x y +@deffn {Scheme Procedure} eq? x y Return @code{#t} iff @var{x} references the same object as @var{y}. @code{eq?} is similar to @code{eqv?} except that in some cases it is capable of discerning distinctions finer than those detectable by @@ -843,7 +933,7 @@ capable of discerning distinctions finer than those detectable by @end deffn eqv? -@deffn primitive eqv? x y +@deffn {Scheme Procedure} eqv? x y The @code{eqv?} procedure defines a useful equivalence relation on objects. Briefly, it returns @code{#t} if @var{x} and @var{y} should normally be regarded as the same object. This relation is left slightly open to @@ -852,7 +942,7 @@ and inexact numbers. @end deffn equal? -@deffn primitive equal? x y +@deffn {Scheme Procedure} equal? x y Return @code{#t} iff @var{x} and @var{y} are recursively @code{eqv?} equivalent. @code{equal?} recursively compares the contents of pairs, vectors, and strings, applying @code{eqv?} on other objects such as @@ -862,7 +952,8 @@ terminate if its arguments are circular data structures. @end deffn scm-error -@deffn primitive scm-error key subr message args data +@deffn {Scheme Procedure} scm-error key subr message args data +@deffnx {C Function} scm_error_scm (key, subr, message, args, data) Raise an error with key @var{key}. @var{subr} can be a string naming the procedure associated with the error, or @code{#f}. @var{message} is the error message string, possibly containing @@ -879,13 +970,15 @@ it will usually be @code{#f}. @end deffn strerror -@deffn primitive strerror err +@deffn {Scheme Procedure} strerror err +@deffnx {C Function} scm_strerror (err) Return the Unix error message corresponding to @var{err}, which must be an integer value. @end deffn apply:nconc2last -@deffn primitive apply:nconc2last lst +@deffn {Scheme Procedure} apply:nconc2last lst +@deffnx {C Function} scm_nconc2last (lst) Given a list (@var{arg1} @dots{} @var{args}), this function conses the @var{arg1} @dots{} arguments onto the front of @var{args}, and returns the resulting list. Note that @@ -896,27 +989,31 @@ destroys its argument, so use with care. @end deffn force -@deffn primitive force x +@deffn {Scheme Procedure} force x +@deffnx {C Function} scm_force (x) If the promise @var{x} has not been computed yet, compute and return @var{x}, otherwise just return the previously computed value. @end deffn promise? -@deffn primitive promise? obj +@deffn {Scheme Procedure} promise? obj +@deffnx {C Function} scm_promise_p (obj) Return true if @var{obj} is a promise, i.e. a delayed computation (@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). @end deffn cons-source -@deffn primitive cons-source xorig x y +@deffn {Scheme Procedure} cons-source xorig x y +@deffnx {C Function} scm_cons_source (xorig, x, y) Create and return a new pair whose car and cdr are @var{x} and @var{y}. Any source properties associated with @var{xorig} are also associated with the new pair. @end deffn copy-tree -@deffn primitive copy-tree obj +@deffn {Scheme Procedure} copy-tree obj +@deffnx {C Function} scm_copy_tree (obj) Recursively copy the data tree that is bound to @var{obj}, and return a pointer to the new data structure. @code{copy-tree} recurses down the contents of both pairs and vectors (since both cons cells and vector @@ -925,44 +1022,50 @@ any other object. @end deffn primitive-eval -@deffn primitive primitive-eval exp +@deffn {Scheme Procedure} primitive-eval exp +@deffnx {C Function} scm_primitive_eval (exp) Evaluate @var{exp} in the top-level environment specified by the current module. @end deffn eval -@deffn primitive eval exp module +@deffn {Scheme Procedure} eval exp module +@deffnx {C Function} scm_eval (exp, module) Evaluate @var{exp}, a list representing a Scheme expression, in the top-level environment specified by @var{module}. -While @var{exp} is evaluated (using @var{primitive-eval}), +While @var{exp} is evaluated (using @code{primitive-eval}), @var{module} is made the current module. The current module is reset to its previous value when @var{eval} returns. @end deffn eval-options-interface -@deffn primitive eval-options-interface [setting] +@deffn {Scheme Procedure} eval-options-interface [setting] +@deffnx {C Function} scm_eval_options_interface (setting) Option interface for the evaluation options. Instead of using this procedure directly, use the procedures @code{eval-enable}, @code{eval-disable}, @code{eval-set!} and @var{eval-options}. @end deffn evaluator-traps-interface -@deffn primitive evaluator-traps-interface [setting] +@deffn {Scheme Procedure} evaluator-traps-interface [setting] +@deffnx {C Function} scm_evaluator_traps (setting) Option interface for the evaluator trap options. @end deffn defined? -@deffn primitive defined? sym [env] +@deffn {Scheme Procedure} defined? sym [env] +@deffnx {C Function} scm_definedp (sym, env) Return @code{#t} if @var{sym} is defined in the lexical environment @var{env}. When @var{env} is not specified, look in the top-level environment as defined by the current module. @end deffn map-in-order -@deffn primitive map-in-order +@deffn {Scheme Procedure} map-in-order implemented by the C function "scm_map" @end deffn load-extension -@deffn primitive load-extension lib init +@deffn {Scheme Procedure} load-extension lib init +@deffnx {C Function} scm_load_extension (lib, init) Load and initialize the extension designated by LIB and INIT. When there is no pre-registered function for LIB/INIT, this is equivalent to @@ -1000,8 +1103,9 @@ well. For example, @end deffn program-arguments -@deffn primitive program-arguments -@deffnx procedure command-line +@deffn {Scheme Procedure} program-arguments +@deffnx {Scheme Procedure} command-line +@deffnx {C Function} scm_program_arguments () Return the list of command line arguments passed to Guile, as a list of strings. The list includes the invoked program name, which is usually @code{"guile"}, but excludes switches and parameters for command line @@ -1009,7 +1113,8 @@ options like @code{-e} and @code{-l}. @end deffn make-fluid -@deffn primitive make-fluid +@deffn {Scheme Procedure} make-fluid +@deffnx {C Function} scm_make_fluid () Return a newly created fluid. Fluids are objects of a certain type (a smob) that can hold one SCM value per dynamic root. That is, modifications to this value are @@ -1020,25 +1125,29 @@ in its own dynamic root, you can use fluids for thread local storage. @end deffn fluid? -@deffn primitive fluid? obj +@deffn {Scheme Procedure} fluid? obj +@deffnx {C Function} scm_fluid_p (obj) Return @code{#t} iff @var{obj} is a fluid; otherwise, return @code{#f}. @end deffn fluid-ref -@deffn primitive fluid-ref fluid +@deffn {Scheme Procedure} fluid-ref fluid +@deffnx {C Function} scm_fluid_ref (fluid) Return the value associated with @var{fluid} in the current dynamic root. If @var{fluid} has not been set, then return @code{#f}. @end deffn fluid-set! -@deffn primitive fluid-set! fluid value +@deffn {Scheme Procedure} fluid-set! fluid value +@deffnx {C Function} scm_fluid_set_x (fluid, value) Set the value associated with @var{fluid} in the current dynamic root. @end deffn with-fluids* -@deffn primitive with-fluids* fluids values thunk +@deffn {Scheme Procedure} with-fluids* fluids values thunk +@deffnx {C Function} scm_with_fluids (fluids, values, thunk) Set @var{fluids} to @var{values} temporary, and call @var{thunk}. @var{fluids} must be a list of fluids and @var{values} must be the same number of their values to be applied. Each substitution is done @@ -1046,7 +1155,8 @@ one after another. @var{thunk} must be a procedure with no argument. @end deffn setvbuf -@deffn primitive setvbuf port mode [size] +@deffn {Scheme Procedure} setvbuf port mode [size] +@deffnx {C Function} scm_setvbuf (port, mode, size) Set the buffering mode for @var{port}. @var{mode} can be: @table @code @item _IONBF @@ -1060,12 +1170,14 @@ If @var{size} is omitted, a default size will be used. @end deffn file-port? -@deffn primitive file-port? obj +@deffn {Scheme Procedure} file-port? obj +@deffnx {C Function} scm_file_port_p (obj) Determine whether @var{obj} is a port that is related to a file. @end deffn open-file -@deffn primitive open-file filename mode +@deffn {Scheme Procedure} open-file filename mode +@deffnx {C Function} scm_open_file (filename, mode) Open the file whose name is @var{filename}, and return a port representing that file. The attributes of the port are determined by the @var{mode} string. The way in which this is @@ -1106,32 +1218,37 @@ requested, @code{open-file} throws an exception. @end deffn gc-stats -@deffn primitive gc-stats +@deffn {Scheme Procedure} gc-stats +@deffnx {C Function} scm_gc_stats () Return an association list of statistics about Guile's current use of storage. @end deffn object-address -@deffn primitive object-address obj +@deffn {Scheme Procedure} object-address obj +@deffnx {C Function} scm_object_address (obj) Return an integer that for the lifetime of @var{obj} is uniquely returned by this function for @var{obj} @end deffn gc -@deffn primitive gc +@deffn {Scheme Procedure} gc +@deffnx {C Function} scm_gc () Scans all of SCM objects and reclaims for further use those that are no longer accessible. @end deffn %compute-slots -@deffn primitive %compute-slots class +@deffn {Scheme Procedure} %compute-slots class +@deffnx {C Function} scm_sys_compute_slots (class) Return a list consisting of the names of all slots belonging to class @var{class}, i. e. the slots of @var{class} and of all of its superclasses. @end deffn get-keyword -@deffn primitive get-keyword key l default_value +@deffn {Scheme Procedure} get-keyword key l default_value +@deffnx {C Function} scm_get_keyword (key, l, default_value) Determine an associated value for the keyword @var{key} from the list @var{l}. The list @var{l} has to consist of an even number of elements, where, starting with the first, every @@ -1141,246 +1258,293 @@ If @var{l} does not hold a value for @var{key}, the value @end deffn %initialize-object -@deffn primitive %initialize-object obj initargs +@deffn {Scheme Procedure} %initialize-object obj initargs +@deffnx {C Function} scm_sys_initialize_object (obj, initargs) Initialize the object @var{obj} with the given arguments @var{initargs}. @end deffn %prep-layout! -@deffn primitive %prep-layout! class +@deffn {Scheme Procedure} %prep-layout! class +@deffnx {C Function} scm_sys_prep_layout_x (class) @end deffn %inherit-magic! -@deffn primitive %inherit-magic! class dsupers +@deffn {Scheme Procedure} %inherit-magic! class dsupers +@deffnx {C Function} scm_sys_inherit_magic_x (class, dsupers) @end deffn instance? -@deffn primitive instance? obj +@deffn {Scheme Procedure} instance? obj +@deffnx {C Function} scm_instance_p (obj) Return @code{#t} if @var{obj} is an instance. @end deffn class-name -@deffn primitive class-name obj +@deffn {Scheme Procedure} class-name obj +@deffnx {C Function} scm_class_name (obj) Return the class name of @var{obj}. @end deffn class-direct-supers -@deffn primitive class-direct-supers obj +@deffn {Scheme Procedure} class-direct-supers obj +@deffnx {C Function} scm_class_direct_supers (obj) Return the direct superclasses of the class @var{obj}. @end deffn class-direct-slots -@deffn primitive class-direct-slots obj +@deffn {Scheme Procedure} class-direct-slots obj +@deffnx {C Function} scm_class_direct_slots (obj) Return the direct slots of the class @var{obj}. @end deffn class-direct-subclasses -@deffn primitive class-direct-subclasses obj +@deffn {Scheme Procedure} class-direct-subclasses obj +@deffnx {C Function} scm_class_direct_subclasses (obj) Return the direct subclasses of the class @var{obj}. @end deffn class-direct-methods -@deffn primitive class-direct-methods obj +@deffn {Scheme Procedure} class-direct-methods obj +@deffnx {C Function} scm_class_direct_methods (obj) Return the direct methods of the class @var{obj} @end deffn class-precedence-list -@deffn primitive class-precedence-list obj +@deffn {Scheme Procedure} class-precedence-list obj +@deffnx {C Function} scm_class_precedence_list (obj) Return the class precedence list of the class @var{obj}. @end deffn class-slots -@deffn primitive class-slots obj +@deffn {Scheme Procedure} class-slots obj +@deffnx {C Function} scm_class_slots (obj) Return the slot list of the class @var{obj}. @end deffn class-environment -@deffn primitive class-environment obj +@deffn {Scheme Procedure} class-environment obj +@deffnx {C Function} scm_class_environment (obj) Return the environment of the class @var{obj}. @end deffn generic-function-name -@deffn primitive generic-function-name obj +@deffn {Scheme Procedure} generic-function-name obj +@deffnx {C Function} scm_generic_function_name (obj) Return the name of the generic function @var{obj}. @end deffn generic-function-methods -@deffn primitive generic-function-methods obj +@deffn {Scheme Procedure} generic-function-methods obj +@deffnx {C Function} scm_generic_function_methods (obj) Return the methods of the generic function @var{obj}. @end deffn method-generic-function -@deffn primitive method-generic-function obj +@deffn {Scheme Procedure} method-generic-function obj +@deffnx {C Function} scm_method_generic_function (obj) Return the generic function fot the method @var{obj}. @end deffn method-specializers -@deffn primitive method-specializers obj +@deffn {Scheme Procedure} method-specializers obj +@deffnx {C Function} scm_method_specializers (obj) Return specializers of the method @var{obj}. @end deffn method-procedure -@deffn primitive method-procedure obj +@deffn {Scheme Procedure} method-procedure obj +@deffnx {C Function} scm_method_procedure (obj) Return the procedure of the method @var{obj}. @end deffn accessor-method-slot-definition -@deffn primitive accessor-method-slot-definition obj +@deffn {Scheme Procedure} accessor-method-slot-definition obj +@deffnx {C Function} scm_accessor_method_slot_definition (obj) Return the slot definition of the accessor @var{obj}. @end deffn %tag-body -@deffn primitive %tag-body body +@deffn {Scheme Procedure} %tag-body body +@deffnx {C Function} scm_sys_tag_body (body) Internal GOOPS magic---don't use this function! @end deffn make-unbound -@deffn primitive make-unbound +@deffn {Scheme Procedure} make-unbound +@deffnx {C Function} scm_make_unbound () Return the unbound value. @end deffn unbound? -@deffn primitive unbound? obj +@deffn {Scheme Procedure} unbound? obj +@deffnx {C Function} scm_unbound_p (obj) Return @code{#t} if @var{obj} is unbound. @end deffn assert-bound -@deffn primitive assert-bound value obj +@deffn {Scheme Procedure} assert-bound value obj +@deffnx {C Function} scm_assert_bound (value, obj) Return @var{value} if it is bound, and invoke the @var{slot-unbound} method of @var{obj} if it is not. @end deffn @@assert-bound-ref -@deffn primitive @@assert-bound-ref obj index +@deffn {Scheme Procedure} @@assert-bound-ref obj index +@deffnx {C Function} scm_at_assert_bound_ref (obj, index) Like @code{assert-bound}, but use @var{index} for accessing the value from @var{obj}. @end deffn %fast-slot-ref -@deffn primitive %fast-slot-ref obj index +@deffn {Scheme Procedure} %fast-slot-ref obj index +@deffnx {C Function} scm_sys_fast_slot_ref (obj, index) Return the slot value with index @var{index} from @var{obj}. @end deffn %fast-slot-set! -@deffn primitive %fast-slot-set! obj index value +@deffn {Scheme Procedure} %fast-slot-set! obj index value +@deffnx {C Function} scm_sys_fast_slot_set_x (obj, index, value) Set the slot with index @var{index} in @var{obj} to @var{value}. @end deffn slot-ref-using-class -@deffn primitive slot-ref-using-class class obj slot_name +@deffn {Scheme Procedure} slot-ref-using-class class obj slot_name +@deffnx {C Function} scm_slot_ref_using_class (class, obj, slot_name) @end deffn slot-set-using-class! -@deffn primitive slot-set-using-class! class obj slot_name value +@deffn {Scheme Procedure} slot-set-using-class! class obj slot_name value +@deffnx {C Function} scm_slot_set_using_class_x (class, obj, slot_name, value) @end deffn slot-bound-using-class? -@deffn primitive slot-bound-using-class? class obj slot_name +@deffn {Scheme Procedure} slot-bound-using-class? class obj slot_name +@deffnx {C Function} scm_slot_bound_using_class_p (class, obj, slot_name) @end deffn slot-exists-using-class? -@deffn primitive slot-exists-using-class? class obj slot_name +@deffn {Scheme Procedure} slot-exists-using-class? class obj slot_name +@deffnx {C Function} scm_slot_exists_using_class_p (class, obj, slot_name) @end deffn slot-ref -@deffn primitive slot-ref obj slot_name +@deffn {Scheme Procedure} slot-ref obj slot_name +@deffnx {C Function} scm_slot_ref (obj, slot_name) Return the value from @var{obj}'s slot with the name @var{slot_name}. @end deffn slot-set! -@deffn primitive slot-set! obj slot_name value +@deffn {Scheme Procedure} slot-set! obj slot_name value +@deffnx {C Function} scm_slot_set_x (obj, slot_name, value) Set the slot named @var{slot_name} of @var{obj} to @var{value}. @end deffn slot-bound? -@deffn primitive slot-bound? obj slot_name +@deffn {Scheme Procedure} slot-bound? obj slot_name +@deffnx {C Function} scm_slot_bound_p (obj, slot_name) Return @code{#t} if the slot named @var{slot_name} of @var{obj} is bound. @end deffn slot-exists? -@deffn primitive slot-exists? obj slot_name +@deffn {Scheme Procedure} slot-exists? obj slot_name +@deffnx {C Function} scm_slots_exists_p (obj, slot_name) Return @code{#t} if @var{obj} has a slot named @var{slot_name}. @end deffn %allocate-instance -@deffn primitive %allocate-instance class initargs +@deffn {Scheme Procedure} %allocate-instance class initargs +@deffnx {C Function} scm_sys_allocate_instance (class, initargs) Create a new instance of class @var{class} and initialize it from the arguments @var{initargs}. @end deffn %set-object-setter! -@deffn primitive %set-object-setter! obj setter +@deffn {Scheme Procedure} %set-object-setter! obj setter +@deffnx {C Function} scm_sys_set_object_setter_x (obj, setter) @end deffn %modify-instance -@deffn primitive %modify-instance old new +@deffn {Scheme Procedure} %modify-instance old new +@deffnx {C Function} scm_sys_modify_instance (old, new) @end deffn %modify-class -@deffn primitive %modify-class old new +@deffn {Scheme Procedure} %modify-class old new +@deffnx {C Function} scm_sys_modify_class (old, new) @end deffn %invalidate-class -@deffn primitive %invalidate-class class +@deffn {Scheme Procedure} %invalidate-class class +@deffnx {C Function} scm_sys_invalidate_class (class) @end deffn %invalidate-method-cache! -@deffn primitive %invalidate-method-cache! gf +@deffn {Scheme Procedure} %invalidate-method-cache! gf +@deffnx {C Function} scm_sys_invalidate_method_cache_x (gf) @end deffn generic-capability? -@deffn primitive generic-capability? proc +@deffn {Scheme Procedure} generic-capability? proc +@deffnx {C Function} scm_generic_capability_p (proc) @end deffn enable-primitive-generic! -@deffn primitive enable-primitive-generic! . subrs +@deffn {Scheme Procedure} enable-primitive-generic! . subrs +@deffnx {C Function} scm_enable_primitive_generic_x (subrs) @end deffn primitive-generic-generic -@deffn primitive primitive-generic-generic subr +@deffn {Scheme Procedure} primitive-generic-generic subr +@deffnx {C Function} scm_primitive_generic_generic (subr) @end deffn make -@deffn primitive make . args +@deffn {Scheme Procedure} make . args +@deffnx {C Function} scm_make (args) Make a new object. @var{args} must contain the class and all necessary initialization information. @end deffn find-method -@deffn primitive find-method . l +@deffn {Scheme Procedure} find-method . l +@deffnx {C Function} scm_find_method (l) @end deffn %method-more-specific? -@deffn primitive %method-more-specific? m1 m2 targs +@deffn {Scheme Procedure} %method-more-specific? m1 m2 targs +@deffnx {C Function} scm_sys_method_more_specific_p (m1, m2, targs) @end deffn %goops-loaded -@deffn primitive %goops-loaded +@deffn {Scheme Procedure} %goops-loaded +@deffnx {C Function} scm_sys_goops_loaded () Announce that GOOPS is loaded and perform initialization on the C level which depends on the loaded GOOPS modules. @end deffn make-guardian -@deffn primitive make-guardian [greedy_p] +@deffn {Scheme Procedure} make-guardian [greedy_p] +@deffnx {C Function} scm_make_guardian (greedy_p) Create a new guardian. A guardian protects a set of objects from garbage collection, allowing a program to apply cleanup or other actions. @@ -1409,24 +1573,28 @@ paper still (mostly) accurately describes the interface). @end deffn guardian-destroyed? -@deffn primitive guardian-destroyed? guardian +@deffn {Scheme Procedure} guardian-destroyed? guardian +@deffnx {C Function} scm_guardian_destroyed_p (guardian) Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}. @end deffn guardian-greedy? -@deffn primitive guardian-greedy? guardian +@deffn {Scheme Procedure} guardian-greedy? guardian +@deffnx {C Function} scm_guardian_greedy_p (guardian) Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}. @end deffn destroy-guardian! -@deffn primitive destroy-guardian! guardian +@deffn {Scheme Procedure} destroy-guardian! guardian +@deffnx {C Function} scm_destroy_guardian_x (guardian) Destroys @var{guardian}, by making it impossible to put any more objects in it or get any objects from it. It also unguards any objects guarded by @var{guardian}. @end deffn hashq -@deffn primitive hashq key size +@deffn {Scheme Procedure} hashq key size +@deffnx {C Function} scm_hashq (key, size) Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eq?} is used as the equality predicate. The function returns an @@ -1440,7 +1608,8 @@ different values, since @code{foo} will be garbage collected. @end deffn hashv -@deffn primitive hashv key size +@deffn {Scheme Procedure} hashv key size +@deffnx {C Function} scm_hashv (key, size) Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eqv?} is used as the equality predicate. The function returns an @@ -1454,7 +1623,8 @@ different values, since @code{foo} will be garbage collected. @end deffn hash -@deffn primitive hash key size +@deffn {Scheme Procedure} hash key size +@deffnx {C Function} scm_hash (key, size) Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{equal?} is used as the equality predicate. The function returns an @@ -1462,7 +1632,8 @@ integer in the range 0 to @var{size} - 1. @end deffn hashq-get-handle -@deffn primitive hashq-get-handle table key +@deffn {Scheme Procedure} hashq-get-handle table key +@deffnx {C Function} scm_hashq_get_handle (table, key) This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an associated value for @var{key}, @code{#f} is returned. @@ -1470,14 +1641,16 @@ Uses @code{eq?} for equality testing. @end deffn hashq-create-handle! -@deffn primitive hashq-create-handle! table key init +@deffn {Scheme Procedure} hashq-create-handle! table key init +@deffnx {C Function} scm_hashq_create_handle_x (table, key, init) This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which associates @var{key} with @var{init}. @end deffn hashq-ref -@deffn primitive hashq-ref table key [dflt] +@deffn {Scheme Procedure} hashq-ref table key [dflt] +@deffnx {C Function} scm_hashq_ref (table, key, dflt) Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, return @var{default} (or @code{#f} if no @var{default} argument @@ -1485,19 +1658,22 @@ is supplied). Uses @code{eq?} for equality testing. @end deffn hashq-set! -@deffn primitive hashq-set! table key val +@deffn {Scheme Procedure} hashq-set! table key val +@deffnx {C Function} scm_hashq_set_x (table, key, val) Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{eq?} for equality testing. @end deffn hashq-remove! -@deffn primitive hashq-remove! table key +@deffn {Scheme Procedure} hashq-remove! table key +@deffnx {C Function} scm_hashq_remove_x (table, key) Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{eq?} for equality tests. @end deffn hashv-get-handle -@deffn primitive hashv-get-handle table key +@deffn {Scheme Procedure} hashv-get-handle table key +@deffnx {C Function} scm_hashv_get_handle (table, key) This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an associated value for @var{key}, @code{#f} is returned. @@ -1505,14 +1681,16 @@ Uses @code{eqv?} for equality testing. @end deffn hashv-create-handle! -@deffn primitive hashv-create-handle! table key init +@deffn {Scheme Procedure} hashv-create-handle! table key init +@deffnx {C Function} scm_hashv_create_handle_x (table, key, init) This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which associates @var{key} with @var{init}. @end deffn hashv-ref -@deffn primitive hashv-ref table key [dflt] +@deffn {Scheme Procedure} hashv-ref table key [dflt] +@deffnx {C Function} scm_hashv_ref (table, key, dflt) Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, return @var{default} (or @code{#f} if no @var{default} argument @@ -1520,19 +1698,22 @@ is supplied). Uses @code{eqv?} for equality testing. @end deffn hashv-set! -@deffn primitive hashv-set! table key val +@deffn {Scheme Procedure} hashv-set! table key val +@deffnx {C Function} scm_hashv_set_x (table, key, val) Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{eqv?} for equality testing. @end deffn hashv-remove! -@deffn primitive hashv-remove! table key +@deffn {Scheme Procedure} hashv-remove! table key +@deffnx {C Function} scm_hashv_remove_x (table, key) Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{eqv?} for equality tests. @end deffn hash-get-handle -@deffn primitive hash-get-handle table key +@deffn {Scheme Procedure} hash-get-handle table key +@deffnx {C Function} scm_hash_get_handle (table, key) This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an associated value for @var{key}, @code{#f} is returned. @@ -1540,14 +1721,16 @@ Uses @code{equal?} for equality testing. @end deffn hash-create-handle! -@deffn primitive hash-create-handle! table key init +@deffn {Scheme Procedure} hash-create-handle! table key init +@deffnx {C Function} scm_hash_create_handle_x (table, key, init) This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which associates @var{key} with @var{init}. @end deffn hash-ref -@deffn primitive hash-ref table key [dflt] +@deffn {Scheme Procedure} hash-ref table key [dflt] +@deffnx {C Function} scm_hash_ref (table, key, dflt) Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, return @var{default} (or @code{#f} if no @var{default} argument @@ -1555,20 +1738,23 @@ is supplied). Uses @code{equal?} for equality testing. @end deffn hash-set! -@deffn primitive hash-set! table key val +@deffn {Scheme Procedure} hash-set! table key val +@deffnx {C Function} scm_hash_set_x (table, key, val) Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{equal?} for equality testing. @end deffn hash-remove! -@deffn primitive hash-remove! table key +@deffn {Scheme Procedure} hash-remove! table key +@deffnx {C Function} scm_hash_remove_x (table, key) Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{equal?} for equality tests. @end deffn hashx-get-handle -@deffn primitive hashx-get-handle hash assoc table key +@deffn {Scheme Procedure} hashx-get-handle hash assoc table key +@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key) This behaves the same way as the corresponding @code{-get-handle} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be @@ -1578,7 +1764,8 @@ table size. @code{assoc} must be an associator function, like @end deffn hashx-create-handle! -@deffn primitive hashx-create-handle! hash assoc table key init +@deffn {Scheme Procedure} hashx-create-handle! hash assoc table key init +@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init) This behaves the same way as the corresponding @code{-create-handle} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be @@ -1588,7 +1775,8 @@ table size. @code{assoc} must be an associator function, like @end deffn hashx-ref -@deffn primitive hashx-ref hash assoc table key [dflt] +@deffn {Scheme Procedure} hashx-ref hash assoc table key [dflt] +@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt) This behaves the same way as the corresponding @code{ref} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be a function @@ -1601,7 +1789,8 @@ equivalent to @code{hashx-ref hashq assq table key}. @end deffn hashx-set! -@deffn primitive hashx-set! hash assoc table key val +@deffn {Scheme Procedure} hashx-set! hash assoc table key val +@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val) This behaves the same way as the corresponding @code{set!} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be a function @@ -1614,7 +1803,8 @@ equivalent to @code{hashx-set! hashq assq table key}. @end deffn hash-fold -@deffn primitive hash-fold proc init table +@deffn {Scheme Procedure} hash-fold proc init table +@deffnx {C Function} scm_hash_fold (proc, init, table) An iterator over hash-table elements. Accumulates and returns a result by applying PROC successively. The arguments to PROC are "(key value prior-result)" where key @@ -1626,25 +1816,29 @@ table into an a-list of key-value pairs. @end deffn make-hook -@deffn primitive make-hook [n_args] +@deffn {Scheme Procedure} make-hook [n_args] +@deffnx {C Function} scm_make_hook (n_args) Create a hook for storing procedure of arity @var{n_args}. @var{n_args} defaults to zero. The returned value is a hook object to be used with the other hook procedures. @end deffn hook? -@deffn primitive hook? x +@deffn {Scheme Procedure} hook? x +@deffnx {C Function} scm_hook_p (x) Return @code{#t} if @var{x} is a hook, @code{#f} otherwise. @end deffn hook-empty? -@deffn primitive hook-empty? hook +@deffn {Scheme Procedure} hook-empty? hook +@deffnx {C Function} scm_hook_empty_p (hook) Return @code{#t} if @var{hook} is an empty hook, @code{#f} otherwise. @end deffn add-hook! -@deffn primitive add-hook! hook proc [append_p] +@deffn {Scheme Procedure} add-hook! hook proc [append_p] +@deffnx {C Function} scm_add_hook_x (hook, proc, append_p) Add the procedure @var{proc} to the hook @var{hook}. The procedure is added to the end if @var{append_p} is true, otherwise it is added to the front. The return value of this @@ -1652,31 +1846,36 @@ procedure is not specified. @end deffn remove-hook! -@deffn primitive remove-hook! hook proc +@deffn {Scheme Procedure} remove-hook! hook proc +@deffnx {C Function} scm_remove_hook_x (hook, proc) Remove the procedure @var{proc} from the hook @var{hook}. The return value of this procedure is not specified. @end deffn reset-hook! -@deffn primitive reset-hook! hook +@deffn {Scheme Procedure} reset-hook! hook +@deffnx {C Function} scm_reset_hook_x (hook) Remove all procedures from the hook @var{hook}. The return value of this procedure is not specified. @end deffn run-hook -@deffn primitive run-hook hook . args +@deffn {Scheme Procedure} run-hook hook . args +@deffnx {C Function} scm_run_hook (hook, args) Apply all procedures from the hook @var{hook} to the arguments @var{args}. The order of the procedure application is first to last. The return value of this procedure is not specified. @end deffn hook->list -@deffn primitive hook->list hook +@deffn {Scheme Procedure} hook->list hook +@deffnx {C Function} scm_hook_to_list (hook) Convert the procedure list of @var{hook} to a list. @end deffn ftell -@deffn primitive ftell fd_port +@deffn {Scheme Procedure} ftell fd_port +@deffnx {C Function} scm_ftell (fd_port) Return an integer representing the current position of @var{fd/port}, measured from the beginning. Equivalent to: @@ -1686,7 +1885,8 @@ Return an integer representing the current position of @end deffn redirect-port -@deffn primitive redirect-port old new +@deffn {Scheme Procedure} redirect-port old new +@deffnx {C Function} scm_redirect_port (old, new) This procedure takes two ports and duplicates the underlying file descriptor from @var{old-port} into @var{new-port}. The current file descriptor in @var{new-port} will be closed. @@ -1703,14 +1903,16 @@ revealed counts. @end deffn dup->fdes -@deffn primitive dup->fdes fd_or_port [fd] +@deffn {Scheme Procedure} dup->fdes fd_or_port [fd] +@deffnx {C Function} scm_dup_to_fdes (fd_or_port, fd) Return a new integer file descriptor referring to the open file designated by @var{fd_or_port}, which must be either an open file port or a file descriptor. @end deffn dup2 -@deffn primitive dup2 oldfd newfd +@deffn {Scheme Procedure} dup2 oldfd newfd +@deffnx {C Function} scm_dup2 (oldfd, newfd) A simple wrapper for the @code{dup2} system call. Copies the file descriptor @var{oldfd} to descriptor number @var{newfd}, replacing the previous meaning @@ -1722,19 +1924,22 @@ The return value is unspecified. @end deffn fileno -@deffn primitive fileno port +@deffn {Scheme Procedure} fileno port +@deffnx {C Function} scm_fileno (port) Return the integer file descriptor underlying @var{port}. Does not change its revealed count. @end deffn isatty? -@deffn primitive isatty? port +@deffn {Scheme Procedure} isatty? port +@deffnx {C Function} scm_isatty_p (port) Return @code{#t} if @var{port} is using a serial non--file device, otherwise @code{#f}. @end deffn fdopen -@deffn primitive fdopen fdes modes +@deffn {Scheme Procedure} fdopen fdes modes +@deffnx {C Function} scm_fdopen (fdes, modes) Return a new port based on the file descriptor @var{fdes}. Modes are given by the string @var{modes}. The revealed count of the port is initialized to zero. The modes string is the @@ -1742,7 +1947,8 @@ same as that accepted by @ref{File Ports, open-file}. @end deffn primitive-move->fdes -@deffn primitive primitive-move->fdes port fd +@deffn {Scheme Procedure} primitive-move->fdes port fd +@deffnx {C Function} scm_primitive_move_to_fdes (port, fd) Moves the underlying file descriptor for @var{port} to the integer value @var{fdes} without changing the revealed count of @var{port}. Any other ports already using this descriptor will be automatically @@ -1752,68 +1958,78 @@ required value or @code{#t} if it was moved. @end deffn fdes->ports -@deffn primitive fdes->ports fd +@deffn {Scheme Procedure} fdes->ports fd +@deffnx {C Function} scm_fdes_to_ports (fd) Return a list of existing ports which have @var{fdes} as an underlying file descriptor, without changing their revealed counts. @end deffn make-keyword-from-dash-symbol -@deffn primitive make-keyword-from-dash-symbol symbol +@deffn {Scheme Procedure} make-keyword-from-dash-symbol symbol +@deffnx {C Function} scm_make_keyword_from_dash_symbol (symbol) Make a keyword object from a @var{symbol} that starts with a dash. @end deffn keyword? -@deffn primitive keyword? obj +@deffn {Scheme Procedure} keyword? obj +@deffnx {C Function} scm_keyword_p (obj) Return @code{#t} if the argument @var{obj} is a keyword, else @code{#f}. @end deffn keyword-dash-symbol -@deffn primitive keyword-dash-symbol keyword +@deffn {Scheme Procedure} keyword-dash-symbol keyword +@deffnx {C Function} scm_keyword_dash_symbol (keyword) Return the dash symbol for @var{keyword}. This is the inverse of @code{make-keyword-from-dash-symbol}. @end deffn nil-cons -@deffn primitive nil-cons x y +@deffn {Scheme Procedure} nil-cons x y +@deffnx {C Function} scm_nil_cons (x, y) Create a new cons cell with @var{x} as the car and @var{y} as the cdr, but convert @var{y} to Scheme's end-of-list if it is a LISP nil. @end deffn nil-car -@deffn primitive nil-car x +@deffn {Scheme Procedure} nil-car x +@deffnx {C Function} scm_nil_car (x) Return the car of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn nil-cdr -@deffn primitive nil-cdr x +@deffn {Scheme Procedure} nil-cdr x +@deffnx {C Function} scm_nil_cdr (x) Return the cdr of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn null -@deffn primitive null x +@deffn {Scheme Procedure} null x +@deffnx {C Function} scm_null (x) Return LISP's @code{t} if @var{x} is nil in the LISP sense, return LISP's nil otherwise. @end deffn nil-eq -@deffn primitive nil-eq x y +@deffn {Scheme Procedure} nil-eq x y Compare @var{x} and @var{y} and return LISP's t if they are @code{eq?}, return LISP's nil otherwise. @end deffn list -@deffn primitive list . objs +@deffn {Scheme Procedure} list . objs +@deffnx {C Function} scm_list (objs) Return a list containing @var{objs}, the arguments to @code{list}. @end deffn cons* -@deffn primitive cons* arg . rest +@deffn {Scheme Procedure} cons* arg . rest +@deffnx {C Function} scm_cons_star (arg, rest) Like @code{list}, but the last arg provides the tail of the constructed list, returning @code{(cons @var{arg1} (cons @var{arg2} (cons @dots{} @var{argn})))}. Requires at least one @@ -1823,22 +2039,26 @@ Schemes and in Common LISP. @end deffn null? -@deffn primitive null? x +@deffn {Scheme Procedure} null? x +@deffnx {C Function} scm_null_p (x) Return @code{#t} iff @var{x} is the empty list, else @code{#f}. @end deffn list? -@deffn primitive list? x +@deffn {Scheme Procedure} list? x +@deffnx {C Function} scm_list_p (x) Return @code{#t} iff @var{x} is a proper list, else @code{#f}. @end deffn length -@deffn primitive length lst +@deffn {Scheme Procedure} length lst +@deffnx {C Function} scm_length (lst) Return the number of elements in list @var{lst}. @end deffn append -@deffn primitive append . args +@deffn {Scheme Procedure} append . args +@deffnx {C Function} scm_append (args) Return a list consisting of the elements the lists passed as arguments. @lisp @@ -1857,7 +2077,8 @@ if the last argument is not a proper list. @end deffn append! -@deffn primitive append! . lists +@deffn {Scheme Procedure} append! . lists +@deffnx {C Function} scm_append_x (lists) A destructive version of @code{append} (@pxref{Pairs and Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field of each list's final pair is changed to point to the head of @@ -1866,19 +2087,22 @@ the mutated list. @end deffn last-pair -@deffn primitive last-pair lst +@deffn {Scheme Procedure} last-pair lst +@deffnx {C Function} scm_last_pair (lst) Return a pointer to the last pair in @var{lst}, signalling an error if @var{lst} is circular. @end deffn reverse -@deffn primitive reverse lst +@deffn {Scheme Procedure} reverse lst +@deffnx {C Function} scm_reverse (lst) Return a new list that contains the elements of @var{lst} but in reverse order. @end deffn reverse! -@deffn primitive reverse! lst [new_tail] +@deffn {Scheme Procedure} reverse! lst [new_tail] +@deffnx {C Function} scm_reverse_x (lst, new_tail) A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is modified to point to the previous list element. Return a pointer to the @@ -1893,23 +2117,26 @@ of the modified list is not lost, it is wise to save the return value of @end deffn list-ref -@deffn primitive list-ref list k +@deffn {Scheme Procedure} list-ref list k +@deffnx {C Function} scm_list_ref (list, k) Return the @var{k}th element from @var{list}. @end deffn list-set! -@deffn primitive list-set! list k val +@deffn {Scheme Procedure} list-set! list k val +@deffnx {C Function} scm_list_set_x (list, k, val) Set the @var{k}th element of @var{list} to @var{val}. @end deffn list-cdr-ref -@deffn primitive list-cdr-ref +@deffn {Scheme Procedure} list-cdr-ref implemented by the C function "scm_list_tail" @end deffn list-tail -@deffn primitive list-tail lst k -@deffnx primitive list-cdr-ref lst k +@deffn {Scheme Procedure} list-tail lst k +@deffnx {Scheme Procedure} list-cdr-ref lst k +@deffnx {C Function} scm_list_tail (lst, k) Return the "tail" of @var{lst} beginning with its @var{k}th element. The first element of the list is considered to be element 0. @@ -1919,23 +2146,27 @@ or returning the results of cdring @var{k} times down @var{lst}. @end deffn list-cdr-set! -@deffn primitive list-cdr-set! list k val +@deffn {Scheme Procedure} list-cdr-set! list k val +@deffnx {C Function} scm_list_cdr_set_x (list, k, val) Set the @var{k}th cdr of @var{list} to @var{val}. @end deffn list-head -@deffn primitive list-head lst k +@deffn {Scheme Procedure} list-head lst k +@deffnx {C Function} scm_list_head (lst, k) Copy the first @var{k} elements from @var{lst} into a new list, and return it. @end deffn list-copy -@deffn primitive list-copy lst +@deffn {Scheme Procedure} list-copy lst +@deffnx {C Function} scm_list_copy (lst) Return a (newly-created) copy of @var{lst}. @end deffn memq -@deffn primitive memq x lst +@deffn {Scheme Procedure} memq x lst +@deffnx {C Function} scm_memq (x, lst) Return the first sublist of @var{lst} whose car is @code{eq?} to @var{x} where the sublists of @var{lst} are the non-empty lists returned by @code{(list-tail @var{lst} @var{k})} for @@ -1945,7 +2176,8 @@ returned. @end deffn memv -@deffn primitive memv x lst +@deffn {Scheme Procedure} memv x lst +@deffnx {C Function} scm_memv (x, lst) Return the first sublist of @var{lst} whose car is @code{eqv?} to @var{x} where the sublists of @var{lst} are the non-empty lists returned by @code{(list-tail @var{lst} @var{k})} for @@ -1955,7 +2187,8 @@ returned. @end deffn member -@deffn primitive member x lst +@deffn {Scheme Procedure} member x lst +@deffnx {C Function} scm_member (x, lst) Return the first sublist of @var{lst} whose car is @code{equal?} to @var{x} where the sublists of @var{lst} are the non-empty lists returned by @code{(list-tail @var{lst} @@ -1965,9 +2198,10 @@ empty list) is returned. @end deffn delq! -@deffn primitive delq! item lst -@deffnx primitive delv! item lst -@deffnx primitive delete! item lst +@deffn {Scheme Procedure} delq! item lst +@deffnx {Scheme Procedure} delv! item lst +@deffnx {Scheme Procedure} delete! item lst +@deffnx {C Function} scm_delq_x (item, lst) These procedures are destructive versions of @code{delq}, @code{delv} and @code{delete}: they modify the pointers in the existing @var{lst} rather than creating a new list. Caveat evaluator: Like other @@ -1977,19 +2211,22 @@ destructive list functions, these functions cannot modify the binding of @end deffn delv! -@deffn primitive delv! item lst +@deffn {Scheme Procedure} delv! item lst +@deffnx {C Function} scm_delv_x (item, lst) Destructively remove all elements from @var{lst} that are @code{eqv?} to @var{item}. @end deffn delete! -@deffn primitive delete! item lst +@deffn {Scheme Procedure} delete! item lst +@deffnx {C Function} scm_delete_x (item, lst) Destructively remove all elements from @var{lst} that are @code{equal?} to @var{item}. @end deffn delq -@deffn primitive delq item lst +@deffn {Scheme Procedure} delq item lst +@deffnx {C Function} scm_delq (item, lst) Return a newly-created copy of @var{lst} with elements @code{eq?} to @var{item} removed. This procedure mirrors @code{memq}: @code{delq} compares elements of @var{lst} against @@ -1997,7 +2234,8 @@ Return a newly-created copy of @var{lst} with elements @end deffn delv -@deffn primitive delv item lst +@deffn {Scheme Procedure} delv item lst +@deffnx {C Function} scm_delv (item, lst) Return a newly-created copy of @var{lst} with elements @code{eqv?} to @var{item} removed. This procedure mirrors @code{memv}: @code{delv} compares elements of @var{lst} against @@ -2005,7 +2243,8 @@ Return a newly-created copy of @var{lst} with elements @end deffn delete -@deffn primitive delete item lst +@deffn {Scheme Procedure} delete item lst +@deffnx {C Function} scm_delete (item, lst) Return a newly-created copy of @var{lst} with elements @code{equal?} to @var{item} removed. This procedure mirrors @code{member}: @code{delete} compares elements of @var{lst} @@ -2013,28 +2252,32 @@ against @var{item} with @code{equal?}. @end deffn delq1! -@deffn primitive delq1! item lst +@deffn {Scheme Procedure} delq1! item lst +@deffnx {C Function} scm_delq1_x (item, lst) Like @code{delq!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @code{eq?}. See also @code{delv1!} and @code{delete1!}. @end deffn delv1! -@deffn primitive delv1! item lst +@deffn {Scheme Procedure} delv1! item lst +@deffnx {C Function} scm_delv1_x (item, lst) Like @code{delv!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @code{eqv?}. See also @code{delq1!} and @code{delete1!}. @end deffn delete1! -@deffn primitive delete1! item lst +@deffn {Scheme Procedure} delete1! item lst +@deffnx {C Function} scm_delete1_x (item, lst) Like @code{delete!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @code{equal?}. See also @code{delq1!} and @code{delv1!}. @end deffn primitive-load -@deffn primitive primitive-load filename +@deffn {Scheme Procedure} primitive-load filename +@deffnx {C Function} scm_primitive_load (filename) Load the file named @var{filename} and evaluate its contents in the top-level environment. The load paths are not searched; @var{filename} must either be a full pathname or be a pathname @@ -2045,26 +2288,30 @@ documentation for @code{%load-hook} later in this section. @end deffn %package-data-dir -@deffn primitive %package-data-dir +@deffn {Scheme Procedure} %package-data-dir +@deffnx {C Function} scm_sys_package_data_dir () Return the name of the directory where Scheme packages, modules and libraries are kept. On most Unix systems, this will be @samp{/usr/local/share/guile}. @end deffn %library-dir -@deffn primitive %library-dir +@deffn {Scheme Procedure} %library-dir +@deffnx {C Function} scm_sys_library_dir () Return the directory where the Guile Scheme library files are installed. E.g., may return "/usr/share/guile/1.3.5". @end deffn %site-dir -@deffn primitive %site-dir +@deffn {Scheme Procedure} %site-dir +@deffnx {C Function} scm_sys_site_dir () Return the directory where the Guile site files are installed. E.g., may return "/usr/share/guile/site". @end deffn parse-path -@deffn primitive parse-path path [tail] +@deffn {Scheme Procedure} parse-path path [tail] +@deffnx {C Function} scm_parse_path (path, tail) Parse @var{path}, which is expected to be a colon-separated string, into a list and return the resulting list with @var{tail} appended. If @var{path} is @code{#f}, @var{tail} @@ -2072,7 +2319,8 @@ is returned. @end deffn search-path -@deffn primitive search-path path filename [extensions] +@deffn {Scheme Procedure} search-path path filename [extensions] +@deffnx {C Function} scm_search_path (path, filename, extensions) Search @var{path} for a directory containing a file named @var{filename}. The file must be readable, and not a directory. If we find one, return its full filename; otherwise, return @@ -2083,7 +2331,8 @@ concatenated with each @var{extension}. @end deffn %search-load-path -@deffn primitive %search-load-path filename +@deffn {Scheme Procedure} %search-load-path filename +@deffnx {C Function} scm_sys_search_load_path (filename) Search @var{%load-path} for the file named @var{filename}, which must be readable by the current user. If @var{filename} is found in the list of paths to search or is an absolute @@ -2094,7 +2343,8 @@ will try each extension automatically. @end deffn primitive-load-path -@deffn primitive primitive-load-path filename +@deffn {Scheme Procedure} primitive-load-path filename +@deffnx {C Function} scm_primitive_load_path (filename) Search @var{%load-path} for the file named @var{filename} and load it into the top-level environment. If @var{filename} is a relative pathname and is not found in the list of search paths, @@ -2102,7 +2352,8 @@ an error is signalled. @end deffn procedure->syntax -@deffn primitive procedure->syntax code +@deffn {Scheme Procedure} procedure->syntax code +@deffnx {C Function} scm_makacro (code) Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, returns the result of applying @var{code} to the expression and the @@ -2110,7 +2361,8 @@ environment. @end deffn procedure->macro -@deffn primitive procedure->macro code +@deffn {Scheme Procedure} procedure->macro code +@deffnx {C Function} scm_makmacro (code) Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the result of applying @var{code} to the expression and the @@ -2128,7 +2380,8 @@ passed to @var{code}. For example: @end deffn procedure->memoizing-macro -@deffn primitive procedure->memoizing-macro code +@deffn {Scheme Procedure} procedure->memoizing-macro code +@deffnx {C Function} scm_makmmacro (code) Return a @dfn{macro} which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the result of applying @var{proc} to the expression and the @@ -2146,43 +2399,50 @@ passed to @var{proc}. For example: @end deffn macro? -@deffn primitive macro? obj +@deffn {Scheme Procedure} macro? obj +@deffnx {C Function} scm_macro_p (obj) Return @code{#t} if @var{obj} is a regular macro, a memoizing macro or a syntax transformer. @end deffn macro-type -@deffn primitive macro-type m +@deffn {Scheme Procedure} macro-type m +@deffnx {C Function} scm_macro_type (m) Return one of the symbols @code{syntax}, @code{macro} or @code{macro!}, depending on whether @var{m} is a syntax -tranformer, a regular macro, or a memoizing macro, +transformer, a regular macro, or a memoizing macro, respectively. If @var{m} is not a macro, @code{#f} is returned. @end deffn macro-name -@deffn primitive macro-name m +@deffn {Scheme Procedure} macro-name m +@deffnx {C Function} scm_macro_name (m) Return the name of the macro @var{m}. @end deffn macro-transformer -@deffn primitive macro-transformer m +@deffn {Scheme Procedure} macro-transformer m +@deffnx {C Function} scm_macro_transformer (m) Return the transformer of the macro @var{m}. @end deffn current-module -@deffn primitive current-module +@deffn {Scheme Procedure} current-module +@deffnx {C Function} scm_current_module () Return the current module. @end deffn set-current-module -@deffn primitive set-current-module module +@deffn {Scheme Procedure} set-current-module module +@deffnx {C Function} scm_set_current_module (module) Set the current module to @var{module} and return the previous current module. @end deffn interaction-environment -@deffn primitive interaction-environment +@deffn {Scheme Procedure} interaction-environment +@deffnx {C Function} scm_interaction_environment () Return a specifier for the environment that contains implementation--defined bindings, typically a superset of those listed in the report. The intent is that this procedure will @@ -2191,45 +2451,52 @@ evaluate expressions dynamically typed by the user. @end deffn env-module -@deffn primitive env-module env +@deffn {Scheme Procedure} env-module env +@deffnx {C Function} scm_env_module (env) Return the module of @var{ENV}, a lexical environment. @end deffn standard-eval-closure -@deffn primitive standard-eval-closure module +@deffn {Scheme Procedure} standard-eval-closure module +@deffnx {C Function} scm_standard_eval_closure (module) Return an eval closure for the module @var{module}. @end deffn standard-interface-eval-closure -@deffn primitive standard-interface-eval-closure module +@deffn {Scheme Procedure} standard-interface-eval-closure module +@deffnx {C Function} scm_standard_interface_eval_closure (module) Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added. @end deffn %get-pre-modules-obarray -@deffn primitive %get-pre-modules-obarray +@deffn {Scheme Procedure} %get-pre-modules-obarray +@deffnx {C Function} scm_get_pre_modules_obarray () Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system. @end deffn exact? -@deffn primitive exact? x +@deffn {Scheme Procedure} exact? x +@deffnx {C Function} scm_exact_p (x) Return @code{#t} if @var{x} is an exact number, @code{#f} otherwise. @end deffn odd? -@deffn primitive odd? n +@deffn {Scheme Procedure} odd? n +@deffnx {C Function} scm_odd_p (n) Return @code{#t} if @var{n} is an odd number, @code{#f} otherwise. @end deffn even? -@deffn primitive even? n +@deffn {Scheme Procedure} even? n +@deffnx {C Function} scm_even_p (n) Return @code{#t} if @var{n} is an even number, @code{#f} otherwise. @end deffn logand -@deffn primitive logand n1 n2 +@deffn {Scheme Procedure} logand n1 n2 Return the bitwise AND of the integer arguments. @lisp @@ -2240,7 +2507,7 @@ Return the bitwise AND of the integer arguments. @end deffn logior -@deffn primitive logior n1 n2 +@deffn {Scheme Procedure} logior n1 n2 Return the bitwise OR of the integer arguments. @lisp @@ -2251,7 +2518,7 @@ Return the bitwise OR of the integer arguments. @end deffn logxor -@deffn primitive logxor n1 n2 +@deffn {Scheme Procedure} logxor n1 n2 Return the bitwise XOR of the integer arguments. A bit is set in the result if it is set in an odd number of arguments. @lisp @@ -2263,7 +2530,8 @@ set in the result if it is set in an odd number of arguments. @end deffn logtest -@deffn primitive logtest j k +@deffn {Scheme Procedure} logtest j k +@deffnx {C Function} scm_logtest (j, k) @lisp (logtest j k) @equiv{} (not (zero? (logand j k))) @@ -2273,7 +2541,8 @@ set in the result if it is set in an odd number of arguments. @end deffn logbit? -@deffn primitive logbit? index j +@deffn {Scheme Procedure} logbit? index j +@deffnx {C Function} scm_logbit_p (index, j) @lisp (logbit? index j) @equiv{} (logtest (integer-expt 2 index) j) @@ -2286,7 +2555,8 @@ set in the result if it is set in an odd number of arguments. @end deffn lognot -@deffn primitive lognot n +@deffn {Scheme Procedure} lognot n +@deffnx {C Function} scm_lognot (n) Return the integer which is the 2s-complement of the integer argument. @@ -2299,7 +2569,8 @@ argument. @end deffn integer-expt -@deffn primitive integer-expt n k +@deffn {Scheme Procedure} integer-expt n k +@deffnx {C Function} scm_integer_expt (n, k) Return @var{n} raised to the non-negative integer exponent @var{k}. @@ -2312,7 +2583,8 @@ Return @var{n} raised to the non-negative integer exponent @end deffn ash -@deffn primitive ash n cnt +@deffn {Scheme Procedure} ash n cnt +@deffnx {C Function} scm_ash (n, cnt) The function ash performs an arithmetic shift left by @var{cnt} bits (or shift right, if @var{cnt} is negative). 'Arithmetic' means, that the function does not guarantee to keep the bit @@ -2331,7 +2603,8 @@ Formally, the function returns an integer equivalent to @end deffn bit-extract -@deffn primitive bit-extract n start end +@deffn {Scheme Procedure} bit-extract n start end +@deffnx {C Function} scm_bit_extract (n, start, end) Return the integer composed of the @var{start} (inclusive) through @var{end} (exclusive) bits of @var{n}. The @var{start}th bit becomes the 0-th bit in the result. @@ -2345,7 +2618,8 @@ through @var{end} (exclusive) bits of @var{n}. The @end deffn logcount -@deffn primitive logcount n +@deffn {Scheme Procedure} logcount n +@deffnx {C Function} scm_logcount (n) Return the number of bits in integer @var{n}. If integer is positive, the 1-bits in its binary representation are counted. If negative, the 0-bits in its two's-complement binary @@ -2362,7 +2636,8 @@ representation are counted. If 0, 0 is returned. @end deffn integer-length -@deffn primitive integer-length n +@deffn {Scheme Procedure} integer-length n +@deffnx {C Function} scm_integer_length (n) Return the number of bits neccessary to represent @var{n}. @lisp @@ -2376,14 +2651,16 @@ Return the number of bits neccessary to represent @var{n}. @end deffn number->string -@deffn primitive number->string n [radix] +@deffn {Scheme Procedure} number->string n [radix] +@deffnx {C Function} scm_number_to_string (n, radix) Return a string holding the external representation of the number @var{n} in the given @var{radix}. If @var{n} is inexact, a radix of 10 will be used. @end deffn string->number -@deffn primitive string->number string [radix] +@deffn {Scheme Procedure} string->number string [radix] +@deffnx {C Function} scm_string_to_number (string, radix) Return a number of the maximally precise representation expressed by the given @var{string}. @var{radix} must be an exact integer, either 2, 8, 10, or 16. If supplied, @var{radix} @@ -2395,12 +2672,13 @@ syntactically valid notation for a number, then @end deffn number? -@deffn primitive number? +@deffn {Scheme Procedure} number? implemented by the C function "scm_number_p" @end deffn complex? -@deffn primitive complex? x +@deffn {Scheme Procedure} complex? x +@deffnx {C Function} scm_number_p (x) Return @code{#t} if @var{x} is a complex number, @code{#f} else. Note that the sets of real, rational and integer values form subsets of the set of complex numbers, i. e. the @@ -2409,12 +2687,13 @@ rational or integer number. @end deffn real? -@deffn primitive real? +@deffn {Scheme Procedure} real? implemented by the C function "scm_real_p" @end deffn rational? -@deffn primitive rational? x +@deffn {Scheme Procedure} rational? x +@deffnx {C Function} scm_real_p (x) Return @code{#t} if @var{x} is a rational number, @code{#f} else. Note that the set of integer values forms a subset of the set of rational numbers, i. e. the predicate will also be @@ -2424,25 +2703,29 @@ precision. @end deffn integer? -@deffn primitive integer? x +@deffn {Scheme Procedure} integer? x +@deffnx {C Function} scm_integer_p (x) Return @code{#t} if @var{x} is an integer number, @code{#f} else. @end deffn inexact? -@deffn primitive inexact? x +@deffn {Scheme Procedure} inexact? x +@deffnx {C Function} scm_inexact_p (x) Return @code{#t} if @var{x} is an inexact number, @code{#f} else. @end deffn $expt -@deffn primitive $expt x y +@deffn {Scheme Procedure} $expt x y +@deffnx {C Function} scm_sys_expt (x, y) Return @var{x} raised to the power of @var{y}. This procedure does not accept complex arguments. @end deffn $atan2 -@deffn primitive $atan2 x y +@deffn {Scheme Procedure} $atan2 x y +@deffnx {C Function} scm_sys_atan2 (x, y) Return the arc tangent of the two arguments @var{x} and @var{y}. This is similar to calculating the arc tangent of @var{x} / @var{y}, except that the signs of both arguments @@ -2451,111 +2734,126 @@ procedure does not accept complex arguments. @end deffn make-rectangular -@deffn primitive make-rectangular real imaginary +@deffn {Scheme Procedure} make-rectangular real imaginary +@deffnx {C Function} scm_make_rectangular (real, imaginary) Return a complex number constructed of the given @var{real} and @var{imaginary} parts. @end deffn make-polar -@deffn primitive make-polar x y +@deffn {Scheme Procedure} make-polar x y +@deffnx {C Function} scm_make_polar (x, y) Return the complex number @var{x} * e^(i * @var{y}). @end deffn inexact->exact -@deffn primitive inexact->exact z +@deffn {Scheme Procedure} inexact->exact z +@deffnx {C Function} scm_inexact_to_exact (z) Return an exact number that is numerically closest to @var{z}. @end deffn class-of -@deffn primitive class-of x +@deffn {Scheme Procedure} class-of x +@deffnx {C Function} scm_class_of (x) Return the class of @var{x}. @end deffn entity? -@deffn primitive entity? obj +@deffn {Scheme Procedure} entity? obj +@deffnx {C Function} scm_entity_p (obj) Return @code{#t} if @var{obj} is an entity. @end deffn operator? -@deffn primitive operator? obj +@deffn {Scheme Procedure} operator? obj +@deffnx {C Function} scm_operator_p (obj) Return @code{#t} if @var{obj} is an operator. @end deffn valid-object-procedure? -@deffn primitive valid-object-procedure? proc +@deffn {Scheme Procedure} valid-object-procedure? proc +@deffnx {C Function} scm_valid_object_procedure_p (proc) Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}. @end deffn set-object-procedure! -@deffn primitive set-object-procedure! obj proc +@deffn {Scheme Procedure} set-object-procedure! obj proc +@deffnx {C Function} scm_set_object_procedure_x (obj, proc) Set the object procedure of @var{obj} to @var{proc}. @var{obj} must be either an entity or an operator. @end deffn make-class-object -@deffn primitive make-class-object metaclass layout +@deffn {Scheme Procedure} make-class-object metaclass layout +@deffnx {C Function} scm_make_class_object (metaclass, layout) Create a new class object of class @var{metaclass}, with the slot layout specified by @var{layout}. @end deffn make-subclass-object -@deffn primitive make-subclass-object class layout +@deffn {Scheme Procedure} make-subclass-object class layout +@deffnx {C Function} scm_make_subclass_object (class, layout) Create a subclass object of @var{class}, with the slot layout specified by @var{layout}. @end deffn object-properties -@deffn primitive object-properties obj -@deffnx primitive procedure-properties obj +@deffn {Scheme Procedure} object-properties obj +@deffnx {C Function} scm_object_properties (obj) Return @var{obj}'s property list. @end deffn set-object-properties! -@deffn primitive set-object-properties! obj alist -@deffnx primitive set-procedure-properties! obj alist +@deffn {Scheme Procedure} set-object-properties! obj alist +@deffnx {C Function} scm_set_object_properties_x (obj, alist) Set @var{obj}'s property list to @var{alist}. @end deffn object-property -@deffn primitive object-property obj key -@deffnx primitive procedure-property obj key +@deffn {Scheme Procedure} object-property obj key +@deffnx {C Function} scm_object_property (obj, key) Return the property of @var{obj} with name @var{key}. @end deffn set-object-property! -@deffn primitive set-object-property! obj key value -@deffnx primitive set-procedure-property! obj key value +@deffn {Scheme Procedure} set-object-property! obj key value +@deffnx {C Function} scm_set_object_property_x (obj, key, value) In @var{obj}'s property list, set the property named @var{key} to @var{value}. @end deffn cons -@deffn primitive cons x y +@deffn {Scheme Procedure} cons x y +@deffnx {C Function} scm_cons (x, y) Return a newly allocated pair whose car is @var{x} and whose cdr is @var{y}. The pair is guaranteed to be different (in the sense of @code{eq?}) from every previously existing object. @end deffn pair? -@deffn primitive pair? x +@deffn {Scheme Procedure} pair? x +@deffnx {C Function} scm_pair_p (x) Return @code{#t} if @var{x} is a pair; otherwise return @code{#f}. @end deffn set-car! -@deffn primitive set-car! pair value +@deffn {Scheme Procedure} set-car! pair value +@deffnx {C Function} scm_set_car_x (pair, value) Stores @var{value} in the car field of @var{pair}. The value returned by @code{set-car!} is unspecified. @end deffn set-cdr! -@deffn primitive set-cdr! pair value +@deffn {Scheme Procedure} set-cdr! pair value +@deffnx {C Function} scm_set_cdr_x (pair, value) Stores @var{value} in the cdr field of @var{pair}. The value returned by @code{set-cdr!} is unspecified. @end deffn char-ready? -@deffn primitive char-ready? [port] +@deffn {Scheme Procedure} char-ready? [port] +@deffnx {C Function} scm_char_ready_p (port) Return @code{#t} if a character is ready on input @var{port} and return @code{#f} otherwise. If @code{char-ready?} returns @code{#t} then the next @code{read-char} operation on @@ -2572,7 +2870,8 @@ interactive port that has no ready characters.} @end deffn drain-input -@deffn primitive drain-input port +@deffn {Scheme Procedure} drain-input port +@deffnx {C Function} scm_drain_input (port) This procedure clears a port's input buffers, similar to the way that force-output clears the output buffer. The contents of the buffers are returned as a single string, e.g., @@ -2590,14 +2889,16 @@ for further input. @end deffn current-input-port -@deffn primitive current-input-port +@deffn {Scheme Procedure} current-input-port +@deffnx {C Function} scm_current_input_port () Return the current input port. This is the default port used by many input procedures. Initially, @code{current-input-port} returns the @dfn{standard input} in Unix and C terminology. @end deffn current-output-port -@deffn primitive current-output-port +@deffn {Scheme Procedure} current-output-port +@deffnx {C Function} scm_current_output_port () Return the current output port. This is the default port used by many output procedures. Initially, @code{current-output-port} returns the @dfn{standard output} in @@ -2605,49 +2906,57 @@ Unix and C terminology. @end deffn current-error-port -@deffn primitive current-error-port +@deffn {Scheme Procedure} current-error-port +@deffnx {C Function} scm_current_error_port () Return the port to which errors and warnings should be sent (the @dfn{standard error} in Unix and C terminology). @end deffn current-load-port -@deffn primitive current-load-port +@deffn {Scheme Procedure} current-load-port +@deffnx {C Function} scm_current_load_port () Return the current-load-port. The load port is used internally by @code{primitive-load}. @end deffn set-current-input-port -@deffn primitive set-current-input-port port -@deffnx primitive set-current-output-port port -@deffnx primitive set-current-error-port port +@deffn {Scheme Procedure} set-current-input-port port +@deffnx {Scheme Procedure} set-current-output-port port +@deffnx {Scheme Procedure} set-current-error-port port +@deffnx {C Function} scm_set_current_input_port (port) Change the ports returned by @code{current-input-port}, @code{current-output-port} and @code{current-error-port}, respectively, so that they use the supplied @var{port} for input or output. @end deffn set-current-output-port -@deffn primitive set-current-output-port port +@deffn {Scheme Procedure} set-current-output-port port +@deffnx {C Function} scm_set_current_output_port (port) Set the current default output port to @var{port}. @end deffn set-current-error-port -@deffn primitive set-current-error-port port +@deffn {Scheme Procedure} set-current-error-port port +@deffnx {C Function} scm_set_current_error_port (port) Set the current default error port to @var{port}. @end deffn port-revealed -@deffn primitive port-revealed port +@deffn {Scheme Procedure} port-revealed port +@deffnx {C Function} scm_port_revealed (port) Return the revealed count for @var{port}. @end deffn set-port-revealed! -@deffn primitive set-port-revealed! port rcount +@deffn {Scheme Procedure} set-port-revealed! port rcount +@deffnx {C Function} scm_set_port_revealed_x (port, rcount) Sets the revealed count for a port to a given value. The return value is unspecified. @end deffn port-mode -@deffn primitive port-mode port +@deffn {Scheme Procedure} port-mode port +@deffnx {C Function} scm_port_mode (port) Return the port modes associated with the open port @var{port}. These will not necessarily be identical to the modes used when the port was opened, since modes such as "append" which are @@ -2655,7 +2964,8 @@ used only during port creation are not retained. @end deffn close-port -@deffn primitive close-port port +@deffn {Scheme Procedure} close-port port +@deffnx {C Function} scm_close_port (port) Close the specified port object. Return @code{#t} if it successfully closes a port or @code{#f} if it was already closed. An exception may be raised if an error occurs, for @@ -2665,7 +2975,8 @@ descriptors. @end deffn close-input-port -@deffn primitive close-input-port port +@deffn {Scheme Procedure} close-input-port port +@deffnx {C Function} scm_close_input_port (port) Close the specified input port object. The routine has no effect if the file has already been closed. An exception may be raised if an error occurs. The value returned is unspecified. @@ -2675,7 +2986,8 @@ which can close file descriptors. @end deffn close-output-port -@deffn primitive close-output-port port +@deffn {Scheme Procedure} close-output-port port +@deffnx {C Function} scm_close_output_port (port) Close the specified output port object. The routine has no effect if the file has already been closed. An exception may be raised if an error occurs. The value returned is unspecified. @@ -2685,7 +2997,8 @@ which can close file descriptors. @end deffn port-for-each -@deffn primitive port-for-each proc +@deffn {Scheme Procedure} port-for-each proc +@deffnx {C Function} scm_port_for_each (proc) Apply @var{proc} to each port in the Guile port table in turn. The return value is unspecified. More specifically, @var{proc} is applied exactly once to every port that exists @@ -2695,40 +3008,46 @@ have no effect as far as @var{port-for-each} is concerned. @end deffn input-port? -@deffn primitive input-port? x +@deffn {Scheme Procedure} input-port? x +@deffnx {C Function} scm_input_port_p (x) Return @code{#t} if @var{x} is an input port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @code{port?}. @end deffn output-port? -@deffn primitive output-port? x +@deffn {Scheme Procedure} output-port? x +@deffnx {C Function} scm_output_port_p (x) Return @code{#t} if @var{x} is an output port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @code{port?}. @end deffn port? -@deffn primitive port? x +@deffn {Scheme Procedure} port? x +@deffnx {C Function} scm_port_p (x) Return a boolean indicating whether @var{x} is a port. Equivalent to @code{(or (input-port? @var{x}) (output-port? @var{x}))}. @end deffn port-closed? -@deffn primitive port-closed? port +@deffn {Scheme Procedure} port-closed? port +@deffnx {C Function} scm_port_closed_p (port) Return @code{#t} if @var{port} is closed or @code{#f} if it is open. @end deffn eof-object? -@deffn primitive eof-object? x +@deffn {Scheme Procedure} eof-object? x +@deffnx {C Function} scm_eof_object_p (x) Return @code{#t} if @var{x} is an end-of-file object; otherwise return @code{#f}. @end deffn force-output -@deffn primitive force-output [port] +@deffn {Scheme Procedure} force-output [port] +@deffnx {C Function} scm_force_output (port) Flush the specified output port, or the current output port if @var{port} is omitted. The current output buffer contents are passed to the underlying port implementation (e.g., in the case of fports, the @@ -2739,20 +3058,23 @@ The return value is unspecified. @end deffn flush-all-ports -@deffn primitive flush-all-ports +@deffn {Scheme Procedure} flush-all-ports +@deffnx {C Function} scm_flush_all_ports () Equivalent to calling @code{force-output} on all open output ports. The return value is unspecified. @end deffn read-char -@deffn primitive read-char [port] +@deffn {Scheme Procedure} read-char [port] +@deffnx {C Function} scm_read_char (port) Return the next character available from @var{port}, updating @var{port} to point to the following character. If no more characters are available, the end-of-file object is returned. @end deffn peek-char -@deffn primitive peek-char [port] +@deffn {Scheme Procedure} peek-char [port] +@deffnx {C Function} scm_peek_char (port) Return the next character available from @var{port}, @emph{without} updating @var{port} to point to the following character. If no more characters are available, the @@ -2768,7 +3090,8 @@ to @code{read-char} would have hung.} @end deffn unread-char -@deffn primitive unread-char cobj [port] +@deffn {Scheme Procedure} unread-char cobj [port] +@deffnx {C Function} scm_unread_char (cobj, port) Place @var{char} in @var{port} so that it will be read by the next read operation. If called multiple times, the unread characters will be read again in last-in first-out order. If @var{port} is @@ -2776,7 +3099,8 @@ not supplied, the current input port is used. @end deffn unread-string -@deffn primitive unread-string str port +@deffn {Scheme Procedure} unread-string str port +@deffnx {C Function} scm_unread_string (str, port) Place the string @var{str} in @var{port} so that its characters will be read in subsequent read operations. If called multiple times, the unread characters will be read again in last-in first-out order. If @@ -2784,7 +3108,8 @@ unread characters will be read again in last-in first-out order. If @end deffn seek -@deffn primitive seek fd_port offset whence +@deffn {Scheme Procedure} seek fd_port offset whence +@deffnx {C Function} scm_seek (fd_port, offset, whence) Sets the current position of @var{fd/port} to the integer @var{offset}, which is interpreted according to the value of @var{whence}. @@ -2811,7 +3136,8 @@ that the current position of a port can be obtained using: @end deffn truncate-file -@deffn primitive truncate-file object [length] +@deffn {Scheme Procedure} truncate-file object [length] +@deffnx {C Function} scm_truncate_file (object, length) Truncates the object referred to by @var{object} to at most @var{length} bytes. @var{object} can be a string containing a file name or an integer file descriptor or a port. @@ -2821,18 +3147,21 @@ position. The return value is unspecified. @end deffn port-line -@deffn primitive port-line port +@deffn {Scheme Procedure} port-line port +@deffnx {C Function} scm_port_line (port) Return the current line number for @var{port}. @end deffn set-port-line! -@deffn primitive set-port-line! port line +@deffn {Scheme Procedure} set-port-line! port line +@deffnx {C Function} scm_set_port_line_x (port, line) Set the current line number for @var{port} to @var{line}. @end deffn port-column -@deffn primitive port-column port -@deffnx primitive port-line port +@deffn {Scheme Procedure} port-column port +@deffnx {Scheme Procedure} port-line port +@deffnx {C Function} scm_port_column (port) Return the current column number or line number of @var{port}, using the current input port if none is specified. If the number is unknown, the result is #f. Otherwise, the result is a 0-origin integer @@ -2844,21 +3173,24 @@ what non-programmers will find most natural.) @end deffn set-port-column! -@deffn primitive set-port-column! port column -@deffnx primitive set-port-line! port line +@deffn {Scheme Procedure} set-port-column! port column +@deffnx {Scheme Procedure} set-port-line! port line +@deffnx {C Function} scm_set_port_column_x (port, column) Set the current column or line number of @var{port}, using the current input port if none is specified. @end deffn port-filename -@deffn primitive port-filename port +@deffn {Scheme Procedure} port-filename port +@deffnx {C Function} scm_port_filename (port) Return the filename associated with @var{port}. This function returns the strings "standard input", "standard output" and "standard error" when called on the current input, output and error ports respectively. @end deffn set-port-filename! -@deffn primitive set-port-filename! port filename +@deffn {Scheme Procedure} set-port-filename! port filename +@deffnx {C Function} scm_set_port_filename_x (port, filename) Change the filename associated with @var{port}, using the current input port if none is specified. Note that this does not change the port's source of data, but only the value that is returned by @@ -2866,7 +3198,8 @@ source of data, but only the value that is returned by @end deffn %make-void-port -@deffn primitive %make-void-port mode +@deffn {Scheme Procedure} %make-void-port mode +@deffnx {C Function} scm_sys_make_void_port (mode) Create and return a new void port. A void port acts like /dev/null. The @var{mode} argument specifies the input/output modes for this port: see the @@ -2874,7 +3207,8 @@ documentation for @code{open-file} in @ref{File Ports}. @end deffn print-options-interface -@deffn primitive print-options-interface [setting] +@deffn {Scheme Procedure} print-options-interface [setting] +@deffnx {C Function} scm_print_options (setting) Option interface for the print options. Instead of using this procedure directly, use the procedures @code{print-enable}, @code{print-disable}, @code{print-set!} @@ -2882,7 +3216,8 @@ and @code{print-options}. @end deffn simple-format -@deffn primitive simple-format destination message . args +@deffn {Scheme Procedure} simple-format destination message . args +@deffnx {C Function} scm_simple_format (destination, message, args) Write @var{message} to @var{destination}, defaulting to the current output port. @var{message} can contain @code{~A} (was @code{%s}) and @@ -2897,65 +3232,78 @@ containing the formatted text. Does not add a trailing newline. @end deffn newline -@deffn primitive newline [port] +@deffn {Scheme Procedure} newline [port] +@deffnx {C Function} scm_newline (port) Send a newline to @var{port}. +If @var{port} is omitted, send to the current output port. @end deffn write-char -@deffn primitive write-char chr [port] +@deffn {Scheme Procedure} write-char chr [port] +@deffnx {C Function} scm_write_char (chr, port) Send character @var{chr} to @var{port}. @end deffn port-with-print-state -@deffn primitive port-with-print-state port pstate +@deffn {Scheme Procedure} port-with-print-state port pstate +@deffnx {C Function} scm_port_with_print_state (port, pstate) Create a new port which behaves like @var{port}, but with an included print state @var{pstate}. @end deffn get-print-state -@deffn primitive get-print-state port +@deffn {Scheme Procedure} get-print-state port +@deffnx {C Function} scm_get_print_state (port) Return the print state of the port @var{port}. If @var{port} has no associated print state, @code{#f} is returned. @end deffn procedure-properties -@deffn primitive procedure-properties proc +@deffn {Scheme Procedure} procedure-properties proc +@deffnx {C Function} scm_procedure_properties (proc) Return @var{obj}'s property list. @end deffn set-procedure-properties! -@deffn primitive set-procedure-properties! proc new_val +@deffn {Scheme Procedure} set-procedure-properties! proc new_val +@deffnx {C Function} scm_set_procedure_properties_x (proc, new_val) Set @var{obj}'s property list to @var{alist}. @end deffn procedure-property -@deffn primitive procedure-property p k +@deffn {Scheme Procedure} procedure-property p k +@deffnx {C Function} scm_procedure_property (p, k) Return the property of @var{obj} with name @var{key}. @end deffn set-procedure-property! -@deffn primitive set-procedure-property! p k v +@deffn {Scheme Procedure} set-procedure-property! p k v +@deffnx {C Function} scm_set_procedure_property_x (p, k, v) In @var{obj}'s property list, set the property named @var{key} to @var{value}. @end deffn procedure? -@deffn primitive procedure? obj +@deffn {Scheme Procedure} procedure? obj +@deffnx {C Function} scm_procedure_p (obj) Return @code{#t} if @var{obj} is a procedure. @end deffn closure? -@deffn primitive closure? obj +@deffn {Scheme Procedure} closure? obj +@deffnx {C Function} scm_closure_p (obj) Return @code{#t} if @var{obj} is a closure. @end deffn thunk? -@deffn primitive thunk? obj +@deffn {Scheme Procedure} thunk? obj +@deffnx {C Function} scm_thunk_p (obj) Return @code{#t} if @var{obj} is a thunk. @end deffn procedure-documentation -@deffn primitive procedure-documentation proc +@deffn {Scheme Procedure} procedure-documentation proc +@deffnx {C Function} scm_procedure_documentation (proc) Return the documentation string associated with @code{proc}. By convention, if a procedure contains more than one expression and the first expression is a string constant, that string is assumed to contain @@ -2963,25 +3311,29 @@ documentation for that procedure. @end deffn procedure-with-setter? -@deffn primitive procedure-with-setter? obj +@deffn {Scheme Procedure} procedure-with-setter? obj +@deffnx {C Function} scm_procedure_with_setter_p (obj) Return @code{#t} if @var{obj} is a procedure with an associated setter procedure. @end deffn make-procedure-with-setter -@deffn primitive make-procedure-with-setter procedure setter +@deffn {Scheme Procedure} make-procedure-with-setter procedure setter +@deffnx {C Function} scm_make_procedure_with_setter (procedure, setter) Create a new procedure which behaves like @var{procedure}, but with the associated setter @var{setter}. @end deffn procedure -@deffn primitive procedure proc +@deffn {Scheme Procedure} procedure proc +@deffnx {C Function} scm_procedure (proc) Return the procedure of @var{proc}, which must be either a procedure with setter, or an operator struct. @end deffn primitive-make-property -@deffn primitive primitive-make-property not_found_proc +@deffn {Scheme Procedure} primitive-make-property not_found_proc +@deffnx {C Function} scm_primitive_make_property (not_found_proc) Create a @dfn{property token} that can be used with @code{primitive-property-ref} and @code{primitive-property-set!}. See @code{primitive-property-ref} for the significance of @@ -2989,7 +3341,8 @@ See @code{primitive-property-ref} for the significance of @end deffn primitive-property-ref -@deffn primitive primitive-property-ref prop obj +@deffn {Scheme Procedure} primitive-property-ref prop obj +@deffnx {C Function} scm_primitive_property_ref (prop, obj) Return the property @var{prop} of @var{obj}. When no value has yet been associated with @var{prop} and @var{obj}, call @var{not-found-proc} instead (see @code{primitive-make-property}) @@ -3000,17 +3353,20 @@ default value of @var{prop}. @end deffn primitive-property-set! -@deffn primitive primitive-property-set! prop obj val +@deffn {Scheme Procedure} primitive-property-set! prop obj val +@deffnx {C Function} scm_primitive_property_set_x (prop, obj, val) Associate @var{code} with @var{prop} and @var{obj}. @end deffn primitive-property-del! -@deffn primitive primitive-property-del! prop obj +@deffn {Scheme Procedure} primitive-property-del! prop obj +@deffnx {C Function} scm_primitive_property_del_x (prop, obj) Remove any value associated with @var{prop} and @var{obj}. @end deffn random -@deffn primitive random n [state] +@deffn {Scheme Procedure} random n [state] +@deffnx {C Function} scm_random (n, state) Return a number in [0,N). Accepts a positive integer or real n and returns a @@ -3026,23 +3382,27 @@ as a side effect of the random operation. @end deffn copy-random-state -@deffn primitive copy-random-state [state] +@deffn {Scheme Procedure} copy-random-state [state] +@deffnx {C Function} scm_copy_random_state (state) Return a copy of the random state @var{state}. @end deffn seed->random-state -@deffn primitive seed->random-state seed +@deffn {Scheme Procedure} seed->random-state seed +@deffnx {C Function} scm_seed_to_random_state (seed) Return a new random state using @var{seed}. @end deffn random:uniform -@deffn primitive random:uniform [state] +@deffn {Scheme Procedure} random:uniform [state] +@deffnx {C Function} scm_random_uniform (state) Return a uniformly distributed inexact real random number in [0,1). @end deffn random:normal -@deffn primitive random:normal [state] +@deffn {Scheme Procedure} random:normal [state] +@deffnx {C Function} scm_random_normal (state) Return an inexact real in a normal distribution. The distribution used has mean 0 and standard deviation 1. For a normal distribution with mean m and standard deviation d use @@ -3050,7 +3410,8 @@ normal distribution with mean m and standard deviation d use @end deffn random:solid-sphere! -@deffn primitive random:solid-sphere! v [state] +@deffn {Scheme Procedure} random:solid-sphere! v [state] +@deffnx {C Function} scm_random_solid_sphere_x (v, state) Fills vect with inexact real random numbers the sum of whose squares is less than 1.0. Thinking of vect as coordinates in space of @@ -3060,7 +3421,8 @@ The sum of the squares of the numbers is returned. @end deffn random:hollow-sphere! -@deffn primitive random:hollow-sphere! v [state] +@deffn {Scheme Procedure} random:hollow-sphere! v [state] +@deffnx {C Function} scm_random_hollow_sphere_x (v, state) Fills vect with inexact real random numbers the sum of whose squares is equal to 1.0. Thinking of vect as coordinates in space of @@ -3070,21 +3432,24 @@ unit n-sphere. @end deffn random:normal-vector! -@deffn primitive random:normal-vector! v [state] +@deffn {Scheme Procedure} random:normal-vector! v [state] +@deffnx {C Function} scm_random_normal_vector_x (v, state) Fills vect with inexact real random numbers that are independent and standard normally distributed (i.e., with mean 0 and variance 1). @end deffn random:exp -@deffn primitive random:exp [state] +@deffn {Scheme Procedure} random:exp [state] +@deffnx {C Function} scm_random_exp (state) Return an inexact real in an exponential distribution with mean 1. For an exponential distribution with mean u use (* u (random:exp)). @end deffn %read-delimited! -@deffn primitive %read-delimited! delims str gobble [port [start [end]]] +@deffn {Scheme Procedure} %read-delimited! delims str gobble [port [start [end]]] +@deffnx {C Function} scm_read_delimited_x (delims, str, gobble, port, start, end) Read characters from @var{port} into @var{str} until one of the characters in the @var{delims} string is encountered. If @var{gobble} is true, discard the delimiter character; @@ -3103,7 +3468,8 @@ a delimiter, this value is @code{#f}. @end deffn %read-line -@deffn primitive %read-line [port] +@deffn {Scheme Procedure} %read-line [port] +@deffnx {C Function} scm_read_line (port) Read a newline-terminated line from @var{port}, allocating storage as necessary. The newline terminator (if any) is removed from the string, and a pair consisting of the line and its delimiter is returned. The @@ -3113,7 +3479,8 @@ delimiter may be either a newline or the @var{eof-object}; if @end deffn write-line -@deffn primitive write-line obj [port] +@deffn {Scheme Procedure} write-line obj [port] +@deffnx {C Function} scm_write_line (obj, port) Display @var{obj} and a newline character to @var{port}. If @var{port} is not specified, @code{(current-output-port)} is used. This function is equivalent to: @@ -3124,21 +3491,24 @@ used. This function is equivalent to: @end deffn read-options-interface -@deffn primitive read-options-interface [setting] +@deffn {Scheme Procedure} read-options-interface [setting] +@deffnx {C Function} scm_read_options (setting) Option interface for the read options. Instead of using this procedure directly, use the procedures @code{read-enable}, @code{read-disable}, @code{read-set!} and @var{read-options}. @end deffn read -@deffn primitive read [port] +@deffn {Scheme Procedure} read [port] +@deffnx {C Function} scm_read (port) Read an s-expression from the input port @var{port}, or from the current input port if @var{port} is not specified. Any whitespace before the next token is discarded. @end deffn read-hash-extend -@deffn primitive read-hash-extend chr proc +@deffn {Scheme Procedure} read-hash-extend chr proc +@deffnx {C Function} scm_read_hash_extend (chr, proc) Install the procedure @var{proc} for reading expressions starting with the character sequence @code{#} and @var{chr}. @var{proc} will be called with two arguments: the character @@ -3147,7 +3517,8 @@ returned will be the return value of @code{read}. @end deffn call-with-dynamic-root -@deffn primitive call-with-dynamic-root thunk handler +@deffn {Scheme Procedure} call-with-dynamic-root thunk handler +@deffnx {C Function} scm_call_with_dynamic_root (thunk, handler) Evaluate @code{(thunk)} in a new dynamic context, returning its value. If an error occurs during evaluation, apply @var{handler} to the @@ -3193,7 +3564,8 @@ be under a new dynamic root.) @end deffn dynamic-root -@deffn primitive dynamic-root +@deffn {Scheme Procedure} dynamic-root +@deffnx {C Function} scm_dynamic_root () Return an object representing the current dynamic root. These objects are only useful for comparison using @code{eq?}. @@ -3202,7 +3574,8 @@ in no way depend on this. @end deffn read-string!/partial -@deffn primitive read-string!/partial str [port_or_fdes [start [end]]] +@deffn {Scheme Procedure} read-string!/partial str [port_or_fdes [start [end]]] +@deffnx {C Function} scm_read_string_x_partial (str, port_or_fdes, start, end) Read characters from a port or file descriptor into a string @var{str}. A port must have an underlying file descriptor --- a so-called fport. This procedure is @@ -3243,7 +3616,8 @@ end-of-file check. @end deffn write-string/partial -@deffn primitive write-string/partial str [port_or_fdes [start [end]]] +@deffn {Scheme Procedure} write-string/partial str [port_or_fdes [start [end]]] +@deffnx {C Function} scm_write_string_partial (str, port_or_fdes, start, end) Write characters from a string @var{str} to a port or file descriptor. A port must have an underlying file descriptor --- a so-called fport. This procedure is @@ -3288,7 +3662,8 @@ return 0 immediately if the request size is 0 bytes. @end deffn sigaction -@deffn primitive sigaction signum [handler [flags]] +@deffn {Scheme Procedure} sigaction signum [handler [flags]] +@deffnx {C Function} scm_sigaction (signum, handler, flags) Install or report the signal handler for a specified signal. @var{signum} is the signal number, which can be specified using the value @@ -3318,13 +3693,15 @@ structures. @end deffn restore-signals -@deffn primitive restore-signals +@deffn {Scheme Procedure} restore-signals +@deffnx {C Function} scm_restore_signals () Return all signal handlers to the values they had before any call to @code{sigaction} was made. The return value is unspecified. @end deffn alarm -@deffn primitive alarm i +@deffn {Scheme Procedure} alarm i +@deffnx {C Function} scm_alarm (i) Set a timer to raise a @code{SIGALRM} signal after the specified number of seconds (an integer). It's advisable to install a signal handler for @@ -3337,7 +3714,8 @@ no previous alarm, the return value is zero. @end deffn setitimer -@deffn primitive setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds +@deffn {Scheme Procedure} setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds +@deffnx {C Function} scm_setitimer (which_timer, interval_seconds, interval_microseconds, value_seconds, value_microseconds) Set the timer specified by @var{which_timer} according to the given @var{interval_seconds}, @var{interval_microseconds}, @var{value_seconds}, and @var{value_microseconds} values. @@ -3356,7 +3734,8 @@ the seconds and microseconds of the timer @code{it_value}. @end deffn getitimer -@deffn primitive getitimer which_timer +@deffn {Scheme Procedure} getitimer which_timer +@deffnx {C Function} scm_getitimer (which_timer) Return information about the timer specified by @var{which_timer} Errors are handled as described in the guile info pages under ``POSIX Interface Conventions''. @@ -3371,33 +3750,38 @@ the seconds and microseconds of the timer @code{it_value}. @end deffn pause -@deffn primitive pause +@deffn {Scheme Procedure} pause +@deffnx {C Function} scm_pause () Pause the current process (thread?) until a signal arrives whose action is to either terminate the current process or invoke a handler procedure. The return value is unspecified. @end deffn sleep -@deffn primitive sleep i +@deffn {Scheme Procedure} sleep i +@deffnx {C Function} scm_sleep (i) Wait for the given number of seconds (an integer) or until a signal arrives. The return value is zero if the time elapses or the number of seconds remaining otherwise. @end deffn usleep -@deffn primitive usleep i +@deffn {Scheme Procedure} usleep i +@deffnx {C Function} scm_usleep (i) Sleep for I microseconds. @code{usleep} is not available on all platforms. @end deffn raise -@deffn primitive raise sig +@deffn {Scheme Procedure} raise sig +@deffnx {C Function} scm_raise (sig) Sends a specified signal @var{sig} to the current process, where @var{sig} is as described for the kill procedure. @end deffn system -@deffn primitive system [cmd] +@deffn {Scheme Procedure} system [cmd] +@deffnx {C Function} scm_system (cmd) Execute @var{cmd} using the operating system's "command processor". Under Unix this is usually the default shell @code{sh}. The value returned is @var{cmd}'s exit status as @@ -3409,21 +3793,24 @@ indicating whether the command processor is available. @end deffn getenv -@deffn primitive getenv nam +@deffn {Scheme Procedure} getenv nam +@deffnx {C Function} scm_getenv (nam) Looks up the string @var{name} in the current environment. The return value is @code{#f} unless a string of the form @code{NAME=VALUE} is found, in which case the string @code{VALUE} is returned. @end deffn primitive-exit -@deffn primitive primitive-exit [status] +@deffn {Scheme Procedure} primitive-exit [status] +@deffnx {C Function} scm_primitive_exit (status) Terminate the current process without unwinding the Scheme stack. This is would typically be useful after a fork. The exit status is @var{status} if supplied, otherwise zero. @end deffn restricted-vector-sort! -@deffn primitive restricted-vector-sort! vec less startpos endpos +@deffn {Scheme Procedure} restricted-vector-sort! vec less startpos endpos +@deffnx {C Function} scm_restricted_vector_sort_x (vec, less, startpos, endpos) Sort the vector @var{vec}, using @var{less} for comparing the vector elements. @var{startpos} and @var{endpos} delimit the range of the vector which gets sorted. The return value @@ -3431,24 +3818,28 @@ is not specified. @end deffn sorted? -@deffn primitive sorted? items less +@deffn {Scheme Procedure} sorted? items less +@deffnx {C Function} scm_sorted_p (items, less) Return @code{#t} iff @var{items} is a list or a vector such that for all 1 <= i <= m, the predicate @var{less} returns true when applied to all elements i - 1 and i @end deffn merge -@deffn primitive merge alist blist less -Takes two lists @var{alist} and @var{blist} such that -@code{(sorted? alist less?)} and @code{(sorted? blist less?)} and -returns a new list in which the elements of @var{alist} and +@deffn {Scheme Procedure} merge alist blist less +@deffnx {C Function} scm_merge (alist, blist, less) +Merge two already sorted lists into one. +Given two lists @var{alist} and @var{blist}, such that +@code{(sorted? alist less?)} and @code{(sorted? blist less?)}, +return a new list in which the elements of @var{alist} and @var{blist} have been stably interleaved so that @code{(sorted? (merge alist blist less?) less?)}. Note: this does _not_ accept vectors. @end deffn merge! -@deffn primitive merge! alist blist less +@deffn {Scheme Procedure} merge! alist blist less +@deffnx {C Function} scm_merge_x (alist, blist, less) Takes two lists @var{alist} and @var{blist} such that @code{(sorted? alist less?)} and @code{(sorted? blist less?)} and returns a new list in which the elements of @var{alist} and @@ -3459,7 +3850,8 @@ Note: this does _not_ accept vectors. @end deffn sort! -@deffn primitive sort! items less +@deffn {Scheme Procedure} sort! items less +@deffnx {C Function} scm_sort_x (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. The sorting is destructive, that means that the @@ -3468,14 +3860,16 @@ This is not a stable sort. @end deffn sort -@deffn primitive sort items less +@deffn {Scheme Procedure} sort items less +@deffnx {C Function} scm_sort (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. This is not a stable sort. @end deffn stable-sort! -@deffn primitive stable-sort! items less +@deffn {Scheme Procedure} stable-sort! items less +@deffnx {C Function} scm_stable_sort_x (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. The sorting is destructive, that means that the input sequence @@ -3484,14 +3878,16 @@ This is a stable sort. @end deffn stable-sort -@deffn primitive stable-sort items less +@deffn {Scheme Procedure} stable-sort items less +@deffnx {C Function} scm_stable_sort (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. This is a stable sort. @end deffn sort-list! -@deffn primitive sort-list! items less +@deffn {Scheme Procedure} sort-list! items less +@deffnx {C Function} scm_sort_list_x (items, less) Sort the list @var{items}, using @var{less} for comparing the list elements. The sorting is destructive, that means that the input list is modified to produce the sorted result. @@ -3499,41 +3895,48 @@ This is a stable sort. @end deffn sort-list -@deffn primitive sort-list items less +@deffn {Scheme Procedure} sort-list items less +@deffnx {C Function} scm_sort_list (items, less) Sort the list @var{items}, using @var{less} for comparing the list elements. This is a stable sort. @end deffn source-properties -@deffn primitive source-properties obj +@deffn {Scheme Procedure} source-properties obj +@deffnx {C Function} scm_source_properties (obj) Return the source property association list of @var{obj}. @end deffn set-source-properties! -@deffn primitive set-source-properties! obj plist +@deffn {Scheme Procedure} set-source-properties! obj plist +@deffnx {C Function} scm_set_source_properties_x (obj, plist) Install the association list @var{plist} as the source property list for @var{obj}. @end deffn source-property -@deffn primitive source-property obj key +@deffn {Scheme Procedure} source-property obj key +@deffnx {C Function} scm_source_property (obj, key) Return the source property specified by @var{key} from @var{obj}'s source property list. @end deffn set-source-property! -@deffn primitive set-source-property! obj key datum +@deffn {Scheme Procedure} set-source-property! obj key datum +@deffnx {C Function} scm_set_source_property_x (obj, key, datum) Set the source property of object @var{obj}, which is specified by @var{key} to @var{datum}. Normally, the key will be a symbol. @end deffn stack? -@deffn primitive stack? obj +@deffn {Scheme Procedure} stack? obj +@deffnx {C Function} scm_stack_p (obj) Return @code{#t} if @var{obj} is a calling stack. @end deffn make-stack -@deffn primitive make-stack obj . args +@deffn {Scheme Procedure} make-stack obj . args +@deffnx {C Function} scm_make_stack (obj, args) Create a new stack. If @var{obj} is @code{#t}, the current evaluation stack is used for creating the stack frames, otherwise the frames are taken from @var{obj} (which must be @@ -3565,93 +3968,110 @@ taken as 0. @end deffn stack-id -@deffn primitive stack-id stack +@deffn {Scheme Procedure} stack-id stack +@deffnx {C Function} scm_stack_id (stack) Return the identifier given to @var{stack} by @code{start-stack}. @end deffn stack-ref -@deffn primitive stack-ref stack index +@deffn {Scheme Procedure} stack-ref stack index +@deffnx {C Function} scm_stack_ref (stack, index) Return the @var{index}'th frame from @var{stack}. @end deffn stack-length -@deffn primitive stack-length stack +@deffn {Scheme Procedure} stack-length stack +@deffnx {C Function} scm_stack_length (stack) Return the length of @var{stack}. @end deffn frame? -@deffn primitive frame? obj +@deffn {Scheme Procedure} frame? obj +@deffnx {C Function} scm_frame_p (obj) Return @code{#t} if @var{obj} is a stack frame. @end deffn last-stack-frame -@deffn primitive last-stack-frame obj +@deffn {Scheme Procedure} last-stack-frame obj +@deffnx {C Function} scm_last_stack_frame (obj) Return a stack which consists of a single frame, which is the last stack frame for @var{obj}. @var{obj} must be either a debug object or a continuation. @end deffn frame-number -@deffn primitive frame-number frame +@deffn {Scheme Procedure} frame-number frame +@deffnx {C Function} scm_frame_number (frame) Return the frame number of @var{frame}. @end deffn frame-source -@deffn primitive frame-source frame +@deffn {Scheme Procedure} frame-source frame +@deffnx {C Function} scm_frame_source (frame) Return the source of @var{frame}. @end deffn frame-procedure -@deffn primitive frame-procedure frame +@deffn {Scheme Procedure} frame-procedure frame +@deffnx {C Function} scm_frame_procedure (frame) Return the procedure for @var{frame}, or @code{#f} if no procedure is associated with @var{frame}. @end deffn frame-arguments -@deffn primitive frame-arguments frame +@deffn {Scheme Procedure} frame-arguments frame +@deffnx {C Function} scm_frame_arguments (frame) Return the arguments of @var{frame}. @end deffn frame-previous -@deffn primitive frame-previous frame +@deffn {Scheme Procedure} frame-previous frame +@deffnx {C Function} scm_frame_previous (frame) Return the previous frame of @var{frame}, or @code{#f} if @var{frame} is the first frame in its stack. @end deffn frame-next -@deffn primitive frame-next frame +@deffn {Scheme Procedure} frame-next frame +@deffnx {C Function} scm_frame_next (frame) Return the next frame of @var{frame}, or @code{#f} if @var{frame} is the last frame in its stack. @end deffn frame-real? -@deffn primitive frame-real? frame +@deffn {Scheme Procedure} frame-real? frame +@deffnx {C Function} scm_frame_real_p (frame) Return @code{#t} if @var{frame} is a real frame. @end deffn frame-procedure? -@deffn primitive frame-procedure? frame +@deffn {Scheme Procedure} frame-procedure? frame +@deffnx {C Function} scm_frame_procedure_p (frame) Return @code{#t} if a procedure is associated with @var{frame}. @end deffn frame-evaluating-args? -@deffn primitive frame-evaluating-args? frame +@deffn {Scheme Procedure} frame-evaluating-args? frame +@deffnx {C Function} scm_frame_evaluating_args_p (frame) Return @code{#t} if @var{frame} contains evaluated arguments. @end deffn frame-overflow? -@deffn primitive frame-overflow? frame +@deffn {Scheme Procedure} frame-overflow? frame +@deffnx {C Function} scm_frame_overflow_p (frame) Return @code{#t} if @var{frame} is an overflow frame. @end deffn get-internal-real-time -@deffn primitive get-internal-real-time +@deffn {Scheme Procedure} get-internal-real-time +@deffnx {C Function} scm_get_internal_real_time () Return the number of time units since the interpreter was started. @end deffn times -@deffn primitive times +@deffn {Scheme Procedure} times +@deffnx {C Function} scm_times () Return an object with information about real and processor time. The following procedures accept such an object as an argument and return a selected component: @@ -3676,20 +4096,23 @@ terminated child processes. @end deffn get-internal-run-time -@deffn primitive get-internal-run-time +@deffn {Scheme Procedure} get-internal-run-time +@deffnx {C Function} scm_get_internal_run_time () Return the number of time units of processor time used by the interpreter. Both @emph{system} and @emph{user} time are included but subprocesses are not. @end deffn current-time -@deffn primitive current-time +@deffn {Scheme Procedure} current-time +@deffnx {C Function} scm_current_time () Return the number of seconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. @end deffn gettimeofday -@deffn primitive gettimeofday +@deffn {Scheme Procedure} gettimeofday +@deffnx {C Function} scm_gettimeofday () Return a pair containing the number of seconds and microseconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note: whether true microsecond resolution is available depends on the @@ -3697,7 +4120,8 @@ operating system. @end deffn localtime -@deffn primitive localtime time [zone] +@deffn {Scheme Procedure} localtime time [zone] +@deffnx {C Function} scm_localtime (time, zone) Return an object representing the broken down components of @var{time}, an integer like the one returned by @code{current-time}. The time zone for the calculation is @@ -3706,14 +4130,16 @@ optionally specified by @var{zone} (a string), otherwise the @end deffn gmtime -@deffn primitive gmtime time +@deffn {Scheme Procedure} gmtime time +@deffnx {C Function} scm_gmtime (time) Return an object representing the broken down components of @var{time}, an integer like the one returned by @code{current-time}. The values are calculated for UTC. @end deffn mktime -@deffn primitive mktime sbd_time [zone] +@deffn {Scheme Procedure} mktime sbd_time [zone] +@deffnx {C Function} scm_mktime (sbd_time, zone) @var{bd-time} is an object representing broken down time and @code{zone} is an optional time zone specifier (otherwise the TZ environment variable or the system default is used). @@ -3725,7 +4151,8 @@ as @var{bd-time} but with normalized values. @end deffn tzset -@deffn primitive tzset +@deffn {Scheme Procedure} tzset +@deffnx {C Function} scm_tzset () Initialize the timezone from the TZ environment variable or the system default. It's not usually necessary to call this procedure since it's done automatically by other procedures that depend on the @@ -3733,7 +4160,8 @@ timezone. @end deffn strftime -@deffn primitive strftime format stime +@deffn {Scheme Procedure} strftime format stime +@deffnx {C Function} scm_strftime (format, stime) Formats a time specification @var{time} using @var{template}. @var{time} is an object with time components in the form returned by @code{localtime} or @code{gmtime}. @var{template} is a string which can include formatting @@ -3744,7 +4172,8 @@ is the formatted string. @end deffn strptime -@deffn primitive strptime format string +@deffn {Scheme Procedure} strptime format string +@deffnx {C Function} scm_strptime (format, string) Performs the reverse action to @code{strftime}, parsing @var{string} according to the specification supplied in @var{template}. The interpretation of month and day names is @@ -3758,25 +4187,27 @@ which were used for the conversion. @end deffn string? -@deffn primitive string? obj -Return @code{#t} iff @var{obj} is a string, else returns -@code{#f}. +@deffn {Scheme Procedure} string? obj +@deffnx {C Function} scm_string_p (obj) +Return @code{#t} iff @var{obj} is a string, else @code{#f}. @end deffn list->string -@deffn primitive list->string +@deffn {Scheme Procedure} list->string implemented by the C function "scm_string" @end deffn string -@deffn primitive string . chrs -@deffnx primitive list->string chrs +@deffn {Scheme Procedure} string . chrs +@deffnx {Scheme Procedure} list->string chrs +@deffnx {C Function} scm_string (chrs) Return a newly allocated string composed of the arguments, @var{chrs}. @end deffn make-string -@deffn primitive make-string k [chr] +@deffn {Scheme Procedure} make-string k [chr] +@deffnx {C Function} scm_make_string (k, chr) Return a newly allocated string of length @var{k}. If @var{chr} is given, then all elements of the string are initialized to @var{chr}, otherwise the contents @@ -3784,25 +4215,29 @@ of the @var{string} are unspecified. @end deffn string-length -@deffn primitive string-length string +@deffn {Scheme Procedure} string-length string +@deffnx {C Function} scm_string_length (string) Return the number of characters in @var{string}. @end deffn string-ref -@deffn primitive string-ref str k +@deffn {Scheme Procedure} string-ref str k +@deffnx {C Function} scm_string_ref (str, k) Return character @var{k} of @var{str} using zero-origin indexing. @var{k} must be a valid index of @var{str}. @end deffn string-set! -@deffn primitive string-set! str k chr +@deffn {Scheme Procedure} string-set! str k chr +@deffnx {C Function} scm_string_set_x (str, k, chr) Store @var{chr} in element @var{k} of @var{str} and return an unspecified value. @var{k} must be a valid index of @var{str}. @end deffn substring -@deffn primitive substring str start [end] +@deffn {Scheme Procedure} substring str start [end] +@deffnx {C Function} scm_substring (str, start, end) Return a newly allocated string formed from the characters of @var{str} beginning with index @var{start} (inclusive) and ending with index @var{end} (exclusive). @@ -3813,13 +4248,15 @@ exact integers satisfying: @end deffn string-append -@deffn primitive string-append . args +@deffn {Scheme Procedure} string-append . args +@deffnx {C Function} scm_string_append (args) Return a newly allocated string whose characters form the concatenation of the given strings, @var{args}. @end deffn string-index -@deffn primitive string-index str chr [frm [to]] +@deffn {Scheme Procedure} string-index str chr [frm [to]] +@deffnx {C Function} scm_string_index (str, chr, frm, to) Return the index of the first occurrence of @var{chr} in @var{str}. The optional integer arguments @var{frm} and @var{to} limit the search to a portion of the string. This @@ -3839,7 +4276,8 @@ procedure essentially implements the @code{index} or @end deffn string-rindex -@deffn primitive string-rindex str chr [frm [to]] +@deffn {Scheme Procedure} string-rindex str chr [frm [to]] +@deffnx {C Function} scm_string_rindex (str, chr, frm, to) Like @code{string-index}, but search from the right of the string rather than from the left. This procedure essentially implements the @code{rindex} or @code{strrchr} functions from @@ -3857,40 +4295,17 @@ the C library. @end lisp @end deffn - substring-move-left! -@deffn primitive substring-move-left! -implemented by the C function "scm_substring_move_x" -@end deffn - - substring-move-right! -@deffn primitive substring-move-right! -implemented by the C function "scm_substring_move_x" -@end deffn - substring-move! -@deffn primitive substring-move! str1 start1 end1 str2 start2 -@deffnx primitive substring-move-left! str1 start1 end1 str2 start2 -@deffnx primitive substring-move-right! str1 start1 end1 str2 start2 +@deffn {Scheme Procedure} substring-move! str1 start1 end1 str2 start2 +@deffnx {C Function} scm_substring_move_x (str1, start1, end1, str2, start2) Copy the substring of @var{str1} bounded by @var{start1} and @var{end1} into @var{str2} beginning at position @var{start2}. -@code{substring-move-right!} begins copying from the rightmost character -and moves left, and @code{substring-move-left!} copies from the leftmost -character moving right. - -It is useful to have two functions that copy in different directions so -that substrings can be copied back and forth within a single string. If -you wish to copy text from the left-hand side of a string to the -right-hand side of the same string, and the source and destination -overlap, you must be careful to copy the rightmost characters of the -text first, to avoid clobbering your data. Hence, when @var{str1} and -@var{str2} are the same string, you should use -@code{substring-move-right!} when moving text from left to right, and -@code{substring-move-left!} otherwise. If @code{str1} and @samp{str2} -are different strings, it does not matter which function you use. +@var{str1} and @var{str2} can be the same string. @end deffn substring-fill! -@deffn primitive substring-fill! str start end fill +@deffn {Scheme Procedure} substring-fill! str start end fill +@deffnx {C Function} scm_substring_fill_x (str, start, end, fill) Change every character in @var{str} between @var{start} and @var{end} to @var{fill}. @@ -3903,7 +4318,8 @@ y @end deffn string-null? -@deffn primitive string-null? str +@deffn {Scheme Procedure} string-null? str +@deffnx {C Function} scm_string_null_p (str) Return @code{#t} if @var{str}'s length is zero, and @code{#f} otherwise. @lisp @@ -3914,7 +4330,8 @@ y @result{} "foo" @end deffn string->list -@deffn primitive string->list str +@deffn {Scheme Procedure} string->list str +@deffnx {C Function} scm_string_to_list (str) Return a newly allocated list of the characters that make up the given string @var{str}. @code{string->list} and @code{list->string} are inverses as far as @samp{equal?} is @@ -3922,18 +4339,21 @@ concerned. @end deffn string-copy -@deffn primitive string-copy str +@deffn {Scheme Procedure} string-copy str +@deffnx {C Function} scm_string_copy (str) Return a newly allocated copy of the given @var{string}. @end deffn string-fill! -@deffn primitive string-fill! str chr +@deffn {Scheme Procedure} string-fill! str chr +@deffnx {C Function} scm_string_fill_x (str, chr) Store @var{char} in every element of the given @var{string} and return an unspecified value. @end deffn string-upcase! -@deffn primitive string-upcase! str +@deffn {Scheme Procedure} string-upcase! str +@deffnx {C Function} scm_string_upcase_x (str) Destructively upcase every character in @var{str} and return @var{str}. @lisp @@ -3944,13 +4364,15 @@ y @result{} "ARRDEFG" @end deffn string-upcase -@deffn primitive string-upcase str +@deffn {Scheme Procedure} string-upcase str +@deffnx {C Function} scm_string_upcase (str) Return a freshly allocated string containing the characters of @var{str} in upper case. @end deffn string-downcase! -@deffn primitive string-downcase! str +@deffn {Scheme Procedure} string-downcase! str +@deffnx {C Function} scm_string_downcase_x (str) Destructively downcase every character in @var{str} and return @var{str}. @lisp @@ -3961,13 +4383,15 @@ y @result{} "arrdefg" @end deffn string-downcase -@deffn primitive string-downcase str +@deffn {Scheme Procedure} string-downcase str +@deffnx {C Function} scm_string_downcase (str) Return a freshly allocation string containing the characters in @var{str} in lower case. @end deffn string-capitalize! -@deffn primitive string-capitalize! str +@deffn {Scheme Procedure} string-capitalize! str +@deffnx {C Function} scm_string_capitalize_x (str) Upcase the first character of every word in @var{str} destructively and return @var{str}. @@ -3979,43 +4403,46 @@ y @result{} "Hello World" @end deffn string-capitalize -@deffn primitive string-capitalize str +@deffn {Scheme Procedure} string-capitalize str +@deffnx {C Function} scm_string_capitalize (str) Return a freshly allocated string with the characters in @var{str}, where the first character of every word is capitalized. @end deffn string-split -@deffn primitive string-split str chr +@deffn {Scheme Procedure} string-split str chr +@deffnx {C Function} scm_string_split (str, chr) Split the string @var{str} into the a list of the substrings delimited by appearances of the character @var{chr}. Note that an empty substring between separator characters will result in an empty string in the result list. @lisp -(string-split "root:x:0:0:root:/root:/bin/bash" #:) +(string-split "root:x:0:0:root:/root:/bin/bash" #\:) @result{} ("root" "x" "0" "0" "root" "/root" "/bin/bash") -(string-split "::" #:) +(string-split "::" #\:) @result{} ("" "" "") -(string-split "" #:) +(string-split "" #\:) @result{} ("") @end lisp @end deffn string-ci->symbol -@deffn primitive string-ci->symbol str +@deffn {Scheme Procedure} string-ci->symbol str +@deffnx {C Function} scm_string_ci_to_symbol (str) Return the symbol whose name is @var{str}. @var{str} is converted to lowercase before the conversion is done, if Guile -is currently reading symbols case--insensitively. +is currently reading symbols case-insensitively. @end deffn string=? -@deffn primitive string=? s1 s2 +@deffn {Scheme Procedure} string=? s1 s2 Lexicographic equality predicate; return @code{#t} if the two strings are the same length and contain the same characters in the same positions, otherwise return @code{#f}. @@ -4027,7 +4454,7 @@ characters. @end deffn string-ci=? -@deffn primitive string-ci=? s1 s2 +@deffn {Scheme Procedure} string-ci=? s1 s2 Case-insensitive string equality predicate; return @code{#t} if the two strings are the same length and their component characters match (ignoring case) at each position; otherwise @@ -4035,80 +4462,84 @@ return @code{#f}. @end deffn string? -@deffn primitive string>? s1 s2 +@deffn {Scheme Procedure} string>? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @var{s2}. @end deffn string>=? -@deffn primitive string>=? s1 s2 +@deffn {Scheme Procedure} string>=? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or equal to @var{s2}. @end deffn string-ci? -@deffn primitive string-ci>? s1 s2 +@deffn {Scheme Procedure} string-ci>? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @var{s2} regardless of case. @end deffn string-ci>=? -@deffn primitive string-ci>=? s1 s2 +@deffn {Scheme Procedure} string-ci>=? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or equal to @var{s2} regardless of case. @end deffn object->string -@deffn primitive object->string obj [printer] +@deffn {Scheme Procedure} object->string obj [printer] +@deffnx {C Function} scm_object_to_string (obj, printer) Return a Scheme string obtained by printing @var{obj}. Printing function can be specified by the optional second argument @var{printer} (default: @code{write}). @end deffn call-with-output-string -@deffn primitive call-with-output-string proc +@deffn {Scheme Procedure} call-with-output-string proc +@deffnx {C Function} scm_call_with_output_string (proc) Calls the one-argument procedure @var{proc} with a newly created output port. When the function returns, the string composed of the characters written into the port is returned. @end deffn call-with-input-string -@deffn primitive call-with-input-string string proc +@deffn {Scheme Procedure} call-with-input-string string proc +@deffnx {C Function} scm_call_with_input_string (string, proc) Calls the one-argument procedure @var{proc} with a newly created input port from which @var{string}'s contents may be read. The value yielded by the @var{proc} is returned. @end deffn open-input-string -@deffn primitive open-input-string str +@deffn {Scheme Procedure} open-input-string str +@deffnx {C Function} scm_open_input_string (str) Take a string and return an input port that delivers characters from the string. The port can be closed by @code{close-input-port}, though its storage will be reclaimed @@ -4116,7 +4547,8 @@ by the garbage collector if it becomes inaccessible. @end deffn open-output-string -@deffn primitive open-output-string +@deffn {Scheme Procedure} open-output-string +@deffnx {C Function} scm_open_output_string () Return an output port that will accumulate characters for retrieval by @code{get-output-string}. The port can be closed by the procedure @code{close-output-port}, though its storage @@ -4125,14 +4557,16 @@ inaccessible. @end deffn get-output-string -@deffn primitive get-output-string port +@deffn {Scheme Procedure} get-output-string port +@deffnx {C Function} scm_get_output_string (port) Given an output port created by @code{open-output-string}, return a string consisting of the characters that have been output to the port so far. @end deffn eval-string -@deffn primitive eval-string string +@deffn {Scheme Procedure} eval-string string +@deffnx {C Function} scm_eval_string (string) Evaluate @var{string} as the text representation of a Scheme form or forms, and return whatever value they produce. Evaluation takes place in the environment returned by the @@ -4140,7 +4574,8 @@ procedure @code{interaction-environment}. @end deffn make-struct-layout -@deffn primitive make-struct-layout fields +@deffn {Scheme Procedure} make-struct-layout fields +@deffnx {C Function} scm_make_struct_layout (fields) Return a new structure layout object. @var{fields} must be a string made up of pairs of characters @@ -4154,18 +4589,21 @@ indicate that the field is a tail-array. @end deffn struct? -@deffn primitive struct? x +@deffn {Scheme Procedure} struct? x +@deffnx {C Function} scm_struct_p (x) Return @code{#t} iff @var{x} is a structure object, else @code{#f}. @end deffn struct-vtable? -@deffn primitive struct-vtable? x +@deffn {Scheme Procedure} struct-vtable? x +@deffnx {C Function} scm_struct_vtable_p (x) Return @code{#t} iff @var{x} is a vtable structure. @end deffn make-struct -@deffn primitive make-struct vtable tail_array_size . init +@deffn {Scheme Procedure} make-struct vtable tail_array_size . init +@deffnx {C Function} scm_make_struct (vtable, tail_array_size, init) Create a new structure. @var{type} must be a vtable structure (@pxref{Vtables}). @@ -4194,7 +4632,8 @@ For more information, see the documentation for @code{make-vtable-vtable}. @end deffn make-vtable-vtable -@deffn primitive make-vtable-vtable user_fields tail_array_size . init +@deffn {Scheme Procedure} make-vtable-vtable user_fields tail_array_size . init +@deffnx {C Function} scm_make_vtable_vtable (user_fields, tail_array_size, init) Return a new, self-describing vtable structure. @var{user-fields} is a string describing user defined fields of the @@ -4254,8 +4693,9 @@ ball @result{} # @end deffn struct-ref -@deffn primitive struct-ref handle pos -@deffnx primitive struct-set! struct n value +@deffn {Scheme Procedure} struct-ref handle pos +@deffnx {Scheme Procedure} struct-set! struct n value +@deffnx {C Function} scm_struct_ref (handle, pos) Access (or modify) the @var{n}th field of @var{struct}. If the field is of type 'p', then it can be set to an arbitrary value. @@ -4265,40 +4705,47 @@ integer value small enough to fit in one machine word. @end deffn struct-set! -@deffn primitive struct-set! handle pos val +@deffn {Scheme Procedure} struct-set! handle pos val +@deffnx {C Function} scm_struct_set_x (handle, pos, val) Set the slot of the structure @var{handle} with index @var{pos} to @var{val}. Signal an error if the slot can not be written to. @end deffn struct-vtable -@deffn primitive struct-vtable handle +@deffn {Scheme Procedure} struct-vtable handle +@deffnx {C Function} scm_struct_vtable (handle) Return the vtable structure that describes the type of @var{struct}. @end deffn struct-vtable-tag -@deffn primitive struct-vtable-tag handle +@deffn {Scheme Procedure} struct-vtable-tag handle +@deffnx {C Function} scm_struct_vtable_tag (handle) Return the vtable tag of the structure @var{handle}. @end deffn struct-vtable-name -@deffn primitive struct-vtable-name vtable +@deffn {Scheme Procedure} struct-vtable-name vtable +@deffnx {C Function} scm_struct_vtable_name (vtable) Return the name of the vtable @var{vtable}. @end deffn set-struct-vtable-name! -@deffn primitive set-struct-vtable-name! vtable name +@deffn {Scheme Procedure} set-struct-vtable-name! vtable name +@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name) Set the name of the vtable @var{vtable} to @var{name}. @end deffn symbol? -@deffn primitive symbol? obj +@deffn {Scheme Procedure} symbol? obj +@deffnx {C Function} scm_symbol_p (obj) Return @code{#t} if @var{obj} is a symbol, otherwise return @code{#f}. @end deffn symbol->string -@deffn primitive symbol->string s +@deffn {Scheme Procedure} symbol->string s +@deffnx {C Function} scm_symbol_to_string (s) Return the name of @var{symbol} as a string. If the symbol was part of an object returned as the value of a literal expression (section @pxref{Literal expressions,,,r5rs, The Revised^5 @@ -4325,7 +4772,8 @@ standard case is lower case: @end deffn string->symbol -@deffn primitive string->symbol string +@deffn {Scheme Procedure} string->symbol string +@deffnx {C Function} scm_string_to_symbol (string) Return the symbol whose name is @var{string}. This procedure can create symbols with names containing special characters or letters in the non-standard case, but it is usually a bad idea @@ -4349,7 +4797,8 @@ standard case is lower case: @end deffn gensym -@deffn primitive gensym [prefix] +@deffn {Scheme Procedure} gensym [prefix] +@deffnx {C Function} scm_gensym (prefix) Create a new symbol with a name constructed from a prefix and a counter value. The string @var{prefix} can be specified as an optional argument. Default prefix is @code{g}. The counter @@ -4358,32 +4807,38 @@ resetting the counter. @end deffn symbol-hash -@deffn primitive symbol-hash symbol +@deffn {Scheme Procedure} symbol-hash symbol +@deffnx {C Function} scm_symbol_hash (symbol) Return a hash value for @var{symbol}. @end deffn symbol-fref -@deffn primitive symbol-fref s +@deffn {Scheme Procedure} symbol-fref s +@deffnx {C Function} scm_symbol_fref (s) Return the contents of @var{symbol}'s @dfn{function slot}. @end deffn symbol-pref -@deffn primitive symbol-pref s +@deffn {Scheme Procedure} symbol-pref s +@deffnx {C Function} scm_symbol_pref (s) Return the @dfn{property list} currently associated with @var{symbol}. @end deffn symbol-fset! -@deffn primitive symbol-fset! s val +@deffn {Scheme Procedure} symbol-fset! s val +@deffnx {C Function} scm_symbol_fset_x (s, val) Change the binding of @var{symbol}'s function slot. @end deffn symbol-pset! -@deffn primitive symbol-pset! s val +@deffn {Scheme Procedure} symbol-pset! s val +@deffnx {C Function} scm_symbol_pset_x (s, val) Change the binding of @var{symbol}'s property slot. @end deffn catch -@deffn primitive catch key thunk handler +@deffn {Scheme Procedure} catch key thunk handler +@deffnx {C Function} scm_catch (key, thunk, handler) Invoke @var{thunk} in the dynamic context of @var{handler} for exceptions matching @var{key}. If thunk throws to the symbol @var{key}, then @var{handler} is invoked this way: @@ -4405,7 +4860,8 @@ match this call to @code{catch}. @end deffn lazy-catch -@deffn primitive lazy-catch key thunk handler +@deffn {Scheme Procedure} lazy-catch key thunk handler +@deffnx {C Function} scm_lazy_catch (key, thunk, handler) This behaves exactly like @code{catch}, except that it does not unwind the stack before invoking @var{handler}. The @var{handler} procedure is not allowed to return: @@ -4413,7 +4869,8 @@ it must throw to another catch, or otherwise exit non-locally. @end deffn throw -@deffn primitive throw key . args +@deffn {Scheme Procedure} throw key . args +@deffnx {C Function} scm_throw (key, args) Invoke the catch form matching @var{key}, passing @var{args} to the @var{handler}. @@ -4424,7 +4881,8 @@ If there is no handler at all, Guile prints an error and then exits. @end deffn values -@deffn primitive values . args +@deffn {Scheme Procedure} values . args +@deffnx {C Function} scm_values (args) Delivers all of its arguments to its continuation. Except for continuations created by the @code{call-with-values} procedure, all continuations take exactly one value. The effect of @@ -4433,56 +4891,64 @@ were not created by @code{call-with-values} is unspecified. @end deffn make-variable -@deffn primitive make-variable init +@deffn {Scheme Procedure} make-variable init +@deffnx {C Function} scm_make_variable (init) Return a variable initialized to value @var{init}. @end deffn make-undefined-variable -@deffn primitive make-undefined-variable +@deffn {Scheme Procedure} make-undefined-variable +@deffnx {C Function} scm_make_undefined_variable () Return a variable that is initially unbound. @end deffn variable? -@deffn primitive variable? obj +@deffn {Scheme Procedure} variable? obj +@deffnx {C Function} scm_variable_p (obj) Return @code{#t} iff @var{obj} is a variable object, else return @code{#f}. @end deffn variable-ref -@deffn primitive variable-ref var +@deffn {Scheme Procedure} variable-ref var +@deffnx {C Function} scm_variable_ref (var) Dereference @var{var} and return its value. @var{var} must be a variable object; see @code{make-variable} and @code{make-undefined-variable}. @end deffn variable-set! -@deffn primitive variable-set! var val +@deffn {Scheme Procedure} variable-set! var val +@deffnx {C Function} scm_variable_set_x (var, val) Set the value of the variable @var{var} to @var{val}. @var{var} must be a variable object, @var{val} can be any value. Return an unspecified value. @end deffn variable-bound? -@deffn primitive variable-bound? var +@deffn {Scheme Procedure} variable-bound? var +@deffnx {C Function} scm_variable_bound_p (var) Return @code{#t} iff @var{var} is bound to a value. Throws an error if @var{var} is not a variable object. @end deffn vector? -@deffn primitive vector? obj +@deffn {Scheme Procedure} vector? obj +@deffnx {C Function} scm_vector_p (obj) Return @code{#t} if @var{obj} is a vector, otherwise return @code{#f}. @end deffn list->vector -@deffn primitive list->vector +@deffn {Scheme Procedure} list->vector implemented by the C function "scm_vector" @end deffn vector -@deffn primitive vector . l -@deffnx primitive list->vector l -Return a newly allocated vector whose elements contain the +@deffn {Scheme Procedure} vector . l +@deffnx {Scheme Procedure} list->vector l +@deffnx {C Function} scm_vector (l) +Return a newly allocated vector composed of the given arguments. Analogous to @code{list}. @lisp @@ -4491,17 +4957,18 @@ given arguments. Analogous to @code{list}. @end deffn make-vector -@deffn primitive make-vector k [fill] +@deffn {Scheme Procedure} make-vector k [fill] +@deffnx {C Function} scm_make_vector (k, fill) Return a newly allocated vector of @var{k} elements. If a -second argument is given, then each element is initialized to -@var{fill}. Otherwise the initial contents of each element is +second argument is given, then each position is initialized to +@var{fill}. Otherwise the initial contents of each position is unspecified. @end deffn vector->list -@deffn primitive vector->list v -Return a newly allocated list of the objects contained in the -elements of @var{vector}. +@deffn {Scheme Procedure} vector->list v +@deffnx {C Function} scm_vector_to_list (v) +Return a newly allocated list composed of the elements of @var{v}. @lisp (vector->list '#(dah dah didah)) @result{} (dah dah didah) @@ -4510,44 +4977,51 @@ elements of @var{vector}. @end deffn vector-fill! -@deffn primitive vector-fill! v fill -Store @var{fill} in every element of @var{vector}. The value +@deffn {Scheme Procedure} vector-fill! v fill +@deffnx {C Function} scm_vector_fill_x (v, fill) +Store @var{fill} in every position of @var{vector}. The value returned by @code{vector-fill!} is unspecified. @end deffn vector-move-left! -@deffn primitive vector-move-left! vec1 start1 end1 vec2 start2 +@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2 +@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2) Vector version of @code{substring-move-left!}. @end deffn vector-move-right! -@deffn primitive vector-move-right! vec1 start1 end1 vec2 start2 +@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2 +@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2) Vector version of @code{substring-move-right!}. @end deffn major-version -@deffn primitive major-version +@deffn {Scheme Procedure} major-version +@deffnx {C Function} scm_major_version () Return a string containing Guile's major version number. E.g., the 1 in "1.6.5". @end deffn minor-version -@deffn primitive minor-version +@deffn {Scheme Procedure} minor-version +@deffnx {C Function} scm_minor_version () Return a string containing Guile's minor version number. E.g., the 6 in "1.6.5". @end deffn micro-version -@deffn primitive micro-version +@deffn {Scheme Procedure} micro-version +@deffnx {C Function} scm_micro_version () Return a string containing Guile's micro version number. E.g., the 5 in "1.6.5". @end deffn version -@deffn primitive version -@deffnx primitive major-version -@deffnx primitive minor-version -@deffnx primitive micro-version +@deffn {Scheme Procedure} version +@deffnx {Scheme Procedure} major-version +@deffnx {Scheme Procedure} minor-version +@deffnx {Scheme Procedure} micro-version +@deffnx {C Function} scm_version () Return a string describing Guile's version number, or its major, minor or micro version number, respectively. @@ -4560,7 +5034,8 @@ or micro version number, respectively. @end deffn make-soft-port -@deffn primitive make-soft-port pv modes +@deffn {Scheme Procedure} make-soft-port pv modes +@deffnx {C Function} scm_make_soft_port (pv, modes) Return a port capable of receiving or delivering characters as specified by the @var{modes} string (@pxref{File Ports, open-file}). @var{pv} must be a vector of length 5. Its @@ -4605,7 +5080,8 @@ For example: @end deffn make-weak-vector -@deffn primitive make-weak-vector size [fill] +@deffn {Scheme Procedure} make-weak-vector size [fill] +@deffnx {C Function} scm_make_weak_vector (size, fill) Return a weak vector with @var{size} elements. If the optional argument @var{fill} is given, all entries in the vector will be set to @var{fill}. The default value for @var{fill} is the @@ -4613,13 +5089,14 @@ empty list. @end deffn list->weak-vector -@deffn primitive list->weak-vector +@deffn {Scheme Procedure} list->weak-vector implemented by the C function "scm_weak_vector" @end deffn weak-vector -@deffn primitive weak-vector . l -@deffnx primitive list->weak-vector l +@deffn {Scheme Procedure} weak-vector . l +@deffnx {Scheme Procedure} list->weak-vector l +@deffnx {C Function} scm_weak_vector (l) Construct a weak vector from a list: @code{weak-vector} uses the list of its arguments while @code{list->weak-vector} uses its only argument @var{l} (a list) to construct a weak vector @@ -4627,15 +5104,17 @@ the same way @code{list->vector} would. @end deffn weak-vector? -@deffn primitive weak-vector? obj +@deffn {Scheme Procedure} weak-vector? obj +@deffnx {C Function} scm_weak_vector_p (obj) Return @code{#t} if @var{obj} is a weak vector. Note that all weak hashes are also weak vectors. @end deffn make-weak-key-hash-table -@deffn primitive make-weak-key-hash-table size -@deffnx primitive make-weak-value-hash-table size -@deffnx primitive make-doubly-weak-hash-table size +@deffn {Scheme Procedure} make-weak-key-hash-table size +@deffnx {Scheme Procedure} make-weak-value-hash-table size +@deffnx {Scheme Procedure} make-doubly-weak-hash-table size +@deffnx {C Function} scm_make_weak_key_hash_table (size) Return a weak hash table with @var{size} buckets. As with any hash table, choosing a good size for the table requires some caution. @@ -4645,44 +5124,51 @@ would modify regular hash tables. (@pxref{Hash Tables}) @end deffn make-weak-value-hash-table -@deffn primitive make-weak-value-hash-table size +@deffn {Scheme Procedure} make-weak-value-hash-table size +@deffnx {C Function} scm_make_weak_value_hash_table (size) Return a hash table with weak values with @var{size} buckets. (@pxref{Hash Tables}) @end deffn make-doubly-weak-hash-table -@deffn primitive make-doubly-weak-hash-table size +@deffn {Scheme Procedure} make-doubly-weak-hash-table size +@deffnx {C Function} scm_make_doubly_weak_hash_table (size) Return a hash table with weak keys and values with @var{size} buckets. (@pxref{Hash Tables}) @end deffn weak-key-hash-table? -@deffn primitive weak-key-hash-table? obj -@deffnx primitive weak-value-hash-table? obj -@deffnx primitive doubly-weak-hash-table? obj +@deffn {Scheme Procedure} weak-key-hash-table? obj +@deffnx {Scheme Procedure} weak-value-hash-table? obj +@deffnx {Scheme Procedure} doubly-weak-hash-table? obj +@deffnx {C Function} scm_weak_key_hash_table_p (obj) Return @code{#t} if @var{obj} is the specified weak hash table. Note that a doubly weak hash table is neither a weak key nor a weak value hash table. @end deffn weak-value-hash-table? -@deffn primitive weak-value-hash-table? obj +@deffn {Scheme Procedure} weak-value-hash-table? obj +@deffnx {C Function} scm_weak_value_hash_table_p (obj) Return @code{#t} if @var{obj} is a weak value hash table. @end deffn doubly-weak-hash-table? -@deffn primitive doubly-weak-hash-table? obj +@deffn {Scheme Procedure} doubly-weak-hash-table? obj +@deffnx {C Function} scm_doubly_weak_hash_table_p (obj) Return @code{#t} if @var{obj} is a doubly weak hash table. @end deffn regexp? -@deffn primitive regexp? obj +@deffn {Scheme Procedure} regexp? obj +@deffnx {C Function} scm_regexp_p (obj) Return @code{#t} if @var{obj} is a compiled regular expression, or @code{#f} otherwise. @end deffn make-regexp -@deffn primitive make-regexp pat . flags +@deffn {Scheme Procedure} make-regexp pat . flags +@deffnx {C Function} scm_make_regexp (pat, flags) Compile the regular expression described by @var{pat}, and return the compiled regexp structure. If @var{pat} does not describe a legal regular expression, @code{make-regexp} throws @@ -4723,7 +5209,8 @@ one which comes last will override the earlier one. @end deffn regexp-exec -@deffn primitive regexp-exec rx str [start [flags]] +@deffn {Scheme Procedure} regexp-exec rx str [start [flags]] +@deffnx {C Function} scm_regexp_exec (rx, str, start, flags) Match the compiled regular expression @var{rx} against @code{str}. If the optional integer @var{start} argument is provided, begin matching from that position in the string. @@ -4746,33 +5233,36 @@ considered the end of a line. @end deffn array-fill! -@deffn primitive array-fill! ra fill -Stores @var{fill} in every element of @var{array}. The value returned +@deffn {Scheme Procedure} array-fill! ra fill +@deffnx {C Function} scm_array_fill_x (ra, fill) +Store @var{fill} in every element of @var{array}. The value returned is unspecified. @end deffn array-copy-in-order! -@deffn primitive array-copy-in-order! +@deffn {Scheme Procedure} array-copy-in-order! implemented by the C function "scm_array_copy_x" @end deffn array-copy! -@deffn primitive array-copy! src dst -@deffnx primitive array-copy-in-order! src dst -Copies every element from vector or array @var{source} to the +@deffn {Scheme Procedure} array-copy! src dst +@deffnx {Scheme Procedure} array-copy-in-order! src dst +@deffnx {C Function} scm_array_copy_x (src, dst) +Copy every element from vector or array @var{source} to the corresponding element of @var{destination}. @var{destination} must have the same rank as @var{source}, and be at least as large in each dimension. The order is unspecified. @end deffn array-map-in-order! -@deffn primitive array-map-in-order! +@deffn {Scheme Procedure} array-map-in-order! implemented by the C function "scm_array_map_x" @end deffn array-map! -@deffn primitive array-map! ra0 proc . lra -@deffnx primitive array-map-in-order! ra0 proc . lra +@deffn {Scheme Procedure} array-map! ra0 proc . lra +@deffnx {Scheme Procedure} array-map-in-order! ra0 proc . lra +@deffnx {C Function} scm_array_map_x (ra0, proc, lra) @var{array1}, @dots{} must have the same number of dimensions as @var{array0} and have a range for each index which includes the range for the corresponding index in @var{array0}. @var{proc} is applied to @@ -4782,14 +5272,16 @@ unspecified. The order of application is unspecified. @end deffn array-for-each -@deffn primitive array-for-each proc ra0 . lra -@var{proc} is applied to each tuple of elements of @var{array0} @dots{} +@deffn {Scheme Procedure} array-for-each proc ra0 . lra +@deffnx {C Function} scm_array_for_each (proc, ra0, lra) +Apply @var{proc} to each tuple of elements of @var{array0} @dots{} in row-major order. The value returned is unspecified. @end deffn array-index-map! -@deffn primitive array-index-map! ra proc -applies @var{proc} to the indices of each element of @var{array} in +@deffn {Scheme Procedure} array-index-map! ra proc +@deffnx {C Function} scm_array_index_map_x (ra, proc) +Apply @var{proc} to the indices of each element of @var{array} in turn, storing the result in the corresponding element. The value returned and the order of application are unspecified. @@ -4810,25 +5302,29 @@ Another example: @end deffn uniform-vector-length -@deffn primitive uniform-vector-length v +@deffn {Scheme Procedure} uniform-vector-length v +@deffnx {C Function} scm_uniform_vector_length (v) Return the number of elements in @var{uve}. @end deffn array? -@deffn primitive array? v [prot] +@deffn {Scheme Procedure} array? v [prot] +@deffnx {C Function} scm_array_p (v, prot) Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. The @var{prototype} argument is used with uniform arrays and is described elsewhere. @end deffn array-rank -@deffn primitive array-rank ra +@deffn {Scheme Procedure} array-rank ra +@deffnx {C Function} scm_array_rank (ra) Return the number of dimensions of @var{obj}. If @var{obj} is not an array, @code{0} is returned. @end deffn array-dimensions -@deffn primitive array-dimensions ra +@deffn {Scheme Procedure} array-dimensions ra +@deffnx {C Function} scm_array_dimensions (ra) @code{Array-dimensions} is similar to @code{array-shape} but replaces elements with a @code{0} minimum with one greater than the maximum. So: @lisp @@ -4837,23 +5333,27 @@ elements with a @code{0} minimum with one greater than the maximum. So: @end deffn shared-array-root -@deffn primitive shared-array-root ra +@deffn {Scheme Procedure} shared-array-root ra +@deffnx {C Function} scm_shared_array_root (ra) Return the root vector of a shared array. @end deffn shared-array-offset -@deffn primitive shared-array-offset ra +@deffn {Scheme Procedure} shared-array-offset ra +@deffnx {C Function} scm_shared_array_offset (ra) Return the root vector index of the first element in the array. @end deffn shared-array-increments -@deffn primitive shared-array-increments ra +@deffn {Scheme Procedure} shared-array-increments ra +@deffnx {C Function} scm_shared_array_increments (ra) For each dimension, return the distance between elements in the root vector. @end deffn dimensions->uniform-array -@deffn primitive dimensions->uniform-array dims prot [fill] -@deffnx primitive make-uniform-vector length prototype [fill] +@deffn {Scheme Procedure} dimensions->uniform-array dims prot [fill] +@deffnx {Scheme Procedure} make-uniform-vector length prototype [fill] +@deffnx {C Function} scm_dimensions_to_uniform_array (dims, prot, fill) Create and return a uniform array or vector of type corresponding to @var{prototype} with dimensions @var{dims} or length @var{length}. If @var{fill} is supplied, it's used to @@ -4861,7 +5361,8 @@ fill the array, otherwise @var{prototype} is used. @end deffn make-shared-array -@deffn primitive make-shared-array oldra mapfunc . dims +@deffn {Scheme Procedure} make-shared-array oldra mapfunc . dims +@deffnx {C Function} scm_make_shared_array (oldra, mapfunc, dims) @code{make-shared-array} can be used to create shared subarrays of other arrays. The @var{mapper} is a function that translates coordinates in the new array into coordinates in the old array. A @var{mapper} must be @@ -4880,7 +5381,8 @@ it can be otherwise arbitrary. A simple example: @end deffn transpose-array -@deffn primitive transpose-array ra . args +@deffn {Scheme Procedure} transpose-array ra . args +@deffnx {C Function} scm_transpose_array (ra, args) Return an array sharing contents with @var{array}, but with dimensions arranged in a different order. There must be one @var{dim} argument for each dimension of @var{array}. @@ -4903,7 +5405,8 @@ have smaller rank than @var{array}. @end deffn enclose-array -@deffn primitive enclose-array ra . axes +@deffn {Scheme Procedure} enclose-array ra . axes +@deffnx {C Function} scm_enclose_array (ra, axes) @var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than the rank of @var{array}. @var{enclose-array} returns an array resembling an array of shared arrays. The dimensions of each shared @@ -4928,38 +5431,41 @@ examples: @end deffn array-in-bounds? -@deffn primitive array-in-bounds? v . args +@deffn {Scheme Procedure} array-in-bounds? v . args +@deffnx {C Function} scm_array_in_bounds_p (v, args) Return @code{#t} if its arguments would be acceptable to @code{array-ref}. @end deffn array-ref -@deffn primitive array-ref +@deffn {Scheme Procedure} array-ref implemented by the C function "scm_uniform_vector_ref" @end deffn uniform-vector-ref -@deffn primitive uniform-vector-ref v args -@deffnx primitive array-ref v . args +@deffn {Scheme Procedure} uniform-vector-ref v args +@deffnx {Scheme Procedure} array-ref v . args +@deffnx {C Function} scm_uniform_vector_ref (v, args) Return the element at the @code{(index1, index2)} element in @var{array}. @end deffn uniform-array-set1! -@deffn primitive uniform-array-set1! +@deffn {Scheme Procedure} uniform-array-set1! implemented by the C function "scm_array_set_x" @end deffn array-set! -@deffn primitive array-set! v obj . args -@deffnx primitive uniform-array-set1! v obj args -Sets the element at the @code{(index1, index2)} element in @var{array} to +@deffn {Scheme Procedure} array-set! v obj . args +@deffnx {Scheme Procedure} uniform-array-set1! v obj args +@deffnx {C Function} scm_array_set_x (v, obj, args) +Set the element at the @code{(index1, index2)} element in @var{array} to @var{new-value}. The value returned by array-set! is unspecified. @end deffn array-contents -@deffn primitive array-contents ra [strict] -@deffnx primitive array-contents array strict +@deffn {Scheme Procedure} array-contents ra [strict] +@deffnx {C Function} scm_array_contents (ra, strict) If @var{array} may be @dfn{unrolled} into a one dimensional shared array without changing their order (last subscript changing fastest), then @code{array-contents} returns that shared array, otherwise it returns @@ -4973,12 +5479,13 @@ memory. @end deffn uniform-array-read! -@deffn primitive uniform-array-read! ra [port_or_fd [start [end]]] -@deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end] -Attempts to read all elements of @var{ura}, in lexicographic order, as +@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]] +@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end] +@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end) +Attempt to read all elements of @var{ura}, in lexicographic order, as binary objects from @var{port-or-fdes}. -If an end of file is encountered during -uniform-array-read! the objects up to that point only are put into @var{ura} +If an end of file is encountered, +the objects up to that point are put into @var{ura} (starting at the beginning) and the remainder of the array is unchanged. @@ -4992,8 +5499,9 @@ returned by @code{(current-input-port)}. @end deffn uniform-array-write -@deffn primitive uniform-array-write v [port_or_fd [start [end]]] -@deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end] +@deffn {Scheme Procedure} uniform-array-write v [port_or_fd [start [end]]] +@deffnx {Scheme Procedure} uniform-vector-write uve [port-or-fdes] [start] [end] +@deffnx {C Function} scm_uniform_array_write (v, port_or_fd, start, end) Writes all elements of @var{ura} as binary objects to @var{port-or-fdes}. @@ -5008,33 +5516,37 @@ omitted, in which case it defaults to the value returned by @end deffn bit-count -@deffn primitive bit-count b bitvector +@deffn {Scheme Procedure} bit-count b bitvector +@deffnx {C Function} scm_bit_count (b, bitvector) Return the number of occurrences of the boolean @var{b} in @var{bitvector}. @end deffn bit-position -@deffn primitive bit-position item v k +@deffn {Scheme Procedure} bit-position item v k +@deffnx {C Function} scm_bit_position (item, v, k) Return the minimum index of an occurrence of @var{bool} in @var{bv} which is at least @var{k}. If no @var{bool} occurs within the specified range @code{#f} is returned. @end deffn bit-set*! -@deffn primitive bit-set*! v kv obj +@deffn {Scheme Procedure} bit-set*! v kv obj +@deffnx {C Function} scm_bit_set_star_x (v, kv, obj) If uve is a bit-vector @var{bv} and uve must be of the same length. If @var{bool} is @code{#t}, uve is OR'ed into @var{bv}; If @var{bool} is @code{#f}, the inversion of uve is AND'ed into @var{bv}. -If uve is a unsigned integer vector all the elements of uve +If uve is a unsigned long integer vector all the elements of uve must be between 0 and the @code{length} of @var{bv}. The bits of @var{bv} corresponding to the indexes in uve are set to @var{bool}. The return value is unspecified. @end deffn bit-count* -@deffn primitive bit-count* v kv obj +@deffn {Scheme Procedure} bit-count* v kv obj +@deffnx {C Function} scm_bit_count_star (v, kv, obj) Return @lisp (bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t). @@ -5043,19 +5555,22 @@ Return @end deffn bit-invert! -@deffn primitive bit-invert! v -Modifies @var{bv} by replacing each element with its negation. +@deffn {Scheme Procedure} bit-invert! v +@deffnx {C Function} scm_bit_invert_x (v) +Modify @var{bv} by replacing each element with its negation. @end deffn array->list -@deffn primitive array->list v +@deffn {Scheme Procedure} array->list v +@deffnx {C Function} scm_t_arrayo_list (v) Return a list consisting of all the elements, in order, of @var{array}. @end deffn list->uniform-array -@deffn primitive list->uniform-array ndim prot lst -@deffnx procedure list->uniform-vector prot lst +@deffn {Scheme Procedure} list->uniform-array ndim prot lst +@deffnx {Scheme Procedure} list->uniform-vector prot lst +@deffnx {C Function} scm_list_to_uniform_array (ndim, prot, lst) Return a uniform array of the type indicated by prototype @var{prot} with elements the same as those of @var{lst}. Elements must be of the appropriate type, no coercions are @@ -5063,14 +5578,16 @@ done. @end deffn array-prototype -@deffn primitive array-prototype ra +@deffn {Scheme Procedure} array-prototype ra +@deffnx {C Function} scm_array_prototype (ra) Return an object that would produce an array of the same type as @var{array}, if used as the @var{prototype} for @code{make-uniform-array}. @end deffn chown -@deffn primitive chown object owner group +@deffn {Scheme Procedure} chown object owner group +@deffnx {C Function} scm_chown (object, owner, group) Change the ownership and group of the file referred to by @var{object} to the integer values @var{owner} and @var{group}. @var{object} can be a string containing a file name or, if the platform @@ -5086,7 +5603,8 @@ as @code{-1}, then that ID is not changed. @end deffn chmod -@deffn primitive chmod object mode +@deffn {Scheme Procedure} chmod object mode +@deffnx {C Function} scm_chmod (object, mode) Changes the permissions of the file referred to by @var{obj}. @var{obj} can be a string containing a file name or a port or integer file descriptor which is open on a file (in which case @code{fchmod} is used @@ -5097,7 +5615,8 @@ The return value is unspecified. @end deffn umask -@deffn primitive umask [mode] +@deffn {Scheme Procedure} umask [mode] +@deffnx {C Function} scm_umask (mode) If @var{mode} is omitted, retuns a decimal number representing the current file creation mask. Otherwise the file creation mask is set to @var{mode} and the previous value is returned. @@ -5106,13 +5625,15 @@ E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18. @end deffn open-fdes -@deffn primitive open-fdes path flags [mode] +@deffn {Scheme Procedure} open-fdes path flags [mode] +@deffnx {C Function} scm_open_fdes (path, flags, mode) Similar to @code{open} but return a file descriptor instead of a port. @end deffn open -@deffn primitive open path flags [mode] +@deffn {Scheme Procedure} open path flags [mode] +@deffnx {C Function} scm_open (path, flags, mode) Open the file named by @var{path} for reading and/or writing. @var{flags} is an integer specifying how the file should be opened. @var{mode} is an integer specifying the permission bits of the file, if @@ -5143,8 +5664,9 @@ for additional flags. @end deffn close -@deffn primitive close fd_or_port -Similar to close-port (@pxref{Generic Port Operations, close-port}), +@deffn {Scheme Procedure} close fd_or_port +@deffnx {C Function} scm_close (fd_or_port) +Similar to close-port (@pxref{Closing, close-port}), but also works on file descriptors. A side effect of closing a file descriptor is that any ports using that file descriptor are moved to a different file descriptor and have @@ -5152,7 +5674,8 @@ their revealed counts set to zero. @end deffn close-fdes -@deffn primitive close-fdes fd +@deffn {Scheme Procedure} close-fdes fd +@deffnx {C Function} scm_close_fdes (fd) A simple wrapper for the @code{close} system call. Close file descriptor @var{fd}, which must be an integer. Unlike close (@pxref{Ports and File Descriptors, close}), @@ -5161,7 +5684,8 @@ The return value is unspecified. @end deffn stat -@deffn primitive stat object +@deffn {Scheme Procedure} stat object +@deffnx {C Function} scm_stat (object) Return an object containing various information about the file determined by @var{obj}. @var{obj} can be a string containing a file name or a port or integer file descriptor which is open @@ -5221,7 +5745,8 @@ An integer representing the access permission bits. @end deffn link -@deffn primitive link oldpath newpath +@deffn {Scheme Procedure} link oldpath newpath +@deffnx {C Function} scm_link (oldpath, newpath) Creates a new name @var{newpath} in the file system for the file named by @var{oldpath}. If @var{oldpath} is a symbolic link, the link may or may not be followed depending on the @@ -5229,18 +5754,21 @@ system. @end deffn rename-file -@deffn primitive rename-file oldname newname +@deffn {Scheme Procedure} rename-file oldname newname +@deffnx {C Function} scm_rename (oldname, newname) Renames the file specified by @var{oldname} to @var{newname}. The return value is unspecified. @end deffn delete-file -@deffn primitive delete-file str +@deffn {Scheme Procedure} delete-file str +@deffnx {C Function} scm_delete_file (str) Deletes (or "unlinks") the file specified by @var{path}. @end deffn mkdir -@deffn primitive mkdir path [mode] +@deffn {Scheme Procedure} mkdir path [mode] +@deffnx {C Function} scm_mkdir (path, mode) Create a new directory named by @var{path}. If @var{mode} is omitted then the permissions of the directory file are set using the current umask. Otherwise they are set to the decimal value specified with @@ -5248,55 +5776,64 @@ umask. Otherwise they are set to the decimal value specified with @end deffn rmdir -@deffn primitive rmdir path +@deffn {Scheme Procedure} rmdir path +@deffnx {C Function} scm_rmdir (path) Remove the existing directory named by @var{path}. The directory must be empty for this to succeed. The return value is unspecified. @end deffn directory-stream? -@deffn primitive directory-stream? obj +@deffn {Scheme Procedure} directory-stream? obj +@deffnx {C Function} scm_directory_stream_p (obj) Return a boolean indicating whether @var{object} is a directory stream as returned by @code{opendir}. @end deffn opendir -@deffn primitive opendir dirname +@deffn {Scheme Procedure} opendir dirname +@deffnx {C Function} scm_opendir (dirname) Open the directory specified by @var{path} and return a directory stream. @end deffn readdir -@deffn primitive readdir port +@deffn {Scheme Procedure} readdir port +@deffnx {C Function} scm_readdir (port) Return (as a string) the next directory entry from the directory stream @var{stream}. If there is no remaining entry to be read then the end of file object is returned. @end deffn rewinddir -@deffn primitive rewinddir port +@deffn {Scheme Procedure} rewinddir port +@deffnx {C Function} scm_rewinddir (port) Reset the directory port @var{stream} so that the next call to @code{readdir} will return the first directory entry. @end deffn closedir -@deffn primitive closedir port +@deffn {Scheme Procedure} closedir port +@deffnx {C Function} scm_closedir (port) Close the directory stream @var{stream}. The return value is unspecified. @end deffn chdir -@deffn primitive chdir str +@deffn {Scheme Procedure} chdir str +@deffnx {C Function} scm_chdir (str) Change the current working directory to @var{path}. The return value is unspecified. @end deffn getcwd -@deffn primitive getcwd +@deffn {Scheme Procedure} getcwd +@deffnx {C Function} scm_getcwd () Return the name of the current working directory. @end deffn select -@deffn primitive select reads writes excepts [secs [usecs]] +@deffn {Scheme Procedure} select reads writes excepts [secs [usecs]] +@deffnx {C Function} scm_select (reads, writes, excepts, secs, usecs) This procedure has a variety of uses: waiting for the ability to provide input, accept output, or the existance of exceptional conditions on a collection of ports or file @@ -5329,7 +5866,8 @@ An additional @code{select!} interface is provided. @end deffn fcntl -@deffn primitive fcntl object cmd [value] +@deffn {Scheme Procedure} fcntl object cmd [value] +@deffnx {C Function} scm_fcntl (object, cmd, value) Apply @var{command} to the specified file descriptor or the underlying file descriptor of the specified port. @var{value} is an optional integer argument. @@ -5358,7 +5896,8 @@ The value used to indicate the "close on exec" flag with @code{F_GETFL} or @end deffn fsync -@deffn primitive fsync object +@deffn {Scheme Procedure} fsync object +@deffnx {C Function} scm_fsync (object) Copies any unwritten data for the specified output file descriptor to disk. If @var{port/fd} is a port, its buffer is flushed before the underlying file descriptor is fsync'd. @@ -5366,39 +5905,45 @@ The return value is unspecified. @end deffn symlink -@deffn primitive symlink oldpath newpath +@deffn {Scheme Procedure} symlink oldpath newpath +@deffnx {C Function} scm_symlink (oldpath, newpath) Create a symbolic link named @var{path-to} with the value (i.e., pointing to) @var{path-from}. The return value is unspecified. @end deffn readlink -@deffn primitive readlink path +@deffn {Scheme Procedure} readlink path +@deffnx {C Function} scm_readlink (path) Return the value of the symbolic link named by @var{path} (a string), i.e., the file that the link points to. @end deffn lstat -@deffn primitive lstat str +@deffn {Scheme Procedure} lstat str +@deffnx {C Function} scm_lstat (str) Similar to @code{stat}, but does not follow symbolic links, i.e., it will return information about a symbolic link itself, not the file it points to. @var{path} must be a string. @end deffn copy-file -@deffn primitive copy-file oldfile newfile +@deffn {Scheme Procedure} copy-file oldfile newfile +@deffnx {C Function} scm_copy_file (oldfile, newfile) Copy the file specified by @var{path-from} to @var{path-to}. The return value is unspecified. @end deffn dirname -@deffn primitive dirname filename +@deffn {Scheme Procedure} dirname filename +@deffnx {C Function} scm_dirname (filename) Return the directory name component of the file name @var{filename}. If @var{filename} does not contain a directory component, @code{.} is returned. @end deffn basename -@deffn primitive basename filename [suffix] +@deffn {Scheme Procedure} basename filename [suffix] +@deffnx {C Function} scm_basename (filename, suffix) Return the base name of the file name @var{filename}. The base name is the file name without any directory components. If @var{suffix} is privided, and is equal to the end of @@ -5406,7 +5951,8 @@ If @var{suffix} is privided, and is equal to the end of @end deffn pipe -@deffn primitive pipe +@deffn {Scheme Procedure} pipe +@deffnx {C Function} scm_pipe () Return a newly created pipe: a pair of ports which are linked together on the local machine. The @emph{car} is the input port and the @emph{cdr} is the output port. Data written (and @@ -5423,41 +5969,47 @@ from the input port. @end deffn getgroups -@deffn primitive getgroups +@deffn {Scheme Procedure} getgroups +@deffnx {C Function} scm_getgroups () Return a vector of integers representing the current supplimentary group IDs. @end deffn getpw -@deffn primitive getpw [user] +@deffn {Scheme Procedure} getpw [user] +@deffnx {C Function} scm_getpwuid (user) Look up an entry in the user database. @var{obj} can be an integer, a string, or omitted, giving the behaviour of getpwuid, getpwnam or getpwent respectively. @end deffn setpw -@deffn primitive setpw [arg] +@deffn {Scheme Procedure} setpw [arg] +@deffnx {C Function} scm_setpwent (arg) If called with a true argument, initialize or reset the password data stream. Otherwise, close the stream. The @code{setpwent} and @code{endpwent} procedures are implemented on top of this. @end deffn getgr -@deffn primitive getgr [name] +@deffn {Scheme Procedure} getgr [name] +@deffnx {C Function} scm_getgrgid (name) Look up an entry in the group database. @var{obj} can be an integer, a string, or omitted, giving the behaviour of getgrgid, getgrnam or getgrent respectively. @end deffn setgr -@deffn primitive setgr [arg] +@deffn {Scheme Procedure} setgr [arg] +@deffnx {C Function} scm_setgrent (arg) If called with a true argument, initialize or reset the group data stream. Otherwise, close the stream. The @code{setgrent} and @code{endgrent} procedures are implemented on top of this. @end deffn kill -@deffn primitive kill pid sig +@deffn {Scheme Procedure} kill pid sig +@deffnx {C Function} scm_kill (pid, sig) Sends a signal to the specified process or group of processes. @var{pid} specifies the processes to which the signal is sent: @@ -5488,7 +6040,8 @@ Interrupt signal. @end deffn waitpid -@deffn primitive waitpid pid [options] +@deffn {Scheme Procedure} waitpid pid [options] +@deffnx {C Function} scm_waitpid (pid, options) This procedure collects status information from a child process which has terminated or (optionally) stopped. Normally it will suspend the calling process until this can be done. If more than one @@ -5533,42 +6086,49 @@ The integer status value. @end deffn status:exit-val -@deffn primitive status:exit-val status +@deffn {Scheme Procedure} status:exit-val status +@deffnx {C Function} scm_status_exit_val (status) Return the exit status value, as would be set if a process ended normally through a call to @code{exit} or @code{_exit}, if any, otherwise @code{#f}. @end deffn status:term-sig -@deffn primitive status:term-sig status +@deffn {Scheme Procedure} status:term-sig status +@deffnx {C Function} scm_status_term_sig (status) Return the signal number which terminated the process, if any, otherwise @code{#f}. @end deffn status:stop-sig -@deffn primitive status:stop-sig status +@deffn {Scheme Procedure} status:stop-sig status +@deffnx {C Function} scm_status_stop_sig (status) Return the signal number which stopped the process, if any, otherwise @code{#f}. @end deffn getppid -@deffn primitive getppid +@deffn {Scheme Procedure} getppid +@deffnx {C Function} scm_getppid () Return an integer representing the process ID of the parent process. @end deffn getuid -@deffn primitive getuid +@deffn {Scheme Procedure} getuid +@deffnx {C Function} scm_getuid () Return an integer representing the current real user ID. @end deffn getgid -@deffn primitive getgid +@deffn {Scheme Procedure} getgid +@deffnx {C Function} scm_getgid () Return an integer representing the current real group ID. @end deffn geteuid -@deffn primitive geteuid +@deffn {Scheme Procedure} geteuid +@deffnx {C Function} scm_geteuid () Return an integer representing the current effective user ID. If the system does not support effective IDs, then the real ID is returned. @code{(feature? 'EIDs)} reports whether the @@ -5576,7 +6136,8 @@ system supports effective IDs. @end deffn getegid -@deffn primitive getegid +@deffn {Scheme Procedure} getegid +@deffnx {C Function} scm_getegid () Return an integer representing the current effective group ID. If the system does not support effective IDs, then the real ID is returned. @code{(feature? 'EIDs)} reports whether the @@ -5584,21 +6145,24 @@ system supports effective IDs. @end deffn setuid -@deffn primitive setuid id +@deffn {Scheme Procedure} setuid id +@deffnx {C Function} scm_setuid (id) Sets both the real and effective user IDs to the integer @var{id}, provided the process has appropriate privileges. The return value is unspecified. @end deffn setgid -@deffn primitive setgid id +@deffn {Scheme Procedure} setgid id +@deffnx {C Function} scm_setgid (id) Sets both the real and effective group IDs to the integer @var{id}, provided the process has appropriate privileges. The return value is unspecified. @end deffn seteuid -@deffn primitive seteuid id +@deffn {Scheme Procedure} seteuid id +@deffnx {C Function} scm_seteuid (id) Sets the effective user ID to the integer @var{id}, provided the process has appropriate privileges. If effective IDs are not supported, the real ID is set instead -- @code{(feature? 'EIDs)} reports whether the @@ -5607,7 +6171,8 @@ The return value is unspecified. @end deffn setegid -@deffn primitive setegid id +@deffn {Scheme Procedure} setegid id +@deffnx {C Function} scm_setegid (id) Sets the effective group ID to the integer @var{id}, provided the process has appropriate privileges. If effective IDs are not supported, the real ID is set instead -- @code{(feature? 'EIDs)} reports whether the @@ -5616,13 +6181,15 @@ The return value is unspecified. @end deffn getpgrp -@deffn primitive getpgrp +@deffn {Scheme Procedure} getpgrp +@deffnx {C Function} scm_getpgrp () Return an integer representing the current process group ID. This is the POSIX definition, not BSD. @end deffn setpgid -@deffn primitive setpgid pid pgid +@deffn {Scheme Procedure} setpgid pid pgid +@deffnx {C Function} scm_setpgid (pid, pgid) Move the process @var{pid} into the process group @var{pgid}. @var{pid} or @var{pgid} must be integers: they can be zero to indicate the ID of the current process. @@ -5631,7 +6198,8 @@ The return value is unspecified. @end deffn setsid -@deffn primitive setsid +@deffn {Scheme Procedure} setsid +@deffnx {C Function} scm_setsid () Creates a new session. The current process becomes the session leader and is put in a new process group. The process will be detached from its controlling terminal if it has one. @@ -5639,19 +6207,22 @@ The return value is an integer representing the new process group ID. @end deffn ttyname -@deffn primitive ttyname port +@deffn {Scheme Procedure} ttyname port +@deffnx {C Function} scm_ttyname (port) Return a string with the name of the serial terminal device underlying @var{port}. @end deffn ctermid -@deffn primitive ctermid +@deffn {Scheme Procedure} ctermid +@deffnx {C Function} scm_ctermid () Return a string containing the file name of the controlling terminal for the current process. @end deffn tcgetpgrp -@deffn primitive tcgetpgrp port +@deffn {Scheme Procedure} tcgetpgrp port +@deffnx {C Function} scm_tcgetpgrp (port) Return the process group ID of the foreground process group associated with the terminal open on the file descriptor underlying @var{port}. @@ -5665,7 +6236,8 @@ foreground. @end deffn tcsetpgrp -@deffn primitive tcsetpgrp port pgid +@deffn {Scheme Procedure} tcsetpgrp port pgid +@deffnx {C Function} scm_tcsetpgrp (port, pgid) Set the foreground process group ID for the terminal used by the file descriptor underlying @var{port} to the integer @var{pgid}. The calling process @@ -5674,12 +6246,13 @@ controlling terminal. The return value is unspecified. @end deffn execl -@deffn primitive execl filename . args +@deffn {Scheme Procedure} execl filename . args +@deffnx {C Function} scm_execl (filename, args) Executes the file named by @var{path} as a new process image. The remaining arguments are supplied to the process; from a C program they are accessable as the @code{argv} argument to @code{main}. Conventionally the first @var{arg} is the same as @var{path}. -All arguments must be strings. +All arguments must be strings. If @var{arg} is missing, @var{path} is executed with a null argument list, which may have system-dependent side-effects. @@ -5689,7 +6262,8 @@ call, but we call it @code{execl} because of its Scheme calling interface. @end deffn execlp -@deffn primitive execlp filename . args +@deffn {Scheme Procedure} execlp filename . args +@deffnx {C Function} scm_execlp (filename, args) Similar to @code{execl}, however if @var{filename} does not contain a slash then the file to execute will be located by searching the @@ -5700,7 +6274,8 @@ call, but we call it @code{execlp} because of its Scheme calling interface. @end deffn execle -@deffn primitive execle filename env . args +@deffn {Scheme Procedure} execle filename env . args +@deffnx {C Function} scm_execle (filename, env, args) Similar to @code{execl}, but the environment of the new process is specified by @var{env}, which must be a list of strings as returned by the @code{environ} procedure. @@ -5710,7 +6285,8 @@ call, but we call it @code{execle} because of its Scheme calling interface. @end deffn primitive-fork -@deffn primitive primitive-fork +@deffn {Scheme Procedure} primitive-fork +@deffnx {C Function} scm_fork () Creates a new "child" process by duplicating the current "parent" process. In the child the return value is 0. In the parent the return value is the integer process ID of the child. @@ -5720,13 +6296,15 @@ with the scsh fork. @end deffn uname -@deffn primitive uname +@deffn {Scheme Procedure} uname +@deffnx {C Function} scm_uname () Return an object with some information about the computer system the program is running on. @end deffn environ -@deffn primitive environ [env] +@deffn {Scheme Procedure} environ [env] +@deffnx {C Function} scm_environ (env) If @var{env} is omitted, return the current environment (in the Unix sense) as a list of strings. Otherwise set the current environment, which is also the default environment for child @@ -5737,7 +6315,8 @@ then the return value is unspecified. @end deffn tmpnam -@deffn primitive tmpnam +@deffn {Scheme Procedure} tmpnam +@deffnx {C Function} scm_tmpnam () Return a name in the file system that does not match any existing file. However there is no guarantee that another process will not create the file after @code{tmpnam} is called. @@ -5746,7 +6325,8 @@ Care should be taken if opening the file, e.g., use the @end deffn mkstemp! -@deffn primitive mkstemp! tmpl +@deffn {Scheme Procedure} mkstemp! tmpl +@deffnx {C Function} scm_mkstemp (tmpl) Create a new unique file in the file system and returns a new buffered port open for reading and writing to the file. @var{tmpl} is a string specifying where the file should be @@ -5755,7 +6335,8 @@ place to return the name of the temporary file. @end deffn utime -@deffn primitive utime pathname [actime [modtime]] +@deffn {Scheme Procedure} utime pathname [actime [modtime]] +@deffnx {C Function} scm_utime (pathname, actime, modtime) @code{utime} sets the access and modification times for the file named by @var{path}. If @var{actime} or @var{modtime} is not supplied, then the current time is used. @var{actime} and @@ -5769,7 +6350,8 @@ modification time to the current time. @end deffn access? -@deffn primitive access? path how +@deffn {Scheme Procedure} access? path how +@deffnx {C Function} scm_access (path, how) Return @code{#t} if @var{path} corresponds to an existing file and the current process has the type of access specified by @var{how}, otherwise @code{#f}. @var{how} should be specified @@ -5796,12 +6378,14 @@ test for existence of the file. @end deffn getpid -@deffn primitive getpid +@deffn {Scheme Procedure} getpid +@deffnx {C Function} scm_getpid () Return an integer representing the current process ID. @end deffn putenv -@deffn primitive putenv str +@deffn {Scheme Procedure} putenv str +@deffnx {C Function} scm_putenv (str) Modifies the environment of the current process, which is also the default environment inherited by child processes. @@ -5816,7 +6400,8 @@ The return value is unspecified. @end deffn setlocale -@deffn primitive setlocale category [locale] +@deffn {Scheme Procedure} setlocale category [locale] +@deffnx {C Function} scm_setlocale (category, locale) If @var{locale} is omitted, return the current value of the specified locale category as a system-dependent string. @var{category} should be specified using the values @@ -5829,7 +6414,8 @@ the locale will be set using envirionment variables. @end deffn mknod -@deffn primitive mknod path type perms dev +@deffn {Scheme Procedure} mknod path type perms dev +@deffnx {C Function} scm_mknod (path, type, perms, dev) Creates a new special file, such as a file corresponding to a device. @var{path} specifies the name of the file. @var{type} should be one of the following symbols: @@ -5848,26 +6434,30 @@ The return value is unspecified. @end deffn nice -@deffn primitive nice incr +@deffn {Scheme Procedure} nice incr +@deffnx {C Function} scm_nice (incr) Increment the priority of the current process by @var{incr}. A higher priority value means that the process runs less often. The return value is unspecified. @end deffn sync -@deffn primitive sync +@deffn {Scheme Procedure} sync +@deffnx {C Function} scm_sync () Flush the operating system disk buffers. The return value is unspecified. @end deffn crypt -@deffn primitive crypt key salt +@deffn {Scheme Procedure} crypt key salt +@deffnx {C Function} scm_crypt (key, salt) Encrypt @var{key} using @var{salt} as the salt value to the crypt(3) library call. @end deffn chroot -@deffn primitive chroot path +@deffn {Scheme Procedure} chroot path +@deffnx {C Function} scm_chroot (path) Change the root directory to that specified in @var{path}. This directory will be used for path names beginning with @file{/}. The root directory is inherited by all children @@ -5876,21 +6466,24 @@ root directory. @end deffn getlogin -@deffn primitive getlogin +@deffn {Scheme Procedure} getlogin +@deffnx {C Function} scm_getlogin () Return a string containing the name of the user logged in on the controlling terminal of the process, or @code{#f} if this information cannot be obtained. @end deffn cuserid -@deffn primitive cuserid +@deffn {Scheme Procedure} cuserid +@deffnx {C Function} scm_cuserid () Return a string containing a user name associated with the effective user id of the process. Return @code{#f} if this information cannot be obtained. @end deffn getpriority -@deffn primitive getpriority which who +@deffn {Scheme Procedure} getpriority which who +@deffnx {C Function} scm_getpriority (which, who) Return the scheduling priority of the process, process group or user, as indicated by @var{which} and @var{who}. @var{which} is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} @@ -5904,7 +6497,8 @@ specified processes. @end deffn setpriority -@deffn primitive setpriority which who prio +@deffn {Scheme Procedure} setpriority which who prio +@deffnx {C Function} scm_setpriority (which, who, prio) Set the scheduling priority of the process, process group or user, as indicated by @var{which} and @var{who}. @var{which} is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} @@ -5921,7 +6515,8 @@ The return value is not specified. @end deffn getpass -@deffn primitive getpass prompt +@deffn {Scheme Procedure} getpass prompt +@deffnx {C Function} scm_getpass (prompt) Display @var{prompt} to the standard error output and read a password from @file{/dev/tty}. If this file is not accessible, it reads from standard input. The password may be @@ -5932,7 +6527,8 @@ characters is disabled. @end deffn flock -@deffn primitive flock file operation +@deffn {Scheme Procedure} flock file operation +@deffnx {C Function} scm_flock (file, operation) Apply or remove an advisory lock on an open file. @var{operation} specifies the action to be done: @table @code @@ -5953,21 +6549,24 @@ file descriptor or an open file descriptior port. @end deffn sethostname -@deffn primitive sethostname name +@deffn {Scheme Procedure} sethostname name +@deffnx {C Function} scm_sethostname (name) Set the host name of the current processor to @var{name}. May only be used by the superuser. The return value is not specified. @end deffn gethostname -@deffn primitive gethostname +@deffn {Scheme Procedure} gethostname +@deffnx {C Function} scm_gethostname () Return the host name of the current processor. @end deffn gethost -@deffn primitive gethost [host] -@deffnx procedure gethostbyname hostname -@deffnx procedure gethostbyaddr address +@deffn {Scheme Procedure} gethost [host] +@deffnx {Scheme Procedure} gethostbyname hostname +@deffnx {Scheme Procedure} gethostbyaddr address +@deffnx {C Function} scm_gethost (host) Look up a host by name or address, returning a host object. The @code{gethost} procedure will accept either a string name or an integer address; if given no arguments, it behaves like @code{gethostent} (see @@ -5980,9 +6579,10 @@ Unusual conditions may result in errors thrown to the @end deffn getnet -@deffn primitive getnet [net] -@deffnx procedure getnetbyname net-name -@deffnx procedure getnetbyaddr net-number +@deffn {Scheme Procedure} getnet [net] +@deffnx {Scheme Procedure} getnetbyname net-name +@deffnx {Scheme Procedure} getnetbyaddr net-number +@deffnx {C Function} scm_getnet (net) Look up a network by name or net number in the network database. The @var{net-name} argument must be a string, and the @var{net-number} argument must be an integer. @code{getnet} will accept either type of @@ -5991,9 +6591,10 @@ given. @end deffn getproto -@deffn primitive getproto [protocol] -@deffnx procedure getprotobyname name -@deffnx procedure getprotobynumber number +@deffn {Scheme Procedure} getproto [protocol] +@deffnx {Scheme Procedure} getprotobyname name +@deffnx {Scheme Procedure} getprotobynumber number +@deffnx {C Function} scm_getproto (protocol) Look up a network protocol by name or by number. @code{getprotobyname} takes a string argument, and @code{getprotobynumber} takes an integer argument. @code{getproto} will accept either type, behaving like @@ -6001,9 +6602,10 @@ argument. @code{getproto} will accept either type, behaving like @end deffn getserv -@deffn primitive getserv [name [protocol]] -@deffnx procedure getservbyname name protocol -@deffnx procedure getservbyport port protocol +@deffn {Scheme Procedure} getserv [name [protocol]] +@deffnx {Scheme Procedure} getservbyname name protocol +@deffnx {Scheme Procedure} getservbyport port protocol +@deffnx {C Function} scm_getserv (name, protocol) Look up a network service by name or by service number, and return a network service object. The @var{protocol} argument specifies the name of the desired protocol; if the protocol found in the network service @@ -6015,59 +6617,68 @@ as its first argument; if given no arguments, it behaves like @end deffn sethost -@deffn primitive sethost [stayopen] +@deffn {Scheme Procedure} sethost [stayopen] +@deffnx {C Function} scm_sethost (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endhostent}. Otherwise it is equivalent to @code{sethostent stayopen}. @end deffn setnet -@deffn primitive setnet [stayopen] +@deffn {Scheme Procedure} setnet [stayopen] +@deffnx {C Function} scm_setnet (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endnetent}. Otherwise it is equivalent to @code{setnetent stayopen}. @end deffn setproto -@deffn primitive setproto [stayopen] +@deffn {Scheme Procedure} setproto [stayopen] +@deffnx {C Function} scm_setproto (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}. Otherwise it is equivalent to @code{setprotoent stayopen}. @end deffn setserv -@deffn primitive setserv [stayopen] +@deffn {Scheme Procedure} setserv [stayopen] +@deffnx {C Function} scm_setserv (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endservent}. Otherwise it is equivalent to @code{setservent stayopen}. @end deffn htons -@deffn primitive htons value +@deffn {Scheme Procedure} htons value +@deffnx {C Function} scm_htons (value) Convert a 16 bit quantity from host to network byte ordering. @var{value} is packed into 2 bytes, which are then converted and returned as a new integer. @end deffn ntohs -@deffn primitive ntohs value +@deffn {Scheme Procedure} ntohs value +@deffnx {C Function} scm_ntohs (value) Convert a 16 bit quantity from network to host byte ordering. @var{value} is packed into 2 bytes, which are then converted and returned as a new integer. @end deffn htonl -@deffn primitive htonl value +@deffn {Scheme Procedure} htonl value +@deffnx {C Function} scm_htonl (value) Convert a 32 bit quantity from host to network byte ordering. @var{value} is packed into 4 bytes, which are then converted and returned as a new integer. @end deffn ntohl -@deffn primitive ntohl value +@deffn {Scheme Procedure} ntohl value +@deffnx {C Function} scm_ntohl (value) Convert a 32 bit quantity from network to host byte ordering. @var{value} is packed into 4 bytes, which are then converted and returned as a new integer. @end deffn inet-aton -@deffn primitive inet-aton address +@deffn {Scheme Procedure} inet-aton address +@deffnx {C Function} scm_inet_aton (address) Convert an IPv4 Internet address from printable string (dotted decimal notation) to an integer. E.g., @@ -6077,7 +6688,8 @@ Convert an IPv4 Internet address from printable string @end deffn inet-ntoa -@deffn primitive inet-ntoa inetid +@deffn {Scheme Procedure} inet-ntoa inetid +@deffnx {C Function} scm_inet_ntoa (inetid) Convert an IPv4 Internet address to a printable (dotted decimal notation) string. E.g., @@ -6087,7 +6699,8 @@ Convert an IPv4 Internet address to a printable @end deffn inet-netof -@deffn primitive inet-netof address +@deffn {Scheme Procedure} inet-netof address +@deffnx {C Function} scm_inet_netof (address) Return the network number part of the given IPv4 Internet address. E.g., @@ -6097,7 +6710,8 @@ Internet address. E.g., @end deffn inet-lnaof -@deffn primitive inet-lnaof address +@deffn {Scheme Procedure} inet-lnaof address +@deffnx {C Function} scm_lnaof (address) Return the local-address-with-network part of the given IPv4 Internet address, using the obsolete class A/B/C system. E.g., @@ -6108,7 +6722,8 @@ E.g., @end deffn inet-makeaddr -@deffn primitive inet-makeaddr net lna +@deffn {Scheme Procedure} inet-makeaddr net lna +@deffnx {C Function} scm_inet_makeaddr (net, lna) Make an IPv4 Internet address by combining the network number @var{net} with the local-address-within-network number @var{lna}. E.g., @@ -6119,7 +6734,8 @@ Make an IPv4 Internet address by combining the network number @end deffn inet-pton -@deffn primitive inet-pton family address +@deffn {Scheme Procedure} inet-pton family address +@deffnx {C Function} scm_inet_pton (family, address) Convert a string containing a printable network address to an integer address. Note that unlike the C version of this function, @@ -6133,7 +6749,8 @@ the result is an integer with normal host byte ordering. @end deffn inet-ntop -@deffn primitive inet-ntop family address +@deffn {Scheme Procedure} inet-ntop family address +@deffnx {C Function} scm_inet_ntop (family, address) Convert a network address into a printable string. Note that unlike the C version of this function, the input is an integer with normal host byte ordering. @@ -6147,7 +6764,8 @@ ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff @end deffn socket -@deffn primitive socket family style proto +@deffn {Scheme Procedure} socket family style proto +@deffnx {C Function} scm_socket (family, style, proto) Return a new socket port of the type specified by @var{family}, @var{style} and @var{proto}. All three parameters are integers. Supported values for @var{family} are @@ -6164,7 +6782,8 @@ has been connected to another socket. @end deffn socketpair -@deffn primitive socketpair family style proto +@deffn {Scheme Procedure} socketpair family style proto +@deffnx {C Function} scm_socketpair (family, style, proto) Return a pair of connected (but unnamed) socket ports of the type specified by @var{family}, @var{style} and @var{proto}. Many systems support only socket pairs of the @code{AF_UNIX} @@ -6173,7 +6792,8 @@ family. Zero is likely to be the only meaningful value for @end deffn getsockopt -@deffn primitive getsockopt sock level optname +@deffn {Scheme Procedure} getsockopt sock level optname +@deffnx {C Function} scm_getsockopt (sock, level, optname) Return the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of option being requested, e.g., @code{SOL_SOCKET} for @@ -6186,7 +6806,8 @@ returns a pair of integers. @end deffn setsockopt -@deffn primitive setsockopt sock level optname value +@deffn {Scheme Procedure} setsockopt sock level optname value +@deffnx {C Function} scm_setsockopt (sock, level, optname, value) Set the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of option being set, e.g., @code{SOL_SOCKET} for socket-level options. @@ -6201,7 +6822,8 @@ The return value is unspecified. @end deffn shutdown -@deffn primitive shutdown sock how +@deffn {Scheme Procedure} shutdown sock how +@deffnx {C Function} scm_shutdown (sock, how) Sockets can be closed simply by using @code{close-port}. The @code{shutdown} procedure allows reception or tranmission on a connection to be shut down individually, according to the parameter @@ -6222,7 +6844,8 @@ The return value is unspecified. @end deffn connect -@deffn primitive connect sock fam address . args +@deffn {Scheme Procedure} connect sock fam address . args +@deffnx {C Function} scm_connect (sock, fam, address, args) Initiate a connection from a socket using a specified address family to the address specified by @var{address} and possibly @var{args}. @@ -6247,7 +6870,8 @@ The return value is unspecified. @end deffn bind -@deffn primitive bind sock fam address . args +@deffn {Scheme Procedure} bind sock fam address . args +@deffnx {C Function} scm_bind (sock, fam, address, args) Assign an address to the socket port @var{sock}. Generally this only needs to be done for server sockets, so they know where to look for incoming connections. A socket @@ -6294,7 +6918,8 @@ The return value is unspecified. @end deffn listen -@deffn primitive listen sock backlog +@deffn {Scheme Procedure} listen sock backlog +@deffnx {C Function} scm_listen (sock, backlog) Enable @var{sock} to accept connection requests. @var{backlog} is an integer specifying the maximum length of the queue for pending connections. @@ -6306,7 +6931,8 @@ The return value is unspecified. @end deffn accept -@deffn primitive accept sock +@deffn {Scheme Procedure} accept sock +@deffnx {C Function} scm_accept (sock) Accept a connection on a bound, listening socket. If there are no pending connections in the queue, wait until @@ -6324,14 +6950,16 @@ connection and will continue to accept new requests. @end deffn getsockname -@deffn primitive getsockname sock +@deffn {Scheme Procedure} getsockname sock +@deffnx {C Function} scm_getsockname (sock) Return the address of @var{sock}, in the same form as the object returned by @code{accept}. On many systems the address of a socket in the @code{AF_FILE} namespace cannot be read. @end deffn getpeername -@deffn primitive getpeername sock +@deffn {Scheme Procedure} getpeername sock +@deffnx {C Function} scm_getpeername (sock) Return the address that @var{sock} is connected to, in the same form as the object returned by @code{accept}. On many systems the address of a socket in the @@ -6339,7 +6967,8 @@ is connected to, in the same form as the object returned by @end deffn recv! -@deffn primitive recv! sock buf [flags] +@deffn {Scheme Procedure} recv! sock buf [flags] +@deffnx {C Function} scm_recv (sock, buf, flags) Receive data from a socket port. @var{sock} must already be bound to the address from which data is to be received. @@ -6363,7 +6992,8 @@ any unread buffered port data is ignored. @end deffn send -@deffn primitive send sock message [flags] +@deffn {Scheme Procedure} send sock message [flags] +@deffnx {C Function} scm_send (sock, message, flags) Transmit the string @var{message} on a socket port @var{sock}. @var{sock} must already be bound to a destination address. The value returned is the number of bytes transmitted -- @@ -6380,7 +7010,8 @@ any unflushed buffered port data is ignored. @end deffn recvfrom! -@deffn primitive recvfrom! sock str [flags [start [end]]] +@deffn {Scheme Procedure} recvfrom! sock str [flags [start [end]]] +@deffnx {C Function} scm_recvfrom (sock, str, flags, start, end) Return data from the socket port @var{sock} and also information about where the data was received from. @var{sock} must already be bound to the address from which @@ -6407,7 +7038,8 @@ descriptor: any unread buffered port data is ignored. @end deffn sendto -@deffn primitive sendto sock message fam address . args_and_flags +@deffn {Scheme Procedure} sendto sock message fam address . args_and_flags +@deffnx {C Function} scm_sendto (sock, message, fam, address, args_and_flags) Transmit the string @var{message} on the socket port @var{sock}. The destination address is specified using the @var{fam}, diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 3fa2b7d7f..8236d1649 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,19 @@ +2001-11-16 Neil Jerram + + * debugging.texi, deprecated.texi, intro.texi, misc-modules.texi, + new-docstrings.texi, posix.texi, scheme-binding.texi, + scheme-control.texi, scheme-data.texi, scheme-debug.texi, + scheme-evaluation.texi, scheme-io.texi, scheme-memory.texi, + scheme-modules.texi, scheme-options.texi, scheme-procedures.texi, + scheme-scheduling.texi, scheme-translation.texi, + scheme-utility.texi, script-getopt.texi, srfi-modules.texi: Change + category for "primitive" and "procedure" @deffn's to {Scheme + Procedure}; add @deffnx lines for {C Function}s; automatic updates + from libguile docstring changes. + + * scheme-memory.texi (Garbage Collection): Removed doc for removed + `unhash-name'. + 2001-11-14 Thien-Thi Nguyen * scheme-procedures.texi: Spell "library" correctly. diff --git a/doc/ref/debugging.texi b/doc/ref/debugging.texi index 28607c551..045772721 100644 --- a/doc/ref/debugging.texi +++ b/doc/ref/debugging.texi @@ -117,11 +117,11 @@ function calls, each of which is called a @dfn{frame}. The programmer can learn more about the program's state at the point of interruption by inspecting and modifying these frames. -@deffn primitive stack? obj +@deffn {Scheme Procedure} stack? obj Return @code{#t} if @var{obj} is a calling stack. @end deffn -@deffn primitive make-stack +@deffn {Scheme Procedure} make-stack @end deffn @deffn syntax start-stack id exp @@ -132,48 +132,48 @@ way of artificially limiting backtraces and stack procedures, largely as a convenience to the user. @end deffn -@deffn primitive stack-id stack +@deffn {Scheme Procedure} stack-id stack Return the identifier given to @var{stack} by @code{start-stack}. @end deffn -@deffn primitive stack-ref +@deffn {Scheme Procedure} stack-ref @end deffn -@deffn primitive stack-length +@deffn {Scheme Procedure} stack-length @end deffn -@deffn primitive frame? +@deffn {Scheme Procedure} frame? @end deffn -@deffn primitive last-stack-frame +@deffn {Scheme Procedure} last-stack-frame @end deffn -@deffn primitive frame-number +@deffn {Scheme Procedure} frame-number @end deffn -@deffn primitive frame-source +@deffn {Scheme Procedure} frame-source @end deffn -@deffn primitive frame-procedure +@deffn {Scheme Procedure} frame-procedure @end deffn -@deffn primitive frame-arguments +@deffn {Scheme Procedure} frame-arguments @end deffn -@deffn primitive frame-previous +@deffn {Scheme Procedure} frame-previous @end deffn -@deffn primitive frame-next +@deffn {Scheme Procedure} frame-next @end deffn -@deffn primitive frame-real? +@deffn {Scheme Procedure} frame-real? @end deffn -@deffn primitive frame-procedure? +@deffn {Scheme Procedure} frame-procedure? @end deffn -@deffn primitive frame-evaluating-args? +@deffn {Scheme Procedure} frame-evaluating-args? @end deffn -@deffn primitive frame-overflow +@deffn {Scheme Procedure} frame-overflow @end deffn diff --git a/doc/ref/deprecated.texi b/doc/ref/deprecated.texi index e99e73819..3f423fe7f 100644 --- a/doc/ref/deprecated.texi +++ b/doc/ref/deprecated.texi @@ -38,7 +38,7 @@ substring is an object that mostly behaves just like an ordinary substring, except that it actually shares storage space with its parent string. -@deffn primitive make-shared-substring str [start [end]] +@deffn {Scheme Procedure} make-shared-substring str [start [end]] Return a shared substring of @var{str}. The arguments are the same as for the @code{substring} function: the shared substring returned includes all of the text from @var{str} between @@ -132,7 +132,7 @@ now require strings: ERROR: Wrong type argument (expecting STRINGP): /home/ @end lisp -@deffn primitive read-only-string? obj +@deffn {Scheme Procedure} read-only-string? obj Return @code{#t} if @var{obj} is either a string or a symbol, otherwise return @code{#f}. @end deffn diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi index 9391a1d48..09da686c6 100644 --- a/doc/ref/intro.texi +++ b/doc/ref/intro.texi @@ -1,4 +1,4 @@ -@c $Id: intro.texi,v 1.3 2001-11-11 15:01:51 ossau Exp $ +@c $Id: intro.texi,v 1.4 2001-11-16 15:04:16 ossau Exp $ @page @@ -200,8 +200,8 @@ As another example, here is a simple replacement for the POSIX (newline) @end example -@deffn procedure command-line -@deffnx primitive program-arguments +@deffn {Scheme Procedure} command-line +@deffnx {Scheme Procedure} program-arguments Return a list of the command-line arguments passed to the currently running program. If the program invoked Guile with the @samp{-s}, @samp{-c} or @samp{--} switches, these procedures ignore everything up diff --git a/doc/ref/misc-modules.texi b/doc/ref/misc-modules.texi index 9dd6d99f0..be4f2ca46 100644 --- a/doc/ref/misc-modules.texi +++ b/doc/ref/misc-modules.texi @@ -30,7 +30,7 @@ how @code{pretty-print} will format the output, see the following: (else (if (= x 1) 2 (* x x x)))))) @end lisp -@deffn procedure pretty-print obj [port] +@deffn {Scheme Procedure} pretty-print obj [port] Print the textual representation of the Scheme object @var{obj} to @var{port}. @var{port} defaults to the current output port, if not given. @@ -76,7 +76,7 @@ The @code{format} procedure, to be found in module @code{(ice-9 format)}, can do all this, and even more. If you are a C programmer, you can think of this procedure as Guile's @code{fprintf}. -@deffn procedure format destination format-string args @dots{} +@deffn {Scheme Procedure} format destination format-string args @dots{} The first parameter is the @var{destination}, it determines where the output of @code{format} will go. diff --git a/doc/ref/new-docstrings.texi b/doc/ref/new-docstrings.texi index 02a1a4aad..65ea5a620 100644 --- a/doc/ref/new-docstrings.texi +++ b/doc/ref/new-docstrings.texi @@ -1,23 +1,27 @@ @c module (guile) -@deffn primitive environment? obj +@deffn {Scheme Procedure} environment? obj +@deffnx {C Function} scm_environment_p (obj) Return @code{#t} if @var{obj} is an environment, or @code{#f} otherwise. @end deffn -@deffn primitive environment-bound? env sym +@deffn {Scheme Procedure} environment-bound? env sym +@deffnx {C Function} scm_environment_bound_p (env, sym) Return @code{#t} if @var{sym} is bound in @var{env}, or @code{#f} otherwise. @end deffn -@deffn primitive environment-ref env sym +@deffn {Scheme Procedure} environment-ref env sym +@deffnx {C Function} scm_environment_ref (env, sym) Return the value of the location bound to @var{sym} in @var{env}. If @var{sym} is unbound in @var{env}, signal an @code{environment:unbound} error. @end deffn -@deffn primitive environment-fold env proc init +@deffn {Scheme Procedure} environment-fold env proc init +@deffnx {C Function} scm_environment_fold (env, proc, init) Iterate over all the bindings in @var{env}, accumulating some value. For each binding in @var{env}, apply @var{proc} to the symbol @@ -51,7 +55,8 @@ using environment-fold: @end lisp @end deffn -@deffn primitive environment-define env sym val +@deffn {Scheme Procedure} environment-define env sym val +@deffnx {C Function} scm_environment_define (env, sym, val) Bind @var{sym} to a new location containing @var{val} in @var{env}. If @var{sym} is already bound to another location in @var{env} and the binding is mutable, that binding is @@ -61,7 +66,8 @@ If @var{sym} is already bound in @var{env}, and the binding is immutable, signal an @code{environment:immutable-binding} error. @end deffn -@deffn primitive environment-undefine env sym +@deffn {Scheme Procedure} environment-undefine env sym +@deffnx {C Function} scm_environment_undefine (env, sym) Remove any binding for @var{sym} from @var{env}. If @var{sym} is unbound in @var{env}, do nothing. The return value is unspecified. @@ -69,7 +75,8 @@ If @var{sym} is already bound in @var{env}, and the binding is immutable, signal an @code{environment:immutable-binding} error. @end deffn -@deffn primitive environment-set! env sym val +@deffn {Scheme Procedure} environment-set! env sym val +@deffnx {C Function} scm_environment_set_x (env, sym, val) If @var{env} binds @var{sym} to some location, change that location's value to @var{val}. The return value is unspecified. @@ -79,7 +86,8 @@ to an immutable location, signal an @code{environment:immutable-location} error. @end deffn -@deffn primitive environment-cell env sym for_write +@deffn {Scheme Procedure} environment-cell env sym for_write +@deffnx {C Function} scm_environment_cell (env, sym, for_write) Return the value cell which @var{env} binds to @var{sym}, or @code{#f} if the binding does not live in a value cell. The argument @var{for-write} indicates whether the caller @@ -94,7 +102,8 @@ If you use this function, you should consider using re-bound to a new value cell, or becomes undefined. @end deffn -@deffn primitive environment-observe env proc +@deffn {Scheme Procedure} environment-observe env proc +@deffnx {C Function} scm_environment_observe (env, proc) Whenever @var{env}'s bindings change, apply @var{proc} to @var{env}. This function returns an object, token, which you can pass to @@ -103,7 +112,8 @@ of procedures observing @var{env}. The type and value of token is unspecified. @end deffn -@deffn primitive environment-observe-weak env proc +@deffn {Scheme Procedure} environment-observe-weak env proc +@deffnx {C Function} scm_environment_observe_weak (env, proc) This function is the same as environment-observe, except that the reference @var{env} retains to @var{proc} is a weak reference. This means that, if there are no other live, @@ -112,7 +122,8 @@ garbage-collected, and dropped from @var{env}'s list of observing procedures. @end deffn -@deffn primitive environment-unobserve token +@deffn {Scheme Procedure} environment-unobserve token +@deffnx {C Function} scm_environment_unobserve (token) Cancel the observation request which returned the value @var{token}. The return value is unspecified. If a call @code{(environment-observe env proc)} returns @@ -121,18 +132,21 @@ will cause @var{proc} to no longer be called when @var{env}'s bindings change. @end deffn -@deffn primitive make-leaf-environment +@deffn {Scheme Procedure} make-leaf-environment +@deffnx {C Function} scm_make_leaf_environment () Create a new leaf environment, containing no bindings. All bindings and locations created in the new environment will be mutable. @end deffn -@deffn primitive leaf-environment? object +@deffn {Scheme Procedure} leaf-environment? object +@deffnx {C Function} scm_leaf_environment_p (object) Return @code{#t} if object is a leaf environment, or @code{#f} otherwise. @end deffn -@deffn primitive make-eval-environment local imported +@deffn {Scheme Procedure} make-eval-environment local imported +@deffnx {C Function} scm_make_eval_environment (local, imported) Return a new environment object eval whose bindings are the union of the bindings in the environments @var{local} and @var{imported}, with bindings from @var{local} taking @@ -156,28 +170,34 @@ In typical use, @var{local} will be a finite environment, and @var{imported} will be an import environment @end deffn -@deffn primitive eval-environment? object +@deffn {Scheme Procedure} eval-environment? object +@deffnx {C Function} scm_eval_environment_p (object) Return @code{#t} if object is an eval environment, or @code{#f} otherwise. @end deffn -@deffn primitive eval-environment-local env +@deffn {Scheme Procedure} eval-environment-local env +@deffnx {C Function} scm_eval_environment_local (env) Return the local environment of eval environment @var{env}. @end deffn -@deffn primitive eval-environment-set-local! env local +@deffn {Scheme Procedure} eval-environment-set-local! env local +@deffnx {C Function} scm_eval_environment_set_local_x (env, local) Change @var{env}'s local environment to @var{local}. @end deffn -@deffn primitive eval-environment-imported env +@deffn {Scheme Procedure} eval-environment-imported env +@deffnx {C Function} scm_eval_environment_imported (env) Return the imported environment of eval environment @var{env}. @end deffn -@deffn primitive eval-environment-set-imported! env imported +@deffn {Scheme Procedure} eval-environment-set-imported! env imported +@deffnx {C Function} scm_eval_environment_set_imported_x (env, imported) Change @var{env}'s imported environment to @var{imported}. @end deffn -@deffn primitive make-import-environment imports conflict_proc +@deffn {Scheme Procedure} make-import-environment imports conflict_proc +@deffnx {C Function} scm_make_import_environment (imports, conflict_proc) Return a new environment @var{imp} whose bindings are the union of the bindings from the environments in @var{imports}; @var{imports} must be a list of environments. That is, @@ -205,22 +225,26 @@ notice that the set of bindings in @var{imp} may still change, if one of its imported environments changes. @end deffn -@deffn primitive import-environment? object +@deffn {Scheme Procedure} import-environment? object +@deffnx {C Function} scm_import_environment_p (object) Return @code{#t} if object is an import environment, or @code{#f} otherwise. @end deffn -@deffn primitive import-environment-imports env +@deffn {Scheme Procedure} import-environment-imports env +@deffnx {C Function} scm_import_environment_imports (env) Return the list of environments imported by the import environment @var{env}. @end deffn -@deffn primitive import-environment-set-imports! env imports +@deffn {Scheme Procedure} import-environment-set-imports! env imports +@deffnx {C Function} scm_import_environment_set_imports_x (env, imports) Change @var{env}'s list of imported environments to @var{imports}, and check for conflicts. @end deffn -@deffn primitive make-export-environment private signature +@deffn {Scheme Procedure} make-export-environment private signature +@deffnx {C Function} scm_make_export_environment (private, signature) Return a new environment @var{exp} containing only those bindings in private whose symbols are present in @var{signature}. The @var{private} argument must be an @@ -267,34 +291,41 @@ notice that the set of bindings in @var{exp} may still change, if the bindings in private change. @end deffn -@deffn primitive export-environment? object +@deffn {Scheme Procedure} export-environment? object +@deffnx {C Function} scm_export_environment_p (object) Return @code{#t} if object is an export environment, or @code{#f} otherwise. @end deffn -@deffn primitive export-environment-private env +@deffn {Scheme Procedure} export-environment-private env +@deffnx {C Function} scm_export_environment_private (env) Return the private environment of export environment @var{env}. @end deffn -@deffn primitive export-environment-set-private! env private +@deffn {Scheme Procedure} export-environment-set-private! env private +@deffnx {C Function} scm_export_environment_set_private_x (env, private) Change the private environment of export environment @var{env}. @end deffn -@deffn primitive export-environment-signature env +@deffn {Scheme Procedure} export-environment-signature env +@deffnx {C Function} scm_export_environment_signature (env) Return the signature of export environment @var{env}. @end deffn -@deffn primitive export-environment-set-signature! env signature +@deffn {Scheme Procedure} export-environment-set-signature! env signature +@deffnx {C Function} scm_export_environment_set_signature_x (env, signature) Change the signature of export environment @var{env}. @end deffn -@deffn primitive %compute-slots class +@deffn {Scheme Procedure} %compute-slots class +@deffnx {C Function} scm_sys_compute_slots (class) Return a list consisting of the names of all slots belonging to class @var{class}, i. e. the slots of @var{class} and of all of its superclasses. @end deffn -@deffn primitive get-keyword key l default_value +@deffn {Scheme Procedure} get-keyword key l default_value +@deffnx {C Function} scm_get_keyword (key, l, default_value) Determine an associated value for the keyword @var{key} from the list @var{l}. The list @var{l} has to consist of an even number of elements, where, starting with the first, every @@ -303,222 +334,271 @@ If @var{l} does not hold a value for @var{key}, the value @var{default_value} is returned. @end deffn -@deffn primitive slot-ref-using-class class obj slot_name +@deffn {Scheme Procedure} slot-ref-using-class class obj slot_name +@deffnx {C Function} scm_slot_ref_using_class (class, obj, slot_name) @end deffn -@deffn primitive slot-set-using-class! class obj slot_name value +@deffn {Scheme Procedure} slot-set-using-class! class obj slot_name value +@deffnx {C Function} scm_slot_set_using_class_x (class, obj, slot_name, value) @end deffn -@deffn primitive class-of x +@deffn {Scheme Procedure} class-of x +@deffnx {C Function} scm_class_of (x) Return the class of @var{x}. @end deffn -@deffn primitive %goops-loaded +@deffn {Scheme Procedure} %goops-loaded +@deffnx {C Function} scm_sys_goops_loaded () Announce that GOOPS is loaded and perform initialization on the C level which depends on the loaded GOOPS modules. @end deffn -@deffn primitive %method-more-specific? m1 m2 targs +@deffn {Scheme Procedure} %method-more-specific? m1 m2 targs +@deffnx {C Function} scm_sys_method_more_specific_p (m1, m2, targs) @end deffn -@deffn primitive find-method . l +@deffn {Scheme Procedure} find-method . l +@deffnx {C Function} scm_find_method (l) @end deffn -@deffn primitive primitive-generic-generic subr +@deffn {Scheme Procedure} primitive-generic-generic subr +@deffnx {C Function} scm_primitive_generic_generic (subr) @end deffn -@deffn primitive enable-primitive-generic! . subrs +@deffn {Scheme Procedure} enable-primitive-generic! . subrs +@deffnx {C Function} scm_enable_primitive_generic_x (subrs) @end deffn -@deffn primitive generic-capability? proc +@deffn {Scheme Procedure} generic-capability? proc +@deffnx {C Function} scm_generic_capability_p (proc) @end deffn -@deffn primitive %invalidate-method-cache! gf +@deffn {Scheme Procedure} %invalidate-method-cache! gf +@deffnx {C Function} scm_sys_invalidate_method_cache_x (gf) @end deffn -@deffn primitive %invalidate-class class +@deffn {Scheme Procedure} %invalidate-class class +@deffnx {C Function} scm_sys_invalidate_class (class) @end deffn -@deffn primitive %modify-class old new +@deffn {Scheme Procedure} %modify-class old new +@deffnx {C Function} scm_sys_modify_class (old, new) @end deffn -@deffn primitive %modify-instance old new +@deffn {Scheme Procedure} %modify-instance old new +@deffnx {C Function} scm_sys_modify_instance (old, new) @end deffn -@deffn primitive %set-object-setter! obj setter +@deffn {Scheme Procedure} %set-object-setter! obj setter +@deffnx {C Function} scm_sys_set_object_setter_x (obj, setter) @end deffn -@deffn primitive %allocate-instance class initargs +@deffn {Scheme Procedure} %allocate-instance class initargs +@deffnx {C Function} scm_sys_allocate_instance (class, initargs) Create a new instance of class @var{class} and initialize it from the arguments @var{initargs}. @end deffn -@deffn primitive slot-exists? obj slot_name +@deffn {Scheme Procedure} slot-exists? obj slot_name +@deffnx {C Function} scm_slots_exists_p (obj, slot_name) Return @code{#t} if @var{obj} has a slot named @var{slot_name}. @end deffn -@deffn primitive slot-bound? obj slot_name +@deffn {Scheme Procedure} slot-bound? obj slot_name +@deffnx {C Function} scm_slot_bound_p (obj, slot_name) Return @code{#t} if the slot named @var{slot_name} of @var{obj} is bound. @end deffn -@deffn primitive slot-set! obj slot_name value +@deffn {Scheme Procedure} slot-set! obj slot_name value +@deffnx {C Function} scm_slot_set_x (obj, slot_name, value) Set the slot named @var{slot_name} of @var{obj} to @var{value}. @end deffn -@deffn primitive slot-exists-using-class? class obj slot_name +@deffn {Scheme Procedure} slot-exists-using-class? class obj slot_name +@deffnx {C Function} scm_slot_exists_using_class_p (class, obj, slot_name) @end deffn -@deffn primitive slot-bound-using-class? class obj slot_name +@deffn {Scheme Procedure} slot-bound-using-class? class obj slot_name +@deffnx {C Function} scm_slot_bound_using_class_p (class, obj, slot_name) @end deffn -@deffn primitive %fast-slot-set! obj index value +@deffn {Scheme Procedure} %fast-slot-set! obj index value +@deffnx {C Function} scm_sys_fast_slot_set_x (obj, index, value) Set the slot with index @var{index} in @var{obj} to @var{value}. @end deffn -@deffn primitive %fast-slot-ref obj index +@deffn {Scheme Procedure} %fast-slot-ref obj index +@deffnx {C Function} scm_sys_fast_slot_ref (obj, index) Return the slot value with index @var{index} from @var{obj}. @end deffn -@deffn primitive @@assert-bound-ref obj index +@deffn {Scheme Procedure} @@assert-bound-ref obj index +@deffnx {C Function} scm_at_assert_bound_ref (obj, index) Like @code{assert-bound}, but use @var{index} for accessing the value from @var{obj}. @end deffn -@deffn primitive assert-bound value obj +@deffn {Scheme Procedure} assert-bound value obj +@deffnx {C Function} scm_assert_bound (value, obj) Return @var{value} if it is bound, and invoke the @var{slot-unbound} method of @var{obj} if it is not. @end deffn -@deffn primitive unbound? obj +@deffn {Scheme Procedure} unbound? obj +@deffnx {C Function} scm_unbound_p (obj) Return @code{#t} if @var{obj} is unbound. @end deffn -@deffn primitive make-unbound +@deffn {Scheme Procedure} make-unbound +@deffnx {C Function} scm_make_unbound () Return the unbound value. @end deffn -@deffn primitive accessor-method-slot-definition obj +@deffn {Scheme Procedure} accessor-method-slot-definition obj +@deffnx {C Function} scm_accessor_method_slot_definition (obj) Return the slot definition of the accessor @var{obj}. @end deffn -@deffn primitive method-procedure obj +@deffn {Scheme Procedure} method-procedure obj +@deffnx {C Function} scm_method_procedure (obj) Return the procedure of the method @var{obj}. @end deffn -@deffn primitive method-specializers obj +@deffn {Scheme Procedure} method-specializers obj +@deffnx {C Function} scm_method_specializers (obj) Return specializers of the method @var{obj}. @end deffn -@deffn primitive method-generic-function obj +@deffn {Scheme Procedure} method-generic-function obj +@deffnx {C Function} scm_method_generic_function (obj) Return the generic function fot the method @var{obj}. @end deffn -@deffn primitive generic-function-methods obj +@deffn {Scheme Procedure} generic-function-methods obj +@deffnx {C Function} scm_generic_function_methods (obj) Return the methods of the generic function @var{obj}. @end deffn -@deffn primitive generic-function-name obj +@deffn {Scheme Procedure} generic-function-name obj +@deffnx {C Function} scm_generic_function_name (obj) Return the name of the generic function @var{obj}. @end deffn -@deffn primitive class-environment obj +@deffn {Scheme Procedure} class-environment obj +@deffnx {C Function} scm_class_environment (obj) Return the environment of the class @var{obj}. @end deffn -@deffn primitive class-slots obj +@deffn {Scheme Procedure} class-slots obj +@deffnx {C Function} scm_class_slots (obj) Return the slot list of the class @var{obj}. @end deffn -@deffn primitive class-precedence-list obj +@deffn {Scheme Procedure} class-precedence-list obj +@deffnx {C Function} scm_class_precedence_list (obj) Return the class precedence list of the class @var{obj}. @end deffn -@deffn primitive class-direct-methods obj +@deffn {Scheme Procedure} class-direct-methods obj +@deffnx {C Function} scm_class_direct_methods (obj) Return the direct methods of the class @var{obj} @end deffn -@deffn primitive class-direct-subclasses obj +@deffn {Scheme Procedure} class-direct-subclasses obj +@deffnx {C Function} scm_class_direct_subclasses (obj) Return the direct subclasses of the class @var{obj}. @end deffn -@deffn primitive class-direct-slots obj +@deffn {Scheme Procedure} class-direct-slots obj +@deffnx {C Function} scm_class_direct_slots (obj) Return the direct slots of the class @var{obj}. @end deffn -@deffn primitive class-direct-supers obj +@deffn {Scheme Procedure} class-direct-supers obj +@deffnx {C Function} scm_class_direct_supers (obj) Return the direct superclasses of the class @var{obj}. @end deffn -@deffn primitive class-name obj +@deffn {Scheme Procedure} class-name obj +@deffnx {C Function} scm_class_name (obj) Return the class name of @var{obj}. @end deffn -@deffn primitive instance? obj +@deffn {Scheme Procedure} instance? obj +@deffnx {C Function} scm_instance_p (obj) Return @code{#t} if @var{obj} is an instance. @end deffn -@deffn primitive %inherit-magic! class dsupers +@deffn {Scheme Procedure} %inherit-magic! class dsupers +@deffnx {C Function} scm_sys_inherit_magic_x (class, dsupers) @end deffn -@deffn primitive %prep-layout! class +@deffn {Scheme Procedure} %prep-layout! class +@deffnx {C Function} scm_sys_prep_layout_x (class) @end deffn -@deffn primitive %initialize-object obj initargs +@deffn {Scheme Procedure} %initialize-object obj initargs +@deffnx {C Function} scm_sys_initialize_object (obj, initargs) Initialize the object @var{obj} with the given arguments @var{initargs}. @end deffn -@deffn primitive make . args +@deffn {Scheme Procedure} make . args +@deffnx {C Function} scm_make (args) Make a new object. @var{args} must contain the class and all necessary initialization information. @end deffn -@deffn primitive slot-ref obj slot_name +@deffn {Scheme Procedure} slot-ref obj slot_name +@deffnx {C Function} scm_slot_ref (obj, slot_name) Return the value from @var{obj}'s slot with the name @var{slot_name}. @end deffn -@deffn primitive builtin-bindings +@deffn {Scheme Procedure} builtin-bindings Create and return a copy of the global symbol table, removing all unbound symbols. @end deffn -@deffn primitive %tag-body body +@deffn {Scheme Procedure} %tag-body body +@deffnx {C Function} scm_sys_tag_body (body) Internal GOOPS magic---don't use this function! @end deffn -@deffn primitive list* +@deffn {Scheme Procedure} list* implemented by the C function "scm_cons_star" @end deffn -@deffn primitive set-current-module module +@deffn {Scheme Procedure} set-current-module module +@deffnx {C Function} scm_set_current_module (module) Set the current module to @var{module} and return the previous current module. @end deffn -@deffn primitive current-module +@deffn {Scheme Procedure} current-module +@deffnx {C Function} scm_current_module () Return the current module. @end deffn -@deffn primitive c-clear-registered-modules +@deffn {Scheme Procedure} c-clear-registered-modules Destroy the list of modules registered with the current Guile process. The return value is unspecified. @strong{Warning:} this function does not actually unlink or deallocate these modules, but only destroys the @@ -526,7 +606,7 @@ records of which modules have been loaded. It should therefore be used only by module bookkeeping operations. @end deffn -@deffn primitive c-registered-modules +@deffn {Scheme Procedure} c-registered-modules Return a list of the object code modules that have been imported into the current Guile process. Each element of the list is a pair whose car is the name of the module, and whose cdr is the function handle @@ -534,12 +614,12 @@ for that module's initializer function. The name is the string that has been passed to scm_register_module_xxx. @end deffn -@deffn primitive include-deprecated-features +@deffn {Scheme Procedure} include-deprecated-features Return @code{#t} iff deprecated features should be included in public interfaces. @end deffn -@deffn primitive issue-deprecation-warning . msgs +@deffn {Scheme Procedure} issue-deprecation-warning . msgs Output @var{msgs} to @code{(current-error-port)} when this is the first call to @code{issue-deprecation-warning} with this specific @var{msg}. Do nothing otherwise. @@ -547,23 +627,28 @@ The argument @var{msgs} should be a list of strings; they are printed in turn, each one followed by a newline. @end deffn -@deffn primitive valid-object-procedure? proc +@deffn {Scheme Procedure} valid-object-procedure? proc +@deffnx {C Function} scm_valid_object_procedure_p (proc) Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}. @end deffn -@deffn primitive %get-pre-modules-obarray +@deffn {Scheme Procedure} %get-pre-modules-obarray +@deffnx {C Function} scm_get_pre_modules_obarray () Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system. @end deffn -@deffn primitive standard-interface-eval-closure module +@deffn {Scheme Procedure} standard-interface-eval-closure module +@deffnx {C Function} scm_standard_interface_eval_closure (module) Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added. @end deffn -@deffn primitive env-module env +@deffn {Scheme Procedure} env-module env +@deffnx {C Function} scm_env_module (env) Return the module of @var{ENV}, a lexical environment. @end deffn -@deffn primitive load-extension lib init +@deffn {Scheme Procedure} load-extension lib init +@deffnx {C Function} scm_load_extension (lib, init) Load and initialize the extension designated by LIB and INIT. When there is no pre-registered function for LIB/INIT, this is equivalent to diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index f2237f2c1..e2fd65873 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -145,51 +145,57 @@ one, so that dropping references to one of these ports will not result in its garbage collection: it could be retrieved with fdopen or fdes->ports. -@deffn primitive port-revealed port +@deffn {Scheme Procedure} port-revealed port +@deffnx {C Function} scm_port_revealed (port) Return the revealed count for @var{port}. @end deffn -@deffn primitive set-port-revealed! port rcount +@deffn {Scheme Procedure} set-port-revealed! port rcount +@deffnx {C Function} scm_set_port_revealed_x (port, rcount) Sets the revealed count for a port to a given value. The return value is unspecified. @end deffn -@deffn primitive fileno port +@deffn {Scheme Procedure} fileno port +@deffnx {C Function} scm_fileno (port) Return the integer file descriptor underlying @var{port}. Does not change its revealed count. @end deffn -@deffn procedure port->fdes port +@deffn {Scheme Procedure} port->fdes port Returns the integer file descriptor underlying @var{port}. As a side effect the revealed count of @var{port} is incremented. @end deffn -@deffn primitive fdopen fdes modes +@deffn {Scheme Procedure} fdopen fdes modes +@deffnx {C Function} scm_fdopen (fdes, modes) Return a new port based on the file descriptor @var{fdes}. Modes are given by the string @var{modes}. The revealed count of the port is initialized to zero. The modes string is the same as that accepted by @ref{File Ports, open-file}. @end deffn -@deffn primitive fdes->ports fd +@deffn {Scheme Procedure} fdes->ports fd +@deffnx {C Function} scm_fdes_to_ports (fd) Return a list of existing ports which have @var{fdes} as an underlying file descriptor, without changing their revealed counts. @end deffn -@deffn procedure fdes->inport fdes +@deffn {Scheme Procedure} fdes->inport fdes Returns an existing input port which has @var{fdes} as its underlying file descriptor, if one exists, and increments its revealed count. Otherwise, returns a new input port with a revealed count of 1. @end deffn -@deffn procedure fdes->outport fdes +@deffn {Scheme Procedure} fdes->outport fdes Returns an existing output port which has @var{fdes} as its underlying file descriptor, if one exists, and increments its revealed count. Otherwise, returns a new output port with a revealed count of 1. @end deffn -@deffn primitive primitive-move->fdes port fd +@deffn {Scheme Procedure} primitive-move->fdes port fd +@deffnx {C Function} scm_primitive_move_to_fdes (port, fd) Moves the underlying file descriptor for @var{port} to the integer value @var{fdes} without changing the revealed count of @var{port}. Any other ports already using this descriptor will be automatically @@ -198,7 +204,7 @@ The return value is @code{#f} if the file descriptor already had the required value or @code{#t} if it was moved. @end deffn -@deffn procedure move->fdes port fdes +@deffn {Scheme Procedure} move->fdes port fdes Moves the underlying file descriptor for @var{port} to the integer value @var{fdes} and sets its revealed count to one. Any other ports already using this descriptor will be automatically @@ -206,18 +212,20 @@ shifted to new descriptors and their revealed counts reset to zero. The return value is unspecified. @end deffn -@deffn procedure release-port-handle port +@deffn {Scheme Procedure} release-port-handle port Decrements the revealed count for a port. @end deffn -@deffn primitive fsync object +@deffn {Scheme Procedure} fsync object +@deffnx {C Function} scm_fsync (object) Copies any unwritten data for the specified output file descriptor to disk. If @var{port/fd} is a port, its buffer is flushed before the underlying file descriptor is fsync'd. The return value is unspecified. @end deffn -@deffn primitive open path flags [mode] +@deffn {Scheme Procedure} open path flags [mode] +@deffnx {C Function} scm_open (path, flags, mode) Open the file named by @var{path} for reading and/or writing. @var{flags} is an integer specifying how the file should be opened. @var{mode} is an integer specifying the permission bits of the file, if @@ -247,19 +255,23 @@ See the Unix documentation of the @code{open} system call for additional flags. @end deffn -@deffn primitive open-fdes path flags [mode] +@deffn {Scheme Procedure} open-fdes path flags [mode] +@deffnx {C Function} scm_open_fdes (path, flags, mode) Similar to @code{open} but return a file descriptor instead of a port. @end deffn -@deffn primitive close fd_or_port -Similar to close-port (@pxref{Closing, close-port}), but also works on -file descriptors. A side effect of closing a file descriptor is that -any ports using that file descriptor are moved to a different file -descriptor and have their revealed counts set to zero. +@deffn {Scheme Procedure} close fd_or_port +@deffnx {C Function} scm_close (fd_or_port) +Similar to close-port (@pxref{Closing, close-port}), +but also works on file descriptors. A side +effect of closing a file descriptor is that any ports using that file +descriptor are moved to a different file descriptor and have +their revealed counts set to zero. @end deffn -@deffn primitive close-fdes fd +@deffn {Scheme Procedure} close-fdes fd +@deffnx {C Function} scm_close_fdes (fd) A simple wrapper for the @code{close} system call. Close file descriptor @var{fd}, which must be an integer. Unlike close (@pxref{Ports and File Descriptors, close}), @@ -267,21 +279,22 @@ the file descriptor will be closed even if a port is using it. The return value is unspecified. @end deffn -@deffn primitive unread-char char [port] +@deffn {Scheme Procedure} unread-char char [port] Place @var{char} in @var{port} so that it will be read by the next read operation. If called multiple times, the unread characters will be read again in last-in first-out order. If @var{port} is not supplied, the current input port is used. @end deffn -@deffn primitive unread-string str port +@deffn {Scheme Procedure} unread-string str port Place the string @var{str} in @var{port} so that its characters will be read in subsequent read operations. If called multiple times, the unread characters will be read again in last-in first-out order. If @var{port} is not supplied, the current-input-port is used. @end deffn -@deffn primitive pipe +@deffn {Scheme Procedure} pipe +@deffnx {C Function} scm_pipe () Return a newly created pipe: a pair of ports which are linked together on the local machine. The @emph{car} is the input port and the @emph{cdr} is the output port. Data written (and @@ -307,31 +320,32 @@ All procedures also have the side effect when performing @code{dup2} that any ports using @var{newfd} are moved to a different file descriptor and have their revealed counts set to zero. -@deffn primitive dup->fdes fd_or_port [fd] +@deffn {Scheme Procedure} dup->fdes fd_or_port [fd] +@deffnx {C Function} scm_dup_to_fdes (fd_or_port, fd) Return a new integer file descriptor referring to the open file designated by @var{fd_or_port}, which must be either an open file port or a file descriptor. @end deffn -@deffn procedure dup->inport port/fd [newfd] +@deffn {Scheme Procedure} dup->inport port/fd [newfd] Returns a new input port using the new file descriptor. @end deffn -@deffn procedure dup->outport port/fd [newfd] +@deffn {Scheme Procedure} dup->outport port/fd [newfd] Returns a new output port using the new file descriptor. @end deffn -@deffn procedure dup port/fd [newfd] +@deffn {Scheme Procedure} dup port/fd [newfd] Returns a new port if @var{port/fd} is a port, with the same mode as the supplied port, otherwise returns an integer file descriptor. @end deffn -@deffn procedure dup->port port/fd mode [newfd] +@deffn {Scheme Procedure} dup->port port/fd mode [newfd] Returns a new port using the new file descriptor. @var{mode} supplies a mode string for the port (@pxref{File Ports, open-file}). @end deffn -@deffn procedure duplicate-port port modes +@deffn {Scheme Procedure} duplicate-port port modes Returns a new port which is opened on a duplicate of the file descriptor underlying @var{port}, with mode string @var{modes} as for @ref{File Ports, open-file}. The two ports @@ -345,7 +359,8 @@ port. This procedure is equivalent to @code{(dup->port @var{port} @var{modes})}. @end deffn -@deffn primitive redirect-port old new +@deffn {Scheme Procedure} redirect-port old new +@deffnx {C Function} scm_redirect_port (old, new) This procedure takes two ports and duplicates the underlying file descriptor from @var{old-port} into @var{new-port}. The current file descriptor in @var{new-port} will be closed. @@ -361,7 +376,8 @@ This procedure does not have any side effects on other ports or revealed counts. @end deffn -@deffn primitive dup2 oldfd newfd +@deffn {Scheme Procedure} dup2 oldfd newfd +@deffnx {C Function} scm_dup2 (oldfd, newfd) A simple wrapper for the @code{dup2} system call. Copies the file descriptor @var{oldfd} to descriptor number @var{newfd}, replacing the previous meaning @@ -372,14 +388,14 @@ is made to move away ports which are using @var{newfd}. The return value is unspecified. @end deffn -@deffn primitive port-mode port +@deffn {Scheme Procedure} port-mode port Return the port modes associated with the open port @var{port}. These will not necessarily be identical to the modes used when the port was opened, since modes such as "append" which are used only during port creation are not retained. @end deffn -@deffn primitive close-all-ports-except . ports +@deffn {Scheme Procedure} close-all-ports-except . ports [DEPRECATED] Close all open file ports used by the interpreter except for those supplied as arguments. This procedure was intended to be used before an exec call to close file descriptors @@ -388,7 +404,8 @@ undesirable side-effect of flushing buffes, so it's deprecated. Use port-for-each instead. @end deffn -@deffn primitive port-for-each proc +@deffn {Scheme Procedure} port-for-each proc +@deffnx {C Function} scm_port_for_each (proc) Apply @var{proc} to each port in the Guile port table in turn. The return value is unspecified. More specifically, @var{proc} is applied exactly once to every port that exists @@ -397,7 +414,8 @@ Changes to the port table while @var{port-for-each} is running have no effect as far as @var{port-for-each} is concerned. @end deffn -@deffn primitive setvbuf port mode [size] +@deffn {Scheme Procedure} setvbuf port mode [size] +@deffnx {C Function} scm_setvbuf (port, mode, size) Set the buffering mode for @var{port}. @var{mode} can be: @table @code @item _IONBF @@ -410,7 +428,8 @@ If @var{size} is omitted, a default size will be used. @end table @end deffn -@deffn primitive fcntl object cmd [value] +@deffn {Scheme Procedure} fcntl object cmd [value] +@deffnx {C Function} scm_fcntl (object, cmd, value) Apply @var{command} to the specified file descriptor or the underlying file descriptor of the specified port. @var{value} is an optional integer argument. @@ -438,7 +457,8 @@ The value used to indicate the "close on exec" flag with @code{F_GETFL} or @end table @end deffn -@deffn primitive flock file operation +@deffn {Scheme Procedure} flock file operation +@deffnx {C Function} scm_flock (file, operation) Apply or remove an advisory lock on an open file. @var{operation} specifies the action to be done: @table @code @@ -458,7 +478,8 @@ The return value is not specified. @var{file} may be an open file descriptor or an open file descriptior port. @end deffn -@deffn primitive select reads writes excepts [secs [usecs]] +@deffn {Scheme Procedure} select reads writes excepts [secs [usecs]] +@deffnx {C Function} scm_select (reads, writes, excepts, secs, usecs) This procedure has a variety of uses: waiting for the ability to provide input, accept output, or the existance of exceptional conditions on a collection of ports or file @@ -499,7 +520,8 @@ permissions, sizes and types of files); deleting, copying, renaming and linking files; creating and removing directories and querying their contents; syncing the file system and creating special files. -@deffn primitive access? path how +@deffn {Scheme Procedure} access? path how +@deffnx {C Function} scm_access (path, how) Return @code{#t} if @var{path} corresponds to an existing file and the current process has the type of access specified by @var{how}, otherwise @code{#f}. @var{how} should be specified @@ -526,7 +548,8 @@ test for existence of the file. @end deffn @findex fstat -@deffn primitive stat object +@deffn {Scheme Procedure} stat object +@deffnx {C Function} scm_stat (object) Return an object containing various information about the file determined by @var{obj}. @var{obj} can be a string containing a file name or a port or integer file descriptor which is open @@ -585,20 +608,23 @@ An integer representing the access permission bits. @end table @end deffn -@deffn primitive lstat str +@deffn {Scheme Procedure} lstat str +@deffnx {C Function} scm_lstat (str) Similar to @code{stat}, but does not follow symbolic links, i.e., it will return information about a symbolic link itself, not the file it points to. @var{path} must be a string. @end deffn -@deffn primitive readlink path +@deffn {Scheme Procedure} readlink path +@deffnx {C Function} scm_readlink (path) Return the value of the symbolic link named by @var{path} (a string), i.e., the file that the link points to. @end deffn @findex fchown @findex lchown -@deffn primitive chown object owner group +@deffn {Scheme Procedure} chown object owner group +@deffnx {C Function} scm_chown (object, owner, group) Change the ownership and group of the file referred to by @var{object} to the integer values @var{owner} and @var{group}. @var{object} can be a string containing a file name or, if the platform @@ -614,7 +640,8 @@ as @code{-1}, then that ID is not changed. @end deffn @findex fchmod -@deffn primitive chmod object mode +@deffn {Scheme Procedure} chmod object mode +@deffnx {C Function} scm_chmod (object, mode) Changes the permissions of the file referred to by @var{obj}. @var{obj} can be a string containing a file name or a port or integer file descriptor which is open on a file (in which case @code{fchmod} is used @@ -624,7 +651,8 @@ the new permissions as a decimal number, e.g., @code{(chmod "foo" #o755)}. The return value is unspecified. @end deffn -@deffn primitive utime pathname [actime [modtime]] +@deffn {Scheme Procedure} utime pathname [actime [modtime]] +@deffnx {C Function} scm_utime (pathname, actime, modtime) @code{utime} sets the access and modification times for the file named by @var{path}. If @var{actime} or @var{modtime} is not supplied, then the current time is used. @var{actime} and @@ -638,77 +666,91 @@ modification time to the current time. @end deffn @findex unlink -@deffn primitive delete-file str +@deffn {Scheme Procedure} delete-file str +@deffnx {C Function} scm_delete_file (str) Deletes (or "unlinks") the file specified by @var{path}. @end deffn -@deffn primitive copy-file oldfile newfile +@deffn {Scheme Procedure} copy-file oldfile newfile +@deffnx {C Function} scm_copy_file (oldfile, newfile) Copy the file specified by @var{path-from} to @var{path-to}. The return value is unspecified. @end deffn @findex rename -@deffn primitive rename-file oldname newname +@deffn {Scheme Procedure} rename-file oldname newname +@deffnx {C Function} scm_rename (oldname, newname) Renames the file specified by @var{oldname} to @var{newname}. The return value is unspecified. @end deffn -@deffn primitive link oldpath newpath +@deffn {Scheme Procedure} link oldpath newpath +@deffnx {C Function} scm_link (oldpath, newpath) Creates a new name @var{newpath} in the file system for the file named by @var{oldpath}. If @var{oldpath} is a symbolic link, the link may or may not be followed depending on the system. @end deffn -@deffn primitive symlink oldpath newpath +@deffn {Scheme Procedure} symlink oldpath newpath +@deffnx {C Function} scm_symlink (oldpath, newpath) Create a symbolic link named @var{path-to} with the value (i.e., pointing to) @var{path-from}. The return value is unspecified. @end deffn -@deffn primitive mkdir path [mode] +@deffn {Scheme Procedure} mkdir path [mode] +@deffnx {C Function} scm_mkdir (path, mode) Create a new directory named by @var{path}. If @var{mode} is omitted then the permissions of the directory file are set using the current umask. Otherwise they are set to the decimal value specified with @var{mode}. The return value is unspecified. @end deffn -@deffn primitive rmdir path +@deffn {Scheme Procedure} rmdir path +@deffnx {C Function} scm_rmdir (path) Remove the existing directory named by @var{path}. The directory must be empty for this to succeed. The return value is unspecified. @end deffn -@deffn primitive opendir dirname +@deffn {Scheme Procedure} opendir dirname +@deffnx {C Function} scm_opendir (dirname) Open the directory specified by @var{path} and return a directory stream. @end deffn -@deffn primitive directory-stream? obj +@deffn {Scheme Procedure} directory-stream? obj +@deffnx {C Function} scm_directory_stream_p (obj) Return a boolean indicating whether @var{object} is a directory stream as returned by @code{opendir}. @end deffn -@deffn primitive readdir port +@deffn {Scheme Procedure} readdir port +@deffnx {C Function} scm_readdir (port) Return (as a string) the next directory entry from the directory stream @var{stream}. If there is no remaining entry to be read then the end of file object is returned. @end deffn -@deffn primitive rewinddir port +@deffn {Scheme Procedure} rewinddir port +@deffnx {C Function} scm_rewinddir (port) Reset the directory port @var{stream} so that the next call to @code{readdir} will return the first directory entry. @end deffn -@deffn primitive closedir port +@deffn {Scheme Procedure} closedir port +@deffnx {C Function} scm_closedir (port) Close the directory stream @var{stream}. The return value is unspecified. @end deffn -@deffn primitive sync +@deffn {Scheme Procedure} sync +@deffnx {C Function} scm_sync () Flush the operating system disk buffers. The return value is unspecified. @end deffn -@deffn primitive mknod path type perms dev +@deffn {Scheme Procedure} mknod path type perms dev +@deffnx {C Function} scm_mknod (path, type, perms, dev) Creates a new special file, such as a file corresponding to a device. @var{path} specifies the name of the file. @var{type} should be one of the following symbols: @@ -726,7 +768,8 @@ E.g., The return value is unspecified. @end deffn -@deffn primitive tmpnam +@deffn {Scheme Procedure} tmpnam +@deffnx {C Function} scm_tmpnam () Return a name in the file system that does not match any existing file. However there is no guarantee that another process will not create the file after @code{tmpnam} is called. @@ -734,7 +777,8 @@ Care should be taken if opening the file, e.g., use the @code{O_EXCL} open flag or use @code{mkstemp!} instead. @end deffn -@deffn primitive mkstemp! tmpl +@deffn {Scheme Procedure} mkstemp! tmpl +@deffnx {C Function} scm_mkstemp (tmpl) Create a new unique file in the file system and returns a new buffered port open for reading and writing to the file. @var{tmpl} is a string specifying where the file should be @@ -742,13 +786,15 @@ created: it must end with @code{XXXXXX} and will be changed in place to return the name of the temporary file. @end deffn -@deffn primitive dirname filename +@deffn {Scheme Procedure} dirname filename +@deffnx {C Function} scm_dirname (filename) Return the directory name component of the file name @var{filename}. If @var{filename} does not contain a directory component, @code{.} is returned. @end deffn -@deffn primitive basename filename [suffix] +@deffn {Scheme Procedure} basename filename [suffix] +@deffnx {C Function} scm_basename (filename, suffix) Return the base name of the file name @var{filename}. The base name is the file name without any directory components. If @var{suffix} is privided, and is equal to the end of @@ -783,36 +829,38 @@ The home directory. The login shell. @end table -@deffn procedure getpwuid uid +@deffn {Scheme Procedure} getpwuid uid Look up an integer userid in the user database. @end deffn -@deffn procedure getpwnam name +@deffn {Scheme Procedure} getpwnam name Look up a user name string in the user database. @end deffn -@deffn procedure setpwent +@deffn {Scheme Procedure} setpwent Initializes a stream used by @code{getpwent} to read from the user database. The next use of @code{getpwent} will return the first entry. The return value is unspecified. @end deffn -@deffn procedure getpwent +@deffn {Scheme Procedure} getpwent Return the next entry in the user database, using the stream set by @code{setpwent}. @end deffn -@deffn procedure endpwent +@deffn {Scheme Procedure} endpwent Closes the stream used by @code{getpwent}. The return value is unspecified. @end deffn -@deffn primitive setpw [arg] +@deffn {Scheme Procedure} setpw [arg] +@deffnx {C Function} scm_setpwent (arg) If called with a true argument, initialize or reset the password data stream. Otherwise, close the stream. The @code{setpwent} and @code{endpwent} procedures are implemented on top of this. @end deffn -@deffn primitive getpw [user] +@deffn {Scheme Procedure} getpw [user] +@deffnx {C Function} scm_getpwuid (user) Look up an entry in the user database. @var{obj} can be an integer, a string, or omitted, giving the behaviour of getpwuid, getpwnam or getpwent respectively. @@ -832,37 +880,39 @@ The group id number. A list of userids which have this group as a supplimentary group. @end table -@deffn procedure getgrgid gid +@deffn {Scheme Procedure} getgrgid gid Look up an integer groupid in the group database. @end deffn -@deffn procedure getgrnam name +@deffn {Scheme Procedure} getgrnam name Look up a group name in the group database. @end deffn -@deffn procedure setgrent +@deffn {Scheme Procedure} setgrent Initializes a stream used by @code{getgrent} to read from the group database. The next use of @code{getgrent} will return the first entry. The return value is unspecified. @end deffn -@deffn procedure getgrent +@deffn {Scheme Procedure} getgrent Return the next entry in the group database, using the stream set by @code{setgrent}. @end deffn -@deffn procedure endgrent +@deffn {Scheme Procedure} endgrent Closes the stream used by @code{getgrent}. The return value is unspecified. @end deffn -@deffn primitive setgr [arg] +@deffn {Scheme Procedure} setgr [arg] +@deffnx {C Function} scm_setgrent (arg) If called with a true argument, initialize or reset the group data stream. Otherwise, close the stream. The @code{setgrent} and @code{endgrent} procedures are implemented on top of this. @end deffn -@deffn primitive getgr [name] +@deffn {Scheme Procedure} getgr [name] +@deffnx {C Function} scm_getgrgid (name) Look up an entry in the group database. @var{obj} can be an integer, a string, or omitted, giving the behaviour of getgrgid, getgrnam or getgrent respectively. @@ -871,13 +921,15 @@ or getgrent respectively. In addition to the accessor procedures for the user database, the following shortcut procedures are also available. -@deffn primitive cuserid +@deffn {Scheme Procedure} cuserid +@deffnx {C Function} scm_cuserid () Return a string containing a user name associated with the effective user id of the process. Return @code{#f} if this information cannot be obtained. @end deffn -@deffn primitive getlogin +@deffn {Scheme Procedure} getlogin +@deffnx {C Function} scm_getlogin () Return a string containing the name of the user logged in on the controlling terminal of the process, or @code{#f} if this information cannot be obtained. @@ -887,12 +939,14 @@ information cannot be obtained. @node Time @section Time -@deffn primitive current-time +@deffn {Scheme Procedure} current-time +@deffnx {C Function} scm_current_time () Return the number of seconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. @end deffn -@deffn primitive gettimeofday +@deffn {Scheme Procedure} gettimeofday +@deffnx {C Function} scm_gettimeofday () Return a pair containing the number of seconds and microseconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note: whether true microsecond resolution is available depends on the @@ -930,7 +984,8 @@ Time zone offset in seconds west of UTC (-46800 to 43200). Time zone label (a string), not necessarily unique. @end table -@deffn primitive localtime time [zone] +@deffn {Scheme Procedure} localtime time [zone] +@deffnx {C Function} scm_localtime (time, zone) Return an object representing the broken down components of @var{time}, an integer like the one returned by @code{current-time}. The time zone for the calculation is @@ -938,13 +993,15 @@ optionally specified by @var{zone} (a string), otherwise the @code{TZ} environment variable or the system default is used. @end deffn -@deffn primitive gmtime time +@deffn {Scheme Procedure} gmtime time +@deffnx {C Function} scm_gmtime (time) Return an object representing the broken down components of @var{time}, an integer like the one returned by @code{current-time}. The values are calculated for UTC. @end deffn -@deffn primitive mktime sbd_time [zone] +@deffn {Scheme Procedure} mktime sbd_time [zone] +@deffnx {C Function} scm_mktime (sbd_time, zone) @var{bd-time} is an object representing broken down time and @code{zone} is an optional time zone specifier (otherwise the TZ environment variable or the system default is used). @@ -955,14 +1012,16 @@ by @code{current-time}; the cdr is a broken down time object, similar to as @var{bd-time} but with normalized values. @end deffn -@deffn primitive tzset +@deffn {Scheme Procedure} tzset +@deffnx {C Function} scm_tzset () Initialize the timezone from the TZ environment variable or the system default. It's not usually necessary to call this procedure since it's done automatically by other procedures that depend on the timezone. @end deffn -@deffn primitive strftime format stime +@deffn {Scheme Procedure} strftime format stime +@deffnx {C Function} scm_strftime (format, stime) Formats a time specification @var{time} using @var{template}. @var{time} is an object with time components in the form returned by @code{localtime} or @code{gmtime}. @var{template} is a string which can include formatting @@ -972,7 +1031,8 @@ is the formatted string. @xref{Formatting Date and Time, , , libc, The GNU C Library Reference Manual}.) @end deffn -@deffn primitive strptime format string +@deffn {Scheme Procedure} strptime format string +@deffnx {C Function} scm_strptime (format, string) Performs the reverse action to @code{strftime}, parsing @var{string} according to the specification supplied in @var{template}. The interpretation of month and day names is @@ -990,7 +1050,8 @@ The value of this variable is the number of time units per second reported by the following procedures. @end defvar -@deffn primitive times +@deffn {Scheme Procedure} times +@deffnx {C Function} scm_times () Return an object with information about real and processor time. The following procedures accept such an object as an argument and return a selected component: @@ -1014,12 +1075,14 @@ terminated child processes. @end table @end deffn -@deffn primitive get-internal-real-time +@deffn {Scheme Procedure} get-internal-real-time +@deffnx {C Function} scm_get_internal_real_time () Return the number of time units since the interpreter was started. @end deffn -@deffn primitive get-internal-run-time +@deffn {Scheme Procedure} get-internal-run-time +@deffnx {C Function} scm_get_internal_run_time () Return the number of time units of processor time used by the interpreter. Both @emph{system} and @emph{user} time are included but subprocesses are not. @@ -1028,22 +1091,24 @@ included but subprocesses are not. @node Runtime Environment @section Runtime Environment -@deffn primitive program-arguments -@deffnx procedure command-line +@deffn {Scheme Procedure} program-arguments +@deffnx {Scheme Procedure} command-line +@deffnx {C Function} scm_program_arguments () Return the list of command line arguments passed to Guile, as a list of strings. The list includes the invoked program name, which is usually @code{"guile"}, but excludes switches and parameters for command line options like @code{-e} and @code{-l}. @end deffn -@deffn primitive getenv nam +@deffn {Scheme Procedure} getenv nam +@deffnx {C Function} scm_getenv (nam) Looks up the string @var{name} in the current environment. The return value is @code{#f} unless a string of the form @code{NAME=VALUE} is found, in which case the string @code{VALUE} is returned. @end deffn @c begin (scm-doc-string "boot-9.scm" "setenv") -@deffn procedure setenv name value +@deffn {Scheme Procedure} setenv name value Modifies the environment of the current process, which is also the default environment inherited by child processes. @@ -1055,7 +1120,8 @@ to the environment, replacing any existing string with name matching The return value is unspecified. @end deffn -@deffn primitive environ [env] +@deffn {Scheme Procedure} environ [env] +@deffnx {C Function} scm_environ (env) If @var{env} is omitted, return the current environment (in the Unix sense) as a list of strings. Otherwise set the current environment, which is also the default environment for child @@ -1065,7 +1131,8 @@ processes, to the supplied list of strings. Each member of then the return value is unspecified. @end deffn -@deffn primitive putenv str +@deffn {Scheme Procedure} putenv str +@deffnx {C Function} scm_putenv (str) Modifies the environment of the current process, which is also the default environment inherited by child processes. @@ -1084,17 +1151,20 @@ The return value is unspecified. @section Processes @findex cd -@deffn primitive chdir str +@deffn {Scheme Procedure} chdir str +@deffnx {C Function} scm_chdir (str) Change the current working directory to @var{path}. The return value is unspecified. @end deffn @findex pwd -@deffn primitive getcwd +@deffn {Scheme Procedure} getcwd +@deffnx {C Function} scm_getcwd () Return the name of the current working directory. @end deffn -@deffn primitive umask [mode] +@deffn {Scheme Procedure} umask [mode] +@deffnx {C Function} scm_umask (mode) If @var{mode} is omitted, retuns a decimal number representing the current file creation mask. Otherwise the file creation mask is set to @var{mode} and the previous value is returned. @@ -1102,7 +1172,8 @@ file creation mask. Otherwise the file creation mask is set to E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18. @end deffn -@deffn primitive chroot path +@deffn {Scheme Procedure} chroot path +@deffnx {C Function} scm_chroot (path) Change the root directory to that specified in @var{path}. This directory will be used for path names beginning with @file{/}. The root directory is inherited by all children @@ -1110,55 +1181,65 @@ of the current process. Only the superuser may change the root directory. @end deffn -@deffn primitive getpid +@deffn {Scheme Procedure} getpid +@deffnx {C Function} scm_getpid () Return an integer representing the current process ID. @end deffn -@deffn primitive getgroups +@deffn {Scheme Procedure} getgroups +@deffnx {C Function} scm_getgroups () Return a vector of integers representing the current supplimentary group IDs. @end deffn -@deffn primitive getppid +@deffn {Scheme Procedure} getppid +@deffnx {C Function} scm_getppid () Return an integer representing the process ID of the parent process. @end deffn -@deffn primitive getuid +@deffn {Scheme Procedure} getuid +@deffnx {C Function} scm_getuid () Return an integer representing the current real user ID. @end deffn -@deffn primitive getgid +@deffn {Scheme Procedure} getgid +@deffnx {C Function} scm_getgid () Return an integer representing the current real group ID. @end deffn -@deffn primitive geteuid +@deffn {Scheme Procedure} geteuid +@deffnx {C Function} scm_geteuid () Return an integer representing the current effective user ID. If the system does not support effective IDs, then the real ID is returned. @code{(feature? 'EIDs)} reports whether the system supports effective IDs. @end deffn -@deffn primitive getegid +@deffn {Scheme Procedure} getegid +@deffnx {C Function} scm_getegid () Return an integer representing the current effective group ID. If the system does not support effective IDs, then the real ID is returned. @code{(feature? 'EIDs)} reports whether the system supports effective IDs. @end deffn -@deffn primitive setuid id +@deffn {Scheme Procedure} setuid id +@deffnx {C Function} scm_setuid (id) Sets both the real and effective user IDs to the integer @var{id}, provided the process has appropriate privileges. The return value is unspecified. @end deffn -@deffn primitive setgid id +@deffn {Scheme Procedure} setgid id +@deffnx {C Function} scm_setgid (id) Sets both the real and effective group IDs to the integer @var{id}, provided the process has appropriate privileges. The return value is unspecified. @end deffn -@deffn primitive seteuid id +@deffn {Scheme Procedure} seteuid id +@deffnx {C Function} scm_seteuid (id) Sets the effective user ID to the integer @var{id}, provided the process has appropriate privileges. If effective IDs are not supported, the real ID is set instead -- @code{(feature? 'EIDs)} reports whether the @@ -1166,7 +1247,8 @@ system supports effective IDs. The return value is unspecified. @end deffn -@deffn primitive setegid id +@deffn {Scheme Procedure} setegid id +@deffnx {C Function} scm_setegid (id) Sets the effective group ID to the integer @var{id}, provided the process has appropriate privileges. If effective IDs are not supported, the real ID is set instead -- @code{(feature? 'EIDs)} reports whether the @@ -1174,12 +1256,14 @@ system supports effective IDs. The return value is unspecified. @end deffn -@deffn primitive getpgrp +@deffn {Scheme Procedure} getpgrp +@deffnx {C Function} scm_getpgrp () Return an integer representing the current process group ID. This is the POSIX definition, not BSD. @end deffn -@deffn primitive setpgid pid pgid +@deffn {Scheme Procedure} setpgid pid pgid +@deffnx {C Function} scm_setpgid (pid, pgid) Move the process @var{pid} into the process group @var{pgid}. @var{pid} or @var{pgid} must be integers: they can be zero to indicate the ID of the current process. @@ -1187,14 +1271,16 @@ Fails on systems that do not support job control. The return value is unspecified. @end deffn -@deffn primitive setsid +@deffn {Scheme Procedure} setsid +@deffnx {C Function} scm_setsid () Creates a new session. The current process becomes the session leader and is put in a new process group. The process will be detached from its controlling terminal if it has one. The return value is an integer representing the new process group ID. @end deffn -@deffn primitive waitpid pid [options] +@deffn {Scheme Procedure} waitpid pid [options] +@deffnx {C Function} scm_waitpid (pid, options) This procedure collects status information from a child process which has terminated or (optionally) stopped. Normally it will suspend the calling process until this can be done. If more than one @@ -1242,23 +1328,27 @@ The following three functions can be used to decode the process status code returned by @code{waitpid}. -@deffn primitive status:exit-val status +@deffn {Scheme Procedure} status:exit-val status +@deffnx {C Function} scm_status_exit_val (status) Return the exit status value, as would be set if a process ended normally through a call to @code{exit} or @code{_exit}, if any, otherwise @code{#f}. @end deffn -@deffn primitive status:term-sig status +@deffn {Scheme Procedure} status:term-sig status +@deffnx {C Function} scm_status_term_sig (status) Return the signal number which terminated the process, if any, otherwise @code{#f}. @end deffn -@deffn primitive status:stop-sig status +@deffn {Scheme Procedure} status:stop-sig status +@deffnx {C Function} scm_status_stop_sig (status) Return the signal number which stopped the process, if any, otherwise @code{#f}. @end deffn -@deffn primitive system [cmd] +@deffn {Scheme Procedure} system [cmd] +@deffnx {C Function} scm_system (cmd) Execute @var{cmd} using the operating system's "command processor". Under Unix this is usually the default shell @code{sh}. The value returned is @var{cmd}'s exit status as @@ -1269,13 +1359,15 @@ If @code{system} is called without arguments, return a boolean indicating whether the command processor is available. @end deffn -@deffn primitive primitive-exit [status] +@deffn {Scheme Procedure} primitive-exit [status] +@deffnx {C Function} scm_primitive_exit (status) Terminate the current process without unwinding the Scheme stack. This is would typically be useful after a fork. The exit status is @var{status} if supplied, otherwise zero. @end deffn -@deffn primitive execl filename . args +@deffn {Scheme Procedure} execl filename . args +@deffnx {C Function} scm_execl (filename, args) Executes the file named by @var{path} as a new process image. The remaining arguments are supplied to the process; from a C program they are accessable as the @code{argv} argument to @code{main}. @@ -1289,7 +1381,8 @@ This procedure is currently implemented using the @code{execv} system call, but we call it @code{execl} because of its Scheme calling interface. @end deffn -@deffn primitive execlp filename . args +@deffn {Scheme Procedure} execlp filename . args +@deffnx {C Function} scm_execlp (filename, args) Similar to @code{execl}, however if @var{filename} does not contain a slash then the file to execute will be located by searching the @@ -1299,7 +1392,8 @@ This procedure is currently implemented using the @code{execvp} system call, but we call it @code{execlp} because of its Scheme calling interface. @end deffn -@deffn primitive execle filename env . args +@deffn {Scheme Procedure} execle filename env . args +@deffnx {C Function} scm_execle (filename, env, args) Similar to @code{execl}, but the environment of the new process is specified by @var{env}, which must be a list of strings as returned by the @code{environ} procedure. @@ -1308,7 +1402,8 @@ This procedure is currently implemented using the @code{execve} system call, but we call it @code{execle} because of its Scheme calling interface. @end deffn -@deffn primitive primitive-fork +@deffn {Scheme Procedure} primitive-fork +@deffnx {C Function} scm_fork () Creates a new "child" process by duplicating the current "parent" process. In the child the return value is 0. In the parent the return value is the integer process ID of the child. @@ -1317,13 +1412,15 @@ This procedure has been renamed from @code{fork} to avoid a naming conflict with the scsh fork. @end deffn -@deffn primitive nice incr +@deffn {Scheme Procedure} nice incr +@deffnx {C Function} scm_nice (incr) Increment the priority of the current process by @var{incr}. A higher priority value means that the process runs less often. The return value is unspecified. @end deffn -@deffn primitive setpriority which who prio +@deffn {Scheme Procedure} setpriority which who prio +@deffnx {C Function} scm_setpriority (which, who, prio) Set the scheduling priority of the process, process group or user, as indicated by @var{which} and @var{who}. @var{which} is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} @@ -1339,7 +1436,8 @@ processes. Only the super-user may lower priorities. The return value is not specified. @end deffn -@deffn primitive getpriority which who +@deffn {Scheme Procedure} getpriority which who +@deffnx {C Function} scm_getpriority (which, who) Return the scheduling priority of the process, process group or user, as indicated by @var{which} and @var{who}. @var{which} is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP} @@ -1358,7 +1456,8 @@ specified processes. Procedures to raise, handle and wait for signals. -@deffn primitive kill pid sig +@deffn {Scheme Procedure} kill pid sig +@deffnx {C Function} scm_kill (pid, sig) Sends a signal to the specified process or group of processes. @var{pid} specifies the processes to which the signal is sent: @@ -1388,12 +1487,14 @@ Interrupt signal. @end defvar @end deffn -@deffn primitive raise sig +@deffn {Scheme Procedure} raise sig +@deffnx {C Function} scm_raise (sig) Sends a specified signal @var{sig} to the current process, where @var{sig} is as described for the kill procedure. @end deffn -@deffn primitive sigaction signum [handler [flags]] +@deffn {Scheme Procedure} sigaction signum [handler [flags]] +@deffnx {C Function} scm_sigaction (signum, handler, flags) Install or report the signal handler for a specified signal. @var{signum} is the signal number, which can be specified using the value @@ -1422,12 +1523,14 @@ provide solutions to the problem of consistent access to data structures. @end deffn -@deffn primitive restore-signals +@deffn {Scheme Procedure} restore-signals +@deffnx {C Function} scm_restore_signals () Return all signal handlers to the values they had before any call to @code{sigaction} was made. The return value is unspecified. @end deffn -@deffn primitive alarm i +@deffn {Scheme Procedure} alarm i +@deffnx {C Function} scm_alarm (i) Set a timer to raise a @code{SIGALRM} signal after the specified number of seconds (an integer). It's advisable to install a signal handler for @@ -1439,24 +1542,28 @@ if any. The new value replaces the previous alarm. If there was no previous alarm, the return value is zero. @end deffn -@deffn primitive pause +@deffn {Scheme Procedure} pause +@deffnx {C Function} scm_pause () Pause the current process (thread?) until a signal arrives whose action is to either terminate the current process or invoke a handler procedure. The return value is unspecified. @end deffn -@deffn primitive sleep i +@deffn {Scheme Procedure} sleep i +@deffnx {C Function} scm_sleep (i) Wait for the given number of seconds (an integer) or until a signal arrives. The return value is zero if the time elapses or the number of seconds remaining otherwise. @end deffn -@deffn primitive usleep i +@deffn {Scheme Procedure} usleep i +@deffnx {C Function} scm_usleep (i) Sleep for I microseconds. @code{usleep} is not available on all platforms. @end deffn -@deffn primitive setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds +@deffn {Scheme Procedure} setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds +@deffnx {C Function} scm_setitimer (which_timer, interval_seconds, interval_microseconds, value_seconds, value_microseconds) Set the timer specified by @var{which_timer} according to the given @var{interval_seconds}, @var{interval_microseconds}, @var{value_seconds}, and @var{value_microseconds} values. @@ -1474,7 +1581,8 @@ microseconds of the timer @code{it_interval}, and the second pair is the seconds and microseconds of the timer @code{it_value}. @end deffn -@deffn primitive getitimer which_timer +@deffn {Scheme Procedure} getitimer which_timer +@deffnx {C Function} scm_getitimer (which_timer) Return information about the timer specified by @var{which_timer} Errors are handled as described in the guile info pages under ``POSIX Interface Conventions''. @@ -1492,22 +1600,26 @@ the seconds and microseconds of the timer @code{it_value}. @node Terminals and Ptys @section Terminals and Ptys -@deffn primitive isatty? port +@deffn {Scheme Procedure} isatty? port +@deffnx {C Function} scm_isatty_p (port) Return @code{#t} if @var{port} is using a serial non--file device, otherwise @code{#f}. @end deffn -@deffn primitive ttyname port +@deffn {Scheme Procedure} ttyname port +@deffnx {C Function} scm_ttyname (port) Return a string with the name of the serial terminal device underlying @var{port}. @end deffn -@deffn primitive ctermid +@deffn {Scheme Procedure} ctermid +@deffnx {C Function} scm_ctermid () Return a string containing the file name of the controlling terminal for the current process. @end deffn -@deffn primitive tcgetpgrp port +@deffn {Scheme Procedure} tcgetpgrp port +@deffnx {C Function} scm_tcgetpgrp (port) Return the process group ID of the foreground process group associated with the terminal open on the file descriptor underlying @var{port}. @@ -1520,7 +1632,8 @@ terminated, and no other job has yet been moved into the foreground. @end deffn -@deffn primitive tcsetpgrp port pgid +@deffn {Scheme Procedure} tcsetpgrp port pgid +@deffnx {C Function} scm_tcsetpgrp (port, pgid) Set the foreground process group ID for the terminal used by the file descriptor underlying @var{port} to the integer @var{pgid}. The calling process @@ -1540,23 +1653,23 @@ module: @end smalllisp @findex popen -@deffn procedure open-pipe command modes +@deffn {Scheme Procedure} open-pipe command modes Executes the shell command @var{command} (a string) in a subprocess. A pipe to the process is created and returned. @var{modes} specifies whether an input or output pipe to the process is created: it should be the value of @code{OPEN_READ} or @code{OPEN_WRITE}. @end deffn -@deffn procedure open-input-pipe command +@deffn {Scheme Procedure} open-input-pipe command Equivalent to @code{open-pipe} with mode @code{OPEN_READ}. @end deffn -@deffn procedure open-output-pipe command +@deffn {Scheme Procedure} open-output-pipe command Equivalent to @code{open-pipe} with mode @code{OPEN_WRITE}. @end deffn @findex pclose -@deffn procedure close-pipe port +@deffn {Scheme Procedure} close-pipe port Closes the pipe created by @code{open-pipe}, then waits for the process to terminate and returns its status value, @xref{Processes, waitpid}, for information on how to interpret this value. @@ -1582,7 +1695,8 @@ between numeric and string formats. @subsubsection IPv4 Address Conversion -@deffn primitive inet-aton address +@deffn {Scheme Procedure} inet-aton address +@deffnx {C Function} scm_inet_aton (address) Convert an IPv4 Internet address from printable string (dotted decimal notation) to an integer. E.g., @@ -1591,7 +1705,8 @@ Convert an IPv4 Internet address from printable string @end lisp @end deffn -@deffn primitive inet-ntoa inetid +@deffn {Scheme Procedure} inet-ntoa inetid +@deffnx {C Function} scm_inet_ntoa (inetid) Convert an IPv4 Internet address to a printable (dotted decimal notation) string. E.g., @@ -1600,7 +1715,8 @@ Convert an IPv4 Internet address to a printable @end lisp @end deffn -@deffn primitive inet-netof address +@deffn {Scheme Procedure} inet-netof address +@deffnx {C Function} scm_inet_netof (address) Return the network number part of the given IPv4 Internet address. E.g., @@ -1609,7 +1725,8 @@ Internet address. E.g., @end lisp @end deffn -@deffn primitive inet-lnaof address +@deffn {Scheme Procedure} inet-lnaof address +@deffnx {C Function} scm_lnaof (address) Return the local-address-with-network part of the given IPv4 Internet address, using the obsolete class A/B/C system. E.g., @@ -1619,7 +1736,8 @@ E.g., @end lisp @end deffn -@deffn primitive inet-makeaddr net lna +@deffn {Scheme Procedure} inet-makeaddr net lna +@deffnx {C Function} scm_inet_makeaddr (net, lna) Make an IPv4 Internet address by combining the network number @var{net} with the local-address-within-network number @var{lna}. E.g., @@ -1631,7 +1749,8 @@ Make an IPv4 Internet address by combining the network number @subsubsection IPv6 Address Conversion -@deffn primitive inet-ntop family address +@deffn {Scheme Procedure} inet-ntop family address +@deffnx {C Function} scm_inet_ntop (family, address) Convert a network address into a printable string. Note that unlike the C version of this function, the input is an integer with normal host byte ordering. @@ -1644,7 +1763,8 @@ ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff @end lisp @end deffn -@deffn primitive inet-pton family address +@deffn {Scheme Procedure} inet-pton family address +@deffnx {C Function} scm_inet_pton (family, address) Convert a string containing a printable network address to an integer address. Note that unlike the C version of this function, @@ -1674,28 +1794,29 @@ identity inside software. The following functions accept a host object and return a selected component: -@deffn procedure hostent:name host +@deffn {Scheme Procedure} hostent:name host The "official" hostname for @var{host}. @end deffn -@deffn procedure hostent:aliases host +@deffn {Scheme Procedure} hostent:aliases host A list of aliases for @var{host}. @end deffn -@deffn procedure hostent:addrtype host +@deffn {Scheme Procedure} hostent:addrtype host The host address type. For hosts with Internet addresses, this will return @code{AF_INET}. @end deffn -@deffn procedure hostent:length host +@deffn {Scheme Procedure} hostent:length host The length of each address for @var{host}, in bytes. @end deffn -@deffn procedure hostent:addr-list host +@deffn {Scheme Procedure} hostent:addr-list host The list of network addresses associated with @var{host}. @end deffn The following procedures are used to search the host database: -@deffn primitive gethost [host] -@deffnx procedure gethostbyname hostname -@deffnx procedure gethostbyaddr address +@deffn {Scheme Procedure} gethost [host] +@deffnx {Scheme Procedure} gethostbyname hostname +@deffnx {Scheme Procedure} gethostbyaddr address +@deffnx {C Function} scm_gethost (host) Look up a host by name or address, returning a host object. The @code{gethost} procedure will accept either a string name or an integer address; if given no arguments, it behaves like @code{gethostent} (see @@ -1710,7 +1831,7 @@ Unusual conditions may result in errors thrown to the The following procedures may be used to step through the host database from beginning to end. -@deffn procedure sethostent [stayopen] +@deffn {Scheme Procedure} sethostent [stayopen] Initialize an internal stream from which host objects may be read. This procedure must be called before any calls to @code{gethostent}, and may also be called afterward to reset the host entry stream. If @@ -1719,17 +1840,18 @@ closed by subsequent @code{gethostbyname} or @code{gethostbyaddr} calls, possibly giving an efficiency gain. @end deffn -@deffn procedure gethostent +@deffn {Scheme Procedure} gethostent Return the next host object from the host database, or @code{#f} if there are no more hosts to be found (or an error has been encountered). This procedure may not be used before @code{sethostent} has been called. @end deffn -@deffn procedure endhostent +@deffn {Scheme Procedure} endhostent Close the stream used by @code{gethostent}. The return value is unspecified. @end deffn -@deffn primitive sethost [stayopen] +@deffn {Scheme Procedure} sethost [stayopen] +@deffnx {C Function} scm_sethost (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endhostent}. Otherwise it is equivalent to @code{sethostent stayopen}. @end deffn @@ -1738,25 +1860,26 @@ Otherwise it is equivalent to @code{sethostent stayopen}. The following functions accept an object representing a network and return a selected component: -@deffn procedure netent:name net +@deffn {Scheme Procedure} netent:name net The "official" network name. @end deffn -@deffn procedure netent:aliases net +@deffn {Scheme Procedure} netent:aliases net A list of aliases for the network. @end deffn -@deffn procedure netent:addrtype net +@deffn {Scheme Procedure} netent:addrtype net The type of the network number. Currently, this returns only @code{AF_INET}. @end deffn -@deffn procedure netent:net net +@deffn {Scheme Procedure} netent:net net The network number. @end deffn The following procedures are used to search the network database: -@deffn primitive getnet [net] -@deffnx procedure getnetbyname net-name -@deffnx procedure getnetbyaddr net-number +@deffn {Scheme Procedure} getnet [net] +@deffnx {Scheme Procedure} getnetbyname net-name +@deffnx {Scheme Procedure} getnetbyaddr net-number +@deffnx {C Function} scm_getnet (net) Look up a network by name or net number in the network database. The @var{net-name} argument must be a string, and the @var{net-number} argument must be an integer. @code{getnet} will accept either type of @@ -1767,7 +1890,7 @@ given. The following procedures may be used to step through the network database from beginning to end. -@deffn procedure setnetent [stayopen] +@deffn {Scheme Procedure} setnetent [stayopen] Initialize an internal stream from which network objects may be read. This procedure must be called before any calls to @code{getnetent}, and may also be called afterward to reset the net entry stream. If @@ -1776,15 +1899,16 @@ closed by subsequent @code{getnetbyname} or @code{getnetbyaddr} calls, possibly giving an efficiency gain. @end deffn -@deffn procedure getnetent +@deffn {Scheme Procedure} getnetent Return the next entry from the network database. @end deffn -@deffn procedure endnetent +@deffn {Scheme Procedure} endnetent Close the stream used by @code{getnetent}. The return value is unspecified. @end deffn -@deffn primitive setnet [stayopen] +@deffn {Scheme Procedure} setnet [stayopen] +@deffnx {C Function} scm_setnet (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endnetent}. Otherwise it is equivalent to @code{setnetent stayopen}. @end deffn @@ -1794,21 +1918,22 @@ Otherwise it is equivalent to @code{setnetent stayopen}. The following functions accept an object representing a protocol and return a selected component: -@deffn procedure protoent:name protocol +@deffn {Scheme Procedure} protoent:name protocol The "official" protocol name. @end deffn -@deffn procedure protoent:aliases protocol +@deffn {Scheme Procedure} protoent:aliases protocol A list of aliases for the protocol. @end deffn -@deffn procedure protoent:proto protocol +@deffn {Scheme Procedure} protoent:proto protocol The protocol number. @end deffn The following procedures are used to search the protocol database: -@deffn primitive getproto [protocol] -@deffnx procedure getprotobyname name -@deffnx procedure getprotobynumber number +@deffn {Scheme Procedure} getproto [protocol] +@deffnx {Scheme Procedure} getprotobyname name +@deffnx {Scheme Procedure} getprotobynumber number +@deffnx {C Function} scm_getproto (protocol) Look up a network protocol by name or by number. @code{getprotobyname} takes a string argument, and @code{getprotobynumber} takes an integer argument. @code{getproto} will accept either type, behaving like @@ -1818,7 +1943,7 @@ argument. @code{getproto} will accept either type, behaving like The following procedures may be used to step through the protocol database from beginning to end. -@deffn procedure setprotoent [stayopen] +@deffn {Scheme Procedure} setprotoent [stayopen] Initialize an internal stream from which protocol objects may be read. This procedure must be called before any calls to @code{getprotoent}, and may also be called afterward to reset the protocol entry stream. If @@ -1827,15 +1952,16 @@ closed by subsequent @code{getprotobyname} or @code{getprotobynumber} calls, possibly giving an efficiency gain. @end deffn -@deffn procedure getprotoent +@deffn {Scheme Procedure} getprotoent Return the next entry from the protocol database. @end deffn -@deffn procedure endprotoent +@deffn {Scheme Procedure} endprotoent Close the stream used by @code{getprotoent}. The return value is unspecified. @end deffn -@deffn primitive setproto [stayopen] +@deffn {Scheme Procedure} setproto [stayopen] +@deffnx {C Function} scm_setproto (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}. Otherwise it is equivalent to @code{setprotoent stayopen}. @end deffn @@ -1845,25 +1971,26 @@ Otherwise it is equivalent to @code{setprotoent stayopen}. The following functions accept an object representing a service and return a selected component: -@deffn procedure servent:name serv +@deffn {Scheme Procedure} servent:name serv The "official" name of the network service. @end deffn -@deffn procedure servent:aliases serv +@deffn {Scheme Procedure} servent:aliases serv A list of aliases for the network service. @end deffn -@deffn procedure servent:port serv +@deffn {Scheme Procedure} servent:port serv The Internet port used by the service. @end deffn -@deffn procedure servent:proto serv +@deffn {Scheme Procedure} servent:proto serv The protocol used by the service. A service may be listed many times in the database under different protocol names. @end deffn The following procedures are used to search the service database: -@deffn primitive getserv [name [protocol]] -@deffnx procedure getservbyname name protocol -@deffnx procedure getservbyport port protocol +@deffn {Scheme Procedure} getserv [name [protocol]] +@deffnx {Scheme Procedure} getservbyname name protocol +@deffnx {Scheme Procedure} getservbyport port protocol +@deffnx {C Function} scm_getserv (name, protocol) Look up a network service by name or by service number, and return a network service object. The @var{protocol} argument specifies the name of the desired protocol; if the protocol found in the network service @@ -1877,7 +2004,7 @@ as its first argument; if given no arguments, it behaves like The following procedures may be used to step through the service database from beginning to end. -@deffn procedure setservent [stayopen] +@deffn {Scheme Procedure} setservent [stayopen] Initialize an internal stream from which service objects may be read. This procedure must be called before any calls to @code{getservent}, and may also be called afterward to reset the service entry stream. If @@ -1886,15 +2013,16 @@ closed by subsequent @code{getservbyname} or @code{getservbyport} calls, possibly giving an efficiency gain. @end deffn -@deffn procedure getservent +@deffn {Scheme Procedure} getservent Return the next entry from the services database. @end deffn -@deffn procedure endservent +@deffn {Scheme Procedure} endservent Close the stream used by @code{getservent}. The return value is unspecified. @end deffn -@deffn primitive setserv [stayopen] +@deffn {Scheme Procedure} setserv [stayopen] +@deffnx {C Function} scm_setserv (stayopen) If @var{stayopen} is omitted, this is equivalent to @code{endservent}. Otherwise it is equivalent to @code{setservent stayopen}. @end deffn @@ -1912,7 +2040,8 @@ are always held in host order at the Scheme level. The procedures in this section automatically convert between host and network order when required. The arguments and return values are thus in host order. -@deffn primitive socket family style proto +@deffn {Scheme Procedure} socket family style proto +@deffnx {C Function} scm_socket (family, style, proto) Return a new socket port of the type specified by @var{family}, @var{style} and @var{proto}. All three parameters are integers. Supported values for @var{family} are @@ -1928,7 +2057,8 @@ A single socket port cannot by used for communication until it has been connected to another socket. @end deffn -@deffn primitive socketpair family style proto +@deffn {Scheme Procedure} socketpair family style proto +@deffnx {C Function} scm_socketpair (family, style, proto) Return a pair of connected (but unnamed) socket ports of the type specified by @var{family}, @var{style} and @var{proto}. Many systems support only socket pairs of the @code{AF_UNIX} @@ -1936,7 +2066,8 @@ family. Zero is likely to be the only meaningful value for @var{proto}. @end deffn -@deffn primitive getsockopt sock level optname +@deffn {Scheme Procedure} getsockopt sock level optname +@deffnx {C Function} scm_getsockopt (sock, level, optname) Return the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of option being requested, e.g., @code{SOL_SOCKET} for @@ -1948,7 +2079,8 @@ The returned value is typically an integer but @code{SO_LINGER} returns a pair of integers. @end deffn -@deffn primitive setsockopt sock level optname value +@deffn {Scheme Procedure} setsockopt sock level optname value +@deffnx {C Function} scm_setsockopt (sock, level, optname, value) Set the value of a particular socket option for the socket port @var{sock}. @var{level} is an integer code for type of option being set, e.g., @code{SOL_SOCKET} for socket-level options. @@ -1962,7 +2094,8 @@ be a pair. The return value is unspecified. @end deffn -@deffn primitive shutdown sock how +@deffn {Scheme Procedure} shutdown sock how +@deffnx {C Function} scm_shutdown (sock, how) Sockets can be closed simply by using @code{close-port}. The @code{shutdown} procedure allows reception or tranmission on a connection to be shut down individually, according to the parameter @@ -1982,7 +2115,8 @@ Stop both reception and transmission. The return value is unspecified. @end deffn -@deffn primitive connect sock fam address . args +@deffn {Scheme Procedure} connect sock fam address . args +@deffnx {C Function} scm_connect (sock, fam, address, args) Initiate a connection from a socket using a specified address family to the address specified by @var{address} and possibly @var{args}. @@ -2006,7 +2140,8 @@ where flowinfo and scope_id default to zero. The return value is unspecified. @end deffn -@deffn primitive bind sock fam address . args +@deffn {Scheme Procedure} bind sock fam address . args +@deffnx {C Function} scm_bind (sock, fam, address, args) Assign an address to the socket port @var{sock}. Generally this only needs to be done for server sockets, so they know where to look for incoming connections. A socket @@ -2052,7 +2187,8 @@ where flowinfo and scope_id default to zero. The return value is unspecified. @end deffn -@deffn primitive listen sock backlog +@deffn {Scheme Procedure} listen sock backlog +@deffnx {C Function} scm_listen (sock, backlog) Enable @var{sock} to accept connection requests. @var{backlog} is an integer specifying the maximum length of the queue for pending connections. @@ -2063,7 +2199,8 @@ the queue. The return value is unspecified. @end deffn -@deffn primitive accept sock +@deffn {Scheme Procedure} accept sock +@deffnx {C Function} scm_accept (sock) Accept a connection on a bound, listening socket. If there are no pending connections in the queue, wait until @@ -2098,20 +2235,23 @@ If the socket family is @code{AF_INET}, returns the Internet port number. @end table -@deffn primitive getsockname sock +@deffn {Scheme Procedure} getsockname sock +@deffnx {C Function} scm_getsockname (sock) Return the address of @var{sock}, in the same form as the object returned by @code{accept}. On many systems the address of a socket in the @code{AF_FILE} namespace cannot be read. @end deffn -@deffn primitive getpeername sock +@deffn {Scheme Procedure} getpeername sock +@deffnx {C Function} scm_getpeername (sock) Return the address that @var{sock} is connected to, in the same form as the object returned by @code{accept}. On many systems the address of a socket in the @code{AF_FILE} namespace cannot be read. @end deffn -@deffn primitive recv! sock buf [flags] +@deffn {Scheme Procedure} recv! sock buf [flags] +@deffnx {C Function} scm_recv (sock, buf, flags) Receive data from a socket port. @var{sock} must already be bound to the address from which data is to be received. @@ -2134,7 +2274,8 @@ descriptor: any unread buffered port data is ignored. @end deffn -@deffn primitive send sock message [flags] +@deffn {Scheme Procedure} send sock message [flags] +@deffnx {C Function} scm_send (sock, message, flags) Transmit the string @var{message} on a socket port @var{sock}. @var{sock} must already be bound to a destination address. The value returned is the number of bytes transmitted -- @@ -2150,7 +2291,8 @@ file descriptor: any unflushed buffered port data is ignored. @end deffn -@deffn primitive recvfrom! sock str [flags [start [end]]] +@deffn {Scheme Procedure} recvfrom! sock str [flags [start [end]]] +@deffnx {C Function} scm_recvfrom (sock, str, flags, start, end) Return data from the socket port @var{sock} and also information about where the data was received from. @var{sock} must already be bound to the address from which @@ -2176,7 +2318,8 @@ Note that the data is read directly from the socket file descriptor: any unread buffered port data is ignored. @end deffn -@deffn primitive sendto sock message fam address . args_and_flags +@deffn {Scheme Procedure} sendto sock message fam address . args_and_flags +@deffnx {C Function} scm_sendto (sock, message, fam, address, args_and_flags) Transmit the string @var{message} on the socket port @var{sock}. The destination address is specified using the @var{fam}, @@ -2202,25 +2345,29 @@ between "host" and "network" order. Although the procedures above do this automatically for addresses, the conversion will still need to be done when sending or receiving encoded integer data from the network. -@deffn primitive htons value +@deffn {Scheme Procedure} htons value +@deffnx {C Function} scm_htons (value) Convert a 16 bit quantity from host to network byte ordering. @var{value} is packed into 2 bytes, which are then converted and returned as a new integer. @end deffn -@deffn primitive ntohs value +@deffn {Scheme Procedure} ntohs value +@deffnx {C Function} scm_ntohs (value) Convert a 16 bit quantity from network to host byte ordering. @var{value} is packed into 2 bytes, which are then converted and returned as a new integer. @end deffn -@deffn primitive htonl value +@deffn {Scheme Procedure} htonl value +@deffnx {C Function} scm_htonl (value) Convert a 32 bit quantity from host to network byte ordering. @var{value} is packed into 4 bytes, which are then converted and returned as a new integer. @end deffn -@deffn primitive ntohl value +@deffn {Scheme Procedure} ntohl value +@deffnx {C Function} scm_ntohl (value) Convert a 32 bit quantity from network to host byte ordering. @var{value} is packed into 4 bytes, which are then converted and returned as a new integer. @@ -2248,7 +2395,8 @@ These procedures are inconvenient to use at present, but consider: This section lists the various procedures Guile provides for accessing information about the system it runs on. -@deffn primitive uname +@deffn {Scheme Procedure} uname +@deffnx {C Function} scm_uname () Return an object with some information about the computer system the program is running on. @end deffn @@ -2269,18 +2417,20 @@ The current version level within the release of the operating system. A description of the hardware. @end table -@deffn primitive gethostname +@deffn {Scheme Procedure} gethostname +@deffnx {C Function} scm_gethostname () Return the host name of the current processor. @end deffn -@deffn primitive sethostname name +@deffn {Scheme Procedure} sethostname name +@deffnx {C Function} scm_sethostname (name) Set the host name of the current processor to @var{name}. May only be used by the superuser. The return value is not specified. @end deffn @c FIXME::martin: Not in libguile! -@deffn primitive software-type +@deffn {Scheme Procedure} software-type Return a symbol describing the current platform's operating system. This may be one of AIX, VMS, UNIX, COHERENT, WINDOWS, MS-DOS, OS/2, THINKC, AMIGA, ATARIST, MACH, or ACORN. @@ -2296,7 +2446,8 @@ no other easy or unambiguous way of detecting such features. @node Locales @section Locales -@deffn primitive setlocale category [locale] +@deffn {Scheme Procedure} setlocale category [locale] +@deffnx {C Function} scm_setlocale (category, locale) If @var{locale} is omitted, return the current value of the specified locale category as a system-dependent string. @var{category} should be specified using the values @@ -2317,7 +2468,8 @@ common system library functions of the same name. They are just as good (or bad) as the underlying functions, so you should refer to your system documentation before using them. -@deffn primitive crypt key salt +@deffn {Scheme Procedure} crypt key salt +@deffnx {C Function} scm_crypt (key, salt) Encrypt @var{key} using @var{salt} as the salt value to the crypt(3) library call. @end deffn @@ -2326,7 +2478,8 @@ crypt(3) library call. in compination with @code{crypt}, that is why it appears in this section. -@deffn primitive getpass prompt +@deffn {Scheme Procedure} getpass prompt +@deffnx {C Function} scm_getpass (prompt) Display @var{prompt} to the standard error output and read a password from @file{/dev/tty}. If this file is not accessible, it reads from standard input. The password may be diff --git a/doc/ref/scheme-binding.texi b/doc/ref/scheme-binding.texi index 5e476141e..38f9bae08 100644 --- a/doc/ref/scheme-binding.texi +++ b/doc/ref/scheme-binding.texi @@ -232,7 +232,8 @@ bound in expression, you can use the @code{bound?} macro from the module @code{(ice-9 optargs)}, documented in @ref{Optional Arguments}. @c NJFIXME explain [env] -@deffn primitive defined? sym [env] +@deffn {Scheme Procedure} defined? sym [env] +@deffnx {C Function} scm_definedp (sym, env) Return @code{#t} if @var{sym} is defined in the lexical environment @var{env}. When @var{env} is not specified, look in the top-level environment as defined by the current module. @end deffn diff --git a/doc/ref/scheme-control.texi b/doc/ref/scheme-control.texi index d7b95151b..c53d9fd5e 100644 --- a/doc/ref/scheme-control.texi +++ b/doc/ref/scheme-control.texi @@ -273,7 +273,7 @@ for escape procedures and your program is running too slow, you might want to use exceptions (@pxref{Exceptions}) instead. @rnindex call-with-current-continuation -@deffn primitive call-with-current-continuation proc +@deffn {Scheme Procedure} call-with-current-continuation proc Capture the current continuation and call @var{proc} with the captured continuation as the single argument. This continuation can then be called with arbitrarily many arguments. Such a call will work like a @@ -325,7 +325,8 @@ multiple values with a procedure which accepts these values as parameters. @rnindex values -@deffn primitive values expr @dots{} +@deffn {Scheme Procedure} values . args +@deffnx {C Function} scm_values (args) Delivers all of its arguments to its continuation. Except for continuations created by the @code{call-with-values} procedure, all continuations take exactly one value. The effect of @@ -334,7 +335,7 @@ were not created by @code{call-with-values} is unspecified. @end deffn @rnindex call-with-values -@deffn primitive call-with-values producer consumer +@deffn {Scheme Procedure} call-with-values producer consumer Calls its @var{producer} argument with no values and a continuation that, when passed some values, calls the @var{consumer} procedure with those values as arguments. The @@ -490,7 +491,8 @@ procedure must be designed to accept a number of arguments that corresponds to the number of arguments in all @code{throw} expressions that can be caught by this @code{catch}. -@deffn primitive catch key thunk handler +@deffn {Scheme Procedure} catch key thunk handler +@deffnx {C Function} scm_catch (key, thunk, handler) Invoke @var{thunk} in the dynamic context of @var{handler} for exceptions matching @var{key}. If thunk throws to the symbol @var{key}, then @var{handler} is invoked this way: @@ -545,7 +547,8 @@ depends on the exception type. The documentation for each possible type of exception should specify the additional arguments that are expected for that kind of exception. -@deffn primitive throw key . args +@deffn {Scheme Procedure} throw key . args +@deffnx {C Function} scm_throw (key, args) Invoke the catch form matching @var{key}, passing @var{args} to the @var{handler}. @@ -607,7 +610,8 @@ one important respect: the handler procedure is executed without unwinding the call stack from the context of the @code{throw} expression that caused the handler to be invoked. -@deffn primitive lazy-catch key thunk handler +@deffn {Scheme Procedure} lazy-catch key thunk handler +@deffnx {C Function} scm_lazy_catch (key, thunk, handler) This behaves exactly like @code{catch}, except that it does not unwind the stack before invoking @var{handler}. The @var{handler} procedure is not allowed to return: @@ -728,12 +732,13 @@ Guile provides a set of convenience procedures for signaling error conditions that are implemented on top of the exception primitives just described. -@deffn procedure error msg args @dots{} +@deffn {Scheme Procedure} error msg args @dots{} Raise an error with key @code{misc-error} and a message constructed by displaying @var{msg} and writing @var{args}. @end deffn -@deffn primitive scm-error key subr message args data +@deffn {Scheme Procedure} scm-error key subr message args data +@deffnx {C Function} scm_error_scm (key, subr, message, args, data) Raise an error with key @var{key}. @var{subr} can be a string naming the procedure associated with the error, or @code{#f}. @var{message} is the error message string, possibly containing @@ -749,7 +754,8 @@ should be a list containing the Unix signal number; otherwise it will usually be @code{#f}. @end deffn -@deffn primitive strerror err +@deffn {Scheme Procedure} strerror err +@deffnx {C Function} scm_strerror (err) Return the Unix error message corresponding to @var{err}, which must be an integer value. @end deffn @@ -769,7 +775,8 @@ if an exception occurs then @code{#f} is returned instead. be reviewed] @rnindex dynamic-wind -@deffn primitive dynamic-wind in_guard thunk out_guard +@deffn {Scheme Procedure} dynamic-wind in_guard thunk out_guard +@deffnx {C Function} scm_dynamic_wind (in_guard, thunk, out_guard) All three arguments must be 0-argument procedures. @var{in_guard} is called, then @var{thunk}, then @var{out_guard}. @@ -861,12 +868,12 @@ be @code{#f} if no additional objects are required. In addition to @code{catch} and @code{throw}, the following Scheme facilities are available: -@deffn primitive scm-error key subr message args rest +@deffn {Scheme Procedure} scm-error key subr message args rest Throw an error, with arguments as described above. @end deffn -@deffn procedure error msg arg @dots{} +@deffn {Scheme Procedure} error msg arg @dots{} Throw an error using the key @code{'misc-error}. The error message is created by displaying @var{msg} and writing the @var{args}. @end deffn diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 1583f413f..e8ffd3a81 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -123,7 +123,8 @@ number 0 (like in C and C++), and not the same as the ``empty list'' The @code{not} procedure returns the boolean inverse of its argument: @rnindex not -@deffn primitive not x +@deffn {Scheme Procedure} not x +@deffnx {C Function} scm_not (x) Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}. @end deffn @@ -131,7 +132,8 @@ The @code{boolean?} procedure is a predicate that returns @code{#t} if its argument is one of the boolean values, otherwise @code{#f}. @rnindex boolean? -@deffn primitive boolean? obj +@deffn {Scheme Procedure} boolean? obj +@deffnx {C Function} scm_boolean_p (obj) Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}. @end deffn @@ -205,8 +207,10 @@ converted by Guile to the corresponding real number. The @code{number?} predicate may be applied to any Scheme value to discover whether the value is any of the supported numerical types. -@deffn primitive number? obj +@deffn {Scheme Procedure} number? obj +@deffnx {C Function} scm_number_p (obj) Return @code{#t} if @var{obj} is any kind of number, @code{#f} else. +@findex number? @end deffn For example: @@ -275,7 +279,8 @@ completely invisible to the Scheme level programmer. @c REFFIXME Maybe point here to discussion of handling immediates/bignums @c on the C level, where the conversion is not so automatic - NJ -@deffn primitive integer? x +@deffn {Scheme Procedure} integer? x +@deffnx {C Function} scm_integer_p (x) Return @code{#t} if @var{x} is an integer number, @code{#f} else. @lisp @@ -338,14 +343,17 @@ rational numbers and real irrational numbers such as square roots, and in such a way that the new kinds of number integrate seamlessly with those that are already implemented. -@deffn primitive real? obj +@deffn {Scheme Procedure} real? obj +@deffnx {C Function} scm_real_p (obj) Return @code{#t} if @var{obj} is a real number, @code{#f} else. Note that the sets of integer and rational values form subsets of the set of real numbers, so the predicate will also be fulfilled if @var{obj} is an integer number or a rational number. +@findex real? @end deffn -@deffn primitive rational? x +@deffn {Scheme Procedure} rational? x +@deffnx {C Function} scm_real_p (x) Return @code{#t} if @var{x} is a rational number, @code{#f} else. Note that the set of integer values forms a subset of the set of rational numbers, i. e. the predicate will also be @@ -384,7 +392,8 @@ Guile represents a complex number as a pair of numbers both of which are real, so the real and imaginary parts of a complex number have the same properties of inexactness and limited precision as single real numbers. -@deffn primitive complex? x +@deffn {Scheme Procedure} complex? x +@deffnx {C Function} scm_number_p (x) Return @code{#t} if @var{x} is a complex number, @code{#f} else. Note that the sets of real, rational and integer values form subsets of the set of complex numbers, i. e. the @@ -411,22 +420,25 @@ available, has no fractional part, and is printed as @code{5.0}. Guile will only convert the latter value to the former when forced to do so by an invocation of the @code{inexact->exact} procedure. -@deffn primitive exact? x +@deffn {Scheme Procedure} exact? x +@deffnx {C Function} scm_exact_p (x) Return @code{#t} if @var{x} is an exact number, @code{#f} otherwise. @end deffn -@deffn primitive inexact? x +@deffn {Scheme Procedure} inexact? x +@deffnx {C Function} scm_inexact_p (x) Return @code{#t} if @var{x} is an inexact number, @code{#f} else. @end deffn -@deffn primitive inexact->exact z +@deffn {Scheme Procedure} inexact->exact z +@deffnx {C Function} scm_inexact_to_exact (z) Return an exact number that is numerically closest to @var{z}. @end deffn @c begin (texi-doc-string "guile" "exact->inexact") -@deffn primitive exact->inexact z +@deffn {Scheme Procedure} exact->inexact z Convert the number @var{z} to its inexact representation. @end deffn @@ -508,23 +520,25 @@ multiplying by 10^N. @rnindex gcd @rnindex lcm -@deffn primitive odd? n +@deffn {Scheme Procedure} odd? n +@deffnx {C Function} scm_odd_p (n) Return @code{#t} if @var{n} is an odd number, @code{#f} otherwise. @end deffn -@deffn primitive even? n +@deffn {Scheme Procedure} even? n +@deffnx {C Function} scm_even_p (n) Return @code{#t} if @var{n} is an even number, @code{#f} otherwise. @end deffn @c begin (texi-doc-string "guile" "quotient") -@deffn primitive quotient +@deffn {Scheme Procedure} quotient Return the quotient of the numbers @var{x} and @var{y}. @end deffn @c begin (texi-doc-string "guile" "remainder") -@deffn primitive remainder +@deffn {Scheme Procedure} remainder Return the remainder of the numbers @var{x} and @var{y}. @lisp (remainder 13 4) @result{} 1 @@ -533,7 +547,7 @@ Return the remainder of the numbers @var{x} and @var{y}. @end deffn @c begin (texi-doc-string "guile" "modulo") -@deffn primitive modulo +@deffn {Scheme Procedure} modulo Return the modulo of the numbers @var{x} and @var{y}. @lisp (modulo 13 4) @result{} 1 @@ -542,13 +556,13 @@ Return the modulo of the numbers @var{x} and @var{y}. @end deffn @c begin (texi-doc-string "guile" "gcd") -@deffn primitive gcd +@deffn {Scheme Procedure} gcd Return the greatest common divisor of all arguments. If called without arguments, 0 is returned. @end deffn @c begin (texi-doc-string "guile" "lcm") -@deffn primitive lcm +@deffn {Scheme Procedure} lcm Return the least common multiple of the arguments. If called without arguments, 1 is returned. @end deffn @@ -561,48 +575,48 @@ If called without arguments, 1 is returned. @rnindex negative? @c begin (texi-doc-string "guile" "=") -@deffn primitive = +@deffn {Scheme Procedure} = Return @code{#t} if all parameters are numerically equal. @end deffn @c begin (texi-doc-string "guile" "<") -@deffn primitive < +@deffn {Scheme Procedure} < Return @code{#t} if the list of parameters is monotonically increasing. @end deffn @c begin (texi-doc-string "guile" ">") -@deffn primitive > +@deffn {Scheme Procedure} > Return @code{#t} if the list of parameters is monotonically decreasing. @end deffn @c begin (texi-doc-string "guile" "<=") -@deffn primitive <= +@deffn {Scheme Procedure} <= Return @code{#t} if the list of parameters is monotonically non-decreasing. @end deffn @c begin (texi-doc-string "guile" ">=") -@deffn primitive >= +@deffn {Scheme Procedure} >= Return @code{#t} if the list of parameters is monotonically non-increasing. @end deffn @c begin (texi-doc-string "guile" "zero?") -@deffn primitive zero? +@deffn {Scheme Procedure} zero? Return @code{#t} if @var{z} is an exact or inexact number equal to zero. @end deffn @c begin (texi-doc-string "guile" "positive?") -@deffn primitive positive? +@deffn {Scheme Procedure} positive? Return @code{#t} if @var{x} is an exact or inexact number greater than zero. @end deffn @c begin (texi-doc-string "guile" "negative?") -@deffn primitive negative? +@deffn {Scheme Procedure} negative? Return @code{#t} if @var{x} is an exact or inexact number less than zero. @end deffn @@ -613,13 +627,15 @@ zero. @rnindex number->string @rnindex string->number -@deffn primitive number->string n [radix] +@deffn {Scheme Procedure} number->string n [radix] +@deffnx {C Function} scm_number_to_string (n, radix) Return a string holding the external representation of the number @var{n} in the given @var{radix}. If @var{n} is inexact, a radix of 10 will be used. @end deffn -@deffn primitive string->number string [radix] +@deffn {Scheme Procedure} string->number string [radix] +@deffnx {C Function} scm_string_to_number (string, radix) Return a number of the maximally precise representation expressed by the given @var{string}. @var{radix} must be an exact integer, either 2, 8, 10, or 16. If supplied, @var{radix} @@ -640,33 +656,35 @@ syntactically valid notation for a number, then @rnindex magnitude @rnindex angle -@deffn primitive make-rectangular real imaginary +@deffn {Scheme Procedure} make-rectangular real imaginary +@deffnx {C Function} scm_make_rectangular (real, imaginary) Return a complex number constructed of the given @var{real} and @var{imaginary} parts. @end deffn -@deffn primitive make-polar x y +@deffn {Scheme Procedure} make-polar x y +@deffnx {C Function} scm_make_polar (x, y) Return the complex number @var{x} * e^(i * @var{y}). @end deffn @c begin (texi-doc-string "guile" "real-part") -@deffn primitive real-part +@deffn {Scheme Procedure} real-part Return the real part of the number @var{z}. @end deffn @c begin (texi-doc-string "guile" "imag-part") -@deffn primitive imag-part +@deffn {Scheme Procedure} imag-part Return the imaginary part of the number @var{z}. @end deffn @c begin (texi-doc-string "guile" "magnitude") -@deffn primitive magnitude +@deffn {Scheme Procedure} magnitude Return the magnitude of the number @var{z}. This is the same as @code{abs} for real arguments, but also allows complex numbers. @end deffn @c begin (texi-doc-string "guile" "angle") -@deffn primitive angle +@deffn {Scheme Procedure} angle Return the angle of the complex number @var{z}. @end deffn @@ -686,62 +704,62 @@ Return the angle of the complex number @var{z}. @rnindex round @c begin (texi-doc-string "guile" "+") -@deffn primitive + z1 @dots{} +@deffn {Scheme Procedure} + z1 @dots{} Return the sum of all parameter values. Return 0 if called without any parameters. @end deffn @c begin (texi-doc-string "guile" "-") -@deffn primitive - z1 z2 @dots{} +@deffn {Scheme Procedure} - z1 z2 @dots{} If called with one argument @var{z1}, -@var{z1} is returned. Otherwise the sum of all but the first argument are subtracted from the first argument. @end deffn @c begin (texi-doc-string "guile" "*") -@deffn primitive * z1 @dots{} +@deffn {Scheme Procedure} * z1 @dots{} Return the product of all arguments. If called without arguments, 1 is returned. @end deffn @c begin (texi-doc-string "guile" "/") -@deffn primitive / z1 z2 @dots{} +@deffn {Scheme Procedure} / z1 z2 @dots{} Divide the first argument by the product of the remaining arguments. If called with one argument @var{z1}, 1/@var{z1} is returned. @end deffn @c begin (texi-doc-string "guile" "abs") -@deffn primitive abs x +@deffn {Scheme Procedure} abs x Return the absolute value of @var{x}. @end deffn @c begin (texi-doc-string "guile" "max") -@deffn primitive max x1 x2 @dots{} +@deffn {Scheme Procedure} max x1 x2 @dots{} Return the maximum of all parameter values. @end deffn @c begin (texi-doc-string "guile" "min") -@deffn primitive min x1 x2 @dots{} +@deffn {Scheme Procedure} min x1 x2 @dots{} Return the minium of all parameter values. @end deffn @c begin (texi-doc-string "guile" "truncate") -@deffn primitive truncate +@deffn {Scheme Procedure} truncate Round the inexact number @var{x} towards zero. @end deffn @c begin (texi-doc-string "guile" "round") -@deffn primitive round x +@deffn {Scheme Procedure} round x Round the inexact number @var{x} towards zero. @end deffn @c begin (texi-doc-string "guile" "floor") -@deffn primitive floor x +@deffn {Scheme Procedure} floor x Round the number @var{x} towards minus infinity. @end deffn @c begin (texi-doc-string "guile" "ceiling") -@deffn primitive ceiling x +@deffn {Scheme Procedure} ceiling x Round the number @var{x} towards infinity. @end deffn @@ -754,97 +772,97 @@ including complex numbers. @rnindex sqrt @c begin (texi-doc-string "guile" "sqrt") -@deffn procedure sqrt z +@deffn {Scheme Procedure} sqrt z Return the square root of @var{z}. @end deffn @rnindex expt @c begin (texi-doc-string "guile" "expt") -@deffn procedure expt z1 z2 +@deffn {Scheme Procedure} expt z1 z2 Return @var{z1} raised to the power of @var{z2}. @end deffn @rnindex sin @c begin (texi-doc-string "guile" "sin") -@deffn procedure sin z +@deffn {Scheme Procedure} sin z Return the sine of @var{z}. @end deffn @rnindex cos @c begin (texi-doc-string "guile" "cos") -@deffn procedure cos z +@deffn {Scheme Procedure} cos z Return the cosine of @var{z}. @end deffn @rnindex tan @c begin (texi-doc-string "guile" "tan") -@deffn procedure tan z +@deffn {Scheme Procedure} tan z Return the tangent of @var{z}. @end deffn @rnindex asin @c begin (texi-doc-string "guile" "asin") -@deffn procedure asin z +@deffn {Scheme Procedure} asin z Return the arcsine of @var{z}. @end deffn @rnindex acos @c begin (texi-doc-string "guile" "acos") -@deffn procedure acos z +@deffn {Scheme Procedure} acos z Return the arccosine of @var{z}. @end deffn @rnindex atan @c begin (texi-doc-string "guile" "atan") -@deffn procedure atan z +@deffn {Scheme Procedure} atan z Return the arctangent of @var{z}. @end deffn @rnindex exp @c begin (texi-doc-string "guile" "exp") -@deffn procedure exp z +@deffn {Scheme Procedure} exp z Return e to the power of @var{z}, where e is the base of natural logarithms (2.71828@dots{}). @end deffn @rnindex log @c begin (texi-doc-string "guile" "log") -@deffn procedure log z +@deffn {Scheme Procedure} log z Return the natural logarithm of @var{z}. @end deffn @c begin (texi-doc-string "guile" "log10") -@deffn procedure log10 z +@deffn {Scheme Procedure} log10 z Return the base 10 logarithm of @var{z}. @end deffn @c begin (texi-doc-string "guile" "sinh") -@deffn procedure sinh z +@deffn {Scheme Procedure} sinh z Return the hyperbolic sine of @var{z}. @end deffn @c begin (texi-doc-string "guile" "cosh") -@deffn procedure cosh z +@deffn {Scheme Procedure} cosh z Return the hyperbolic cosine of @var{z}. @end deffn @c begin (texi-doc-string "guile" "tanh") -@deffn procedure tanh z +@deffn {Scheme Procedure} tanh z Return the hyperbolic tangent of @var{z}. @end deffn @c begin (texi-doc-string "guile" "asinh") -@deffn procedure asinh z +@deffn {Scheme Procedure} asinh z Return the hyperbolic arcsine of @var{z}. @end deffn @c begin (texi-doc-string "guile" "acosh") -@deffn procedure acosh z +@deffn {Scheme Procedure} acosh z Return the hyperbolic arccosine of @var{z}. @end deffn @c begin (texi-doc-string "guile" "atanh") -@deffn procedure atanh z +@deffn {Scheme Procedure} atanh z Return the hyperbolic arctangent of @var{z}. @end deffn @@ -858,51 +876,53 @@ procedures that use the following real number-based primitives. These primitives signal an error if they are called with complex arguments. @c begin (texi-doc-string "guile" "$abs") -@deffn primitive $abs x +@deffn {Scheme Procedure} $abs x Return the absolute value of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$sqrt") -@deffn primitive $sqrt x +@deffn {Scheme Procedure} $sqrt x Return the square root of @var{x}. @end deffn -@deffn primitive $expt x y +@deffn {Scheme Procedure} $expt x y +@deffnx {C Function} scm_sys_expt (x, y) Return @var{x} raised to the power of @var{y}. This procedure does not accept complex arguments. @end deffn @c begin (texi-doc-string "guile" "$sin") -@deffn primitive $sin x +@deffn {Scheme Procedure} $sin x Return the sine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$cos") -@deffn primitive $cos x +@deffn {Scheme Procedure} $cos x Return the cosine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$tan") -@deffn primitive $tan x +@deffn {Scheme Procedure} $tan x Return the tangent of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$asin") -@deffn primitive $asin x +@deffn {Scheme Procedure} $asin x Return the arcsine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$acos") -@deffn primitive $acos x +@deffn {Scheme Procedure} $acos x Return the arccosine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$atan") -@deffn primitive $atan x +@deffn {Scheme Procedure} $atan x Return the arctangent of @var{x} in the range -PI/2 to PI/2. @end deffn -@deffn primitive $atan2 x y +@deffn {Scheme Procedure} $atan2 x y +@deffnx {C Function} scm_sys_atan2 (x, y) Return the arc tangent of the two arguments @var{x} and @var{y}. This is similar to calculating the arc tangent of @var{x} / @var{y}, except that the signs of both arguments @@ -911,43 +931,43 @@ procedure does not accept complex arguments. @end deffn @c begin (texi-doc-string "guile" "$exp") -@deffn primitive $exp x +@deffn {Scheme Procedure} $exp x Return e to the power of @var{x}, where e is the base of natural logarithms (2.71828@dots{}). @end deffn @c begin (texi-doc-string "guile" "$log") -@deffn primitive $log x +@deffn {Scheme Procedure} $log x Return the natural logarithm of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$sinh") -@deffn primitive $sinh x +@deffn {Scheme Procedure} $sinh x Return the hyperbolic sine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$cosh") -@deffn primitive $cosh x +@deffn {Scheme Procedure} $cosh x Return the hyperbolic cosine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$tanh") -@deffn primitive $tanh x +@deffn {Scheme Procedure} $tanh x Return the hyperbolic tangent of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$asinh") -@deffn primitive $asinh x +@deffn {Scheme Procedure} $asinh x Return the hyperbolic arcsine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$acosh") -@deffn primitive $acosh x +@deffn {Scheme Procedure} $acosh x Return the hyperbolic arccosine of @var{x}. @end deffn @c begin (texi-doc-string "guile" "$atanh") -@deffn primitive $atanh x +@deffn {Scheme Procedure} $atanh x Return the hyperbolic arctangent of @var{x}. @end deffn @@ -955,7 +975,7 @@ Return the hyperbolic arctangent of @var{x}. @node Bitwise Operations @subsection Bitwise Operations -@deffn primitive logand n1 n2 +@deffn {Scheme Procedure} logand n1 n2 Return the bitwise AND of the integer arguments. @lisp @@ -965,7 +985,7 @@ Return the bitwise AND of the integer arguments. @end lisp @end deffn -@deffn primitive logior n1 n2 +@deffn {Scheme Procedure} logior n1 n2 Return the bitwise OR of the integer arguments. @lisp @@ -975,7 +995,7 @@ Return the bitwise OR of the integer arguments. @end lisp @end deffn -@deffn primitive logxor n1 n2 +@deffn {Scheme Procedure} logxor n1 n2 Return the bitwise XOR of the integer arguments. A bit is set in the result if it is set in an odd number of arguments. @lisp @@ -986,7 +1006,8 @@ set in the result if it is set in an odd number of arguments. @end lisp @end deffn -@deffn primitive lognot n +@deffn {Scheme Procedure} lognot n +@deffnx {C Function} scm_lognot (n) Return the integer which is the 2s-complement of the integer argument. @@ -998,7 +1019,8 @@ argument. @end lisp @end deffn -@deffn primitive logtest j k +@deffn {Scheme Procedure} logtest j k +@deffnx {C Function} scm_logtest (j, k) @lisp (logtest j k) @equiv{} (not (zero? (logand j k))) @@ -1007,7 +1029,8 @@ argument. @end lisp @end deffn -@deffn primitive logbit? index j +@deffn {Scheme Procedure} logbit? index j +@deffnx {C Function} scm_logbit_p (index, j) @lisp (logbit? index j) @equiv{} (logtest (integer-expt 2 index) j) @@ -1019,7 +1042,8 @@ argument. @end lisp @end deffn -@deffn primitive ash n cnt +@deffn {Scheme Procedure} ash n cnt +@deffnx {C Function} scm_ash (n, cnt) The function ash performs an arithmetic shift left by @var{cnt} bits (or shift right, if @var{cnt} is negative). 'Arithmetic' means, that the function does not guarantee to keep the bit @@ -1037,7 +1061,8 @@ Formally, the function returns an integer equivalent to @end lisp @end deffn -@deffn primitive logcount n +@deffn {Scheme Procedure} logcount n +@deffnx {C Function} scm_logcount (n) Return the number of bits in integer @var{n}. If integer is positive, the 1-bits in its binary representation are counted. If negative, the 0-bits in its two's-complement binary @@ -1053,7 +1078,8 @@ representation are counted. If 0, 0 is returned. @end lisp @end deffn -@deffn primitive integer-length n +@deffn {Scheme Procedure} integer-length n +@deffnx {C Function} scm_integer_length (n) Return the number of bits neccessary to represent @var{n}. @lisp @@ -1066,7 +1092,8 @@ Return the number of bits neccessary to represent @var{n}. @end lisp @end deffn -@deffn primitive integer-expt n k +@deffn {Scheme Procedure} integer-expt n k +@deffnx {C Function} scm_integer_expt (n, k) Return @var{n} raised to the non-negative integer exponent @var{k}. @@ -1078,7 +1105,8 @@ Return @var{n} raised to the non-negative integer exponent @end lisp @end deffn -@deffn primitive bit-extract n start end +@deffn {Scheme Procedure} bit-extract n start end +@deffnx {C Function} scm_bit_extract (n, start, end) Return the integer composed of the @var{start} (inclusive) through @var{end} (exclusive) bits of @var{n}. The @var{start}th bit becomes the 0-th bit in the result. @@ -1095,11 +1123,13 @@ through @var{end} (exclusive) bits of @var{n}. The @node Random @subsection Random Number Generation -@deffn primitive copy-random-state [state] +@deffn {Scheme Procedure} copy-random-state [state] +@deffnx {C Function} scm_copy_random_state (state) Return a copy of the random state @var{state}. @end deffn -@deffn primitive random n [state] +@deffn {Scheme Procedure} random n [state] +@deffnx {C Function} scm_random (n, state) Return a number in [0,N). Accepts a positive integer or real n and returns a @@ -1114,13 +1144,15 @@ the state of the pseudo-random-number generator and is altered as a side effect of the random operation. @end deffn -@deffn primitive random:exp [state] +@deffn {Scheme Procedure} random:exp [state] +@deffnx {C Function} scm_random_exp (state) Return an inexact real in an exponential distribution with mean 1. For an exponential distribution with mean u use (* u (random:exp)). @end deffn -@deffn primitive random:hollow-sphere! v [state] +@deffn {Scheme Procedure} random:hollow-sphere! v [state] +@deffnx {C Function} scm_random_hollow_sphere_x (v, state) Fills vect with inexact real random numbers the sum of whose squares is equal to 1.0. Thinking of vect as coordinates in space of @@ -1129,20 +1161,23 @@ are uniformly distributed over the surface of the unit n-sphere. @end deffn -@deffn primitive random:normal [state] +@deffn {Scheme Procedure} random:normal [state] +@deffnx {C Function} scm_random_normal (state) Return an inexact real in a normal distribution. The distribution used has mean 0 and standard deviation 1. For a normal distribution with mean m and standard deviation d use @code{(+ m (* d (random:normal)))}. @end deffn -@deffn primitive random:normal-vector! v [state] +@deffn {Scheme Procedure} random:normal-vector! v [state] +@deffnx {C Function} scm_random_normal_vector_x (v, state) Fills vect with inexact real random numbers that are independent and standard normally distributed (i.e., with mean 0 and variance 1). @end deffn -@deffn primitive random:solid-sphere! v [state] +@deffn {Scheme Procedure} random:solid-sphere! v [state] +@deffnx {C Function} scm_random_solid_sphere_x (v, state) Fills vect with inexact real random numbers the sum of whose squares is less than 1.0. Thinking of vect as coordinates in space of @@ -1151,12 +1186,14 @@ are uniformly distributed within the unit n-sphere. The sum of the squares of the numbers is returned. @end deffn -@deffn primitive random:uniform [state] +@deffn {Scheme Procedure} random:uniform [state] +@deffnx {C Function} scm_random_uniform (state) Return a uniformly distributed inexact real random number in [0,1). @end deffn -@deffn primitive seed->random-state seed +@deffn {Scheme Procedure} seed->random-state seed +@deffnx {C Function} scm_seed_to_random_state (seed) Return a new random state using @var{seed}. @end deffn @@ -1228,123 +1265,134 @@ Several characters have more than one name: @end itemize @rnindex char? -@deffn primitive char? x +@deffn {Scheme Procedure} char? x +@deffnx {C Function} scm_char_p (x) Return @code{#t} iff @var{x} is a character, else @code{#f}. @end deffn @rnindex char=? -@deffn primitive char=? x y +@deffn {Scheme Procedure} char=? x y Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}. @end deffn @rnindex char? -@deffn primitive char>? x y +@deffn {Scheme Procedure} char>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence, else @code{#f}. @end deffn @rnindex char>=? -@deffn primitive char>=? x y +@deffn {Scheme Procedure} char>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence, else @code{#f}. @end deffn @rnindex char-ci=? -@deffn primitive char-ci=? x y +@deffn {Scheme Procedure} char-ci=? x y Return @code{#t} iff @var{x} is the same character as @var{y} ignoring case, else @code{#f}. @end deffn @rnindex char-ci? -@deffn primitive char-ci>? x y +@deffn {Scheme Procedure} char-ci>? x y Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn @rnindex char-ci>=? -@deffn primitive char-ci>=? x y +@deffn {Scheme Procedure} char-ci>=? x y Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the ASCII sequence ignoring case, else @code{#f}. @end deffn @rnindex char-alphabetic? -@deffn primitive char-alphabetic? chr +@deffn {Scheme Procedure} char-alphabetic? chr +@deffnx {C Function} scm_char_alphabetic_p (chr) Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}. Alphabetic means the same thing as the isalpha C library function. @end deffn @rnindex char-numeric? -@deffn primitive char-numeric? chr +@deffn {Scheme Procedure} char-numeric? chr +@deffnx {C Function} scm_char_numeric_p (chr) Return @code{#t} iff @var{chr} is numeric, else @code{#f}. Numeric means the same thing as the isdigit C library function. @end deffn @rnindex char-whitespace? -@deffn primitive char-whitespace? chr +@deffn {Scheme Procedure} char-whitespace? chr +@deffnx {C Function} scm_char_whitespace_p (chr) Return @code{#t} iff @var{chr} is whitespace, else @code{#f}. Whitespace means the same thing as the isspace C library function. @end deffn @rnindex char-upper-case? -@deffn primitive char-upper-case? chr +@deffn {Scheme Procedure} char-upper-case? chr +@deffnx {C Function} scm_char_upper_case_p (chr) Return @code{#t} iff @var{chr} is uppercase, else @code{#f}. Uppercase means the same thing as the isupper C library function. @end deffn @rnindex char-lower-case? -@deffn primitive char-lower-case? chr +@deffn {Scheme Procedure} char-lower-case? chr +@deffnx {C Function} scm_char_lower_case_p (chr) Return @code{#t} iff @var{chr} is lowercase, else @code{#f}. Lowercase means the same thing as the islower C library function. @end deffn -@deffn primitive char-is-both? chr +@deffn {Scheme Procedure} char-is-both? chr +@deffnx {C Function} scm_char_is_both_p (chr) Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}. Uppercase and lowercase are as defined by the isupper and islower C library functions. @end deffn @rnindex char->integer -@deffn primitive char->integer chr +@deffn {Scheme Procedure} char->integer chr +@deffnx {C Function} scm_char_to_integer (chr) Return the number corresponding to ordinal position of @var{chr} in the ASCII sequence. @end deffn @rnindex integer->char -@deffn primitive integer->char n +@deffn {Scheme Procedure} integer->char n +@deffnx {C Function} scm_integer_to_char (n) Return the character at position @var{n} in the ASCII sequence. @end deffn @rnindex char-upcase -@deffn primitive char-upcase chr +@deffn {Scheme Procedure} char-upcase chr +@deffnx {C Function} scm_char_upcase (chr) Return the uppercase character version of @var{chr}. @end deffn @rnindex char-downcase -@deffn primitive char-downcase chr +@deffn {Scheme Procedure} char-downcase chr +@deffnx {C Function} scm_char_downcase (chr) Return the lowercase character version of @var{chr}. @end deffn @@ -1410,11 +1458,13 @@ The following procedures can be used to check whether a given string fulfills some specified property. @rnindex string? -@deffn primitive string? obj +@deffn {Scheme Procedure} string? obj +@deffnx {C Function} scm_string_p (obj) Return @code{#t} iff @var{obj} is a string, else @code{#f}. @end deffn -@deffn primitive string-null? str +@deffn {Scheme Procedure} string-null? str +@deffnx {C Function} scm_string_null_p (str) Return @code{#t} if @var{str}'s length is zero, and @code{#f} otherwise. @lisp @@ -1434,14 +1484,16 @@ initializing them with some specified character data. @rnindex string @rnindex list->string -@deffn primitive string . chrs -@deffnx primitive list->string chrs +@deffn {Scheme Procedure} string . chrs +@deffnx {Scheme Procedure} list->string chrs +@deffnx {C Function} scm_string (chrs) Return a newly allocated string composed of the arguments, @var{chrs}. @end deffn @rnindex make-string -@deffn primitive make-string k [chr] +@deffn {Scheme Procedure} make-string k [chr] +@deffnx {C Function} scm_make_string (k, chr) Return a newly allocated string of length @var{k}. If @var{chr} is given, then all elements of the string are initialized to @var{chr}, otherwise the contents @@ -1457,14 +1509,16 @@ work with the resulting list, and then convert it back into a string. These procedures are useful for similar tasks. @rnindex string->list -@deffn primitive string->list str +@deffn {Scheme Procedure} string->list str +@deffnx {C Function} scm_string_to_list (str) Return a newly allocated list of the characters that make up the given string @var{str}. @code{string->list} and @code{list->string} are inverses as far as @samp{equal?} is concerned. @end deffn -@deffn primitive string-split str chr +@deffn {Scheme Procedure} string-split str chr +@deffnx {C Function} scm_string_split (str, chr) Split the string @var{str} into the a list of the substrings delimited by appearances of the character @var{chr}. Note that an empty substring between separator characters will result in an empty string in the @@ -1494,23 +1548,27 @@ Portions of strings can be extracted by these procedures. @code{substring} can be used to extract substrings from longer strings. @rnindex string-length -@deffn primitive string-length string +@deffn {Scheme Procedure} string-length string +@deffnx {C Function} scm_string_length (string) Return the number of characters in @var{string}. @end deffn @rnindex string-ref -@deffn primitive string-ref str k +@deffn {Scheme Procedure} string-ref str k +@deffnx {C Function} scm_string_ref (str, k) Return character @var{k} of @var{str} using zero-origin indexing. @var{k} must be a valid index of @var{str}. @end deffn @rnindex string-copy -@deffn primitive string-copy str +@deffn {Scheme Procedure} string-copy str +@deffnx {C Function} scm_string_copy (str) Return a newly allocated copy of the given @var{string}. @end deffn @rnindex substring -@deffn primitive substring str start [end] +@deffn {Scheme Procedure} substring str start [end] +@deffnx {C Function} scm_substring (str, start, end) Return a newly allocated string formed from the characters of @var{str} beginning with index @var{start} (inclusive) and ending with index @var{end} (exclusive). @@ -1528,19 +1586,22 @@ result of the operation is not a new string; instead, the original string's memory representation is modified. @rnindex string-set! -@deffn primitive string-set! str k chr +@deffn {Scheme Procedure} string-set! str k chr +@deffnx {C Function} scm_string_set_x (str, k, chr) Store @var{chr} in element @var{k} of @var{str} and return an unspecified value. @var{k} must be a valid index of @var{str}. @end deffn @rnindex string-fill! -@deffn primitive string-fill! str chr +@deffn {Scheme Procedure} string-fill! str chr +@deffnx {C Function} scm_string_fill_x (str, chr) Store @var{char} in every element of the given @var{string} and return an unspecified value. @end deffn -@deffn primitive substring-fill! str start end fill +@deffn {Scheme Procedure} substring-fill! str start end fill +@deffnx {C Function} scm_substring_fill_x (str, start, end, fill) Change every character in @var{str} between @var{start} and @var{end} to @var{fill}. @@ -1552,56 +1613,11 @@ y @end lisp @end deffn -@deffn primitive substring-move! str1 start1 end1 str2 start2 -@deffnx primitive substring-move-left! str1 start1 end1 str2 start2 -@deffnx primitive substring-move-right! str1 start1 end1 str2 start2 +@deffn {Scheme Procedure} substring-move! str1 start1 end1 str2 start2 +@deffnx {C Function} scm_substring_move_x (str1, start1, end1, str2, start2) Copy the substring of @var{str1} bounded by @var{start1} and @var{end1} into @var{str2} beginning at position @var{start2}. -@code{substring-move-right!} begins copying from the rightmost character -and moves left, and @code{substring-move-left!} copies from the leftmost -character moving right. - -It is useful to have two functions that copy in different directions so -that substrings can be copied back and forth within a single string. If -you wish to copy text from the left-hand side of a string to the -right-hand side of the same string, and the source and destination -overlap, you must be careful to copy the rightmost characters of the -text first, to avoid clobbering your data. Hence, when @var{str1} and -@var{str2} are the same string, you should use -@code{substring-move-right!} when moving text from left to right, and -@code{substring-move-left!} otherwise. If @code{str1} and @samp{str2} -are different strings, it does not matter which function you use. - -@example -(define x (make-string 10 #\a)) -(define y "bcd") -(substring-move-left! x 2 5 y 0) -y -@result{} "aaa" - -x -@result{} "aaaaaaaaaa" - -(define y "bcdefg") -(substring-move-left! x 2 5 y 0) -y -@result{} "aaaefg" - -(define y "abcdefg") -(substring-move-left! y 2 5 y 3) -y -@result{} "abccccg" - -(define y "abcdefg") -(substring-move-right! y 2 5 y 0) -y -@result{} "ededefg" - -(define y "abcdefg") -(substring-move-right! y 2 5 y 3) -y -@result{} "abccdeg" -@end example +@var{str1} and @var{str2} can be the same string. @end deffn @@ -1616,7 +1632,7 @@ strings. @rnindex string=? -@deffn primitive string=? s1 s2 +@deffn {Scheme Procedure} string=? s1 s2 Lexicographic equality predicate; return @code{#t} if the two strings are the same length and contain the same characters in the same positions, otherwise return @code{#f}. @@ -1628,31 +1644,31 @@ characters. @end deffn @rnindex string? -@deffn primitive string>? s1 s2 +@deffn {Scheme Procedure} string>? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @var{s2}. @end deffn @rnindex string>=? -@deffn primitive string>=? s1 s2 +@deffn {Scheme Procedure} string>=? s1 s2 Lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or equal to @var{s2}. @end deffn @rnindex string-ci=? -@deffn primitive string-ci=? s1 s2 +@deffn {Scheme Procedure} string-ci=? s1 s2 Case-insensitive string equality predicate; return @code{#t} if the two strings are the same length and their component characters match (ignoring case) at each position; otherwise @@ -1660,28 +1676,28 @@ return @code{#f}. @end deffn @rnindex string-ci< -@deffn primitive string-ci? -@deffn primitive string-ci>? s1 s2 +@deffn {Scheme Procedure} string-ci>? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than @var{s2} regardless of case. @end deffn @rnindex string-ci>=? -@deffn primitive string-ci>=? s1 s2 +@deffn {Scheme Procedure} string-ci>=? s1 s2 Case insensitive lexicographic ordering predicate; return @code{#t} if @var{s1} is lexicographically greater than or equal to @var{s2} regardless of case. @@ -1694,7 +1710,8 @@ equal to @var{s2} regardless of case. When searching for the index of a character in a string, these procedures can be used. -@deffn primitive string-index str chr [frm [to]] +@deffn {Scheme Procedure} string-index str chr [frm [to]] +@deffnx {C Function} scm_string_index (str, chr, frm, to) Return the index of the first occurrence of @var{chr} in @var{str}. The optional integer arguments @var{frm} and @var{to} limit the search to a portion of the string. This @@ -1713,7 +1730,8 @@ procedure essentially implements the @code{index} or @end lisp @end deffn -@deffn primitive string-rindex str chr [frm [to]] +@deffn {Scheme Procedure} string-rindex str chr [frm [to]] +@deffnx {C Function} scm_string_rindex (str, chr, frm, to) Like @code{string-index}, but search from the right of the string rather than from the left. This procedure essentially implements the @code{rindex} or @code{strrchr} functions from @@ -1737,12 +1755,14 @@ the C library. These are procedures for mapping strings to their upper- or lower-case equivalents, respectively, or for capitalizing strings. -@deffn primitive string-upcase str +@deffn {Scheme Procedure} string-upcase str +@deffnx {C Function} scm_string_upcase (str) Return a freshly allocated string containing the characters of @var{str} in upper case. @end deffn -@deffn primitive string-upcase! str +@deffn {Scheme Procedure} string-upcase! str +@deffnx {C Function} scm_string_upcase_x (str) Destructively upcase every character in @var{str} and return @var{str}. @lisp @@ -1752,12 +1772,14 @@ y @result{} "ARRDEFG" @end lisp @end deffn -@deffn primitive string-downcase str +@deffn {Scheme Procedure} string-downcase str +@deffnx {C Function} scm_string_downcase (str) Return a freshly allocation string containing the characters in @var{str} in lower case. @end deffn -@deffn primitive string-downcase! str +@deffn {Scheme Procedure} string-downcase! str +@deffnx {C Function} scm_string_downcase_x (str) Destructively downcase every character in @var{str} and return @var{str}. @lisp @@ -1767,13 +1789,15 @@ y @result{} "arrdefg" @end lisp @end deffn -@deffn primitive string-capitalize str +@deffn {Scheme Procedure} string-capitalize str +@deffnx {C Function} scm_string_capitalize (str) Return a freshly allocated string with the characters in @var{str}, where the first character of every word is capitalized. @end deffn -@deffn primitive string-capitalize! str +@deffn {Scheme Procedure} string-capitalize! str +@deffnx {C Function} scm_string_capitalize_x (str) Upcase the first character of every word in @var{str} destructively and return @var{str}. @@ -1792,9 +1816,10 @@ The procedure @code{string-append} appends several strings together to form a longer result string. @rnindex string-append -@deffn primitive string-append string1 @dots{} +@deffn {Scheme Procedure} string-append . args +@deffnx {C Function} scm_string_append (args) Return a newly allocated string whose characters form the -concatenation of the given strings. +concatenation of the given strings, @var{args}. @end deffn @@ -1803,7 +1828,8 @@ concatenation of the given strings. This section contains all remaining string procedures. -@deffn primitive string-ci->symbol str +@deffn {Scheme Procedure} string-ci->symbol str +@deffnx {C Function} scm_string_ci_to_symbol (str) Return the symbol whose name is @var{str}. @var{str} is converted to lowercase before the conversion is done, if Guile is currently reading symbols case-insensitively. @@ -1854,7 +1880,7 @@ implemented by SCSH, the Scheme Shell. It is intended to be upwardly compatible with SCSH regular expressions. @c begin (scm-doc-string "regex.scm" "string-match") -@deffn procedure string-match pattern str [start] +@deffn {Scheme Procedure} string-match pattern str [start] Compile the string @var{pattern} into a regular expression and compare it with @var{str}. The optional numeric argument @var{start} specifies the position of @var{str} at which to begin matching. @@ -1872,7 +1898,8 @@ the same regular expression is used several times (for example, in a loop). For better performance, you can compile a regular expression in advance and then match strings against the compiled regexp. -@deffn primitive make-regexp pat . flags +@deffn {Scheme Procedure} make-regexp pat . flags +@deffnx {C Function} scm_make_regexp (pat, flags) Compile the regular expression described by @var{pat}, and return the compiled regexp structure. If @var{pat} does not describe a legal regular expression, @code{make-regexp} throws @@ -1912,7 +1939,8 @@ one which comes last will override the earlier one. @end table @end deffn -@deffn primitive regexp-exec rx str [start [flags]] +@deffn {Scheme Procedure} regexp-exec rx str [start [flags]] +@deffnx {C Function} scm_regexp_exec (rx, str, start, flags) Match the compiled regular expression @var{rx} against @code{str}. If the optional integer @var{start} argument is provided, begin matching from that position in the string. @@ -1934,7 +1962,8 @@ considered the end of a line. @end table @end deffn -@deffn primitive regexp? obj +@deffn {Scheme Procedure} regexp? obj +@deffnx {C Function} scm_regexp_p (obj) Return @code{#t} if @var{obj} is a compiled regular expression, or @code{#f} otherwise. @end deffn @@ -1943,7 +1972,7 @@ Regular expressions are commonly used to find patterns in one string and replace them with the contents of another string. @c begin (scm-doc-string "regex.scm" "regexp-substitute") -@deffn procedure regexp-substitute port match [item@dots{}] +@deffn {Scheme Procedure} regexp-substitute port match [item@dots{}] Write to the output port @var{port} selected contents of the match structure @var{match}. Each @var{item} specifies what should be written, and may be one of the following arguments: @@ -1970,7 +1999,7 @@ the regexp match is written. @end deffn @c begin (scm-doc-string "regex.scm" "regexp-substitute") -@deffn procedure regexp-substitute/global port regexp target [item@dots{}] +@deffn {Scheme Procedure} regexp-substitute/global port regexp target [item@dots{}] Similar to @code{regexp-substitute}, but can be used to perform global substitutions on @var{str}. Instead of taking a match structure as an argument, @code{regexp-substitute/global} takes two string arguments: a @@ -2016,13 +2045,13 @@ matched against a regular expression; we will call that string @var{target} for easy reference. @c begin (scm-doc-string "regex.scm" "regexp-match?") -@deffn procedure regexp-match? obj +@deffn {Scheme Procedure} regexp-match? obj Return @code{#t} if @var{obj} is a match structure returned by a previous call to @code{regexp-exec}, or @code{#f} otherwise. @end deffn @c begin (scm-doc-string "regex.scm" "match:substring") -@deffn procedure match:substring match [n] +@deffn {Scheme Procedure} match:substring match [n] Return the portion of @var{target} matched by subexpression number @var{n}. Submatch 0 (the default) represents the entire regexp match. If the regular expression as a whole matched, but the subexpression @@ -2030,34 +2059,34 @@ number @var{n} did not match, return @code{#f}. @end deffn @c begin (scm-doc-string "regex.scm" "match:start") -@deffn procedure match:start match [n] +@deffn {Scheme Procedure} match:start match [n] Return the starting position of submatch number @var{n}. @end deffn @c begin (scm-doc-string "regex.scm" "match:end") -@deffn procedure match:end match [n] +@deffn {Scheme Procedure} match:end match [n] Return the ending position of submatch number @var{n}. @end deffn @c begin (scm-doc-string "regex.scm" "match:prefix") -@deffn procedure match:prefix match +@deffn {Scheme Procedure} match:prefix match Return the unmatched portion of @var{target} preceding the regexp match. @end deffn @c begin (scm-doc-string "regex.scm" "match:suffix") -@deffn procedure match:suffix match +@deffn {Scheme Procedure} match:suffix match Return the unmatched portion of @var{target} following the regexp match. @end deffn @c begin (scm-doc-string "regex.scm" "match:count") -@deffn procedure match:count match +@deffn {Scheme Procedure} match:count match Return the number of parenthesized subexpressions from @var{match}. Note that the entire regular expression match itself counts as a subexpression, and failed submatches are included in the count. @end deffn @c begin (scm-doc-string "regex.scm" "match:string") -@deffn procedure match:string match +@deffn {Scheme Procedure} match:string match Return the original @var{target} string. @end deffn @@ -2091,7 +2120,7 @@ by any number of alphabetic characters. The regular expression regexp each match a single backslash in the target string. @c begin (scm-doc-string "regex.scm" "regexp-quote") -@deffn procedure regexp-quote str +@deffn {Scheme Procedure} regexp-quote str Quote each special character found in @var{str} with a backslash, and return the resulting string. @end deffn @@ -2180,7 +2209,7 @@ guile> The definitions of @code{regcomp} and @code{regexec} are as follows: @c NJFIXME not in libguile! -@deffn primitive regcomp pattern [flags] +@deffn {Scheme Procedure} regcomp pattern [flags] Compile the regular expression pattern using POSIX rules. Flags is optional and should be specified using symbolic names: @defvar REG_EXTENDED @@ -2203,7 +2232,7 @@ literal string e.g., @code{"\\(a\\)\\?"}. @end deffn @c NJFIXME not in libguile! -@deffn primitive regexec regex string [match-pick] [flags] +@deffn {Scheme Procedure} regexec regex string [match-pick] [flags] Match @var{string} against the compiled POSIX regular expression @var{regex}. @@ -2262,32 +2291,32 @@ Here are some other procedures that might be used when using regular expressions: @c NJFIXME not in libguile! -@deffn primitive compiled-regexp? obj +@deffn {Scheme Procedure} compiled-regexp? obj Test whether obj is a compiled regular expression. @end deffn @c NJFIXME not in libguile! -@deffn primitive regexp->dfa regex [flags] +@deffn {Scheme Procedure} regexp->dfa regex [flags] @end deffn @c NJFIXME not in libguile! -@deffn primitive dfa-fork dfa +@deffn {Scheme Procedure} dfa-fork dfa @end deffn @c NJFIXME not in libguile! -@deffn primitive reset-dfa! dfa +@deffn {Scheme Procedure} reset-dfa! dfa @end deffn @c NJFIXME not in libguile! -@deffn primitive dfa-final-tag dfa +@deffn {Scheme Procedure} dfa-final-tag dfa @end deffn @c NJFIXME not in libguile! -@deffn primitive dfa-continuable? dfa +@deffn {Scheme Procedure} dfa-continuable? dfa @end deffn @c NJFIXME not in libguile! -@deffn primitive advance-dfa! dfa string +@deffn {Scheme Procedure} advance-dfa! dfa string @end deffn @@ -2373,13 +2402,15 @@ Usage of this form of read syntax is discouraged, because it is not portable at all, and is not very readable. @rnindex symbol? -@deffn primitive symbol? obj +@deffn {Scheme Procedure} symbol? obj +@deffnx {C Function} scm_symbol_p (obj) Return @code{#t} if @var{obj} is a symbol, otherwise return @code{#f}. @end deffn @rnindex string->symbol -@deffn primitive string->symbol string +@deffn {Scheme Procedure} string->symbol string +@deffnx {C Function} scm_string_to_symbol (string) Return the symbol whose name is @var{string}. This procedure can create symbols with names containing special characters or letters in the non-standard case, but it is usually a bad idea @@ -2403,7 +2434,8 @@ standard case is lower case: @end deffn @rnindex symbol->string -@deffn primitive symbol->string s +@deffn {Scheme Procedure} symbol->string s +@deffnx {C Function} scm_symbol_to_string (s) Return the name of @var{symbol} as a string. If the symbol was part of an object returned as the value of a literal expression (section @pxref{Literal expressions,,,r5rs, The Revised^5 @@ -2446,12 +2478,13 @@ table (with an undefined value) if none is yet present. @c FIXME::martin: According to NEWS, removed. Remove here too, or @c leave for compatibility? @c @c docstring begin (texi-doc-string "guile" "builtin-bindings") -@c @deffn primitive builtin-bindings +@c @deffn {Scheme Procedure} builtin-bindings @c Create and return a copy of the global symbol table, removing all @c unbound symbols. @c @end deffn -@deffn primitive gensym [prefix] +@deffn {Scheme Procedure} gensym [prefix] +@deffnx {C Function} scm_gensym (prefix) Create a new symbol with a name constructed from a prefix and a counter value. The string @var{prefix} can be specified as an optional argument. Default prefix is @code{g}. The counter @@ -2459,7 +2492,7 @@ is increased by 1 at each call. There is no provision for resetting the counter. @end deffn -@deffn primitive gentemp [prefix [obarray]] +@deffn {Scheme Procedure} gentemp [prefix [obarray]] Create a new symbol with a name unique in an obarray. The name is constructed from an optional string @var{prefix} and a counter value. The default prefix is @code{t}. The @@ -2469,25 +2502,25 @@ interned. The counter is increased by 1 at each call. There is no provision for resetting the counter. @end deffn -@deffn primitive intern-symbol obarray string +@deffn {Scheme Procedure} intern-symbol obarray string Add a new symbol to @var{obarray} with name @var{string}, bound to an unspecified initial value. The symbol table is not modified if a symbol with this name is already present. @end deffn -@deffn primitive string->obarray-symbol obarray string [soft?] +@deffn {Scheme Procedure} string->obarray-symbol obarray string [soft?] Intern a new symbol in @var{obarray}, a symbol table, with name @var{string}. @end deffn -@deffn primitive symbol-binding obarray string +@deffn {Scheme Procedure} symbol-binding obarray string Look up in @var{obarray} the symbol whose name is @var{string}, and return the value to which it is bound. If @var{obarray} is @code{#f}, use the global symbol table. If @var{string} is not interned in @var{obarray}, an error is signalled. @end deffn -@deffn primitive symbol-bound? obarray string +@deffn {Scheme Procedure} symbol-bound? obarray string Return @code{#t} if @var{obarray} contains a symbol with name @var{string} bound to a defined value. This differs from @var{symbol-interned?} in that the mere mention of a symbol @@ -2496,38 +2529,43 @@ determines whether a symbol has been given any meaningful value. @end deffn -@deffn primitive symbol-fref symbol +@deffn {Scheme Procedure} symbol-fref symbol +@deffnx {C Function} scm_symbol_fref (symbol) Return the contents of @var{symbol}'s @dfn{function slot}. @end deffn -@deffn primitive symbol-fset! symbol value +@deffn {Scheme Procedure} symbol-fset! symbol value +@deffnx {C Function} scm_symbol_fset_x (symbol, value) Change the binding of @var{symbol}'s function slot. @end deffn -@deffn primitive symbol-hash symbol +@deffn {Scheme Procedure} symbol-hash symbol +@deffnx {C Function} scm_symbol_hash (symbol) Return a hash value for @var{symbol}. @end deffn -@deffn primitive symbol-interned? obarray string +@deffn {Scheme Procedure} symbol-interned? obarray string Return @code{#t} if @var{obarray} contains a symbol with name @var{string}, and @code{#f} otherwise. @end deffn -@deffn primitive symbol-pref symbol +@deffn {Scheme Procedure} symbol-pref symbol +@deffnx {C Function} scm_symbol_pref (symbol) Return the @dfn{property list} currently associated with @var{symbol}. @end deffn -@deffn primitive symbol-pset! symbol value +@deffn {Scheme Procedure} symbol-pset! symbol value +@deffnx {C Function} scm_symbol_pset_x (symbol, value) Change the binding of @var{symbol}'s property slot. @end deffn -@deffn primitive symbol-set! obarray string value +@deffn {Scheme Procedure} symbol-set! obarray string value Find the symbol in @var{obarray} whose name is @var{string}, and rebind it to @var{value}. An error is signalled if @var{string} is not present in @var{obarray}. @end deffn -@deffn primitive unintern-symbol obarray string +@deffn {Scheme Procedure} unintern-symbol obarray string Remove the symbol with name @var{string} from @var{obarray}. This function returns @code{#t} if the symbol was present and @code{#f} otherwise. @@ -2551,38 +2589,44 @@ one of the constructor procedures @code{make-variable} or First-class variables are especially useful for interacting with the current module system (@pxref{The Guile module system}). -@deffn primitive builtin-variable name +@deffn {Scheme Procedure} builtin-variable name Return the built-in variable with the name @var{name}. @var{name} must be a symbol (not a string). Then use @code{variable-ref} to access its value. @end deffn -@deffn primitive make-undefined-variable +@deffn {Scheme Procedure} make-undefined-variable +@deffnx {C Function} scm_make_undefined_variable () Return a variable that is initially unbound. @end deffn -@deffn primitive make-variable init +@deffn {Scheme Procedure} make-variable init +@deffnx {C Function} scm_make_variable (init) Return a variable initialized to value @var{init}. @end deffn -@deffn primitive variable-bound? var +@deffn {Scheme Procedure} variable-bound? var +@deffnx {C Function} scm_variable_bound_p (var) Return @code{#t} iff @var{var} is bound to a value. Throws an error if @var{var} is not a variable object. @end deffn -@deffn primitive variable-ref var +@deffn {Scheme Procedure} variable-ref var +@deffnx {C Function} scm_variable_ref (var) Dereference @var{var} and return its value. @var{var} must be a variable object; see @code{make-variable} and @code{make-undefined-variable}. @end deffn -@deffn primitive variable-set! var val +@deffn {Scheme Procedure} variable-set! var val +@deffnx {C Function} scm_variable_set_x (var, val) Set the value of the variable @var{var} to @var{val}. @var{var} must be a variable object, @var{val} can be any value. Return an unspecified value. @end deffn -@deffn primitive variable? obj +@deffn {Scheme Procedure} variable? obj +@deffnx {C Function} scm_variable_p (obj) Return @code{#t} iff @var{obj} is a variable object, else return @code{#f}. @end deffn @@ -2778,11 +2822,11 @@ ABORT: (unbound-variable) The following procedures can be used for converting symbols to keywords and back. -@deffn procedure symbol->keyword sym +@deffn {Scheme Procedure} symbol->keyword sym Return a keyword with the same characters as in @var{sym}. @end deffn -@deffn procedure keyword->symbol kw +@deffn {Scheme Procedure} keyword->symbol kw Return a symbol with the same characters as in @var{kw}. @end deffn @@ -2803,16 +2847,19 @@ construct a keyword object programmatically, you can do so by calling (as the reader does). The dash symbol for a keyword object can be retrieved using the @code{keyword-dash-symbol} procedure. -@deffn primitive make-keyword-from-dash-symbol symbol +@deffn {Scheme Procedure} make-keyword-from-dash-symbol symbol +@deffnx {C Function} scm_make_keyword_from_dash_symbol (symbol) Make a keyword object from a @var{symbol} that starts with a dash. @end deffn -@deffn primitive keyword? obj +@deffn {Scheme Procedure} keyword? obj +@deffnx {C Function} scm_keyword_p (obj) Return @code{#t} if the argument @var{obj} is a keyword, else @code{#f}. @end deffn -@deffn primitive keyword-dash-symbol keyword +@deffn {Scheme Procedure} keyword-dash-symbol keyword +@deffnx {C Function} scm_keyword_dash_symbol (keyword) Return the dash symbol for @var{keyword}. This is the inverse of @code{make-keyword-from-dash-symbol}. @end deffn @@ -2867,14 +2914,16 @@ pair, and the pair is returned. The name @code{cons} stands for given Scheme object is a pair or not. @rnindex cons -@deffn primitive cons x y +@deffn {Scheme Procedure} cons x y +@deffnx {C Function} scm_cons (x, y) Return a newly allocated pair whose car is @var{x} and whose cdr is @var{y}. The pair is guaranteed to be different (in the sense of @code{eq?}) from every previously existing object. @end deffn @rnindex pair? -@deffn primitive pair? x +@deffn {Scheme Procedure} pair? x +@deffnx {C Function} scm_pair_p (x) Return @code{#t} if @var{x} is a pair; otherwise return @code{#f}. @end deffn @@ -2889,15 +2938,15 @@ are also predefined. @rnindex car @rnindex cdr -@deffn primitive car pair -@deffnx primitive cdr pair +@deffn {Scheme Procedure} car pair +@deffnx {Scheme Procedure} cdr pair Return the car or the cdr of @var{pair}, respectively. @end deffn -@deffn primitive caar pair -@deffnx primitive cadr pair @dots{} -@deffnx primitive cdddar pair -@deffnx primitive cddddr pair +@deffn {Scheme Procedure} caar pair +@deffnx {Scheme Procedure} cadr pair @dots{} +@deffnx {Scheme Procedure} cdddar pair +@deffnx {Scheme Procedure} cddddr pair These procedures are compositions of @code{car} and @code{cdr}, where for example @code{caddr} could be defined by @@ -2907,13 +2956,15 @@ for example @code{caddr} could be defined by @end deffn @rnindex set-car! -@deffn primitive set-car! pair value +@deffn {Scheme Procedure} set-car! pair value +@deffnx {C Function} scm_set_car_x (pair, value) Stores @var{value} in the car field of @var{pair}. The value returned by @code{set-car!} is unspecified. @end deffn @rnindex set-cdr! -@deffn primitive set-cdr! pair value +@deffn {Scheme Procedure} set-cdr! pair value +@deffnx {C Function} scm_set_cdr_x (pair, value) Stores @var{value} in the cdr field of @var{pair}. The value returned by @code{set-cdr!} is unspecified. @end deffn @@ -3006,7 +3057,8 @@ whether their input is valid, or they could do different things depending on the datatype of their arguments. @rnindex list? -@deffn primitive list? x +@deffn {Scheme Procedure} list? x +@deffnx {C Function} scm_list_p (x) Return @code{#t} iff @var{x} is a proper list, else @code{#f}. @end deffn @@ -3016,7 +3068,8 @@ somehow deals with the elements of a list until the list satisfies @code{null?}. Then, the algorithm terminates. @rnindex null? -@deffn primitive null? x +@deffn {Scheme Procedure} null? x +@deffnx {C Function} scm_null_p (x) Return @code{#t} iff @var{x} is the empty list, else @code{#f}. @end deffn @@ -3029,12 +3082,14 @@ This section describes the procedures for constructing new lists. the last pair of the list. @rnindex list -@deffn primitive list arg1 @dots{} +@deffn {Scheme Procedure} list . objs +@deffnx {C Function} scm_list (objs) Return a list containing @var{objs}, the arguments to @code{list}. @end deffn -@deffn primitive cons* arg1 arg2 @dots{} +@deffn {Scheme Procedure} cons* arg1 arg2 @dots{} +@deffnx {C Function} scm_cons_star (arg1, rest) Like @code{list}, but the last arg provides the tail of the constructed list, returning @code{(cons @var{arg1} (cons @var{arg2} (cons @dots{} @var{argn})))}. Requires at least one @@ -3043,11 +3098,12 @@ result. This function is called @code{list*} in some other Schemes and in Common LISP. @end deffn -@deffn primitive list-copy lst +@deffn {Scheme Procedure} list-copy lst +@deffnx {C Function} scm_list_copy (lst) Return a (newly-created) copy of @var{lst}. @end deffn -@deffn procedure make-list n [init] +@deffn {Scheme Procedure} make-list n [init] Create a list containing of @var{n} elements, where each element is initialized to @var{init}. @var{init} defaults to the empty list @code{()} if not given. @@ -3070,23 +3126,27 @@ These procedures are used to get some information about a list, or to retrieve one or more elements of a list. @rnindex length -@deffn primitive length lst +@deffn {Scheme Procedure} length lst +@deffnx {C Function} scm_length (lst) Return the number of elements in list @var{lst}. @end deffn -@deffn primitive last-pair lst +@deffn {Scheme Procedure} last-pair lst +@deffnx {C Function} scm_last_pair (lst) Return a pointer to the last pair in @var{lst}, signalling an error if @var{lst} is circular. @end deffn @rnindex list-ref -@deffn primitive list-ref list k +@deffn {Scheme Procedure} list-ref list k +@deffnx {C Function} scm_list_ref (list, k) Return the @var{k}th element from @var{list}. @end deffn @rnindex list-tail -@deffn primitive list-tail lst k -@deffnx primitive list-cdr-ref lst k +@deffn {Scheme Procedure} list-tail lst k +@deffnx {Scheme Procedure} list-cdr-ref lst k +@deffnx {C Function} scm_list_tail (lst, k) Return the "tail" of @var{lst} beginning with its @var{k}th element. The first element of the list is considered to be element 0. @@ -3095,7 +3155,8 @@ think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list, or returning the results of cdring @var{k} times down @var{lst}. @end deffn -@deffn primitive list-head lst k +@deffn {Scheme Procedure} list-head lst k +@deffnx {C Function} scm_list_head (lst, k) Copy the first @var{k} elements from @var{lst} into a new list, and return it. @end deffn @@ -3114,7 +3175,8 @@ pairs. This is why you should be careful when using the side-effecting variants. @rnindex append -@deffn primitive append . args +@deffn {Scheme Procedure} append . args +@deffnx {C Function} scm_append (args) Return a list consisting of the elements the lists passed as arguments. @lisp @@ -3132,23 +3194,26 @@ if the last argument is not a proper list. @end lisp @end deffn -@deffn primitive append! . lists +@deffn {Scheme Procedure} append! . lists +@deffnx {C Function} scm_append_x (lists) A destructive version of @code{append} (@pxref{Pairs and -lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field +Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field of each list's final pair is changed to point to the head of the next list, so no consing is performed. Return a pointer to the mutated list. @end deffn @rnindex reverse -@deffn primitive reverse lst +@deffn {Scheme Procedure} reverse lst +@deffnx {C Function} scm_reverse (lst) Return a new list that contains the elements of @var{lst} but in reverse order. @end deffn @c NJFIXME explain new_tail -@deffn primitive reverse! lst [new_tail] -A destructive version of @code{reverse} (@pxref{Pairs and lists,,,r5rs, +@deffn {Scheme Procedure} reverse! lst [new_tail] +@deffnx {C Function} scm_reverse_x (lst, new_tail) +A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is modified to point to the previous list element. Return a pointer to the head of the reversed list. @@ -3167,38 +3232,46 @@ of the modified list is not lost, it is wise to save the return value of The following procedures modify an existing list, either by changing elements of the list, or by changing the list structure itself. -@deffn primitive list-set! list k val +@deffn {Scheme Procedure} list-set! list k val +@deffnx {C Function} scm_list_set_x (list, k, val) Set the @var{k}th element of @var{list} to @var{val}. @end deffn -@deffn primitive list-cdr-set! list k val +@deffn {Scheme Procedure} list-cdr-set! list k val +@deffnx {C Function} scm_list_cdr_set_x (list, k, val) Set the @var{k}th cdr of @var{list} to @var{val}. @end deffn -@deffn primitive delq item lst +@deffn {Scheme Procedure} delq item lst +@deffnx {C Function} scm_delq (item, lst) Return a newly-created copy of @var{lst} with elements @code{eq?} to @var{item} removed. This procedure mirrors @code{memq}: @code{delq} compares elements of @var{lst} against @var{item} with @code{eq?}. @end deffn -@deffn primitive delv item lst +@deffn {Scheme Procedure} delv item lst +@deffnx {C Function} scm_delv (item, lst) Return a newly-created copy of @var{lst} with elements @code{eqv?} to @var{item} removed. This procedure mirrors @code{memv}: @code{delv} compares elements of @var{lst} against @var{item} with @code{eqv?}. @end deffn -@deffn primitive delete item lst +@deffn {Scheme Procedure} delete item lst +@deffnx {C Function} scm_delete (item, lst) Return a newly-created copy of @var{lst} with elements @code{equal?} to @var{item} removed. This procedure mirrors @code{member}: @code{delete} compares elements of @var{lst} against @var{item} with @code{equal?}. @end deffn -@deffn primitive delq! item lst -@deffnx primitive delv! item lst -@deffnx primitive delete! item lst +@deffn {Scheme Procedure} delq! item lst +@deffnx {Scheme Procedure} delv! item lst +@deffnx {Scheme Procedure} delete! item lst +@deffnx {C Function} scm_delq_x (item, lst) +@deffnx {C Function} scm_delv_x (item, lst) +@deffnx {C Function} scm_delete_x (item, lst) These procedures are destructive versions of @code{delq}, @code{delv} and @code{delete}: they modify the pointers in the existing @var{lst} rather than creating a new list. Caveat evaluator: Like other @@ -3207,19 +3280,22 @@ destructive list functions, these functions cannot modify the binding of @var{lst} destructively. @end deffn -@deffn primitive delq1! item lst +@deffn {Scheme Procedure} delq1! item lst +@deffnx {C Function} scm_delq1_x (item, lst) Like @code{delq!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @code{eq?}. See also @code{delv1!} and @code{delete1!}. @end deffn -@deffn primitive delv1! item lst +@deffn {Scheme Procedure} delv1! item lst +@deffnx {C Function} scm_delv1_x (item, lst) Like @code{delv!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @code{eqv?}. See also @code{delq1!} and @code{delete1!}. @end deffn -@deffn primitive delete1! item lst +@deffn {Scheme Procedure} delete1! item lst +@deffnx {C Function} scm_delete1_x (item, lst) Like @code{delete!}, but only deletes the first occurrence of @var{item} from @var{lst}. Tests for equality using @code{equal?}. See also @code{delq1!} and @code{delv1!}. @@ -3237,7 +3313,8 @@ they return the sublist whose car is equal to the search object, where equality depends on the equality predicate used. @rnindex memq -@deffn primitive memq x lst +@deffn {Scheme Procedure} memq x lst +@deffnx {C Function} scm_memq (x, lst) Return the first sublist of @var{lst} whose car is @code{eq?} to @var{x} where the sublists of @var{lst} are the non-empty lists returned by @code{(list-tail @var{lst} @var{k})} for @@ -3247,7 +3324,8 @@ returned. @end deffn @rnindex memv -@deffn primitive memv x lst +@deffn {Scheme Procedure} memv x lst +@deffnx {C Function} scm_memv (x, lst) Return the first sublist of @var{lst} whose car is @code{eqv?} to @var{x} where the sublists of @var{lst} are the non-empty lists returned by @code{(list-tail @var{lst} @var{k})} for @@ -3257,7 +3335,8 @@ returned. @end deffn @rnindex member -@deffn primitive member x lst +@deffn {Scheme Procedure} member x lst +@deffnx {C Function} scm_member (x, lst) Return the first sublist of @var{lst} whose car is @code{equal?} to @var{x} where the sublists of @var{lst} are the non-empty lists returned by @code{(list-tail @var{lst} @@ -3270,19 +3349,19 @@ empty list) is returned. high level at all? Maybe these docs should be relegated to a "Guile Internals" node or something. -twp] -@deffn primitive sloppy-memq x lst +@deffn {Scheme Procedure} sloppy-memq x lst This procedure behaves like @code{memq}, but does no type or error checking. Its use is recommended only in writing Guile internals, not for high-level Scheme programs. @end deffn -@deffn primitive sloppy-memv x lst +@deffn {Scheme Procedure} sloppy-memv x lst This procedure behaves like @code{memv}, but does no type or error checking. Its use is recommended only in writing Guile internals, not for high-level Scheme programs. @end deffn -@deffn primitive sloppy-member x lst +@deffn {Scheme Procedure} sloppy-member x lst This procedure behaves like @code{member}, but does no type or error checking. Its use is recommended only in writing Guile internals, not for high-level Scheme programs. @@ -3302,8 +3381,9 @@ return value. @rnindex map @c begin (texi-doc-string "guile" "map") -@deffn primitive map proc arg1 arg2 @dots{} -@deffnx primitive map-in-order proc arg1 arg2 @dots{} +@deffn {Scheme Procedure} map proc arg1 arg2 @dots{} +@deffnx {Scheme Procedure} map-in-order proc arg1 arg2 @dots{} +@deffnx {C Function} scm_map (proc, arg1, args) Apply @var{proc} to each element of the list @var{arg1} (if only two arguments are given), or to the corresponding elements of the argument lists (if more than two arguments are given). The result(s) of the @@ -3315,7 +3395,7 @@ elements. @rnindex for-each @c begin (texi-doc-string "guile" "for-each") -@deffn primitive for-each proc arg1 arg2 @dots{} +@deffn {Scheme Procedure} for-each proc arg1 arg2 @dots{} Like @code{map}, but the procedure is always applied from left to right, and the result(s) of the procedure applications are thrown away. The return value is not specified. @@ -3362,7 +3442,8 @@ number in hexadecimal notation. @subsection Vector Predicates @rnindex vector? -@deffn primitive vector? obj +@deffn {Scheme Procedure} vector? obj +@deffnx {C Function} scm_vector_p (obj) Return @code{#t} if @var{obj} is a vector, otherwise return @code{#f}. @end deffn @@ -3370,19 +3451,21 @@ Return @code{#t} if @var{obj} is a vector, otherwise return @subsection Vector Constructors @rnindex make-vector -@deffn primitive make-vector k [fill] +@deffn {Scheme Procedure} make-vector k [fill] +@deffnx {C Function} scm_make_vector (k, fill) Return a newly allocated vector of @var{k} elements. If a second argument is given, then each position is initialized to -@var{fill}. Otherwise the initial contents of each position are +@var{fill}. Otherwise the initial contents of each position is unspecified. @end deffn @rnindex vector @rnindex list->vector -@deffn primitive vector . l -@deffnx primitive list->vector l -Return a newly allocated vector composed of the given arguments. -Analogous to @code{list}. +@deffn {Scheme Procedure} vector . l +@deffnx {Scheme Procedure} list->vector l +@deffnx {C Function} scm_vector (l) +Return a newly allocated vector composed of the +given arguments. Analogous to @code{list}. @lisp (vector 'a 'b 'c) @result{} #(a b c) @@ -3390,7 +3473,8 @@ Analogous to @code{list}. @end deffn @rnindex vector->list -@deffn primitive vector->list v +@deffn {Scheme Procedure} vector->list v +@deffnx {C Function} scm_vector_to_list (v) Return a newly allocated list composed of the elements of @var{v}. @lisp @@ -3411,7 +3495,7 @@ considered to be constant, although Guile currently does not detect this error. @rnindex vector-set! -@deffn primitive vector-set! vector k obj +@deffn {Scheme Procedure} vector-set! vector k obj Store @var{obj} in position @var{k} of @var{vector}. @var{k} must be a valid index of @var{vector}. The value returned by @samp{vector-set!} is unspecified. @@ -3423,19 +3507,20 @@ The value returned by @samp{vector-set!} is unspecified. @end deffn @rnindex vector-fill! -@deffn primitive vector-fill! v fill +@deffn {Scheme Procedure} vector-fill! v fill +@deffnx {C Function} scm_vector_fill_x (v, fill) Store @var{fill} in every position of @var{vector}. The value returned by @code{vector-fill!} is unspecified. @end deffn -@deffn primitive vector-move-left! vec1 start1 end1 vec2 start2 -Vector version of @code{substring-move-left!} (@pxref{String -Modification}). +@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2 +@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2) +Vector version of @code{substring-move-left!}. @end deffn -@deffn primitive vector-move-right! vec1 start1 end1 vec2 start2 -Vector version of @code{substring-move-right!} (@pxref{String -Modification}). +@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2 +@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2) +Vector version of @code{substring-move-right!}. @end deffn @subsection Vector Selection @@ -3444,12 +3529,12 @@ These procedures return information about a given vector, such as the size or what elements are contained in the vector. @rnindex vector-length -@deffn primitive vector-length vector +@deffn {Scheme Procedure} vector-length vector Return the number of elements in @var{vector} as an exact integer. @end deffn @rnindex vector-ref -@deffn primitive vector-ref vector k +@deffn {Scheme Procedure} vector-ref vector k Return the contents of position @var{k} of @var{vector}. @var{k} must be a valid index of @var{vector}. @lisp @@ -3469,7 +3554,7 @@ Return the contents of position @var{k} of @var{vector}. A @dfn{record type} is a first class object representing a user-defined data type. A @dfn{record} is an instance of a record type. -@deffn procedure record? obj +@deffn {Scheme Procedure} record? obj Return @code{#t} if @var{obj} is a record of any type and @code{#f} otherwise. @@ -3477,7 +3562,7 @@ Note that @code{record?} may be true of any Scheme value; there is no promise that records are disjoint with other Scheme types. @end deffn -@deffn procedure make-record-type type-name field-names +@deffn {Scheme Procedure} make-record-type type-name field-names Return a @dfn{record-type descriptor}, a value representing a new data type disjoint from all others. The @var{type-name} argument must be a string, but is only used for debugging purposes (such as the printed @@ -3487,7 +3572,7 @@ new type. It is an error if the list contains any duplicates. It is unspecified how record-type descriptors are represented. @end deffn -@deffn procedure record-constructor rtd [field-names] +@deffn {Scheme Procedure} record-constructor rtd [field-names] Return a procedure for constructing new members of the type represented by @var{rtd}. The returned procedure accepts exactly as many arguments as there are symbols in the given list, @var{field-names}; these are @@ -3500,14 +3585,14 @@ if the @var{field-names} argument is provided, it is an error if it contains any duplicates or any symbols not in the default list. @end deffn -@deffn procedure record-predicate rtd +@deffn {Scheme Procedure} record-predicate rtd Return a procedure for testing membership in the type represented by @var{rtd}. The returned procedure accepts exactly one argument and returns a true value if the argument is a member of the indicated record type; it returns a false value otherwise. @end deffn -@deffn procedure record-accessor rtd field-name +@deffn {Scheme Procedure} record-accessor rtd field-name Return a procedure for reading the value of a particular field of a member of the type represented by @var{rtd}. The returned procedure accepts exactly one argument which must be a record of the appropriate @@ -3517,7 +3602,7 @@ member of the list of field-names in the call to @code{make-record-type} that created the type represented by @var{rtd}. @end deffn -@deffn procedure record-modifier rtd field-name +@deffn {Scheme Procedure} record-modifier rtd field-name Return a procedure for writing the value of a particular field of a member of the type represented by @var{rtd}. The returned procedure accepts exactly two arguments: first, a record of the appropriate type, @@ -3529,7 +3614,7 @@ to @code{make-record-type} that created the type represented by @var{rtd}. @end deffn -@deffn procedure record-type-descriptor record +@deffn {Scheme Procedure} record-type-descriptor record Return a record-type descriptor representing the type of the given record. That is, for example, if the returned descriptor were passed to @code{record-predicate}, the resulting predicate would return a true @@ -3539,14 +3624,14 @@ case that the returned descriptor is the one that was passed to procedure that created the given record. @end deffn -@deffn procedure record-type-name rtd +@deffn {Scheme Procedure} record-type-name rtd Return the type-name associated with the type represented by rtd. The returned value is @code{eqv?} to the @var{type-name} argument given in the call to @code{make-record-type} that created the type represented by @var{rtd}. @end deffn -@deffn procedure record-type-fields rtd +@deffn {Scheme Procedure} record-type-fields rtd Return a list of the symbols naming the fields in members of the type represented by @var{rtd}. The returned value is @code{equal?} to the field-names argument given in the call to @code{make-record-type} that @@ -3708,7 +3793,8 @@ Structure layouts are represented by specially interned symbols whose name is a string of type and protection codes. To create a new structure layout, use this procedure: -@deffn primitive make-struct-layout fields +@deffn {Scheme Procedure} make-struct-layout fields +@deffnx {C Function} scm_make_struct_layout (fields) Return a new structure layout object. @var{fields} must be a string made up of pairs of characters @@ -3729,7 +3815,8 @@ indicate that the field is a tail-array. This section describes the basic procedures for creating and accessing structures. -@deffn primitive make-struct vtable tail_array_size . init +@deffn {Scheme Procedure} make-struct vtable tail_array_size . init +@deffnx {C Function} scm_make_struct (vtable, tail_array_size, init) Create a new structure. @var{type} must be a vtable structure (@pxref{Vtables}). @@ -3757,14 +3844,17 @@ more powerful. For more information, see the documentation for @code{make-vtable-vtable}. @end deffn -@deffn primitive struct? x +@deffn {Scheme Procedure} struct? x +@deffnx {C Function} scm_struct_p (x) Return @code{#t} iff @var{x} is a structure object, else @code{#f}. @end deffn -@deffn primitive struct-ref handle pos -@deffnx primitive struct-set! struct n value +@deffn {Scheme Procedure} struct-ref handle pos +@deffnx {Scheme Procedure} struct-set! struct n value +@deffnx {C Function} scm_struct_ref (handle, pos) +@deffnx {C Function} scm_struct_set_x (struct, n, value) Access (or modify) the @var{n}th field of @var{struct}. If the field is of type 'p', then it can be set to an arbitrary value. @@ -3786,11 +3876,13 @@ which are used only internally to libguile. The variable @code{vtable-offset-user} is bound to a field number. Vtable fields at that position or greater are user definable. -@deffn primitive struct-vtable handle +@deffn {Scheme Procedure} struct-vtable handle +@deffnx {C Function} scm_struct_vtable (handle) Return the vtable structure that describes the type of @var{struct}. @end deffn -@deffn primitive struct-vtable? x +@deffn {Scheme Procedure} struct-vtable? x +@deffnx {C Function} scm_struct_vtable_p (x) Return @code{#t} iff @var{x} is a vtable structure. @end deffn @@ -3802,7 +3894,8 @@ created by using @code{(make-struct V' ...)}. Another possibility is that @code{V} is an instance of the type it itself describes. Vtable structures of the second sort are created by this procedure: -@deffn primitive make-vtable-vtable user_fields tail_array_size . init +@deffn {Scheme Procedure} make-vtable-vtable user_fields tail_array_size . init +@deffnx {C Function} scm_make_vtable_vtable (user_fields, tail_array_size, init) Return a new, self-describing vtable structure. @var{user-fields} is a string describing user defined fields of the @@ -3861,15 +3954,18 @@ ball @result{} # @end lisp @end deffn -@deffn primitive struct-vtable-name vtable +@deffn {Scheme Procedure} struct-vtable-name vtable +@deffnx {C Function} scm_struct_vtable_name (vtable) Return the name of the vtable @var{vtable}. @end deffn -@deffn primitive set-struct-vtable-name! vtable name +@deffn {Scheme Procedure} set-struct-vtable-name! vtable name +@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name) Set the name of the vtable @var{vtable} to @var{name}. @end deffn -@deffn primitive struct-vtable-tag handle +@deffn {Scheme Procedure} struct-vtable-tag handle +@deffnx {C Function} scm_struct_vtable_tag (handle) Return the vtable tag of the structure @var{handle}. @end deffn @@ -3928,13 +4024,14 @@ a vector: The following procedures can be used with conventional arrays (or vectors). -@deffn primitive array? v [prot] +@deffn {Scheme Procedure} array? v [prot] +@deffnx {C Function} scm_array_p (v, prot) Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. The @var{prototype} argument is used with uniform arrays and is described elsewhere. @end deffn -@deffn procedure make-array initial-value bound1 bound2 @dots{} +@deffn {Scheme Procedure} make-array initial-value bound1 bound2 @dots{} Create and return an array that has as many dimensions as there are @var{bound}s and fill it with @var{initial-value}. Each @var{bound} may be a positive non-zero integer @var{N}, in which case the index for @@ -3947,25 +4044,29 @@ same number (however, @var{lower} cannot be greater than @var{upper}). @c array-ref's type is `compiled-closure'. There's some weird stuff @c going on in array.c, too. Let's call it a primitive. -twp -@deffn primitive uniform-vector-ref v args -@deffnx primitive array-ref v . args +@deffn {Scheme Procedure} uniform-vector-ref v args +@deffnx {Scheme Procedure} array-ref v . args +@deffnx {C Function} scm_uniform_vector_ref (v, args) Return the element at the @code{(index1, index2)} element in @var{array}. @end deffn -@deffn primitive array-in-bounds? v . args +@deffn {Scheme Procedure} array-in-bounds? v . args +@deffnx {C Function} scm_array_in_bounds_p (v, args) Return @code{#t} if its arguments would be acceptable to @code{array-ref}. @end deffn @c fixme: why do these sigs differ? -ttn 2001/07/19 01:14:12 -@deffn primitive array-set! v obj . args -@deffnx primitive uniform-array-set1! v obj args +@deffn {Scheme Procedure} array-set! v obj . args +@deffnx {Scheme Procedure} uniform-array-set1! v obj args +@deffnx {C Function} scm_array_set_x (v, obj, args) Set the element at the @code{(index1, index2)} element in @var{array} to @var{new-value}. The value returned by array-set! is unspecified. @end deffn -@deffn primitive make-shared-array oldra mapfunc . dims +@deffn {Scheme Procedure} make-shared-array oldra mapfunc . dims +@deffnx {C Function} scm_make_shared_array (oldra, mapfunc, dims) @code{make-shared-array} can be used to create shared subarrays of other arrays. The @var{mapper} is a function that translates coordinates in the new array into coordinates in the old array. A @var{mapper} must be @@ -3983,19 +4084,23 @@ it can be otherwise arbitrary. A simple example: @end lisp @end deffn -@deffn primitive shared-array-increments ra +@deffn {Scheme Procedure} shared-array-increments ra +@deffnx {C Function} scm_shared_array_increments (ra) For each dimension, return the distance between elements in the root vector. @end deffn -@deffn primitive shared-array-offset ra +@deffn {Scheme Procedure} shared-array-offset ra +@deffnx {C Function} scm_shared_array_offset (ra) Return the root vector index of the first element in the array. @end deffn -@deffn primitive shared-array-root ra +@deffn {Scheme Procedure} shared-array-root ra +@deffnx {C Function} scm_shared_array_root (ra) Return the root vector of a shared array. @end deffn -@deffn primitive transpose-array ra . args +@deffn {Scheme Procedure} transpose-array ra . args +@deffnx {C Function} scm_transpose_array (ra, args) Return an array sharing contents with @var{array}, but with dimensions arranged in a different order. There must be one @var{dim} argument for each dimension of @var{array}. @@ -4017,7 +4122,8 @@ have smaller rank than @var{array}. @end lisp @end deffn -@deffn primitive enclose-array ra . axes +@deffn {Scheme Procedure} enclose-array ra . axes +@deffnx {C Function} scm_enclose_array (ra, axes) @var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than the rank of @var{array}. @var{enclose-array} returns an array resembling an array of shared arrays. The dimensions of each shared @@ -4041,14 +4147,15 @@ examples: @end lisp @end deffn -@deffn procedure array-shape array +@deffn {Scheme Procedure} array-shape array Return a list of inclusive bounds of integers. @example (array-shape (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) (0 4)) @end example @end deffn -@deffn primitive array-dimensions ra +@deffn {Scheme Procedure} array-dimensions ra +@deffnx {C Function} scm_array_dimensions (ra) @code{Array-dimensions} is similar to @code{array-shape} but replaces elements with a @code{0} minimum with one greater than the maximum. So: @lisp @@ -4056,31 +4163,35 @@ elements with a @code{0} minimum with one greater than the maximum. So: @end lisp @end deffn -@deffn primitive array-rank ra +@deffn {Scheme Procedure} array-rank ra +@deffnx {C Function} scm_array_rank (ra) Return the number of dimensions of @var{obj}. If @var{obj} is not an array, @code{0} is returned. @end deffn -@deffn primitive array->list v +@deffn {Scheme Procedure} array->list v +@deffnx {C Function} scm_t_arrayo_list (v) Return a list consisting of all the elements, in order, of @var{array}. @end deffn -@deffn primitive array-copy! src dst -@deffnx primitive array-copy-in-order! src dst +@deffn {Scheme Procedure} array-copy! src dst +@deffnx {Scheme Procedure} array-copy-in-order! src dst +@deffnx {C Function} scm_array_copy_x (src, dst) Copy every element from vector or array @var{source} to the corresponding element of @var{destination}. @var{destination} must have the same rank as @var{source}, and be at least as large in each dimension. The order is unspecified. @end deffn -@deffn primitive array-fill! ra fill +@deffn {Scheme Procedure} array-fill! ra fill +@deffnx {C Function} scm_array_fill_x (ra, fill) Store @var{fill} in every element of @var{array}. The value returned is unspecified. @end deffn @c begin (texi-doc-string "guile" "array-equal?") -@deffn primitive array-equal? ra0 ra1 +@deffn {Scheme Procedure} array-equal? ra0 ra1 Return @code{#t} iff all arguments are arrays with the same shape, the same type, and have corresponding elements which are either @code{equal?} or @code{array-equal?}. This function differs from @@ -4088,8 +4199,8 @@ same type, and have corresponding elements which are either @var{array-equal?} but not @var{equal?} to a vector or uniform vector. @end deffn -@deffn primitive array-contents ra [strict] -@deffnx primitive array-contents array strict +@deffn {Scheme Procedure} array-contents array [strict] +@deffnx {C Function} scm_array_contents (array, strict) If @var{array} may be @dfn{unrolled} into a one dimensional shared array without changing their order (last subscript changing fastest), then @code{array-contents} returns that shared array, otherwise it returns @@ -4105,8 +4216,9 @@ memory. @node Array Mapping @subsection Array Mapping -@deffn primitive array-map! ra0 proc . lra -@deffnx primitive array-map-in-order! ra0 proc . lra +@deffn {Scheme Procedure} array-map! ra0 proc . lra +@deffnx {Scheme Procedure} array-map-in-order! ra0 proc . lra +@deffnx {C Function} scm_array_map_x (ra0, proc, lra) @var{array1}, @dots{} must have the same number of dimensions as @var{array0} and have a range for each index which includes the range for the corresponding index in @var{array0}. @var{proc} is applied to @@ -4115,12 +4227,14 @@ as the corresponding element in @var{array0}. The value returned is unspecified. The order of application is unspecified. @end deffn -@deffn primitive array-for-each proc ra0 . lra +@deffn {Scheme Procedure} array-for-each proc ra0 . lra +@deffnx {C Function} scm_array_for_each (proc, ra0, lra) Apply @var{proc} to each tuple of elements of @var{array0} @dots{} in row-major order. The value returned is unspecified. @end deffn -@deffn primitive array-index-map! ra proc +@deffn {Scheme Procedure} array-index-map! ra proc +@deffnx {C Function} scm_array_index_map_x (ra, proc) Apply @var{proc} to the indices of each element of @var{array} in turn, storing the result in the corresponding element. The value returned and the order of application are unspecified. @@ -4198,44 +4312,48 @@ except that a single character from the above table is put between @code{#} and @code{(}. For example, a uniform vector of signed long integers is displayed in the form @code{'#e(3 5 9)}. -@deffn primitive array? v [prot] +@deffn {Scheme Procedure} array? v [prot] Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. The @var{prototype} argument is used with uniform arrays and is described elsewhere. @end deffn -@deffn procedure make-uniform-array prototype bound1 bound2 @dots{} +@deffn {Scheme Procedure} make-uniform-array prototype bound1 bound2 @dots{} Create and return a uniform array of type corresponding to @var{prototype} that has as many dimensions as there are @var{bound}s and fill it with @var{prototype}. @end deffn -@deffn primitive array-prototype ra +@deffn {Scheme Procedure} array-prototype ra +@deffnx {C Function} scm_array_prototype (ra) Return an object that would produce an array of the same type as @var{array}, if used as the @var{prototype} for @code{make-uniform-array}. @end deffn -@deffn primitive list->uniform-array ndim prot lst -@deffnx procedure list->uniform-vector prot lst +@deffn {Scheme Procedure} list->uniform-array ndim prot lst +@deffnx {Scheme Procedure} list->uniform-vector prot lst +@deffnx {C Function} scm_list_to_uniform_array (ndim, prot, lst) Return a uniform array of the type indicated by prototype @var{prot} with elements the same as those of @var{lst}. Elements must be of the appropriate type, no coercions are done. @end deffn -@deffn primitive uniform-vector-fill! uve fill +@deffn {Scheme Procedure} uniform-vector-fill! uve fill Store @var{fill} in every element of @var{uve}. The value returned is unspecified. @end deffn -@deffn primitive uniform-vector-length v +@deffn {Scheme Procedure} uniform-vector-length v +@deffnx {C Function} scm_uniform_vector_length (v) Return the number of elements in @var{uve}. @end deffn -@deffn primitive dimensions->uniform-array dims prot [fill] -@deffnx primitive make-uniform-vector length prototype [fill] +@deffn {Scheme Procedure} dimensions->uniform-array dims prot [fill] +@deffnx {Scheme Procedure} make-uniform-vector length prototype [fill] +@deffnx {C Function} scm_dimensions_to_uniform_array (dims, prot, fill) Create and return a uniform array or vector of type corresponding to @var{prototype} with dimensions @var{dims} or length @var{length}. If @var{fill} is supplied, it's used to @@ -4244,12 +4362,13 @@ fill the array, otherwise @var{prototype} is used. @c Another compiled-closure. -twp -@deffn primitive uniform-array-read! ra [port_or_fd [start [end]]] -@deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end] +@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]] +@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end] +@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end) Attempt to read all elements of @var{ura}, in lexicographic order, as binary objects from @var{port-or-fdes}. -If an end of file is encountered during -uniform-array-read! the objects up to that point only are put into @var{ura} +If an end of file is encountered, +the objects up to that point are put into @var{ura} (starting at the beginning) and the remainder of the array is unchanged. @@ -4262,8 +4381,9 @@ leaving the remainder of the vector unchanged. returned by @code{(current-input-port)}. @end deffn -@deffn primitive uniform-array-write v [port_or_fd [start [end]]] -@deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end] +@deffn {Scheme Procedure} uniform-array-write v [port_or_fd [start [end]]] +@deffnx {Scheme Procedure} uniform-vector-write uve [port-or-fdes] [start] [end] +@deffnx {C Function} scm_uniform_array_write (v, port_or_fd, start, end) Writes all elements of @var{ura} as binary objects to @var{port-or-fdes}. @@ -4296,22 +4416,26 @@ They are displayed as a sequence of @code{0}s and #*101 @end example -@deffn primitive bit-count b bitvector +@deffn {Scheme Procedure} bit-count b bitvector +@deffnx {C Function} scm_bit_count (b, bitvector) Return the number of occurrences of the boolean @var{b} in @var{bitvector}. @end deffn -@deffn primitive bit-position item v k +@deffn {Scheme Procedure} bit-position item v k +@deffnx {C Function} scm_bit_position (item, v, k) Return the minimum index of an occurrence of @var{bool} in @var{bv} which is at least @var{k}. If no @var{bool} occurs within the specified range @code{#f} is returned. @end deffn -@deffn primitive bit-invert! v +@deffn {Scheme Procedure} bit-invert! v +@deffnx {C Function} scm_bit_invert_x (v) Modify @var{bv} by replacing each element with its negation. @end deffn -@deffn primitive bit-set*! v kv obj +@deffn {Scheme Procedure} bit-set*! v kv obj +@deffnx {C Function} scm_bit_set_star_x (v, kv, obj) If uve is a bit-vector @var{bv} and uve must be of the same length. If @var{bool} is @code{#t}, uve is OR'ed into @var{bv}; If @var{bool} is @code{#f}, the inversion of uve is @@ -4323,7 +4447,8 @@ of @var{bv} corresponding to the indexes in uve are set to @var{bool}. The return value is unspecified. @end deffn -@deffn primitive bit-count* v kv obj +@deffn {Scheme Procedure} bit-count* v kv obj +@deffnx {C Function} scm_bit_count_star (v, kv, obj) Return @lisp (bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t). @@ -4552,16 +4677,20 @@ independent from the list that results from modification by use @code{list-copy} to copy the old association list before modifying it. -@deffn primitive acons key value alist +@deffn {Scheme Procedure} acons key value alist +@deffnx {C Function} scm_acons (key, value, alist) Add a new key-value pair to @var{alist}. A new pair is created whose car is @var{key} and whose cdr is @var{value}, and the pair is consed onto @var{alist}, and the new list is returned. This function is @emph{not} destructive; @var{alist} is not modified. @end deffn -@deffn primitive assq-set! alist key val -@deffnx primitive assv-set! alist key value -@deffnx primitive assoc-set! alist key value +@deffn {Scheme Procedure} assq-set! alist key val +@deffnx {Scheme Procedure} assv-set! alist key value +@deffnx {Scheme Procedure} assoc-set! alist key value +@deffnx {C Function} scm_assq_set_x (alist, key, val) +@deffnx {C Function} scm_assv_set_x (alist, key, val) +@deffnx {C Function} scm_assoc_set_x (alist, key, val) Reassociate @var{key} in @var{alist} with @var{value}: find any existing @var{alist} entry for @var{key} and associate it with the new @var{value}. If @var{alist} does not contain an entry for @var{key}, @@ -4584,9 +4713,12 @@ arguments and return the entry for that key if an entry exists, or where an entry exists, these procedures return the complete entry, that is @code{(KEY . VALUE)}, not just the value. -@deffn primitive assq key alist -@deffnx primitive assv key alist -@deffnx primitive assoc key alist +@deffn {Scheme Procedure} assq key alist +@deffnx {Scheme Procedure} assv key alist +@deffnx {Scheme Procedure} assoc key alist +@deffnx {C Function} scm_assq (key, alist) +@deffnx {C Function} scm_assv (key, alist) +@deffnx {C Function} scm_assoc (key, alist) Fetch the entry in @var{alist} that is associated with @var{key}. To decide whether the argument @var{key} matches a particular entry in @var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv} @@ -4608,9 +4740,12 @@ Consequently, @code{assq-ref} and friends should only be used where it is known that an entry exists, or where the ambiguity doesn't matter for some other reason. -@deffn primitive assq-ref alist key -@deffnx primitive assv-ref alist key -@deffnx primitive assoc-ref alist key +@deffn {Scheme Procedure} assq-ref alist key +@deffnx {Scheme Procedure} assv-ref alist key +@deffnx {Scheme Procedure} assoc-ref alist key +@deffnx {C Function} scm_assq_ref (alist, key) +@deffnx {C Function} scm_assv_ref (alist, key) +@deffnx {C Function} scm_assoc_ref (alist, key) Like @code{assq}, @code{assv} and @code{assoc}, except that only the value associated with @var{key} in @var{alist} is returned. These functions are equivalent to @@ -4681,9 +4816,12 @@ two distinct entries to @code{address-list}. When compared using after removing the first matching entry that it finds, and so one of the "mary" entries is left in place. -@deffn primitive assq-remove! alist key -@deffnx primitive assv-remove! alist key -@deffnx primitive assoc-remove! alist key +@deffn {Scheme Procedure} assq-remove! alist key +@deffnx {Scheme Procedure} assv-remove! alist key +@deffnx {Scheme Procedure} assoc-remove! alist key +@deffnx {C Function} scm_assq_remove_x (alist, key) +@deffnx {C Function} scm_assv_remove_x (alist, key) +@deffnx {C Function} scm_assoc_remove_x (alist, key) Delete the first entry in @var{alist} associated with @var{key}, and return the resulting alist. @end deffn @@ -4733,17 +4871,20 @@ it is much safer to use the non-@code{sloppy-} procedures, because they help to highlight coding and data errors that the @code{sloppy-} versions would silently cover up. -@deffn primitive sloppy-assq key alist +@deffn {Scheme Procedure} sloppy-assq key alist +@deffnx {C Function} scm_sloppy_assq (key, alist) Behaves like @code{assq} but does not do any error checking. Recommended only for use in Guile internals. @end deffn -@deffn primitive sloppy-assv key alist +@deffn {Scheme Procedure} sloppy-assv key alist +@deffnx {C Function} scm_sloppy_assv (key, alist) Behaves like @code{assv} but does not do any error checking. Recommended only for use in Guile internals. @end deffn -@deffn primitive sloppy-assoc key alist +@deffn {Scheme Procedure} sloppy-assoc key alist +@deffnx {C Function} scm_sloppy_assoc (key, alist) Behaves like @code{assoc} but does not do any error checking. Recommended only for use in Guile internals. @end deffn @@ -4895,7 +5036,7 @@ In each of the functions that follow, the @var{table} argument must be a vector. The @var{key} and @var{value} arguments may be any Scheme object. -@deffn procedure make-hash-table size +@deffn {Scheme Procedure} make-hash-table size Create a new hash table of @var{size} slots. Note that the number of slots does not limit the size of the table, it just tells how large the underlying vector will be. The @var{size} should be similar to @@ -4904,54 +5045,63 @@ they need not match. For good performance, it might be a good idea to use a prime number as the @var{size}. @end deffn -@deffn primitive hashq-ref table key [dflt] +@deffn {Scheme Procedure} hashq-ref table key [dflt] +@deffnx {C Function} scm_hashq_ref (table, key, dflt) Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, return @var{default} (or @code{#f} if no @var{default} argument is supplied). Uses @code{eq?} for equality testing. @end deffn -@deffn primitive hashv-ref table key [dflt] +@deffn {Scheme Procedure} hashv-ref table key [dflt] +@deffnx {C Function} scm_hashv_ref (table, key, dflt) Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, return @var{default} (or @code{#f} if no @var{default} argument is supplied). Uses @code{eqv?} for equality testing. @end deffn -@deffn primitive hash-ref table key [dflt] +@deffn {Scheme Procedure} hash-ref table key [dflt] +@deffnx {C Function} scm_hash_ref (table, key, dflt) Look up @var{key} in the hash table @var{table}, and return the value (if any) associated with it. If @var{key} is not found, return @var{default} (or @code{#f} if no @var{default} argument is supplied). Uses @code{equal?} for equality testing. @end deffn -@deffn primitive hashq-set! table key val +@deffn {Scheme Procedure} hashq-set! table key val +@deffnx {C Function} scm_hashq_set_x (table, key, val) Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{eq?} for equality testing. @end deffn -@deffn primitive hashv-set! table key val +@deffn {Scheme Procedure} hashv-set! table key val +@deffnx {C Function} scm_hashv_set_x (table, key, val) Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{eqv?} for equality testing. @end deffn -@deffn primitive hash-set! table key val +@deffn {Scheme Procedure} hash-set! table key val +@deffnx {C Function} scm_hash_set_x (table, key, val) Find the entry in @var{table} associated with @var{key}, and store @var{value} there. Uses @code{equal?} for equality testing. @end deffn -@deffn primitive hashq-remove! table key +@deffn {Scheme Procedure} hashq-remove! table key +@deffnx {C Function} scm_hashq_remove_x (table, key) Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{eq?} for equality tests. @end deffn -@deffn primitive hashv-remove! table key +@deffn {Scheme Procedure} hashv-remove! table key +@deffnx {C Function} scm_hashv_remove_x (table, key) Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{eqv?} for equality tests. @end deffn -@deffn primitive hash-remove! table key +@deffn {Scheme Procedure} hash-remove! table key +@deffnx {C Function} scm_hash_remove_x (table, key) Remove @var{key} (and any value associated with it) from @var{table}. Uses @code{equal?} for equality tests. @end deffn @@ -4971,7 +5121,8 @@ use comfortably. If you are interested in learning more, see an introductory textbook on data structures or algorithms for an explanation of how hash tables are implemented. -@deffn primitive hashq key size +@deffn {Scheme Procedure} hashq key size +@deffnx {C Function} scm_hashq (key, size) Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eq?} is used as the equality predicate. The function returns an @@ -4984,7 +5135,8 @@ in between. This can happen, for example with symbols: different values, since @code{foo} will be garbage collected. @end deffn -@deffn primitive hashv key size +@deffn {Scheme Procedure} hashv key size +@deffnx {C Function} scm_hashv (key, size) Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{eqv?} is used as the equality predicate. The function returns an @@ -4997,14 +5149,16 @@ in between. This can happen, for example with symbols: different values, since @code{foo} will be garbage collected. @end deffn -@deffn primitive hash key size +@deffn {Scheme Procedure} hash key size +@deffnx {C Function} scm_hash (key, size) Determine a hash value for @var{key} that is suitable for lookups in a hashtable of size @var{size}, where @code{equal?} is used as the equality predicate. The function returns an integer in the range 0 to @var{size} - 1. @end deffn -@deffn primitive hashx-ref hash assoc table key [dflt] +@deffn {Scheme Procedure} hashx-ref hash assoc table key [dflt] +@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt) This behaves the same way as the corresponding @code{ref} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be a function @@ -5016,7 +5170,8 @@ By way of illustration, @code{hashq-ref table key} is equivalent to @code{hashx-ref hashq assq table key}. @end deffn -@deffn primitive hashx-set! hash assoc table key val +@deffn {Scheme Procedure} hashx-set! hash assoc table key val +@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val) This behaves the same way as the corresponding @code{set!} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be a function @@ -5028,28 +5183,32 @@ that takes two arguments, a key to be hashed and a table size. equivalent to @code{hashx-set! hashq assq table key}. @end deffn -@deffn primitive hashq-get-handle table key +@deffn {Scheme Procedure} hashq-get-handle table key +@deffnx {C Function} scm_hashq_get_handle (table, key) This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an associated value for @var{key}, @code{#f} is returned. Uses @code{eq?} for equality testing. @end deffn -@deffn primitive hashv-get-handle table key +@deffn {Scheme Procedure} hashv-get-handle table key +@deffnx {C Function} scm_hashv_get_handle (table, key) This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an associated value for @var{key}, @code{#f} is returned. Uses @code{eqv?} for equality testing. @end deffn -@deffn primitive hash-get-handle table key +@deffn {Scheme Procedure} hash-get-handle table key +@deffnx {C Function} scm_hash_get_handle (table, key) This procedure returns the @code{(key . value)} pair from the hash table @var{table}. If @var{table} does not hold an associated value for @var{key}, @code{#f} is returned. Uses @code{equal?} for equality testing. @end deffn -@deffn primitive hashx-get-handle hash assoc table key +@deffn {Scheme Procedure} hashx-get-handle hash assoc table key +@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key) This behaves the same way as the corresponding @code{-get-handle} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be @@ -5058,25 +5217,29 @@ table size. @code{assoc} must be an associator function, like @code{assoc}, @code{assq} or @code{assv}. @end deffn -@deffn primitive hashq-create-handle! table key init +@deffn {Scheme Procedure} hashq-create-handle! table key init +@deffnx {C Function} scm_hashq_create_handle_x (table, key, init) This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which associates @var{key} with @var{init}. @end deffn -@deffn primitive hashv-create-handle! table key init +@deffn {Scheme Procedure} hashv-create-handle! table key init +@deffnx {C Function} scm_hashv_create_handle_x (table, key, init) This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which associates @var{key} with @var{init}. @end deffn -@deffn primitive hash-create-handle! table key init +@deffn {Scheme Procedure} hash-create-handle! table key init +@deffnx {C Function} scm_hash_create_handle_x (table, key, init) This function looks up @var{key} in @var{table} and returns its handle. If @var{key} is not already present, a new handle is created which associates @var{key} with @var{init}. @end deffn -@deffn primitive hashx-create-handle! hash assoc table key init +@deffn {Scheme Procedure} hashx-create-handle! hash assoc table key init +@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init) This behaves the same way as the corresponding @code{-create-handle} function, but uses @var{hash} as a hash function and @var{assoc} to compare keys. @code{hash} must be @@ -5085,7 +5248,8 @@ table size. @code{assoc} must be an associator function, like @code{assoc}, @code{assq} or @code{assv}. @end deffn -@deffn primitive hash-fold proc init table +@deffn {Scheme Procedure} hash-fold proc init table +@deffnx {C Function} scm_hash_fold (proc, init, table) An iterator over hash-table elements. Accumulates and returns a result by applying PROC successively. The arguments to PROC are "(key value prior-result)" where key @@ -5188,45 +5352,53 @@ are always called from first to last when they are invoked via When calling @code{hook->list}, the procedures in the resulting list are in the same order as they would have been called by @code{run-hook}. -@deffn primitive make-hook [n_args] +@deffn {Scheme Procedure} make-hook [n_args] +@deffnx {C Function} scm_make_hook (n_args) Create a hook for storing procedure of arity @var{n_args}. @var{n_args} defaults to zero. The returned value is a hook object to be used with the other hook procedures. @end deffn -@deffn primitive hook? x +@deffn {Scheme Procedure} hook? x +@deffnx {C Function} scm_hook_p (x) Return @code{#t} if @var{x} is a hook, @code{#f} otherwise. @end deffn -@deffn primitive hook-empty? hook +@deffn {Scheme Procedure} hook-empty? hook +@deffnx {C Function} scm_hook_empty_p (hook) Return @code{#t} if @var{hook} is an empty hook, @code{#f} otherwise. @end deffn -@deffn primitive add-hook! hook proc [append_p] +@deffn {Scheme Procedure} add-hook! hook proc [append_p] +@deffnx {C Function} scm_add_hook_x (hook, proc, append_p) Add the procedure @var{proc} to the hook @var{hook}. The procedure is added to the end if @var{append_p} is true, otherwise it is added to the front. The return value of this procedure is not specified. @end deffn -@deffn primitive remove-hook! hook proc +@deffn {Scheme Procedure} remove-hook! hook proc +@deffnx {C Function} scm_remove_hook_x (hook, proc) Remove the procedure @var{proc} from the hook @var{hook}. The return value of this procedure is not specified. @end deffn -@deffn primitive reset-hook! hook +@deffn {Scheme Procedure} reset-hook! hook +@deffnx {C Function} scm_reset_hook_x (hook) Remove all procedures from the hook @var{hook}. The return value of this procedure is not specified. @end deffn -@deffn primitive run-hook hook . args +@deffn {Scheme Procedure} run-hook hook . args +@deffnx {C Function} scm_run_hook (hook, args) Apply all procedures from the hook @var{hook} to the arguments @var{args}. The order of the procedure application is first to last. The return value of this procedure is not specified. @end deffn -@deffn primitive hook->list hook +@deffn {Scheme Procedure} hook->list hook +@deffnx {C Function} scm_hook_to_list (hook) Convert the procedure list of @var{hook} to a list. @end deffn diff --git a/doc/ref/scheme-debug.texi b/doc/ref/scheme-debug.texi index 170d7e382..c6a92130e 100644 --- a/doc/ref/scheme-debug.texi +++ b/doc/ref/scheme-debug.texi @@ -6,7 +6,8 @@ from the appendix describing the debugger UI. The intro should have a pointer to the UI appendix. -@deffn primitive display-error stack port subr message args rest +@deffn {Scheme Procedure} display-error stack port subr message args rest +@deffnx {C Function} scm_display_error (stack, port, subr, message, args, rest) Display an error message to the output port @var{port}. @var{stack} is the saved stack for the error, @var{subr} is the name of the procedure in which the error occured and @@ -16,13 +17,15 @@ the list @var{args} accordingly. @var{rest} is currently ignored. @end deffn -@deffn primitive display-application frame [port [indent]] +@deffn {Scheme Procedure} display-application frame [port [indent]] +@deffnx {C Function} scm_display_application (frame, port, indent) Display a procedure application @var{frame} to the output port @var{port}. @var{indent} specifies the indentation of the output. @end deffn -@deffn primitive display-backtrace stack port [first [depth]] +@deffn {Scheme Procedure} display-backtrace stack port [first [depth]] +@deffnx {C Function} scm_display_backtrace (stack, port, first, depth) Display a backtrace to the output port @var{port}. @var{stack} is the stack to take the backtrace from, @var{first} specifies where in the stack to start and @var{depth} how much frames @@ -30,12 +33,13 @@ to display. Both @var{first} and @var{depth} can be @code{#f}, which means that default values will be used. @end deffn -@deffn primitive backtrace +@deffn {Scheme Procedure} backtrace +@deffnx {C Function} scm_backtrace () Display a backtrace of the stack saved by the last error to the current output port. @end deffn -@deffn primitive malloc-stats +@deffn {Scheme Procedure} malloc-stats Return an alist ((@var{what} . @var{n}) ...) describing number of malloced objects. @var{what} is the second argument to @code{scm_must_malloc}, @@ -43,98 +47,120 @@ of malloced objects. allocated. @end deffn -@deffn primitive debug-options-interface [setting] +@deffn {Scheme Procedure} debug-options-interface [setting] +@deffnx {C Function} scm_debug_options (setting) Option interface for the debug options. Instead of using this procedure directly, use the procedures @code{debug-enable}, @code{debug-disable}, @code{debug-set!} and @var{debug-options}. @end deffn -@deffn primitive with-traps thunk +@deffn {Scheme Procedure} with-traps thunk +@deffnx {C Function} scm_with_traps (thunk) Call @var{thunk} with traps enabled. @end deffn -@deffn primitive memoized? obj +@deffn {Scheme Procedure} memoized? obj +@deffnx {C Function} scm_memoized_p (obj) Return @code{#t} if @var{obj} is memoized. @end deffn -@deffn primitive unmemoize m +@deffn {Scheme Procedure} unmemoize m +@deffnx {C Function} scm_unmemoize (m) Unmemoize the memoized expression @var{m}, @end deffn -@deffn primitive memoized-environment m +@deffn {Scheme Procedure} memoized-environment m +@deffnx {C Function} scm_memoized_environment (m) Return the environment of the memoized expression @var{m}. @end deffn -@deffn primitive procedure-name proc +@deffn {Scheme Procedure} procedure-name proc +@deffnx {C Function} scm_procedure_name (proc) Return the name of the procedure @var{proc} @end deffn -@deffn primitive procedure-source proc +@deffn {Scheme Procedure} procedure-source proc +@deffnx {C Function} scm_procedure_source (proc) Return the source of the procedure @var{proc}. @end deffn -@deffn primitive procedure-environment proc +@deffn {Scheme Procedure} procedure-environment proc +@deffnx {C Function} scm_procedure_environment (proc) Return the environment of the procedure @var{proc}. @end deffn -@deffn primitive debug-object? obj +@deffn {Scheme Procedure} debug-object? obj +@deffnx {C Function} scm_debug_object_p (obj) Return @code{#t} if @var{obj} is a debug object. @end deffn -@deffn primitive frame-arguments frame +@deffn {Scheme Procedure} frame-arguments frame +@deffnx {C Function} scm_frame_arguments (frame) Return the arguments of @var{frame}. @end deffn -@deffn primitive frame-evaluating-args? frame +@deffn {Scheme Procedure} frame-evaluating-args? frame +@deffnx {C Function} scm_frame_evaluating_args_p (frame) Return @code{#t} if @var{frame} contains evaluated arguments. @end deffn -@deffn primitive frame-next frame +@deffn {Scheme Procedure} frame-next frame +@deffnx {C Function} scm_frame_next (frame) Return the next frame of @var{frame}, or @code{#f} if @var{frame} is the last frame in its stack. @end deffn -@deffn primitive frame-number frame +@deffn {Scheme Procedure} frame-number frame +@deffnx {C Function} scm_frame_number (frame) Return the frame number of @var{frame}. @end deffn -@deffn primitive frame-overflow? frame +@deffn {Scheme Procedure} frame-overflow? frame +@deffnx {C Function} scm_frame_overflow_p (frame) Return @code{#t} if @var{frame} is an overflow frame. @end deffn -@deffn primitive frame-previous frame +@deffn {Scheme Procedure} frame-previous frame +@deffnx {C Function} scm_frame_previous (frame) Return the previous frame of @var{frame}, or @code{#f} if @var{frame} is the first frame in its stack. @end deffn -@deffn primitive frame-procedure frame +@deffn {Scheme Procedure} frame-procedure frame +@deffnx {C Function} scm_frame_procedure (frame) Return the procedure for @var{frame}, or @code{#f} if no procedure is associated with @var{frame}. @end deffn -@deffn primitive frame-procedure? frame +@deffn {Scheme Procedure} frame-procedure? frame +@deffnx {C Function} scm_frame_procedure_p (frame) Return @code{#t} if a procedure is associated with @var{frame}. @end deffn -@deffn primitive frame-real? frame +@deffn {Scheme Procedure} frame-real? frame +@deffnx {C Function} scm_frame_real_p (frame) Return @code{#t} if @var{frame} is a real frame. @end deffn -@deffn primitive frame-source frame +@deffn {Scheme Procedure} frame-source frame +@deffnx {C Function} scm_frame_source (frame) Return the source of @var{frame}. @end deffn -@deffn primitive frame? obj +@deffn {Scheme Procedure} frame? obj +@deffnx {C Function} scm_frame_p (obj) Return @code{#t} if @var{obj} is a stack frame. @end deffn -@deffn primitive last-stack-frame obj +@deffn {Scheme Procedure} last-stack-frame obj +@deffnx {C Function} scm_last_stack_frame (obj) Return a stack which consists of a single frame, which is the last stack frame for @var{obj}. @var{obj} must be either a debug object or a continuation. @end deffn -@deffn primitive make-stack obj . args +@deffn {Scheme Procedure} make-stack obj . args +@deffnx {C Function} scm_make_stack (obj, args) Create a new stack. If @var{obj} is @code{#t}, the current evaluation stack is used for creating the stack frames, otherwise the frames are taken from @var{obj} (which must be @@ -165,19 +191,23 @@ If the @var{outer_cut_N} of the last pair is missing, it is taken as 0. @end deffn -@deffn primitive stack-id stack +@deffn {Scheme Procedure} stack-id stack +@deffnx {C Function} scm_stack_id (stack) Return the identifier given to @var{stack} by @code{start-stack}. @end deffn -@deffn primitive stack-length stack +@deffn {Scheme Procedure} stack-length stack +@deffnx {C Function} scm_stack_length (stack) Return the length of @var{stack}. @end deffn -@deffn primitive stack-ref stack index +@deffn {Scheme Procedure} stack-ref stack index +@deffnx {C Function} scm_stack_ref (stack, index) Return the @var{index}'th frame from @var{stack}. @end deffn -@deffn primitive stack? obj +@deffn {Scheme Procedure} stack? obj +@deffnx {C Function} scm_stack_p (obj) Return @code{#t} if @var{obj} is a calling stack. @end deffn diff --git a/doc/ref/scheme-evaluation.texi b/doc/ref/scheme-evaluation.texi index 094214a76..d9854fe6d 100644 --- a/doc/ref/scheme-evaluation.texi +++ b/doc/ref/scheme-evaluation.texi @@ -122,7 +122,8 @@ to use uppercase letters in their identifiers anyway. @node Reader Extensions @subsection Reader Extensions -@deffn primitive read-hash-extend chr proc +@deffn {Scheme Procedure} read-hash-extend chr proc +@deffnx {C Function} scm_read_hash_extend (chr, proc) Install the procedure @var{proc} for reading expressions starting with the character sequence @code{#} and @var{chr}. @var{proc} will be called with two arguments: the character @@ -135,7 +136,8 @@ returned will be the return value of @code{read}. @section Reading Scheme Code @rnindex read -@deffn primitive read [port] +@deffn {Scheme Procedure} read [port] +@deffnx {C Function} scm_read (port) Read an s-expression from the input port @var{port}, or from the current input port if @var{port} is not specified. Any whitespace before the next token is discarded. @@ -149,7 +151,7 @@ available, @xref{Reader options}. @c FIXME::martin: This is taken from libguile/options.c. Is there @c actually a difference between 'help and 'full? -@deffn procedure read-options [setting] +@deffn {Scheme Procedure} read-options [setting] Display the current settings of the read options. If @var{setting} is omitted, only a short form of the current read options is printed. Otherwise, @var{setting} should be one of the following symbols: @@ -161,18 +163,19 @@ Like @code{help}, but also print programmer options. @end table @end deffn -@deffn procedure read-enable option-name -@deffnx procedure read-disable option-name -@deffnx procedure read-set! option-name value +@deffn {Scheme Procedure} read-enable option-name +@deffnx {Scheme Procedure} read-disable option-name +@deffnx {Scheme Procedure} read-set! option-name value Modify the read options. @code{read-enable} should be used with boolean options and switches them on, @code{read-disable} switches them off. @code{read-set!} can be used to set an option to a specific value. @end deffn -@deffn primitive read-options-interface [setting] +@deffn {Scheme Procedure} read-options-interface [setting] +@deffnx {C Function} scm_read_options (setting) Option interface for the read options. Instead of using this procedure directly, use the procedures @code{read-enable}, -@code{read-disable}, @code{read-set!} and @code{read-options}. +@code{read-disable}, @code{read-set!} and @var{read-options}. @end deffn @@ -181,13 +184,18 @@ this procedure directly, use the procedures @code{read-enable}, @rnindex eval @c ARGFIXME environment/environment specifier -@deffn primitive eval exp environment -Evaluate @var{exp}, a list representing a Scheme expression, in the -environment given by @var{environment specifier}. +@deffn {Scheme Procedure} eval exp module +@deffnx {C Function} scm_eval (exp, module) +Evaluate @var{exp}, a list representing a Scheme expression, +in the top-level environment specified by @var{module}. +While @var{exp} is evaluated (using @code{primitive-eval}), +@var{module} is made the current module. The current module +is reset to its previous value when @var{eval} returns. @end deffn @rnindex interaction-environment -@deffn primitive interaction-environment +@deffn {Scheme Procedure} interaction-environment +@deffnx {C Function} scm_interaction_environment () Return a specifier for the environment that contains implementation--defined bindings, typically a superset of those listed in the report. The intent is that this procedure will @@ -195,14 +203,16 @@ return the environment in which the implementation would evaluate expressions dynamically typed by the user. @end deffn -@deffn primitive eval-string string +@deffn {Scheme Procedure} eval-string string +@deffnx {C Function} scm_eval_string (string) Evaluate @var{string} as the text representation of a Scheme form or forms, and return whatever value they produce. Evaluation takes place in the environment returned by the procedure @code{interaction-environment}. @end deffn -@deffn primitive apply:nconc2last lst +@deffn {Scheme Procedure} apply:nconc2last lst +@deffnx {C Function} scm_nconc2last (lst) Given a list (@var{arg1} @dots{} @var{args}), this function conses the @var{arg1} @dots{} arguments onto the front of @var{args}, and returns the resulting list. Note that @@ -213,13 +223,14 @@ destroys its argument, so use with care. @end deffn @rnindex apply -@deffn primitive apply proc arg1 @dots{} args +@deffn {Scheme Procedure} apply proc arg1 @dots{} args @var{proc} must be a procedure and @var{args} must be a list. Call @var{proc} with the elements of the list @code{(append (list @var{arg1} @dots{}) @var{args})} as the actual arguments. @end deffn -@deffn primitive primitive-eval exp +@deffn {Scheme Procedure} primitive-eval exp +@deffnx {C Function} scm_primitive_eval (exp) Evaluate @var{exp} in the top-level environment specified by the current module. @end deffn @@ -229,7 +240,7 @@ the current module. @section Loading Scheme Code from File @rnindex load -@deffn procedure load filename +@deffn {Scheme Procedure} load filename Load @var{filename} and evaluate its contents in the top-level environment. The load paths are not searched. If the variable @code{%load-hook} is defined, it should be bound to a procedure that @@ -237,12 +248,13 @@ will be called before any code is loaded. See documentation for @code{%load-hook} later in this section. @end deffn -@deffn procedure load-from-path filename +@deffn {Scheme Procedure} load-from-path filename Similar to @code{load}, but searches for @var{filename} in the load paths. @end deffn -@deffn primitive primitive-load filename +@deffn {Scheme Procedure} primitive-load filename +@deffnx {C Function} scm_primitive_load (filename) Load the file named @var{filename} and evaluate its contents in the top-level environment. The load paths are not searched; @var{filename} must either be a full pathname or be a pathname @@ -252,14 +264,16 @@ that will be called before any code is loaded. See the documentation for @code{%load-hook} later in this section. @end deffn -@deffn primitive primitive-load-path filename +@deffn {Scheme Procedure} primitive-load-path filename +@deffnx {C Function} scm_primitive_load_path (filename) Search @var{%load-path} for the file named @var{filename} and load it into the top-level environment. If @var{filename} is a relative pathname and is not found in the list of search paths, an error is signalled. @end deffn -@deffn primitive %search-load-path filename +@deffn {Scheme Procedure} %search-load-path filename +@deffnx {C Function} scm_sys_search_load_path (filename) Search @var{%load-path} for the file named @var{filename}, which must be readable by the current user. If @var{filename} is found in the list of paths to search or is an absolute @@ -285,7 +299,8 @@ was passed to @code{primitive-load}. @end defvar -@deffn primitive current-load-port +@deffn {Scheme Procedure} current-load-port +@deffnx {C Function} scm_current_load_port () Return the current-load-port. The load port is used internally by @code{primitive-load}. @end deffn @@ -303,13 +318,15 @@ list @code{("" ".scm")}. [delay] -@deffn primitive promise? obj +@deffn {Scheme Procedure} promise? obj +@deffnx {C Function} scm_promise_p (obj) Return true if @var{obj} is a promise, i.e. a delayed computation (@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). @end deffn @rnindex force -@deffn primitive force x +@deffn {Scheme Procedure} force x +@deffnx {C Function} scm_force (x) If the promise @var{x} has not been computed yet, compute and return @var{x}, otherwise just return the previously computed value. @@ -321,7 +338,8 @@ value. [the-environment] -@deffn primitive local-eval exp [env] +@deffn {Scheme Procedure} local-eval exp [env] +@deffnx {C Function} scm_local_eval (exp, env) Evaluate @var{exp} in its environment. If @var{env} is supplied, it is the environment in which to evaluate @var{exp}. Otherwise, @var{exp} must be a memoized code object (in which case, its environment @@ -343,7 +361,7 @@ available, @xref{Evaluator options}. @c FIXME::martin: This is taken from libguile/options.c. Is there @c actually a difference between 'help and 'full? -@deffn procedure eval-options [setting] +@deffn {Scheme Procedure} eval-options [setting] Display the current settings of the evaluator options. If @var{setting} is omitted, only a short form of the current evaluator options is printed. Otherwise, @var{setting} should be one of the following @@ -356,24 +374,25 @@ Like @code{help}, but also print programmer options. @end table @end deffn -@deffn procedure eval-enable option-name -@deffnx procedure eval-disable option-name -@deffnx procedure eval-set! option-name value +@deffn {Scheme Procedure} eval-enable option-name +@deffnx {Scheme Procedure} eval-disable option-name +@deffnx {Scheme Procedure} eval-set! option-name value Modify the evaluator options. @code{eval-enable} should be used with boolean options and switches them on, @code{eval-disable} switches them off. @code{eval-set!} can be used to set an option to a specific value. @end deffn -@deffn primitive eval-options-interface [setting] +@deffn {Scheme Procedure} eval-options-interface [setting] +@deffnx {C Function} scm_eval_options_interface (setting) Option interface for the evaluation options. Instead of using this procedure directly, use the procedures @code{eval-enable}, -@code{eval-disable}, @code{eval-set!} and @code{eval-options}. +@code{eval-disable}, @code{eval-set!} and @var{eval-options}. @end deffn @c FIXME::martin: Why aren't these procedure named like the other options @c procedures? -@deffn procedure traps [setting] +@deffn {Scheme Procedure} traps [setting] Display the current settings of the evaluator traps options. If @var{setting} is omitted, only a short form of the current evaluator traps options is printed. Otherwise, @var{setting} should be one of the @@ -386,15 +405,16 @@ Like @code{help}, but also print programmer options. @end table @end deffn -@deffn procedure trap-enable option-name -@deffnx procedure trap-disable option-name -@deffnx procedure trap-set! option-name value +@deffn {Scheme Procedure} trap-enable option-name +@deffnx {Scheme Procedure} trap-disable option-name +@deffnx {Scheme Procedure} trap-set! option-name value Modify the evaluator options. @code{trap-enable} should be used with boolean options and switches them on, @code{trap-disable} switches them off. @code{trap-set!} can be used to set an option to a specific value. @end deffn -@deffn primitive evaluator-traps-interface [setting] +@deffn {Scheme Procedure} evaluator-traps-interface [setting] +@deffnx {C Function} scm_evaluator_traps (setting) Option interface for the evaluator trap options. @end deffn diff --git a/doc/ref/scheme-io.texi b/doc/ref/scheme-io.texi index a121823a5..2ea12174d 100644 --- a/doc/ref/scheme-io.texi +++ b/doc/ref/scheme-io.texi @@ -34,20 +34,23 @@ that simulate ports in software. @dfn{Soft ports} and @dfn{string ports} are two interesting and powerful examples of this technique. @rnindex input-port? -@deffn primitive input-port? x +@deffn {Scheme Procedure} input-port? x +@deffnx {C Function} scm_input_port_p (x) Return @code{#t} if @var{x} is an input port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @code{port?}. @end deffn @rnindex output-port? -@deffn primitive output-port? x +@deffn {Scheme Procedure} output-port? x +@deffnx {C Function} scm_output_port_p (x) Return @code{#t} if @var{x} is an output port, otherwise return @code{#f}. Any object satisfying this predicate also satisfies @code{port?}. @end deffn -@deffn primitive port? x +@deffn {Scheme Procedure} port? x +@deffnx {C Function} scm_port_p (x) Return a boolean indicating whether @var{x} is a port. Equivalent to @code{(or (input-port? @var{x}) (output-port? @var{x}))}. @@ -60,13 +63,15 @@ Equivalent to @code{(or (input-port? @var{x}) (output-port? [Generic procedures for reading from ports.] @rnindex eof-object? -@deffn primitive eof-object? x +@deffn {Scheme Procedure} eof-object? x +@deffnx {C Function} scm_eof_object_p (x) Return @code{#t} if @var{x} is an end-of-file object; otherwise return @code{#f}. @end deffn @rnindex char-ready? -@deffn primitive char-ready? [port] +@deffn {Scheme Procedure} char-ready? [port] +@deffnx {C Function} scm_char_ready_p (port) Return @code{#t} if a character is ready on input @var{port} and return @code{#f} otherwise. If @code{char-ready?} returns @code{#t} then the next @code{read-char} operation on @@ -83,14 +88,16 @@ interactive port that has no ready characters.} @end deffn @rnindex read-char? -@deffn primitive read-char [port] +@deffn {Scheme Procedure} read-char [port] +@deffnx {C Function} scm_read_char (port) Return the next character available from @var{port}, updating @var{port} to point to the following character. If no more characters are available, the end-of-file object is returned. @end deffn @rnindex peek-char? -@deffn primitive peek-char [port] +@deffn {Scheme Procedure} peek-char [port] +@deffnx {C Function} scm_peek_char (port) Return the next character available from @var{port}, @emph{without} updating @var{port} to point to the following character. If no more characters are available, the @@ -105,21 +112,24 @@ an interactive port will hang waiting for input whenever a call to @code{read-char} would have hung.} @end deffn -@deffn primitive unread-char cobj port +@deffn {Scheme Procedure} unread-char cobj [port] +@deffnx {C Function} scm_unread_char (cobj, port) Place @var{char} in @var{port} so that it will be read by the next read operation. If called multiple times, the unread characters will be read again in last-in first-out order. If @var{port} is not supplied, the current input port is used. @end deffn -@deffn primitive unread-string str port +@deffn {Scheme Procedure} unread-string str port +@deffnx {C Function} scm_unread_string (str, port) Place the string @var{str} in @var{port} so that its characters will be read in subsequent read operations. If called multiple times, the unread characters will be read again in last-in first-out order. If @var{port} is not supplied, the current-input-port is used. @end deffn -@deffn primitive drain-input port +@deffn {Scheme Procedure} drain-input port +@deffnx {C Function} scm_drain_input (port) This procedure clears a port's input buffers, similar to the way that force-output clears the output buffer. The contents of the buffers are returned as a single string, e.g., @@ -136,8 +146,10 @@ buffered I/O so that the file descriptor can be used directly for further input. @end deffn -@deffn primitive port-column port -@deffnx primitive port-line port +@deffn {Scheme Procedure} port-column port +@deffnx {Scheme Procedure} port-line port +@deffnx {C Function} scm_port_column (port) +@deffnx {C Function} scm_port_line (port) Return the current column number or line number of @var{port}, using the current input port if none is specified. If the number is unknown, the result is #f. Otherwise, the result is a 0-origin integer @@ -148,8 +160,10 @@ because lines and column numbers traditionally start with 1, and that is what non-programmers will find most natural.) @end deffn -@deffn primitive set-port-column! port column -@deffnx primitive set-port-line! port line +@deffn {Scheme Procedure} set-port-column! port column +@deffnx {Scheme Procedure} set-port-line! port line +@deffnx {C Function} scm_set_port_column_x (port, column) +@deffnx {C Function} scm_set_port_line_x (port, line) Set the current column or line number of @var{port}, using the current input port if none is specified. @end deffn @@ -159,13 +173,14 @@ current input port if none is specified. [Generic procedures for writing to ports.] -@deffn primitive get-print-state port +@deffn {Scheme Procedure} get-print-state port +@deffnx {C Function} scm_get_print_state (port) Return the print state of the port @var{port}. If @var{port} has no associated print state, @code{#f} is returned. @end deffn @rnindex display -@deffn primitive display obj [port] +@deffn {Scheme Procedure} display obj [port] Send a representation of @var{obj} to @var{current-output-port}. Optional second arg @var{port} specifies an alternative output port. The representation is similar to that produced by @code{write} (REFFIXME), @@ -174,23 +189,28 @@ escaped), and characters are rendered as if with @code{write-char}. @end deffn @rnindex newline -@deffn primitive newline [port] -Send a newline to @var{port} (default @var{current-output-port} if omitted). +@deffn {Scheme Procedure} newline [port] +@deffnx {C Function} scm_newline (port) +Send a newline to @var{port}. +If @var{port} is omitted, send to the current output port. @end deffn -@deffn primitive port-with-print-state port pstate +@deffn {Scheme Procedure} port-with-print-state port pstate +@deffnx {C Function} scm_port_with_print_state (port, pstate) Create a new port which behaves like @var{port}, but with an included print state @var{pstate}. @end deffn -@deffn primitive print-options-interface [setting] +@deffn {Scheme Procedure} print-options-interface [setting] +@deffnx {C Function} scm_print_options (setting) Option interface for the print options. Instead of using this procedure directly, use the procedures @code{print-enable}, @code{print-disable}, @code{print-set!} and @code{print-options}. @end deffn -@deffn primitive simple-format destination message . args +@deffn {Scheme Procedure} simple-format destination message . args +@deffnx {C Function} scm_simple_format (destination, message, args) Write @var{message} to @var{destination}, defaulting to the current output port. @var{message} can contain @code{~A} (was @code{%s}) and @@ -205,12 +225,14 @@ containing the formatted text. Does not add a trailing newline. @end deffn @rnindex write-char -@deffn primitive write-char chr [port] +@deffn {Scheme Procedure} write-char chr [port] +@deffnx {C Function} scm_write_char (chr, port) Send character @var{chr} to @var{port}. @end deffn @findex fflush -@deffn primitive force-output [port] +@deffn {Scheme Procedure} force-output [port] +@deffnx {C Function} scm_force_output (port) Flush the specified output port, or the current output port if @var{port} is omitted. The current output buffer contents are passed to the underlying port implementation (e.g., in the case of fports, the @@ -220,7 +242,8 @@ It has no effect on an unbuffered port. The return value is unspecified. @end deffn -@deffn primitive flush-all-ports +@deffn {Scheme Procedure} flush-all-ports +@deffnx {C Function} scm_flush_all_ports () Equivalent to calling @code{force-output} on all open output ports. The return value is unspecified. @end deffn @@ -229,7 +252,8 @@ all open output ports. The return value is unspecified. @node Closing @section Closing -@deffn primitive close-port port +@deffn {Scheme Procedure} close-port port +@deffnx {C Function} scm_close_port (port) Close the specified port object. Return @code{#t} if it successfully closes a port or @code{#f} if it was already closed. An exception may be raised if an error occurs, for @@ -239,7 +263,8 @@ descriptors. @end deffn @rnindex close-input-port -@deffn primitive close-input-port port +@deffn {Scheme Procedure} close-input-port port +@deffnx {C Function} scm_close_input_port (port) Close the specified input port object. The routine has no effect if the file has already been closed. An exception may be raised if an error occurs. The value returned is unspecified. @@ -249,7 +274,8 @@ which can close file descriptors. @end deffn @rnindex close-output-port -@deffn primitive close-output-port port +@deffn {Scheme Procedure} close-output-port port +@deffnx {C Function} scm_close_output_port (port) Close the specified output port object. The routine has no effect if the file has already been closed. An exception may be raised if an error occurs. The value returned is unspecified. @@ -258,7 +284,8 @@ See also @ref{Ports and File Descriptors, close}, for a procedure which can close file descriptors. @end deffn -@deffn primitive port-closed? port +@deffn {Scheme Procedure} port-closed? port +@deffnx {C Function} scm_port_closed_p (port) Return @code{#t} if @var{port} is closed or @code{#f} if it is open. @end deffn @@ -267,7 +294,8 @@ open. @node Random Access @section Random Access -@deffn primitive seek fd_port offset whence +@deffn {Scheme Procedure} seek fd_port offset whence +@deffnx {C Function} scm_seek (fd_port, offset, whence) Sets the current position of @var{fd/port} to the integer @var{offset}, which is interpreted according to the value of @var{whence}. @@ -293,7 +321,8 @@ that the current position of a port can be obtained using: @end lisp @end deffn -@deffn primitive ftell fd_port +@deffn {Scheme Procedure} ftell fd_port +@deffnx {C Function} scm_ftell (fd_port) Return an integer representing the current position of @var{fd/port}, measured from the beginning. Equivalent to: @@ -304,7 +333,8 @@ Return an integer representing the current position of @findex truncate @findex ftruncate -@deffn primitive truncate-file object [length] +@deffn {Scheme Procedure} truncate-file object [length] +@deffnx {C Function} scm_truncate_file (object, length) Truncates the object referred to by @var{object} to at most @var{length} bytes. @var{object} can be a string containing a file name or an integer file descriptor or a port. @@ -328,7 +358,7 @@ module from guile-scsh, but does not use multiple values or character sets and has an extra procedure @code{write-line}. @c begin (scm-doc-string "rdelim.scm" "read-line") -@deffn procedure read-line [port] [handle-delim] +@deffn {Scheme Procedure} read-line [port] [handle-delim] Return a line of text from @var{port} if specified, otherwise from the value returned by @code{(current-input-port)}. Under Unix, a line of text is terminated by the first end-of-line character or by end-of-file. @@ -351,7 +381,7 @@ terminating delimiter or end-of-file object. @end deffn @c begin (scm-doc-string "rdelim.scm" "read-line!") -@deffn procedure read-line! buf [port] +@deffn {Scheme Procedure} read-line! buf [port] Read a line of text into the supplied string @var{buf} and return the number of characters added to @var{buf}. If @var{buf} is filled, then @code{#f} is returned. @@ -360,7 +390,7 @@ specified, otherwise from the value returned by @code{(current-input-port)}. @end deffn @c begin (scm-doc-string "rdelim.scm" "read-delimited") -@deffn procedure read-delimited delims [port] [handle-delim] +@deffn {Scheme Procedure} read-delimited delims [port] [handle-delim] Read text until one of the characters in the string @var{delims} is found or end-of-file is reached. Read from @var{port} if supplied, otherwise from the value returned by @code{(current-input-port)}. @@ -368,7 +398,7 @@ from the value returned by @code{(current-input-port)}. @end deffn @c begin (scm-doc-string "rdelim.scm" "read-delimited!") -@deffn procedure read-delimited! delims buf [port] [handle-delim] [start] [end] +@deffn {Scheme Procedure} read-delimited! delims buf [port] [handle-delim] [start] [end] Read text into the supplied string @var{buf} and return the number of characters added to @var{buf} (subject to @var{handle-delim}, which takes the same values specified for @code{read-line}. If @var{buf} is filled, @@ -379,7 +409,8 @@ or end-of-file is reached. Read from @var{port} if supplied, otherwise from the value returned by @code{(current-input-port)}. @end deffn -@deffn primitive write-line obj [port] +@deffn {Scheme Procedure} write-line obj [port] +@deffnx {C Function} scm_write_line (obj, port) Display @var{obj} and a newline character to @var{port}. If @var{port} is not specified, @code{(current-output-port)} is used. This function is equivalent to: @@ -393,7 +424,8 @@ Some of the abovementioned I/O functions rely on the following C primitives. These will mainly be of interest to people hacking Guile internals. -@deffn primitive %read-delimited! delims str gobble [port [start [end]]] +@deffn {Scheme Procedure} %read-delimited! delims str gobble [port [start [end]]] +@deffnx {C Function} scm_read_delimited_x (delims, str, gobble, port, start, end) Read characters from @var{port} into @var{str} until one of the characters in the @var{delims} string is encountered. If @var{gobble} is true, discard the delimiter character; @@ -411,7 +443,8 @@ at the end of file, the delimiter returned is the a delimiter, this value is @code{#f}. @end deffn -@deffn primitive %read-line [port] +@deffn {Scheme Procedure} %read-line [port] +@deffnx {C Function} scm_read_line (port) Read a newline-terminated line from @var{port}, allocating storage as necessary. The newline terminator (if any) is removed from the string, and a pair consisting of the line and its delimiter is returned. The @@ -432,7 +465,8 @@ The Block-string-I/O module can be accessed with: It currently contains procedures that help to implement the @code{(scsh rw)} module in guile-scsh. -@deffn primitive read-string!/partial str [port_or_fdes [start [end]]] +@deffn {Scheme Procedure} read-string!/partial str [port_or_fdes [start [end]]] +@deffnx {C Function} scm_read_string_x_partial (str, port_or_fdes, start, end) Read characters from a port or file descriptor into a string @var{str}. A port must have an underlying file descriptor --- a so-called fport. This procedure is @@ -472,7 +506,8 @@ end-of-file check. @end itemize @end deffn -@deffn primitive write-string/partial str [port_or_fdes start end] +@deffn {Scheme Procedure} write-string/partial str [port_or_fdes [start [end]]] +@deffnx {C Function} scm_write_string_partial (str, port_or_fdes, start, end) Write characters from a string @var{str} to a port or file descriptor. A port must have an underlying file descriptor --- a so-called fport. This procedure is @@ -520,38 +555,44 @@ return 0 immediately if the request size is 0 bytes. @section Default Ports for Input, Output and Errors @rnindex current-input-port -@deffn primitive current-input-port +@deffn {Scheme Procedure} current-input-port +@deffnx {C Function} scm_current_input_port () Return the current input port. This is the default port used by many input procedures. Initially, @code{current-input-port} returns the @dfn{standard input} in Unix and C terminology. @end deffn @rnindex current-output-port -@deffn primitive current-output-port +@deffn {Scheme Procedure} current-output-port +@deffnx {C Function} scm_current_output_port () Return the current output port. This is the default port used by many output procedures. Initially, @code{current-output-port} returns the @dfn{standard output} in Unix and C terminology. @end deffn -@deffn primitive current-error-port +@deffn {Scheme Procedure} current-error-port +@deffnx {C Function} scm_current_error_port () Return the port to which errors and warnings should be sent (the @dfn{standard error} in Unix and C terminology). @end deffn -@deffn primitive set-current-input-port port -@deffnx primitive set-current-output-port port -@deffnx primitive set-current-error-port port +@deffn {Scheme Procedure} set-current-input-port port +@deffnx {Scheme Procedure} set-current-output-port port +@deffnx {Scheme Procedure} set-current-error-port port +@deffnx {C Function} scm_set_current_input_port (port) +@deffnx {C Function} scm_set_current_output_port (port) +@deffnx {C Function} scm_set_current_error_port (port) Change the ports returned by @code{current-input-port}, @code{current-output-port} and @code{current-error-port}, respectively, so that they use the supplied @var{port} for input or output. @end deffn -@deffn primitive set-current-output-port port +@deffn {Scheme Procedure} set-current-output-port port Set the current default output port to PORT. @end deffn -@deffn primitive set-current-error-port port +@deffn {Scheme Procedure} set-current-error-port port Set the current default error port to PORT. @end deffn @@ -576,7 +617,8 @@ The following procedures are used to open file ports. See also @ref{Ports and File Descriptors, open}, for an interface to the Unix @code{open} system call. -@deffn primitive open-file filename mode +@deffn {Scheme Procedure} open-file filename mode +@deffnx {C Function} scm_open_file (filename, mode) Open the file whose name is @var{filename}, and return a port representing that file. The attributes of the port are determined by the @var{mode} string. The way in which this is @@ -617,7 +659,7 @@ requested, @code{open-file} throws an exception. @end deffn @rnindex open-input-file -@deffn procedure open-input-file filename +@deffn {Scheme Procedure} open-input-file filename Open @var{filename} for input. Equivalent to @smalllisp (open-file @var{filename} "r") @@ -625,7 +667,7 @@ Open @var{filename} for input. Equivalent to @end deffn @rnindex open-output-file -@deffn procedure open-output-file filename +@deffn {Scheme Procedure} open-output-file filename Open @var{filename} for output. Equivalent to @smalllisp (open-file @var{filename} "w") @@ -633,7 +675,7 @@ Open @var{filename} for output. Equivalent to @end deffn @rnindex call-with-input-file -@deffn procedure call-with-input-file file proc +@deffn {Scheme Procedure} call-with-input-file file proc @var{proc} should be a procedure of one argument, and @var{file} should be a string naming a file. The file must already exist. These procedures call @var{proc} with one argument: the port obtained by @@ -646,7 +688,7 @@ never again be used for a read or write operation. @end deffn @rnindex call-with-output-file -@deffn procedure call-with-output-file file proc +@deffn {Scheme Procedure} call-with-output-file file proc @var{proc} should be a procedure of one argument, and @var{file} should be a string naming a file. The behaviour is unspecified if the file already exists. These procedures call @var{proc} with one argument: the @@ -659,7 +701,7 @@ port will never again be used for a read or write operation. @end deffn @rnindex with-input-from-file -@deffn procedure with-input-from-file file thunk +@deffn {Scheme Procedure} with-input-from-file file thunk @var{thunk} must be a procedure of no arguments, and @var{file} must be a string naming a file. The file must already exist. The file is opened for input, an input port connected to it is made the default value @@ -672,7 +714,7 @@ dependent. @end deffn @rnindex with-output-to-file -@deffn procedure with-output-to-file file thunk +@deffn {Scheme Procedure} with-output-to-file file thunk @var{thunk} must be a procedure of no arguments, and @var{file} must be a string naming a file. The effect is unspecified if the file already exists. The file is opened for output, an output port connected to it @@ -684,7 +726,7 @@ used to escape from the continuation of these procedures, their behavior is implementation dependent. @end deffn -@deffn procedure with-error-to-file file thunk +@deffn {Scheme Procedure} with-error-to-file file thunk @var{thunk} must be a procedure of no arguments, and @var{file} must be a string naming a file. The effect is unspecified if the file already exists. The file is opened for output, an output port connected to it @@ -696,27 +738,31 @@ from the continuation of these procedures, their behavior is implementation dependent. @end deffn -@deffn primitive port-mode port -Returns the port modes associated with the open port @var{port}. These -will not necessarily be identical to the modes used when the port was -opened, since modes such as "append" which are used only during -port creation are not retained. +@deffn {Scheme Procedure} port-mode port +@deffnx {C Function} scm_port_mode (port) +Return the port modes associated with the open port @var{port}. +These will not necessarily be identical to the modes used when +the port was opened, since modes such as "append" which are +used only during port creation are not retained. @end deffn -@deffn primitive port-filename port +@deffn {Scheme Procedure} port-filename port +@deffnx {C Function} scm_port_filename (port) Return the filename associated with @var{port}. This function returns the strings "standard input", "standard output" and "standard error" when called on the current input, output and error ports respectively. @end deffn -@deffn primitive set-port-filename! port filename +@deffn {Scheme Procedure} set-port-filename! port filename +@deffnx {C Function} scm_set_port_filename_x (port, filename) Change the filename associated with @var{port}, using the current input port if none is specified. Note that this does not change the port's source of data, but only the value that is returned by @code{port-filename} and reported in diagnostic output. @end deffn -@deffn primitive file-port? obj +@deffn {Scheme Procedure} file-port? obj +@deffnx {C Function} scm_file_port_p (obj) Determine whether @var{obj} is a port that is related to a file. @end deffn @@ -727,38 +773,42 @@ Determine whether @var{obj} is a port that is related to a file. The following allow string ports to be opened by analogy to R4R* file port facilities: -@deffn primitive call-with-output-string proc +@deffn {Scheme Procedure} call-with-output-string proc +@deffnx {C Function} scm_call_with_output_string (proc) Calls the one-argument procedure @var{proc} with a newly created output port. When the function returns, the string composed of the characters written into the port is returned. @end deffn -@deffn primitive call-with-input-string string proc +@deffn {Scheme Procedure} call-with-input-string string proc +@deffnx {C Function} scm_call_with_input_string (string, proc) Calls the one-argument procedure @var{proc} with a newly created input port from which @var{string}'s contents may be read. The value yielded by the @var{proc} is returned. @end deffn -@deffn procedure with-output-to-string thunk +@deffn {Scheme Procedure} with-output-to-string thunk Calls the zero-argument procedure @var{thunk} with the current output port set temporarily to a new string port. It returns a string composed of the characters written to the current output. @end deffn -@deffn procedure with-input-from-string string thunk +@deffn {Scheme Procedure} with-input-from-string string thunk Calls the zero-argument procedure @var{thunk} with the current input port set temporarily to a string port opened on the specified @var{string}. The value yielded by @var{thunk} is returned. @end deffn -@deffn primitive open-input-string str +@deffn {Scheme Procedure} open-input-string str +@deffnx {C Function} scm_open_input_string (str) Take a string and return an input port that delivers characters from the string. The port can be closed by @code{close-input-port}, though its storage will be reclaimed by the garbage collector if it becomes inaccessible. @end deffn -@deffn primitive open-output-string +@deffn {Scheme Procedure} open-output-string +@deffnx {C Function} scm_open_output_string () Return an output port that will accumulate characters for retrieval by @code{get-output-string}. The port can be closed by the procedure @code{close-output-port}, though its storage @@ -766,7 +816,8 @@ will be reclaimed by the garbage collector if it becomes inaccessible. @end deffn -@deffn primitive get-output-string port +@deffn {Scheme Procedure} get-output-string port +@deffnx {C Function} scm_get_output_string (port) Given an output port created by @code{open-output-string}, return a string consisting of the characters that have been output to the port so far. @@ -784,7 +835,8 @@ but trying to extract the file descriptor number will fail. A @dfn{soft-port} is a port based on a vector of procedures capable of accepting or delivering characters. It allows emulation of I/O ports. -@deffn primitive make-soft-port pv modes +@deffn {Scheme Procedure} make-soft-port pv modes +@deffnx {C Function} scm_make_soft_port (pv, modes) Return a port capable of receiving or delivering characters as specified by the @var{modes} string (@pxref{File Ports, open-file}). @var{pv} must be a vector of length 5. Its @@ -835,11 +887,12 @@ For example: This kind of port causes any data to be discarded when written to, and always returns the end-of-file object when read from. -@deffn primitive %make-void-port mode +@deffn {Scheme Procedure} %make-void-port mode +@deffnx {C Function} scm_sys_make_void_port (mode) Create and return a new void port. A void port acts like -@code{/dev/null}. The @var{mode} argument specifies the input/output -modes for this port: see the documentation for @code{open-file} in -@ref{File Ports}. +/dev/null. The @var{mode} argument +specifies the input/output modes for this port: see the +documentation for @code{open-file} in @ref{File Ports}. @end deffn diff --git a/doc/ref/scheme-memory.texi b/doc/ref/scheme-memory.texi index e29fd8607..ee418dbba 100644 --- a/doc/ref/scheme-memory.texi +++ b/doc/ref/scheme-memory.texi @@ -15,26 +15,24 @@ [FIXME: this is pasted in from Tom Lord's original guile.texi and should be reviewed] -@deffn primitive gc +@deffn {Scheme Procedure} gc +@deffnx {C Function} scm_gc () Scans all of SCM objects and reclaims for further use those that are no longer accessible. @end deffn -@deffn primitive gc-stats +@deffn {Scheme Procedure} gc-stats +@deffnx {C Function} scm_gc_stats () Return an association list of statistics about Guile's current use of storage. @end deffn -@deffn primitive object-address obj +@deffn {Scheme Procedure} object-address obj +@deffnx {C Function} scm_object_address (obj) Return an integer that for the lifetime of @var{obj} is uniquely returned by this function for @var{obj} @end deffn -@deffn primitive unhash-name name -Flushes the glocs for @var{name}, or all glocs if @var{name} -is @code{#t}. -@end deffn - @node Weak References @section Weak References @@ -84,9 +82,12 @@ they constitute a doubly-weak table has to be used. @node Weak key hashes @subsection Weak key hashes -@deffn primitive make-weak-key-hash-table size -@deffnx primitive make-weak-value-hash-table size -@deffnx primitive make-doubly-weak-hash-table size +@deffn {Scheme Procedure} make-weak-key-hash-table size +@deffnx {Scheme Procedure} make-weak-value-hash-table size +@deffnx {Scheme Procedure} make-doubly-weak-hash-table size +@deffnx {C Function} scm_make_weak_key_hash_table (size) +@deffnx {C Function} scm_make_weak_value_hash_table (size) +@deffnx {C Function} scm_make_doubly_weak_hash_table (size) Return a weak hash table with @var{size} buckets. As with any hash table, choosing a good size for the table requires some caution. @@ -95,24 +96,27 @@ You can modify weak hash tables in exactly the same way you would modify regular hash tables. (@pxref{Hash Tables}) @end deffn -@deffn primitive weak-key-hash-table? obj -@deffnx primitive weak-value-hash-table? obj -@deffnx primitive doubly-weak-hash-table? obj +@deffn {Scheme Procedure} weak-key-hash-table? obj +@deffnx {Scheme Procedure} weak-value-hash-table? obj +@deffnx {Scheme Procedure} doubly-weak-hash-table? obj +@deffnx {C Function} scm_weak_key_hash_table_p (obj) +@deffnx {C Function} scm_weak_value_hash_table_p (obj) +@deffnx {C Function} scm_doubly_weak_hash_table_p (obj) Return @code{#t} if @var{obj} is the specified weak hash table. Note that a doubly weak hash table is neither a weak key nor a weak value hash table. @end deffn -@deffn primitive make-weak-value-hash-table k +@deffn {Scheme Procedure} make-weak-value-hash-table k @end deffn -@deffn primitive weak-value-hash-table? x +@deffn {Scheme Procedure} weak-value-hash-table? x @end deffn -@deffn primitive make-doubly-weak-hash-table k +@deffn {Scheme Procedure} make-doubly-weak-hash-table k @end deffn -@deffn primitive doubly-weak-hash-table? x +@deffn {Scheme Procedure} doubly-weak-hash-table? x @end deffn @@ -122,22 +126,25 @@ nor a weak value hash table. Weak vectors are mainly useful in Guile's implementation of weak hash tables. -@deffn primitive make-weak-vector size [fill] +@deffn {Scheme Procedure} make-weak-vector size [fill] +@deffnx {C Function} scm_make_weak_vector (size, fill) Return a weak vector with @var{size} elements. If the optional argument @var{fill} is given, all entries in the vector will be set to @var{fill}. The default value for @var{fill} is the empty list. @end deffn -@deffn primitive weak-vector . l -@deffnx primitive list->weak-vector l +@deffn {Scheme Procedure} weak-vector . l +@deffnx {Scheme Procedure} list->weak-vector l +@deffnx {C Function} scm_weak_vector (l) Construct a weak vector from a list: @code{weak-vector} uses the list of its arguments while @code{list->weak-vector} uses its only argument @var{l} (a list) to construct a weak vector the same way @code{list->vector} would. @end deffn -@deffn primitive weak-vector? obj +@deffn {Scheme Procedure} weak-vector? obj +@deffnx {C Function} scm_weak_vector_p (obj) Return @code{#t} if @var{obj} is a weak vector. Note that all weak hashes are also weak vectors. @end deffn @@ -146,7 +153,8 @@ weak hashes are also weak vectors. @node Guardians @section Guardians -@deffn primitive make-guardian [greedy?] +@deffn {Scheme Procedure} make-guardian [greedy?] +@deffnx {C Function} scm_make_guardian (greedy_p) Create a new guardian. A guardian protects a set of objects from garbage collection, allowing a program to apply cleanup or other actions. @@ -174,17 +182,20 @@ and Implementation, June 1993. paper still (mostly) accurately describes the interface). @end deffn -@deffn primitive destroy-guardian! guardian +@deffn {Scheme Procedure} destroy-guardian! guardian +@deffnx {C Function} scm_destroy_guardian_x (guardian) Destroys @var{guardian}, by making it impossible to put any more objects in it or get any objects from it. It also unguards any objects guarded by @var{guardian}. @end deffn -@deffn primitive guardian-greedy? guardian +@deffn {Scheme Procedure} guardian-greedy? guardian +@deffnx {C Function} scm_guardian_greedy_p (guardian) Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}. @end deffn -@deffn primitive guardian-destroyed? guardian +@deffn {Scheme Procedure} guardian-destroyed? guardian +@deffnx {C Function} scm_guardian_destroyed_p (guardian) Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}. @end deffn @@ -193,25 +204,30 @@ Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}. @node Objects @chapter Objects -@deffn primitive entity? obj +@deffn {Scheme Procedure} entity? obj +@deffnx {C Function} scm_entity_p (obj) Return @code{#t} if @var{obj} is an entity. @end deffn -@deffn primitive operator? obj +@deffn {Scheme Procedure} operator? obj +@deffnx {C Function} scm_operator_p (obj) Return @code{#t} if @var{obj} is an operator. @end deffn -@deffn primitive set-object-procedure! obj proc +@deffn {Scheme Procedure} set-object-procedure! obj proc +@deffnx {C Function} scm_set_object_procedure_x (obj, proc) Set the object procedure of @var{obj} to @var{proc}. @var{obj} must be either an entity or an operator. @end deffn -@deffn primitive make-class-object metaclass layout +@deffn {Scheme Procedure} make-class-object metaclass layout +@deffnx {C Function} scm_make_class_object (metaclass, layout) Create a new class object of class @var{metaclass}, with the slot layout specified by @var{layout}. @end deffn -@deffn primitive make-subclass-object class layout +@deffn {Scheme Procedure} make-subclass-object class layout +@deffnx {C Function} scm_make_subclass_object (class, layout) Create a subclass object of @var{class}, with the slot layout specified by @var{layout}. @end deffn diff --git a/doc/ref/scheme-modules.texi b/doc/ref/scheme-modules.texi index 70cbd94d7..ac6ead1e8 100644 --- a/doc/ref/scheme-modules.texi +++ b/doc/ref/scheme-modules.texi @@ -193,7 +193,7 @@ This example also shows how to use the convenience procedure @code{symbol-prefix-proc}. @c begin (scm-doc-string "boot-9.scm" "symbol-prefix-proc") -@deffn procedure symbol-prefix-proc prefix-sym +@deffn {Scheme Procedure} symbol-prefix-proc prefix-sym Return a procedure that prefixes its arg (a symbol) with @var{prefix-sym}. @c Insert gratuitous C++ slam here. --ttn @@ -332,7 +332,8 @@ The procedures in this section are useful if you want to dig into the innards of Guile's module system. If you don't know precisely what you do, you should probably avoid using any of them. -@deffn primitive standard-eval-closure module +@deffn {Scheme Procedure} standard-eval-closure module +@deffnx {C Function} scm_standard_eval_closure (module) Return an eval closure for the module @var{module}. @end deffn @@ -495,7 +496,8 @@ When using the low level procedures to do your dynamic linking, you have complete control over which library is loaded when and what get's done with it. -@deffn primitive dynamic-link library +@deffn {Scheme Procedure} dynamic-link library +@deffnx {C Function} scm_dynamic_link (library) Find the shared library denoted by @var{library} (a string) and link it into the running Guile application. When everything works out, return a Scheme object suitable for representing the linked object file. @@ -507,24 +509,26 @@ that will be searched for in the places where shared libraries usually reside, such as in @file{/usr/lib} and @file{/usr/local/lib}. @end deffn -@deffn primitive dynamic-object? val -Determine whether @var{val} represents a dynamically linked object file. +@deffn {Scheme Procedure} dynamic-object? obj +@deffnx {C Function} scm_dynamic_object_p (obj) +Return @code{#t} if @var{obj} is a dynamic library handle, or @code{#f} +otherwise. @end deffn -@deffn primitive dynamic-unlink dynobj -Unlink the indicated object file from the application. The argument -@var{dynobj} should be one of the values returned by -@code{dynamic-link}. When @code{dynamic-unlink} has been called on -@var{dynobj}, it is no longer usable as an argument to the functions -below and you will get type mismatch errors when you try to. +@deffn {Scheme Procedure} dynamic-unlink dobj +@deffnx {C Function} scm_dynamic_unlink (dobj) +Unlink the indicated object file from the application. The +argument @var{dobj} must have been obtained by a call to +@code{dynamic-link}. After @code{dynamic-unlink} has been +called on @var{dobj}, its content is no longer accessible. @end deffn -@deffn primitive dynamic-func function dynobj -Search the C function indicated by @var{function} (a string or symbol) -in @var{dynobj} and return some Scheme object that can later be used -with @code{dynamic-call} to actually call this function. Right now, -these Scheme objects are formed by casting the address of the function -to @code{long} and converting this number to its Scheme representation. +@deffn {Scheme Procedure} dynamic-func name dobj +@deffnx {C Function} scm_dynamic_func (name, dobj) +Search the dynamic object @var{dobj} for the C function +indicated by the string @var{name} and return some Scheme +handle that can later be used with @code{dynamic-call} to +actually call the function. Regardless whether your C compiler prepends an underscore @samp{_} to the global names in a program, you should @strong{not} include this @@ -532,35 +536,37 @@ underscore in @var{function}. Guile knows whether the underscore is needed or not and will add it when necessary. @end deffn -@deffn primitive dynamic-call function dynobj -Call the C function indicated by @var{function} and @var{dynobj}. The -function is passed no arguments and its return value is ignored. When -@var{function} is something returned by @code{dynamic-func}, call that -function and ignore @var{dynobj}. When @var{function} is a string (or -symbol, etc.), look it up in @var{dynobj}; this is equivalent to - +@deffn {Scheme Procedure} dynamic-call func dobj +@deffnx {C Function} scm_dynamic_call (func, dobj) +Call the C function indicated by @var{func} and @var{dobj}. +The function is passed no arguments and its return value is +ignored. When @var{function} is something returned by +@code{dynamic-func}, call that function and ignore @var{dobj}. +When @var{func} is a string , look it up in @var{dynobj}; this +is equivalent to @smallexample -(dynamic-call (dynamic-func @var{function} @var{dynobj} #f)) +(dynamic-call (dynamic-func @var{func} @var{dobj} #f)) @end smallexample Interrupts are deferred while the C function is executing (with @code{SCM_DEFER_INTS}/@code{SCM_ALLOW_INTS}). @end deffn -@deffn primitive dynamic-args-call function dynobj args -Call the C function indicated by @var{function} and @var{dynobj}, just -like @code{dynamic-call}, but pass it some arguments and return its -return value. The C function is expected to take two arguments and -return an @code{int}, just like @code{main}: - +@deffn {Scheme Procedure} dynamic-args-call func dobj args +@deffnx {C Function} scm_dynamic_args_call (func, dobj, args) +Call the C function indicated by @var{func} and @var{dobj}, +just like @code{dynamic-call}, but pass it some arguments and +return its return value. The C function is expected to take +two arguments and return an @code{int}, just like @code{main}: @smallexample int c_func (int argc, char **argv); @end smallexample -The parameter @var{args} must be a list of strings and is converted into -an array of @code{char *}. The array is passed in @var{argv} and its -size in @var{argc}. The return value is converted to a Scheme number -and returned from the call to @code{dynamic-args-call}. +The parameter @var{args} must be a list of strings and is +converted into an array of @code{char *}. The array is passed +in @var{argv} and its size in @var{argc}. The return value is +converted to a Scheme number and returned from the call to +@code{dynamic-args-call}. @end deffn When dynamic linking is disabled or not supported on your system, diff --git a/doc/ref/scheme-options.texi b/doc/ref/scheme-options.texi index e4da66355..3b24463ba 100644 --- a/doc/ref/scheme-options.texi +++ b/doc/ref/scheme-options.texi @@ -34,11 +34,11 @@ We will use the expression @code{} to represent @code{read}, @subheading Low level @c NJFIXME -@deffn primitive -options-interface -@deffnx primitive read-options-interface [SOME-INT] -@deffnx primitive print-options-interface [SOME-INT] -@deffnx primitive evaluator-traps-interface [SOME-INT] -@deffnx primitive read-options-interface [SOME-INT] +@deffn {Scheme Procedure} -options-interface +@deffnx {Scheme Procedure} read-options-interface [SOME-INT] +@deffnx {Scheme Procedure} print-options-interface [SOME-INT] +@deffnx {Scheme Procedure} evaluator-traps-interface [SOME-INT] +@deffnx {Scheme Procedure} read-options-interface [SOME-INT] [FIXME: I have just taken the comments for C routine scm_options that implements all of these. It needs to be presented better.] @@ -59,11 +59,11 @@ and documentation string. @c @end deftp @c NJFIXME -@deffn procedure -options [arg] -@deffnx procedure read-options [arg] -@deffnx procedure print-options [arg] -@deffnx procedure debug-options [arg] -@deffnx procedure traps [arg] +@deffn {Scheme Procedure} -options [arg] +@deffnx {Scheme Procedure} read-options [arg] +@deffnx {Scheme Procedure} print-options [arg] +@deffnx {Scheme Procedure} debug-options [arg] +@deffnx {Scheme Procedure} traps [arg] These functions list the options in their group. The optional argument @var{arg} is a symbol which modifies the form in which the options are presented. @@ -81,22 +81,22 @@ options) and symbols followed by values. up?] @c NJFIXME -@deffn procedure -enable option-symbol -@deffnx procedure read-enable option-symbol -@deffnx procedure print-enable option-symbol -@deffnx procedure debug-enable option-symbol -@deffnx procedure trap-enable option-symbol +@deffn {Scheme Procedure} -enable option-symbol +@deffnx {Scheme Procedure} read-enable option-symbol +@deffnx {Scheme Procedure} print-enable option-symbol +@deffnx {Scheme Procedure} debug-enable option-symbol +@deffnx {Scheme Procedure} trap-enable option-symbol These functions set the specified @var{option-symbol} in their options group. They only work if the option is boolean, and throw an error otherwise. @end deffn @c NJFIXME -@deffn procedure -disable option-symbol -@deffnx procedure read-disable option-symbol -@deffnx procedure print-disable option-symbol -@deffnx procedure debug-disable option-symbol -@deffnx procedure trap-disable option-symbol +@deffn {Scheme Procedure} -disable option-symbol +@deffnx {Scheme Procedure} read-disable option-symbol +@deffnx {Scheme Procedure} print-disable option-symbol +@deffnx {Scheme Procedure} debug-disable option-symbol +@deffnx {Scheme Procedure} trap-disable option-symbol These functions turn off the specified @var{option-symbol} in their options group. They only work if the option is boolean, and throw an error otherwise. @@ -331,10 +331,14 @@ It is often useful to have site-specific information about the current Guile installation. This chapter describes how to find out about Guile's configuration at run time. -@deffn primitive version -@deffnx primitive major-version -@deffnx primitive minor-version -@deffnx primitive micro-version +@deffn {Scheme Procedure} version +@deffnx {Scheme Procedure} major-version +@deffnx {Scheme Procedure} minor-version +@deffnx {Scheme Procedure} micro-version +@deffnx {C Function} scm_version () +@deffnx {C Function} scm_major_version () +@deffnx {C Function} scm_minor_version () +@deffnx {C Function} scm_micro_version () Return a string describing Guile's version number, or its major, minor or micro version number, respectively. @@ -347,37 +351,42 @@ or micro version number, respectively. @end deffn @c NJFIXME not in libguile! -@deffn primitive libguile-config-stamp +@deffn {Scheme Procedure} libguile-config-stamp Return a string describing the date on which @code{libguile} was configured. This is used to determine whether the Guile core interpreter and the ice-9 runtime have grown out of date with one another. @end deffn -@deffn primitive %package-data-dir +@deffn {Scheme Procedure} %package-data-dir +@deffnx {C Function} scm_sys_package_data_dir () Return the name of the directory where Scheme packages, modules and libraries are kept. On most Unix systems, this will be @samp{/usr/local/share/guile}. @end deffn -@deffn primitive %library-dir +@deffn {Scheme Procedure} %library-dir +@deffnx {C Function} scm_sys_library_dir () Return the directory where the Guile Scheme library files are installed. E.g., may return "/usr/share/guile/1.3.5". @end deffn -@deffn primitive %site-dir +@deffn {Scheme Procedure} %site-dir +@deffnx {C Function} scm_sys_site_dir () Return the directory where the Guile site files are installed. E.g., may return "/usr/share/guile/site". @end deffn -@deffn primitive parse-path path [tail] +@deffn {Scheme Procedure} parse-path path [tail] +@deffnx {C Function} scm_parse_path (path, tail) Parse @var{path}, which is expected to be a colon-separated string, into a list and return the resulting list with @var{tail} appended. If @var{path} is @code{#f}, @var{tail} is returned. @end deffn -@deffn primitive search-path path filename [extensions] +@deffn {Scheme Procedure} search-path path filename [extensions] +@deffnx {C Function} scm_search_path (path, filename, extensions) Search @var{path} for a directory containing a file named @var{filename}. The file must be readable, and not a directory. If we find one, return its full filename; otherwise, return diff --git a/doc/ref/scheme-procedures.texi b/doc/ref/scheme-procedures.texi index 4a4830358..bc186c9e5 100644 --- a/doc/ref/scheme-procedures.texi +++ b/doc/ref/scheme-procedures.texi @@ -347,15 +347,18 @@ for primitive procedures, and @code{thunk?} only returns @code{#t} for procedures which do not accept any arguments. @rnindex procedure? -@deffn primitive procedure? obj +@deffn {Scheme Procedure} procedure? obj +@deffnx {C Function} scm_procedure_p (obj) Return @code{#t} if @var{obj} is a procedure. @end deffn -@deffn primitive closure? obj +@deffn {Scheme Procedure} closure? obj +@deffnx {C Function} scm_closure_p (obj) Return @code{#t} if @var{obj} is a closure. @end deffn -@deffn primitive thunk? obj +@deffn {Scheme Procedure} thunk? obj +@deffnx {C Function} scm_thunk_p (obj) Return @code{#t} if @var{obj} is a thunk. @end deffn @@ -365,19 +368,23 @@ Procedure properties are general properties to be attached to procedures. These can be the name of a procedure or other relevant information, such as debug hints. -@deffn primitive procedure-properties proc +@deffn {Scheme Procedure} procedure-properties proc +@deffnx {C Function} scm_procedure_properties (proc) Return @var{obj}'s property list. @end deffn -@deffn primitive procedure-property p k +@deffn {Scheme Procedure} procedure-property obj key +@deffnx {C Function} scm_procedure_property (obj, key) Return the property of @var{obj} with name @var{key}. @end deffn -@deffn primitive set-procedure-properties! proc new_val +@deffn {Scheme Procedure} set-procedure-properties! proc alist +@deffnx {C Function} scm_set_procedure_properties_x (proc, alist) Set @var{obj}'s property list to @var{alist}. @end deffn -@deffn primitive set-procedure-property! p k v +@deffn {Scheme Procedure} set-procedure-property! obj key value +@deffnx {C Function} scm_set_procedure_property_x (obj, key, value) In @var{obj}'s property list, set the property named @var{key} to @var{value}. @end deffn @@ -386,7 +393,8 @@ In @var{obj}'s property list, set the property named @var{key} to Documentation for a procedure can be accessed with the procedure @code{procedure-documentation}. -@deffn primitive procedure-documentation proc +@deffn {Scheme Procedure} procedure-documentation proc +@deffnx {C Function} scm_procedure_documentation (proc) Return the documentation string associated with @code{proc}. By convention, if a procedure contains more than one expression and the first expression is a string constant, that string is assumed to contain @@ -398,22 +406,26 @@ documentation for that procedure. Source properties are properties which are related to the source code of a procedure, such as the line and column numbers, the file name etc. -@deffn primitive set-source-properties! obj plist +@deffn {Scheme Procedure} set-source-properties! obj plist +@deffnx {C Function} scm_set_source_properties_x (obj, plist) Install the association list @var{plist} as the source property list for @var{obj}. @end deffn -@deffn primitive set-source-property! obj key datum +@deffn {Scheme Procedure} set-source-property! obj key datum +@deffnx {C Function} scm_set_source_property_x (obj, key, datum) Set the source property of object @var{obj}, which is specified by @var{key} to @var{datum}. Normally, the key will be a symbol. @end deffn -@deffn primitive source-properties obj +@deffn {Scheme Procedure} source-properties obj +@deffnx {C Function} scm_source_properties (obj) Return the source property association list of @var{obj}. @end deffn -@deffn primitive source-property obj key +@deffn {Scheme Procedure} source-property obj key +@deffnx {C Function} scm_source_property (obj, key) Return the source property specified by @var{key} from @var{obj}'s source property list. @end deffn @@ -480,22 +492,25 @@ structure stored in @code{f}, or to write into the structure. (foo f 0) @result{} dum @end lisp -@deffn primitive make-procedure-with-setter procedure setter +@deffn {Scheme Procedure} make-procedure-with-setter procedure setter +@deffnx {C Function} scm_make_procedure_with_setter (procedure, setter) Create a new procedure which behaves like @var{procedure}, but with the associated setter @var{setter}. @end deffn -@deffn primitive procedure-with-setter? obj +@deffn {Scheme Procedure} procedure-with-setter? obj +@deffnx {C Function} scm_procedure_with_setter_p (obj) Return @code{#t} if @var{obj} is a procedure with an associated setter procedure. @end deffn -@deffn primitive procedure proc +@deffn {Scheme Procedure} procedure proc +@deffnx {C Function} scm_procedure (proc) Return the procedure of @var{proc}, which must be either a procedure with setter, or an operator struct. @end deffn -@deffn primitive setter proc +@deffn {Scheme Procedure} setter proc Return the setter of @var{proc}, which must be either a procedure with setter or an operator struct. @end deffn @@ -710,30 +725,34 @@ change. Use @code{defmacro}, @code{define-macro} (@pxref{Macros}) or terms, @code{defmacro}, @code{define-macro} and @code{define-syntax} are all implemented as mmacros.) -@deffn primitive procedure->syntax code -Return a macro which, when a symbol defined to this value appears as the -first symbol in an expression, returns the result of applying @var{code} -to the expression and the environment. +@deffn {Scheme Procedure} procedure->syntax code +@deffnx {C Function} scm_makacro (code) +Return a @dfn{macro} which, when a symbol defined to this value +appears as the first symbol in an expression, returns the +result of applying @var{code} to the expression and the +environment. @end deffn -@deffn primitive procedure->macro code -Return a macro which, when a symbol defined to this value appears as the -first symbol in an expression, evaluates the result of applying -@var{code} to the expression and the environment. For example: +@deffn {Scheme Procedure} procedure->macro code +@deffnx {C Function} scm_makmacro (code) +Return a @dfn{macro} which, when a symbol defined to this value +appears as the first symbol in an expression, evaluates the +result of applying @var{code} to the expression and the +environment. The value returned from @var{code} which has been +passed to @code{procedure->memoizing-macro} replaces the form +passed to @var{code}. For example: @lisp (define trace (procedure->macro - (lambda (x env) - `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x)))))) + (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x)))))) -(trace @i{foo}) -@equiv{} -(set! @i{foo} (tracef @i{foo} '@i{foo})). +(trace @i{foo}) @equiv{} (set! @i{foo} (tracef @i{foo} '@i{foo})). @end lisp @end deffn -@deffn primitive procedure->memoizing-macro code +@deffn {Scheme Procedure} procedure->memoizing-macro code +@deffnx {C Function} scm_makmmacro (code) Return a macro which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the result of applying @var{code} to the expression and the environment. @@ -746,12 +765,14 @@ of the containing code. In the following primitives, @dfn{acro} flavour macros are referred to as @dfn{syntax transformers}. -@deffn primitive macro? obj +@deffn {Scheme Procedure} macro? obj +@deffnx {C Function} scm_macro_p (obj) Return @code{#t} if @var{obj} is a regular macro, a memoizing macro or a syntax transformer. @end deffn -@deffn primitive macro-type m +@deffn {Scheme Procedure} macro-type m +@deffnx {C Function} scm_macro_type (m) Return one of the symbols @code{syntax}, @code{macro} or @code{macro!}, depending on whether @var{m} is a syntax transformer, a regular macro, or a memoizing macro, @@ -759,15 +780,18 @@ respectively. If @var{m} is not a macro, @code{#f} is returned. @end deffn -@deffn primitive macro-name m +@deffn {Scheme Procedure} macro-name m +@deffnx {C Function} scm_macro_name (m) Return the name of the macro @var{m}. @end deffn -@deffn primitive macro-transformer m +@deffn {Scheme Procedure} macro-transformer m +@deffnx {C Function} scm_macro_transformer (m) Return the transformer of the macro @var{m}. @end deffn -@deffn primitive cons-source xorig x y +@deffn {Scheme Procedure} cons-source xorig x y +@deffnx {C Function} scm_cons_source (xorig, x, y) Create and return a new pair whose car and cdr are @var{x} and @var{y}. Any source properties associated with @var{xorig} are also associated with the new pair. diff --git a/doc/ref/scheme-scheduling.texi b/doc/ref/scheme-scheduling.texi index e2cdd3d2a..920a73029 100644 --- a/doc/ref/scheme-scheduling.texi +++ b/doc/ref/scheme-scheduling.texi @@ -30,18 +30,21 @@ otherwise it will fail and return @code{#f}. Once an arbiter is successfully locked, it cannot be locked by another thread until the thread holding the arbiter calls @code{release-arbiter} to unlock it. -@deffn primitive make-arbiter name +@deffn {Scheme Procedure} make-arbiter name +@deffnx {C Function} scm_make_arbiter (name) Return an object of type arbiter and name @var{name}. Its state is initially unlocked. Arbiters are a way to achieve process synchronization. @end deffn -@deffn primitive try-arbiter arb +@deffn {Scheme Procedure} try-arbiter arb +@deffnx {C Function} scm_try_arbiter (arb) Return @code{#t} and lock the arbiter @var{arb} if the arbiter was unlocked. Otherwise, return @code{#f}. @end deffn -@deffn primitive release-arbiter arb +@deffn {Scheme Procedure} release-arbiter arb +@deffnx {C Function} scm_release_arbiter (arb) Return @code{#t} and unlock the arbiter @var{arb} if the arbiter was locked. Otherwise, return @code{#f}. @end deffn @@ -70,20 +73,24 @@ Normal asyncs are created with @code{async}, system asyncs with @code{system-async}. They are marked with @code{async-mark} or @code{system-async-mark}, respectively. -@deffn primitive async thunk +@deffn {Scheme Procedure} async thunk +@deffnx {C Function} scm_async (thunk) Create a new async for the procedure @var{thunk}. @end deffn -@deffn primitive system-async thunk +@deffn {Scheme Procedure} system-async thunk +@deffnx {C Function} scm_system_async (thunk) Create a new async for the procedure @var{thunk}. Also add it to the system's list of active async objects. @end deffn -@deffn primitive async-mark a +@deffn {Scheme Procedure} async-mark a +@deffnx {C Function} scm_async_mark (a) Mark the async @var{a} for future execution. @end deffn -@deffn primitive system-async-mark a +@deffn {Scheme Procedure} system-async-mark a +@deffnx {C Function} scm_system_async_mark (a) Mark the async @var{a} for future execution. @end deffn @@ -91,7 +98,8 @@ As already mentioned above, system asyncs are executed automatically. Normal asyncs have to be explicitly invoked by storing one or more of them into a list and passing them to @code{run-asyncs}. -@deffn primitive run-asyncs list_of_a +@deffn {Scheme Procedure} run-asyncs list_of_a +@deffnx {C Function} scm_run_asyncs (list_of_a) Execute all thunks from the asyncs of the list @var{list_of_a}. @end deffn @@ -102,18 +110,21 @@ run once execution is enabled again. Please note that calls to these procedures should always be paired, and they must not be nested, e.g. no @code{mask-signals} is allowed if another one is still active. -@deffn primitive mask-signals +@deffn {Scheme Procedure} mask-signals +@deffnx {C Function} scm_mask_signals () Mask signals. The returned value is not specified. @end deffn -@deffn primitive unmask-signals +@deffn {Scheme Procedure} unmask-signals +@deffnx {C Function} scm_unmask_signals () Unmask signals. The returned value is not specified. @end deffn @c FIXME::martin: Find an example for usage of `noop'. What is that @c procedure for anyway? -@deffn primitive noop . args +@deffn {Scheme Procedure} noop . args +@deffnx {C Function} scm_noop (args) Do nothing. When called without arguments, return @code{#f}, otherwise return the first argument. @end deffn @@ -139,7 +150,8 @@ dynamic root. For example, if you want to apply a procedure, but to not allow that procedure to capture the current continuation, calling the procedure under a new dynamic root will do the job. -@deffn primitive call-with-dynamic-root thunk handler +@deffn {Scheme Procedure} call-with-dynamic-root thunk handler +@deffnx {C Function} scm_call_with_dynamic_root (thunk, handler) Evaluate @code{(thunk)} in a new dynamic context, returning its value. If an error occurs during evaluation, apply @var{handler} to the @@ -185,7 +197,8 @@ be under a new dynamic root.) @end deffn -@deffn primitive dynamic-root +@deffn {Scheme Procedure} dynamic-root +@deffnx {C Function} scm_dynamic_root () Return an object representing the current dynamic root. These objects are only useful for comparison using @code{eq?}. @@ -194,7 +207,7 @@ in no way depend on this. @end deffn @c begin (scm-doc-string "boot-9.scm" "quit") -@deffn procedure quit [exit_val] +@deffn {Scheme Procedure} quit [exit_val] Throw back to the error handler of the current dynamic root. If integer @var{exit_val} is specified and if Guile is being used @@ -215,12 +228,12 @@ from Scheme code to be removed. An example of where this is useful is after forking a new process intended to run non-interactively. @c begin (scm-doc-string "boot-9.scm" "batch-mode?") -@deffn procedure batch-mode? +@deffn {Scheme Procedure} batch-mode? Returns a boolean indicating whether the interpreter is in batch mode. @end deffn @c begin (scm-doc-string "boot-9.scm" "set-batch-mode?!") -@deffn procedure set-batch-mode?! arg +@deffn {Scheme Procedure} set-batch-mode?! arg If @var{arg} is true, switches the interpreter to batch mode. The @code{#f} case has not been implemented. @end deffn @@ -258,7 +271,7 @@ executed in a new dynamic root. @c are in sync. @c begin (texi-doc-string "guile" "call-with-new-thread") -@deffn primitive call-with-new-thread thunk error-handler +@deffn {Scheme Procedure} call-with-new-thread thunk error-handler Evaluate @code{(thunk)} in a new thread, and new dynamic context, returning a new thread object representing the thread. @@ -273,31 +286,31 @@ All the evaluation rules for dynamic roots apply to threads. @end deffn @c begin (texi-doc-string "guile" "join-thread") -@deffn primitive join-thread thread +@deffn {Scheme Procedure} join-thread thread Suspend execution of the calling thread until the target @var{thread} terminates, unless the target @var{thread} has already terminated. @end deffn @c begin (texi-doc-string "guile" "yield") -@deffn primitive yield +@deffn {Scheme Procedure} yield If one or more threads are waiting to execute, calling yield forces an immediate context switch to one of them. Otherwise, yield has no effect. @end deffn @c begin (texi-doc-string "guile" "make-mutex") -@deffn primitive make-mutex +@deffn {Scheme Procedure} make-mutex Create a new mutex object. @end deffn @c begin (texi-doc-string "guile" "lock-mutex") -@deffn primitive lock-mutex mutex +@deffn {Scheme Procedure} lock-mutex mutex Lock @var{mutex}. If the mutex is already locked, the calling thread blocks until the mutex becomes available. The function returns when the calling thread owns the lock on @var{mutex}. @end deffn @c begin (texi-doc-string "guile" "unlock-mutex") -@deffn primitive unlock-mutex mutex +@deffn {Scheme Procedure} unlock-mutex mutex Unlocks @var{mutex} if the calling thread owns the lock on @var{mutex}. Calling unlock-mutex on a mutex not owned by the current thread results in undefined behaviour. Once a mutex has been unlocked, one thread @@ -305,15 +318,15 @@ blocked on @var{mutex} is awakened and grabs the mutex lock. @end deffn @c begin (texi-doc-string "guile" "make-condition-variable") -@deffn primitive make-condition-variable +@deffn {Scheme Procedure} make-condition-variable @end deffn @c begin (texi-doc-string "guile" "wait-condition-variable") -@deffn primitive wait-condition-variable cond-var mutex +@deffn {Scheme Procedure} wait-condition-variable cond-var mutex @end deffn @c begin (texi-doc-string "guile" "signal-condition-variable") -@deffn primitive signal-condition-variable cond-var +@deffn {Scheme Procedure} signal-condition-variable cond-var @end deffn @@ -326,7 +339,7 @@ Higher level thread procedures are available by loading the @code{(ice-9 threads)} module. These provide standardized thread creation and mutex interaction. -@deffn primitive %thread-handler tag args@dots{} +@deffn {Scheme Procedure} %thread-handler tag args@dots{} This procedure is specified as the standard error-handler for @code{make-thread} and @code{begin-thread}. If the number of @var{args} @@ -390,7 +403,8 @@ in Scheme---this cannot happen. See the description of New fluids are created with @code{make-fluid} and @code{fluid?} is used for testing whether an object is actually a fluid. -@deffn primitive make-fluid +@deffn {Scheme Procedure} make-fluid +@deffnx {C Function} scm_make_fluid () Return a newly created fluid. Fluids are objects of a certain type (a smob) that can hold one SCM value per dynamic root. That is, modifications to this value are @@ -400,7 +414,8 @@ inherits the values from its parent. Because each thread executes in its own dynamic root, you can use fluids for thread local storage. @end deffn -@deffn primitive fluid? obj +@deffn {Scheme Procedure} fluid? obj +@deffnx {C Function} scm_fluid_p (obj) Return @code{#t} iff @var{obj} is a fluid; otherwise, return @code{#f}. @end deffn @@ -408,13 +423,15 @@ Return @code{#t} iff @var{obj} is a fluid; otherwise, return The values stored in a fluid can be accessed with @code{fluid-ref} and @code{fluid-set!}. -@deffn primitive fluid-ref fluid +@deffn {Scheme Procedure} fluid-ref fluid +@deffnx {C Function} scm_fluid_ref (fluid) Return the value associated with @var{fluid} in the current dynamic root. If @var{fluid} has not been set, then return @code{#f}. @end deffn -@deffn primitive fluid-set! fluid value +@deffn {Scheme Procedure} fluid-set! fluid value +@deffnx {C Function} scm_fluid_set_x (fluid, value) Set the value associated with @var{fluid} in the current dynamic root. @end deffn @@ -422,7 +439,8 @@ Set the value associated with @var{fluid} in the current dynamic root. so that the given procedure and each procedure called by it access the given values. After the procedure returns, the old values are restored. -@deffn primitive with-fluids* fluids values thunk +@deffn {Scheme Procedure} with-fluids* fluids values thunk +@deffnx {C Function} scm_with_fluids (fluids, values, thunk) Set @var{fluids} to @var{values} temporary, and call @var{thunk}. @var{fluids} must be a list of fluids and @var{values} must be the same number of their values to be applied. Each substitution is done diff --git a/doc/ref/scheme-translation.texi b/doc/ref/scheme-translation.texi index c01b1491a..03984dddc 100644 --- a/doc/ref/scheme-translation.texi +++ b/doc/ref/scheme-translation.texi @@ -12,28 +12,32 @@ @node Emacs Lisp Support @section Emacs Lisp Support -@deffn primitive nil-car x +@deffn {Scheme Procedure} nil-car x +@deffnx {C Function} scm_nil_car (x) Return the car of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn -@deffn primitive nil-cdr x +@deffn {Scheme Procedure} nil-cdr x +@deffnx {C Function} scm_nil_cdr (x) Return the cdr of @var{x}, but convert it to LISP nil if it is Scheme's end-of-list. @end deffn -@deffn primitive nil-cons x y +@deffn {Scheme Procedure} nil-cons x y +@deffnx {C Function} scm_nil_cons (x, y) Create a new cons cell with @var{x} as the car and @var{y} as the cdr, but convert @var{y} to Scheme's end-of-list if it is a LISP nil. @end deffn -@deffn primitive nil-eq x y +@deffn {Scheme Procedure} nil-eq x y Compare @var{x} and @var{y} and return LISP's t if they are @code{eq?}, return LISP's nil otherwise. @end deffn -@deffn primitive null x +@deffn {Scheme Procedure} null x +@deffnx {C Function} scm_null (x) Return LISP's @code{t} if @var{x} is nil in the LISP sense, return LISP's nil otherwise. @end deffn diff --git a/doc/ref/scheme-utility.texi b/doc/ref/scheme-utility.texi index 93c76bdf1..cc44f42ce 100644 --- a/doc/ref/scheme-utility.texi +++ b/doc/ref/scheme-utility.texi @@ -47,7 +47,7 @@ procedures for testing for equality are provided, which correspond to the three kinds of @dfn{sameness} defined above. @rnindex eq? -@deffn primitive eq? x y +@deffn {Scheme Procedure} eq? x y Return @code{#t} iff @var{x} references the same object as @var{y}. @code{eq?} is similar to @code{eqv?} except that in some cases it is capable of discerning distinctions finer than those detectable by @@ -55,7 +55,7 @@ capable of discerning distinctions finer than those detectable by @end deffn @rnindex eqv? -@deffn primitive eqv? x y +@deffn {Scheme Procedure} eqv? x y The @code{eqv?} procedure defines a useful equivalence relation on objects. Briefly, it returns @code{#t} if @var{x} and @var{y} should normally be regarded as the same object. This relation is left slightly open to @@ -64,7 +64,7 @@ and inexact numbers. @end deffn @rnindex equal? -@deffn primitive equal? x y +@deffn {Scheme Procedure} equal? x y Return @code{#t} iff @var{x} and @var{y} are recursively @code{eqv?} equivalent. @code{equal?} recursively compares the contents of pairs, vectors, and strings, applying @code{eqv?} on other objects such as @@ -89,23 +89,23 @@ closures than for other kinds of objects. Therefore, when manipulating a property list associated with a procedure object, use the @code{procedure} functions; otherwise, use the @code{object} functions. -@deffn primitive object-properties obj -@deffnx primitive procedure-properties obj +@deffn {Scheme Procedure} object-properties obj +@deffnx {C Function} scm_object_properties (obj) Return @var{obj}'s property list. @end deffn -@deffn primitive set-object-properties! obj alist -@deffnx primitive set-procedure-properties! obj alist +@deffn {Scheme Procedure} set-object-properties! obj alist +@deffnx {C Function} scm_set_object_properties_x (obj, alist) Set @var{obj}'s property list to @var{alist}. @end deffn -@deffn primitive object-property obj key -@deffnx primitive procedure-property obj key +@deffn {Scheme Procedure} object-property obj key +@deffnx {C Function} scm_object_property (obj, key) Return the property of @var{obj} with name @var{key}. @end deffn -@deffn primitive set-object-property! obj key value -@deffnx primitive set-procedure-property! obj key value +@deffn {Scheme Procedure} set-object-property! obj key value +@deffnx {C Function} scm_set_object_property_x (obj, key, value) In @var{obj}'s property list, set the property named @var{key} to @var{value}. @end deffn @@ -117,14 +117,16 @@ the user provides a "property table" that is possibly private.] @node Primitive Properties @section Primitive Properties -@deffn primitive primitive-make-property not_found_proc +@deffn {Scheme Procedure} primitive-make-property not_found_proc +@deffnx {C Function} scm_primitive_make_property (not_found_proc) Create a @dfn{property token} that can be used with @code{primitive-property-ref} and @code{primitive-property-set!}. See @code{primitive-property-ref} for the significance of @var{not_found_proc}. @end deffn -@deffn primitive primitive-property-ref prop obj +@deffn {Scheme Procedure} primitive-property-ref prop obj +@deffnx {C Function} scm_primitive_property_ref (prop, obj) Return the property @var{prop} of @var{obj}. When no value has yet been associated with @var{prop} and @var{obj}, call @var{not-found-proc} instead (see @code{primitive-make-property}) @@ -134,11 +136,13 @@ and use its return value. That value is also associated with default value of @var{prop}. @end deffn -@deffn primitive primitive-property-set! prop obj val +@deffn {Scheme Procedure} primitive-property-set! prop obj val +@deffnx {C Function} scm_primitive_property_set_x (prop, obj, val) Associate @var{code} with @var{prop} and @var{obj}. @end deffn -@deffn primitive primitive-property-del! prop obj +@deffn {Scheme Procedure} primitive-property-del! prop obj +@deffnx {C Function} scm_primitive_property_del_x (prop, obj) Remove any value associated with @var{prop} and @var{obj}. @end deffn @@ -161,15 +165,19 @@ The first group of procedures can be used to merge two lists (which must be already sorted on their own) and produce sorted lists containing all elements of the input lists. -@deffn primitive merge alist blist less -Take two lists @var{alist} and @var{blist} such that -@code{(sorted? alist less?)} and @code{(sorted? blist less?)} and -returns a new list in which the elements of @var{alist} and +@deffn {Scheme Procedure} merge alist blist less +@deffnx {C Function} scm_merge (alist, blist, less) +Merge two already sorted lists into one. +Given two lists @var{alist} and @var{blist}, such that +@code{(sorted? alist less?)} and @code{(sorted? blist less?)}, +return a new list in which the elements of @var{alist} and @var{blist} have been stably interleaved so that @code{(sorted? (merge alist blist less?) less?)}. +Note: this does _not_ accept vectors. @end deffn -@deffn primitive merge! alist blist less +@deffn {Scheme Procedure} merge! alist blist less +@deffnx {C Function} scm_merge_x (alist, blist, less) Takes two lists @var{alist} and @var{blist} such that @code{(sorted? alist less?)} and @code{(sorted? blist less?)} and returns a new list in which the elements of @var{alist} and @@ -189,19 +197,22 @@ If two or more elements are the same according to the comparison predicate, they are left in the same order as they appeared in the input. -@deffn primitive sorted? items less +@deffn {Scheme Procedure} sorted? items less +@deffnx {C Function} scm_sorted_p (items, less) Return @code{#t} iff @var{items} is a list or a vector such that for all 1 <= i <= m, the predicate @var{less} returns true when applied to all elements i - 1 and i @end deffn -@deffn primitive sort items less +@deffn {Scheme Procedure} sort items less +@deffnx {C Function} scm_sort (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. This is not a stable sort. @end deffn -@deffn primitive sort! items less +@deffn {Scheme Procedure} sort! items less +@deffnx {C Function} scm_sort_x (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. The sorting is destructive, that means that the @@ -209,13 +220,15 @@ input sequence is modified to produce the sorted result. This is not a stable sort. @end deffn -@deffn primitive stable-sort items less +@deffn {Scheme Procedure} stable-sort items less +@deffnx {C Function} scm_stable_sort (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. This is a stable sort. @end deffn -@deffn primitive stable-sort! items less +@deffn {Scheme Procedure} stable-sort! items less +@deffnx {C Function} scm_stable_sort_x (items, less) Sort the sequence @var{items}, which may be a list or a vector. @var{less} is used for comparing the sequence elements. The sorting is destructive, that means that the input sequence @@ -226,19 +239,22 @@ This is a stable sort. The procedures in the last group only accept lists or vectors as input, as their names indicate. -@deffn primitive sort-list items less +@deffn {Scheme Procedure} sort-list items less +@deffnx {C Function} scm_sort_list (items, less) Sort the list @var{items}, using @var{less} for comparing the list elements. This is a stable sort. @end deffn -@deffn primitive sort-list! items less +@deffn {Scheme Procedure} sort-list! items less +@deffnx {C Function} scm_sort_list_x (items, less) Sort the list @var{items}, using @var{less} for comparing the list elements. The sorting is destructive, that means that the input list is modified to produce the sorted result. This is a stable sort. @end deffn -@deffn primitive restricted-vector-sort! vec less startpos endpos +@deffn {Scheme Procedure} restricted-vector-sort! vec less startpos endpos +@deffnx {C Function} scm_restricted_vector_sort_x (vec, less, startpos, endpos) Sort the vector @var{vec}, using @var{less} for comparing the vector elements. @var{startpos} and @var{endpos} delimit the range of the vector which gets sorted. The return value @@ -257,7 +273,8 @@ procedures for copying vectors. @code{copy-tree} can be used for these application, as it does not only copy the spine of a list, but also copies any pairs in the cars of the input lists. -@deffn primitive copy-tree obj +@deffn {Scheme Procedure} copy-tree obj +@deffnx {C Function} scm_copy_tree (obj) Recursively copy the data tree that is bound to @var{obj}, and return a pointer to the new data structure. @code{copy-tree} recurses down the contents of both pairs and vectors (since both cons cells and vector @@ -283,7 +300,8 @@ Converting an object back from the string is only possible if the object type has a read syntax and the read syntax is preserved by the printing procedure. -@deffn primitive object->string obj [printer] +@deffn {Scheme Procedure} object->string obj [printer] +@deffnx {C Function} scm_object_to_string (obj, printer) Return a Scheme string obtained by printing @var{obj}. Printing function can be specified by the optional second argument @var{printer} (default: @code{write}). diff --git a/doc/ref/script-getopt.texi b/doc/ref/script-getopt.texi index 474394af7..c71dbd205 100644 --- a/doc/ref/script-getopt.texi +++ b/doc/ref/script-getopt.texi @@ -343,7 +343,7 @@ as ordinary argument strings. @node getopt-long Reference @subsection Reference Documentation for @code{getopt-long} -@deffn procedure getopt-long args grammar +@deffn {Scheme Procedure} getopt-long args grammar Parse the command line given in @var{args} (which must be a list of strings) according to the option specification @var{grammar}. @@ -416,7 +416,7 @@ An option predicate fails. @node option-ref Reference @subsection Reference Documentation for @code{option-ref} -@deffn procedure option-ref options key default +@deffn {Scheme Procedure} option-ref options key default Search @var{options} for a command line option named @var{key} and return its value, if found. If the option has no value, but was given, return @code{#t}. If the option was not given, return @var{default}. diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index c620050f0..b115068a0 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -199,24 +199,24 @@ processing procedure, you should also have a look at the sections New lists can be constructed by calling one of the following procedures. -@deffn procedure xcons d a +@deffn {Scheme Procedure} xcons d a Like @code{cons}, but with interchanged arguments. Useful mostly when passed to higher-order procedures. @end deffn -@deffn procedure list-tabulate n init-proc +@deffn {Scheme Procedure} list-tabulate n init-proc Return an @var{n}-element list, where each list element is produced by applying the procedure @var{init-proc} to the corresponding list index. The order in which @var{init-proc} is applied to the indices is not specified. @end deffn -@deffn procedure circular-list elt1 elt2 @dots{} +@deffn {Scheme Procedure} circular-list elt1 elt2 @dots{} Return a circular list containing the given arguments @var{elt1} @var{elt2} @dots{}. @end deffn -@deffn procedure iota count [start step] +@deffn {Scheme Procedure} iota count [start step] Return a list containing @var{count} elements, where each element is calculated as follows: @@ -233,23 +233,23 @@ calculated as follows: The procedures in this section test specific properties of lists. -@deffn procedure proper-list? obj +@deffn {Scheme Procedure} proper-list? obj Return @code{#t} if @var{obj} is a proper list, that is a finite list, terminated with the empty list. Otherwise, return @code{#f}. @end deffn -@deffn procedure circular-list? obj +@deffn {Scheme Procedure} circular-list? obj Return @code{#t} if @var{obj} is a circular list, otherwise return @code{#f}. @end deffn -@deffn procedure dotted-list? obj +@deffn {Scheme Procedure} dotted-list? obj Return @code{#t} if @var{obj} is a dotted list, return @code{#f} otherwise. A dotted list is a finite list which is not terminated by the empty list, but some other value. @end deffn -@deffn procedure null-list? lst +@deffn {Scheme Procedure} null-list? lst Return @code{#t} if @var{lst} is the empty list @code{()}, @code{#f} otherwise. If something else than a proper or circular list is passed as @var{lst}, an error is signalled. This procedure is recommented @@ -257,14 +257,14 @@ for checking for the end of a list in contexts where dotted lists are not allowed. @end deffn -@deffn procedure not-pair? obj +@deffn {Scheme Procedure} not-pair? obj Return @code{#t} is @var{obj} is not a pair, @code{#f} otherwise. This is shorthand notation @code{(not (pair? @var{obj}))} and is supposed to be used for end-of-list checking in contexts where dotted lists are allowed. @end deffn -@deffn procedure list= elt= list1 @dots{} +@deffn {Scheme Procedure} list= elt= list1 @dots{} Return @code{#t} if all argument lists are equal, @code{#f} otherwise. List equality is determined by testing whether all lists have the same length and the corresponding elements are equal in the sense of the @@ -278,42 +278,42 @@ equality predicate @var{elt=}. If no or only one list is given, @c FIXME::martin: Review me! -@deffn procedure first pair -@deffnx procedure second pair -@deffnx procedure third pair -@deffnx procedure fourth pair -@deffnx procedure fifth pair -@deffnx procedure sixth pair -@deffnx procedure seventh pair -@deffnx procedure eighth pair -@deffnx procedure ninth pair -@deffnx procedure tenth pair +@deffn {Scheme Procedure} first pair +@deffnx {Scheme Procedure} second pair +@deffnx {Scheme Procedure} third pair +@deffnx {Scheme Procedure} fourth pair +@deffnx {Scheme Procedure} fifth pair +@deffnx {Scheme Procedure} sixth pair +@deffnx {Scheme Procedure} seventh pair +@deffnx {Scheme Procedure} eighth pair +@deffnx {Scheme Procedure} ninth pair +@deffnx {Scheme Procedure} tenth pair These are synonyms for @code{car}, @code{cadr}, @code{caddr}, @dots{}. @end deffn -@deffn procedure car+cdr pair +@deffn {Scheme Procedure} car+cdr pair Return two values, the @sc{car} and the @sc{cdr} of @var{pair}. @end deffn -@deffn procedure take lst i -@deffnx procedure take! lst i +@deffn {Scheme Procedure} take lst i +@deffnx {Scheme Procedure} take! lst i Return a list containing the first @var{i} elements of @var{lst}. @code{take!} may modify the structure of the argument list @var{lst} in order to produce the result. @end deffn -@deffn procedure drop lst i +@deffn {Scheme Procedure} drop lst i Return a list containing all but the first @var{i} elements of @var{lst}. @end deffn -@deffn procedure take-right lst i +@deffn {Scheme Procedure} take-right lst i Return the a list containing the @var{i} last elements of @var{lst}. @end deffn -@deffn procedure drop-right lst i -@deffnx procedure drop-right! lst i +@deffn {Scheme Procedure} drop-right lst i +@deffnx {Scheme Procedure} drop-right! lst i Return the a list containing all but the @var{i} last elements of @var{lst}. @@ -321,8 +321,8 @@ Return the a list containing all but the @var{i} last elements of @var{lst} in order to produce the result. @end deffn -@deffn procedure split-at lst i -@deffnx procedure split-at! lst i +@deffn {Scheme Procedure} split-at lst i +@deffnx {Scheme Procedure} split-at! lst i Return two values, a list containing the first @var{i} elements of the list @var{lst} and a list containing the remaining elements. @@ -330,7 +330,7 @@ list @var{lst} and a list containing the remaining elements. @var{lst} in order to produce the result. @end deffn -@deffn procedure last lst +@deffn {Scheme Procedure} last lst Return the last element of the non-empty, finite list @var{lst}. @end deffn @@ -340,21 +340,21 @@ Return the last element of the non-empty, finite list @var{lst}. @c FIXME::martin: Review me! -@deffn procedure length+ lst +@deffn {Scheme Procedure} length+ lst Return the length of the argument list @var{lst}. When @var{lst} is a circular list, @code{#f} is returned. @end deffn -@deffn procedure concatenate list-of-lists -@deffnx procedure concatenate! list-of-lists +@deffn {Scheme Procedure} concatenate list-of-lists +@deffnx {Scheme Procedure} concatenate! list-of-lists Construct a list by appending all lists in @var{list-of-lists}. @code{concatenate!} may modify the structure of the given lists in order to produce the result. @end deffn -@deffn procedure append-reverse rev-head tail -@deffnx procedure append-reverse! rev-head tail +@deffn {Scheme Procedure} append-reverse rev-head tail +@deffnx {Scheme Procedure} append-reverse! rev-head tail Reverse @var{rev-head}, append @var{tail} and return the result. This is equivalent to @code{(append (reverse @var{rev-head}) @var{tail})}, but more efficient. @@ -363,18 +363,18 @@ but more efficient. the result. @end deffn -@deffn procedure zip lst1 lst2 @dots{} +@deffn {Scheme Procedure} zip lst1 lst2 @dots{} Return a list as long as the shortest of the argument lists, where each element is a list. The first list contains the first elements of the argument lists, the second list contains the second elements, and so on. @end deffn -@deffn procedure unzip1 lst -@deffnx procedure unzip2 lst -@deffnx procedure unzip3 lst -@deffnx procedure unzip4 lst -@deffnx procedure unzip5 lst +@deffn {Scheme Procedure} unzip1 lst +@deffnx {Scheme Procedure} unzip2 lst +@deffnx {Scheme Procedure} unzip3 lst +@deffnx {Scheme Procedure} unzip4 lst +@deffnx {Scheme Procedure} unzip5 lst @code{unzip1} takes a list of lists, and returns a list containing the first elements of each list, @code{unzip2} returns two lists, the first containing the first elements of each lists and the second @@ -387,7 +387,7 @@ containing the second elements of each lists, and so on. @c FIXME::martin: Review me! -@deffn procedure fold kons knil lst1 lst2 @dots{} +@deffn {Scheme Procedure} fold kons knil lst1 lst2 @dots{} Fold the procedure @var{kons} across all elements of @var{lst1}, @var{lst2}, @dots{}. Produce the result of @@ -398,7 +398,7 @@ if @var{enm} are the elements of the lists @var{lst1}, @var{lst2}, @dots{}. @end deffn -@deffn procedure fold-right kons knil lst1 lst2 @dots{} +@deffn {Scheme Procedure} fold-right kons knil lst1 lst2 @dots{} Similar to @code{fold}, but applies @var{kons} in right-to-left order to the list elements, that is: @@ -406,27 +406,27 @@ to the list elements, that is: @var{e22} @dots{} (@var{kons} @var{en1} @var{en2} @var{knil})))}, @end deffn -@deffn procedure pair-fold kons knil lst1 lst2 @dots{} +@deffn {Scheme Procedure} pair-fold kons knil lst1 lst2 @dots{} Like @code{fold}, but apply @var{kons} to the pairs of the list instead of the list elements. @end deffn -@deffn procedure pair-fold-right kons knil lst1 lst2 @dots{} +@deffn {Scheme Procedure} pair-fold-right kons knil lst1 lst2 @dots{} Like @code{fold-right}, but apply @var{kons} to the pairs of the list instead of the list elements. @end deffn -@deffn procedure reduce f ridentity lst +@deffn {Scheme Procedure} reduce f ridentity lst @code{reduce} is a variant of @code{reduce}. If @var{lst} is @code{()}, @var{ridentity} is returned. Otherwise, @code{(fold (car @var{lst}) (cdr @var{lst}))} is returned. @end deffn -@deffn procedure reduce-right f ridentity lst +@deffn {Scheme Procedure} reduce-right f ridentity lst This is the @code{fold-right} variant of @var{reduce}. @end deffn -@deffn procedure unfold p f g seed [tail-gen] +@deffn {Scheme Procedure} unfold p f g seed [tail-gen] @code{unfold} is defined as follows: @lisp @@ -458,7 +458,7 @@ elements by @var{f}. These elements are put into a list in left-to-right order, and @var{p} tells when to stop unfolding. @end deffn -@deffn procedure unfold-right p f g seed [tail] +@deffn {Scheme Procedure} unfold-right p f g seed [tail] Construct a list with the following loop. @lisp @@ -487,7 +487,7 @@ Creates the tail of the list; defaults to @code{(lambda (x) '())}. @end deffn -@deffn procedure map f lst1 lst2 @dots{} +@deffn {Scheme Procedure} map f lst1 lst2 @dots{} Map the procedure over the list(s) @var{lst1}, @var{lst2}, @dots{} and return a list containing the results of the procedure applications. This procedure is extended with respect to R5RS, because the argument @@ -496,7 +496,7 @@ length as the shortest argument lists. The order in which @var{f} will be applied to the list element(s) is not specified. @end deffn -@deffn procedure for-each f lst1 lst2 @dots{} +@deffn {Scheme Procedure} for-each f lst1 lst2 @dots{} Apply the procedure @var{f} to each pair of corresponding elements of the list(s) @var{lst1}, @var{lst2}, @dots{}. The return value is not specified. This procedure is extended with respect to R5RS, because @@ -506,8 +506,8 @@ be applied to tge list elements in left-to-right order. @end deffn -@deffn procedure append-map f lst1 lst2 @dots{} -@deffnx procedure append-map! f lst1 lst2 @dots{} +@deffn {Scheme Procedure} append-map f lst1 lst2 @dots{} +@deffnx {Scheme Procedure} append-map! f lst1 lst2 @dots{} Equivalent to @lisp @@ -530,7 +530,7 @@ The dynamic order in which the various applications of @var{f} are made is not specified. @end deffn -@deffn procedure map! f lst1 lst2 @dots{} +@deffn {Scheme Procedure} map! f lst1 lst2 @dots{} Linear-update variant of @code{map} -- @code{map!} is allowed, but not required, to alter the cons cells of @var{lst1} to construct the result list. @@ -540,13 +540,13 @@ made is not specified. In the n-ary case, @var{lst2}, @var{lst3}, @dots{} must have at least as many elements as @var{lst1}. @end deffn -@deffn procedure pair-for-each f lst1 lst2 @dots{} +@deffn {Scheme Procedure} pair-for-each f lst1 lst2 @dots{} Like @code{for-each}, but applies the procedure @var{f} to the pairs from which the argument lists are constructed, instead of the list elements. The return value is not specified. @end deffn -@deffn procedure filter-map f lst1 lst2 @dots{} +@deffn {Scheme Procedure} filter-map f lst1 lst2 @dots{} Like @code{map}, but only results from the applications of @var{f} which are true are saved in the result list. @end deffn @@ -562,8 +562,8 @@ specific condition. Partitioning a list means to make two groups of list elements, one which contains the elements satisfying a condition, and the other for the elements which don't. -@deffn procedure filter pred lst -@deffnx procedure filter! pred lst +@deffn {Scheme Procedure} filter pred lst +@deffnx {Scheme Procedure} filter! pred lst Return a list containing all elements from @var{lst} which satisfy the predicate @var{pred}. The elements in the result list have the same order as in @var{lst}. The order in which @var{pred} is applied to @@ -572,8 +572,8 @@ the list elements is not specified. @code{filter!} is allowed, but not required to modify the structure of @end deffn -@deffn procedure partition pred lst -@deffnx procedure partition! pred lst +@deffn {Scheme Procedure} partition pred lst +@deffnx {Scheme Procedure} partition! pred lst Return two lists, one containing all elements from @var{lst} which satisfy the predicate @var{pred}, and one list containing the elements which do not satisfy the predicated. The elements in the result lists @@ -584,8 +584,8 @@ applied to the list elements is not specified. the input list. @end deffn -@deffn procedure remove pred lst -@deffnx procedure remove! pred lst +@deffn {Scheme Procedure} remove pred lst +@deffnx {Scheme Procedure} remove! pred lst Return a list containing all elements from @var{lst} which do not satisfy the predicate @var{pred}. The elements in the result list have the same order as in @var{lst}. The order in which @var{pred} is @@ -605,18 +605,18 @@ The procedures for searching elements in lists either accept a predicate or a comparison object for determining which elements are to be searched. -@deffn procedure find pred lst +@deffn {Scheme Procedure} find pred lst Return the first element of @var{lst} which satisfies the predicate @var{pred} and @code{#f} if no such element is found. @end deffn -@deffn procedure find-tail pred lst +@deffn {Scheme Procedure} find-tail pred lst Return the first pair of @var{lst} whose @sc{car} satisfies the predicate @var{pred} and @code{#f} if no such element is found. @end deffn -@deffn procedure take-while pred lst -@deffnx procedure take-while! pred lst +@deffn {Scheme Procedure} take-while pred lst +@deffnx {Scheme Procedure} take-while! pred lst Return the longest initial prefix of @var{lst} whose elements all satisfy the predicate @var{pred}. @@ -624,15 +624,15 @@ satisfy the predicate @var{pred}. list while producing the result. @end deffn -@deffn procedure drop-while pred lst +@deffn {Scheme Procedure} drop-while pred lst Drop the longest initial prefix of @var{lst} whose elements all satisfy the predicate @var{pred}. @end deffn -@deffn procedure span pred lst -@deffnx procedure span! pred lst -@deffnx procedure break pred lst -@deffnx procedure break! pred lst +@deffn {Scheme Procedure} span pred lst +@deffnx {Scheme Procedure} span! pred lst +@deffnx {Scheme Procedure} break pred lst +@deffnx {Scheme Procedure} break! pred lst @code{span} splits the list @var{lst} into the longest initial prefix whose elements all satisfy the predicate @var{pred}, and the remaining tail. @code{break} inverts the sense of the predicate. @@ -642,25 +642,25 @@ the structure of the input list @var{lst} in order to produce the result. @end deffn -@deffn procedure any pred lst1 lst2 @dots{} +@deffn {Scheme Procedure} any pred lst1 lst2 @dots{} Apply @var{pred} across the lists and return a true value if the predicate returns true for any of the list elements(s); return @code{#f} otherwise. The true value returned is always the result of the first succesful application of @var{pred}. @end deffn -@deffn procedure every pred lst1 lst2 @dots{} +@deffn {Scheme Procedure} every pred lst1 lst2 @dots{} Apply @var{pred} across the lists and return a true value if the predicate returns true for every of the list elements(s); return @code{#f} otherwise. The true value returned is always the result of the final succesful application of @var{pred}. @end deffn -@deffn procedure list-index pred lst1 lst2 @dots{} +@deffn {Scheme Procedure} list-index pred lst1 lst2 @dots{} Return the index of the leftmost element that satisfies @var{pred}. @end deffn -@deffn procedure member x lst [=] +@deffn {Scheme Procedure} member x lst [=] Return the first sublist of @var{lst} whose @sc{car} is equal to @var{x}. If @var{x} does no appear in @var{lst}, return @code{#f}. Equality is determined by the equality predicate @var{=}, or @@ -677,8 +677,8 @@ The procedures for deleting elements from a list either accept a predicate or a comparison object for determining which elements are to be removed. -@deffn procedure delete x lst [=] -@deffnx procedure delete! x lst [=] +@deffn {Scheme Procedure} delete x lst [=] +@deffnx {Scheme Procedure} delete! x lst [=] Return a list containing all elements from @var{lst}, but without the elements equal to @var{x}. Equality is determined by the equality predicate @var{=}, which defaults to @code{equal?} if not given. @@ -687,8 +687,8 @@ predicate @var{=}, which defaults to @code{equal?} if not given. the argument list in order to produce the result. @end deffn -@deffn procedure delete-duplicates lst [=] -@deffnx procedure delete-duplicates! lst [=] +@deffn {Scheme Procedure} delete-duplicates lst [=] +@deffnx {Scheme Procedure} delete-duplicates! lst [=] Return a list containing all elements from @var{lst}, but without duplicate elements. Equality of elements is determined by the equality predicate @var{=}, which defaults to @code{equal?} if not @@ -708,13 +708,13 @@ Association lists are described in detail in section @ref{Association Lists}. The present section only documents the additional procedures for dealing with association lists defined by SRFI-1. -@deffn procedure assoc key alist [=] +@deffn {Scheme Procedure} assoc key alist [=] Return the pair from @var{alist} which matches @var{key}. Equality is determined by @var{=}, which defaults to @code{equal?} if not given. @var{alist} must be an association lists---a list of pairs. @end deffn -@deffn procedure alist-cons key datum alist +@deffn {Scheme Procedure} alist-cons key datum alist Equivalent to @lisp @@ -725,13 +725,13 @@ This procedure is used to coons a new pair onto an existing association list. @end deffn -@deffn procedure alist-copy alist +@deffn {Scheme Procedure} alist-copy alist Return a newly allocated copy of @var{alist}, that means that the spine of the list as well as the pairs are copied. @end deffn -@deffn procedure alist-delete key alist [=] -@deffnx procedure alist-delete! key alist [=] +@deffn {Scheme Procedure} alist-delete key alist [=] +@deffnx {Scheme Procedure} alist-delete! key alist [=] Return a list containing the pairs of @var{alist}, but without the pairs whose @sc{cars} are equal to @var{key}. Equality is determined by @var{=}, which defaults to @code{equal?} if not given. @@ -759,43 +759,43 @@ All these procedures accept an equality predicate as the first argument. This predicate is used for testing the objects in the list sets for sameness. -@deffn procedure lset<= = list1 @dots{} +@deffn {Scheme Procedure} lset<= = list1 @dots{} Return @code{#t} if every @var{listi} is a subset of @var{listi+1}, otherwise return @code{#f}. Returns @code{#t} if called with less than two arguments. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset= = list1 list2 @dots{} +@deffn {Scheme Procedure} lset= = list1 list2 @dots{} Return @code{#t} if all argument lists are equal. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset-adjoin = list elt1 @dots{} -@deffnx procedure lset-adjoin! = list elt1 @dots{} +@deffn {Scheme Procedure} lset-adjoin = list elt1 @dots{} +@deffnx {Scheme Procedure} lset-adjoin! = list elt1 @dots{} Add all @var{elts} to the list @var{list}, suppressing duplicates and return the resulting list. @code{lset-adjoin!} is allowed, but not required to modify its first argument. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset-union = list1 @dots{} -@deffnx procedure lset-union! = list1 @dots{} +@deffn {Scheme Procedure} lset-union = list1 @dots{} +@deffnx {Scheme Procedure} lset-union! = list1 @dots{} Return the union of all argument list sets. The union is the set of all elements which appear in any of the argument sets. @code{lset-union!} is allowed, but not required to modify its first argument. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset-intersection = list1 list2 @dots{} -@deffnx procedure lset-intersection! = list1 list2 @dots{} +@deffn {Scheme Procedure} lset-intersection = list1 list2 @dots{} +@deffnx {Scheme Procedure} lset-intersection! = list1 list2 @dots{} Return the intersection of all argument list sets. The intersection is the set containing all elements which appear in all argument sets. @code{lset-intersection!} is allowed, but not required to modify its first argument. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset-difference = list1 list2 @dots{} -@deffnx procedure lset-difference! = list1 list2 @dots{} +@deffn {Scheme Procedure} lset-difference = list1 list2 @dots{} +@deffnx {Scheme Procedure} lset-difference! = list1 list2 @dots{} Return the difference of all argument list sets. The difference is the the set containing all elements of the first list which do not appear in the other lists. @code{lset-difference!} is allowed, but @@ -803,8 +803,8 @@ not required to modify its first argument. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset-xor = list1 @dots{} -@deffnx procedure lset-xor! = list1 @dots{} +@deffn {Scheme Procedure} lset-xor = list1 @dots{} +@deffnx {Scheme Procedure} lset-xor! = list1 @dots{} Return the set containing all elements which appear in the first argument list set, but not in the second; or, more generally: which appear in an odd number of sets. @code{lset-xor!} is allowed, but @@ -812,8 +812,8 @@ not required to modify its first argument. @var{=} is used for testing element equality. @end deffn -@deffn procedure lset-diff+intersection = list1 list2 @dots{} -@deffnx procedure lset-diff+intersection! = list1 list2 @dots{} +@deffn {Scheme Procedure} lset-diff+intersection = list1 list2 @dots{} +@deffnx {Scheme Procedure} lset-diff+intersection! = list1 list2 @dots{} Return two values, the difference and the intersection of the argument list sets. This works like a combination of @code{lset-difference} and @code{lset-intersection}, but is more efficient. @@ -939,42 +939,42 @@ For example, you can use the procedures @code{u8vector?}, @code{make-s8vector}, @code{u16vector}, @code{u32vector-length}, @code{s64vector-ref}, @code{f32vector-set!} or @code{f64vector->list}. -@deffn primitive TAGvector? obj +@deffn {Scheme Procedure} TAGvector? obj Return @code{#t} if @var{obj} is a homogeneous numeric vector of type @code{TAG}. @end deffn -@deffn primitive make-TAGvector n [value] +@deffn {Scheme Procedure} make-TAGvector n [value] Create a newly allocated homogeneous numeric vector of type @code{TAG}, which can hold @var{n} elements. If @var{value} is given, the vector is initialized with the value, otherwise, the contents of the returned vector is not specified. @end deffn -@deffn primitive TAGvector value1 @dots{} +@deffn {Scheme Procedure} TAGvector value1 @dots{} Create a newly allocated homogeneous numeric vector of type @code{TAG}. The returned vector is as long as the number of arguments given, and is initialized with the argument values. @end deffn -@deffn primitive TAGvector-length TAGvec +@deffn {Scheme Procedure} TAGvector-length TAGvec Return the number of elements in @var{TAGvec}. @end deffn -@deffn primitive TAGvector-ref TAGvec i +@deffn {Scheme Procedure} TAGvector-ref TAGvec i Return the element at index @var{i} in @var{TAGvec}. @end deffn -@deffn primitive TAGvector-ref TAGvec i value +@deffn {Scheme Procedure} TAGvector-ref TAGvec i value Set the element at index @var{i} in @var{TAGvec} to @var{value}. The return value is not specified. @end deffn -@deffn primitive TAGvector->list TAGvec +@deffn {Scheme Procedure} TAGvector->list TAGvec Return a newly allocated list holding all elements of @var{TAGvec}. @end deffn -@deffn primitive list->TAGvector lst +@deffn {Scheme Procedure} list->TAGvector lst Return a newly allocated homogeneous numeric vector of type @code{TAG}, initialized with the elements of the list @var{lst}. @end deffn @@ -1079,7 +1079,7 @@ Example: Please note the quote before the @code{#,(file ...)} expression. This is necessary because ports are not self-evaluating in Guile. -@deffn procedure define-reader-ctor symbol proc +@deffn {Scheme Procedure} define-reader-ctor symbol proc Define @var{proc} as the reader constructor for hash-comma forms with a tag @var{symbol}. @var{proc} will be applied to the datum(s) following the tag in the hash-comma expression after the complete form has been @@ -1196,7 +1196,7 @@ In addition to the primitives @code{string?} and @code{string-null?}, which are already in the Guile core, the string predicates @code{string-any} and @code{string-every} are defined by SRFI-13. -@deffn primitive string-any pred s [start end] +@deffn {Scheme Procedure} string-any pred s [start end] Check if the predicate @var{pred} is true for any character in the string @var{s}, proceeding from left (index @var{start}) to right (index @var{end}). If @code{string-any} returns true, @@ -1204,7 +1204,7 @@ the returned true value is the one produced by the first successful application of @var{pred}. @end deffn -@deffn primitive string-every pred s [start end] +@deffn {Scheme Procedure} string-every pred s [start end] Check if the predicate @var{pred} is true for every character in the string @var{s}, proceeding from left (index @var{start}) to right (index @var{end}). If @code{string-every} returns @@ -1222,7 +1222,7 @@ SRFI-13 defines several procedures for constructing new strings. In addition to @code{make-string} and @code{string} (available in the Guile core library), the procedure @code{string-tabulate} does exist. -@deffn primitive string-tabulate proc len +@deffn {Scheme Procedure} string-tabulate proc len @var{proc} is an integer->char procedure. Construct a string of size @var{len} by applying @var{proc} to each index to produce the corresponding string element. The order in which @@ -1241,11 +1241,11 @@ The Guile core already contains the procedure @code{list->string} for converting a list of characters into a string (@pxref{List/String Conversion}). -@deffn primitive string->list str [start end] +@deffn {Scheme Procedure} string->list str [start end] Convert the string @var{str} into a list of characters. @end deffn -@deffn primitive reverse-list->string chrs +@deffn {Scheme Procedure} reverse-list->string chrs An efficient implementation of @code{(compose string->list reverse)}: @@ -1254,7 +1254,7 @@ reverse)}: @end smalllisp @end deffn -@deffn primitive string-join ls [delimiter grammar] +@deffn {Scheme Procedure} string-join ls [delimiter grammar] Append the string in the string list @var{ls}, using the string @var{delim} as a delimiter between the elements of @var{ls}. @var{grammar} is a symbol which specifies how the delimiter is @@ -1294,18 +1294,18 @@ Additional selector procedures are documented in the Strings section @code{string-copy} is also available in core Guile, but this version accepts additional start/end indices. -@deffn primitive string-copy str [start end] +@deffn {Scheme Procedure} string-copy str [start end] Return a freshly allocated copy of the string @var{str}. If given, @var{start} and @var{end} delimit the portion of @var{str} which is copied. @end deffn -@deffn primitive substring/shared str start [end] +@deffn {Scheme Procedure} substring/shared str start [end] Like @code{substring}, but the result may share memory with the argument @var{str}. @end deffn -@deffn primitive string-copy! target tstart s [start end] +@deffn {Scheme Procedure} string-copy! target tstart s [start end] Copy the sequence of characters from index range [@var{start}, @var{end}) in string @var{s} to string @var{target}, beginning at index @var{tstart}. The characters are copied left-to-right @@ -1315,27 +1315,27 @@ error if the copy operation runs off the end of the target string. @end deffn -@deffn primitive string-take s n -@deffnx primitive string-take-right s n +@deffn {Scheme Procedure} string-take s n +@deffnx {Scheme Procedure} string-take-right s n Return the @var{n} first/last characters of @var{s}. @end deffn -@deffn primitive string-drop s n -@deffnx primitive string-drop-right s n +@deffn {Scheme Procedure} string-drop s n +@deffnx {Scheme Procedure} string-drop-right s n Return all but the first/last @var{n} characters of @var{s}. @end deffn -@deffn primitive string-pad s len [chr start end] -@deffnx primitive string-pad-right s len [chr start end] +@deffn {Scheme Procedure} string-pad s len [chr start end] +@deffnx {Scheme Procedure} string-pad-right s len [chr start end] Take that characters from @var{start} to @var{end} from the string @var{s} and return a new string, right(left)-padded by the character @var{chr} to length @var{len}. If the resulting string is longer than @var{len}, it is truncated on the right (left). @end deffn -@deffn primitive string-trim s [char_pred start end] -@deffnx primitive string-trim-right s [char_pred start end] -@deffnx primitive string-trim-both s [char_pred start end] +@deffn {Scheme Procedure} string-trim s [char_pred start end] +@deffnx {Scheme Procedure} string-trim-right s [char_pred start end] +@deffnx {Scheme Procedure} string-trim-both s [char_pred start end] Trim @var{s} by skipping over all characters on the left/right/both sides of the string that satisfy the parameter @var{char_pred}: @@ -1368,7 +1368,7 @@ of the same name in the Guile core. The second modification procedure @code{string-set!} is documented in the Strings section (@pxref{String Modification}). -@deffn primitive string-fill! str chr [start end] +@deffn {Scheme Procedure} string-fill! str chr [start end] Stores @var{chr} in every element of the given @var{str} and returns an unspecified value. @end deffn @@ -1387,8 +1387,8 @@ index in the case of a true return value. @code{string-hash} and @code{string-hash-ci} are for calculating hash values for strings, useful for implementing fast lookup mechanisms. -@deffn primitive string-compare s1 s2 proc_lt proc_eq proc_gt [start1 end1 start2 end2] -@deffnx primitive string-compare-ci s1 s2 proc_lt proc_eq proc_gt [start1 end1 start2 end2] +@deffn {Scheme Procedure} string-compare s1 s2 proc_lt proc_eq proc_gt [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-compare-ci s1 s2 proc_lt proc_eq proc_gt [start1 end1 start2 end2] Apply @var{proc_lt}, @var{proc_eq}, @var{proc_gt} to the mismatch index, depending upon whether @var{s1} is less than, equal to, or greater than @var{s2}. The mismatch index is the @@ -1398,30 +1398,30 @@ largest index @var{i} such that for every 0 <= @var{j} < character comparison is done case-insensitively. @end deffn -@deffn primitive string= s1 s2 [start1 end1 start2 end2] -@deffnx primitive string<> s1 s2 [start1 end1 start2 end2] -@deffnx primitive string< s1 s2 [start1 end1 start2 end2] -@deffnx primitive string> s1 s2 [start1 end1 start2 end2] -@deffnx primitive string<= s1 s2 [start1 end1 start2 end2] -@deffnx primitive string>= s1 s2 [start1 end1 start2 end2] +@deffn {Scheme Procedure} string= s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string<> s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string< s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string> s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string<= s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string>= s1 s2 [start1 end1 start2 end2] Compare @var{s1} and @var{s2} and return @code{#f} if the predicate fails. Otherwise, the mismatch index is returned (or @var{end1} in the case of @code{string=}. @end deffn -@deffn primitive string-ci= s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-ci<> s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-ci< s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-ci> s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-ci<= s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-ci>= s1 s2 [start1 end1 start2 end2] +@deffn {Scheme Procedure} string-ci= s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-ci<> s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-ci< s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-ci> s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-ci<= s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-ci>= s1 s2 [start1 end1 start2 end2] Compare @var{s1} and @var{s2} and return @code{#f} if the predicate fails. Otherwise, the mismatch index is returned (or @var{end1} in the case of @code{string=}. These are the case-insensitive variants. @end deffn -@deffn primitive string-hash s [bound start end] -@deffnx primitive string-hash-ci s [bound start end] +@deffn {Scheme Procedure} string-hash s [bound start end] +@deffnx {Scheme Procedure} string-hash-ci s [bound start end] Return a hash value of the string @var{s} in the range 0 @dots{} @var{bound} - 1. @code{string-hash-ci} is the case-insensitive variant. @end deffn @@ -1436,19 +1436,19 @@ Using these procedures you can determine whether a given string is a prefix or suffix of another string or how long a common prefix/suffix is. -@deffn primitive string-prefix-length s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-prefix-length-ci s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-suffix-length s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-suffix-length-ci s1 s2 [start1 end1 start2 end2] +@deffn {Scheme Procedure} string-prefix-length s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-prefix-length-ci s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-suffix-length s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-suffix-length-ci s1 s2 [start1 end1 start2 end2] Return the length of the longest common prefix/suffix of the two strings. @code{string-prefix-length-ci} and @code{string-suffix-length-ci} are the case-insensitive variants. @end deffn -@deffn primitive string-prefix? s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-prefix-ci? s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-suffix? s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-suffix-ci? s1 s2 [start1 end1 start2 end2] +@deffn {Scheme Procedure} string-prefix? s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-prefix-ci? s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-suffix? s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-suffix-ci? s1 s2 [start1 end1 start2 end2] Is @var{s1} a prefix/suffix of @var{s2}. @code{string-prefix-ci?} and @code{string-suffix-ci?} are the case-insensitive variants. @end deffn @@ -1462,8 +1462,8 @@ Is @var{s1} a prefix/suffix of @var{s2}. @code{string-prefix-ci?} and Use these procedures to find out whether a string contains a given character or a given substring, or a character from a set of characters. -@deffn primitive string-index s char_pred [start end] -@deffnx primitive string-index-right s char_pred [start end] +@deffn {Scheme Procedure} string-index s char_pred [start end] +@deffnx {Scheme Procedure} string-index-right s char_pred [start end] Search through the string @var{s} from left to right (right to left), returning the index of the first (last) occurence of a character which @@ -1480,8 +1480,8 @@ is in the set @var{char_pred}, if it is a character set. @end itemize @end deffn -@deffn primitive string-skip s char_pred [start end] -@deffnx primitive string-skip-right s char_pred [start end] +@deffn {Scheme Procedure} string-skip s char_pred [start end] +@deffnx {Scheme Procedure} string-skip-right s char_pred [start end] Search through the string @var{s} from left to right (right to left), returning the index of the first (last) occurence of a character which @@ -1498,7 +1498,7 @@ is not in the set if @var{char_pred} is a character set. @end itemize @end deffn -@deffn primitive string-count s char_pred [start end] +@deffn {Scheme Procedure} string-count s char_pred [start end] Return the count of the number of characters in the string @var{s} which @@ -1514,8 +1514,8 @@ is in the set @var{char_pred}, if it is a character set. @end itemize @end deffn -@deffn primitive string-contains s1 s2 [start1 end1 start2 end2] -@deffnx primitive string-contains-ci s1 s2 [start1 end1 start2 end2] +@deffn {Scheme Procedure} string-contains s1 s2 [start1 end1 start2 end2] +@deffnx {Scheme Procedure} string-contains-ci s1 s2 [start1 end1 start2 end2] Does string @var{s1} contain string @var{s2}? Return the index in @var{s1} where @var{s2} occurs as a substring, or false. The optional start/end indices restrict the operation to the @@ -1534,20 +1534,20 @@ These procedures convert the alphabetic case of strings. They are similar to the procedures in the Guile core, but are extended to handle optional start/end indices. -@deffn primitive string-upcase s [start end] -@deffnx primitive string-upcase! s [start end] +@deffn {Scheme Procedure} string-upcase s [start end] +@deffnx {Scheme Procedure} string-upcase! s [start end] Upcase every character in @var{s}. @code{string-upcase!} is the side-effecting variant. @end deffn -@deffn primitive string-downcase s [start end] -@deffnx primitive string-downcase! s [start end] +@deffn {Scheme Procedure} string-downcase s [start end] +@deffnx {Scheme Procedure} string-downcase! s [start end] Downcase every character in @var{s}. @code{string-downcase!} is the side-effecting variant. @end deffn -@deffn primitive string-titlecase s [start end] -@deffnx primitive string-titlecase! s [start end] +@deffn {Scheme Procedure} string-titlecase s [start end] +@deffnx {Scheme Procedure} string-titlecase! s [start end] Upcase every first character in every word in @var{s}, downcase the other characters. @code{string-titlecase!} is the side-effecting variant. @@ -1562,8 +1562,8 @@ variant. One appending procedure, @code{string-append} is the same in R5RS and in SRFI-13, so it is not redefined. -@deffn primitive string-reverse str [start end] -@deffnx primitive string-reverse! str [start end] +@deffn {Scheme Procedure} string-reverse str [start end] +@deffnx {Scheme Procedure} string-reverse! str [start end] Reverse the string @var{str}. The optional arguments @var{start} and @var{end} delimit the region of @var{str} to operate on. @@ -1572,23 +1572,23 @@ operate on. unspecified value. @end deffn -@deffn primitive string-append/shared ls @dots{} +@deffn {Scheme Procedure} string-append/shared ls @dots{} Like @code{string-append}, but the result may share memory with the argument strings. @end deffn -@deffn primitive string-concatenate ls +@deffn {Scheme Procedure} string-concatenate ls Append the elements of @var{ls} (which must be strings) together into a single string. Guaranteed to return a freshly allocated string. @end deffn -@deffn primitive string-concatenate/shared ls +@deffn {Scheme Procedure} string-concatenate/shared ls Like @code{string-concatenate}, but the result may share memory with the strings in the list @var{ls}. @end deffn -@deffn primitive string-concatenate-reverse ls final_string end +@deffn {Scheme Procedure} string-concatenate-reverse ls final_string end Without optional arguments, this procedure is equivalent to @smalllisp @@ -1604,7 +1604,7 @@ is given, only the characters of @var{final_string} up to index Guaranteed to return a freshly allocated string. @end deffn -@deffn primitive string-concatenate-reverse/shared ls final_string end +@deffn {Scheme Procedure} string-concatenate-reverse/shared ls final_string end Like @code{string-concatenate-reverse}, but the result may share memory with the the strings in the @var{ls} arguments. @end deffn @@ -1619,29 +1619,29 @@ share memory with the the strings in the @var{ls} arguments. the characters a string is composed of. The fold and unfold procedures are list iterators and constructors. -@deffn primitive string-map proc s [start end] +@deffn {Scheme Procedure} string-map proc s [start end] @var{proc} is a char->char procedure, it is mapped over @var{s}. The order in which the procedure is applied to the string elements is not specified. @end deffn -@deffn primitive string-map! proc s [start end] +@deffn {Scheme Procedure} string-map! proc s [start end] @var{proc} is a char->char procedure, it is mapped over @var{s}. The order in which the procedure is applied to the string elements is not specified. The string @var{s} is modified in-place, the return value is not specified. @end deffn -@deffn primitive string-fold kons knil s [start end] -@deffnx primitive string-fold-right kons knil s [start end] +@deffn {Scheme Procedure} string-fold kons knil s [start end] +@deffnx {Scheme Procedure} string-fold-right kons knil s [start end] Fold @var{kons} over the characters of @var{s}, with @var{knil} as the terminating element, from left to right (or right to left, for @code{string-fold-right}). @var{kons} must expect two arguments: The actual character and the last result of @var{kons}' application. @end deffn -@deffn primitive string-unfold p f g seed [base make_final] -@deffnx primitive string-unfold-right p f g seed [base make_final] +@deffn {Scheme Procedure} string-unfold p f g seed [base make_final] +@deffnx {Scheme Procedure} string-unfold-right p f g seed [base make_final] These are the fundamental string constructors. @itemize @bullet @item @var{g} is used to generate a series of @emph{seed} @@ -1662,7 +1662,7 @@ value (on which @var{p} returns true) to produce the final/rightmost @end itemize @end deffn -@deffn primitive string-for-each proc s [start end] +@deffn {Scheme Procedure} string-for-each proc s [start end] @var{proc} is mapped over @var{s} in left-to-right order. The return value is not specified. @end deffn @@ -1684,7 +1684,7 @@ consider this code fragment, which replicates the input string "foofoo" @end lisp -@deffn primitive xsubstring s from [to start end] +@deffn {Scheme Procedure} xsubstring s from [to start end] This is the @emph{extended substring} procedure that implements replicated copying of a substring of some string. @@ -1697,7 +1697,7 @@ beginning at index @var{from}, and ending at @var{to}, which defaults to @var{from} + (@var{end} - @var{start}). @end deffn -@deffn primitive string-xcopy! target tstart s sfrom [sto start end] +@deffn {Scheme Procedure} string-xcopy! target tstart s sfrom [sto start end] Exactly the same as @code{xsubstring}, but the extracted text is written into the string @var{target} starting at index @var{tstart}. The operation is not defined if @code{(eq? @@ -1715,13 +1715,13 @@ cannot copy a string on top of itself. another string and @code{string-tokenize} splits a string into a list of strings, breaking it up at a specified character. -@deffn primitive string-replace s1 s2 [start1 end1 start2 end2] +@deffn {Scheme Procedure} string-replace s1 s2 [start1 end1 start2 end2] Return the string @var{s1}, but with the characters @var{start1} @dots{} @var{end1} replaced by the characters @var{start2} @dots{} @var{end2} from @var{s2}. @end deffn -@deffn primitive string-tokenize s [token_char start end] +@deffn {Scheme Procedure} string-tokenize s [token_char start end] Split the string @var{s} into a list of substrings, where each substring is a maximal non-empty contiguous sequence of characters equal to the character @var{token_char}, or @@ -1739,7 +1739,7 @@ token borders. @dfn{Filtering} means to remove all characters from a string which do not match a given criteria, @dfn{deleting} means the opposite. -@deffn primitive string-filter s char_pred [start end] +@deffn {Scheme Procedure} string-filter s char_pred [start end] Filter the string @var{s}, retaining only those characters that satisfy the @var{char_pred} argument. If the argument is a procedure, it is applied to each character as a predicate, if @@ -1747,7 +1747,7 @@ it is a character, it is tested for equality and if it is a character set, it is tested for membership. @end deffn -@deffn primitive string-delete s char_pred [start end] +@deffn {Scheme Procedure} string-delete s char_pred [start end] Filter the string @var{s}, retaining only those characters that do not satisfy the @var{char_pred} argument. If the argument is a procedure, it is applied to each character as a predicate, @@ -1823,21 +1823,21 @@ or whether several character sets are equal or subsets of each other. @code{char-set-hash} can be used for calculating a hash value, maybe for usage in fast lookup procedures. -@deffn primitive char-set? obj +@deffn {Scheme Procedure} char-set? obj Return @code{#t} if @var{obj} is a character set, @code{#f} otherwise. @end deffn -@deffn primitive char-set= cs1 @dots{} +@deffn {Scheme Procedure} char-set= cs1 @dots{} Return @code{#t} if all given character sets are equal. @end deffn -@deffn primitive char-set<= cs1 @dots{} +@deffn {Scheme Procedure} char-set<= cs1 @dots{} Return @code{#t} if every character set @var{cs}i is a subset of character set @var{cs}i+1. @end deffn -@deffn primitive char-set-hash cs [bound] +@deffn {Scheme Procedure} char-set-hash cs [bound] Compute a hash value for the character set @var{cs}. If @var{bound} is given and not @code{#f}, it restricts the returned value to the range 0 @dots{} @var{bound - 1}. @@ -1859,34 +1859,34 @@ element of the set can be checked with @code{end-of-char-set?}. Additionally, mapping and (un-)folding procedures for character sets are provided. -@deffn primitive char-set-cursor cs +@deffn {Scheme Procedure} char-set-cursor cs Return a cursor into the character set @var{cs}. @end deffn -@deffn primitive char-set-ref cs cursor +@deffn {Scheme Procedure} char-set-ref cs cursor Return the character at the current cursor position @var{cursor} in the character set @var{cs}. It is an error to pass a cursor for which @code{end-of-char-set?} returns true. @end deffn -@deffn primitive char-set-cursor-next cs cursor +@deffn {Scheme Procedure} char-set-cursor-next cs cursor Advance the character set cursor @var{cursor} to the next character in the character set @var{cs}. It is an error if the cursor given satisfies @code{end-of-char-set?}. @end deffn -@deffn primitive end-of-char-set? cursor +@deffn {Scheme Procedure} end-of-char-set? cursor Return @code{#t} if @var{cursor} has reached the end of a character set, @code{#f} otherwise. @end deffn -@deffn primitive char-set-fold kons knil cs +@deffn {Scheme Procedure} char-set-fold kons knil cs Fold the procedure @var{kons} over the character set @var{cs}, initializing it with @var{knil}. @end deffn -@deffn primitive char-set-unfold p f g seed [base_cs] -@deffnx primitive char-set-unfold! p f g seed base_cs +@deffn {Scheme Procedure} char-set-unfold p f g seed [base_cs] +@deffnx {Scheme Procedure} char-set-unfold! p f g seed base_cs This is a fundamental constructor for character sets. @itemize @bullet @item @var{g} is used to generate a series of ``seed'' values @@ -1902,12 +1902,12 @@ form the result; @var{base_cs} defaults to the empty set. @code{char-set-unfold!} is the side-effecting variant. @end deffn -@deffn primitive char-set-for-each proc cs +@deffn {Scheme Procedure} char-set-for-each proc cs Apply @var{proc} to every character in the character set @var{cs}. The return value is not specified. @end deffn -@deffn primitive char-set-map proc cs +@deffn {Scheme Procedure} char-set-map proc cs Map the procedure @var{proc} over every character in @var{cs}. @var{proc} must be a character -> character procedure. @end deffn @@ -1920,17 +1920,17 @@ Map the procedure @var{proc} over every character in @var{cs}. New character sets are produced with these procedures. -@deffn primitive char-set-copy cs +@deffn {Scheme Procedure} char-set-copy cs Return a newly allocated character set containing all characters in @var{cs}. @end deffn -@deffn primitive char-set char1 @dots{} +@deffn {Scheme Procedure} char-set char1 @dots{} Return a character set containing all given characters. @end deffn -@deffn primitive list->char-set char_list [base_cs] -@deffnx primitive list->char-set! char_list base_cs +@deffn {Scheme Procedure} list->char-set char_list [base_cs] +@deffnx {Scheme Procedure} list->char-set! char_list base_cs Convert the character list @var{list} to a character set. If the character set @var{base_cs} is given, the character in this set are also included in the result. @@ -1938,8 +1938,8 @@ set are also included in the result. @code{list->char-set!} is the side-effecting variant. @end deffn -@deffn primitive string->char-set s [base_cs] -@deffnx primitive string->char-set! s base_cs +@deffn {Scheme Procedure} string->char-set s [base_cs] +@deffnx {Scheme Procedure} string->char-set! s base_cs Convert the string @var{str} to a character set. If the character set @var{base_cs} is given, the characters in this set are also included in the result. @@ -1947,8 +1947,8 @@ set are also included in the result. @code{string->char-set!} is the side-effecting variant. @end deffn -@deffn primitive char-set-filter pred cs [base_cs] -@deffnx primitive char-set-filter! pred cs base_cs +@deffn {Scheme Procedure} char-set-filter pred cs [base_cs] +@deffnx {Scheme Procedure} char-set-filter! pred cs base_cs Return a character set containing every character from @var{cs} so that it satisfies @var{pred}. If provided, the characters from @var{base_cs} are added to the result. @@ -1956,8 +1956,8 @@ from @var{base_cs} are added to the result. @code{char-set-filter!} is the side-effecting variant. @end deffn -@deffn primitive ucs-range->char-set lower upper [error? base_cs] -@deffnx primitive uce-range->char-set! lower upper error? base_cs +@deffn {Scheme Procedure} ucs-range->char-set lower upper [error? base_cs] +@deffnx {Scheme Procedure} uce-range->char-set! lower upper error? base_cs Return a character set containing all characters whose character codes lie in the half-open range [@var{lower},@var{upper}). @@ -1974,7 +1974,7 @@ given. @code{ucs-range->char-set!} is the side-effecting variant. @end deffn -@deffn procedure ->char-set x +@deffn {Scheme Procedure} ->char-set x Coerce @var{x} into a character set. @var{x} may be a string, a character or a character set. @end deffn @@ -1988,37 +1988,37 @@ character or a character set. Access the elements and other information of a character set with these procedures. -@deffn primitive char-set-size cs +@deffn {Scheme Procedure} char-set-size cs Return the number of elements in character set @var{cs}. @end deffn -@deffn primitive char-set-count pred cs +@deffn {Scheme Procedure} char-set-count pred cs Return the number of the elements int the character set @var{cs} which satisfy the predicate @var{pred}. @end deffn -@deffn primitive char-set->list cs +@deffn {Scheme Procedure} char-set->list cs Return a list containing the elements of the character set @var{cs}. @end deffn -@deffn primitive char-set->string cs +@deffn {Scheme Procedure} char-set->string cs Return a string containing the elements of the character set @var{cs}. The order in which the characters are placed in the string is not defined. @end deffn -@deffn primitive char-set-contains? cs char +@deffn {Scheme Procedure} char-set-contains? cs char Return @code{#t} iff the character @var{ch} is contained in the character set @var{cs}. @end deffn -@deffn primitive char-set-every pred cs +@deffn {Scheme Procedure} char-set-every pred cs Return a true value if every character in the character set @var{cs} satisfies the predicate @var{pred}. @end deffn -@deffn primitive char-set-any pred cs +@deffn {Scheme Procedure} char-set-any pred cs Return a true value if any character in the character set @var{cs} satisfies the predicate @var{pred}. @end deffn @@ -2034,45 +2034,45 @@ such as union, complement, intersection etc. All of these procedures provide side-effecting variants, which modify their character set argument(s). -@deffn primitive char-set-adjoin cs char1 @dots{} -@deffnx primitive char-set-adjoin! cs char1 @dots{} +@deffn {Scheme Procedure} char-set-adjoin cs char1 @dots{} +@deffnx {Scheme Procedure} char-set-adjoin! cs char1 @dots{} Add all character arguments to the first argument, which must be a character set. @end deffn -@deffn primitive char-set-delete cs char1 @dots{} -@deffnx primitive char-set-delete! cs char1 @dots{} +@deffn {Scheme Procedure} char-set-delete cs char1 @dots{} +@deffnx {Scheme Procedure} char-set-delete! cs char1 @dots{} Delete all character arguments from the first argument, which must be a character set. @end deffn -@deffn primitive char-set-complement cs -@deffnx primitive char-set-complement! cs +@deffn {Scheme Procedure} char-set-complement cs +@deffnx {Scheme Procedure} char-set-complement! cs Return the complement of the character set @var{cs}. @end deffn -@deffn primitive char-set-union cs1 @dots{} -@deffnx primitive char-set-union! cs1 @dots{} +@deffn {Scheme Procedure} char-set-union cs1 @dots{} +@deffnx {Scheme Procedure} char-set-union! cs1 @dots{} Return the union of all argument character sets. @end deffn -@deffn primitive char-set-intersection cs1 @dots{} -@deffnx primitive char-set-intersection! cs1 @dots{} +@deffn {Scheme Procedure} char-set-intersection cs1 @dots{} +@deffnx {Scheme Procedure} char-set-intersection! cs1 @dots{} Return the intersection of all argument character sets. @end deffn -@deffn primitive char-set-difference cs1 @dots{} -@deffnx primitive char-set-difference! cs1 @dots{} +@deffn {Scheme Procedure} char-set-difference cs1 @dots{} +@deffnx {Scheme Procedure} char-set-difference! cs1 @dots{} Return the difference of all argument character sets. @end deffn -@deffn primitive char-set-xor cs1 @dots{} -@deffnx primitive char-set-xor! cs1 @dots{} +@deffn {Scheme Procedure} char-set-xor cs1 @dots{} +@deffnx {Scheme Procedure} char-set-xor! cs1 @dots{} Return the exclusive-or of all argument character sets. @end deffn -@deffn primitive char-set-diff+intersection cs1 @dots{} -@deffnx primitive char-set-diff+intersection! cs1 @dots{} +@deffn {Scheme Procedure} char-set-diff+intersection cs1 @dots{} +@deffnx {Scheme Procedure} char-set-diff+intersection! cs1 @dots{} Return the difference and the intersection of all argument character sets. @end deffn diff --git a/libguile/ChangeLog b/libguile/ChangeLog index d89307087..002cd3521 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,30 @@ 2001-11-16 Neil Jerram + * gc.h (scm_unhash_name): Old declaration removed. + + * eval.c (s_scm_eval): Change @var{primitive-eval} to + @code{primitive-eval}. + + * feature.c, vectors.c, net_db.c, unif.c, weaks.c, struct.c, + version.c, alist.c, ports.c, ramap.c, unif.c, strings.c, list.c: + Change @deffnx lines in docstrings to say {Scheme Procedure} + rather than primitive or procedure. + + * posix.c (scm_execl), filesys.c (scm_close), unif.c + (scm_array_set_x, scm_array_contents, scm_uniform_array_read_x, + scm_bit_set_star_x, scm_bit_invert_x), ramap.c (scm_array_fill_x, + scm_array_for_each, scm_array_index_map_x), vectors.c (scm_vector, + scm_make_vector, scm_vector_to_list, scm_vector_fill_x), strop.c + (scm_string_split, scm_string_ci_to_symbol), strings.c + (scm_string_p), sort.c (scm_merge), print.c (scm_newline), + macros.c (scm_macro_type), alist.c (scm_acons, scm_assq): + Docstring fixes and improvements reflecting edits that have been + made in the reference manual source. + + * objprop.c (scm_object_properties, scm_set_object_properties_x, + scm_object_property, scm_set_object_property_x): Remove invalid + @deffnx lines for corresponding procedure property primitives. + These changes add a @deffnx C function declaration and function index entries for each Guile primitive to the copy of the doc snarf output that is used for reference manual synchronization. diff --git a/libguile/alist.c b/libguile/alist.c index e2fa86068..9bb44cca8 100644 --- a/libguile/alist.c +++ b/libguile/alist.c @@ -52,7 +52,7 @@ SCM_DEFINE (scm_acons, "acons", 3, 0, 0, (SCM key, SCM value, SCM alist), - "Adds a new key-value pair to @var{alist}. A new pair is\n" + "Add a new key-value pair to @var{alist}. A new pair is\n" "created whose car is @var{key} and whose cdr is @var{value}, and the\n" "pair is consed onto @var{alist}, and the new list is returned. This\n" "function is @emph{not} destructive; @var{alist} is not modified.") @@ -133,14 +133,14 @@ SCM_DEFINE (scm_sloppy_assoc, "sloppy-assoc", 2, 0, 0, SCM_DEFINE (scm_assq, "assq", 2, 0, 0, (SCM key, SCM alist), - "@deffnx primitive assv key alist\n" - "@deffnx primitive assoc key alist\n" - "Fetches the entry in @var{alist} that is associated with @var{key}. To\n" + "@deffnx {Scheme Procedure} assv key alist\n" + "@deffnx {Scheme Procedure} assoc key alist\n" + "Fetch the entry in @var{alist} that is associated with @var{key}. To\n" "decide whether the argument @var{key} matches a particular entry in\n" "@var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv}\n" "uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key}\n" "cannot be found in @var{alist} (according to whichever equality\n" - "predicate is in use), then @code{#f} is returned. These functions\n" + "predicate is in use), then return @code{#f}. These functions\n" "return the entire alist entry found (i.e. both the key and the value).") #define FUNC_NAME s_scm_assq { @@ -218,8 +218,8 @@ SCM_DEFINE (scm_assoc, "assoc", 2, 0, 0, */ SCM_DEFINE (scm_assq_ref, "assq-ref", 2, 0, 0, (SCM alist, SCM key), - "@deffnx primitive assv-ref alist key\n" - "@deffnx primitive assoc-ref alist key\n" + "@deffnx {Scheme Procedure} assv-ref alist key\n" + "@deffnx {Scheme Procedure} assoc-ref alist key\n" "Like @code{assq}, @code{assv} and @code{assoc}, except that only the\n" "value associated with @var{key} in @var{alist} is returned. These\n" "functions are equivalent to\n\n" @@ -282,8 +282,8 @@ SCM_DEFINE (scm_assoc_ref, "assoc-ref", 2, 0, 0, SCM_DEFINE (scm_assq_set_x, "assq-set!", 3, 0, 0, (SCM alist, SCM key, SCM val), - "@deffnx primitive assv-set! alist key value\n" - "@deffnx primitive assoc-set! alist key value\n" + "@deffnx {Scheme Procedure} assv-set! alist key value\n" + "@deffnx {Scheme Procedure} assoc-set! alist key value\n" "Reassociate @var{key} in @var{alist} with @var{value}: find any existing\n" "@var{alist} entry for @var{key} and associate it with the new\n" "@var{value}. If @var{alist} does not contain an entry for @var{key},\n" @@ -347,8 +347,8 @@ SCM_DEFINE (scm_assoc_set_x, "assoc-set!", 3, 0, 0, SCM_DEFINE (scm_assq_remove_x, "assq-remove!", 2, 0, 0, (SCM alist, SCM key), - "@deffnx primitive assv-remove! alist key\n" - "@deffnx primitive assoc-remove! alist key\n" + "@deffnx {Scheme Procedure} assv-remove! alist key\n" + "@deffnx {Scheme Procedure} assoc-remove! alist key\n" "Delete the first entry in @var{alist} associated with @var{key}, and return\n" "the resulting alist.") #define FUNC_NAME s_scm_assq_remove_x diff --git a/libguile/eval.c b/libguile/eval.c index 6a05083fa..2977da696 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -4069,7 +4069,7 @@ SCM_DEFINE (scm_eval, "eval", 2, 0, 0, (SCM exp, SCM module), "Evaluate @var{exp}, a list representing a Scheme expression,\n" "in the top-level environment specified by @var{module}.\n" - "While @var{exp} is evaluated (using @var{primitive-eval}),\n" + "While @var{exp} is evaluated (using @code{primitive-eval}),\n" "@var{module} is made the current module. The current module\n" "is reset to its previous value when @var{eval} returns.") #define FUNC_NAME s_scm_eval diff --git a/libguile/feature.c b/libguile/feature.c index 30f5325c3..5748fd30b 100644 --- a/libguile/feature.c +++ b/libguile/feature.c @@ -70,7 +70,7 @@ scm_add_feature (const char *str) SCM_DEFINE (scm_program_arguments, "program-arguments", 0, 0, 0, (), - "@deffnx procedure command-line\n" + "@deffnx {Scheme Procedure} command-line\n" "Return the list of command line arguments passed to Guile, as a list of\n" "strings. The list includes the invoked program name, which is usually\n" "@code{\"guile\"}, but excludes switches and parameters for command line\n" diff --git a/libguile/filesys.c b/libguile/filesys.c index f891be40e..b8a9aadc9 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -382,7 +382,7 @@ SCM_DEFINE (scm_open, "open", 2, 1, 0, SCM_DEFINE (scm_close, "close", 1, 0, 0, (SCM fd_or_port), - "Similar to close-port (@pxref{Generic Port Operations, close-port}),\n" + "Similar to close-port (@pxref{Closing, close-port}),\n" "but also works on file descriptors. A side\n" "effect of closing a file descriptor is that any ports using that file\n" "descriptor are moved to a different file descriptor and have\n" diff --git a/libguile/gc.h b/libguile/gc.h index c392b5d07..5e2a01ec4 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -351,7 +351,6 @@ SCM_API void scm_assert_cell_valid (SCM); SCM_API SCM scm_set_debug_cell_accesses_x (SCM flag); #endif SCM_API SCM scm_object_address (SCM obj); -SCM_API SCM scm_unhash_name (SCM name); SCM_API SCM scm_gc_stats (void); SCM_API SCM scm_gc (void); SCM_API void scm_gc_for_alloc (struct scm_t_freelist *freelist); diff --git a/libguile/list.c b/libguile/list.c index a2f29f034..b709b882d 100644 --- a/libguile/list.c +++ b/libguile/list.c @@ -445,7 +445,7 @@ SCM_REGISTER_PROC(s_list_cdr_ref, "list-cdr-ref", 2, 0, 0, scm_list_tail); SCM_DEFINE (scm_list_tail, "list-tail", 2, 0, 0, (SCM lst, SCM k), - "@deffnx primitive list-cdr-ref lst k\n" + "@deffnx {Scheme Procedure} list-cdr-ref lst k\n" "Return the \"tail\" of @var{lst} beginning with its @var{k}th element.\n" "The first element of the list is considered to be element 0.\n\n" "@code{list-tail} and @code{list-cdr-ref} are identical. It may help to\n" @@ -628,8 +628,8 @@ SCM_DEFINE (scm_member, "member", 2, 0, 0, SCM_DEFINE (scm_delq_x, "delq!", 2, 0, 0, (SCM item, SCM lst), - "@deffnx primitive delv! item lst\n" - "@deffnx primitive delete! item lst\n" + "@deffnx {Scheme Procedure} delv! item lst\n" + "@deffnx {Scheme Procedure} delete! item lst\n" "These procedures are destructive versions of @code{delq}, @code{delv}\n" "and @code{delete}: they modify the pointers in the existing @var{lst}\n" "rather than creating a new list. Caveat evaluator: Like other\n" diff --git a/libguile/macros.c b/libguile/macros.c index 8f011c055..aac969fdb 100644 --- a/libguile/macros.c +++ b/libguile/macros.c @@ -175,7 +175,7 @@ SCM_DEFINE (scm_macro_type, "macro-type", 1, 0, 0, (SCM m), "Return one of the symbols @code{syntax}, @code{macro} or\n" "@code{macro!}, depending on whether @var{m} is a syntax\n" - "tranformer, a regular macro, or a memoizing macro,\n" + "transformer, a regular macro, or a memoizing macro,\n" "respectively. If @var{m} is not a macro, @code{#f} is\n" "returned.") #define FUNC_NAME s_scm_macro_type diff --git a/libguile/net_db.c b/libguile/net_db.c index 8afd9244c..d32819ee8 100644 --- a/libguile/net_db.c +++ b/libguile/net_db.c @@ -136,8 +136,8 @@ static void scm_resolv_error (const char *subr, SCM bad_value) SCM_DEFINE (scm_gethost, "gethost", 0, 1, 0, (SCM host), - "@deffnx procedure gethostbyname hostname\n" - "@deffnx procedure gethostbyaddr address\n" + "@deffnx {Scheme Procedure} gethostbyname hostname\n" + "@deffnx {Scheme Procedure} gethostbyaddr address\n" "Look up a host by name or address, returning a host object. The\n" "@code{gethost} procedure will accept either a string name or an integer\n" "address; if given no arguments, it behaves like @code{gethostent} (see\n" @@ -219,8 +219,8 @@ SCM_DEFINE (scm_gethost, "gethost", 0, 1, 0, #if defined(HAVE_GETNETENT) && defined(HAVE_GETNETBYNAME) && defined(HAVE_GETNETBYADDR) SCM_DEFINE (scm_getnet, "getnet", 0, 1, 0, (SCM net), - "@deffnx procedure getnetbyname net-name\n" - "@deffnx procedure getnetbyaddr net-number\n" + "@deffnx {Scheme Procedure} getnetbyname net-name\n" + "@deffnx {Scheme Procedure} getnetbyaddr net-number\n" "Look up a network by name or net number in the network database. The\n" "@var{net-name} argument must be a string, and the @var{net-number}\n" "argument must be an integer. @code{getnet} will accept either type of\n" @@ -269,8 +269,8 @@ SCM_DEFINE (scm_getnet, "getnet", 0, 1, 0, #ifdef HAVE_GETPROTOENT SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0, (SCM protocol), - "@deffnx procedure getprotobyname name\n" - "@deffnx procedure getprotobynumber number\n" + "@deffnx {Scheme Procedure} getprotobyname name\n" + "@deffnx {Scheme Procedure} getprotobynumber number\n" "Look up a network protocol by name or by number. @code{getprotobyname}\n" "takes a string argument, and @code{getprotobynumber} takes an integer\n" "argument. @code{getproto} will accept either type, behaving like\n" @@ -332,8 +332,8 @@ scm_return_entry (struct servent *entry) SCM_DEFINE (scm_getserv, "getserv", 0, 2, 0, (SCM name, SCM protocol), - "@deffnx procedure getservbyname name protocol\n" - "@deffnx procedure getservbyport port protocol\n" + "@deffnx {Scheme Procedure} getservbyname name protocol\n" + "@deffnx {Scheme Procedure} getservbyport port protocol\n" "Look up a network service by name or by service number, and return a\n" "network service object. The @var{protocol} argument specifies the name\n" "of the desired protocol; if the protocol found in the network service\n" diff --git a/libguile/objprop.c b/libguile/objprop.c index 4d5dd79cb..aa3883165 100644 --- a/libguile/objprop.c +++ b/libguile/objprop.c @@ -56,7 +56,6 @@ SCM_DEFINE (scm_object_properties, "object-properties", 1, 0, 0, (SCM obj), - "@deffnx primitive procedure-properties obj\n" "Return @var{obj}'s property list.") #define FUNC_NAME s_scm_object_properties { @@ -67,7 +66,6 @@ SCM_DEFINE (scm_object_properties, "object-properties", 1, 0, 0, SCM_DEFINE (scm_set_object_properties_x, "set-object-properties!", 2, 0, 0, (SCM obj, SCM alist), - "@deffnx primitive set-procedure-properties! obj alist\n" "Set @var{obj}'s property list to @var{alist}.") #define FUNC_NAME s_scm_set_object_properties_x { @@ -79,7 +77,6 @@ SCM_DEFINE (scm_set_object_properties_x, "set-object-properties!", 2, 0, 0, SCM_DEFINE (scm_object_property, "object-property", 2, 0, 0, (SCM obj, SCM key), - "@deffnx primitive procedure-property obj key\n" "Return the property of @var{obj} with name @var{key}.") #define FUNC_NAME s_scm_object_property { @@ -91,7 +88,6 @@ SCM_DEFINE (scm_object_property, "object-property", 2, 0, 0, SCM_DEFINE (scm_set_object_property_x, "set-object-property!", 3, 0, 0, (SCM obj, SCM key, SCM value), - "@deffnx primitive set-procedure-property! obj key value\n" "In @var{obj}'s property list, set the property named @var{key}\n" "to @var{value}.") #define FUNC_NAME s_scm_set_object_property_x diff --git a/libguile/ports.c b/libguile/ports.c index 0250f503c..6e79e9ab7 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -395,8 +395,8 @@ SCM_DEFINE (scm_current_load_port, "current-load-port", 0, 0, 0, SCM_DEFINE (scm_set_current_input_port, "set-current-input-port", 1, 0, 0, (SCM port), - "@deffnx primitive set-current-output-port port\n" - "@deffnx primitive set-current-error-port port\n" + "@deffnx {Scheme Procedure} set-current-output-port port\n" + "@deffnx {Scheme Procedure} set-current-error-port port\n" "Change the ports returned by @code{current-input-port},\n" "@code{current-output-port} and @code{current-error-port}, respectively,\n" "so that they use the supplied @var{port} for input or output.") @@ -1400,7 +1400,7 @@ SCM_DEFINE (scm_set_port_line_x, "set-port-line!", 2, 0, 0, SCM_DEFINE (scm_port_column, "port-column", 1, 0, 0, (SCM port), - "@deffnx primitive port-line port\n" + "@deffnx {Scheme Procedure} port-line port\n" "Return the current column number or line number of @var{port},\n" "using the current input port if none is specified. If the number is\n" "unknown, the result is #f. Otherwise, the result is a 0-origin integer\n" @@ -1419,7 +1419,7 @@ SCM_DEFINE (scm_port_column, "port-column", 1, 0, 0, SCM_DEFINE (scm_set_port_column_x, "set-port-column!", 2, 0, 0, (SCM port, SCM column), - "@deffnx primitive set-port-line! port line\n" + "@deffnx {Scheme Procedure} set-port-line! port line\n" "Set the current column or line number of @var{port}, using the\n" "current input port if none is specified.") #define FUNC_NAME s_scm_set_port_column_x diff --git a/libguile/posix.c b/libguile/posix.c index acec88b08..6e2393570 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -867,7 +867,7 @@ SCM_DEFINE (scm_execl, "execl", 1, 0, 1, "The remaining arguments are supplied to the process; from a C program\n" "they are accessable as the @code{argv} argument to @code{main}.\n" "Conventionally the first @var{arg} is the same as @var{path}.\n" - "All arguments must be strings. \n\n" + "All arguments must be strings.\n\n" "If @var{arg} is missing, @var{path} is executed with a null\n" "argument list, which may have system-dependent side-effects.\n\n" "This procedure is currently implemented using the @code{execv} system\n" diff --git a/libguile/print.c b/libguile/print.c index 369b112bb..3e7849314 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -992,7 +992,8 @@ SCM_DEFINE (scm_simple_format, "simple-format", 2, 0, 1, SCM_DEFINE (scm_newline, "newline", 0, 1, 0, (SCM port), - "Send a newline to @var{port}.") + "Send a newline to @var{port}.\n" + "If @var{port} is omitted, send to the current output port.") #define FUNC_NAME s_scm_newline { if (SCM_UNBNDP (port)) diff --git a/libguile/ramap.c b/libguile/ramap.c index 4e0e712c8..9cc642f0b 100644 --- a/libguile/ramap.c +++ b/libguile/ramap.c @@ -458,7 +458,7 @@ scm_ramapc (int (*cproc)(), SCM data, SCM ra0, SCM lra, const char *what) SCM_DEFINE (scm_array_fill_x, "array-fill!", 2, 0, 0, (SCM ra, SCM fill), - "Stores @var{fill} in every element of @var{array}. The value returned\n" + "Store @var{fill} in every element of @var{array}. The value returned\n" "is unspecified.") #define FUNC_NAME s_scm_array_fill_x { @@ -829,8 +829,8 @@ SCM_REGISTER_PROC(s_array_copy_in_order_x, "array-copy-in-order!", 2, 0, 0, scm_ SCM_DEFINE (scm_array_copy_x, "array-copy!", 2, 0, 0, (SCM src, SCM dst), - "@deffnx primitive array-copy-in-order! src dst\n" - "Copies every element from vector or array @var{source} to the\n" + "@deffnx {Scheme Procedure} array-copy-in-order! src dst\n" + "Copy every element from vector or array @var{source} to the\n" "corresponding element of @var{destination}. @var{destination} must have\n" "the same rank as @var{source}, and be at least as large in each\n" "dimension. The order is unspecified.") @@ -1512,7 +1512,7 @@ SCM_REGISTER_PROC(s_array_map_in_order_x, "array-map-in-order!", 2, 0, 1, scm_ar SCM_DEFINE (scm_array_map_x, "array-map!", 2, 0, 1, (SCM ra0, SCM proc, SCM lra), - "@deffnx primitive array-map-in-order! ra0 proc . lra\n" + "@deffnx {Scheme Procedure} array-map-in-order! ra0 proc . lra\n" "@var{array1}, @dots{} must have the same number of dimensions as\n" "@var{array0} and have a range for each index which includes the range\n" "for the corresponding index in @var{array0}. @var{proc} is applied to\n" @@ -1664,7 +1664,7 @@ rafe (SCM ra0,SCM proc,SCM ras) SCM_DEFINE (scm_array_for_each, "array-for-each", 2, 0, 1, (SCM proc, SCM ra0, SCM lra), - "@var{proc} is applied to each tuple of elements of @var{array0} @dots{}\n" + "Apply @var{proc} to each tuple of elements of @var{array0} @dots{}\n" "in row-major order. The value returned is unspecified.") #define FUNC_NAME s_scm_array_for_each { @@ -1677,7 +1677,7 @@ SCM_DEFINE (scm_array_for_each, "array-for-each", 2, 0, 1, SCM_DEFINE (scm_array_index_map_x, "array-index-map!", 2, 0, 0, (SCM ra, SCM proc), - "applies @var{proc} to the indices of each element of @var{array} in\n" + "Apply @var{proc} to the indices of each element of @var{array} in\n" "turn, storing the result in the corresponding element. The value\n" "returned and the order of application are unspecified.\n\n" "One can implement @var{array-indexes} as\n" diff --git a/libguile/sort.c b/libguile/sort.c index 70de17505..7519ed2f2 100644 --- a/libguile/sort.c +++ b/libguile/sort.c @@ -516,9 +516,10 @@ SCM_DEFINE (scm_sorted_p, "sorted?", 2, 0, 0, Note: this does _not_ accept vectors. */ SCM_DEFINE (scm_merge, "merge", 3, 0, 0, (SCM alist, SCM blist, SCM less), - "Takes two lists @var{alist} and @var{blist} such that\n" - "@code{(sorted? alist less?)} and @code{(sorted? blist less?)} and\n" - "returns a new list in which the elements of @var{alist} and\n" + "Merge two already sorted lists into one.\n" + "Given two lists @var{alist} and @var{blist}, such that\n" + "@code{(sorted? alist less?)} and @code{(sorted? blist less?)},\n" + "return a new list in which the elements of @var{alist} and\n" "@var{blist} have been stably interleaved so that\n" "@code{(sorted? (merge alist blist less?) less?)}.\n" "Note: this does _not_ accept vectors.") diff --git a/libguile/strings.c b/libguile/strings.c index eef9f4a7f..8bd7de872 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -58,8 +58,7 @@ SCM_DEFINE (scm_string_p, "string?", 1, 0, 0, (SCM obj), - "Return @code{#t} iff @var{obj} is a string, else returns\n" - "@code{#f}.") + "Return @code{#t} iff @var{obj} is a string, else @code{#f}.") #define FUNC_NAME s_scm_string_p { return SCM_BOOL (SCM_STRINGP (obj)); @@ -71,7 +70,7 @@ SCM_REGISTER_PROC (s_scm_list_to_string, "list->string", 1, 0, 0, scm_string); SCM_DEFINE (scm_string, "string", 0, 0, 1, (SCM chrs), - "@deffnx primitive list->string chrs\n" + "@deffnx {Scheme Procedure} list->string chrs\n" "Return a newly allocated string composed of the arguments,\n" "@var{chrs}.") #define FUNC_NAME s_scm_string diff --git a/libguile/strop.c b/libguile/strop.c index 1271dea08..89cd02f62 100644 --- a/libguile/strop.c +++ b/libguile/strop.c @@ -472,15 +472,15 @@ SCM_DEFINE (scm_string_split, "string-split", 2, 0, 0, "result list.\n" "\n" "@lisp\n" - "(string-split \"root:x:0:0:root:/root:/bin/bash\" #\:)\n" + "(string-split \"root:x:0:0:root:/root:/bin/bash\" #\\:)\n" "@result{}\n" "(\"root\" \"x\" \"0\" \"0\" \"root\" \"/root\" \"/bin/bash\")\n" "\n" - "(string-split \"::\" #\:)\n" + "(string-split \"::\" #\\:)\n" "@result{}\n" "(\"\" \"\" \"\")\n" "\n" - "(string-split \"\" #\:)\n" + "(string-split \"\" #\\:)\n" "@result{}\n" "(\"\")\n" "@end lisp") @@ -518,7 +518,7 @@ SCM_DEFINE (scm_string_ci_to_symbol, "string-ci->symbol", 1, 0, 0, (SCM str), "Return the symbol whose name is @var{str}. @var{str} is\n" "converted to lowercase before the conversion is done, if Guile\n" - "is currently reading symbols case--insensitively.") + "is currently reading symbols case-insensitively.") #define FUNC_NAME s_scm_string_ci_to_symbol { return scm_string_to_symbol (SCM_CASE_INSENSITIVE_P diff --git a/libguile/struct.c b/libguile/struct.c index f24fefdb2..9a580cb41 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -560,7 +560,7 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1, SCM_DEFINE (scm_struct_ref, "struct-ref", 2, 0, 0, (SCM handle, SCM pos), - "@deffnx primitive struct-set! struct n value\n" + "@deffnx {Scheme Procedure} struct-set! struct n value\n" "Access (or modify) the @var{n}th field of @var{struct}.\n\n" "If the field is of type 'p', then it can be set to an arbitrary value.\n\n" "If the field is of type 'u', then it can only be set to a non-negative\n" diff --git a/libguile/unif.c b/libguile/unif.c index 138fe36a8..17470207e 100644 --- a/libguile/unif.c +++ b/libguile/unif.c @@ -582,7 +582,7 @@ scm_shap2ra (SCM args, const char *what) SCM_DEFINE (scm_dimensions_to_uniform_array, "dimensions->uniform-array", 2, 1, 0, (SCM dims, SCM prot, SCM fill), - "@deffnx primitive make-uniform-vector length prototype [fill]\n" + "@deffnx {Scheme Procedure} make-uniform-vector length prototype [fill]\n" "Create and return a uniform array or vector of type\n" "corresponding to @var{prototype} with dimensions @var{dims} or\n" "length @var{length}. If @var{fill} is supplied, it's used to\n" @@ -1084,7 +1084,7 @@ SCM_REGISTER_PROC(s_array_ref, "array-ref", 1, 0, 1, scm_uniform_vector_ref); SCM_DEFINE (scm_uniform_vector_ref, "uniform-vector-ref", 2, 0, 0, (SCM v, SCM args), - "@deffnx primitive array-ref v . args\n" + "@deffnx {Scheme Procedure} array-ref v . args\n" "Return the element at the @code{(index1, index2)} element in\n" "@var{array}.") #define FUNC_NAME s_scm_uniform_vector_ref @@ -1262,8 +1262,8 @@ SCM_REGISTER_PROC(s_uniform_array_set1_x, "uniform-array-set1!", 3, 0, 0, scm_ar PROC is used (and it's called from C too). */ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1, (SCM v, SCM obj, SCM args), - "@deffnx primitive uniform-array-set1! v obj args\n" - "Sets the element at the @code{(index1, index2)} element in @var{array} to\n" + "@deffnx {Scheme Procedure} uniform-array-set1! v obj args\n" + "Set the element at the @code{(index1, index2)} element in @var{array} to\n" "@var{new-value}. The value returned by array-set! is unspecified.") #define FUNC_NAME s_scm_array_set_x { @@ -1371,7 +1371,6 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1, wouldn't have contiguous elements. */ SCM_DEFINE (scm_array_contents, "array-contents", 1, 1, 0, (SCM ra, SCM strict), - "@deffnx primitive array-contents array strict\n" "If @var{array} may be @dfn{unrolled} into a one dimensional shared array\n" "without changing their order (last subscript changing fastest), then\n" "@code{array-contents} returns that shared array, otherwise it returns\n" @@ -1482,11 +1481,11 @@ scm_ra2contig (SCM ra, int copy) SCM_DEFINE (scm_uniform_array_read_x, "uniform-array-read!", 1, 3, 0, (SCM ra, SCM port_or_fd, SCM start, SCM end), - "@deffnx primitive uniform-vector-read! uve [port-or-fdes] [start] [end]\n" - "Attempts to read all elements of @var{ura}, in lexicographic order, as\n" + "@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end]\n" + "Attempt to read all elements of @var{ura}, in lexicographic order, as\n" "binary objects from @var{port-or-fdes}.\n" - "If an end of file is encountered during\n" - "uniform-array-read! the objects up to that point only are put into @var{ura}\n" + "If an end of file is encountered,\n" + "the objects up to that point are put into @var{ura}\n" "(starting at the beginning) and the remainder of the array is\n" "unchanged.\n\n" "The optional arguments @var{start} and @var{end} allow\n" @@ -1650,7 +1649,7 @@ loop: SCM_DEFINE (scm_uniform_array_write, "uniform-array-write", 1, 3, 0, (SCM v, SCM port_or_fd, SCM start, SCM end), - "@deffnx primitive uniform-vector-write uve [port-or-fdes] [start] [end]\n" + "@deffnx {Scheme Procedure} uniform-vector-write uve [port-or-fdes] [start] [end]\n" "Writes all elements of @var{ura} as binary objects to\n" "@var{port-or-fdes}.\n\n" "The optional arguments @var{start}\n" @@ -1890,7 +1889,7 @@ SCM_DEFINE (scm_bit_set_star_x, "bit-set*!", 3, 0, 0, "length. If @var{bool} is @code{#t}, uve is OR'ed into\n" "@var{bv}; If @var{bool} is @code{#f}, the inversion of uve is\n" "AND'ed into @var{bv}.\n\n" - "If uve is a unsigned integer vector all the elements of uve\n" + "If uve is a unsigned long integer vector all the elements of uve\n" "must be between 0 and the @code{length} of @var{bv}. The bits\n" "of @var{bv} corresponding to the indexes in uve are set to\n" "@var{bool}. The return value is unspecified.") @@ -2011,7 +2010,7 @@ SCM_DEFINE (scm_bit_count_star, "bit-count*", 3, 0, 0, SCM_DEFINE (scm_bit_invert_x, "bit-invert!", 1, 0, 0, (SCM v), - "Modifies @var{bv} by replacing each element with its negation.") + "Modify @var{bv} by replacing each element with its negation.") #define FUNC_NAME s_scm_bit_invert_x { long int k; @@ -2187,7 +2186,7 @@ static int l2ra(SCM lst, SCM ra, unsigned long base, unsigned long k); SCM_DEFINE (scm_list_to_uniform_array, "list->uniform-array", 3, 0, 0, (SCM ndim, SCM prot, SCM lst), - "@deffnx procedure list->uniform-vector prot lst\n" + "@deffnx {Scheme Procedure} list->uniform-vector prot lst\n" "Return a uniform array of the type indicated by prototype\n" "@var{prot} with elements the same as those of @var{lst}.\n" "Elements must be of the appropriate type, no coercions are\n" diff --git a/libguile/vectors.c b/libguile/vectors.c index cd194a905..36ffda380 100644 --- a/libguile/vectors.c +++ b/libguile/vectors.c @@ -83,8 +83,8 @@ SCM_REGISTER_PROC (s_list_to_vector, "list->vector", 1, 0, 0, scm_vector); */ SCM_DEFINE (scm_vector, "vector", 0, 0, 1, (SCM l), - "@deffnx primitive list->vector l\n" - "Return a newly allocated vector whose elements contain the\n" + "@deffnx {Scheme Procedure} list->vector l\n" + "Return a newly allocated vector composed of the\n" "given arguments. Analogous to @code{list}.\n" "\n" "@lisp\n" @@ -173,8 +173,8 @@ scm_vector_set_x (SCM v, SCM k, SCM obj) SCM_DEFINE (scm_make_vector, "make-vector", 1, 1, 0, (SCM k, SCM fill), "Return a newly allocated vector of @var{k} elements. If a\n" - "second argument is given, then each element is initialized to\n" - "@var{fill}. Otherwise the initial contents of each element is\n" + "second argument is given, then each position is initialized to\n" + "@var{fill}. Otherwise the initial contents of each position is\n" "unspecified.") #define FUNC_NAME s_scm_make_vector { @@ -226,8 +226,7 @@ scm_c_make_vector (unsigned long int k, SCM fill) SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0, (SCM v), - "Return a newly allocated list of the objects contained in the\n" - "elements of @var{vector}.\n" + "Return a newly allocated list composed of the elements of @var{v}.\n" "\n" "@lisp\n" "(vector->list '#(dah dah didah)) @result{} (dah dah didah)\n" @@ -248,7 +247,7 @@ SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0, SCM_DEFINE (scm_vector_fill_x, "vector-fill!", 2, 0, 0, (SCM v, SCM fill), - "Store @var{fill} in every element of @var{vector}. The value\n" + "Store @var{fill} in every position of @var{vector}. The value\n" "returned by @code{vector-fill!} is unspecified.") #define FUNC_NAME s_scm_vector_fill_x { diff --git a/libguile/version.c b/libguile/version.c index e1c40b65b..b99d77710 100644 --- a/libguile/version.c +++ b/libguile/version.c @@ -94,9 +94,9 @@ SCM_DEFINE (scm_micro_version, "micro-version", 0, 0, 0, SCM_DEFINE (scm_version, "version", 0, 0, 0, (), - "@deffnx primitive major-version\n" - "@deffnx primitive minor-version\n" - "@deffnx primitive micro-version\n" + "@deffnx {Scheme Procedure} major-version\n" + "@deffnx {Scheme Procedure} minor-version\n" + "@deffnx {Scheme Procedure} micro-version\n" "Return a string describing Guile's version number, or its major, minor\n" "or micro version number, respectively.\n\n" "@lisp\n" diff --git a/libguile/weaks.c b/libguile/weaks.c index d8eb065cd..74ce39703 100644 --- a/libguile/weaks.c +++ b/libguile/weaks.c @@ -124,7 +124,7 @@ SCM_REGISTER_PROC(s_list_to_weak_vector, "list->weak-vector", 1, 0, 0, scm_weak_ SCM_DEFINE (scm_weak_vector, "weak-vector", 0, 0, 1, (SCM l), - "@deffnx primitive list->weak-vector l\n" + "@deffnx {Scheme Procedure} list->weak-vector l\n" "Construct a weak vector from a list: @code{weak-vector} uses\n" "the list of its arguments while @code{list->weak-vector} uses\n" "its only argument @var{l} (a list) to construct a weak vector\n" @@ -167,8 +167,8 @@ SCM_DEFINE (scm_weak_vector_p, "weak-vector?", 1, 0, 0, SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 1, 0, 0, (SCM size), - "@deffnx primitive make-weak-value-hash-table size\n" - "@deffnx primitive make-doubly-weak-hash-table size\n" + "@deffnx {Scheme Procedure} make-weak-value-hash-table size\n" + "@deffnx {Scheme Procedure} make-doubly-weak-hash-table size\n" "Return a weak hash table with @var{size} buckets. As with any\n" "hash table, choosing a good size for the table requires some\n" "caution.\n" @@ -206,8 +206,8 @@ SCM_DEFINE (scm_make_doubly_weak_hash_table, "make-doubly-weak-hash-table", 1, 0 SCM_DEFINE (scm_weak_key_hash_table_p, "weak-key-hash-table?", 1, 0, 0, (SCM obj), - "@deffnx primitive weak-value-hash-table? obj\n" - "@deffnx primitive doubly-weak-hash-table? obj\n" + "@deffnx {Scheme Procedure} weak-value-hash-table? obj\n" + "@deffnx {Scheme Procedure} doubly-weak-hash-table? obj\n" "Return @code{#t} if @var{obj} is the specified weak hash\n" "table. Note that a doubly weak hash table is neither a weak key\n" "nor a weak value hash table.") diff --git a/scripts/ChangeLog b/scripts/ChangeLog index 01dd7eb19..87be0b25a 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,11 @@ 2001-11-16 Neil Jerram + * snarf-check-and-output-texi: Change generated @deffn categories + from "function" and "primitive" to "C Function" and "Scheme + Procedure". + (end-multiline): Take out @findex generation again; not needed + since index entries are implicit in @deffn forms. + These changes add a @deffnx C function declaration and function index entries for each Guile primitive to the copy of the doc snarf output that is used for reference manual synchronization. diff --git a/scripts/snarf-check-and-output-texi b/scripts/snarf-check-and-output-texi index f6ca78757..37d751c86 100755 --- a/scripts/snarf-check-and-output-texi +++ b/scripts/snarf-check-and-output-texi @@ -143,7 +143,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (set! *sig* #f) (set! *docstring* #f)) -(define *primitive-deffnx-signature* "@deffnx primitive ") +(define *primitive-deffnx-signature* "@deffnx {Scheme Procedure} ") (define *primitive-deffnx-sig-length* (string-length *primitive-deffnx-signature*)) (define (end-multiline) @@ -184,18 +184,18 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (if (and *manual-flag* (eq? *snarf-type* 'primitive)) (with-output-to-string (lambda () - (format #t "@deffnx function SCM ~A (" *c-function-name*) + (format #t "@deffnx {C Function} ~A (" *c-function-name*) (unless (null? *args*) - (format #t "SCM ~A" (car *args*)) + (format #t "~A" (car *args*)) (let loop ((args (cdr *args*))) (unless (null? args) - (format #t ", SCM ~A" (car args)) + (format #t ", ~A" (car args)) (loop (cdr args))))) (format #t ")\n"))) #f))) (format #t "\n ~A\n" *function-name*) (format #t "@c snarfed from ~A:~A\n" *file* *line*) - (format #t "@deffn primitive ~A\n" nice-sig) + (format #t "@deffn {Scheme Procedure} ~A\n" nice-sig) (let loop ((strings *docstring*) (scm-deffnx scm-deffnx)) (cond ((null? strings)) ((or (not scm-deffnx) @@ -209,9 +209,6 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (else (display scm-deffnx) (loop strings #f)))) (display "\n") - (when *manual-flag* - (format #t "@findex ~A\n" *function-name*) - (format #t "@findex ~A\n" *c-function-name*)) (display "@end deffn\n")))) (define (texi-quote s) From 302c12b4b780e15934873ef267b636d1a3c1707e Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 17 Nov 2001 11:43:28 +0000 Subject: [PATCH 166/281] * eval.c: Removed bogus comment about acros. (scm_unmemocar): Use !SCM_CONSP instead of SCM_IMP. Minimize scope of local variable. Eliminate dependency on macro DEBUG_EXTENSIONS. (s_splicing): New error message string. (scm_m_body): Issue 'bad body' message rather than 'missing expression' message. (scm_m_quote): Eliminate unnecessary copying. (scm_m_lambda, scm_m_letstar, scm_m_letrec, scm_m_let): Leave the checking of the body to scm_m_body. (scm_m_do): Move comment to function header. Rename arg1 to binding. Made the code a bit easier to read. (evalcar): Removed. (iqq): Added a comment. Changed the depth parameter to unsigned. Use size_t for vector lengths. Make sure vector object is gc protected as long as its contents are read. Add some syntax checks. Get rid of unnecessary SCM_IMP test. Clean up the control structure a bit. (scm_m_delay): Added comment about the implementation of scm_m_delay. (scm_m_define): Add comment about guile's currying define syntax. Renamed 'proc' to 'name'. Eliminate dependency on macro DEBUG_EXTENSIONS. Simplified code a bit. Eliminate SICP code. (scm_m_letrec1): Removed. Part of the functionality is taken over by the new function 'transform_bindings'. (transform_bindings): New function. Takes over some of the functionality of removed function 'scm_m_letrec1', namely to split a list of bindings into a reversed list of variables and a list of initializers. (scm_m_letrec): Call 'transform_bindings'. (scm_m_let): Minimized scope of local variables. Renamed 'proc' to 'temp' and 'arg1' to 'binding'. Eliminated redundant SCM_NIMP test. Use 'transform_bindings'. Fixed scoping error with named let (Thanks to Aubrey Jaffer for reporting the bug and to Neil Jerram for suggesting the fix). Cleaned up the control structure a bit. (scm_m_expand_body): Use 'transform_bindings'. Eliminated unnecessary consing. Eliminated unnecessary SCM_DEFER/ALLOW_INTS. (SCM_CEVAL): Un-obfuscated some loops. --- BUGS | 2 +- THANKS | 1 + libguile/ChangeLog | 59 +++++ libguile/eval.c | 540 ++++++++++++++++++++++++--------------------- 4 files changed, 354 insertions(+), 248 deletions(-) diff --git a/BUGS b/BUGS index 9342b1af8..693cd473e 100644 --- a/BUGS +++ b/BUGS @@ -63,7 +63,7 @@ to change people is difficult, but that's why we have guile... bug 4 -- named-let transform evaluates initvalue in the wrong scope reported-by: agj@alum.mit.edu / 2001-09-21 -fixed: not-yet +fixed: 2001-11-17 (1.7.x) currently: > (let name ((var init) ...) body ...) diff --git a/THANKS b/THANKS index 773a78eb5..8f8190513 100644 --- a/THANKS +++ b/THANKS @@ -16,6 +16,7 @@ For fixes or providing information which led to a fix: Michael Carmack Brian Crowder Christopher Cramer + Aubrey Jaffer John Goerzen Han-Wen Nienhuys Ken Raeburn diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 002cd3521..53b6a1b19 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,62 @@ +2001-11-17 Dirk Herrmann + + * eval.c: Removed bogus comment about acros. + + (scm_unmemocar): Use !SCM_CONSP instead of SCM_IMP. + Minimize scope of local variable. Eliminate dependency on + macro DEBUG_EXTENSIONS. + + (s_splicing): New error message string. + + (scm_m_body): Issue 'bad body' message rather than 'missing + expression' message. + + (scm_m_quote): Eliminate unnecessary copying. + + (scm_m_lambda, scm_m_letstar, scm_m_letrec, scm_m_let): Leave the + checking of the body to scm_m_body. + + (scm_m_do): Move comment to function header. Rename arg1 to + binding. Made the code a bit easier to read. + + (evalcar): Removed. + + (iqq): Added a comment. Changed the depth parameter to + unsigned. Use size_t for vector lengths. Make sure vector object + is gc protected as long as its contents are read. Add some syntax + checks. Get rid of unnecessary SCM_IMP test. Clean up the + control structure a bit. + + (scm_m_delay): Added comment about the implementation of + scm_m_delay. + + (scm_m_define): Add comment about guile's currying define + syntax. Renamed 'proc' to 'name'. Eliminate dependency on macro + DEBUG_EXTENSIONS. Simplified code a bit. Eliminate SICP code. + + (scm_m_letrec1): Removed. Part of the functionality is taken + over by the new function 'transform_bindings'. + + (transform_bindings): New function. Takes over some of the + functionality of removed function 'scm_m_letrec1', namely to split + a list of bindings into a reversed list of variables and a list of + initializers. + + (scm_m_letrec): Call 'transform_bindings'. + + (scm_m_let): Minimized scope of local variables. Renamed 'proc' + to 'temp' and 'arg1' to 'binding'. Eliminated redundant SCM_NIMP + test. Use 'transform_bindings'. Fixed scoping error with named + let (Thanks to Aubrey Jaffer for reporting the bug and to Neil + Jerram for suggesting the fix). Cleaned up the control structure + a bit. + + (scm_m_expand_body): Use 'transform_bindings'. Eliminated + unnecessary consing. Eliminated unnecessary + SCM_DEFER/ALLOW_INTS. + + (SCM_CEVAL): Un-obfuscated some loops. + 2001-11-16 Neil Jerram * gc.h (scm_unhash_name): Old declaration removed. diff --git a/libguile/eval.c b/libguile/eval.c index 2977da696..11383acf3 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -405,34 +405,33 @@ SCM_SYMBOL (sym_three_question_marks, "???"); SCM scm_unmemocar (SCM form, SCM env) { - SCM c; - - if (SCM_IMP (form)) + if (!SCM_CONSP (form)) return form; - c = SCM_CAR (form); - if (SCM_VARIABLEP (c)) + else { - SCM sym = scm_module_reverse_lookup (scm_env_module (env), c); - if (SCM_EQ_P (sym, SCM_BOOL_F)) - sym = sym_three_question_marks; - SCM_SETCAR (form, sym); - } + SCM c = SCM_CAR (form); + if (SCM_VARIABLEP (c)) + { + SCM sym = scm_module_reverse_lookup (scm_env_module (env), c); + if (SCM_FALSEP (sym)) + sym = sym_three_question_marks; + SCM_SETCAR (form, sym); + } #ifdef MEMOIZE_LOCALS -#ifdef DEBUG_EXTENSIONS - else if (SCM_ILOCP (c)) - { - long ir; + else if (SCM_ILOCP (c)) + { + unsigned long int ir; - for (ir = SCM_IFRAME (c); ir != 0; --ir) - env = SCM_CDR (env); - env = SCM_CAAR (env); - for (ir = SCM_IDIST (c); ir != 0; --ir) - env = SCM_CDR (env); - SCM_SETCAR (form, SCM_ICDRP (c) ? env : SCM_CAR (env)); + for (ir = SCM_IFRAME (c); ir != 0; --ir) + env = SCM_CDR (env); + env = SCM_CAAR (env); + for (ir = SCM_IDIST (c); ir != 0; --ir) + env = SCM_CDR (env); + SCM_SETCAR (form, SCM_ICDRP (c) ? env : SCM_CAR (env)); + } +#endif + return form; } -#endif -#endif - return form; } @@ -457,6 +456,7 @@ const char scm_s_variable[] = "bad variable"; const char scm_s_clauses[] = "bad or missing clauses"; const char scm_s_formals[] = "bad formals"; const char scm_s_duplicate_formals[] = "duplicate formals"; +static const char s_splicing[] = "bad (non-list) result for unquote-splicing"; SCM_GLOBAL_SYMBOL (scm_sym_dot, "."); SCM_GLOBAL_SYMBOL (scm_sym_arrow, "=>"); @@ -490,7 +490,7 @@ SCM_GLOBAL_SYMBOL (scm_sym_trace, "trace"); static SCM scm_m_body (SCM op, SCM xorig, const char *what) { - SCM_ASSYNT (scm_ilength (xorig) >= 1, scm_s_expression, what); + SCM_ASSYNT (scm_ilength (xorig) >= 1, scm_s_body, what); /* Don't add another ISYM if one is present already. */ if (SCM_ISYMP (SCM_CAR (xorig))) @@ -515,10 +515,8 @@ SCM_GLOBAL_SYMBOL (scm_sym_quote, s_quote); SCM scm_m_quote (SCM xorig, SCM env SCM_UNUSED) { - SCM x = scm_copy_tree (SCM_CDR (xorig)); - SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 1, scm_s_expression, s_quote); - return scm_cons (SCM_IM_QUOTE, x); + return scm_cons (SCM_IM_QUOTE, SCM_CDR (xorig)); } @@ -666,8 +664,8 @@ scm_m_lambda (SCM xorig, SCM env SCM_UNUSED) { SCM formals; SCM x = SCM_CDR (xorig); - if (scm_ilength (x) < 2) - scm_misc_error (s_lambda, scm_s_formals, SCM_EOL); + + SCM_ASSYNT (SCM_CONSP (x), scm_s_formals, s_lambda); formals = SCM_CAR (x); while (SCM_CONSP (formals)) @@ -698,7 +696,9 @@ scm_m_letstar (SCM xorig, SCM env SCM_UNUSED) SCM x = SCM_CDR (xorig); SCM vars = SCM_EOL; SCM *varloc = &vars; - SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_body, s_letstar); + + SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letstar); + bindings = SCM_CAR (x); SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_letstar); while (!SCM_NULLP (bindings)) @@ -710,24 +710,30 @@ scm_m_letstar (SCM xorig, SCM env SCM_UNUSED) varloc = SCM_CDRLOC (SCM_CDR (*varloc)); bindings = SCM_CDR (bindings); } + return scm_cons2 (SCM_IM_LETSTAR, vars, scm_m_body (SCM_IM_LETSTAR, SCM_CDR (x), s_letstar)); } -/* DO gets the most radically altered syntax +/* DO gets the most radically altered syntax. The order of the vars is + * reversed here. In contrast, the order of the inits and steps is reversed + * during the evaluation: + (do (( ) ( ) ... ) ( ) ) + ;; becomes - (do_mem (varn ... var2 var1) + + (#@do (varn ... var2 var1) ( ... ) ( ) () ... ) ;; missing steps replaced by var - */ + */ SCM_SYNTAX(s_do, "do", scm_makmmacro, scm_m_do); SCM_GLOBAL_SYMBOL(scm_sym_do, s_do); @@ -747,19 +753,21 @@ scm_m_do (SCM xorig, SCM env SCM_UNUSED) SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, "do"); while (!SCM_NULLP (bindings)) { - SCM arg1 = SCM_CAR (bindings); - long len = scm_ilength (arg1); + SCM binding = SCM_CAR (bindings); + long len = scm_ilength (binding); SCM_ASSYNT (len == 2 || len == 3, scm_s_bindings, "do"); - SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (arg1)), scm_s_variable, "do"); - /* vars reversed here, inits and steps reversed at evaluation */ - vars = scm_cons (SCM_CAR (arg1), vars); /* variable */ - arg1 = SCM_CDR (arg1); - *initloc = scm_list_1 (SCM_CAR (arg1)); /* init */ - initloc = SCM_CDRLOC (*initloc); - arg1 = SCM_CDR (arg1); - *steploc = scm_list_1 (len == 2 ? SCM_CAR (vars) : SCM_CAR (arg1)); - steploc = SCM_CDRLOC (*steploc); - bindings = SCM_CDR (bindings); + { + SCM name = SCM_CAR (binding); + SCM init = SCM_CADR (binding); + SCM step = (len == 2) ? name : SCM_CADDR (binding); + SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_variable, "do"); + vars = scm_cons (name, vars); + *initloc = scm_list_1 (init); + initloc = SCM_CDRLOC (*initloc); + *steploc = scm_list_1 (step); + steploc = SCM_CDRLOC (*steploc); + bindings = SCM_CDR (bindings); + } } x = SCM_CDR (x); SCM_ASSYNT (scm_ilength (SCM_CAR (x)) >= 1, scm_s_test, "do"); @@ -768,16 +776,68 @@ scm_m_do (SCM xorig, SCM env SCM_UNUSED) return scm_cons (SCM_IM_DO, x); } -/* evalcar is small version of inline EVALCAR when we don't care about - * speed - */ -#define evalcar scm_eval_car +SCM_SYNTAX (s_quasiquote, "quasiquote", scm_makacro, scm_m_quasiquote); +SCM_GLOBAL_SYMBOL (scm_sym_quasiquote, s_quasiquote); -static SCM iqq (SCM form, SCM env, long depth); - -SCM_SYNTAX(s_quasiquote, "quasiquote", scm_makacro, scm_m_quasiquote); -SCM_GLOBAL_SYMBOL(scm_sym_quasiquote, s_quasiquote); +/* Internal function to handle a quasiquotation: 'form' is the parameter in + * the call (quasiquotation form), 'env' is the environment where unquoted + * expressions will be evaluated, and 'depth' is the current quasiquotation + * nesting level and is known to be greater than zero. */ +static SCM +iqq (SCM form, SCM env, unsigned long int depth) +{ + if (SCM_CONSP (form)) + { + SCM tmp = SCM_CAR (form); + if (SCM_EQ_P (tmp, scm_sym_quasiquote)) + { + SCM args = SCM_CDR (form); + SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote); + return scm_list_2 (tmp, iqq (SCM_CAR (args), env, depth + 1)); + } + else if (SCM_EQ_P (tmp, scm_sym_unquote)) + { + SCM args = SCM_CDR (form); + SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote); + if (depth - 1 == 0) + return scm_eval_car (args, env); + else + return scm_list_2 (tmp, iqq (SCM_CAR (args), env, depth - 1)); + } + else if (SCM_CONSP (tmp) + && SCM_EQ_P (SCM_CAR (tmp), scm_sym_uq_splicing)) + { + SCM args = SCM_CDR (tmp); + SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote); + if (depth - 1 == 0) + { + SCM list = scm_eval_car (args, env); + SCM rest = SCM_CDR (form); + SCM_ASSYNT (scm_ilength (list) >= 0, s_splicing, s_quasiquote); + return scm_append (scm_list_2 (list, iqq (rest, env, depth))); + } + else + return scm_cons (iqq (SCM_CAR (form), env, depth - 1), + iqq (SCM_CDR (form), env, depth)); + } + else + return scm_cons (iqq (SCM_CAR (form), env, depth), + iqq (SCM_CDR (form), env, depth)); + } + else if (SCM_VECTORP (form)) + { + size_t i = SCM_VECTOR_LENGTH (form); + SCM *data = SCM_VELTS (form); + SCM tmp = SCM_EOL; + while (i != 0) + tmp = scm_cons (data[--i], tmp); + scm_remember_upto_here_1 (form); + return scm_vector (iqq (tmp, env, depth)); + } + else + return form; +} SCM scm_m_quasiquote (SCM xorig, SCM env) @@ -788,56 +848,14 @@ scm_m_quasiquote (SCM xorig, SCM env) } -static SCM -iqq (SCM form, SCM env, long depth) -{ - SCM tmp; - long edepth = depth; - if (SCM_IMP (form)) - return form; - if (SCM_VECTORP (form)) - { - long i = SCM_VECTOR_LENGTH (form); - SCM *data = SCM_VELTS (form); - tmp = SCM_EOL; - for (; --i >= 0;) - tmp = scm_cons (data[i], tmp); - return scm_vector (iqq (tmp, env, depth)); - } - if (!SCM_CONSP (form)) - return form; - tmp = SCM_CAR (form); - if (SCM_EQ_P (scm_sym_quasiquote, tmp)) - { - depth++; - goto label; - } - if (SCM_EQ_P (scm_sym_unquote, tmp)) - { - --depth; - label: - form = SCM_CDR (form); - SCM_ASSERT (SCM_CONSP (form) && SCM_NULLP (SCM_CDR (form)), - form, SCM_ARG1, s_quasiquote); - if (0 == depth) - return evalcar (form, env); - return scm_list_2 (tmp, iqq (SCM_CAR (form), env, depth)); - } - if (SCM_CONSP (tmp) && (SCM_EQ_P (scm_sym_uq_splicing, SCM_CAR (tmp)))) - { - tmp = SCM_CDR (tmp); - if (0 == --edepth) - return scm_append (scm_list_2 (evalcar (tmp, env), iqq (SCM_CDR (form), env, depth))); - } - return scm_cons (iqq (SCM_CAR (form), env, edepth), iqq (SCM_CDR (form), env, depth)); -} - -/* Here are acros which return values rather than code. */ - SCM_SYNTAX (s_delay, "delay", scm_makmmacro, scm_m_delay); SCM_GLOBAL_SYMBOL (scm_sym_delay, s_delay); -SCM +/* Promises are implemented as closures with an empty parameter list. Thus, + * (delay ) is transformed into (#@delay '() ), where + * the empty list represents the empty parameter list. This representation + * allows for easy creation of the closure during evaluation. */ +SCM scm_m_delay (SCM xorig, SCM env SCM_UNUSED) { SCM_ASSYNT (scm_ilength (xorig) == 2, scm_s_expression, s_delay); @@ -848,83 +866,95 @@ scm_m_delay (SCM xorig, SCM env SCM_UNUSED) SCM_SYNTAX(s_define, "define", scm_makmmacro, scm_m_define); SCM_GLOBAL_SYMBOL(scm_sym_define, s_define); -SCM +/* Guile provides an extension to R5RS' define syntax to represent function + * currying in a compact way. With this extension, it is allowed to write + * (define ), where has of one of + * the forms ( ), ( . ), + * ( ) or ( . ). As in R5RS, + * should be either a sequence of zero or more variables, or a sequence of one + * or more variables followed by a space-delimited period and another + * variable. Each level of argument nesting wraps the within another + * lambda expression. For example, the following forms are allowed, each one + * followed by an equivalent, more explicit implementation. + * Example 1: + * (define ((a b . c) . d) ) is equivalent to + * (define a (lambda (b . c) (lambda d ))) + * Example 2: + * (define (((a) b) c . d) ) is equivalent to + * (define a (lambda () (lambda (b) (lambda (c . d) )))) + */ +/* Dirk:FIXME:: We should provide an implementation for 'define' in the R5RS + * module that does not implement this extension. */ +SCM scm_m_define (SCM x, SCM env) { - SCM proc, arg1 = x; + SCM name; x = SCM_CDR (x); SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_expression, s_define); - proc = SCM_CAR (x); + name = SCM_CAR (x); x = SCM_CDR (x); - while (SCM_CONSP (proc)) - { /* nested define syntax */ - x = scm_list_1 (scm_cons2 (scm_sym_lambda, SCM_CDR (proc), x)); - proc = SCM_CAR (proc); + while (SCM_CONSP (name)) + { + /* This while loop realizes function currying by variable nesting. */ + SCM formals = SCM_CDR (name); + x = scm_list_1 (scm_cons2 (scm_sym_lambda, formals, x)); + name = SCM_CAR (name); } - SCM_ASSYNT (SCM_SYMBOLP (proc), scm_s_variable, s_define); - SCM_ASSYNT (1 == scm_ilength (x), scm_s_expression, s_define); + SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_variable, s_define); + SCM_ASSYNT (scm_ilength (x) == 1, scm_s_expression, s_define); if (SCM_TOP_LEVEL (env)) { - x = evalcar (x, env); -#ifdef DEBUG_EXTENSIONS - if (SCM_REC_PROCNAMES_P && SCM_NIMP (x)) + SCM var; + x = scm_eval_car (x, env); + if (SCM_REC_PROCNAMES_P) { - arg1 = x; - proc: - if (SCM_CLOSUREP (arg1) + SCM tmp = x; + while (SCM_MACROP (tmp)) + tmp = SCM_MACRO_CODE (tmp); + if (SCM_CLOSUREP (tmp) /* Only the first definition determines the name. */ - && SCM_FALSEP (scm_procedure_property (arg1, scm_sym_name))) - scm_set_procedure_property_x (arg1, scm_sym_name, proc); - else if (SCM_MACROP (arg1) - /* Dirk::FIXME: Does the following test make sense? */ - && !SCM_EQ_P (SCM_MACRO_CODE (arg1), arg1)) - { - arg1 = SCM_MACRO_CODE (arg1); - goto proc; - } + && SCM_FALSEP (scm_procedure_property (tmp, scm_sym_name))) + scm_set_procedure_property_x (tmp, scm_sym_name, name); } -#endif - arg1 = scm_sym2var (proc, scm_env_top_level (env), SCM_BOOL_T); - SCM_VARIABLE_SET (arg1, x); -#ifdef SICP - return scm_list_2 (scm_sym_quote, proc); -#else + var = scm_sym2var (name, scm_env_top_level (env), SCM_BOOL_T); + SCM_VARIABLE_SET (var, x); return SCM_UNSPECIFIED; -#endif } - return scm_cons2 (SCM_IM_DEFINE, proc, x); + else + return scm_cons2 (SCM_IM_DEFINE, name, x); } -/* end of acros */ -static SCM -scm_m_letrec1 (SCM op, SCM imm, SCM xorig, SCM env SCM_UNUSED) +/* The bindings ((v1 i1) (v2 i2) ... (vn in)) are transformed to the lists + * (vn ... v2 v1) and (i1 i2 ... in). That is, the list of variables is + * reversed here, the list of inits gets reversed during evaluation. */ +static void +transform_bindings (SCM bindings, SCM *rvarloc, SCM *initloc, const char *what) { - SCM cdrx = SCM_CDR (xorig); /* locally mutable version of form */ - char *what = SCM_SYMBOL_CHARS (SCM_CAR (xorig)); - SCM x = cdrx, proc, arg1; /* structure traversers */ - SCM vars = SCM_EOL, inits = SCM_EOL, *initloc = &inits; + SCM rvars = SCM_EOL; + *rvarloc = SCM_EOL; + *initloc = SCM_EOL; + + SCM_ASSYNT (scm_ilength (bindings) >= 1, scm_s_bindings, what); - proc = SCM_CAR (x); - SCM_ASSYNT (scm_ilength (proc) >= 1, scm_s_bindings, what); do { - /* vars scm_list reversed here, inits reversed at evaluation */ - arg1 = SCM_CAR (proc); - SCM_ASSYNT (2 == scm_ilength (arg1), scm_s_bindings, what); - SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (arg1)), scm_s_variable, what); - if (scm_c_improper_memq (SCM_CAR (arg1), vars)) + SCM binding = SCM_CAR (bindings); + SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, what); + SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, what); + if (scm_c_improper_memq (SCM_CAR (binding), rvars)) scm_misc_error (what, scm_s_duplicate_bindings, SCM_EOL); - vars = scm_cons (SCM_CAR (arg1), vars); - *initloc = scm_list_1 (SCM_CADR (arg1)); + rvars = scm_cons (SCM_CAR (binding), rvars); + *initloc = scm_list_1 (SCM_CADR (binding)); initloc = SCM_CDRLOC (*initloc); + bindings = SCM_CDR (bindings); } - while (SCM_NIMP (proc = SCM_CDR (proc))); + while (!SCM_NULLP (bindings)); - return scm_cons2 (op, vars, - scm_cons (inits, scm_m_body (imm, SCM_CDR (x), what))); + *rvarloc = rvars; } + SCM_SYNTAX(s_letrec, "letrec", scm_makmmacro, scm_m_letrec); SCM_GLOBAL_SYMBOL(scm_sym_letrec, s_letrec); @@ -932,74 +962,89 @@ SCM scm_m_letrec (SCM xorig, SCM env) { SCM x = SCM_CDR (xorig); - SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_body, s_letrec); + SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letrec); - if (SCM_NULLP (SCM_CAR (x))) /* null binding, let* faster */ - return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), SCM_EOL, - scm_m_body (SCM_IM_LETREC, - SCM_CDR (x), - s_letrec)), - env); + if (SCM_NULLP (SCM_CAR (x))) + { + /* null binding, let* faster */ + SCM body = scm_m_body (SCM_IM_LETREC, SCM_CDR (x), s_letrec); + return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), SCM_EOL, body), env); + } else - return scm_m_letrec1 (SCM_IM_LETREC, SCM_IM_LETREC, xorig, env); + { + SCM rvars, inits, body; + transform_bindings (SCM_CAR (x), &rvars, &inits, "letrec"); + body = scm_m_body (SCM_IM_LETREC, SCM_CDR (x), "letrec"); + return scm_cons2 (SCM_IM_LETREC, rvars, scm_cons (inits, body)); + } } + SCM_SYNTAX(s_let, "let", scm_makmmacro, scm_m_let); SCM_GLOBAL_SYMBOL(scm_sym_let, s_let); -SCM +SCM scm_m_let (SCM xorig, SCM env) { - SCM cdrx = SCM_CDR (xorig); /* locally mutable version of form */ - SCM x = cdrx, proc, arg1, name; /* structure traversers */ - SCM vars = SCM_EOL, inits = SCM_EOL, *varloc = &vars, *initloc = &inits; + SCM x = SCM_CDR (xorig); + SCM temp; - SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_body, s_let); - proc = SCM_CAR (x); - if (SCM_NULLP (proc) - || (SCM_CONSP (proc) - && SCM_CONSP (SCM_CAR (proc)) && SCM_NULLP (SCM_CDR (proc)))) + SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_let); + temp = SCM_CAR (x); + if (SCM_NULLP (temp) + || (scm_ilength (temp) == 1 && SCM_CONSP (SCM_CAR (temp)))) { /* null or single binding, let* is faster */ - return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), proc, - scm_m_body (SCM_IM_LET, - SCM_CDR (x), - s_let)), - env); + SCM body = scm_m_body (SCM_IM_LET, SCM_CDR (x), s_let); + return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), temp, body), env); } - - SCM_ASSYNT (SCM_NIMP (proc), scm_s_bindings, s_let); - if (SCM_CONSP (proc)) + else if (SCM_CONSP (temp)) { - /* plain let, proc is */ - return scm_m_letrec1 (SCM_IM_LET, SCM_IM_LET, xorig, env); + /* plain let, temp is */ + SCM rvars, inits, body; + transform_bindings (temp, &rvars, &inits, "let"); + body = scm_m_body (SCM_IM_LET, SCM_CDR (x), "let"); + return scm_cons2 (SCM_IM_LET, rvars, scm_cons (inits, body)); } + else + { + /* named let: Transform (let name ((var init) ...) body ...) into + * ((letrec ((name (lambda (var ...) body ...))) name) init ...) */ - if (!SCM_SYMBOLP (proc)) - scm_misc_error (s_let, scm_s_bindings, SCM_EOL); /* bad let */ - name = proc; /* named let, build equiv letrec */ - x = SCM_CDR (x); - SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_body, s_let); - proc = SCM_CAR (x); /* bindings list */ - SCM_ASSYNT (scm_ilength (proc) >= 0, scm_s_bindings, s_let); - while (SCM_NIMP (proc)) - { /* vars and inits both in order */ - arg1 = SCM_CAR (proc); - SCM_ASSYNT (2 == scm_ilength (arg1), scm_s_bindings, s_let); - SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (arg1)), scm_s_variable, s_let); - *varloc = scm_list_1 (SCM_CAR (arg1)); - varloc = SCM_CDRLOC (*varloc); - *initloc = scm_list_1 (SCM_CADR (arg1)); - initloc = SCM_CDRLOC (*initloc); - proc = SCM_CDR (proc); + SCM name = temp; + SCM vars = SCM_EOL; + SCM *varloc = &vars; + SCM inits = SCM_EOL; + SCM *initloc = &inits; + SCM bindings; + + SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_bindings, s_let); + x = SCM_CDR (x); + SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_let); + bindings = SCM_CAR (x); + SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_let); + while (!SCM_NULLP (bindings)) + { /* vars and inits both in order */ + SCM binding = SCM_CAR (bindings); + SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, s_let); + SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, s_let); + *varloc = scm_list_1 (SCM_CAR (binding)); + varloc = SCM_CDRLOC (*varloc); + *initloc = scm_list_1 (SCM_CADR (binding)); + initloc = SCM_CDRLOC (*initloc); + bindings = SCM_CDR (bindings); + } + + { + SCM lambda_body = scm_m_body (SCM_IM_LET, SCM_CDR (x), "let"); + SCM lambda_form = scm_cons2 (scm_sym_lambda, vars, lambda_body); + SCM rvar = scm_list_1 (name); + SCM init = scm_list_1 (lambda_form); + SCM body = scm_m_body (SCM_IM_LET, scm_list_1 (name), "let"); + SCM letrec = scm_cons2 (SCM_IM_LETREC, rvar, scm_cons (init, body)); + return scm_cons (letrec, inits); + } } - - proc = scm_cons2 (scm_sym_lambda, vars, - scm_m_body (SCM_IM_LET, SCM_CDR (x), "let")); - proc = scm_list_3 (scm_sym_let, - scm_list_1 (scm_list_2 (name, proc)), - scm_cons (name, inits)); - return scm_m_letrec1 (SCM_IM_LETREC, SCM_IM_LET, proc, env); } @@ -1205,19 +1250,21 @@ scm_m_expand_body (SCM xorig, SCM env) } } - SCM_ASSYNT (SCM_NIMP (x), scm_s_body, what); - if (SCM_NIMP (defs)) + if (!SCM_NULLP (defs)) { - x = scm_list_1 (scm_m_letrec1 (SCM_IM_LETREC, - SCM_IM_DEFINE, - scm_cons2 (scm_sym_define, defs, x), - env)); + SCM rvars, inits, body, letrec; + transform_bindings (defs, &rvars, &inits, what); + body = scm_m_body (SCM_IM_DEFINE, x, what); + letrec = scm_cons2 (SCM_IM_LETREC, rvars, scm_cons (inits, body)); + SCM_SETCAR (xorig, letrec); + SCM_SETCDR (xorig, SCM_EOL); + } + else + { + SCM_ASSYNT (SCM_CONSP (x), scm_s_body, what); + SCM_SETCAR (xorig, SCM_CAR (x)); + SCM_SETCDR (xorig, SCM_CDR (x)); } - - SCM_DEFER_INTS; - SCM_SETCAR (xorig, SCM_CAR (x)); - SCM_SETCDR (xorig, SCM_CDR (x)); - SCM_ALLOW_INTS; return xorig; } @@ -1947,14 +1994,13 @@ dispatch: case SCM_BIT8(SCM_IM_AND): x = SCM_CDR (x); - t.arg1 = x; - while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1))) - if (SCM_FALSEP (EVALCAR (x, env))) - { + while (!SCM_NULLP (SCM_CDR (x))) + { + if (SCM_FALSEP (EVALCAR (x, env))) RETURN (SCM_BOOL_F); - } - else - x = t.arg1; + else + x = SCM_CDR (x); + } PREP_APPLY (SCM_UNDEFINED, SCM_EOL); goto carloop; @@ -1974,13 +2020,12 @@ dispatch: with the current module. */ if (SCM_CONSP (env) && !SCM_CONSP (SCM_CAR (env))) { - t.arg1 = x; UPDATE_TOPLEVEL_ENV (env); - while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1))) + while (!SCM_NULLP (SCM_CDR (x))) { EVALCAR (x, env); - x = t.arg1; UPDATE_TOPLEVEL_ENV (env); + x = SCM_CDR (x); } goto carloop; } @@ -1992,8 +2037,7 @@ dispatch: nontoplevel_cdrxbegin: x = SCM_CDR (x); nontoplevel_begin: - t.arg1 = x; - while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1))) + while (!SCM_NULLP (SCM_CDR (x))) { if (SCM_IMP (SCM_CAR (x))) { @@ -2007,7 +2051,7 @@ dispatch: } else SCM_CEVAL (SCM_CAR (x), env); - x = t.arg1; + x = SCM_CDR (x); } carloop: /* scm_eval car of last form in list */ @@ -2159,32 +2203,34 @@ dispatch: case SCM_BIT8(SCM_IM_LETSTAR): x = SCM_CDR (x); - proc = SCM_CAR (x); - if (SCM_IMP (proc)) - { + { + SCM bindings = SCM_CAR (x); + if (SCM_NULLP (bindings)) env = EXTEND_ENV (SCM_EOL, SCM_EOL, env); - goto nontoplevel_cdrxnoap; - } - do - { - t.arg1 = SCM_CAR (proc); - proc = SCM_CDR (proc); - env = EXTEND_ENV (t.arg1, EVALCAR (proc, env), env); - } - while (SCM_NIMP (proc = SCM_CDR (proc))); + else + { + do + { + SCM name = SCM_CAR (bindings); + SCM init = SCM_CDR (bindings); + env = EXTEND_ENV (name, EVALCAR (init, env), env); + bindings = SCM_CDR (init); + } + while (!SCM_NULLP (bindings)); + } + } goto nontoplevel_cdrxnoap; + case SCM_BIT8(SCM_IM_OR): x = SCM_CDR (x); - t.arg1 = x; - while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1))) + while (!SCM_NULLP (SCM_CDR (x))) { - x = EVALCAR (x, env); - if (!SCM_FALSEP (x)) - { - RETURN (x); - } - x = t.arg1; + SCM val = EVALCAR (x, env); + if (!SCM_FALSEP (val)) + RETURN (val); + else + x = SCM_CDR (x); } PREP_APPLY (SCM_UNDEFINED, SCM_EOL); goto carloop; @@ -2289,7 +2335,7 @@ dispatch: RETURN (val); } proc = SCM_CDR (x); - proc = evalcar (proc, env); + proc = scm_eval_car (proc, env); SCM_ASRTGO (SCM_NIMP (proc), badfun); PREP_APPLY (proc, scm_list_1 (t.arg1)); ENTER_APPLY; From 7171f1ab47ee8c9950cbb4cb90ede4c68fffa31e Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 17 Nov 2001 11:44:06 +0000 Subject: [PATCH 167/281] * tests/syntax.test: Added some tests, updated some others with respect to recent changes in eval.c. Further, extracted test cases for guile's extended set! functionality to srfi-17.test. * tests/srfi-17.test: New file. --- test-suite/ChangeLog | 8 ++ test-suite/tests/srfi-17.test | 32 ++++++ test-suite/tests/syntax.test | 196 +++++++++++++++++++--------------- 3 files changed, 147 insertions(+), 89 deletions(-) create mode 100644 test-suite/tests/srfi-17.test diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index b91212dad..9f6893202 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,11 @@ +2001-11-17 Dirk Herrmann + + * tests/syntax.test: Added some tests, updated some others with + respect to recent changes in eval.c. Further, extracted test + cases for guile's extended set! functionality to srfi-17.test. + + * tests/srfi-17.test: New file. + 2001-11-04 Stefan Jahn * tests/ports.test: Run (close-port) before (delete-file) if diff --git a/test-suite/tests/srfi-17.test b/test-suite/tests/srfi-17.test new file mode 100644 index 000000000..dc6fd7e06 --- /dev/null +++ b/test-suite/tests/srfi-17.test @@ -0,0 +1,32 @@ +;;;; srfi-17.test --- test suite for Guile's SRFI-17 functions. -*- scheme -*- +;;;; +;;;; Copyright (C) 2001 Free Software Foundation, Inc. +;;;; +;;;; This program is free software; you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation; either version 2, or (at your option) +;;;; any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this software; see the file COPYING. If not, write to +;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, +;;;; Boston, MA 02111-1307 USA + +(use-modules (srfi srfi-17)) + +(with-test-prefix "set!" + + (with-test-prefix "target is not procedure with setter" + + (pass-if-exception "(set! (symbol->string 'x) 1)" + exception:wrong-type-arg + (set! (symbol->string 'x) 1)) + + (pass-if-exception "(set! '#f 1)" + exception:wrong-type-arg + (set! '#f 1)))) diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test index 2c5f06bf2..14836fbc9 100644 --- a/test-suite/tests/syntax.test +++ b/test-suite/tests/syntax.test @@ -51,6 +51,34 @@ exception:missing/extra-expr ()))) +(with-test-prefix "quote" + #t) + +(with-test-prefix "quasiquote" + + (with-test-prefix "unquote" + + (pass-if "repeated execution" + (let ((foo (let ((i 0)) (lambda () (set! i (+ i 1)) `(,i))))) + (and (equal? (foo) '(1)) (equal? (foo) '(2)))))) + + (with-test-prefix "unquote-splicing" + + (pass-if-exception "extra arguments" + exception:missing/extra-expr + (quasiquote ((unquote-splicing (list 1 2) (list 3 4))))))) + +(with-test-prefix "begin" + + (pass-if "legal (begin)" + (begin) + #t) + + (expect-fail-exception "illegal (begin)" + exception:bad-body + (if #t (begin)) + #t)) + (with-test-prefix "lambda" (with-test-prefix "bad formals" @@ -63,10 +91,6 @@ exception:bad-formals (lambda . "foo")) - (pass-if-exception "(lambda ())" - exception:bad-formals - (lambda ())) - (pass-if-exception "(lambda \"foo\")" exception:bad-formals (lambda "foo")) @@ -101,7 +125,13 @@ ;; Fixed on 2001-3-3 (pass-if-exception "(lambda (x x x) 1)" exception:duplicate-formals - (lambda (x x x) 1)))) + (lambda (x x x) 1))) + + (with-test-prefix "bad body" + + (pass-if-exception "(lambda ())" + exception:bad-body + (lambda ())))) (with-test-prefix "let" @@ -111,35 +141,25 @@ exception:unbound-var (let ((x 1) (y x)) y))) - (with-test-prefix "bad body" + (with-test-prefix "bad bindings" - (pass-if-exception "(let ())" - exception:bad-body - (let ())) - - (pass-if-exception "(let ((x 1)))" - exception:bad-body - (let ((x 1)))) - - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(let)" - exception:bad-body + exception:bad-bindings (let)) - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(let 1)" - exception:bad-body + exception:bad-bindings (let 1)) - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(let (x))" - exception:bad-body - (let (x)))) + exception:bad-bindings + (let (x))) - (with-test-prefix "bad bindings" + ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? + ;; (Even although the body is bad as well...) + (pass-if-exception "(let ((x)))" + exception:bad-body + (let ((x)))) (pass-if-exception "(let (x) 1)" exception:bad-bindings @@ -161,10 +181,32 @@ (pass-if-exception "(let ((x 1) (x 2)) x)" exception:duplicate-bindings - (let ((x 1) (x 2)) x)))) + (let ((x 1) (x 2)) x))) + + (with-test-prefix "bad body" + + (pass-if-exception "(let ())" + exception:bad-body + (let ())) + + (pass-if-exception "(let ((x 1)))" + exception:bad-body + (let ((x 1)))))) (with-test-prefix "named let" + (with-test-prefix "initializers" + + (pass-if "evaluated in outer environment" + (let ((f -)) + (eqv? (let f ((n (f 1))) n) -1)))) + + (with-test-prefix "bad bindings" + + (pass-if-exception "(let x (y))" + exception:bad-bindings + (let x (y)))) + (with-test-prefix "bad body" (pass-if-exception "(let x ())" @@ -173,13 +215,7 @@ (pass-if-exception "(let x ((y 1)))" exception:bad-body - (let x ((y 1)))) - - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? - (pass-if-exception "(let x (y))" - exception:bad-body - (let x (y))))) + (let x ((y 1)))))) (with-test-prefix "let*" @@ -193,35 +229,19 @@ (let* ((x 1) (x x)) (= x 1)))) - (with-test-prefix "bad body" + (with-test-prefix "bad bindings" - (pass-if-exception "(let* ())" - exception:bad-body - (let* ())) - - (pass-if-exception "(let* ((x 1)))" - exception:bad-body - (let* ((x 1)))) - - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(let*)" - exception:bad-body + exception:bad-bindings (let*)) - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(let* 1)" - exception:bad-body + exception:bad-bindings (let* 1)) - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(let* (x))" - exception:bad-body - (let* (x)))) - - (with-test-prefix "bad bindings" + exception:bad-bindings + (let* (x))) (pass-if-exception "(let* (x) 1)" exception:bad-bindings @@ -245,7 +265,17 @@ (pass-if-exception "(let* ((1 2)) 3)" exception:bad-var - (let* ((1 2)) 3)))) + (let* ((1 2)) 3))) + + (with-test-prefix "bad body" + + (pass-if-exception "(let* ())" + exception:bad-body + (let* ())) + + (pass-if-exception "(let* ((x 1)))" + exception:bad-body + (let* ((x 1)))))) (with-test-prefix "letrec" @@ -256,35 +286,19 @@ (let ((x 1)) (letrec ((x 1) (y x)) y)))) - (with-test-prefix "bad body" + (with-test-prefix "bad bindings" - (pass-if-exception "(letrec ())" - exception:bad-body - (letrec ())) - - (pass-if-exception "(letrec ((x 1)))" - exception:bad-body - (letrec ((x 1)))) - - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(letrec)" - exception:bad-body + exception:bad-bindings (letrec)) - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(letrec 1)" - exception:bad-body + exception:bad-bindings (letrec 1)) - ;; FIXME: Wouldn't one rather expect a 'bad bindings' error? - ;; Hmm, the body is bad as well, isn't it? (pass-if-exception "(letrec (x))" - exception:bad-body - (letrec (x)))) - - (with-test-prefix "bad bindings" + exception:bad-bindings + (letrec (x))) (pass-if-exception "(letrec (x) 1)" exception:bad-bindings @@ -314,7 +328,17 @@ (pass-if-exception "(letrec ((x 1) (x 2)) x)" exception:duplicate-bindings - (letrec ((x 1) (x 2)) x)))) + (letrec ((x 1) (x 2)) x))) + + (with-test-prefix "bad body" + + (pass-if-exception "(letrec ())" + exception:bad-body + (letrec ())) + + (pass-if-exception "(letrec ((x 1)))" + exception:bad-body + (letrec ((x 1)))))) (with-test-prefix "if" @@ -445,6 +469,12 @@ (with-test-prefix "define" + (with-test-prefix "currying" + + (pass-if "(define ((foo)) #f)" + (define ((foo)) #t) + ((foo)))) + (with-test-prefix "missing or extra expressions" (pass-if-exception "(define)" @@ -489,18 +519,6 @@ exception:bad-var (set! #\space #f)))) -(with-test-prefix "generalized set! (SRFI 17)" - - (with-test-prefix "target is not procedure with setter" - - (pass-if-exception "(set! (symbol->string 'x) 1)" - exception:wrong-type-arg - (set! (symbol->string 'x) 1)) - - (pass-if-exception "(set! '#f 1)" - exception:wrong-type-arg - (set! '#f 1)))) - (with-test-prefix "quote" (with-test-prefix "missing or extra expression" From 3096b33f0d2984fa602c9943078f078668d3d542 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Sat, 17 Nov 2001 12:16:05 +0000 Subject: [PATCH 168/281] * Oops, this belongs to the previous ChangeLog entry... --- libguile/eval.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libguile/eval.c b/libguile/eval.c index 11383acf3..73ac4eceb 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -995,14 +995,16 @@ scm_m_let (SCM xorig, SCM env) || (scm_ilength (temp) == 1 && SCM_CONSP (SCM_CAR (temp)))) { /* null or single binding, let* is faster */ + SCM bindings = temp; SCM body = scm_m_body (SCM_IM_LET, SCM_CDR (x), s_let); - return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), temp, body), env); + return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), bindings, body), env); } else if (SCM_CONSP (temp)) { - /* plain let, temp is */ + /* plain let */ + SCM bindings = temp; SCM rvars, inits, body; - transform_bindings (temp, &rvars, &inits, "let"); + transform_bindings (bindings, &rvars, &inits, "let"); body = scm_m_body (SCM_IM_LET, SCM_CDR (x), "let"); return scm_cons2 (SCM_IM_LET, rvars, scm_cons (inits, body)); } From 694a9bb34e8c07fa265373876323e5aa30465334 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sun, 18 Nov 2001 22:10:41 +0000 Subject: [PATCH 169/281] * Updates for string- and vector-move-right/left! docstrings. * Update Tcl war URLs. --- doc/maint/guile.texi | 18 ++++++++++++++++-- doc/ref/ChangeLog | 5 +++++ doc/ref/scheme-data.texi | 18 ++++++++++++++++-- doc/tutorial/ChangeLog | 5 +++++ doc/tutorial/guile-tut.texi | 4 ++-- libguile/ChangeLog | 6 ++++++ libguile/vectors.c | 16 ++++++++++++++-- 7 files changed, 64 insertions(+), 8 deletions(-) diff --git a/doc/maint/guile.texi b/doc/maint/guile.texi index a099e3dd7..1b7eb67c9 100644 --- a/doc/maint/guile.texi +++ b/doc/maint/guile.texi @@ -4986,13 +4986,27 @@ returned by @code{vector-fill!} is unspecified. vector-move-left! @deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2 @deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2) -Vector version of @code{substring-move-left!}. +Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, +to @var{vec2} starting at position @var{start2}. @var{start1} and +@var{start2} are inclusive indices; @var{end1} is exclusive. + +@code{vector-move-left!} copies elements in leftmost order. +Therefore, in the case where @var{vec1} and @var{vec2} refer to the +same vector, @code{vector-move-left!} is usually appropriate when +@var{start1} is greater than @var{start2}. @end deffn vector-move-right! @deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2 @deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2) -Vector version of @code{substring-move-right!}. +Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, +to @var{vec2} starting at position @var{start2}. @var{start1} and +@var{start2} are inclusive indices; @var{end1} is exclusive. + +@code{vector-move-right!} copies elements in rightmost order. +Therefore, in the case where @var{vec1} and @var{vec2} refer to the +same vector, @code{vector-move-right!} is usually appropriate when +@var{start1} is less than @var{start2}. @end deffn major-version diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 8236d1649..ed8f871c2 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-11-18 Neil Jerram + + * scheme-data.texi (Vectors): Autoupdate docs for + vector-move-left! and vector-move-right!. + 2001-11-16 Neil Jerram * debugging.texi, deprecated.texi, intro.texi, misc-modules.texi, diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index e8ffd3a81..77e9a654c 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -3515,12 +3515,26 @@ returned by @code{vector-fill!} is unspecified. @deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2 @deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2) -Vector version of @code{substring-move-left!}. +Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, +to @var{vec2} starting at position @var{start2}. @var{start1} and +@var{start2} are inclusive indices; @var{end1} is exclusive. + +@code{vector-move-left!} copies elements in leftmost order. +Therefore, in the case where @var{vec1} and @var{vec2} refer to the +same vector, @code{vector-move-left!} is usually appropriate when +@var{start1} is greater than @var{start2}. @end deffn @deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2 @deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2) -Vector version of @code{substring-move-right!}. +Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, +to @var{vec2} starting at position @var{start2}. @var{start1} and +@var{start2} are inclusive indices; @var{end1} is exclusive. + +@code{vector-move-right!} copies elements in rightmost order. +Therefore, in the case where @var{vec1} and @var{vec2} refer to the +same vector, @code{vector-move-right!} is usually appropriate when +@var{start1} is less than @var{start2}. @end deffn @subsection Vector Selection diff --git a/doc/tutorial/ChangeLog b/doc/tutorial/ChangeLog index b784f824c..eea1de221 100644 --- a/doc/tutorial/ChangeLog +++ b/doc/tutorial/ChangeLog @@ -1,3 +1,8 @@ +2001-11-18 Neil Jerram + + * guile-tut.texi (History of Guile and its motivations): Update + Tcl war URLs. + 2001-09-19 Thien-Thi Nguyen * guile-tut.texi: Fix improper `@result' usage. diff --git a/doc/tutorial/guile-tut.texi b/doc/tutorial/guile-tut.texi index 477cdac3e..eb6345d86 100644 --- a/doc/tutorial/guile-tut.texi +++ b/doc/tutorial/guile-tut.texi @@ -285,7 +285,7 @@ In the fall of 1994, Richard Stallman, director of the GNU project, posted an article with the subject "Why you should not use Tcl", in which he argued that Tcl is inadequate as an extension language. This generated a flurry of flames (available in the hypermail archive -(@url{http://www.utdallas.edu/acc/glv/Tcl/war/}) @strong{The Tcl War}). +(@url{http://www.vanderburg.org/Tcl/war/}) @strong{The Tcl War}). @cindex Stallman, Richard @cindex GNU project @cindex Tcl @@ -293,7 +293,7 @@ generated a flurry of flames (available in the hypermail archive The result was that Stallman then proposed his design for the GNU Extension Language, first called GEL and then renamed Guile. The discussion triggered by that article is also available in a hypermail -archive, @url{http://www.utdallas.edu/acc/glv/Tcl/war2/}. +archive, @url{http://www.vanderburg.org/Tcl/war2/}. One interesting feature of this GNU Extension Language plan was that users should have a @emph{choice} of languages to use in extending their diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 53b6a1b19..b88a6ee4d 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2001-11-18 Neil Jerram + + * vectors.c (scm_vector_move_left_x, scm_vector_move_right_x): + Rewrite docstrings without reference to substring-move-left/right, + since the latter no longer exist. + 2001-11-17 Dirk Herrmann * eval.c: Removed bogus comment about acros. diff --git a/libguile/vectors.c b/libguile/vectors.c index 36ffda380..425eee58a 100644 --- a/libguile/vectors.c +++ b/libguile/vectors.c @@ -275,7 +275,13 @@ scm_vector_equal_p(SCM x, SCM y) SCM_DEFINE (scm_vector_move_left_x, "vector-move-left!", 5, 0, 0, (SCM vec1, SCM start1, SCM end1, SCM vec2, SCM start2), - "Vector version of @code{substring-move-left!}.") + "Copy elements from @var{vec1}, positions @var{start1} to @var{end1},\n" + "to @var{vec2} starting at position @var{start2}. @var{start1} and\n" + "@var{start2} are inclusive indices; @var{end1} is exclusive.\n\n" + "@code{vector-move-left!} copies elements in leftmost order.\n" + "Therefore, in the case where @var{vec1} and @var{vec2} refer to the\n" + "same vector, @code{vector-move-left!} is usually appropriate when\n" + "@var{start1} is greater than @var{start2}.") #define FUNC_NAME s_scm_vector_move_left_x { long i; @@ -298,7 +304,13 @@ SCM_DEFINE (scm_vector_move_left_x, "vector-move-left!", 5, 0, 0, SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 5, 0, 0, (SCM vec1, SCM start1, SCM end1, SCM vec2, SCM start2), - "Vector version of @code{substring-move-right!}.") + "Copy elements from @var{vec1}, positions @var{start1} to @var{end1},\n" + "to @var{vec2} starting at position @var{start2}. @var{start1} and\n" + "@var{start2} are inclusive indices; @var{end1} is exclusive.\n\n" + "@code{vector-move-right!} copies elements in rightmost order.\n" + "Therefore, in the case where @var{vec1} and @var{vec2} refer to the\n" + "same vector, @code{vector-move-right!} is usually appropriate when\n" + "@var{start1} is less than @var{start2}.") #define FUNC_NAME s_scm_vector_move_right_x { long i; From 5c790b44f81d6aa53fd2073fa143106b7c990a70 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 18 Nov 2001 23:03:10 +0000 Subject: [PATCH 170/281] *** empty log message *** --- NEWS | 5 +++++ libguile/ChangeLog | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/NEWS b/NEWS index bb6b07cdf..1c21cf408 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,11 @@ micro version number. In addition, ./GUILE-VERSION now defines GUILE_MICRO_VERSION. +** New preprocessor definitions are available for checking versions. + +version.h now #defines SCM_MAJOR_VERSION, SCM_MINOR_VERSION, and +SCM_MICRO_VERSION to the appropriate integer values. + ** Guile now actively warns about deprecated features. The new configure option `--enable-deprecated=LEVEL' and the diff --git a/libguile/ChangeLog b/libguile/ChangeLog index b88a6ee4d..08e71ec0b 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,17 @@ +2001-11-18 Rob Browning + + * version.c + (s_scm_major_version): use SCM_MAJOR_VERSION. + (s_scm_minor_version): use SCM_MINOR_VERSION. + (s_scm_micro_version): use SCM_MICRO_VERSION. + (s_scm_version): use SCM_MAJOR_VERSION, SCM_MINOR_VERSION, and + SCM_MICRO_VERSION. + + * version.h.in + (SCM_MAJOR_VERSION): renamed from SCM_GUILE_MAJOR_VERSION. + (SCM_MINOR_VERSION): renamed from SCM_GUILE_MINOR_VERSION. + (SCM_MICRO_VERSION): renamed from SCM_GUILE_MICRO_VERSION. + 2001-11-18 Neil Jerram * vectors.c (scm_vector_move_left_x, scm_vector_move_right_x): From 76f33258bb48664b99eb164fe9b96c6b86938120 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 18 Nov 2001 23:04:10 +0000 Subject: [PATCH 171/281] * version.c (s_scm_major_version): use SCM_MAJOR_VERSION. (s_scm_minor_version): use SCM_MINOR_VERSION. (s_scm_micro_version): use SCM_MICRO_VERSION. (s_scm_version): use SCM_MAJOR_VERSION, SCM_MINOR_VERSION, and SCM_MICRO_VERSION. --- libguile/version.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libguile/version.c b/libguile/version.c index b99d77710..1a5773d31 100644 --- a/libguile/version.c +++ b/libguile/version.c @@ -59,7 +59,7 @@ SCM_DEFINE (scm_major_version, "major-version", 0, 0, 0, "E.g., the 1 in \"1.6.5\".") #define FUNC_NAME s_scm_major_version { - return scm_number_to_string (SCM_MAKINUM(SCM_GUILE_MAJOR_VERSION), + return scm_number_to_string (SCM_MAKINUM(SCM_MAJOR_VERSION), SCM_MAKINUM(10)); } #undef FUNC_NAME @@ -72,7 +72,7 @@ SCM_DEFINE (scm_minor_version, "minor-version", 0, 0, 0, "E.g., the 6 in \"1.6.5\".") #define FUNC_NAME s_scm_minor_version { - return scm_number_to_string (SCM_MAKINUM(SCM_GUILE_MINOR_VERSION), + return scm_number_to_string (SCM_MAKINUM(SCM_MINOR_VERSION), SCM_MAKINUM(10)); } #undef FUNC_NAME @@ -85,7 +85,7 @@ SCM_DEFINE (scm_micro_version, "micro-version", 0, 0, 0, "E.g., the 5 in \"1.6.5\".") #define FUNC_NAME s_scm_micro_version { - return scm_number_to_string (SCM_MAKINUM(SCM_GUILE_MICRO_VERSION), + return scm_number_to_string (SCM_MAKINUM(SCM_MICRO_VERSION), SCM_MAKINUM(10)); } #undef FUNC_NAME @@ -110,15 +110,15 @@ SCM_DEFINE (scm_version, "version", 0, 0, 0, char version_str[3 * 4 + 3]; -#if SCM_GUILE_MAJOR_VERSION > 9999 || SCM_GUILE_MINOR_VERSION > 9999 \ - || SCM_GUILE_MICRO_VERSION > 9999 +#if SCM_MAJOR_VERSION > 9999 \ + || SCM_MINOR_VERSION > 9999 \ + || SCM_MICRO_VERSION > 9999 # error version string may overflow buffer #endif sprintf (version_str, "%d.%d.%d", - SCM_GUILE_MAJOR_VERSION, - SCM_GUILE_MINOR_VERSION, - SCM_GUILE_MICRO_VERSION); - + SCM_MAJOR_VERSION, + SCM_MINOR_VERSION, + SCM_MICRO_VERSION); return scm_makfrom0str (version_str); } #undef FUNC_NAME From 6acaff8204e0aab6aa9ed605f4eb714f43c026fa Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 18 Nov 2001 23:04:32 +0000 Subject: [PATCH 172/281] * version.h.in (SCM_MAJOR_VERSION): renamed from SCM_GUILE_MAJOR_VERSION. (SCM_MINOR_VERSION): renamed from SCM_GUILE_MINOR_VERSION. (SCM_MICRO_VERSION): renamed from SCM_GUILE_MICRO_VERSION. --- libguile/version.h.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libguile/version.h.in b/libguile/version.h.in index 763c90bce..f6a632d2e 100644 --- a/libguile/version.h.in +++ b/libguile/version.h.in @@ -50,9 +50,9 @@ -#define SCM_GUILE_MAJOR_VERSION @GUILE_MAJOR_VERSION@ -#define SCM_GUILE_MINOR_VERSION @GUILE_MINOR_VERSION@ -#define SCM_GUILE_MICRO_VERSION @GUILE_MICRO_VERSION@ +#define SCM_MAJOR_VERSION @GUILE_MAJOR_VERSION@ +#define SCM_MINOR_VERSION @GUILE_MINOR_VERSION@ +#define SCM_MICRO_VERSION @GUILE_MICRO_VERSION@ extern SCM scm_major_version (void); extern SCM scm_minor_version (void); From 097914898df225e59288f3fd12f9f0243d846587 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Mon, 19 Nov 2001 06:30:29 +0000 Subject: [PATCH 173/281] * configure.in: switch to AC_LIBLTDL_INSTALLABLE so we'll use the system libltdl when it's available. Aside from the normal reasons to prefer installed shared libs, this means other apps that link with libguile and also use libltdl will be more likely to work right. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 1cbecb350..9a40ffdfe 100644 --- a/configure.in +++ b/configure.in @@ -157,7 +157,7 @@ AC_CYGWIN AC_MINGW32 AC_LIBTOOL_WIN32_DLL -AC_LIBLTDL_CONVENIENCE +AC_LIBLTDL_INSTALLABLE AC_CONFIG_SUBDIRS(libltdl) AC_PROG_INSTALL From 3faa54e7dd196be763fc21e159d93094ecdc4343 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Mon, 19 Nov 2001 06:30:38 +0000 Subject: [PATCH 174/281] *** empty log message *** --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 235e0c8ee..402bcd031 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-11-19 Rob Browning + + * configure.in: switch to AC_LIBLTDL_INSTALLABLE so we'll use the + system libltdl when it's available. Aside from the normal reasons + to prefer installed shared libs, this means other apps that link + with libguile and also use libltdl will be more likely to work + right. + 2001-11-15 Thien-Thi Nguyen * guile-tools.in: Handle command "list" specially: list scripts dir. From ebc43ccb6dbe81fc861a76bffacea498f45b3794 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 06:59:38 +0000 Subject: [PATCH 175/281] (patch-send): Renamed from `patch-submit'. Gadzooks what kind of world is this? --- emacs/patch.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emacs/patch.el b/emacs/patch.el index e97c4231b..af8c45dfc 100644 --- a/emacs/patch.el +++ b/emacs/patch.el @@ -31,9 +31,9 @@ ;; On the patch creation side of things, there are various version ;; control systems that are happy to write a diff to stdout (and ;; numerous Emacs interfaces to them all). Thus, we provide only a -;; simple `patch-submit' that composes mail from the current buffer; +;; simple `patch-send' that composes mail from the current buffer; ;; the contents of that buffer are left as an exercise for the patch -;; creator. When preparing the mail, `patch-submit' scans the patch +;; creator. When preparing the mail, `patch-send' scans the patch ;; for standard filename headers and sets up a skeleton change log -- ;; filling this in is a good way to earn respect from maintainers (hint ;; hint). Type `C-c C-c' to send the mail when you are done. (See @@ -82,7 +82,7 @@ files "\n"))) -(defun patch-submit (buffer subject) +(defun patch-send (buffer subject) (interactive "bBuffer: \nsSubject: ") (when (string= "" subject) (error "(empty subject)")) From e12cfbc65c9e0e9f6ed61dbbbef3b3e2b039023e Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 07:12:22 +0000 Subject: [PATCH 176/281] A little birdie from cobalt sang in my ear. As guilish developers uploaded, disappeared. Thunderous silence? Mail server grievance? Mangle that process (son), but don't drink the beer. --- emacs/update-change.el | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 emacs/update-change.el diff --git a/emacs/update-change.el b/emacs/update-change.el new file mode 100644 index 000000000..e69de29bb From 0aded5b003e2befc033e8e88028424ee8fd4eea9 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 08:39:24 +0000 Subject: [PATCH 177/281] bye bye --- emacs/update-change.el | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 emacs/update-change.el diff --git a/emacs/update-change.el b/emacs/update-change.el deleted file mode 100644 index e69de29bb..000000000 From 817c6eca8bfdce405c69ae3316eb494217c2ae12 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 08:55:38 +0000 Subject: [PATCH 178/281] Initial revision --- emacs/update-changelog.el | 163 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 emacs/update-changelog.el diff --git a/emacs/update-changelog.el b/emacs/update-changelog.el new file mode 100644 index 000000000..e55f968ac --- /dev/null +++ b/emacs/update-changelog.el @@ -0,0 +1,163 @@ +;;; update-changelog.el --- stitch rcs2log output to ChangeLog + +;;; Copyright (C) 2001 Free Software Foundation, Inc. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Usage: emacs -batch -l update-changelog.el +;; +;; This program is basically a wrapper around rcs2log, and inherits rcs2log's +;; weaknesses, namely, the requirement that there be a checked out (working +;; directory) copy. It would be nice if rcs2log grokked with the repository +;; directly, but until then, we work around it by requiring the environment +;; var `LOCAL_WORK_ROOT' to be defined. This should be a directory under +;; which cvs modules are checked out. +;; +;; Flash! Newer versions of rcs2log do indeed understand the repository, +;; and can be invoked with "-R" therein. We infer this if `LOCAL_WORK_ROOT' +;; is not set, and use instead `CVSROOT'. At least one of these must be set. +;; +;; The ChangeLog files are by default updated in the cwd, unless overriden by +;; the environment variable `CHANGELOG_DIR', with the name MODULE.ChangeLog. +;; No new files are created; you must manually touch a file to have the next +;; ucl run notice it. +;; +;; You can pass additional options to rcs2log using env var `RCS2LOG_OPTS'. +;; +;; Usage from a Lisp program: +;; (ucl-root) -- return dir of ChangeLog or error if not found +;; (ucl-update module-dir) -- get cvs logs starting in CVSROOT/MODULE-DIR, +;; stitch them to ./ChangeLog, and write it out + +;;; Code: + +;;;--------------------------------------------------------------------------- +;;; Variables + +(defvar ucl-outdir (expand-file-name (or (getenv "CHANGELOG_DIR") + default-directory)) + "Directory containing changelogs (one per cvs module) to be updated.") + +(defvar ucl-o (or (getenv "RCS2LOG_OPTS") "") + "Additional options to pass to rcs2log.") + +;;;--------------------------------------------------------------------------- +;;; Cleanup functions + +(defun ucl-stitch-new-old (new-old &rest ignore) + "In a changelog buffer, remove redundancy around NEW-OLD point. +The new text is before NEW-OLD point, and the old after." + (goto-char new-old) + (or (= new-old (point-max)) ; no old + (let ((last-new + (save-excursion + (buffer-substring (re-search-backward "^[0-9]+") new-old)))) + (let ((has-diff (string-match "\n\tdiff.*-r" last-new))) ; ugh + (and has-diff (setq last-new (substring last-new 0 has-diff)))) + (let ((overlap (search-forward last-new (point-max) t))) + (and overlap (delete-region new-old overlap)))))) + +;; Sometimes wannabe developers append diffs to their log entries. +(defun ucl-omit-diffs (&rest ignore) + "In a changelog buffer, delete diffs (assumed at end of entry)." + (goto-char (point-min)) + (while (re-search-forward "^\tdiff .*-r" (point-max) t) + (beginning-of-line) + (delete-region (point) + (save-excursion + (if (re-search-forward "^[0-9]+" (point-max)) + (- (point) 4) + (point-max)))))) + +(defun ucl-space-out-entries (&rest ignore) + "In a changelog buffer, ensure proper spacing between entries." + (goto-char (point-max)) + (while (re-search-backward "^[0-9]+" (point-min) t) + (unless (= (point) (point-min)) + (open-line 3) ; yuk + (delete-blank-lines)))) + +(defun ucl-kill-eol-white-space (&rest ignore) + "In a changelog buffer, delete end-of-line white space." + (goto-char (point-min)) + (while (re-search-forward "[ \t]+$" (point-max) t) + (delete-region + (match-beginning 0) (match-end 0)))) + +(defvar ucl-cleanup-hook '(ucl-stitch-new-old + ucl-omit-diffs + ucl-space-out-entries + ucl-kill-eol-white-space) + "Hook run after combining the new fragment with the old changelog. These +are called with the argument NEW-OLD, which is the buffer position at the +boundary of the two pieces of text. This is suboptimal; we should use a +marker so that munges on the text do not lose this position. The result is +that currently, `ucl-stitch-new-old' must be called first because it depends +on NEW-OLD, while the other cleanup funcs ignore it. (Sigh.)") + +;;;--------------------------------------------------------------------------- +;;; Update functions + +(defun ucl-root () + (let ((lwr (getenv "LOCAL_WORK_ROOT")) + (cr (getenv "CVSROOT"))) + (concat (or lwr + (and cr (progn + (setq ucl-o (concat "-R " ucl-o)) ; hmm + cr)) + (error "Must set env var LOCAL_WORK_ROOT or CVSROOT")) + "/"))) + +(defun ucl-update (module-dir) + (let ((ofile (expand-file-name (concat module-dir ".ChangeLog") ucl-outdir)) + (cmd (concat "cd %s; rcs2log " ucl-o " -c %s")) + (obuf "*ucl-work*")) + (when (and (file-exists-p ofile) + (progn + (shell-command (format cmd module-dir ofile) obuf) + (get-buffer obuf))) + (save-excursion ; prevent default-directory hosing + (set-buffer obuf) + (unless (= 0 (buffer-size)) + (let ((new-old-boundary (point-max))) + (goto-char new-old-boundary) + (insert-file ofile) + (run-hook-with-args 'ucl-cleanup-hook new-old-boundary)) + (or (= (buffer-size) (nth 7 (file-attributes ofile))) + (let (make-backup-files) ; less clutter + (write-file ofile)))) + (kill-buffer (current-buffer)))))) + +(defun ucl-update-all () + (let ((default-directory (ucl-root))) + (mapcar (lambda (file) + (and (file-directory-p file) + (or (string-match "-R" ucl-o) ; see `ucl-root' + (file-exists-p (concat file "/CVS"))) + (ucl-update file))) + (directory-files default-directory)))) + +;;;--------------------------------------------------------------------------- +;;; Load-time actions + +(and noninteractive ; only when `-batch' + (ucl-update-all)) + +(provide 'update-changelog) + +;;; update-changelog.el ends here From 7818cea42fb461c2b0a929fbb7847fe815b7ab51 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 21:37:48 +0000 Subject: [PATCH 179/281] When run as a batch program, invoke `(ucl-update "ChangeLog")' instead of `(ucl-update-all)'. (ucl-outdir): Delete this var. (ucl-update): Arg now specifies change log file instead of cvs module directory. Make interactive. (ucl-update-all): Delete this func. --- emacs/update-changelog.el | 40 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/emacs/update-changelog.el b/emacs/update-changelog.el index e55f968ac..f9e4ff2ac 100644 --- a/emacs/update-changelog.el +++ b/emacs/update-changelog.el @@ -32,27 +32,16 @@ ;; and can be invoked with "-R" therein. We infer this if `LOCAL_WORK_ROOT' ;; is not set, and use instead `CVSROOT'. At least one of these must be set. ;; -;; The ChangeLog files are by default updated in the cwd, unless overriden by -;; the environment variable `CHANGELOG_DIR', with the name MODULE.ChangeLog. -;; No new files are created; you must manually touch a file to have the next -;; ucl run notice it. -;; ;; You can pass additional options to rcs2log using env var `RCS2LOG_OPTS'. ;; -;; Usage from a Lisp program: -;; (ucl-root) -- return dir of ChangeLog or error if not found -;; (ucl-update module-dir) -- get cvs logs starting in CVSROOT/MODULE-DIR, -;; stitch them to ./ChangeLog, and write it out +;; Usage from a Lisp program: +;; (ucl-update filename) -- Update FILENAME, a Change Log file ;;; Code: ;;;--------------------------------------------------------------------------- ;;; Variables -(defvar ucl-outdir (expand-file-name (or (getenv "CHANGELOG_DIR") - default-directory)) - "Directory containing changelogs (one per cvs module) to be updated.") - (defvar ucl-o (or (getenv "RCS2LOG_OPTS") "") "Additional options to pass to rcs2log.") @@ -123,13 +112,14 @@ on NEW-OLD, while the other cleanup funcs ignore it. (Sigh.)") (error "Must set env var LOCAL_WORK_ROOT or CVSROOT")) "/"))) -(defun ucl-update (module-dir) - (let ((ofile (expand-file-name (concat module-dir ".ChangeLog") ucl-outdir)) - (cmd (concat "cd %s; rcs2log " ucl-o " -c %s")) - (obuf "*ucl-work*")) +(defun ucl-update (filename) + (interactive "fChangeLog: ") + (let* ((ofile (expand-file-name filename)) + (cmd (concat "rcs2log " ucl-o " -c " ofile)) + (obuf "*ucl-work*")) (when (and (file-exists-p ofile) (progn - (shell-command (format cmd module-dir ofile) obuf) + (shell-command cmd obuf) (get-buffer obuf))) (save-excursion ; prevent default-directory hosing (set-buffer obuf) @@ -143,20 +133,12 @@ on NEW-OLD, while the other cleanup funcs ignore it. (Sigh.)") (write-file ofile)))) (kill-buffer (current-buffer)))))) -(defun ucl-update-all () - (let ((default-directory (ucl-root))) - (mapcar (lambda (file) - (and (file-directory-p file) - (or (string-match "-R" ucl-o) ; see `ucl-root' - (file-exists-p (concat file "/CVS"))) - (ucl-update file))) - (directory-files default-directory)))) - ;;;--------------------------------------------------------------------------- ;;; Load-time actions -(and noninteractive ; only when `-batch' - (ucl-update-all)) +(when noninteractive ; only when `-batch' + (or (ucl-update "ChangeLog") + (message "Sorry, could not update ChangeLog in %s" default-directory))) (provide 'update-changelog) From ee125338e4915e33a5dcdfcbc5fadf5562504dde Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 21:43:53 +0000 Subject: [PATCH 180/281] (write emacs/patch.el): New item for 1.8.0, self-assigned. --- TODO | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO b/TODO index 8fd602b0d..e08549346 100644 --- a/TODO +++ b/TODO @@ -65,6 +65,10 @@ that user-visible changes are reflected in NEWS. - add DLL support [ela] <-- set by ttn (my bad) +- write emacs/patch.el [ttn] + + outgoing + - incoming + + sync srfi-modules.texi [ttn] - For GOOPS: [ttn] From 97f439ab738cecc5186312c7a5a8c2421a062c8a Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 21:45:56 +0000 Subject: [PATCH 181/281] *** empty log message *** --- ChangeLog | 4 ++++ emacs/ChangeLog | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 402bcd031..7303d49eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-11-19 Thien-Thi Nguyen + + * TODO (write emacs/patch.el): New item, self-assigned. + 2001-11-19 Rob Browning * configure.in: switch to AC_LIBLTDL_INSTALLABLE so we'll use the diff --git a/emacs/ChangeLog b/emacs/ChangeLog index 98fc02270..a0d25a767 100644 --- a/emacs/ChangeLog +++ b/emacs/ChangeLog @@ -1,3 +1,35 @@ +2001-11-19 Thien-Thi Nguyen + + * update-changelog.el: + When run as a batch program, invoke `(ucl-update "ChangeLog")' + instead of `(ucl-update-all)'. + + (ucl-outdir): Delete this var. + (ucl-update): Arg now specifies change log file + instead of cvs module directory. + Make interactive. + (ucl-update-all): Delete this func. + + * update-changelog.el: New file. + + * update-change.el: bye bye + + * update-change.el: + A little birdie from cobalt sang in my ear. + As guilish developers uploaded, disappeared. + Thunderous silence? + Mail server grievance? + Mangle that process (son), but don't drink the beer. + + * patch.el (patch-send): + Renamed from `patch-submit'. + Gadzooks what kind of world is this? + +2001-10-25 Thien-Thi Nguyen + + * README, patch.el: + New file. + 2001-10-25 Thien-Thi Nguyen * patch.el, README: New files. @@ -16,7 +48,7 @@ (guile-process-import-module): Renamed from guile-process-use-module. * guile-emacs.scm (guile-emacs-apropos, guile-emacs-describe): - New procedures. + New procedures. * guile-scheme.el (guile-scheme-mode-map): Use `shared-lisp-mode-map' as the parent keymap if From 78864a355c21e2421ef7350c0b51256cca69c1d0 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 21:55:57 +0000 Subject: [PATCH 182/281] Use less forking for indexing command. Update index. --- emacs/README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emacs/README b/emacs/README index 49229a242..73e021581 100644 --- a/emacs/README +++ b/emacs/README @@ -1,11 +1,13 @@ Index +gud-guile.el --- Support for debugging guile internals guile-c.el --- Guile C editing commands guile-scheme.el --- Guile Scheme editing mode guile.el --- Emacs Guile interface multistring.el --- editing multiline strings. patch.el --- mail/apply a patch ppexpand.el --- temporarily expanding macros in a pretty way. +update-changelog.el --- stitch rcs2log output to ChangeLog -Generated using: (for f in *.el ; do head -1 $f ; done) | sed 's/^....//g' +Generated using: for f in *.el ; do sed -e 's/^....//g' -e '1q' $f ; done From e1d62be2b7161bd6cb33b1bce36d5edc98735ffe Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 21:57:27 +0000 Subject: [PATCH 183/281] *** empty log message *** --- emacs/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/emacs/ChangeLog b/emacs/ChangeLog index a0d25a767..1afa29852 100644 --- a/emacs/ChangeLog +++ b/emacs/ChangeLog @@ -1,5 +1,8 @@ 2001-11-19 Thien-Thi Nguyen + * README: Use less forking for indexing command. + Update index. + * update-changelog.el: When run as a batch program, invoke `(ucl-update "ChangeLog")' instead of `(ucl-update-all)'. From 78b1e5ad6184f5dacb68b19f8c98aaca720757a1 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 22:09:34 +0000 Subject: [PATCH 184/281] Initial revision --- emacs/gud-guile.el | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 emacs/gud-guile.el diff --git a/emacs/gud-guile.el b/emacs/gud-guile.el new file mode 100644 index 000000000..a0a70fabe --- /dev/null +++ b/emacs/gud-guile.el @@ -0,0 +1,81 @@ +;;; gud-guile.el --- Support for debugging guile internals + +;; Copyright (C) 2001 Free Software Foundation, Inc. + +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Author: Thien-Thi Nguyen +;;; Version: 1 +;;; Favorite-Favorite: Favorite-Favorite + +;;; Commentary: + +;; This is a grab bag of stuff for doing "gdb guile" in Emacs. +;; The var `gdb-guile-suggested-gdbinit' has a string that is +;; snarfed from ../HACKING. (todo: Write `gdb-guile-init' to +;; send it to gdb...) + +;;; Code: + +(require 'cl) + +(defun gdb-guile-display-scm () + (interactive) + (save-excursion + (let ((sym (thing-at-point 'symbol)) + (proc (get-buffer-process + (find-if (lambda (buf) + (string-match "^.gud-." (buffer-name buf))) + (buffer-list))))) + (mapc (lambda (template) + (process-send-string proc (format template sym))) + (list + "set gdb_print(%s)\n" + "printf \"%s: %%s\\n\", gdb_output\n"))))) + +(defvar gdb-guile-suggested-gdbinit " +define gp +set gdb_print($arg0) +print gdb_output +end +document gp +Executes (object->string arg) +end + +define ge +call gdb_read($arg0) +call gdb_eval(gdb_result) +set gdb_print(gdb_result) +print gdb_output +end +document ge +Executes (print (eval (read arg))): ge \"(+ 1 2)\" => 3 +end + +define gh +call g_help(scm_str2symbol($arg0), 20) +set gdb_print($1) +print gdb_output +end +document gh +Prints help string for arg: gh \"enved-target\" +end +" + "A useful .gdbinit") + +(provide 'gud-guile) + +;;; gud-guile.el ends here From d0eeda85631222d80216fb59852ce37ca277989c Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 22:10:57 +0000 Subject: [PATCH 185/281] *** empty log message *** --- emacs/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emacs/ChangeLog b/emacs/ChangeLog index 1afa29852..a49578ac5 100644 --- a/emacs/ChangeLog +++ b/emacs/ChangeLog @@ -3,6 +3,8 @@ * README: Use less forking for indexing command. Update index. + * gud-guile.el: New file. + * update-changelog.el: When run as a batch program, invoke `(ucl-update "ChangeLog")' instead of `(ucl-update-all)'. From d4e5a409a52a703f1e1719b14aa103bf7d6f6bc2 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Mon, 19 Nov 2001 22:28:58 +0000 Subject: [PATCH 186/281] * Improve doc on variables and definitions. --- doc/ref/ChangeLog | 11 +++++++ doc/ref/new-docstrings.texi | 5 --- doc/ref/scheme-binding.texi | 66 ++++++++++++++++++++++++++++--------- doc/ref/scheme-data.texi | 53 ++++++++++++++++------------- 4 files changed, 93 insertions(+), 42 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index ed8f871c2..2e2790f10 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,14 @@ +2001-11-19 Neil Jerram + + * scheme-data.texi (Symbol Tables), new-docstrings.texi: Removed + doc for builtin-bindings (no longer exists). + (Variables): Expanded existing description of variables. Removed + doc for builtin-variable (no longer exists). + + * scheme-binding.texi (Top Level): New docs for define, scm_define + and scm_c_define. Also clarified point about interchangeability + of define and set!. + 2001-11-18 Neil Jerram * scheme-data.texi (Vectors): Autoupdate docs for diff --git a/doc/ref/new-docstrings.texi b/doc/ref/new-docstrings.texi index 65ea5a620..f9195b694 100644 --- a/doc/ref/new-docstrings.texi +++ b/doc/ref/new-docstrings.texi @@ -573,11 +573,6 @@ Return the value from @var{obj}'s slot with the name @var{slot_name}. @end deffn -@deffn {Scheme Procedure} builtin-bindings -Create and return a copy of the global symbol table, removing all -unbound symbols. -@end deffn - @deffn {Scheme Procedure} %tag-body body @deffnx {C Function} scm_sys_tag_body (body) Internal GOOPS magic---don't use this function! diff --git a/doc/ref/scheme-binding.texi b/doc/ref/scheme-binding.texi index 38f9bae08..5c68bf772 100644 --- a/doc/ref/scheme-binding.texi +++ b/doc/ref/scheme-binding.texi @@ -20,35 +20,71 @@ and expressions. This is important for modularity and data abstraction. @node Top Level @section Top Level Variable Definitions -@c FIXME::martin: Review me! - @cindex variable definition -On the top level of a program (e.g. when not inside of a procedure -definition or a @code{let}, @code{let*} or @code{letrec} expression), a -definition of the form +On the top level of a program (i.e. when not inside the body of a +procedure definition or a @code{let}, @code{let*} or @code{letrec} +expression), a definition of the form @lisp -(define a 1) +(define a @var{value}) @end lisp @noindent -defines a variable called @var{a} and sets it to the value 1. When the -variable already was bound with a @code{define} expression, the above +defines a variable called @code{a} and sets it to the value @var{value}. + +If the variable already exists, because it has already been created by a +previous @code{define} expression with the same name, its value is +simply changed to the new @var{value}. In this case, then, the above form is completely equivalent to @lisp -(set! a 1) +(set! a @var{value}) @end lisp @noindent -that means that @code{define} can be used interchangeably with -@code{set!} when at the top level of the REPL or a Scheme source file. -But note that a @code{set!} is not allowed if the variable was not bound -before. +This equivalence means that @code{define} can be used interchangeably +with @code{set!} to change the value of variables at the top level of +the REPL or a Scheme source file. It is useful during interactive +development when reloading a Scheme file that you have modified, because +it allows the @code{define} expressions in that file to work as expected +both the first time that the file is loaded and on subsequent occasions. -Attention: definitions inside local binding constructs (@pxref{Local -Bindings}) act differently (@pxref{Internal Definitions}). +Note, though, that @code{define} and @code{set!} are not always +equivalent. For example, a @code{set!} is not allowed if the named +variable does not already exist, and the two expressions can behave +differently in the case where there are imported variables visible from +another module. + +@deffn {Scheme Syntax} define name value +Create a top level variable named @var{name} with value @var{value}. +If the named variable already exists, just change its value. The return +value of a @code{define} expression is unspecified. +@end deffn + +The C API equivalents of @code{define} are @code{scm_define} and +@code{scm_c_define}, which differ from each other in whether the +variable name is specified as a @code{SCM} symbol or as a +null-terminated C string. + +@deffn {C Function} scm_define (sym, value) +@deffnx {C Function} scm_c_define (const char *name, value) +C equivalents of @code{define}, with variable name specified either by +@var{sym}, a symbol, or by @var{name}, a null-terminated C string. Both +variants return the new or preexisting variable object. +@end deffn + +@code{define} (when it occurs at top level), @code{scm_define} and +@code{scm_c_define} all create or set the value of a variable in the top +level environment of the current module. If there was not already a +variable with the specified name belonging to the current module, but a +similarly named variable from another module was visible through having +been imported, the newly created variable in the current module will +shadow the imported variable, such that the imported variable is no +longer visible. + +Attention: Scheme definitions inside local binding constructs +(@pxref{Local Bindings}) act differently (@pxref{Internal Definitions}). @node Local Bindings diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 77e9a654c..463233546 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -2475,14 +2475,6 @@ Each entry in the alists is a pair (@var{SYMBOL} . @var{VALUE}). To (@var{SYMBOL} . @var{VALUE}) pair, adding a new entry to the symbol table (with an undefined value) if none is yet present. -@c FIXME::martin: According to NEWS, removed. Remove here too, or -@c leave for compatibility? -@c @c docstring begin (texi-doc-string "guile" "builtin-bindings") -@c @deffn {Scheme Procedure} builtin-bindings -@c Create and return a copy of the global symbol table, removing all -@c unbound symbols. -@c @end deffn - @deffn {Scheme Procedure} gensym [prefix] @deffnx {C Function} scm_gensym (prefix) Create a new symbol with a name constructed from a prefix and @@ -2571,30 +2563,47 @@ function returns @code{#t} if the symbol was present and @code{#f} otherwise. @end deffn + @node Variables @subsection Variables @tpindex Variables -@c FIXME::martin: Review me! +A variable is a box-like object that can hold any Scheme value. It is +said to be @dfn{undefined} if its box holds a special Scheme value that +denotes undefined-ness (which is different from all other Scheme values, +including for example @code{#f}); otherwise the variable is +@dfn{defined}. -Variables are objects with two fields. They contain a value and they -can contain a symbol, which is the name of the variable. A variable is -said to be bound if it does not contain the object denoting unbound -variables in the value slot. +On its own, a variable object is anonymous. A variable is said to be +@dfn{bound} when it is associated with a name in some way, usually a +symbol in a module obarray. When this happens, the relationship is +mutual: the variable is bound to the name (in that module), and the name +(in that module) is bound to the variable. -Variables do not have a read syntax, they have to be created by calling -one of the constructor procedures @code{make-variable} or -@code{make-undefined-variable} or retrieved by @code{builtin-variable}. +(That's the theory, anyway. In practice, defined-ness and bound-ness +sometimes get confused, because Lisp and Scheme implementations have +often conflated --- or deliberately drawn no distinction between --- a +name that is unbound and a name that is bound to a variable whose value +is undefined. We will try to be clear about the difference and explain +any confusion where it is unavoidable.) + +Variables do not have a read syntax. Most commonly they are created and +bound implicitly by @code{define} expressions: a top-level @code{define} +expression of the form + +@lisp +(define @var{name} @var{value}) +@end lisp + +@noindent +creates a variable with initial value @var{value} and binds it to the +name @var{name} in the current module. But they can also be created +dynamically by calling one of the constructor procedures +@code{make-variable} and @code{make-undefined-variable}. First-class variables are especially useful for interacting with the current module system (@pxref{The Guile module system}). -@deffn {Scheme Procedure} builtin-variable name -Return the built-in variable with the name @var{name}. -@var{name} must be a symbol (not a string). -Then use @code{variable-ref} to access its value. -@end deffn - @deffn {Scheme Procedure} make-undefined-variable @deffnx {C Function} scm_make_undefined_variable () Return a variable that is initially unbound. From 07a245bc20417edc6e3f180d778f8df76c9a92de Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 23:08:02 +0000 Subject: [PATCH 187/281] (11): Set "fixed: no-need". --- BUGS | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BUGS b/BUGS index 693cd473e..20c531d6f 100644 --- a/BUGS +++ b/BUGS @@ -14,6 +14,9 @@ DATE is formatted YYYY-MM-DD, or "not-yet". Line numbering is zero-origin; line 0 is empty (newline always follows newpage (recognizable w/ "\f\n")). The suggested regexps can be used in a line-oriented parser. +You can use "fixed: no-need (EXPLANATION)" if the bug doesn't need to be +fixed. EXPLANATION might be "not a bug", "user error", etc. + bug 0 -- no BUGS file reported-by: ttn / 2001-09-25 @@ -235,7 +238,7 @@ Bill Gribble sez: bug 11 -- (ice-9 optargs) #:rest arg polluted by keys/values reported-by: ttn / 2001-11-09 -fixed: not-yet +fixed: no-need (behavior consistent w/ Common Lisp, user error) ttn sez: > the following code displays @@ -265,5 +268,16 @@ ttn sez: > (blah #:j 'JAY #:k 'KAY 1) > (blah #:j 'JAY #:k 'KAY '(1 2 3)) +mvo sez: +> In Common Lisp, there are no non-key rest-args when you have keyword +> parameters. After the required and optional arguments, there must +> follow an even number of additional arguments, and every two of them +> are treated as a keyword/value pair. +> +> I think it makes sense the way CL specifies this. Anything beyond +> this would lead to confusion. If you want to go beyond what (ice-9 +> optargs) offers, yo are probably best off writing your own argument +> parser. + [BUGS ends here] From 30bce757a1581327cd6feeed1e95f17ef63d5aef Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 23:08:47 +0000 Subject: [PATCH 188/281] *** empty log message *** --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7303d49eb..8558c7fa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2001-11-19 Thien-Thi Nguyen + * BUGS (11): Set "fixed: no-need". + * TODO (write emacs/patch.el): New item, self-assigned. 2001-11-19 Rob Browning From ccee9ab13d13bfa8e8ebdd3e8e183fefabe752f5 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 19 Nov 2001 23:29:45 +0000 Subject: [PATCH 189/281] *** empty log message *** --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8558c7fa0..7831e5278 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,10 @@ with libguile and also use libltdl will be more likely to work right. +2001-11-17 Dirk Herrmann + + * BUGS (4): Set "fixed: 2001-11-17 (1.7.x)". + 2001-11-15 Thien-Thi Nguyen * guile-tools.in: Handle command "list" specially: list scripts dir. From 0a3c6bb22a9dfcfcfec06a6b9ee2e7d16e26bd47 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 20 Nov 2001 00:24:55 +0000 Subject: [PATCH 190/281] *** empty log message *** --- emacs/ChangeLog | 9 --------- 1 file changed, 9 deletions(-) diff --git a/emacs/ChangeLog b/emacs/ChangeLog index a49578ac5..5189f107f 100644 --- a/emacs/ChangeLog +++ b/emacs/ChangeLog @@ -17,15 +17,6 @@ * update-changelog.el: New file. - * update-change.el: bye bye - - * update-change.el: - A little birdie from cobalt sang in my ear. - As guilish developers uploaded, disappeared. - Thunderous silence? - Mail server grievance? - Mangle that process (son), but don't drink the beer. - * patch.el (patch-send): Renamed from `patch-submit'. Gadzooks what kind of world is this? From 54f16aecf98191d615fb35f02059fe9089f65959 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 20 Nov 2001 10:53:19 +0000 Subject: [PATCH 191/281] (libpath.h): In SCM_BUILD_INFO, also include `buildstamp'. --- libguile/Makefile.am | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index fd7724ff5..887eded92 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -3,17 +3,17 @@ ## Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. ## ## This file is part of GUILE. -## +## ## GUILE is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2, or ## (at your option) any later version. -## +## ## GUILE is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. -## +## ## You should have received a copy of the GNU General Public ## License along with GUILE; see the file COPYING. If not, write ## to the Free Software Foundation, Inc., 59 Temple Place, Suite @@ -120,7 +120,7 @@ libguile_la_DEPENDENCIES = @LIBLOBJS@ libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) $(THREAD_LIBS_LOCAL) libguile_la_LDFLAGS = -version-info @LIBGUILE_INTERFACE_CURRENT@:@LIBGUILE_INTERFACE_REVISION@:@LIBGUILE_INTERFACE_AGE@ -export-dynamic -no-undefined -# These are headers visible as +# These are headers visible as pkginclude_HEADERS = gh.h # These are headers visible as . @@ -155,7 +155,7 @@ EXTRA_DIST = ChangeLog-gh ChangeLog-scm ChangeLog-threads \ ## FIXME: Consider using timestamp file, to avoid unnecessary rebuilds. libpath.h: $(srcdir)/Makefile.in $(top_builddir)/config.status - @echo "Generating libpath.h..." + @echo "Generating libpath.h..." @rm -f libpath.tmp @echo '/* generated by Makefile */' > libpath.tmp @echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp @@ -183,8 +183,10 @@ libpath.h: $(srcdir)/Makefile.in $(top_builddir)/config.status @echo ' { "pkgincludedir", "$(includedir)/@PACKAGE@" }, \' \ >> libpath.tmp @echo ' { "guileversion", "@GUILE_VERSION@" }, \' >> libpath.tmp - @echo ' { "libguileinterface", "@LIBGUILE_INTERFACE@" }, \' >> libpath.tmp + @echo ' { "libguileinterface", "@LIBGUILE_INTERFACE@" }, \' \ + >> libpath.tmp @echo ' { "LIBS", "@GUILE_LIBS@" }, \' >> libpath.tmp + @echo ' { "buildstamp", "'"`date`"'" }, \' >> libpath.tmp @echo '}' >> libpath.tmp @mv libpath.tmp libpath.h From 849038b54257f49b8667fdbbb93c9cb7279179eb Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 20 Nov 2001 10:54:56 +0000 Subject: [PATCH 192/281] *** empty log message *** --- libguile/ChangeLog | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 08e71ec0b..cb2b0887f 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-20 Thien-Thi Nguyen + + * Makefile.am (libpath.h): In SCM_BUILD_INFO, + also include `buildstamp'. + 2001-11-18 Rob Browning * version.c @@ -108,11 +113,11 @@ index entries for each Guile primitive to the copy of the doc snarf output that is used for reference manual synchronization. Online help is unchanged. - + * snarf.h (SCM_SNARF_DOCS): Output primitive's C function name. (SCM_DEFINE, SCM_DEFINE1, SCM_REGISTER_PROC): Supply to C function name to SCM_SNARF_DOCS. - + * guile-snarf-docs-texi.in: Pass the shell script's arguments into snarf-check-and-output-texi. @@ -170,7 +175,7 @@ only -MIN_VALUE can still be negative of all negative numbers (in twos-complement). - * tags.h (SIZEOF_SCM_T_BITS): Define it appropriately. + * tags.h (SIZEOF_SCM_T_BITS): Define it appropriately. * __scm.h: Define HAVE_UINTPTR_T, HAVE_PTRDIFF_T and HAVE_LONG_LONG depending on whether their size is non-zero. From 49d9ca522c33bbd8fd904b2a9475f6e247273b64 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 20 Nov 2001 12:30:26 +0000 Subject: [PATCH 193/281] (Install Config): Tweak `%load-path' verb to not imply it's a proc. Add documentation for `%guile-build-info'. --- doc/ref/scheme-options.texi | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/ref/scheme-options.texi b/doc/ref/scheme-options.texi index 3b24463ba..12c49c3a8 100644 --- a/doc/ref/scheme-options.texi +++ b/doc/ref/scheme-options.texi @@ -397,10 +397,38 @@ concatenated with each @var{extension}. @end deffn @defvar %load-path -Return the list of directories which should be searched for Scheme +List of directories which should be searched for Scheme modules and libraries. @end defvar +@defvar %guile-build-info +Alist of information collected during the building of a particular +@code{guile} program. Entries can be grouped into one of several +categories: directories, env vars, and versioning info. + +Briefly, here are the keys in @code{%guile-build-info}, by group: +@itemize @bullet +@item directories +srcdir, top_srcdir, prefix, exec_prefix, bindir, sbindir, libexecdir, +datadir, sysconfdir, sharedstatedir, localstatedir, libdir, infodir, +mandir, includedir, pkgdatadir, pkglibdir, pkgincludedir +@item env vars +LIBS +@item versioning info +guileversion, libguileinterface, buildstamp +@end itemize + +Values are all strings. The value for @code{LIBS} is typically found also as +a part of "guile-config link" output. The value for @code{guileversion} has +form X.Y.Z, and should be the same as returned by @code{version}. The value +for @code{libguileinterface} is libtool compatible and has form +CURRENT:REVISION:AGE. The value for @code{buildstamp} is the output of the +date(1) command. + +In the source, @code{%guile-build-info} is initialized from +libguile/libpath.h, which is completely generated, so deleting this file +before a build guarantees up-to-date values for that build. +@end defvar @c Local Variables: @c TeX-master: "guile.texi" From 19a35d19d9a1cb3b2ff4e5a572837ee22175d3ae Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 20 Nov 2001 12:32:00 +0000 Subject: [PATCH 194/281] *** empty log message *** --- doc/ref/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 2e2790f10..c7f84b553 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,9 @@ +2001-11-20 Thien-Thi Nguyen + + * scheme-options.texi (Install Config): + Tweak `%load-path' verb to not imply it's a proc. + Add documentation for `%guile-build-info'. + 2001-11-19 Neil Jerram * scheme-data.texi (Symbol Tables), new-docstrings.texi: Removed From eb880cef297dff7e97304d4af422bf20bbd68e5b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 20 Nov 2001 22:45:24 +0000 Subject: [PATCH 195/281] (scm_c_export): Do nothing when the first argument is already the terminating NULL. Thanks to Han-Wen Nienhuys! --- libguile/modules.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/libguile/modules.c b/libguile/modules.c index 554b9f141..e88ff73ea 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -176,24 +176,41 @@ scm_c_use_module (const char *name) static SCM module_export_x_var; + + +/* + @code{scm_c_export}(@var{name-list}) + + @code{scm_c_export} exports the named bindings from the current + module, making them visible to users of the module. This function + takes a list of string arguments, terminated by NULL, e.g. + + @example + scm_c_export ("add-double-record", "bamboozle-money", NULL); + @end example +*/ + void scm_c_export (const char *name, ...) { - va_list ap; - SCM names = scm_cons (scm_str2symbol (name), SCM_EOL); - SCM *tail = SCM_CDRLOC (names); - va_start (ap, name); - while (1) + if (name) { - const char *n = va_arg (ap, const char *); - if (n == NULL) - break; - *tail = scm_cons (scm_str2symbol (n), SCM_EOL); - tail = SCM_CDRLOC (*tail); + va_list ap; + SCM names = scm_cons (scm_str2symbol (name), SCM_EOL); + SCM *tail = SCM_CDRLOC (names); + va_start (ap, name); + while (1) + { + const char *n = va_arg (ap, const char *); + if (n == NULL) + break; + *tail = scm_cons (scm_str2symbol (n), SCM_EOL); + tail = SCM_CDRLOC (*tail); + } + va_end (ap); + scm_call_2 (SCM_VARIABLE_REF (module_export_x_var), + scm_current_module (), names); } - va_end (ap); - scm_call_2 (SCM_VARIABLE_REF (module_export_x_var), - scm_current_module (), names); } /* Environments */ From 351982f656ad8b0e9754b368fb89e751ad226500 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 20 Nov 2001 22:45:37 +0000 Subject: [PATCH 196/281] *** empty log message *** --- libguile/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index cb2b0887f..7445c1d9a 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-20 Marius Vollmer + + * modules.c (scm_c_export): Do nothing when the first argument is + already the terminating NULL. Thanks to Han-Wen Nienhuys! + 2001-11-20 Thien-Thi Nguyen * Makefile.am (libpath.h): In SCM_BUILD_INFO, From 6063dc1ddd76d0d4bc74f86faae9462d855ceff5 Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Wed, 21 Nov 2001 07:59:53 +0000 Subject: [PATCH 197/281] 2001-11-21 Stefan Jahn * win32-socket.c (getservent, setservent, endservent, getprotoent, setprotoent, endprotoent): New functions. Appropriate replacements for M$-Windows. * numbers.c (SIZE_MAX, PTRDIFF_MAX, PTRDIFF_MIN): Reintroduced these definitions for GUILE_DEBUG. * net_db.c: Include "win32-socket.h" if compiling with a native M$-Windows compiler. Include some pieces of code (protoent and servent interface) protected by HAVE_* macros when using a native M$-Windows compiler. --- libguile/ChangeLog | 14 +++ libguile/net_db.c | 12 +- libguile/numbers.c | 11 ++ libguile/win32-socket.c | 248 ++++++++++++++++++++++++++++++++++++++++ libguile/win32-socket.h | 8 ++ 5 files changed, 289 insertions(+), 4 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 7445c1d9a..93bcc0753 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,17 @@ +2001-11-21 Stefan Jahn + + * win32-socket.c (getservent, setservent, endservent, + getprotoent, setprotoent, endprotoent): New functions. + Appropriate replacements for M$-Windows. + + * numbers.c (SIZE_MAX, PTRDIFF_MAX, PTRDIFF_MIN): Reintroduced + these definitions for GUILE_DEBUG. + + * net_db.c: Include "win32-socket.h" if compiling with a native + M$-Windows compiler. Include some pieces of code (protoent and + servent interface) protected by HAVE_* macros when using a + native M$-Windows compiler. + 2001-11-20 Marius Vollmer * modules.c (scm_c_export): Do nothing when the first argument is diff --git a/libguile/net_db.c b/libguile/net_db.c index d32819ee8..fd00a0497 100644 --- a/libguile/net_db.c +++ b/libguile/net_db.c @@ -74,6 +74,10 @@ #include #endif +#ifdef __MINGW32__ +#include "win32-socket.h" +#endif + #if !defined (HAVE_H_ERRNO) && !defined (__MINGW32__) && !defined (__CYGWIN__) /* h_errno not found in netdb.h, maybe this will help. */ extern int h_errno; @@ -266,7 +270,7 @@ SCM_DEFINE (scm_getnet, "getnet", 0, 1, 0, #undef FUNC_NAME #endif -#ifdef HAVE_GETPROTOENT +#if defined (HAVE_GETPROTOENT) || defined (__MINGW32__) SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0, (SCM protocol), "@deffnx {Scheme Procedure} getprotobyname name\n" @@ -314,7 +318,7 @@ SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0, #undef FUNC_NAME #endif -#ifdef HAVE_GETSERVENT +#if defined (HAVE_GETSERVENT) || defined (__MINGW32__) static SCM scm_return_entry (struct servent *entry) { @@ -405,7 +409,7 @@ SCM_DEFINE (scm_setnet, "setnet", 0, 1, 0, #undef FUNC_NAME #endif -#if defined(HAVE_SETPROTOENT) && defined(HAVE_ENDPROTOENT) +#if defined (HAVE_SETPROTOENT) && defined (HAVE_ENDPROTOENT) || defined (__MINGW32__) SCM_DEFINE (scm_setproto, "setproto", 0, 1, 0, (SCM stayopen), "If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}.\n" @@ -421,7 +425,7 @@ SCM_DEFINE (scm_setproto, "setproto", 0, 1, 0, #undef FUNC_NAME #endif -#if defined(HAVE_SETSERVENT) && defined(HAVE_ENDSERVENT) +#if defined (HAVE_SETSERVENT) && defined (HAVE_ENDSERVENT) || defined (__MINGW32__) SCM_DEFINE (scm_setserv, "setserv", 0, 1, 0, (SCM stayopen), "If @var{stayopen} is omitted, this is equivalent to @code{endservent}.\n" diff --git a/libguile/numbers.c b/libguile/numbers.c index 154974d24..4afc1578b 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4390,6 +4390,17 @@ scm_i_big2dbl (SCM b) #ifdef GUILE_DEBUG +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t) (-1)) +#endif +#ifndef PTRDIFF_MIN +#define PTRDIFF_MIN \ + ((ptrdiff_t) ((ptrdiff_t) 1 << (sizeof (ptrdiff_t) * 8 - 1))) +#endif +#ifndef PTRDIFF_MAX +#define PTRDIFF_MAX (~ PTRDIFF_MIN) +#endif + #define CHECK(type, v) \ do { \ if ((v) != scm_num2##type (scm_##type##2num (v), 1, "check_sanity")) \ diff --git a/libguile/win32-socket.c b/libguile/win32-socket.c index 8456ad321..a2556b6d1 100644 --- a/libguile/win32-socket.c +++ b/libguile/win32-socket.c @@ -46,7 +46,16 @@ #include "libguile/modules.h" #include "libguile/numbers.h" +#include +#include +#include +#include #include +#include + +#ifndef PATH_MAX +#define PATH_MAX 255 +#endif #include "win32-socket.h" @@ -62,6 +71,46 @@ typedef struct } socket_error_t; +#define FILE_ETC_SERVICES "services" +#define ENVIRON_ETC_SERVICES "SERVICES" +#define FILE_ETC_NETWORKS "networks" +#define ENVIRON_ETC_NETWORKS "NETWORKS" +#define FILE_ETC_PROTOCOLS "protocol" +#define ENVIRON_ETC_PROTOCOLS "PROTOCOLS" +#define MAX_NAMLEN 256 +#define MAX_ALIASES 4 + +/* Internal structure for a thread's M$-Windows servent interface. */ +typedef struct +{ + FILE *fd; /* Current file. */ + char file[PATH_MAX]; /* File name. */ + struct servent ent; /* Return value. */ + char name[MAX_NAMLEN]; /* Service name. */ + char proto[MAX_NAMLEN]; /* Protocol name. */ + char alias[MAX_ALIASES][MAX_NAMLEN]; /* All aliases. */ + char *aliases[MAX_ALIASES]; /* Alias pointers. */ + int port; /* Network port. */ +} +scm_i_servent_t; + +static scm_i_servent_t scm_i_servent; + +/* Internal structure for a thread's M$-Windows protoent interface. */ +typedef struct +{ + FILE *fd; /* Current file. */ + char file[PATH_MAX]; /* File name. */ + struct protoent ent; /* Return value. */ + char name[MAX_NAMLEN]; /* Protocol name. */ + char alias[MAX_ALIASES][MAX_NAMLEN]; /* All aliases. */ + char *aliases[MAX_ALIASES]; /* Alias pointers. */ + int proto; /* Protocol number. */ +} +scm_i_protoent_t; + +static scm_i_protoent_t scm_i_protoent; + /* Define replacement symbols for most of the WSA* error codes. */ #ifndef EWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK @@ -375,6 +424,205 @@ scm_i_socket_strerror (int error) return NULL; } +/* Constructs a valid filename for the given file @var{file} in the M$-Windows + directory. This is usually the default location for the network files. */ +char * +scm_i_socket_filename (char *file) +{ + static char dir[PATH_MAX]; + int len = PATH_MAX; + + len = GetWindowsDirectory (dir, len); + if (dir[len - 1] != '\\') + strcat (dir, "\\"); + strcat (dir, file); + return dir; +} + +/* Removes comments and white spaces at end of line and returns a pointer + to the end of the line. */ +static char * +scm_i_socket_uncomment (char *line) +{ + char *end; + + if ((end = strchr (line, '#')) != NULL) + *end-- = '\0'; + else + { + end = line + strlen (line) - 1; + while (end > line && (*end == '\r' || *end == '\n')) + *end-- = '\0'; + } + while (end > line && isspace (*end)) + *end-- = '\0'; + + return end; +} + +/* The getservent() function reads the next line from the file `/etc/services' + and returns a structure servent containing the broken out fields from the + line. The `/etc/services' file is opened if necessary. */ +struct servent * +getservent (void) +{ + char line[MAX_NAMLEN], *end, *p; + int done = 0, i, n, a; + struct servent *e = NULL; + + /* Ensure a open file. */ + if (scm_i_servent.fd == NULL || feof (scm_i_servent.fd)) + { + setservent (1); + if (scm_i_servent.fd == NULL) + return NULL; + } + + while (!done) + { + /* Get new line. */ + if (fgets (line, MAX_NAMLEN, scm_i_servent.fd) != NULL) + { + end = scm_i_socket_uncomment (line); + + /* Scan the line. */ + if ((i = sscanf (line, "%s %d/%s%n", + scm_i_servent.name, + &scm_i_servent.port, + scm_i_servent.proto, &n)) != 3) + continue; + + /* Scan the remaining aliases. */ + p = line + n; + for (a = 0; a < MAX_ALIASES && p < end && i != -1 && n > 1; + a++, p += n) + i = sscanf (p, "%s%n", scm_i_servent.alias[a], &n); + + /* Prepare the return value. */ + e = &scm_i_servent.ent; + e->s_name = scm_i_servent.name; + e->s_port = htons (scm_i_servent.port); + e->s_proto = scm_i_servent.proto; + e->s_aliases = scm_i_servent.aliases; + scm_i_servent.aliases[a] = NULL; + while (a--) + scm_i_servent.aliases[a] = scm_i_servent.alias[a]; + done = 1; + } + else + break; + } + return done ? e : NULL; +} + +/* The setservent() function opens and rewinds the `/etc/services' file. + This file can be set from outside with an environment variable specifying + the file name. */ +void +setservent (int stayopen) +{ + char *file = NULL; + + endservent (); + if ((file = getenv (ENVIRON_ETC_SERVICES)) != NULL) + strcpy (scm_i_servent.file, file); + else if ((file = scm_i_socket_filename (FILE_ETC_SERVICES)) != NULL) + strcpy (scm_i_servent.file, file); + scm_i_servent.fd = fopen (scm_i_servent.file, "rt"); +} + +/* The endservent() function closes the `/etc/services' file. */ +void +endservent (void) +{ + if (scm_i_servent.fd != NULL) + { + fclose (scm_i_servent.fd); + scm_i_servent.fd = NULL; + } +} + +/* The getprotoent() function reads the next line from the file + `/etc/protocols' and returns a structure protoent containing the broken + out fields from the line. The `/etc/protocols' file is opened if + necessary. */ +struct protoent * +getprotoent (void) +{ + char line[MAX_NAMLEN], *end, *p; + int done = 0, i, n, a; + struct protoent *e = NULL; + + /* Ensure a open file. */ + if (scm_i_protoent.fd == NULL || feof (scm_i_protoent.fd)) + { + setprotoent (1); + if (scm_i_protoent.fd == NULL) + return NULL; + } + + while (!done) + { + /* Get new line. */ + if (fgets (line, MAX_NAMLEN, scm_i_protoent.fd) != NULL) + { + end = scm_i_socket_uncomment (line); + + /* Scan the line. */ + if ((i = sscanf (line, "%s %d%n", + scm_i_protoent.name, + &scm_i_protoent.proto, &n)) != 2) + continue; + + /* Scan the remaining aliases. */ + p = line + n; + for (a = 0; a < MAX_ALIASES && p < end && i != -1 && n > 1; + a++, p += n) + i = sscanf (p, "%s%n", scm_i_protoent.alias[a], &n); + + /* Prepare the return value. */ + e = &scm_i_protoent.ent; + e->p_name = scm_i_protoent.name; + e->p_proto = scm_i_protoent.proto; + e->p_aliases = scm_i_protoent.aliases; + scm_i_protoent.aliases[a] = NULL; + while (a--) + scm_i_protoent.aliases[a] = scm_i_protoent.alias[a]; + done = 1; + } + else + break; + } + return done ? e : NULL; +} + +/* The setprotoent() function opens and rewinds the `/etc/protocols' file. + As in setservent() the user can modify the location of the file using + an environment variable. */ +void +setprotoent (int stayopen) +{ + char *file = NULL; + + endprotoent (); + if ((file = getenv (ENVIRON_ETC_PROTOCOLS)) != NULL) + strcpy (scm_i_protoent.file, file); + else if ((file = scm_i_socket_filename (FILE_ETC_PROTOCOLS)) != NULL) + strcpy (scm_i_protoent.file, file); + scm_i_protoent.fd = fopen (scm_i_protoent.file, "rt"); +} + +/* The endprotoent() function closes `/etc/protocols'. */ +void +endprotoent (void) +{ + if (scm_i_protoent.fd != NULL) + { + fclose (scm_i_protoent.fd); + scm_i_protoent.fd = NULL; + } +} + /* Define both the original and replacement error symbol is possible. Thus the user is able to check symbolic errors after unsuccessful networking function calls. */ diff --git a/libguile/win32-socket.h b/libguile/win32-socket.h index 83e1030dd..adbe2c517 100644 --- a/libguile/win32-socket.h +++ b/libguile/win32-socket.h @@ -52,5 +52,13 @@ int scm_i_socket_errno (void); char * scm_i_socket_strerror (int error); void scm_i_init_socket_Win32 (void); +char * scm_i_socket_filename (char *file); + +struct servent * getservent (void); +void setservent (int stayopen); +void endservent (void); +struct protoent * getprotoent (void); +void setprotoent (int stayopen); +void endprotoent (void); #endif /* SCM_WIN32_SOCKET_H */ From b27b814d4c0995790ae14f841f0d90b42e37d7a0 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 21 Nov 2001 20:21:39 +0000 Subject: [PATCH 198/281] (install-exec-hook): Prepend $(DESTDIR) to filename. Thanks to Eric Gillespie, Jr! --- libguile/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 887eded92..b9fc1d004 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -106,7 +106,7 @@ OMIT_DEPENDENCIES = libguile.h ltdl.h \ ## lingering there due to an earlier guile version not having been ## wiped out. install-exec-hook: - rm -f $(bindir)/guile-snarf.awk + rm -f $(DESTDIR)$(bindir)/guile-snarf.awk ## This is kind of nasty... there are ".c" files that we don't want to ## compile, since they are #included. So instead we list them here. From 84aff7a7f28499609ac4e7055ff41f8534529c13 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 21 Nov 2001 20:22:01 +0000 Subject: [PATCH 199/281] *** empty log message *** --- THANKS | 1 + libguile/ChangeLog | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/THANKS b/THANKS index 8f8190513..75eb8f4a3 100644 --- a/THANKS +++ b/THANKS @@ -17,6 +17,7 @@ For fixes or providing information which led to a fix: Brian Crowder Christopher Cramer Aubrey Jaffer + Eric Gillespie, Jr John Goerzen Han-Wen Nienhuys Ken Raeburn diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 93bcc0753..7b98f2712 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-21 Marius Vollmer + + * Makefile.am (install-exec-hook): Prepend $(DESTDIR) to filename. + Thanks to Eric Gillespie, Jr! + 2001-11-21 Stefan Jahn * win32-socket.c (getservent, setservent, endservent, From 164826d3ae56db065d0fd8d50ba02b9fad3c08df Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Wed, 21 Nov 2001 23:23:53 +0000 Subject: [PATCH 200/281] * numbers.c (scm_divide): Fix (/ 0). Thanks to Keith Wright for reporting the bug. --- THANKS | 1 + libguile/ChangeLog | 5 +++++ libguile/numbers.c | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 75eb8f4a3..f0c170e4c 100644 --- a/THANKS +++ b/THANKS @@ -23,3 +23,4 @@ For fixes or providing information which led to a fix: Ken Raeburn Bill Schottstaedt Momchil Velikov + Keith Wright diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 7b98f2712..44bc00c26 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-22 Dirk Herrmann + + * numbers.c (scm_divide): Fix (/ 0). Thanks to Keith Wright for + reporting the bug. + 2001-11-21 Marius Vollmer * Makefile.am (install-exec-hook): Prepend $(DESTDIR) to filename. diff --git a/libguile/numbers.c b/libguile/numbers.c index 4afc1578b..b6796fa8c 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -3707,10 +3707,13 @@ scm_divide (SCM x, SCM y) if (SCM_UNBNDP (x)) { SCM_WTA_DISPATCH_0 (g_divide, s_divide); } else if (SCM_INUMP (x)) { - if (SCM_EQ_P (x, SCM_MAKINUM (1L)) || SCM_EQ_P (x, SCM_MAKINUM (-1L))) { + long xx = SCM_INUM (x); + if (xx == 1 || xx == -1) { return x; + } else if (xx == 0) { + scm_num_overflow (s_divide); } else { - return scm_make_real (1.0 / (double) SCM_INUM (x)); + return scm_make_real (1.0 / (double) xx); } } else if (SCM_BIGP (x)) { return scm_make_real (1.0 / scm_i_big2dbl (x)); From 1b3a7932cafa960c9dbe42875ca3a8a9c877e3f6 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Wed, 21 Nov 2001 23:25:40 +0000 Subject: [PATCH 201/281] * tests/numbers.test: Added division by zero tests. --- test-suite/ChangeLog | 4 ++++ test-suite/tests/numbers.test | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 9f6893202..f1e0b0095 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,7 @@ +2001-11-22 Dirk Herrmann + + * tests/numbers.test: Added division by zero tests. + 2001-11-17 Dirk Herrmann * tests/syntax.test: Added some tests, updated some others with diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test index ab3b80234..505d31eb5 100644 --- a/test-suite/tests/numbers.test +++ b/test-suite/tests/numbers.test @@ -47,6 +47,9 @@ ;;; miscellaneous ;;; +(define exception:numerical-overflow + (cons 'numerical-overflow "^Numerical overflow")) + (define (documented? object) (not (not (object-documentation object)))) @@ -1343,6 +1346,21 @@ ;;; / ;;; +(with-test-prefix "/" + + (expect-fail "documented?" + (documented? /)) + + (with-test-prefix "division by zero" + + (pass-if-exception "(/ 0)" + exception:numerical-overflow + (/ 0)) + + (pass-if-exception "(/ 1 0)" + exception:numerical-overflow + (/ 1 0)))) + ;;; ;;; truncate ;;; From 8978878fd8d4afe4701c46dcd99d1dbc2cfdeaed Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Wed, 21 Nov 2001 23:35:15 +0000 Subject: [PATCH 202/281] * Makefile.am (OMIT_DEPENDENCIES): removed, since it seems to be obsolete. autogen.sh says: invalid unused variable name: `OMIT_DEPENDENCIES' --- libguile/ChangeLog | 6 ++++++ libguile/Makefile.am | 7 +++++-- qt/ChangeLog | 6 ++++++ qt/Makefile.am | 4 +++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 44bc00c26..0c399cb9d 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2001-11-21 Gary Houston + + * Makefile.am (OMIT_DEPENDENCIES): removed, since it seems to be + obsolete. autogen.sh says: + invalid unused variable name: `OMIT_DEPENDENCIES' + 2001-11-22 Dirk Herrmann * numbers.c (scm_divide): Fix (/ 0). Thanks to Keith Wright for diff --git a/libguile/Makefile.am b/libguile/Makefile.am index b9fc1d004..07cf6b80e 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -99,8 +99,11 @@ EXTRA_libguile_la_SOURCES = _scm.h \ ## In next release, threads will be factored out of libguile. ## Until then, the machine specific headers is a temporary kludge. -OMIT_DEPENDENCIES = libguile.h ltdl.h \ - axp.h hppa.h i386.h ksr.h m88k.h mips.h sparc.h vax.h + +# Seems to be obsolete - autogen.sh is giving: +# invalid unused variable name: `OMIT_DEPENDENCIES' +#OMIT_DEPENDENCIES = libguile.h ltdl.h \ +# axp.h hppa.h i386.h ksr.h m88k.h mips.h sparc.h vax.h ## delete guile-snarf.awk from the installation bindir, in case it's ## lingering there due to an earlier guile version not having been diff --git a/qt/ChangeLog b/qt/ChangeLog index be11f91c3..ae4e4d285 100644 --- a/qt/ChangeLog +++ b/qt/ChangeLog @@ -1,3 +1,9 @@ +2001-11-21 Gary Houston + + * Makefile.am (OMIT_DEPENDENCIES): removed, since it seems to be + obsolete. autogen.sh says: + invalid unused variable name: `OMIT_DEPENDENCIES' + 2001-11-04 Stefan Jahn * md/Makefile.am (EXTRA_DIST): Added `i386.asm'. diff --git a/qt/Makefile.am b/qt/Makefile.am index 25f05a657..4868a4a7f 100644 --- a/qt/Makefile.am +++ b/qt/Makefile.am @@ -36,7 +36,9 @@ libqthreads_la_LIBADD = qtmds.lo qtmdc.lo libqthreads_la_DEPENDENCIES = qtmds.lo qtmdc.lo libqthreads_la_LDFLAGS = -rpath $(libdir) -version-info @LIBGUILEQTHREADS_INTERFACE_CURRENT@:@LIBGUILEQTHREADS_INTERFACE_REVISION@:@LIBGUILEQTHREADS_INTERFACE_AGE@ -export-dynamic -no-undefined -OMIT_DEPENDENCIES = axp.h hppa.h i386.h ksr.h m88k.h mips.h sparc.h vax.h +# Seems to be obsolete - autogen.sh is giving: +# invalid unused variable name: `OMIT_DEPENDENCIES' +#OMIT_DEPENDENCIES = axp.h hppa.h i386.h ksr.h m88k.h mips.h sparc.h vax.h .s.lo: $(LIBTOOL) --mode=compile $(COMPILE) $(qthread_asflags) -c $< From 9c4e8e366b49d557ea6c13fe8890295d3a7434c2 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Wed, 21 Nov 2001 23:38:43 +0000 Subject: [PATCH 203/281] Removed reference to no longer practiced * in ChangeLog convention. --- HACKING | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/HACKING b/HACKING index 23e01b956..88b70bd6f 100644 --- a/HACKING +++ b/HACKING @@ -416,18 +416,6 @@ When deprecating a definition, always follow this procedure: to do at each release. Add a reminder about the removal of the deprecated defintion at the appropriate release. -- When you make a user-visible change (i.e. one that should be -documented, and appear in NEWS, put an asterisk in column zero of the -start of the ChangeLog entry, like so: - -Sat Aug 3 01:27:14 1996 Gary Houston - -* * fports.c (scm_open_file): don't return #f, throw error. - -When you've written a NEWS entry and updated the documentation, go -ahead and remove the asterisk. The asterisks are used to find and -document changes that haven't been dealt with before a release. - - Please write log entries for functions written in C under the functions' C names, and write log entries for functions written in Scheme under the functions' Scheme names. Please don't do this: From 73edb48a69a4d58691e269c904afb3c24d9a859f Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Wed, 21 Nov 2001 23:39:51 +0000 Subject: [PATCH 204/281] *** empty log message *** --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7831e5278..62874323a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-21 Gary Houston + + * HACKING: Removed reference to no longer practiced * in ChangeLog + convention. + 2001-11-19 Thien-Thi Nguyen * BUGS (11): Set "fixed: no-need". From a5dc23a7a59e62ada97b55c696f715ac49614c30 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Thu, 22 Nov 2001 00:11:37 +0000 Subject: [PATCH 205/281] * HACKING: Modified the Hacking It Yourself section. Removed the version numbers from the tools. --- ChangeLog | 5 +++++ HACKING | 47 +++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62874323a..338817f50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-22 Gary Houston + + * HACKING: Modified the Hacking It Yourself section. Removed the + version numbers from the tools. + 2001-11-21 Gary Houston * HACKING: Removed reference to no longer practiced * in ChangeLog diff --git a/HACKING b/HACKING index 88b70bd6f..5caa3c54d 100644 --- a/HACKING +++ b/HACKING @@ -22,8 +22,8 @@ You can hack whatever you want, thank GNU. However, to see what others have indicated as their interest (and avoid potential wasteful duplication of effort), see file TODO. Note that -the version you find may be out of date; a CVS checkout is recommended -(see also file SNAPSHOTS). +the version you find may be out of date; a CVS checkout is recommended: +see below for details (see also file SNAPSHOTS). It's also a good idea to join the guile-devel@gnu.org mailing list. See http://www.gnu.org/software/guile/mail/mail.html for more info. @@ -31,43 +31,42 @@ See http://www.gnu.org/software/guile/mail/mail.html for more info. Hacking It Yourself ================================================== -As distributed, Guile needs only an ANSI C compiler and a Unix system -to compile. However, Guile's makefiles, configuration scripts, and a -few other files are automatically generated, not written by hand. If -you want to make changes to the system (which we encourage!) you will -find it helpful to have the tools we use to develop Guile. They -are the following: +When Guile is obtained from CVS, a few extra steps must be taken +before the usual configure, make, make install. You will need to have +up-to-date versions of the tools listed below, correctly installed. +i.e., they must be found in the current PATH and not shadowed or +otherwise broken by files left behind from older versions. -Autoconf 2.50 --- a system for automatically generating `configure' +"up-to-date" means the latest released versions at the time that Guile +was obtained from CVS. Sometimes older versions will work. + +Then you must run the autogen.sh script, as described below. + +In case of problems, it may be worth getting a fresh copy of Guile +from CVS: synchronisation problems have been known to occur +occasionally. + +Autoconf --- a system for automatically generating `configure' scripts from templates which list the non-portable features a program would like to use. Available in "ftp://ftp.gnu.org/pub/gnu/autoconf" -Automake 1.4-p4 --- a system for automatically generating Makefiles that +Automake --- a system for automatically generating Makefiles that conform to the (rather Byzantine) GNU coding standards. The nice thing is that it takes care of hairy targets like 'make dist' and 'make distclean', and automatically generates Makefile dependencies. Automake is available in "ftp://ftp.gnu.org/pub/gnu/automake" - Before using automake, you may need to copy `threads.m4' and - `guile.m4' from the top directory of the Guile core disty to - `/usr/local/share/aclocal'. - -libtool 1.4 --- a system for managing the zillion hairy options needed +libtool --- a system for managing the zillion hairy options needed on various systems to produce shared libraries. Available in "ftp://ftp.gnu.org/pub/gnu/libtool" - To avoid reported tricky errors during the Guile build: After - unpacking the libtool distribution, use autoconf (2.50) to - regenerate its ./configure script. Then build and install as - usual. +flex --- a scanner generator. It's probably not essential to have the + latest version. -flex 2.5.4 (or newer) --- a scanner generator. earlier versions will - most probably work too. - -You are lost in a little maze of automatically generated files, all -different. +One false move and you will be lost in a little maze of automatically +generated files, all different. Sample GDB Initialization File========================================= From 5eec27e9c5d75c54c551a097a04250a1e641e5c3 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 22 Nov 2001 21:30:24 +0000 Subject: [PATCH 206/281] * numbers.c (scm_divide): Fix more division by zero errors. --- libguile/ChangeLog | 4 ++++ libguile/numbers.c | 47 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 0c399cb9d..d9d490b9f 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,7 @@ +2001-11-22 Dirk Herrmann + + * numbers.c (scm_divide): Fix more division by zero errors. + 2001-11-21 Gary Houston * Makefile.am (OMIT_DEPENDENCIES): removed, since it seems to be diff --git a/libguile/numbers.c b/libguile/numbers.c index b6796fa8c..f0d23a138 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -3718,7 +3718,11 @@ scm_divide (SCM x, SCM y) } else if (SCM_BIGP (x)) { return scm_make_real (1.0 / scm_i_big2dbl (x)); } else if (SCM_REALP (x)) { - return scm_make_real (1.0 / SCM_REAL_VALUE (x)); + double xx = SCM_REAL_VALUE (x); + if (xx == 0.0) + scm_num_overflow (s_divide); + else + return scm_make_real (1.0 / xx); } else if (SCM_COMPLEXP (x)) { double r = SCM_COMPLEX_REAL (x); double i = SCM_COMPLEX_IMAG (x); @@ -3752,7 +3756,11 @@ scm_divide (SCM x, SCM y) } else if (SCM_BIGP (y)) { return scm_make_real ((double) xx / scm_i_big2dbl (y)); } else if (SCM_REALP (y)) { - return scm_make_real ((double) xx / SCM_REAL_VALUE (y)); + double yy = SCM_REAL_VALUE (y); + if (yy == 0.0) + scm_num_overflow (s_divide); + else + return scm_make_real ((double) xx / yy); } else if (SCM_COMPLEXP (y)) { a = xx; complex_div: /* y _must_ be a complex number */ @@ -3807,7 +3815,11 @@ scm_divide (SCM x, SCM y) ? w : scm_make_real (scm_i_big2dbl (x) / scm_i_big2dbl (y)); } else if (SCM_REALP (y)) { - return scm_make_real (scm_i_big2dbl (x) / SCM_REAL_VALUE (y)); + double yy = SCM_REAL_VALUE (y); + if (yy == 0.0) + scm_num_overflow (s_divide); + else + return scm_make_real (scm_i_big2dbl (x) / yy); } else if (SCM_COMPLEXP (y)) { a = scm_i_big2dbl (x); goto complex_div; @@ -3817,11 +3829,20 @@ scm_divide (SCM x, SCM y) } else if (SCM_REALP (x)) { double rx = SCM_REAL_VALUE (x); if (SCM_INUMP (y)) { - return scm_make_real (rx / (double) SCM_INUM (y)); + long int yy = SCM_INUM (y); + if (yy == 0) { + scm_num_overflow (s_divide); + } else { + return scm_make_real (rx / (double) yy); + } } else if (SCM_BIGP (y)) { return scm_make_real (rx / scm_i_big2dbl (y)); } else if (SCM_REALP (y)) { - return scm_make_real (rx / SCM_REAL_VALUE (y)); + double yy = SCM_REAL_VALUE (y); + if (yy == 0.0) + scm_num_overflow (s_divide); + else + return scm_make_real (rx / yy); } else if (SCM_COMPLEXP (y)) { a = rx; goto complex_div; @@ -3832,14 +3853,22 @@ scm_divide (SCM x, SCM y) double rx = SCM_COMPLEX_REAL (x); double ix = SCM_COMPLEX_IMAG (x); if (SCM_INUMP (y)) { - double d = SCM_INUM (y); - return scm_make_complex (rx / d, ix / d); + long int yy = SCM_INUM (y); + if (yy == 0) { + scm_num_overflow (s_divide); + } else { + double d = yy; + return scm_make_complex (rx / d, ix / d); + } } else if (SCM_BIGP (y)) { double d = scm_i_big2dbl (y); return scm_make_complex (rx / d, ix / d); } else if (SCM_REALP (y)) { - double d = SCM_REAL_VALUE (y); - return scm_make_complex (rx / d, ix / d); + double yy = SCM_REAL_VALUE (y); + if (yy == 0.0) + scm_num_overflow (s_divide); + else + return scm_make_complex (rx / yy, ix / yy); } else if (SCM_COMPLEXP (y)) { double ry = SCM_COMPLEX_REAL (y); double iy = SCM_COMPLEX_IMAG (y); From 80074d779928496901d42dbbb3ba8410c1b0d17c Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Thu, 22 Nov 2001 21:33:15 +0000 Subject: [PATCH 207/281] * tests/numbers.test: Added more division by zero tests. --- test-suite/ChangeLog | 4 +++ test-suite/tests/numbers.test | 64 ++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index f1e0b0095..7a835df5e 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,7 @@ +2001-11-22 Dirk Herrmann + + * tests/numbers.test: Added more division by zero tests. + 2001-11-22 Dirk Herrmann * tests/numbers.test: Added division by zero tests. diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test index 505d31eb5..03998bd41 100644 --- a/test-suite/tests/numbers.test +++ b/test-suite/tests/numbers.test @@ -303,6 +303,16 @@ ;; Are numerical overflows detected correctly? + (with-test-prefix "division by zero" + + (pass-if-exception "(quotient 1 0)" + exception:numerical-overflow + (quotient 1 0)) + + (pass-if-exception "(quotient bignum 0)" + exception:numerical-overflow + (quotient (+ fixnum-max 1) 0))) + ;; Are wrong type arguments detected correctly? ) @@ -478,6 +488,16 @@ ;; Are numerical overflows detected correctly? + (with-test-prefix "division by zero" + + (pass-if-exception "(remainder 1 0)" + exception:numerical-overflow + (remainder 1 0)) + + (pass-if-exception "(remainder bignum 0)" + exception:numerical-overflow + (remainder (+ fixnum-max 1) 0))) + ;; Are wrong type arguments detected correctly? ) @@ -665,6 +685,16 @@ ;; Are numerical overflows detected correctly? + (with-test-prefix "division by zero" + + (pass-if-exception "(modulo 1 0)" + exception:numerical-overflow + (modulo 1 0)) + + (pass-if-exception "(modulo bignum 0)" + exception:numerical-overflow + (modulo (+ fixnum-max 1) 0))) + ;; Are wrong type arguments detected correctly? ) @@ -1357,9 +1387,41 @@ exception:numerical-overflow (/ 0)) + (pass-if-exception "(/ 0.0)" + exception:numerical-overflow + (/ 0.0)) + (pass-if-exception "(/ 1 0)" exception:numerical-overflow - (/ 1 0)))) + (/ 1 0)) + + (pass-if-exception "(/ 1 0.0)" + exception:numerical-overflow + (/ 1 0.0)) + + (pass-if-exception "(/ bignum 0)" + exception:numerical-overflow + (/ (+ fixnum-max 1) 0)) + + (pass-if-exception "(/ bignum 0.0)" + exception:numerical-overflow + (/ (+ fixnum-max 1) 0.0)) + + (pass-if-exception "(/ 1.0 0)" + exception:numerical-overflow + (/ 1.0 0)) + + (pass-if-exception "(/ 1.0 0.0)" + exception:numerical-overflow + (/ 1.0 0.0)) + + (pass-if-exception "(/ +i 0)" + exception:numerical-overflow + (/ +i 0)) + + (pass-if-exception "(/ +i 0.0)" + exception:numerical-overflow + (/ +i 0.0)))) ;;; ;;; truncate From c08a1190cf41160c5cb8be20dfb2426a2a16febe Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Thu, 22 Nov 2001 22:03:43 +0000 Subject: [PATCH 208/281] HACKING, README, ANON-CVS: updates. --- ANON-CVS | 8 +- HACKING | 637 ------------------------------------------------------- README | 10 +- 3 files changed, 14 insertions(+), 641 deletions(-) diff --git a/ANON-CVS b/ANON-CVS index baf07412a..cda379630 100644 --- a/ANON-CVS +++ b/ANON-CVS @@ -39,15 +39,19 @@ To check out a CVS working directory: This should create a new directory `guile-core' in your current directory, and populate it with the current Guile sources. + To check out all modules use: + + $ cvs -z 9 -d :pserver:anoncvs@subversions.gnu.org:/cvs checkout guile + 4) In the top directory of the source tree, run the command `./autogen.sh'. This builds the configure script, Makefile.in, and other derived files used by the build system. -The modules available for checkout are: +The modules available for checkout include: guile-core --- The scheme interpreter itself. guile-tcltk --- An interface between Guile and Tcl/Tk. - guile-scsh --- An incomplete port of SCSH 0.4.4 to Guile. + guile-scsh --- An incomplete port of scsh to Guile. guile-rgx-ctax --- This has been discontinued; use Andrew Archibald's distribution instead: ftp://ftp.red-bean.com/pub/guile/contrib/misc/guile-lang-allover-0.1.tar.gz diff --git a/HACKING b/HACKING index 5caa3c54d..e69de29bb 100644 --- a/HACKING +++ b/HACKING @@ -1,637 +0,0 @@ --*-text-*- -Guile Hacking Guide -Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001 Free software Foundation, Inc. - - Permission is granted to anyone to make or distribute verbatim copies - of this document as received, in any medium, provided that the - copyright notice and permission notice are preserved, - and that the distributor grants the recipient permission - for further redistribution as permitted by this notice. - - Permission is granted to distribute modified versions - of this document, or of portions of it, - under the above conditions, provided also that they - carry prominent notices stating who last changed them, - and that any new or changed statements about the activities - of the Free Software Foundation are approved by the Foundation. - - -What to Hack ========================================================= - -You can hack whatever you want, thank GNU. - -However, to see what others have indicated as their interest (and avoid -potential wasteful duplication of effort), see file TODO. Note that -the version you find may be out of date; a CVS checkout is recommended: -see below for details (see also file SNAPSHOTS). - -It's also a good idea to join the guile-devel@gnu.org mailing list. -See http://www.gnu.org/software/guile/mail/mail.html for more info. - - -Hacking It Yourself ================================================== - -When Guile is obtained from CVS, a few extra steps must be taken -before the usual configure, make, make install. You will need to have -up-to-date versions of the tools listed below, correctly installed. -i.e., they must be found in the current PATH and not shadowed or -otherwise broken by files left behind from older versions. - -"up-to-date" means the latest released versions at the time that Guile -was obtained from CVS. Sometimes older versions will work. - -Then you must run the autogen.sh script, as described below. - -In case of problems, it may be worth getting a fresh copy of Guile -from CVS: synchronisation problems have been known to occur -occasionally. - -Autoconf --- a system for automatically generating `configure' - scripts from templates which list the non-portable features a - program would like to use. Available in - "ftp://ftp.gnu.org/pub/gnu/autoconf" - -Automake --- a system for automatically generating Makefiles that - conform to the (rather Byzantine) GNU coding standards. The - nice thing is that it takes care of hairy targets like 'make - dist' and 'make distclean', and automatically generates - Makefile dependencies. Automake is available in - "ftp://ftp.gnu.org/pub/gnu/automake" - -libtool --- a system for managing the zillion hairy options needed - on various systems to produce shared libraries. Available in - "ftp://ftp.gnu.org/pub/gnu/libtool" - -flex --- a scanner generator. It's probably not essential to have the - latest version. - -One false move and you will be lost in a little maze of automatically -generated files, all different. - - -Sample GDB Initialization File========================================= - -Here is a sample .gdbinit posted by Bill Schottstaedt (modified to -use `set' instead of `call' in some places): - - define gp - set gdb_print($arg0) - print gdb_output - end - document gp - Executes (object->string arg) - end - - define ge - call gdb_read($arg0) - call gdb_eval(gdb_result) - set gdb_print(gdb_result) - print gdb_output - end - document ge - Executes (print (eval (read arg))): ge "(+ 1 2)" => 3 - end - - define gh - call g_help(scm_str2symbol($arg0), 20) - set gdb_print($1) - print gdb_output - end - document gh - Prints help string for arg: gh "enved-target" - end - -Bill further writes: - - so in gdb if you see something useless like: - - #32 0x081ae8f4 in scm_primitive_load (filename=1112137128) at load.c:129 - - You can get the file name with gp: - - (gdb) gp 1112137128 - $1 = 0x40853fac "\"/home/bil/test/share/guile/1.5.0/ice-9/session.scm\"" - - -Contributing Your Changes ============================================ - -- If you have put together a change that meets the coding standards -described below, we encourage you to submit it to Guile. The best -place to post it is guile-devel@gnu.org. Please don't send it -directly to me; I often don't have time to look things over. If you -have tested your change, then you don't need to be shy. - -- Please submit patches using either context or unified diffs (diff -c -or diff -u). Don't include a patch for ChangeLog; such patches don't -apply cleanly, since we've probably changed the top of ChangeLog too. -Instead, provide the unaltered text at the top of your patch. - -- For proper credit, also make sure you update the AUTHORS file -(for new files for which you've assigned copyright to the FSF), or -the THANKS file (for everything else). - -Please don't include patches for generated files like configure, -aclocal.m4, or any Makefile.in. Such patches are often large, and -we're just going to regenerate those files anyway. - - -CVS conventions ====================================================== - -- We use CVS to manage the Guile sources. The repository lives on -subversions.gnu.org, in /cvs; you will need an -account on that machine to access the repository. Also, for security -reasons, subversions presently only supports CVS connections via the SSH -protocol, so you must first install the SSH client. Then, you should -set your CVS_RSH environment variable to ssh, and use the following as -your CVS root: - - :ext:USER@subversions.gnu.org:/cvs - -Either set your CVSROOT environment variable to that, or give it as -the value of the global -d option to CVS when you check out a working -directory. - -For more information on SSH, see http://www.cs.hut.fi/ssh. - -The Guile sources live in several modules: - - - guile-core --- the interpreter, QuickThreads, and ice-9 - - guile-tcltk --- the Guile/Tk interface - - guile-tk --- the new Guile/Tk interface, based on STk's modified Tk - - guile-rgx-ctax --- the Guile/Rx interface, and the ctax implementation - - guile-scsh --- the port of SCSH to guile, talk to Gary Houston - - guile-www --- A Guile module for making HTTP requests. - - guile-statprof --- an experimental statistical profiler. - -There is a mailing list for CVS commit messages; see README for details. - -- The guile-core tree is now versioned similarly to the Linux kernel. -Guile now always uses three numbers to represent the version, -i.e. "1.6.5". The first number, 1, is the major version number, the -second number, 6, is the minor version number, and the third number, -5, is the micro version number. Changes in major version number -indicate major changes in Guile. - -Minor version numbers that are even denote stable releases, and odd -minor version numbers denote development versions (which may be -unstable). The micro version number indicates a minor sub-revision of -a given MAJOR.MINOR release. - -- A default CVS checkout will get the current unstable development -tree. However, for each stable release, a CVS branch is created so -that release (and ongoing maintenance) of the stable version can -proceed independent of the development of the next unstable version. -To check out a particular stable branch, you just need to specify "-r -branch_release-X-Y" to your CVS checkout command (or to any update). -For example, if you wanted to check out the 1.6 stable branch, you -would specify "-r branch_release-1-6". - -So, for example, during a normal development cycle, work will proceed -on an unstable version, say 1.5.X, until it is decided that it's time -for a stable release. At that point, a branch named -branch_release-1-6 will be created, and the version numbers on the -HEAD of the CVS tree (the trunk, i.e. what you get by default), will -be changed to reflect the new unstable version 1.7.X. Then unstable -development will proceed on the unstable version, while the stable -1.5.X branch is fixed up for the eventual 1.6.0 release. - -Anytime you want to yank an existing checked out tree to the stable -branch, you can run a command like this: - - cvs -z3 update -r branch_release-1-6 -Pd - -This will yank the working directory over on to the stable release -branch. Note that this directory will track that branch from then on -unless you do something to yank it back to the main (unstable) trunk. - -To go back to the unstable branch, you can use - - cvs -z3 update -A -Pd - -Note that in either case, you should probably make sure you've -commited or removed all local changes before running the commands or -you're likely to have some unexpected results. - -Finally note that one approach, should you need to work on both -branches, is to keep two trees checked out, one stable, the other -unstable and you can work in whichever is appropriate. - -To save some initial bandwidth, you can check out either the stable -tree or the unstable tree, and then do something like this: - - cp -a core-unstable core-1.5 - cd core-1.5 - cvs -z3 update -r branch_release-1-6 -Pd - -- The stable and unstable CVS trees are distinct, and no changes will -automatically propagate between them. If you make changes that need -to show up both places, you'll need to apply the changes both places. -You *might* be able to do this with a cvs command, but often you'll -probably need to apply the changes by hand or risk migrating -superfluous modifications between the two versions. This is -particularly important when moving a change from the unstable branch -to the stable branch. - -- In general, please don't be adventurous with the stable branch. We -mostly want bugfixes, documentation improvements, build improvements, -etc., though exceptions will doubtless exist. - -- There are a few CVS tagging conventions which follow the Scheme -convention that dashes are used to separate words within a single -symbol, and so dashes bind more tightly than underscores. This means -that foo-bar_baz-bax indicates that foo-bar is somehow separate from -baz-bax. The conventions are as follows: - - Branch root tags: - ----------------- - anytime just before you create a branch it's a good - idea to create a normal tag so that you can refer to the branch point - on the main trunk as well as on the branch. So please use a tag of - the form - - branch-root-release-1-X - - or more generally, for other non-release branches: - - branch-root_FOO - - Branch tags: - ------------ - for the branch tag itself please use - - branch_release-1-6 - - or more generally, for other non-release branches: - - branch_FOO - - Merge tags: - ----------- - Whenever you're merging a branch back into the trunk (or into another - branch repeatedly) you need to tag the branch each time you merge. If - you don't do that, you won't be able to merge repeatedly without - possibly tedious conflicts. For those tags, we suggest: - - branch-merge_SOME-FOO_to_SOME-BAR_1 - branch-merge_SOME-FOO_to_SOME-BAR_2 - .. - - As an example, SOME-BAR might be trunk, or even perhaps another branch - like branch-mvo-super-fixes :> - - More mundanely, you might have - - branch-merge_release-1-6_to_trunk_1 - - (Merging the stable branch to the trunk like this - will probably be much more common, when it happens, than the - reverse for the reasons mentioned above. - - Release tags: - ------------- - When releasing a new version of guile, please use: - - release_X-Y-Z - - i.e. - - release_1-6-0 - -- If you hack on a stable branch, please apply any relevant patches or -fixes to the current unstable version (the main CVS trunk) as well. -Similarly, please back-port any important fixes to the unstable CVS -tree to the current stable branch. - -- We check Makefile.am and configure.in files into CVS, but the -"autogen.sh" script must be run from the top-level to generate the -actual "configure" script that then must be run to create the various -Makefile-s to build guile. The general rule is that you should be able -to check out a working directory of Guile from CVS, and then type -"./autogen.sh", then "configure", and finally "make". No -automatically generated files should be checked into the CVS -repository. - -- The .cvsignore file is contained in the repository, to provide a -reasonable list of auto-generated files that should not be checked in. -This, however, prohibits one from having local additions to the -.cvsignore file (yes, you can modify it and never check it in, but -that doesn't seem to be a good solution to me). To get around this -problem, you might want to patch your cvs program so that it uses a -.cvsignore-local file (say) instead of the one from the repository. A -patch for this can be found at the very end of this file. - -- (Automake 1.4 only) Be sure to run automake at the top of the tree -with no arguments. Do not use `automake Makefile' to regenerate -specific Makefile.in files, and do not trust the Makefile rules to -rebuild them when they are out of date. Automake 1.4 will add -extraneous rules to the top-level Makefile if you specify specific -Makefiles to rebuild on the command line. Running the command -`autoreconf --force' should take care of everything correctly. - -- Make sure your changes compile and work, at least on your own -machine, before checking them into the main branch of the Guile -repository. If you really need to check in untested changes, make a -branch. - -- Include each log entry in both the ChangeLog and in the CVS logs. -If you're using Emacs, the pcl-cvs interface to CVS has features to -make this easier; it checks the ChangeLog, and generates good default -CVS log entries from that. - - -Coding standards ===================================================== - -- Before contributing larger amounts of code to Guile, please read the -documents in `guile-core/devel/policy' in the CVS source tree. - -- As for any part of Project GNU, changes to Guile should follow the -GNU coding standards. The standards are available via anonymous FTP -from prep.ai.mit.edu, as /pub/gnu/standards/standards.texi and -make-stds.texi. - -- The Guile tree should compile without warnings under the following -GCC switches, which are the default in the current configure script: - - -O2 -Wall -Wpointer-arith -Wmissing-prototypes - -To make sure of this, you can use the --enable-error-on-warning option -to configure. This option will make GCC fail if it hits a warning. - -Note that the warnings generated vary from one version of GCC to the -next, and from one architecture to the next (apparently). To provide -a concrete common standard, Guile should compile without warnings from -GCC 2.7.2.3 in a Red Hat 5.2 i386 Linux machine. Furthermore, each -developer should pursue any additional warnings noted by on their -compiler. This means that people using more stringent compilers will -have more work to do, and assures that everyone won't switch to the -most lenient compiler they can find. :) - -Note also that EGCS (as of November 3 1998) doesn't handle the -`noreturn' attribute properly, so it doesn't understand that functions -like scm_error won't return. This may lead to some silly warnings -about uninitialized variables. You should look into these warnings to -make sure they are indeed spurious, but you needn't correct warnings -caused by this EGCS bug. - -- If you add code which uses functions or other features that are not -entirely portable, please make sure the rest of Guile will still -function properly on systems where they are missing. This usually -entails adding a test to configure.in, and then adding #ifdefs to your -code to disable it if the system's features are missing. - -- The normal way of removing a function, macro or variable is to mark -it as "deprecated", keep it for a while, and remove it in a later -release. If a function or macro is marked as "deprecated" it -indicates that people shouldn't use it in new programs, and should try -to remove it in old. Make sure that an alternative exists unless it -is our purpose to remove functionality. Don't deprecate definitions -if it is unclear when they will be removed. (This is to ensure that a -valid way of implementing some functionality always exists.) - -When deprecating a definition, always follow this procedure: - -1. Mark the definition using - - #if (SCM_DEBUG_DEPRECATED == 0) - ... - #endif - - or, for Scheme code, wrap it using - - (begin-deprecated - ...) - -2. Make the deprecated code issue a warning when it is used, by using - scm_c_issue_deprecation_warning (in C) or issue-deprecation-warning - (in Scheme). - -3. Write a comment at the definition explaining how a programmer can - manage without the deprecated definition. - -4. Add an entry that the definition has been deprecated in NEWS and - explain what do do instead. - -5. In file TODO, there is a list of releases with reminders about what - to do at each release. Add a reminder about the removal of the - deprecated defintion at the appropriate release. - -- Please write log entries for functions written in C under the -functions' C names, and write log entries for functions written in -Scheme under the functions' Scheme names. Please don't do this: - - * procs.c, procs.h (procedure-documentation): Moved from eval.c. - -Entries like this make it harder to search the ChangeLogs, because you -can never tell which name the entry will refer to. Instead, write this: - - * procs.c, procs.h (scm_procedure_documentation): Moved from eval.c. - -Changes like adding this line are special: - - SCM_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map); - -Since the change here is about the name itself --- we're adding a new -alias for scm_map that guarantees the order in which we process list -elements, but we're not changing scm_map at all --- it's appropriate -to use the Scheme name in the log entry. - -- There's no need to keep a change log for a ChangeLog file. For any -other kind of file (including documentation, since our documentation -is indeed precisely engineered -- we surpass GNU standards here), add -an appropriate ChangeLog entry when you change it. Simple! - -- Make sure you have papers from people before integrating their -changes or contributions. This is very frustrating, but very -important to do right. From maintain.texi, "Information for -Maintainers of GNU Software": - - When incorporating changes from other people, make sure to follow the - correct procedures. Doing this ensures that the FSF has the legal - right to distribute and defend GNU software. - - For the sake of registering the copyright on later versions ofthe - software you need to keep track of each person who makes significant - changes. A change of ten lines or so, or a few such changes, in a - large program is not significant. - - *Before* incorporating significant changes, make sure that the person - has signed copyright papers, and that the Free Software Foundation has - received them. - -If you receive contributions you want to use from someone, let me know -and I'll take care of the administrivia. Put the contributions aside -until we have the necessary papers. - -Once you accept a contribution, be sure to keep the files AUTHORS and -THANKS uptodate. - -- When you make substantial changes to a file, add the current year to -the list of years in the copyright notice at the top of the file. - -- When you get bug reports or patches from people, be sure to list -them in THANKS. - - -Naming conventions ================================================= - -We use certain naming conventions to structure the considerable number -of global identifiers. All identifiers should be either all lower -case or all upper case. Syllables are separated by underscores `_'. -All non-static identifiers should start with scm_ or SCM_. Then might -follow zero or more syllables giving the category of the identifier. -The currently used category identifiers are - - t - type name - - c,C - something with a interface suited for C use. This is used - to name functions that behave like Scheme primitives but - have a more C friendly calling convention. - - i,I - internal to libguile. It is global, but not considered part - of the libguile API. - - f - a SCM variable pointing to a Scheme function object. - - F - a bit mask for a flag. - - m - a macro transformer procedure - - n,N - a count of something - - s - a constant C string - - k - a SCM variable pointing to a keyword. - - sym - a SCM variable pointing to a symbol. - - var - a SCM variable pointing to a variable object. - -The follwing syllables also have a technical meaning: - - str - this denotes a zero terminated C string - - mem - a C string with an explicit count - - -See also the file `devel/names.text'. - - -Helpful hints ======================================================== - -- [From Mikael Djurfeldt] When working on the Guile internals, it is -quite often practical to implement a scheme-level procedure which -helps you examine the feature you're working on. - -Examples of such procedures are: pt-size, debug-hand and -current-pstate. - -I've now put #ifdef GUILE_DEBUG around all such procedures, so that -they are not compiled into the "normal" Guile library. Please do the -same when you add new procedures/C functions for debugging purpose. - -You can define the GUILE_DEBUG flag by passing --enable-guile-debug to -the configure script. - -- You'll see uses of the macro SCM_P scattered throughout the code; -those are vestiges of a time when Guile was meant to compile on -pre-ANSI compilers. Guile now requires ANSI C, so when you write new -functions, feel free to use ANSI declarations, and please provide -prototypes for everything. You don't need to use SCM_P in new code. - - -Jim Blandy, and others - - -Patches =========================================================== - -This one makes cvs-1.10 consider the file $CVSDOTIGNORE instead of -.cvsignore when that environment variable is set. - -=== patch start === -diff -r -u cvs-1.10/src/cvs.h cvs-1.10.ignore-hack/src/cvs.h ---- cvs-1.10/src/cvs.h Mon Jul 27 04:54:11 1998 -+++ cvs-1.10.ignore-hack/src/cvs.h Sun Jan 23 12:58:09 2000 -@@ -516,7 +516,7 @@ - - extern int ign_name PROTO ((char *name)); - void ign_add PROTO((char *ign, int hold)); --void ign_add_file PROTO((char *file, int hold)); -+int ign_add_file PROTO((char *file, int hold)); - void ign_setup PROTO((void)); - void ign_dir_add PROTO((char *name)); - int ignore_directory PROTO((char *name)); -diff -r -u cvs-1.10/src/ignore.c cvs-1.10.ignore-hack/src/ignore.c ---- cvs-1.10/src/ignore.c Mon Sep 8 01:04:15 1997 -+++ cvs-1.10.ignore-hack/src/ignore.c Sun Jan 23 12:57:50 2000 -@@ -99,9 +99,9 @@ - /* - * Open a file and read lines, feeding each line to a line parser. Arrange - * for keeping a temporary list of wildcards at the end, if the "hold" -- * argument is set. -+ * argument is set. Return true when the file exists and has been handled. - */ --void -+int - ign_add_file (file, hold) - char *file; - int hold; -@@ -149,8 +149,8 @@ - if (fp == NULL) - { - if (! existence_error (errno)) -- error (0, errno, "cannot open %s", file); -- return; -+ error (0, errno, "cannot open %s", file); -+ return 0; - } - while (getline (&line, &line_allocated, fp) >= 0) - ign_add (line, hold); -@@ -159,6 +159,7 @@ - if (fclose (fp) < 0) - error (0, errno, "cannot close %s", file); - free (line); -+ return 1; - } - - /* Parse a line of space-separated wildcards and add them to the list. */ -@@ -375,6 +376,7 @@ - struct stat sb; - char *file; - char *xdir; -+ char *cvsdotignore; - - /* Set SUBDIRS if we have subdirectory information in ENTRIES. */ - if (entries == NULL) -@@ -397,7 +399,10 @@ - if (dirp == NULL) - return; - -- ign_add_file (CVSDOTIGNORE, 1); -+ cvsdotignore = getenv("CVSDOTIGNORE"); -+ if (cvsdotignore == NULL || !ign_add_file (cvsdotignore, 1)) -+ ign_add_file (CVSDOTIGNORE, 1); -+ - wrap_add_file (CVSDOTWRAPPER, 1); - - while ((dp = readdir (dirp)) != NULL) -=== patch end === - -This one is for pcl-cvs-2.9.2, so that `i' adds to the local -.cvsignore file. - -=== patch start === ---- pcl-cvs.el~ Mon Nov 1 12:33:46 1999 -+++ pcl-cvs.el Tue Jan 25 21:46:27 2000 -@@ -1177,7 +1177,10 @@ - "Append the file in FILEINFO to the .cvsignore file. - Can only be used in the *cvs* buffer." - (save-window-excursion -- (set-buffer (find-file-noselect (expand-file-name ".cvsignore" dir))) -+ (set-buffer (find-file-noselect -+ (expand-file-name (or (getenv "CVSDOTIGNORE") -+ ".cvsignore") -+ dir))) - (goto-char (point-max)) - (unless (zerop (current-column)) (insert "\n")) - (insert str "\n") -=== patch end === diff --git a/README b/README index 47f0db224..671b8ae21 100644 --- a/README +++ b/README @@ -195,8 +195,14 @@ Automake macros, in ${prefix}/share/aclocal: Documentation in Info format, in ${prefix}/info: - data-rep.info --- an essay on how to write C code that works with - Guile Scheme values. + guile --- Guile reference manual. + + guile-tut --- Guile tutorial. + + GOOPS --- GOOPS reference manual. + + r5rs --- Revised(5) Report on the Algorithmic Language Scheme. + The Guile source tree is laid out as follows: From c276c3e34433f8138c82cb59ccdddf78da6cad17 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Fri, 23 Nov 2001 11:28:12 +0000 Subject: [PATCH 209/281] * Remove spurious placeholder text. --- doc/ref/ChangeLog | 5 +++++ doc/ref/program.texi | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index c7f84b553..0570a1cae 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-11-23 Neil Jerram + + * program.texi (Program Control): Remove spurious placeholder + text. + 2001-11-20 Thien-Thi Nguyen * scheme-options.texi (Install Config): diff --git a/doc/ref/program.texi b/doc/ref/program.texi index b6d268981..e9c3dccd4 100644 --- a/doc/ref/program.texi +++ b/doc/ref/program.texi @@ -129,8 +129,6 @@ REFFIXME. @node Program Control @section What Controls Program Execution? -What indeed? - @node User Programming @section How About Application Users? From b64f4200f4c60dc29dbd6c073e6966cc9b8962af Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 23 Nov 2001 21:38:33 +0000 Subject: [PATCH 210/281] (scm_c_use_module): Adapt to changes to `process-use-modules'. --- libguile/modules.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/modules.c b/libguile/modules.c index e88ff73ea..25776a026 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -171,7 +171,7 @@ void scm_c_use_module (const char *name) { scm_call_1 (SCM_VARIABLE_REF (process_use_modules_var), - scm_list_1 (convert_module_name (name))); + scm_list_1 (scm_list_1 (convert_module_name (name)))); } static SCM module_export_x_var; From d2bc7faea771339d31a9dceec073e5aff4199338 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 23 Nov 2001 21:40:39 +0000 Subject: [PATCH 211/281] *** empty log message *** --- libguile/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index d9d490b9f..25faa5506 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-11-23 Marius Vollmer + + * modules.c (scm_c_use_module): Adapt to changes to + `process-use-modules'. + 2001-11-22 Dirk Herrmann * numbers.c (scm_divide): Fix more division by zero errors. From 482a28f90a64751c4fd9fbb04adc4e3f80450429 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 23 Nov 2001 21:43:44 +0000 Subject: [PATCH 212/281] Added comments to functions that are used by "modules.c". --- ice-9/boot-9.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 16254d32d..1aee82d60 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -1702,6 +1702,9 @@ (lambda (symbol) (symbol-append prefix symbol))) +;; This function is called from "modules.c". If you change it, be +;; sure to update "modules.c" as well. + (define (process-define-module args) (let* ((module-id (car args)) (module (resolve-module module-id #f)) @@ -1796,6 +1799,9 @@ (define autoloads-in-progress '()) +;; This function is called from "modules.c". If you change it, be +;; sure to update "modules.c" as well. + (define (try-module-autoload module-name) (let* ((reverse-name (reverse module-name)) (name (symbol->string (car reverse-name))) @@ -2553,6 +2559,9 @@ ;; The guts of the use-modules macro. Add the interfaces of the named ;; modules to the use-list of the current module, in order. +;; This function is called by "modules.c". If you change it, be sure +;; to change scm_c_use_module as well. + (define (process-use-modules module-interface-args) (for-each (lambda (mif-args) (let ((mod-iface (apply resolve-interface mif-args))) @@ -2619,7 +2628,10 @@ (defmacro ,@args)))))) ;; Export a local variable -;; + +;; This function is called from "modules.c". If you change it, be +;; sure to update "modules.c" as well. + (define (module-export! m names) (let ((public-i (module-public-interface m))) (for-each (lambda (name) From 2e203f2d11444eaa935e50acd7dce7fe0fce638b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 23 Nov 2001 23:32:13 +0000 Subject: [PATCH 213/281] *** empty log message *** --- devel/memory.text | 198 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 devel/memory.text diff --git a/devel/memory.text b/devel/memory.text new file mode 100644 index 000000000..ea08a0551 --- /dev/null +++ b/devel/memory.text @@ -0,0 +1,198 @@ +The following is gathered from a shortish discussion on the +guile-devel mailing list. I plan to implement this in the next +days. -mvo + +Improving memory handling in Guile +---------------------------------- + +I think we have a problem with the `mallocated' GC trigger. It is not +maintained reliably and I'm afraid we need to have everybody review +their code to get it right. + +I think the current interface with scm_must_malloc, scm_must_free, +scm_done_malloc, scm_done_free is too difficult to use right and too +hard to debug. + +Guile itself is full of mtrigger related bugs, I'm afraid. A typical +one is in fports.c: the buffers for a fport are allocated with +scm_must_malloc and freed with scm_must_free. The allocation is +reported to the GC, but the freeing never is. The result is that the +GC thinks that more and more memory is being allocated that it should +be able to free, but that never actually gets freed (although in +reality the program is very well behaved). As a counter measure to +constant GC, the GC raises its mtrigger setting in a frenzy until it +wraps around, causing a `hallucinating GC' syndrome, effectively +stopping the program dead. + +(Watch scm_mtrigger while your favorite long-running Guile program +executes, it will continuously rise.) + +The problem is that scm_must_malloc registers the allocated amount +with the GC, but scm_must_free does not de-register it. For that, one +would currently needs to use scm_done_free, or return an appropriate +number from a smob free routine. + +Another problem is that scm_must_malloc is used in places where it is +probably not appropriate since the caller does not know whether that +block memory is really ending up under the control of the GC, or not. +For example scm_do_read_line in rdelim.c uses scm_must_malloc to +allocate a buffer that it returns, and scm_read_line passes this to +scm_take_string. scm_take_string assumes that the memory has not been +under GC control previously and calls scm_done_malloc to account for +the fact that it now is. But scm_must_malloc has _already_ increased +scm_mallocated by the proper amount. Thus, it is now doubly +reflected. + +Since the current interface is unsymmetrical (scm_must_malloc +registers, but scm_must_free doesn't de-register), I propose to change +it as follows. Switching to this new interface will force us and +everybody else to systematically review their code. + + - the smob free routine does no longer return the number of bytes + that have been freed. For the transition period, free routines + are first encourged to return 0, then required, and then their + return type changes to void. + + - scm_must_malloc, scm_must_free are deprecated. + + - in their place, we have + + Function: void *scm_malloc (size_t size, const char *what); + + Allocate SIZE bytes of memory. When not enough memory is + available, signal an error. This function runs the GC to free + up some memory when it deems it appropriate. + + The WHAT argument is used for statistical purposes and for + error reporting. It should describe the type of object that + the memory will be used for so that users can identify just + what strange objects are eating up their memory. + + [ Note: this function will not consider the memory block to be + under GC control. ] + + Function: void scm_free (void *mem); + + Free the memory at MEM. MEM must have been returned by + scm_malloc. MEM might be NULL in which case nothing happens. + + Function: void *scm_realloc (void *mem, size_t newsize); + + Change the size of the memory block at MEM to NEWSIZE. A new + pointer is returned. When NEWSIZE is 0 this is the same as + calling scm_free on MEM and NULL is returned. MEM must be + non-NULL, that is, the first allocation must be done with + scm_malloc, to allow specifying the WHAT value. + + Function: void scm_gc_register_collectable_memory + (void *mem, size_t size, const char *what); + + Informs the GC that the memory at MEM of size SIZE can + potentially be freed during a GC. That is, MEM is part of a + GC controlled object and when the GC happens to free that + object, SIZE bytes will be freed along with it. The GC will + _not_ free the memory itself, it will just know that so-and-so + much bytes of memory are associated with GC controlled objects + and the memory system figures this into its decisions when to + run a GC. + + MEM does not need to come from scm_malloc. You can only call + this function once for every memory block. + + Function: void scm_gc_unregister_collectable_memory + (void *mem, size_t size); + + Inform the GC that the memory at MEM of size SIZE is no longer + associated with a GC controlled object. + + Function: void *scm_gc_malloc (size_t size, const char *what); + + Like scm_malloc, but also call scm_gc_register_collectable_memory. + + Function: void scm_gc_free (void *mem, size_t size, const char *what); + + Like scm_free, but also call scm_gc_unregister_collectable_memory. + + Note that you need to explicitely pass the SIZE parameter. + This is done since it should normally be easy to provide this + parameter (for memory that is associated with GC controlled + objects) and this frees us from tracking this value in the GC + itself. (We don't do this out of lazyness but because it will + keep the memory management overhead very low.) + +The normal thing to use is scm_gc_malloc / scm_gc_free. + + +Cell allocation and initialization +---------------------------------- + +It can happen that the GC is invoked during the code that initializes +a cell. The half initialized cell is seen by the GC, which would +normally cause it to crash. To prevent this, the initialization code +is careful to set the type tag of the cell last, so that the GC will +either see a completely initialized cell, or a cell with type tag +`free_cell'. However, some slot of that `free' cell might be the only +place where a live object is referenced from (since the compiler might +reuse the stack location or register that held it before it was +stuffed into the cell). To protect such an object, the contents of +the cell (except the first word) is marked conservatively. + +What happened to me was that scm_gc_mark hit upon a completely +uninitialized cell, that was tagged a s a free cell, and still pointed +to the rest of the freelist were it came from. (It was probably this code + + : + SCM_NEWCELL (port); // port is a free cell + SCM_DEFER_INTS; + pt = scm_add_to_port_table (port); // this invokes the GC + : + +that caused it.) + +scm_gc_mark would conservatively mark the cdr of the free cell, which +resulted in marking the whole free list. This caused a stack overflow +because the marking didn't happen in a tail-calling manner. (Even if +it doesn't crash, a lot of unnecessary work is done.) + +I propose to change the current practice so that no half initialized +cell is ever seen by the GC. scm_gc_mark would abort on seeing a free +cell, and scm_mark_locations (and scm_gc_mark_cell_conservatively if +will survive) would not mark a free cell, even if the pointer points +to a valid cell. scm_gc_sweep would continue to ignore free cells. + +To ensure that initialization can not be interrupted by a GC, we +provide new functions/macros to allocate a cell that include +initialization. For example + + SCM scm_newcell_init (scm_bits_t car, scm_bits_t cdr) + { + SCM z; + if (SCM_NULLP (scm_freelist)) + z = scm_gc_for_newcell (&scm_master_freelist, + &scm_freelist); + else + { + z = scm_freelist; + scm_freelist = SCM_FREE_CELL_CDR (scm_freelist); + } + SCM_SET_CELL_WORD_1 (z, cdr); + SCM_SET_CELL_WORD_0 (z, car); + scm_remember_upto_here (cdr); + return into; + } + +For performance, we might turn this into a macro, and find some +specialized ways to make the compiler remember certain values (like +some `asm' statement for GCC). For a non-threaded Guile, and a +cooperatively threaded one, the scm_remember_upto_here call is not +even needed since we know the the function can not be +interrupted. (Signals can not interrupt the flow of control any +longer). + +In the transition period, while SCM_NEWCELL is deprecated, we can make +it always initialize the first slot with scm_tc16_allocated. Such +cells are marked conservatively by the GC. SCM_NEWCELL can have +abysmal performance while being deprecated. + +Update: SCM_NEWCELL already behaves like this. We only need to +implement scm_newcell_init and replace uses of SCM_NEWCELL with it. From 5bd732c952a135c2a93df512f6b9bb469d1c49a8 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 14:44:10 +0000 Subject: [PATCH 214/281] * acconfig.h (HAVE_INLINE): Added template. * configure.in (HAVE_INLINE): Define it when the compiler supports inline functions. --- acconfig.h | 2 ++ configure.in | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/acconfig.h b/acconfig.h index deff151c9..ac4b6384b 100644 --- a/acconfig.h +++ b/acconfig.h @@ -167,3 +167,5 @@ /* Define if the compiler supports long longs. */ #undef HAVE_LONG_LONGS +/* Define if the compiler supports inline functions. */ +#undef HAVE_INLINE diff --git a/configure.in b/configure.in index 9a40ffdfe..fb5a8e814 100644 --- a/configure.in +++ b/configure.in @@ -176,6 +176,10 @@ AC_C_CONST AC_C_INLINE AC_C_BIGENDIAN +if test "$ac_cv_c_inline" != no; then + AC_DEFINE(HAVE_INLINE) +fi + AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) From 16ea96206da60ab69ce3f0eef80995b5e44c305b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 14:45:17 +0000 Subject: [PATCH 215/281] New files. --- libguile/inline.c | 49 +++++++++++++++ libguile/inline.h | 156 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 libguile/inline.c create mode 100644 libguile/inline.h diff --git a/libguile/inline.c b/libguile/inline.c new file mode 100644 index 000000000..3ec21e55c --- /dev/null +++ b/libguile/inline.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + +#include "libguile/scmconfig.h" + +#ifndef HAVE_INLINE + +#define HAVE_INLINE +#include "libguile/inline.h" + +#endif diff --git a/libguile/inline.h b/libguile/inline.h new file mode 100644 index 000000000..c25bc3ad7 --- /dev/null +++ b/libguile/inline.h @@ -0,0 +1,156 @@ +/* classes: h_files */ + +#ifndef SCM_INLINE_H +#define SCM_INLINE_H + +/* Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * As a special exception, the Free Software Foundation gives permission + * for additional uses of the text contained in its release of GUILE. + * + * The exception is that, if you link the GUILE library with other files + * to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the GUILE library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the + * Free Software Foundation under the name GUILE. If you copy + * code from other Free Software Foundation releases into a copy of + * GUILE, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for GUILE, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. */ + +/* This file is for inline functions. On platforms that don't support + inlining functions, they are turned into ordinary functions. See + "inline.c". +*/ + +#include "libguile/pairs.h" +#include "libguile/gc.h" + +#ifdef HAVE_INLINE + +static inline SCM +scm_alloc_cell (scm_t_bits car, scm_t_bits cdr) +{ + SCM z; + +#ifdef GUILE_DEBUG_FREELIST + scm_newcell_count++; + if (scm_debug_check_freelist) + { + scm_check_freelist (scm_freelist); + scm_gc(); + } +#endif + + if (SCM_NULLP (scm_freelist)) + { + z = scm_gc_for_newcell (&scm_master_freelist, &scm_freelist); + } + else + { + z = scm_freelist; + scm_freelist = SCM_FREE_CELL_CDR (scm_freelist); + } + + /* Initialize the type slot last so that the cell is ignored by the + GC until it is completely initialized. This is only relevant + when the GC can actually run during this code, which it can't for + cooperating threads, but it might be important when we get true + preemptive threads. + */ + SCM_SET_CELL_WORD_1 (z, cdr); + SCM_SET_CELL_WORD_0 (z, car); + +#ifdef USE_THREADS +#ifndef USE_COOP_THREADS + /* When we are using non-cooperating threads, we might need to make + sure that the initial values for the slots are protected until + the cell is completely initialized. + */ +#error review me + scm_remember_upto_here_1 (SCM_PACK (cdr)); +#endif +#endif + + return z; +} + +static inline SCM +scm_alloc_double_cell (scm_t_bits car, scm_t_bits cbr, + scm_t_bits ccr, scm_t_bits cdr) +{ + SCM z; + +#ifdef GUILE_DEBUG_FREELIST + scm_newcell2_count++; + if (scm_debug_check_freelist) + { + scm_check_freelist (scm_freelist2); + scm_gc(); + } +#endif + + if (SCM_NULLP (scm_freelist2)) + { + z = scm_gc_for_newcell (&scm_master_freelist2, &scm_freelist2); + } + else + { + z = scm_freelist2; + scm_freelist2 = SCM_FREE_CELL_CDR (scm_freelist2); + } + + /* Initialize the type slot last so that the cell is ignored by the + GC until it is completely initialized. This is only relevant + when the GC can actually run during this code, which it can't for + cooperating threads, but it might be important when we get true + preemptive threads. + */ + SCM_SET_CELL_WORD_1 (z, cbr); + SCM_SET_CELL_WORD_2 (z, ccr); + SCM_SET_CELL_WORD_3 (z, cdr); + SCM_SET_CELL_WORD_0 (z, car); + +#ifdef USE_THREADS +#ifndef USE_COOP_THREADS + /* When we are using non-cooperating threads, we might need to make + sure that the initial values for the slots are protected until + the cell is completely initialized. + */ +#error review me + scm_remember_upto_here_3 (SCM_PACK (cbr), SCM_PACK (ccr), SCM_PACK (cdr)); +#endif +#endif + + return z; +} + +#endif + +#endif From 394661e96bf1341b8cd725b925732d06306ac029 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 14:45:53 +0000 Subject: [PATCH 216/281] Include "libguile/inline.h". --- libguile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libguile.h b/libguile.h index c184776e2..0dea6240c 100644 --- a/libguile.h +++ b/libguile.h @@ -131,6 +131,7 @@ extern "C" { #ifdef USE_THREADS #include "libguile/threads.h" #endif +#include "libguile/inline.h" #ifdef __cplusplus } From 53c594fc34aa2276eb87090bdb59f3b30743addd Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 14:49:23 +0000 Subject: [PATCH 217/281] *** empty log message *** --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 338817f50..ee6d80cab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-11-25 Marius Vollmer + + * acconfig.h (HAVE_INLINE): Added template. + * configure.in (HAVE_INLINE): Define it when the compiler supports + inline functions. + + * libguile.h: Include "libguile/inline.h". + 2001-11-22 Gary Houston * HACKING: Modified the Hacking It Yourself section. Removed the From 9d5315b649b55cfab89993b0fbd38bcca6ec78c1 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 14:51:03 +0000 Subject: [PATCH 218/281] Removed docs about SCM_NEWCELL and added scm_alloc_cell and scm_alloc_double_cell. Replaced scm_bits_t with scm_t_bits. --- doc/ref/data-rep.texi | 111 +++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/doc/ref/data-rep.texi b/doc/ref/data-rep.texi index 137d11833..b216da093 100644 --- a/doc/ref/data-rep.texi +++ b/doc/ref/data-rep.texi @@ -46,7 +46,7 @@ @c essay @sp 10 @c essay @comment The title is printed in a large font. @c essay @title Data Representation in Guile -@c essay @subtitle $Id: data-rep.texi,v 1.1 2001-08-24 09:40:29 ossau Exp $ +@c essay @subtitle $Id: data-rep.texi,v 1.2 2001-11-25 14:51:03 mvo Exp $ @c essay @subtitle For use with Guile @value{VERSION} @c essay @author Jim Blandy @c essay @author Free Software Foundation @@ -792,25 +792,6 @@ Return non-zero iff @var{x} is a Scheme pair object. The complement of SCM_CONSP. @end deftypefn -@deftypefn Macro void SCM_NEWCELL (SCM @var{into}) -Allocate a new cell, and set @var{into} to point to it. This macro -expands to a statement, not an expression, and @var{into} must be an -lvalue of type SCM. - -This is the most primitive way to allocate a cell; it is quite fast. - -The @sc{car} of the cell initially tags it as a ``free cell''. If the -caller intends to use it as an ordinary cons, she must store ordinary -SCM values in its @sc{car} and @sc{cdr}. - -If the caller intends to use it as a header for some other type, she -must store an appropriate magic value in the cell's @sc{car}, to mark -it as a member of that type, and store whatever value in the @sc{cdr} -that type expects. You should generally not do this, unless you are -implementing a new datatype, and thoroughly understand the code in -@code{}. -@end deftypefn - @deftypefun SCM scm_cons (SCM @var{car}, SCM @var{cdr}) Allocate (``CONStruct'') a new pair, with @var{car} and @var{cdr} as its contents. @@ -1077,7 +1058,7 @@ with @code{SCM} values. Values are converted between C data types and the @code{SCM} type with utility functions and macros. @item -@code{scm_bits_t} is an integral data type that is guaranteed to be +@code{scm_t_bits} is an integral data type that is guaranteed to be large enough to hold all information that is required to represent any Scheme object. While this data type is mostly used to implement Guile's internals, the use of this type is also necessary to write certain kinds @@ -1085,20 +1066,21 @@ of extensions to Guile. @end itemize @menu -* Relationship between SCM and scm_bits_t:: +* Relationship between SCM and scm_t_bits:: * Immediate objects:: * Non-immediate objects:: +* Allocating Cells:: * Heap Cell Type Information:: * Accessing Cell Entries:: * Basic Rules for Accessing Cell Entries:: @end menu -@node Relationship between SCM and scm_bits_t -@subsubsection Relationship between @code{SCM} and @code{scm_bits_t} +@node Relationship between SCM and scm_t_bits +@subsubsection Relationship between @code{SCM} and @code{scm_t_bits} A variable of type @code{SCM} is guaranteed to hold a valid Scheme -object. A variable of type @code{scm_bits_t}, on the other hand, may +object. A variable of type @code{scm_t_bits}, on the other hand, may hold a representation of a @code{SCM} value as a C integral type, but may also hold any C value, even if it does not correspond to a valid Scheme object. @@ -1107,21 +1089,21 @@ For a variable @var{x} of type @code{SCM}, the Scheme object's type information is stored in a form that is not directly usable. To be able to work on the type encoding of the scheme value, the @code{SCM} variable has to be transformed into the corresponding representation as -a @code{scm_bits_t} variable @var{y} by using the @code{SCM_UNPACK} +a @code{scm_t_bits} variable @var{y} by using the @code{SCM_UNPACK} macro. Once this has been done, the type of the scheme object @var{x} -can be derived from the content of the bits of the @code{scm_bits_t} +can be derived from the content of the bits of the @code{scm_t_bits} value @var{y}, in the way illustrated by the example earlier in this chapter (@pxref{Cheaper Pairs}). Conversely, a valid bit encoding of a -Scheme value as a @code{scm_bits_t} variable can be transformed into the +Scheme value as a @code{scm_t_bits} variable can be transformed into the corresponding @code{SCM} value using the @code{SCM_PACK} macro. -@deftypefn Macro scm_bits_t SCM_UNPACK (SCM @var{x}) +@deftypefn Macro scm_t_bits SCM_UNPACK (SCM @var{x}) Transforms the @code{SCM} value @var{x} into its representation as an integral type. Only after applying @code{SCM_UNPACK} it is possible to access the bits and contents of the @code{SCM} value. @end deftypefn -@deftypefn Macro SCM SCM_PACK (scm_bits_t @var{x}) +@deftypefn Macro SCM SCM_PACK (scm_t_bits @var{x}) Takes a valid integral representation of a Scheme object and transforms it into its representation as a @code{SCM} value. @end deftypefn @@ -1153,7 +1135,7 @@ Given a Scheme object @var{x} of unknown type, check first with @code{SCM_IMP (@var{x})} if it is an immediate object. @item If so, all of the type and value information can be determined from the -@code{scm_bits_t} value that is delivered by @code{SCM_UNPACK +@code{scm_t_bits} value that is delivered by @code{SCM_UNPACK (@var{x})}. @end itemize @@ -1180,7 +1162,7 @@ pointer @var{x}. @end deftypefn Note that it is also possible to transform a non-immediate @code{SCM} -value by using @code{SCM_UNPACK} into a @code{scm_bits_t} variable. +value by using @code{SCM_UNPACK} into a @code{scm_t_bits} variable. However, the result of @code{SCM_UNPACK} may not be used as a pointer to a @code{scm_cell}: only @code{SCM2PTR} is guaranteed to transform a @code{SCM} object into a valid pointer to a heap cell. Also, it is not @@ -1200,23 +1182,52 @@ Don't use @code{(scm_cell *) SCM_UNPACK (@var{x})}! Use @code{SCM2PTR Don't use @code{PTR2SCM} for anything but a cell pointer! @end itemize +@node Allocating Cells +@subsubsection Allocating Cells + +Guile provides both ordinary cells with two slots, and double cells +with four slots. The following two function are the most primitive +way to allocate such cells. + +If the caller intends to use it as a header for some other type, she +must pass an appropriate magic value in @var{word_0}, to mark it as a +member of that type, and pass whatever value as @var{word_1}, etc that +the type expects. You should generally not need these functions, +unless you are implementing a new datatype, and thoroughly understand +the code in @code{}. + +If you just want to allocate pairs, use @code{scm_cons}. + +@deftypefn Function SCM scm_alloc_cell (scm_t_bits word_0, scm_t_bits word_1) +Allocate a new cell, initialize the two slots with @var{word_0} and +@var{word_1}, and return it. + +Note that @var{word_0} and @var{word_1} are of type @code{scm_t_bits}. +If you want to pass a @code{SCM} object, you need to use +@code{SCM_UNPACK}. +@end deftypefn + +@deftypefn Function SCM scm_alloc_double_cell (scm_t_bits word_0, scm_t_bits word_1, scm_t_bits word_2, scm_t_bits word_3) +Like @code{scm_alloc_cell}, but allocates a double cell with four +slots. +@end deftypefn @node Heap Cell Type Information @subsubsection Heap Cell Type Information Heap cells contain a number of entries, each of which is either a scheme -object of type @code{SCM} or a raw C value of type @code{scm_bits_t}. +object of type @code{SCM} or a raw C value of type @code{scm_t_bits}. Which of the cell entries contain Scheme objects and which contain raw C values is determined by the first entry of the cell, which holds the cell type information. -@deftypefn Macro scm_bits_t SCM_CELL_TYPE (SCM @var{x}) +@deftypefn Macro scm_t_bits SCM_CELL_TYPE (SCM @var{x}) For a non-immediate Scheme object @var{x}, deliver the content of the first entry of the heap cell referenced by @var{x}. This value holds the information about the cell type. @end deftypefn -@deftypefn Macro void SCM_SET_CELL_TYPE (SCM @var{x}, scm_bits_t @var{t}) +@deftypefn Macro void SCM_SET_CELL_TYPE (SCM @var{x}, scm_t_bits @var{t}) For a non-immediate Scheme object @var{x}, write the value @var{t} into the first entry of the heap cell referenced by @var{x}. The value @var{t} must hold a valid cell type. @@ -1233,7 +1244,7 @@ hold Scheme objects and which cell entries hold raw C data. To access the different cell entries appropriately, the following macros are provided. -@deftypefn Macro scm_bits_t SCM_CELL_WORD (SCM @var{x}, unsigned int @var{n}) +@deftypefn Macro scm_t_bits SCM_CELL_WORD (SCM @var{x}, unsigned int @var{n}) Deliver the cell entry @var{n} of the heap cell referenced by the non-immediate Scheme object @var{x} as raw data. It is illegal, to access cell entries that hold Scheme objects by using these macros. For @@ -1268,7 +1279,7 @@ SCM_CELL_OBJECT_@var{n} (@var{x}) @result{} SCM_CELL_OBJECT (@var{x}, @end itemize @end deftypefn -@deftypefn Macro void SCM_SET_CELL_WORD (SCM @var{x}, unsigned int @var{n}, scm_bits_t @var{w}) +@deftypefn Macro void SCM_SET_CELL_WORD (SCM @var{x}, unsigned int @var{n}, scm_t_bits @var{w}) Write the raw C value @var{w} into entry number @var{n} of the heap cell referenced by the non-immediate Scheme value @var{x}. Values that are written into cells this way may only be read from the cells using the @@ -1432,7 +1443,7 @@ never @code{equal?} unless they are @code{eq?}. To actually register the new smob type, call @code{scm_make_smob_type}: -@deftypefun scm_bits_t scm_make_smob_type (const char *name, size_t size) +@deftypefun scm_t_bits scm_make_smob_type (const char *name, size_t size) This function implements the standard way of adding a new smob type, named @var{name}, with instance size @var{size}, to the system. The return value is a tag that is used in creating instances of the type. @@ -1451,22 +1462,22 @@ special function for a given type. Each function is intended to be used only zero or one time per type, and the call should be placed immediately following the call to @code{scm_make_smob_type}. -@deftypefun void scm_set_smob_mark (scm_bits_t tc, SCM (*mark) (SCM)) +@deftypefun void scm_set_smob_mark (scm_t_bits tc, SCM (*mark) (SCM)) This function sets the smob marking procedure for the smob type specified by the tag @var{tc}. @var{tc} is the tag returned by @code{scm_make_smob_type}. @end deftypefun -@deftypefun void scm_set_smob_free (scm_bits_t tc, size_t (*free) (SCM)) +@deftypefun void scm_set_smob_free (scm_t_bits tc, size_t (*free) (SCM)) This function sets the smob freeing procedure for the smob type specified by the tag @var{tc}. @var{tc} is the tag returned by @code{scm_make_smob_type}. @end deftypefun -@deftypefun void scm_set_smob_print (scm_bits_t tc, int (*print) (SCM, SCM, scm_print_state*)) +@deftypefun void scm_set_smob_print (scm_t_bits tc, int (*print) (SCM, SCM, scm_print_state*)) This function sets the smob printing procedure for the smob type specified by the tag @var{tc}. @var{tc} is the tag returned by @code{scm_make_smob_type}. @end deftypefun -@deftypefun void scm_set_smob_equalp (scm_bits_t tc, SCM (*equalp) (SCM, SCM)) +@deftypefun void scm_set_smob_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM)) This function sets the smob equality-testing predicate for the smob type specified by the tag @var{tc}. @var{tc} is the tag returned by @code{scm_make_smob_type}. @end deftypefun @@ -1500,7 +1511,7 @@ representing eight-bit grayscale images: @example #include -static scm_bits_t image_tag; +static scm_t_bits image_tag; void init_image_type (void) @@ -1529,9 +1540,9 @@ or @code{SCM_NEWSMOB3}:@footnote{The @code{SCM_NEWSMOB2} and @code{SCM_NEWSMOB3} variants will allocate double cells and thus use twice as much memory as smobs created by @code{SCM_NEWSMOB}.} -@deftypefn Macro void SCM_NEWSMOB(SCM value, scm_bits_t tag, void *data) -@deftypefnx Macro void SCM_NEWSMOB2(SCM value, scm_bits_t tag, void *data1, void *data2) -@deftypefnx Macro void SCM_NEWSMOB3(SCM value, scm_bits_t tag, void *data1, void *data2, void *data3) +@deftypefn Macro void SCM_NEWSMOB(SCM value, scm_t_bits tag, void *data) +@deftypefnx Macro void SCM_NEWSMOB2(SCM value, scm_t_bits tag, void *data1, void *data2) +@deftypefnx Macro void SCM_NEWSMOB3(SCM value, scm_t_bits tag, void *data1, void *data2, void *data3) Make @var{value} contain a smob instance of the type with tag @var{tag} and smob data @var{data} (or @var{data1}, @var{data2}, and @var{data3}). @var{value} must be previously declared as C type @code{SCM}. @@ -1541,9 +1552,9 @@ Since it is often the case (e.g., in smob constructors) that you will create a smob instance and return it, there is also a slightly specialized macro for this situation: -@deftypefn Macro fn_returns SCM_RETURN_NEWSMOB(scm_bits_t tag, void *data) -@deftypefnx Macro fn_returns SCM_RETURN_NEWSMOB2(scm_bits_t tag, void *data1, void *data2) -@deftypefnx Macro fn_returns SCM_RETURN_NEWSMOB3(scm_bits_t tag, void *data1, void *data2, void *data3) +@deftypefn Macro fn_returns SCM_RETURN_NEWSMOB(scm_t_bits tag, void *data) +@deftypefnx Macro fn_returns SCM_RETURN_NEWSMOB2(scm_t_bits tag, void *data1, void *data2) +@deftypefnx Macro fn_returns SCM_RETURN_NEWSMOB3(scm_t_bits tag, void *data1, void *data2, void *data3) This macro expands to a block of code that creates a smob instance of the type with tag @var{tag} and smob data @var{data} (or @var{data1}, @var{data2}, and @var{data3}), and returns that @code{SCM} value. It @@ -1942,7 +1953,7 @@ Guile shell, extended with the datatypes described here.) #include #include -static scm_bits_t image_tag; +static scm_t_bits image_tag; struct image @{ int width, height; From 9b7ee9d8a711de45a50cd28bd497e9b8f45ab6e5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 14:53:00 +0000 Subject: [PATCH 219/281] * inline.c, inline.h: New files. * Makefile.am: Added them in all the right places. --- libguile/Makefile.am | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 07cf6b80e..49f0e49a2 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -46,12 +46,13 @@ libguile_la_SOURCES = alist.c arbiters.c async.c backtrace.c boolean.c \ feature.c fluids.c fports.c \ gc.c gc_os_dep.c gdbint.c gh_data.c gh_eval.c gh_funcs.c gh_init.c \ gh_io.c gh_list.c gh_predicates.c goops.c gsubr.c guardians.c hash.c \ - hashtab.c hooks.c init.c ioext.c iselect.c keywords.c lang.c list.c \ + hashtab.c hooks.c init.c inline.c ioext.c iselect.c keywords.c \ + lang.c list.c \ load.c macros.c mallocs.c modules.c numbers.c objects.c objprop.c \ options.c pairs.c ports.c print.c procprop.c procs.c properties.c \ random.c rdelim.c read.c root.c rw.c scmsigs.c script.c simpos.c smob.c \ sort.c srcprop.c stackchk.c stacks.c stime.c strings.c strop.c \ - strorder.c strports.c struct.c symbols.c throw.c values.c \ + strorder.c strports.c struct.c symbols.c throw.c values.c \ variable.c vectors.c version.c vports.c weaks.c DOT_X_FILES = alist.x arbiters.x async.x backtrace.x boolean.x chars.x \ @@ -133,7 +134,8 @@ modinclude_HEADERS = __scm.h alist.h arbiters.h async.h backtrace.h boolean.h \ dynl.h dynwind.h environments.h eq.h error.h eval.h evalext.h \ extensions.h feature.h filesys.h fluids.h fports.h gc.h \ gdb_interface.h gdbint.h \ - goops.h gsubr.h guardians.h hash.h hashtab.h hooks.h init.h ioext.h \ + goops.h gsubr.h guardians.h hash.h hashtab.h hooks.h init.h \ + inline.h ioext.h \ iselect.h keywords.h lang.h list.h load.h macros.h mallocs.h modules.h \ net_db.h numbers.h objects.h objprop.h options.h pairs.h ports.h posix.h \ regex-posix.h print.h procprop.h procs.h properties.h random.h ramap.h \ From d678e25cf9dd4cc6b0ec04e79bc8189f5fed7197 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:00:31 +0000 Subject: [PATCH 220/281] (SCM_GC_SET_ALLOCATED, scm_debug_newcell, scm_debug_newcell2, scm_tc16_allocated): Removed from header. (scm_deprecated_newcell, scm_deprecated_newcell2): New. (SCM_NEWCELL, SCM_NEWCELL2): Implement in terms of scm_deprecated_newcell and scm_deprecated_newcell2. gc.c (scm_tc16_allocated): Only define when including deprecated features. (scm_debug_newcell, scm_debug_newcell2): Removed. (scm_init_storage): Do not initialize scm_tc16_allocated. (scm_init_gc): Do it here. (allocated_mark): New, from old code. (scm_deprecated_newcell, scm_deprecated_newcell2): New. --- libguile/gc.c | 117 ++++++++++++++++++++++---------------------------- libguile/gc.h | 61 ++++++-------------------- 2 files changed, 64 insertions(+), 114 deletions(-) diff --git a/libguile/gc.c b/libguile/gc.c index de1b3ee0d..8abe7f5e0 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -107,8 +107,6 @@ unsigned int scm_gc_running_p = 0; #if (SCM_DEBUG_CELL_ACCESSES == 1) -scm_t_bits scm_tc16_allocated; - /* Set this to != 0 if every cell that is accessed shall be checked: */ unsigned int scm_debug_cell_accesses_p = 1; @@ -695,65 +693,6 @@ SCM_DEFINE (scm_gc_set_debug_check_freelist_x, "gc-set-debug-check-freelist!", 1 } #undef FUNC_NAME - -SCM -scm_debug_newcell (void) -{ - SCM new; - - scm_newcell_count++; - if (scm_debug_check_freelist) - { - scm_check_freelist (scm_freelist); - scm_gc(); - } - - /* The rest of this is supposed to be identical to the SCM_NEWCELL - macro. */ - if (SCM_NULLP (scm_freelist)) - { - new = scm_gc_for_newcell (&scm_master_freelist, &scm_freelist); - SCM_GC_SET_ALLOCATED (new); - } - else - { - new = scm_freelist; - scm_freelist = SCM_FREE_CELL_CDR (scm_freelist); - SCM_GC_SET_ALLOCATED (new); - } - - return new; -} - -SCM -scm_debug_newcell2 (void) -{ - SCM new; - - scm_newcell2_count++; - if (scm_debug_check_freelist) - { - scm_check_freelist (scm_freelist2); - scm_gc (); - } - - /* The rest of this is supposed to be identical to the SCM_NEWCELL - macro. */ - if (SCM_NULLP (scm_freelist2)) - { - new = scm_gc_for_newcell (&scm_master_freelist2, &scm_freelist2); - SCM_GC_SET_ALLOCATED (new); - } - else - { - new = scm_freelist2; - scm_freelist2 = SCM_FREE_CELL_CDR (scm_freelist2); - SCM_GC_SET_ALLOCATED (new); - } - - return new; -} - #endif /* GUILE_DEBUG_FREELIST */ @@ -2703,10 +2642,6 @@ scm_init_storage () size_t init_heap_size_2; size_t j; -#if (SCM_DEBUG_CELL_ACCESSES == 1) - scm_tc16_allocated = scm_make_smob_type ("allocated cell", 0); -#endif /* SCM_DEBUG_CELL_ACCESSES == 1 */ - j = SCM_NUM_PROTECTS; while (j) scm_sys_protects[--j] = SCM_BOOL_F; @@ -2829,12 +2764,64 @@ mark_gc_async (void * hook_data SCM_UNUSED, return NULL; } +#if SCM_ENABLE_DEPRECATED == 1 + +/* If an allocated cell is detected during garbage collection, this + * means that some code has just obtained the object but was preempted + * before the initialization of the object was completed. This meanst + * that some entries of the allocated cell may already contain SCM + * objects. Therefore, allocated cells are scanned conservatively. + */ + +scm_t_bits scm_tc16_allocated; + +static SCM +allocated_mark (SCM cell) +{ + unsigned long int cell_segment = heap_segment (cell); + unsigned int span = scm_heap_table[cell_segment].span; + unsigned int i; + + for (i = 1; i != span * 2; ++i) + { + SCM obj = SCM_CELL_OBJECT (cell, i); + long int obj_segment = heap_segment (obj); + if (obj_segment >= 0) + scm_gc_mark (obj); + } + return SCM_BOOL_F; +} + +SCM +scm_deprecated_newcell (void) +{ + scm_c_issue_deprecation_warning + ("SCM_NEWCELL is deprecated. Use `scm_alloc_cell' instead.\n"); + + return scm_alloc_cell (scm_tc16_allocated, 0); +} + +SCM +scm_deprecated_newcell2 (void) +{ + scm_c_issue_deprecation_warning + ("SCM_NEWCELL2 is deprecated. Use `scm_alloc_double_cell' instead.\n"); + + return scm_alloc_double_cell (scm_tc16_allocated, 0, 0, 0); +} + +#endif /* SCM_ENABLE_DEPRECATED == 1 */ void scm_init_gc () { SCM after_gc_thunk; +#if SCM_ENABLE_DEPRECATED == 1 + scm_tc16_allocated = scm_make_smob_type ("allocated cell", 0); + scm_set_smob_mark (scm_tc16_allocated, allocated_mark); +#endif + scm_after_gc_hook = scm_permanent_object (scm_make_hook (SCM_INUM0)); scm_c_define ("after-gc-hook", scm_after_gc_hook); diff --git a/libguile/gc.h b/libguile/gc.h index 5e2a01ec4..e3f70519a 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -245,57 +245,10 @@ typedef unsigned long scm_t_c_bvec_limb; (((scm_t_bits *) SCM2PTR (x)) [1] = SCM_UNPACK (v)) -#if (SCM_DEBUG_CELL_ACCESSES == 1) -# define SCM_GC_SET_ALLOCATED(x) \ - (((scm_t_bits *) SCM2PTR (x)) [0] = scm_tc16_allocated) -#else -# define SCM_GC_SET_ALLOCATED(x) -#endif - -#ifdef GUILE_DEBUG_FREELIST -#define SCM_NEWCELL(_into) do { _into = scm_debug_newcell (); } while (0) -#define SCM_NEWCELL2(_into) do { _into = scm_debug_newcell2 (); } while (0) -#else -/* When we introduce POSIX threads support, every thread will have - a freelist of its own. */ -#define SCM_NEWCELL(_into) \ - do { \ - if (SCM_NULLP (scm_freelist)) \ - { \ - _into = scm_gc_for_newcell (&scm_master_freelist, \ - &scm_freelist); \ - SCM_GC_SET_ALLOCATED (_into); \ - } \ - else \ - { \ - _into = scm_freelist; \ - scm_freelist = SCM_FREE_CELL_CDR (scm_freelist); \ - SCM_GC_SET_ALLOCATED (_into); \ - } \ - } while(0) -#define SCM_NEWCELL2(_into) \ - do { \ - if (SCM_NULLP (scm_freelist2)) \ - { \ - _into = scm_gc_for_newcell (&scm_master_freelist2, \ - &scm_freelist2); \ - SCM_GC_SET_ALLOCATED (_into); \ - } \ - else \ - { \ - _into = scm_freelist2; \ - scm_freelist2 = SCM_FREE_CELL_CDR (scm_freelist2); \ - SCM_GC_SET_ALLOCATED (_into); \ - } \ - } while(0) -#endif - - #define SCM_MARKEDP SCM_GCMARKP #define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) #if (SCM_DEBUG_CELL_ACCESSES == 1) -SCM_API scm_t_bits scm_tc16_allocated; SCM_API unsigned int scm_debug_cell_accesses_p; #endif @@ -339,8 +292,6 @@ SCM_API SCM scm_map_free_list (void); SCM_API SCM scm_free_list_length (void); #endif #ifdef GUILE_DEBUG_FREELIST -SCM_API SCM scm_debug_newcell (void); -SCM_API SCM scm_debug_newcell2 (void); SCM_API SCM scm_gc_set_debug_check_freelist_x (SCM flag); #endif @@ -389,6 +340,18 @@ SCM_API int scm_init_storage (void); SCM_API void *scm_get_stack_base (void); SCM_API void scm_init_gc (void); +#if SCM_ENABLE_DEPRECATED == 1 + +SCM_API SCM scm_deprecated_newcell (void); +SCM_API SCM scm_deprecated_newcell2 (void); + +#define SCM_NEWCELL(_into) \ + do { _into = scm_deprecated_newcell (); } while (0) +#define SCM_NEWCELL2(_into) \ + do { _into = scm_deprecated_newcell2 (); } while (0) + +#endif + #endif /* SCM_GC_H */ /* From 6253f3f1d9c79a9da71acaf5f997802af110fbeb Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:02:44 +0000 Subject: [PATCH 221/281] Added prototypes for defined functions for the !HAVE_INLINE case. --- libguile/inline.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libguile/inline.h b/libguile/inline.h index c25bc3ad7..926623bf0 100644 --- a/libguile/inline.h +++ b/libguile/inline.h @@ -151,6 +151,12 @@ scm_alloc_double_cell (scm_t_bits car, scm_t_bits cbr, return z; } +#else /* !HAVE_INLINE */ + +SCM_API SCM scm_alloc_cell (scm_t_bits car, scm_t_bits cdr); +SCM_API SCM scm_alloc_double_cell (scm_t_bits car, scm_t_bits cbr, + scm_t_bits ccr, scm_t_bits cdr); + #endif #endif From 0f633e66839f3cf89f7cf7f3eb16bffb1498b8bc Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:03:28 +0000 Subject: [PATCH 222/281] Include "libguile/inline.h". --- libguile/_scm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libguile/_scm.h b/libguile/_scm.h index 1ee482b35..0a1c3f4fe 100644 --- a/libguile/_scm.h +++ b/libguile/_scm.h @@ -79,6 +79,7 @@ #include "libguile/snarf.h" /* Everyone snarfs. */ #include "libguile/variable.h" #include "libguile/modules.h" +#include "libguile/inline.h" /* SCM_SYSCALL retries system calls that have been interrupted (EINTR). However this can be avoided if the operating system can restart From da6129a67e1ccf785fe54ecc4deca44453276140 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:04:56 +0000 Subject: [PATCH 223/281] (scm_system_async_mark_from_signal_handler): New. --- libguile/async.c | 5 +++++ libguile/async.h | 1 + 2 files changed, 6 insertions(+) diff --git a/libguile/async.c b/libguile/async.c index b5c1f9e92..5d06c1f77 100644 --- a/libguile/async.c +++ b/libguile/async.c @@ -339,6 +339,11 @@ SCM_DEFINE (scm_system_async_mark, "system-async-mark", 1, 0, 0, } #undef FUNC_NAME +void +scm_system_async_mark_from_signal_handler (SCM a) +{ + SET_ASYNC_GOT_IT (a, scm_asyncs_pending_p = 1); +} SCM_DEFINE (scm_run_asyncs, "run-asyncs", 1, 0, 0, (SCM list_of_a), diff --git a/libguile/async.h b/libguile/async.h index 7cdb81cd1..e27cd2ccb 100644 --- a/libguile/async.h +++ b/libguile/async.h @@ -61,6 +61,7 @@ SCM_API SCM scm_async (SCM thunk); SCM_API SCM scm_system_async (SCM thunk); SCM_API SCM scm_async_mark (SCM a); SCM_API SCM scm_system_async_mark (SCM a); +SCM_API void scm_system_async_mark_from_signal_handler (SCM a); SCM_API SCM scm_run_asyncs (SCM list_of_a); SCM_API SCM scm_noop (SCM args); SCM_API SCM scm_set_tick_rate (SCM n); From 7123fc3b21c92ed8ac002adb826c74552c846407 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:08:12 +0000 Subject: [PATCH 224/281] (scm_take_signal): Removed all code that assumes that signal handlers are allowed to divert the flow of control. Call scm_system_async_mark_from_signal_handler instead of scm_system_async_mark. --- libguile/scmsigs.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 5ee384995..97375e8af 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -126,37 +126,8 @@ static SIGRETTYPE (*orig_handlers[NSIG])(int); static SIGRETTYPE take_signal (int signum) { - int saved_errno = errno; - SCM ignored; - - if (!scm_ints_disabled) - { - /* For reasons of speed, the SCM_NEWCELL macro doesn't defer - interrupts. Instead, it first sets its argument to point to - the first cell in the list, and then advances the freelist - pointer to the next cell. Now, if this procedure is - interrupted, the only anomalous state possible is to have - both SCM_NEWCELL's argument and scm_freelist pointing to the - same cell. To deal with this case, we always throw away the - first cell in scm_freelist here. - - At least, that's the theory. I'm not convinced that that's - the only anomalous path we need to worry about. */ - SCM_NEWCELL (ignored); - } got_signal[signum] = 1; -#if HAVE_SIGACTION - /* unblock the signal before the scheme handler gets to run, since - it may use longjmp to escape (i.e., throw an exception). */ - { - sigset_t set; - sigemptyset (&set); - sigaddset (&set, signum); - sigprocmask (SIG_UNBLOCK, &set, NULL); - } -#endif - scm_system_async_mark (signal_async); - errno = saved_errno; + scm_system_async_mark_from_signal_handler (signal_async); } static SCM From 6c4493a045445db8cc63d95ce58f9807bf325e3b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:11:20 +0000 Subject: [PATCH 225/281] Replaced SCM_DEBUG_DEPRECATED with !SCM_ENABLE_DEPRECATED. --- libguile/goops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/goops.h b/libguile/goops.h index 5ebae6d03..a288d84ac 100644 --- a/libguile/goops.h +++ b/libguile/goops.h @@ -300,7 +300,7 @@ SCM_API SCM scm_sys_method_more_specific_p (SCM m1, SCM m2, SCM targs); SCM_API SCM scm_init_goops_builtins (void); SCM_API void scm_init_goops (void); -#if (SCM_DEBUG_DEPRECATED == 0) +#if (SCM_ENABLE_DEPRECATED == 1) #define SCM_INST_TYPE(x) SCM_OBJ_CLASS_FLAGS (x) #define SCM_SIMPLEMETHODP(x) \ From 760eb0ce254149d30eca2bb2e83f2aa1dec22e83 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:12:39 +0000 Subject: [PATCH 226/281] (SCM_MAKE_BIGNUM_TAG): New. --- libguile/numbers.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libguile/numbers.h b/libguile/numbers.h index ddd716e9a..1866a8f37 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -175,11 +175,12 @@ #define SCM_BDIGITS(x) ((SCM_BIGDIG *) (SCM_CELL_WORD_1 (x))) #define SCM_SET_BIGNUM_BASE(n, b) (SCM_SET_CELL_WORD_1 ((n), (b))) #define SCM_NUMDIGS(x) ((size_t) (SCM_CELL_WORD_0 (x) >> SCM_BIGSIZEFIELD)) +#define SCM_MAKE_BIGNUM_TAG(v, sign) \ + (scm_tc16_big \ + | ((sign) ? SCM_BIGSIGNFLAG : 0) \ + | (((v) + 0L) << SCM_BIGSIZEFIELD)) #define SCM_SETNUMDIGS(x, v, sign) \ - SCM_SET_CELL_WORD_0 (x, \ - scm_tc16_big \ - | ((sign) ? SCM_BIGSIGNFLAG : 0) \ - | (((v) + 0L) << SCM_BIGSIZEFIELD)) + SCM_SET_CELL_WORD_0 (x, SCM_MAKE_BIGNUM_TAG (v, sign)) From 21ac1f4c5b324f188e8b2c37b66d6edc91dce546 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:13:52 +0000 Subject: [PATCH 227/281] (SCM_MAKE_CCLO_TAG): New. --- libguile/procs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libguile/procs.h b/libguile/procs.h index 90ecb5c72..c60c50ac0 100644 --- a/libguile/procs.h +++ b/libguile/procs.h @@ -76,7 +76,8 @@ typedef struct #define SCM_SUBR_GENERIC(x) (SCM_SUBR_ENTRY (x).generic) #define SCM_CCLO_LENGTH(x) (SCM_CELL_WORD_0 (x) >> 8) -#define SCM_SET_CCLO_LENGTH(x, v) (SCM_SET_CELL_WORD_0 ((x), ((v) << 8) + scm_tc7_cclo)) +#define SCM_MAKE_CCLO_TAG(v) (((v) << 8) + scm_tc7_cclo) +#define SCM_SET_CCLO_LENGTH(x, v) (SCM_SET_CELL_WORD_0 ((x), SCM_MAKE_CCLO_TAG(v))) #define SCM_CCLO_BASE(x) ((scm_t_bits *) SCM_CELL_WORD_1 (x)) #define SCM_SET_CCLO_BASE(x, v) (SCM_SET_CELL_WORD_1 ((x), (v))) From c65e98224bfa9717411ff1e5e2097c749a277559 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:14:51 +0000 Subject: [PATCH 228/281] (SCM_MAKE_STRING_TAG): New. --- libguile/strings.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libguile/strings.h b/libguile/strings.h index 9104a42e4..e7952cae2 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -56,7 +56,8 @@ #define SCM_SET_STRING_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c))) #define SCM_STRING_MAX_LENGTH ((1UL << 24) - 1UL) #define SCM_STRING_LENGTH(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 8)) -#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), (((scm_t_bits) (l)) << 8) + scm_tc7_string)) +#define SCM_MAKE_STRING_TAG(l) ((((scm_t_bits) (l)) << 8) + scm_tc7_string) +#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), SCM_MAKE_STRING_TAG (l))) From 0a7b506d24c824d997440387791adaf08eb5535b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:15:47 +0000 Subject: [PATCH 229/281] (SCM_MAKE_SYMBOL_TAG): New. --- libguile/symbols.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libguile/symbols.h b/libguile/symbols.h index 3a0269ff2..9de355540 100644 --- a/libguile/symbols.h +++ b/libguile/symbols.h @@ -55,7 +55,8 @@ #define SCM_SYMBOLP(x) (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_symbol)) #define SCM_SYMBOL_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) -#define SCM_SET_SYMBOL_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), ((l) << 8) + scm_tc7_symbol)) +#define SCM_MAKE_SYMBOL_TAG(l) (((l) << 8) + scm_tc7_symbol) +#define SCM_SET_SYMBOL_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), SCM_MAKE_SYMBOL_TAG(l))) #define SCM_SYMBOL_CHARS(x) ((char *) (SCM_CELL_WORD_1 (x))) #define SCM_SET_SYMBOL_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c))) #define SCM_SYMBOL_HASH(X) ((unsigned long) SCM_CELL_WORD_2 (X)) From 0b2f15c3ab447f222438ace7df40da31f350876f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:16:34 +0000 Subject: [PATCH 230/281] (SCM_MAKE_BITVECTOR_TAG, SCM_MAKE_UVECTOR_TAG): New. --- libguile/unif.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libguile/unif.h b/libguile/unif.h index b5d393a12..522a630b4 100644 --- a/libguile/unif.h +++ b/libguile/unif.h @@ -96,14 +96,16 @@ SCM_API scm_t_bits scm_tc16_array; #define SCM_SET_UVECTOR_BASE(v, b) (SCM_SET_CELL_WORD_1 ((v), (b))) #define SCM_UVECTOR_MAX_LENGTH SCM_I_MAX_LENGTH #define SCM_UVECTOR_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) -#define SCM_SET_UVECTOR_LENGTH(v, l, t) (SCM_SET_CELL_WORD_0 ((v), ((l) << 8) + (t))) +#define SCM_MAKE_UVECTOR_TAG(l,t) (((l) << 8) + (t)) +#define SCM_SET_UVECTOR_LENGTH(v, l, t) (SCM_SET_CELL_WORD_0 ((v), SCM_MAKE_UVECTOR_TAG(l,t))) #define SCM_BITVECTOR_P(x) (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_bvect)) #define SCM_BITVECTOR_BASE(x) ((unsigned long *) (SCM_CELL_WORD_1 (x))) #define SCM_SET_BITVECTOR_BASE(v, b) (SCM_SET_CELL_WORD_1 ((v), (b))) #define SCM_BITVECTOR_MAX_LENGTH SCM_I_MAX_LENGTH #define SCM_BITVECTOR_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) -#define SCM_SET_BITVECTOR_LENGTH(v, l) (SCM_SET_CELL_WORD_0 ((v), ((l) << 8) + scm_tc7_bvect)) +#define SCM_MAKE_BITVECTOR_TAG(l) (((l) << 8) + scm_tc7_bvect) +#define SCM_SET_BITVECTOR_LENGTH(v, l) (SCM_SET_CELL_WORD_0 ((v), SCM_MAKE_BITVECTOR_TAG (l))) From d3c0e81cc847b39537a2b2945d80de18bf8d5e89 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:18:18 +0000 Subject: [PATCH 231/281] (SCM_MAKE_VECTOR_TAG): New. --- libguile/vectors.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libguile/vectors.h b/libguile/vectors.h index 746a7686a..4d37b37a2 100644 --- a/libguile/vectors.h +++ b/libguile/vectors.h @@ -55,7 +55,8 @@ #define SCM_SET_VECTOR_BASE(v, b) (SCM_SET_CELL_WORD_1 ((v), (b))) #define SCM_VECTOR_MAX_LENGTH ((1L << 24) - 1) #define SCM_VECTOR_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) -#define SCM_SET_VECTOR_LENGTH(v, l, t) (SCM_SET_CELL_WORD_0 ((v), ((l) << 8) + (t))) +#define SCM_MAKE_VECTOR_TAG(l,t) (((l) << 8) + (t)) +#define SCM_SET_VECTOR_LENGTH(v, l, t) (SCM_SET_CELL_WORD_0 ((v), SCM_MAKE_VECTOR_TAG(l,t))) #define SCM_VELTS(x) ((SCM *) SCM_CELL_WORD_1 (x)) #define SCM_VELTS_AS_STACKITEMS(x) ((SCM_STACKITEM *) SCM_CELL_WORD_1 (x)) From 16d4699b6ba33685f1318636ffe4990c7db4fdc6 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:21:07 +0000 Subject: [PATCH 232/281] Replaced SCM_NEWCELL and SCM_NEWCELL2 with scm_alloc_cell and scm_alloc_double_cell, respectively. --- libguile/alist.c | 15 +++------------ libguile/coop-threads.c | 6 ++---- libguile/debug.c | 8 +------- libguile/environments.c | 17 +++++------------ libguile/eval.c | 14 ++++++-------- libguile/fports.c | 2 +- libguile/gh_data.c | 8 +------- libguile/goops.c | 20 ++++++-------------- libguile/guardians.c | 3 +-- libguile/lang.c | 6 +----- libguile/list.c | 4 +--- libguile/num2float.i.c | 3 +-- libguile/numbers.c | 7 ++----- libguile/pairs.c | 19 ++----------------- libguile/ports.c | 2 +- libguile/print.c | 4 +--- libguile/procs.c | 23 +++++------------------ libguile/smob.c | 21 ++++----------------- libguile/smob.h | 17 +++++------------ libguile/strings.c | 8 ++------ libguile/strports.c | 2 +- libguile/struct.c | 14 +++++--------- libguile/symbols.c | 10 +++++----- libguile/unif.c | 22 +++++++--------------- libguile/variable.c | 7 +------ libguile/vectors.c | 5 ++--- libguile/vports.c | 2 +- libguile/weaks.c | 18 ++++++++++-------- 28 files changed, 83 insertions(+), 204 deletions(-) diff --git a/libguile/alist.c b/libguile/alist.c index 9bb44cca8..2dd6057b4 100644 --- a/libguile/alist.c +++ b/libguile/alist.c @@ -58,18 +58,9 @@ SCM_DEFINE (scm_acons, "acons", 3, 0, 0, "function is @emph{not} destructive; @var{alist} is not modified.") #define FUNC_NAME s_scm_acons { - SCM pair; - SCM head; - - SCM_NEWCELL (pair); - SCM_SET_CELL_OBJECT_0 (pair, key); - SCM_SET_CELL_OBJECT_1 (pair, value); - - SCM_NEWCELL (head); - SCM_SET_CELL_OBJECT_0 (head, pair); - SCM_SET_CELL_OBJECT_1 (head, alist); - - return head; + return scm_alloc_cell (SCM_UNPACK (scm_alloc_cell (SCM_UNPACK (key), + SCM_UNPACK (value))), + SCM_UNPACK (alist)); } #undef FUNC_NAME diff --git a/libguile/coop-threads.c b/libguile/coop-threads.c index d126f67f6..659264fc7 100644 --- a/libguile/coop-threads.c +++ b/libguile/coop-threads.c @@ -257,9 +257,8 @@ scm_call_with_new_thread (SCM argl) /* Allocate thread locals. */ root = scm_make_root (scm_root->handle); /* Make thread. */ - SCM_NEWCELL (thread); + thread = scm_alloc_cell (scm_tc16_thread, 0); SCM_DEFER_INTS; - SCM_SETCAR (thread, scm_tc16_thread); argl = scm_cons (thread, argl); /* Note that we couldn't pass a pointer to argl as data since the argl variable may not exist in memory when the thread starts. */ @@ -345,9 +344,8 @@ scm_spawn_thread (scm_t_catch_body body, void *body_data, /* Allocate thread locals. */ root = scm_make_root (scm_root->handle); /* Make thread. */ - SCM_NEWCELL (thread); + thread = scm_alloc_cell (scm_tc16_thread, 0); SCM_DEFER_INTS; - SCM_SETCAR (thread, scm_tc16_thread); data->u.thread = thread; data->body = body; diff --git a/libguile/debug.c b/libguile/debug.c index 0f5373e5c..6b930711c 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -539,13 +539,7 @@ SCM_DEFINE (scm_debug_object_p, "debug-object?", 1, 0, 0, SCM scm_make_debugobj (scm_t_debug_frame *frame) { - register SCM z; - SCM_NEWCELL (z); - SCM_ENTER_A_SECTION; - SCM_SET_DEBUGOBJ_FRAME (z, frame); - SCM_SET_CELL_TYPE (z, scm_tc16_debugobj); - SCM_EXIT_A_SECTION; - return z; + return scm_alloc_cell (scm_tc16_debugobj, (scm_t_bits) frame); } diff --git a/libguile/environments.c b/libguile/environments.c index 541427641..237c8b28e 100644 --- a/libguile/environments.c +++ b/libguile/environments.c @@ -119,13 +119,7 @@ scm_error_environment_immutable_location (const char *func, SCM env, SCM symbol) SCM scm_make_environment (void *type) { - SCM env; - - SCM_NEWCELL (env); - SCM_SET_CELL_WORD_1 (env, type); - SCM_SET_CELL_TYPE (env, scm_tc16_environment); - - return env; + return scm_alloc_cell (scm_tc16_environment, (scm_t_bits) type); } @@ -669,11 +663,10 @@ core_environments_observe (SCM env, scm_environment_observer proc, SCM data, int { SCM observer; - SCM_NEWCELL2 (observer); - SCM_SET_CELL_OBJECT_1 (observer, env); - SCM_SET_CELL_OBJECT_2 (observer, data); - SCM_SET_CELL_WORD_3 (observer, proc); - SCM_SET_CELL_TYPE (observer, scm_tc16_observer); + observer = scm_alloc_double_cell (scm_tc16_observer, + SCM_UNPACK (env), + SCM_UNPACK (data), + (scm_t_bits) proc); if (!weak_p) { diff --git a/libguile/eval.c b/libguile/eval.c index 73ac4eceb..126015e1c 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -3864,11 +3864,11 @@ scm_for_each (SCM proc, SCM arg1, SCM args) SCM scm_closure (SCM code, SCM env) { - register SCM z; - - SCM_NEWCELL (z); - SCM_SETCODE (z, code); - SCM_SETENV (z, env); + SCM z; + SCM closcar = scm_cons (code, SCM_EOL); + z = scm_alloc_cell (SCM_UNPACK (closcar) + scm_tc3_closure, + (scm_t_bits) env); + scm_remember_upto_here (closcar); return z; } @@ -3939,9 +3939,7 @@ SCM_DEFINE (scm_cons_source, "cons-source", 3, 0, 0, #define FUNC_NAME s_scm_cons_source { SCM p, z; - SCM_NEWCELL (z); - SCM_SET_CELL_OBJECT_0 (z, x); - SCM_SET_CELL_OBJECT_1 (z, y); + z = scm_cons (x, y); /* Copy source properties possibly associated with xorig. */ p = scm_whash_lookup (scm_source_whash, xorig); if (!SCM_IMP (p)) diff --git a/libguile/fports.c b/libguile/fports.c index 426db6f55..2ce9c4a0d 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -428,7 +428,7 @@ scm_fdes_to_port (int fdes, char *mode, SCM name) SCM_MISC_ERROR ("requested file mode not available on fdes", SCM_EOL); } - SCM_NEWCELL (port); + port = scm_alloc_cell (scm_tc16_fport, 0); SCM_DEFER_INTS; pt = scm_add_to_port_table (port); SCM_SETPTAB_ENTRY (port, pt); diff --git a/libguile/gh_data.c b/libguile/gh_data.c index 0f503a950..116b523fc 100644 --- a/libguile/gh_data.c +++ b/libguile/gh_data.c @@ -149,13 +149,7 @@ gh_doubles2scm (const double *d, long n) static SCM makvect (char *m, size_t len, int type) { - SCM ans; - SCM_NEWCELL (ans); - SCM_DEFER_INTS; - SCM_SET_UVECTOR_BASE (ans, m); - SCM_SET_UVECTOR_LENGTH (ans, len, type); - SCM_ALLOW_INTS; - return ans; + return scm_alloc_cell (SCM_MAKE_UVECTOR_TAG (len, type), (scm_t_bits) m); } SCM diff --git a/libguile/goops.c b/libguile/goops.c index b813dad05..305f577b3 100644 --- a/libguile/goops.c +++ b/libguile/goops.c @@ -1301,20 +1301,15 @@ static void clear_method_cache (SCM); static SCM wrap_init (SCM class, SCM *m, long n) { - SCM z; long i; /* Set all slots to unbound */ for (i = 0; i < n; i++) m[i] = SCM_GOOPS_UNBOUND; - SCM_NEWCELL2 (z); - SCM_SET_STRUCT_GC_CHAIN (z, 0); - SCM_SET_CELL_WORD_1 (z, m); - SCM_SET_CELL_WORD_0 (z, (scm_t_bits) SCM_STRUCT_DATA (class) - | scm_tc3_struct); - - return z; + return scm_alloc_double_cell ((((scm_t_bits) SCM_STRUCT_DATA (class)) + | scm_tc3_struct), + (scm_t_bits) m, 0, 0); } SCM_DEFINE (scm_sys_allocate_instance, "%allocate-instance", 2, 0, 0, @@ -2589,12 +2584,9 @@ scm_add_slot (SCM class, char *slot_name, SCM slot_class, SCM scm_wrap_object (SCM class, void *data) { - SCM z; - SCM_NEWCELL2 (z); - SCM_SETCDR (z, SCM_PACK ((scm_t_bits) data)); - SCM_SET_STRUCT_GC_CHAIN (z, 0); - SCM_SETCAR (z, SCM_UNPACK (SCM_CDR (class)) | scm_tc3_struct); - return z; + return scm_alloc_double_cell (SCM_UNPACK (SCM_CDR (class)) | scm_tc3_struct, + (scm_t_bits) data, + 0, 0); } SCM scm_components; diff --git a/libguile/guardians.c b/libguile/guardians.c index ad9832539..d9eb5f003 100644 --- a/libguile/guardians.c +++ b/libguile/guardians.c @@ -248,8 +248,6 @@ scm_guard (SCM guardian, SCM obj, int throw_p) { SCM z; - SCM_NEWCELL (z); - /* This critical section barrier will be replaced by a mutex. */ SCM_DEFER_INTS; @@ -272,6 +270,7 @@ scm_guard (SCM guardian, SCM obj, int throw_p) obj, guardian); } + z = scm_cons (SCM_BOOL_F, SCM_BOOL_F); TCONC_IN (g->live, obj, z); SCM_ALLOW_INTS; diff --git a/libguile/lang.c b/libguile/lang.c index b5791fbbf..f022bee77 100644 --- a/libguile/lang.c +++ b/libguile/lang.c @@ -69,11 +69,7 @@ SCM_DEFINE (scm_nil_cons, "nil-cons", 2, 0, 0, "a LISP nil.") #define FUNC_NAME s_scm_nil_cons { - register SCM z; - SCM_NEWCELL (z); - SCM_SETCAR (z, x); - SCM_SETCDR (z, SCM_NIL2EOL (y, y)); - return z; + return scm_cons (x, SCM_NIL2EOL (y, y)); } #undef FUNC_NAME diff --git a/libguile/list.c b/libguile/list.c index b709b882d..8d6237d20 100644 --- a/libguile/list.c +++ b/libguile/list.c @@ -60,9 +60,7 @@ #define SCM_I_CONS(cell,x,y) \ do { \ - SCM_NEWCELL (cell); \ - SCM_SET_CELL_OBJECT_1 (cell, y); \ - SCM_SET_CELL_OBJECT_0 (cell, x); \ + cell = scm_alloc_cell ((scm_t_bits)x, (scm_t_bits)y); \ } while (0) SCM diff --git a/libguile/num2float.i.c b/libguile/num2float.i.c index 22efffb1d..a3e669266 100644 --- a/libguile/num2float.i.c +++ b/libguile/num2float.i.c @@ -32,8 +32,7 @@ SCM FLOAT2NUM (FTYPE n) { SCM z; - SCM_NEWCELL2 (z); - SCM_SET_CELL_TYPE (z, scm_tc16_real); + z = scm_alloc_double_cell (scm_tc16_real, 0, 0, 0); SCM_REAL_VALUE (z) = n; return z; } diff --git a/libguile/numbers.c b/libguile/numbers.c index f0d23a138..daf8d5da7 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -1390,9 +1390,7 @@ scm_i_mkbig (size_t nlen, int sign) base = scm_must_malloc (nlen * sizeof (SCM_BIGDIG), s_bignum); - SCM_NEWCELL (v); - SCM_SET_BIGNUM_BASE (v, base); - SCM_SETNUMDIGS (v, nlen, sign); + v = scm_alloc_cell (SCM_MAKE_BIGNUM_TAG (nlen, sign), (scm_t_bits) base); return v; } @@ -2829,8 +2827,7 @@ SCM scm_make_real (double x) { SCM z; - SCM_NEWCELL2 (z); - SCM_SET_CELL_TYPE (z, scm_tc16_real); + z = scm_alloc_double_cell (scm_tc16_real, 0, 0, 0); SCM_REAL_VALUE (z) = x; return z; } diff --git a/libguile/pairs.c b/libguile/pairs.c index 88ce017c4..5216de8bb 100644 --- a/libguile/pairs.c +++ b/libguile/pairs.c @@ -80,11 +80,7 @@ SCM_DEFINE (scm_cons, "cons", 2, 0, 0, "sense of @code{eq?}) from every previously existing object.") #define FUNC_NAME s_scm_cons { - SCM z; - SCM_NEWCELL (z); - SCM_SET_CELL_OBJECT_0 (z, x); - SCM_SET_CELL_OBJECT_1 (z, y); - return z; + return scm_alloc_cell (SCM_UNPACK (x), SCM_UNPACK (y)); } #undef FUNC_NAME @@ -92,18 +88,7 @@ SCM_DEFINE (scm_cons, "cons", 2, 0, 0, SCM scm_cons2 (SCM w, SCM x, SCM y) { - SCM z1; - SCM z2; - - SCM_NEWCELL (z1); - SCM_SET_CELL_OBJECT_0 (z1, x); - SCM_SET_CELL_OBJECT_1 (z1, y); - - SCM_NEWCELL (z2); - SCM_SET_CELL_OBJECT_0 (z2, w); - SCM_SET_CELL_OBJECT_1 (z2, z1); - - return z2; + return scm_cons (w, scm_cons (x, y)); } diff --git a/libguile/ports.c b/libguile/ports.c index 6e79e9ab7..efeb4cf46 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -1527,7 +1527,7 @@ scm_void_port (char *mode_str) SCM answer; scm_t_port * pt; - SCM_NEWCELL (answer); + answer = scm_alloc_cell (scm_tc16_void_port, 0); SCM_DEFER_INTS; mode_bits = scm_mode_bits (mode_str); pt = scm_add_to_port_table (answer); diff --git a/libguile/print.c b/libguile/print.c index 3e7849314..64bd23e89 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -249,10 +249,8 @@ scm_free_print_state (SCM print_state) */ pstate->fancyp = 0; pstate->revealed = 0; - SCM_NEWCELL (handle); SCM_DEFER_INTS; - SCM_SET_CELL_WORD_0 (handle, print_state); - SCM_SET_CELL_WORD_1 (handle, print_state_pool); + handle = scm_cons (print_state, print_state_pool); print_state_pool = handle; SCM_ALLOW_INTS; } diff --git a/libguile/procs.c b/libguile/procs.c index 6f3dca63a..c53e532e2 100644 --- a/libguile/procs.c +++ b/libguile/procs.c @@ -86,16 +86,12 @@ scm_c_make_subr (const char *name, long type, SCM (*fcn) ()) scm_subr_table_room = new_size; } - SCM_NEWCELL (z); - entry = scm_subr_table_size; + z = scm_alloc_cell ((entry << 8) + type, (scm_t_bits) fcn); scm_subr_table[entry].handle = z; scm_subr_table[entry].name = scm_str2symbol (name); scm_subr_table[entry].generic = 0; scm_subr_table[entry].properties = SCM_EOL; - - SCM_SET_SUBRF (z, fcn); - SCM_SET_CELL_TYPE (z, (entry << 8) + type); scm_subr_table_size++; return z; @@ -165,12 +161,8 @@ scm_makcclo (SCM proc, size_t len) for (i = 0; i < len; ++i) base [i] = SCM_UNPACK (SCM_UNSPECIFIED); - SCM_NEWCELL (s); - SCM_DEFER_INTS; - SCM_SET_CCLO_BASE (s, base); - SCM_SET_CCLO_LENGTH (s, len); + s = scm_alloc_cell (SCM_MAKE_CCLO_TAG (len), (scm_t_bits) base); SCM_SET_CCLO_SUBR (s, proc); - SCM_ALLOW_INTS; return s; } @@ -327,16 +319,11 @@ SCM_DEFINE (scm_make_procedure_with_setter, "make-procedure-with-setter", 2, 0, "with the associated setter @var{setter}.") #define FUNC_NAME s_scm_make_procedure_with_setter { - SCM z; SCM_VALIDATE_PROC (1, procedure); SCM_VALIDATE_PROC (2, setter); - SCM_NEWCELL2 (z); - SCM_ENTER_A_SECTION; - SCM_SET_CELL_OBJECT_1 (z, procedure); - SCM_SET_CELL_OBJECT_2 (z, setter); - SCM_SET_CELL_TYPE (z, scm_tc7_pws); - SCM_EXIT_A_SECTION; - return z; + return scm_alloc_double_cell (scm_tc7_pws, + SCM_UNPACK (procedure), + SCM_UNPACK (setter), 0); } #undef FUNC_NAME diff --git a/libguile/smob.c b/libguile/smob.c index b4935ba81..788e6a8fd 100644 --- a/libguile/smob.c +++ b/libguile/smob.c @@ -456,23 +456,10 @@ scm_make_smob (scm_t_bits tc) { long n = SCM_TC2SMOBNUM (tc); size_t size = scm_smobs[n].size; - SCM z; - SCM_NEWCELL (z); - if (size != 0) - { -#if 0 - if (scm_smobs[n].mark != 0) - { - fprintf - (stderr, - "forbidden operation for smobs with GC data, use SCM_NEWSMOB\n"); - abort (); - } -#endif - SCM_SET_SMOB_DATA (z, scm_must_malloc (size, SCM_SMOBNAME (n))); - } - SCM_SET_CELL_TYPE (z, tc); - return z; + scm_t_bits data = (size > 0 + ? (scm_t_bits) scm_must_malloc (size, SCM_SMOBNAME (n)) + : 0); + return scm_alloc_cell (tc, data); } diff --git a/libguile/smob.h b/libguile/smob.h index e804a60dc..be87b255e 100644 --- a/libguile/smob.h +++ b/libguile/smob.h @@ -72,9 +72,7 @@ typedef struct scm_smob_descriptor #define SCM_NEWSMOB(z, tc, data) \ do { \ - SCM_NEWCELL (z); \ - SCM_SET_CELL_WORD_1 ((z), (data)); \ - SCM_SET_CELL_TYPE ((z), (tc)); \ + z = scm_alloc_cell ((tc), (scm_t_bits) (data)); \ } while (0) #define SCM_RETURN_NEWSMOB(tc, data) \ @@ -85,10 +83,8 @@ do { \ #define SCM_NEWSMOB2(z, tc, data1, data2) \ do { \ - SCM_NEWCELL2 (z); \ - SCM_SET_CELL_WORD_1 ((z), (data1)); \ - SCM_SET_CELL_WORD_2 ((z), (data2)); \ - SCM_SET_CELL_TYPE ((z), (tc)); \ + z = scm_alloc_double_cell ((tc), (scm_t_bits)(data1), \ + (scm_t_bits)(data2), 0); \ } while (0) #define SCM_RETURN_NEWSMOB2(tc, data1, data2) \ @@ -99,11 +95,8 @@ do { \ #define SCM_NEWSMOB3(z, tc, data1, data2, data3) \ do { \ - SCM_NEWCELL2 (z); \ - SCM_SET_CELL_WORD_1 ((z), (data1)); \ - SCM_SET_CELL_WORD_2 ((z), (data2)); \ - SCM_SET_CELL_WORD_3 ((z), (data3)); \ - SCM_SET_CELL_TYPE ((z), (tc)); \ + z = scm_alloc_double_cell ((tc), (scm_t_bits)(data1), \ + (scm_t_bits)(data2), (scm_t_bits)(data3)); \ } while (0) #define SCM_RETURN_NEWSMOB3(tc, data1, data2, data3) \ diff --git a/libguile/strings.c b/libguile/strings.c index 8bd7de872..680707261 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -132,9 +132,7 @@ scm_take_str (char *s, size_t len) SCM_ASSERT_RANGE (2, scm_ulong2num (len), len <= SCM_STRING_MAX_LENGTH); - SCM_NEWCELL (answer); - SCM_SET_STRING_CHARS (answer, s); - SCM_SET_STRING_LENGTH (answer, len); + answer = scm_alloc_cell (SCM_MAKE_STRING_TAG (len), (scm_t_bits) s); scm_done_malloc (len + 1); return answer; @@ -196,9 +194,7 @@ scm_allocate_string (size_t len) mem = (char *) scm_must_malloc (len + 1, FUNC_NAME); mem[len] = 0; - SCM_NEWCELL (s); - SCM_SET_STRING_CHARS (s, mem); - SCM_SET_STRING_LENGTH (s, len); + s = scm_alloc_cell (SCM_MAKE_STRING_TAG (len), (scm_t_bits) mem); return s; } diff --git a/libguile/strports.c b/libguile/strports.c index 612d98b27..daf68b5f3 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -279,7 +279,7 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller) scm_out_of_range (caller, pos); if (!((modes & SCM_WRTNG) || (modes & SCM_RDNG))) scm_misc_error ("scm_mkstrport", "port must read or write", SCM_EOL); - SCM_NEWCELL (z); + z = scm_alloc_cell (scm_tc16_strport, 0); SCM_DEFER_INTS; pt = scm_add_to_port_table (z); SCM_SET_CELL_TYPE (z, scm_tc16_strport | modes); diff --git a/libguile/struct.c b/libguile/struct.c index 9a580cb41..9d75e43f0 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -450,7 +450,6 @@ SCM_DEFINE (scm_make_struct, "make-struct", 2, 0, 1, layout = SCM_PACK (SCM_STRUCT_DATA (vtable) [scm_vtable_index_layout]); basic_size = SCM_SYMBOL_LENGTH (layout) / 2; tail_elts = SCM_INUM (tail_array_size); - SCM_NEWCELL2 (handle); SCM_DEFER_INTS; if (SCM_STRUCT_DATA (vtable)[scm_struct_i_flags] & SCM_STRUCTF_ENTITY) { @@ -464,11 +463,10 @@ SCM_DEFINE (scm_make_struct, "make-struct", 2, 0, 1, data = scm_alloc_struct (basic_size + tail_elts, scm_struct_n_extra_words, "make-struct"); - SCM_SET_CELL_WORD_1 (handle, data); - SCM_SET_STRUCT_GC_CHAIN (handle, 0); + handle = scm_alloc_double_cell ((((scm_t_bits) SCM_STRUCT_DATA (vtable)) + + scm_tc3_struct), + (scm_t_bits) data, 0, 0); scm_struct_init (handle, layout, data, tail_elts, init); - SCM_SET_CELL_WORD_0 (handle, - (scm_t_bits) SCM_STRUCT_DATA (vtable) + scm_tc3_struct); SCM_ALLOW_INTS; return handle; } @@ -540,16 +538,14 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1, layout = scm_make_struct_layout (fields); basic_size = SCM_SYMBOL_LENGTH (layout) / 2; tail_elts = SCM_INUM (tail_array_size); - SCM_NEWCELL2 (handle); SCM_DEFER_INTS; data = scm_alloc_struct (basic_size + tail_elts, scm_struct_n_extra_words, "make-vtable-vtable"); - SCM_SET_CELL_WORD_1 (handle, data); - SCM_SET_STRUCT_GC_CHAIN (handle, 0); + handle = scm_alloc_double_cell ((scm_t_bits) data + scm_tc3_struct, + (scm_t_bits) data, 0, 0); data [scm_vtable_index_layout] = SCM_UNPACK (layout); scm_struct_init (handle, layout, data, tail_elts, scm_cons (layout, init)); - SCM_SET_CELL_WORD_0 (handle, (scm_t_bits) data + scm_tc3_struct); SCM_ALLOW_INTS; return handle; } diff --git a/libguile/symbols.c b/libguile/symbols.c index f833eb2be..0a408234b 100644 --- a/libguile/symbols.c +++ b/libguile/symbols.c @@ -125,11 +125,11 @@ scm_mem2symbol (const char *name, size_t len) SCM cell; SCM slot; - SCM_NEWCELL2 (symbol); - SCM_SET_SYMBOL_CHARS (symbol, scm_must_strndup (name, len)); - SCM_SET_SYMBOL_HASH (symbol, raw_hash); - SCM_SET_PROP_SLOTS (symbol, scm_cons (SCM_BOOL_F, SCM_EOL)); - SCM_SET_SYMBOL_LENGTH (symbol, (long) len); + symbol = scm_alloc_double_cell (SCM_MAKE_SYMBOL_TAG (len), + (scm_t_bits) scm_must_strndup (name, len), + raw_hash, + SCM_UNPACK (scm_cons (SCM_BOOL_F, + SCM_EOL))); slot = SCM_VELTS (symbols) [hash]; cell = scm_cons (symbol, SCM_UNDEFINED); diff --git a/libguile/unif.c b/libguile/unif.c index 17470207e..94107db11 100644 --- a/libguile/unif.c +++ b/libguile/unif.c @@ -165,19 +165,16 @@ scm_make_uve (long k, SCM prot) if (SCM_EQ_P (prot, SCM_BOOL_T)) { - SCM_NEWCELL (v); if (k > 0) { - SCM_ASSERT_RANGE (1, scm_long2num (k), k <= SCM_BITVECTOR_MAX_LENGTH); + SCM_ASSERT_RANGE (1, + scm_long2num (k), k <= SCM_BITVECTOR_MAX_LENGTH); i = sizeof (long) * ((k + SCM_LONG_BIT - 1) / SCM_LONG_BIT); - SCM_SET_BITVECTOR_BASE (v, (char *) scm_must_malloc (i, "vector")); - SCM_SET_BITVECTOR_LENGTH (v, k); + v = scm_alloc_cell (SCM_MAKE_BITVECTOR_TAG (k), + (scm_t_bits) scm_must_malloc (i, "vector")); } else - { - SCM_SET_BITVECTOR_BASE (v, 0); - SCM_SET_BITVECTOR_LENGTH (v, 0); - } + v = scm_alloc_cell (SCM_MAKE_BITVECTOR_TAG (0), 0); return v; } else if (SCM_CHARP (prot) && (SCM_CHAR (prot) == '\0')) @@ -242,12 +239,8 @@ scm_make_uve (long k, SCM prot) SCM_ASSERT_RANGE (1, scm_long2num (k), k <= SCM_UVECTOR_MAX_LENGTH); - SCM_NEWCELL (v); - SCM_DEFER_INTS; - SCM_SET_UVECTOR_BASE (v, (char *) scm_must_malloc (i ? i : 1, "vector")); - SCM_SET_UVECTOR_LENGTH (v, k, type); - SCM_ALLOW_INTS; - return v; + return scm_alloc_cell (SCM_MAKE_UVECTOR_TAG (k, type), + (scm_t_bits) scm_must_malloc (i ? i : 1, "vector")); } #undef FUNC_NAME @@ -525,7 +518,6 @@ SCM scm_make_ra (int ndim) { SCM ra; - SCM_NEWCELL (ra); SCM_DEFER_INTS; SCM_NEWSMOB(ra, ((scm_t_bits) ndim << 17) + scm_tc16_array, scm_must_malloc ((sizeof (scm_t_array) + diff --git a/libguile/variable.c b/libguile/variable.c index b0e9b61d9..66f82b9de 100644 --- a/libguile/variable.c +++ b/libguile/variable.c @@ -68,12 +68,7 @@ scm_i_variable_print (SCM exp, SCM port, scm_print_state *pstate) static SCM make_variable (SCM init) { - SCM z; - SCM_NEWCELL (z); - SCM_SET_CELL_WORD_1 (z, SCM_UNPACK (init)); - SCM_SET_CELL_TYPE (z, scm_tc7_variable); - scm_remember_upto_here_1 (init); - return z; + return scm_alloc_cell (scm_tc7_variable, SCM_UNPACK (init)); } SCM_DEFINE (scm_make_variable, "make-variable", 1, 0, 0, diff --git a/libguile/vectors.c b/libguile/vectors.c index 425eee58a..db9c18669 100644 --- a/libguile/vectors.c +++ b/libguile/vectors.c @@ -214,9 +214,8 @@ scm_c_make_vector (unsigned long int k, SCM fill) else base = NULL; - SCM_NEWCELL (v); - SCM_SET_VECTOR_BASE (v, base); - SCM_SET_VECTOR_LENGTH (v, k, scm_tc7_vector); + v = scm_alloc_cell (SCM_MAKE_VECTOR_TAG (k, scm_tc7_vector), + (scm_t_bits) base); scm_remember_upto_here_1 (fill); return v; diff --git a/libguile/vports.c b/libguile/vports.c index bce6bb867..c25bc204f 100644 --- a/libguile/vports.c +++ b/libguile/vports.c @@ -189,7 +189,7 @@ SCM_DEFINE (scm_make_soft_port, "make-soft-port", 2, 0, 0, SCM z; SCM_VALIDATE_VECTOR_LEN (1,pv,5); SCM_VALIDATE_STRING (2, modes); - SCM_NEWCELL (z); + z = scm_alloc_cell (scm_tc16_sfport, 0); SCM_DEFER_INTS; pt = scm_add_to_port_table (z); scm_port_non_buffer (pt); diff --git a/libguile/weaks.c b/libguile/weaks.c index 74ce39703..277b102b3 100644 --- a/libguile/weaks.c +++ b/libguile/weaks.c @@ -71,10 +71,6 @@ allocate_weak_vector (scm_t_bits type, SCM size, SCM fill, const char* caller) SCM_ASSERT_RANGE (1, size, SCM_INUM (size) >= 0); c_size = SCM_INUM (size); - SCM_NEWCELL2 (v); - SCM_SET_WVECT_GC_CHAIN (v, SCM_EOL); - SCM_SET_WVECT_TYPE (v, type); - if (c_size > 0) { scm_t_bits *base; @@ -87,14 +83,20 @@ allocate_weak_vector (scm_t_bits type, SCM size, SCM fill, const char* caller) base = scm_must_malloc (c_size * sizeof (scm_t_bits), FUNC_NAME); for (j = 0; j != c_size; ++j) base[j] = SCM_UNPACK (fill); - SCM_SET_VECTOR_BASE (v, base); - SCM_SET_VECTOR_LENGTH (v, c_size, scm_tc7_wvect); + v = scm_alloc_double_cell (SCM_MAKE_VECTOR_TAG (c_size, + scm_tc7_wvect), + (scm_t_bits) base, + type, + SCM_UNPACK (SCM_EOL)); scm_remember_upto_here_1 (fill); } else { - SCM_SET_VECTOR_BASE (v, NULL); - SCM_SET_VECTOR_LENGTH (v, 0, scm_tc7_wvect); + v = scm_alloc_double_cell (SCM_MAKE_VECTOR_TAG (0, + scm_tc7_wvect), + (scm_t_bits) NULL, + type, + SCM_UNPACK (SCM_EOL)); } return v; From 4878beecf90c748edf919a88c52dd8ca115214db Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 15:24:07 +0000 Subject: [PATCH 233/281] *** empty log message *** --- libguile/ChangeLog | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 25faa5506..e06cd4a8d 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,54 @@ +2001-11-25 Marius Vollmer + + * vectors.h (SCM_MAKE_VECTOR_TAG): New. + * unif.h (SCM_MAKE_BITVECTOR_TAG, SCM_MAKE_UVECTOR_TAG): New. + * symbols.h (SCM_MAKE_SYMBOL_TAG): New. + * strings.h (SCM_MAKE_STRING_TAG): New. + * procs.h (SCM_MAKE_CCLO_TAG): New. + * numbers.h (SCM_MAKE_BIGNUM_TAG): New. + + * goops.h: Replaced SCM_DEBUG_DEPRECATED with + !SCM_ENABLE_DEPRECATED. + + * async.c, async.h (scm_system_async_mark_from_signal_handler): + New. + + * scmsigs.c (scm_take_signal): Removed all code that assumes that + signal handlers are allowed to divert the flow of control. Call + scm_system_async_mark_from_signal_handler instead of + scm_system_async_mark. + + + Deprecated SCM_NEWCELL and SCM_NEWCELL2. Added scm_alloc_cell and + scm_alloc_double_cell in their place. + + * gc.h (SCM_GC_SET_ALLOCATED, scm_debug_newcell, + scm_debug_newcell2, scm_tc16_allocated): Removed from header. + (scm_deprecated_newcell, scm_deprecated_newcell2): New. + (SCM_NEWCELL, SCM_NEWCELL2): Implement in terms of + scm_deprecated_newcell and scm_deprecated_newcell2. + + gc.c (scm_tc16_allocated): Only define when including deprecated + features. + (scm_debug_newcell, scm_debug_newcell2): Removed. + (scm_init_storage): Do not initialize scm_tc16_allocated. + (scm_init_gc): Do it here. + (allocated_mark): New, from old code. + (scm_deprecated_newcell, scm_deprecated_newcell2): New. + + * inline.c, inline.h: New files. + * Makefile.am: Added them in all the right places. + + * _scm.h: Include "libguile/inline.h". + + * alist.c, coop-threads.c, debug.c, environments.c, eval.c, + fports.c, gh_data.c, goops.c, guardians.c, lang.c, list.c, + num2float.i.c, numbers.c, pairs.c, ports.c, print.c, procs.c, + smob.c, smob.h, strings.c, strports.c, struct.c, symbols.c, + unif.c, variable.c, vectors.c, vports.c, weaks.c: Replaced + SCM_NEWCELL and SCM_NEWCELL2 with scm_alloc_cell and + scm_alloc_double_cell, respectively. + 2001-11-23 Marius Vollmer * modules.c (scm_c_use_module): Adapt to changes to From a9930d22bebc9febd6804b7d7a7cb5c912cae25a Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 25 Nov 2001 19:08:28 +0000 Subject: [PATCH 234/281] Updated for SCM_NEWCELL(2) deprecation. --- NEWS | 8 ++++++++ TODO | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 1c21cf408..c881afff6 100644 --- a/NEWS +++ b/NEWS @@ -57,6 +57,14 @@ linking to the Guile DLL in Windows. There are also SCM_RL_IMPORT, QT_IMPORT, SCM_SRFI1314_IMPORT, and SCM_SRFI4_IMPORT, for the corresponding libraries. +** SCM_NEWCELL and SCM_NEWCELL2 have been deprecated. + +Use the new functions scm_alloc_cell and scm_alloc_double_cell +instead. The old macros had problems because with them allocation and +initialization was separated and the GC could sometimes observe half +initialized cells. Only careful coding by the user of SCM_NEWCELL and +SCM_NEWCELL2 could make this safe and efficient. + Changes since Guile 1.4: * Changes to the distribution diff --git a/TODO b/TODO index e08549346..07c4478f3 100644 --- a/TODO +++ b/TODO @@ -99,5 +99,9 @@ that user-visible changes are reflected in NEWS. - in boot-9.scm: remove deprecated function `feature?´. +- gc.c and gc.h: + remove deprecated macros SCM_NEWCELL and SCM_NEWCELL2 together with + their support staffing scm_deprecated_newcell, + scm_deprecated_newcell2, scm_tc16_allocated, mark_allocated. [TODO ends here] From 5f378d170c8aed064b61247c16c06a1c9dd865fe Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 25 Nov 2001 20:53:19 +0000 Subject: [PATCH 235/281] Fix spelling. Reword `getpass' intro blurb. --- doc/ref/posix.texi | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index e2fd65873..930e960d7 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -16,7 +16,7 @@ * Networking:: gethostbyaddr, getnetent, socket, bind, listen. * System Identification:: Obtaining information about the system. * Locales:: setlocale, etc. -* Encryption:: +* Encryption:: @end menu @node Conventions @@ -1683,8 +1683,8 @@ close a pipe, but doesn't return the status. @menu * Network Address Conversion:: -* Network Databases:: -* Network Sockets and Communication:: +* Network Databases:: +* Network Sockets and Communication:: @end menu @node Network Address Conversion @@ -2474,9 +2474,8 @@ Encrypt @var{key} using @var{salt} as the salt value to the crypt(3) library call. @end deffn -@code{getpass} is no encryption procedure at all, but it is often used -in compination with @code{crypt}, that is why it appears in this -section. +Although @code{getpass} is not an encryption procedure per se, it +appears here because it is often used in combination with @code{crypt}: @deffn {Scheme Procedure} getpass prompt @deffnx {C Function} scm_getpass (prompt) From 5f7dd1ca5b99e7995b9457ee6326d55c671a104f Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 25 Nov 2001 20:56:59 +0000 Subject: [PATCH 236/281] *** empty log message *** --- doc/ref/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 0570a1cae..f4f9d0167 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-11-25 Thien-Thi Nguyen + + * posix.texi: Fix spelling. Thanks to Chris Cramer. + Reword `getpass' intro blurb. + 2001-11-23 Neil Jerram * program.texi (Program Control): Remove spurious placeholder From 28d9cc1d82a4a47aa361542a274940b4a0d8b112 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 27 Nov 2001 22:36:10 +0000 Subject: [PATCH 237/281] Some new ideas. --- devel/memory.text | 59 +++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/devel/memory.text b/devel/memory.text index ea08a0551..50d5a6b6a 100644 --- a/devel/memory.text +++ b/devel/memory.text @@ -57,61 +57,71 @@ everybody else to systematically review their code. - in their place, we have - Function: void *scm_malloc (size_t size, const char *what); + Function: void *scm_malloc (size_t size); Allocate SIZE bytes of memory. When not enough memory is available, signal an error. This function runs the GC to free up some memory when it deems it appropriate. - The WHAT argument is used for statistical purposes and for - error reporting. It should describe the type of object that - the memory will be used for so that users can identify just - what strange objects are eating up their memory. + The memory is allocated by the libc "malloc" function and can + be freed with "free". We do not introduce a `scm_free' + function to go with scm_malloc to make it easier to pass + memory back and forth between different modules. [ Note: this function will not consider the memory block to be under GC control. ] - Function: void scm_free (void *mem); - - Free the memory at MEM. MEM must have been returned by - scm_malloc. MEM might be NULL in which case nothing happens. - Function: void *scm_realloc (void *mem, size_t newsize); Change the size of the memory block at MEM to NEWSIZE. A new pointer is returned. When NEWSIZE is 0 this is the same as - calling scm_free on MEM and NULL is returned. MEM must be - non-NULL, that is, the first allocation must be done with - scm_malloc, to allow specifying the WHAT value. + calling scm_free on MEM and NULL is returned. When MEM is + NULL, this function behaves like scm_malloc and allocates a + new block of size SIZE. + + When not enough memory is available, signal an error. This + function runs the GC to free up some memory when it deems it + appropriate. Function: void scm_gc_register_collectable_memory (void *mem, size_t size, const char *what); Informs the GC that the memory at MEM of size SIZE can - potentially be freed during a GC. That is, MEM is part of a - GC controlled object and when the GC happens to free that - object, SIZE bytes will be freed along with it. The GC will - _not_ free the memory itself, it will just know that so-and-so - much bytes of memory are associated with GC controlled objects - and the memory system figures this into its decisions when to - run a GC. + potentially be freed during a GC. That is, announce that MEM + is part of a GC controlled object and when the GC happens to + free that object, SIZE bytes will be freed along with it. The + GC will _not_ free the memory itself, it will just know that + so-and-so much bytes of memory are associated with GC + controlled objects and the memory system figures this into its + decisions when to run a GC. MEM does not need to come from scm_malloc. You can only call this function once for every memory block. + The WHAT argument is used for statistical purposes. It should + describe the type of object that the memory will be used for + so that users can identify just what strange objects are + eating up their memory. + Function: void scm_gc_unregister_collectable_memory (void *mem, size_t size); Inform the GC that the memory at MEM of size SIZE is no longer - associated with a GC controlled object. + associated with a GC controlled object. You must take care to + match up every call to scm_gc_register_collectable_memory with + a call to scm_gc_unregister_collectable_memory. If you don't + do this, the GC might have a wrong impression of what is going + on and run much less efficiently than it could. Function: void *scm_gc_malloc (size_t size, const char *what); + Function: void *scm_gc_realloc (void *mem, size_t size, + const char *what); Like scm_malloc, but also call scm_gc_register_collectable_memory. Function: void scm_gc_free (void *mem, size_t size, const char *what); - Like scm_free, but also call scm_gc_unregister_collectable_memory. + Like free, but also call scm_gc_unregister_collectable_memory. Note that you need to explicitely pass the SIZE parameter. This is done since it should normally be easy to provide this @@ -126,6 +136,8 @@ The normal thing to use is scm_gc_malloc / scm_gc_free. Cell allocation and initialization ---------------------------------- +The following has been implemented in the unstable branch now. + It can happen that the GC is invoked during the code that initializes a cell. The half initialized cell is seen by the GC, which would normally cause it to crash. To prevent this, the initialization code @@ -193,6 +205,3 @@ In the transition period, while SCM_NEWCELL is deprecated, we can make it always initialize the first slot with scm_tc16_allocated. Such cells are marked conservatively by the GC. SCM_NEWCELL can have abysmal performance while being deprecated. - -Update: SCM_NEWCELL already behaves like this. We only need to -implement scm_newcell_init and replace uses of SCM_NEWCELL with it. From 4dd9ecedf7c033d5ac4770862056a84fcc98e4cf Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 27 Nov 2001 22:36:21 +0000 Subject: [PATCH 238/281] (string-index, list-head): Removed, we already these in the core. --- ice-9/format.scm | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/ice-9/format.scm b/ice-9/format.scm index 5de6ea9f2..6b2313ae8 100644 --- a/ice-9/format.scm +++ b/ice-9/format.scm @@ -1670,17 +1670,6 @@ ;;; some global functions not found in SLIB -;; string-index finds the index of the first occurence of the character `c' -;; in the string `s'; it returns #f if there is no such character in `s'. - -(define (string-index s c) - (let ((slen-1 (- (string-length s) 1))) - (let loop ((i 0)) - (cond - ((char=? c (string-ref s i)) i) - ((= i slen-1) #f) - (else (loop (+ i 1))))))) - (define (string-capitalize-first str) ; "hello" -> "Hello" (let ((cap-str (string-copy str)) ; "hELLO" -> "Hello" (non-first-alpha #f) ; "*hello" -> "*Hello" @@ -1695,12 +1684,6 @@ (set! non-first-alpha #t) (string-set! cap-str i (char-upcase c))))))))) -(define (list-head l k) - (if (= k 0) - '() - (cons (car l) (list-head (cdr l) (- k 1))))) - - ;; Aborts the program when a formatting error occures. This is a null ;; argument closure to jump to the interpreters toplevel continuation. From ff0e175c1866311f9f8f03c721f0058b028a27c6 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 27 Nov 2001 22:36:31 +0000 Subject: [PATCH 239/281] *** empty log message *** --- ice-9/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index 72bb1f0ec..7c08c7472 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,8 @@ +2001-11-27 Marius Vollmer + + * format.scm (string-index, list-head): Removed, we already these + in the core. + 2001-11-06 Marius Vollmer * boot-9.scm (turn-on-debugging): New function, to be used by From 1fc8902f02cd68cb0560701e9a46c765c8892c71 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Tue, 27 Nov 2001 23:18:16 +0000 Subject: [PATCH 240/281] * gc.h (SCM_GC_CELL_WORD, SCM_GC_CELL_OBJECT, SCM_GC_SET_CELL_WORD, SCM_GC_SET_CELL_OBJECT): New macros. (SCM_GC_CELL_TYPE, SCM_CELL_WORD, SCM_CELL_OBJECT, SCM_SET_CELL_WORD, SCM_SET_CELL_OBJECT, SCM_FREE_CELL_CDR, SCM_GC_SET_CELL_OBJECT): Express in terms of SCM_GC_CELL_* macros. (SCM_FREE_CELL_P): Express in terms of SCM_GC_CELL_TYPE. * inline.h (scm_alloc_cell, scm_alloc_double_cell): Use SCM_GC_CELL_* macros when accessing free cells. --- libguile/ChangeLog | 15 +++++++++++ libguile/gc.h | 65 +++++++++++++++++++++++++++------------------- libguile/inline.h | 12 ++++----- 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index e06cd4a8d..eb020f567 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,18 @@ +2001-11-28 Dirk Herrmann + + * gc.h (SCM_GC_CELL_WORD, SCM_GC_CELL_OBJECT, + SCM_GC_SET_CELL_WORD, SCM_GC_SET_CELL_OBJECT): New macros. + + (SCM_GC_CELL_TYPE, SCM_CELL_WORD, SCM_CELL_OBJECT, + SCM_SET_CELL_WORD, SCM_SET_CELL_OBJECT, SCM_FREE_CELL_CDR, + SCM_GC_SET_CELL_OBJECT): Express in terms of SCM_GC_CELL_* + macros. + + (SCM_FREE_CELL_P): Express in terms of SCM_GC_CELL_TYPE. + + * inline.h (scm_alloc_cell, scm_alloc_double_cell): Use + SCM_GC_CELL_* macros when accessing free cells. + 2001-11-25 Marius Vollmer * vectors.h (SCM_MAKE_VECTOR_TAG): New. diff --git a/libguile/gc.h b/libguile/gc.h index e3f70519a..7cfc996f5 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -166,8 +166,30 @@ typedef unsigned long scm_t_c_bvec_limb; #define SCM_SETGCMARK(x) SCM_GC_CELL_SET_BIT (x) #define SCM_CLRGCMARK(x) SCM_GC_CELL_CLR_BIT (x) -/* Low level cell data accessing macros: - */ + +/* Low level cell data accessing macros. These macros should only be used + * from within code related to garbage collection issues, since they will + * never check the cells they are applied to - not even if guile is compiled + * in debug mode. In particular these macros will even work for free cells, + * which should never be encountered by user code. */ + +#define SCM_GC_CELL_WORD(x, n) \ + (((const scm_t_bits *) SCM2PTR (x)) [n]) +#define SCM_GC_CELL_OBJECT(x, n) \ + (SCM_PACK (((const scm_t_bits *) SCM2PTR (x)) [n])) +#define SCM_GC_SET_CELL_WORD(x, n, v) \ + (((scm_t_bits *) SCM2PTR (x)) [n] = (scm_t_bits) (v)) +#define SCM_GC_SET_CELL_OBJECT(x, n, v) \ + (((scm_t_bits *) SCM2PTR (x)) [n] = SCM_UNPACK (v)) +#define SCM_GC_CELL_TYPE(x) SCM_GC_CELL_WORD (x, 0) + + +/* Except for the garbage collector, no part of guile should ever run over a + * free cell. Thus, if guile is compiled in debug mode the SCM_CELL_* and + * SCM_SET_CELL_* macros below report an error if they are applied to a free + * cell. Some other plausibility checks are also performed. However, if + * guile is not compiled in debug mode, there won't be any time penalty at all + * when using these macros. */ #if (SCM_DEBUG_CELL_ACCESSES == 1) # define SCM_VALIDATE_CELL(cell, expr) (scm_assert_cell_valid (cell), (expr)) @@ -176,28 +198,28 @@ typedef unsigned long scm_t_c_bvec_limb; #endif #define SCM_CELL_WORD(x, n) \ - SCM_VALIDATE_CELL ((x), ((const scm_t_bits *) SCM2PTR (x)) [n]) + SCM_VALIDATE_CELL ((x), SCM_GC_CELL_WORD ((x), (n))) #define SCM_CELL_WORD_0(x) SCM_CELL_WORD (x, 0) #define SCM_CELL_WORD_1(x) SCM_CELL_WORD (x, 1) #define SCM_CELL_WORD_2(x) SCM_CELL_WORD (x, 2) #define SCM_CELL_WORD_3(x) SCM_CELL_WORD (x, 3) #define SCM_CELL_OBJECT(x, n) \ - SCM_VALIDATE_CELL ((x), SCM_PACK (((const scm_t_bits *) SCM2PTR (x)) [n])) + SCM_VALIDATE_CELL ((x), SCM_GC_CELL_OBJECT ((x), (n))) #define SCM_CELL_OBJECT_0(x) SCM_CELL_OBJECT (x, 0) #define SCM_CELL_OBJECT_1(x) SCM_CELL_OBJECT (x, 1) #define SCM_CELL_OBJECT_2(x) SCM_CELL_OBJECT (x, 2) #define SCM_CELL_OBJECT_3(x) SCM_CELL_OBJECT (x, 3) #define SCM_SET_CELL_WORD(x, n, v) \ - SCM_VALIDATE_CELL ((x), ((scm_t_bits *) SCM2PTR (x)) [n] = (scm_t_bits) (v)) + SCM_VALIDATE_CELL ((x), SCM_GC_SET_CELL_WORD ((x), (n), (v))) #define SCM_SET_CELL_WORD_0(x, v) SCM_SET_CELL_WORD (x, 0, v) #define SCM_SET_CELL_WORD_1(x, v) SCM_SET_CELL_WORD (x, 1, v) #define SCM_SET_CELL_WORD_2(x, v) SCM_SET_CELL_WORD (x, 2, v) #define SCM_SET_CELL_WORD_3(x, v) SCM_SET_CELL_WORD (x, 3, v) #define SCM_SET_CELL_OBJECT(x, n, v) \ - SCM_VALIDATE_CELL ((x), ((scm_t_bits *) SCM2PTR (x)) [n] = SCM_UNPACK (v)) + SCM_VALIDATE_CELL ((x), SCM_GC_SET_CELL_OBJECT ((x), (n), (v))) #define SCM_SET_CELL_OBJECT_0(x, v) SCM_SET_CELL_OBJECT (x, 0, v) #define SCM_SET_CELL_OBJECT_1(x, v) SCM_SET_CELL_OBJECT (x, 1, v) #define SCM_SET_CELL_OBJECT_2(x, v) SCM_SET_CELL_OBJECT (x, 2, v) @@ -207,14 +229,17 @@ typedef unsigned long scm_t_c_bvec_limb; #define SCM_SET_CELL_TYPE(x, t) SCM_SET_CELL_WORD_0 (x, t) -/* Except for the garbage collector, no part of guile should ever run over a - * free cell. Thus, in debug mode the above macros report an error if they - * are applied to a free cell. Since the garbage collector is allowed to - * access free cells, it needs its own way to access cells which will not - * result in errors when in debug mode. */ +/* Freelists consist of linked cells where the type entry holds the value + * scm_tc_free_cell and the second entry holds a pointer to the next cell of + * the freelist. Due to this structure, freelist cells are not cons cells + * and thus may not be accessed using SCM_CAR and SCM_CDR. */ -#define SCM_GC_CELL_TYPE(x) \ - (((const scm_t_bits *) SCM2PTR (x)) [0]) +#define SCM_FREE_CELL_P(x) \ + (!SCM_IMP (x) && (SCM_GC_CELL_TYPE (x) == scm_tc_free_cell)) +#define SCM_FREE_CELL_CDR(x) \ + (SCM_GC_CELL_OBJECT ((x), 1)) +#define SCM_SET_FREE_CELL_CDR(x, v) \ + (SCM_GC_SET_CELL_OBJECT ((x), 1, (v))) #define SCM_CELL_WORD_LOC(x, n) ((scm_t_bits *) & SCM_CELL_WORD (x, n)) @@ -231,20 +256,6 @@ typedef unsigned long scm_t_c_bvec_limb; #define SCM_PTR_GE(x, y) (!SCM_PTR_LT (x, y)) -/* Freelists consist of linked cells where the type entry holds the value - * scm_tc_free_cell and the second entry holds a pointer to the next cell of - * the freelist. Due to this structure, freelist cells are not cons cells - * and thus may not be accessed using SCM_CAR and SCM_CDR. - */ - -#define SCM_FREE_CELL_P(x) \ - (!SCM_IMP (x) && (* (const scm_t_bits *) SCM2PTR (x) == scm_tc_free_cell)) -#define SCM_FREE_CELL_CDR(x) \ - (SCM_PACK (((const scm_t_bits *) SCM2PTR (x)) [1])) -#define SCM_SET_FREE_CELL_CDR(x, v) \ - (((scm_t_bits *) SCM2PTR (x)) [1] = SCM_UNPACK (v)) - - #define SCM_MARKEDP SCM_GCMARKP #define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) diff --git a/libguile/inline.h b/libguile/inline.h index 926623bf0..9d3b6fca1 100644 --- a/libguile/inline.h +++ b/libguile/inline.h @@ -84,8 +84,8 @@ scm_alloc_cell (scm_t_bits car, scm_t_bits cdr) cooperating threads, but it might be important when we get true preemptive threads. */ - SCM_SET_CELL_WORD_1 (z, cdr); - SCM_SET_CELL_WORD_0 (z, car); + SCM_GC_SET_CELL_WORD (z, 1, cdr); + SCM_GC_SET_CELL_WORD (z, 0, car); #ifdef USE_THREADS #ifndef USE_COOP_THREADS @@ -132,10 +132,10 @@ scm_alloc_double_cell (scm_t_bits car, scm_t_bits cbr, cooperating threads, but it might be important when we get true preemptive threads. */ - SCM_SET_CELL_WORD_1 (z, cbr); - SCM_SET_CELL_WORD_2 (z, ccr); - SCM_SET_CELL_WORD_3 (z, cdr); - SCM_SET_CELL_WORD_0 (z, car); + SCM_GC_SET_CELL_WORD (z, 1, cbr); + SCM_GC_SET_CELL_WORD (z, 2, ccr); + SCM_GC_SET_CELL_WORD (z, 3, cdr); + SCM_GC_SET_CELL_WORD (z, 0, car); #ifdef USE_THREADS #ifndef USE_COOP_THREADS From f8e685d1b2b02f09da485c79b836fdb4ef0a862f Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Wed, 28 Nov 2001 12:43:22 +0000 Subject: [PATCH 241/281] * added extension directory and extension/dynamic-root.text with a description of the problem. --- devel/ChangeLog | 5 +++++ devel/README | 13 ------------- devel/extension/dynamic-root.text | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 devel/extension/dynamic-root.text diff --git a/devel/ChangeLog b/devel/ChangeLog index c4b074bce..6d6c09813 100644 --- a/devel/ChangeLog +++ b/devel/ChangeLog @@ -1,3 +1,8 @@ +2001-11-28 Gary Houston + + * added extension directory and extension/dynamic-root.text with + a description of the problem. + 2001-11-14 Thien-Thi Nguyen * policy/api.text: Initial revision. diff --git a/devel/README b/devel/README index 6fb2b4ca5..e69de29bb 100644 --- a/devel/README +++ b/devel/README @@ -1,13 +0,0 @@ -Directories: - -policy Guile policy documents - -build Build/installation process - -string Strings and characters - -translation Language traslation - -vm Virtual machines - -vm/ior Mikael's ideas on a new type of Scheme interpreter diff --git a/devel/extension/dynamic-root.text b/devel/extension/dynamic-root.text new file mode 100644 index 000000000..edf714f78 --- /dev/null +++ b/devel/extension/dynamic-root.text @@ -0,0 +1,28 @@ +The Problem +=========== + +Certain applications embedding Guile (Scwm, Guppi) have found it +necessary to include hacked versions of scm_call_with_dynamic_root. + +They want to run user callbacks, but don't want the callback to be +able to longjmp (via exceptions or continuations) randomly in and out, +since the C code hasn't been written to dynamically wind/unwind local +state. This is likely to be a common problem for users of Guile as an +extension language. + +libguile/root.c:scm_call_with_dynamic_root seems to almost do this, +but it has the apparently undesirable behaviour of unwinding the +dynamic state when the protected procedure is called. In addition +the implementation looks a bit heavy for use in every callback. + +scm_call_with_dynamic_root was implemented to support threading, so +the needs of libguile itself should be considered. Other +considerations are how any new interface interacts with error handling +and reporting; whether a new interface is convenient to use from C; +whether a new interface should also be available to Scheme code. + +Discussion +========== + +Proposal +======== From b0147aec0a977a229374a4d37694039748a659c9 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 29 Nov 2001 00:01:54 +0000 Subject: [PATCH 242/281] (write-punily): Handle symbols with ":" prefix specially. --- scripts/punify | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/scripts/punify b/scripts/punify index 699f3e2ff..eae8d51a7 100755 --- a/scripts/punify +++ b/scripts/punify @@ -34,8 +34,8 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ;; ;; Example: ;; $ wc ./punify ; ./punify ./punify | wc -;; 81 355 2622 ./punify -;; 0 34 694 +;; 89 384 3031 ./punify +;; 0 42 920 ;; ;; TODO: Read from stdin. ;; Handle vectors. @@ -47,21 +47,29 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" :export (punify)) (define (write-punily form) - (if (and (list? form) (not (null? form))) - (let ((first (car form))) - (display "(") - (write-punily first) - (let loop ((ls (cdr form)) (last-was-list? (list? first))) - (if (null? ls) - (display ")") - (let* ((new-first (car ls)) - (this-is-list? (list? new-first))) - (and (not last-was-list?) - (not this-is-list?) - (display " ")) - (write-punily new-first) - (loop (cdr ls) this-is-list?))))) - (write form))) + (cond ((and (list? form) (not (null? form))) + (let ((first (car form))) + (display "(") + (write-punily first) + (let loop ((ls (cdr form)) (last-was-list? (list? first))) + (if (null? ls) + (display ")") + (let* ((new-first (car ls)) + (this-is-list? (list? new-first))) + (and (not last-was-list?) + (not this-is-list?) + (display " ")) + (write-punily new-first) + (loop (cdr ls) this-is-list?)))))) + ((and (symbol? form) + (let ((ls (string->list (symbol->string form)))) + (and (char=? (car ls) #\:) + (not (memq #\space ls)) + (list->string (cdr ls))))) + => (lambda (symbol-name-after-colon) + (display #\:) + (display symbol-name-after-colon))) + (else (write form)))) (define (punify-one file) (with-input-from-file file From a56e05676fd300550de28d3e32bba49e292bfb59 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 29 Nov 2001 00:03:00 +0000 Subject: [PATCH 243/281] *** empty log message *** --- scripts/ChangeLog | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ChangeLog b/scripts/ChangeLog index 87be0b25a..952ac82e2 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2001-11-28 Thien-Thi Nguyen + + * punify (write-punily): Handle symbols w/ ":" prefix specially. + 2001-11-16 Neil Jerram * snarf-check-and-output-texi: Change generated @deffn categories @@ -10,7 +14,7 @@ index entries for each Guile primitive to the copy of the doc snarf output that is used for reference manual synchronization. Online help is unchanged. - + * snarf-check-and-output-texi (*manual-flag*, snarf-check-and-output-texi): Handle `--manual' invocation arg passed through from libguile/Makefile.am. @@ -21,7 +25,7 @@ (*primitive-deffnx-signature*, *primitive-deffnx-sig-length*): Fluff to help insert the C declaration after any "@deffnx primitive" lines in the snarfed docstring. - + 2001-10-05 Thien-Thi Nguyen * read-scheme-source (quoted?, clump): New procs, exported. From e0902d958d83131e1054a8dbf1fba2dbdd211d9a Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 29 Nov 2001 00:19:13 +0000 Subject: [PATCH 244/281] (ferret): New proc. (grok): Use `ferret'. --- scripts/use2dot | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/use2dot b/scripts/use2dot index 6f2901107..19091f2b6 100755 --- a/scripts/use2dot +++ b/scripts/use2dot @@ -97,7 +97,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (format #t " \"~A\" -> \"~A\"~A;\n" module use etc-spec)))) (define (header) - (format #t "digraph use2dot {") + (format #t "digraph use2dot {\n") (for-each (lambda (s) (format #t " ~A;\n" s)) (map vv `((label . ,(q "Guile Module Dependencies")) ;(rankdir . LR) @@ -106,6 +106,12 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ;(nodesep . ,(q "0.05")) )))) +(define (ferret use) ; handle "((foo bar) :select ...)" + (let ((maybe (car use))) + (if (list? maybe) + maybe + use))) + (define (grok filename) (let* ((p (open-file filename "r")) (next (lambda () (read p))) @@ -121,7 +127,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (or (null? ls) (case (car ls) ((:use-module) - (spew module (cadr ls)) + (spew module (ferret (cadr ls))) (loop (cddr ls))) ((:autoload) (spew module (cadr ls) @@ -133,7 +139,8 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (else (loop (cdr ls)))))))) ((use-modules) (for-each (lambda (use) - (spew (or curmod default-module) use)) + (spew (or curmod default-module) + (ferret use))) (cdr form))) ((load primitive-load) (spew (or curmod default-module) From 3fd8eb6743b10e3d0aa2cb31fee0df350e814729 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 29 Nov 2001 00:20:27 +0000 Subject: [PATCH 245/281] *** empty log message *** --- scripts/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/ChangeLog b/scripts/ChangeLog index 952ac82e2..50dd4d0fe 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -2,6 +2,9 @@ * punify (write-punily): Handle symbols w/ ":" prefix specially. + * use2dot (ferret): New proc. + (grok): Use `ferret'. + 2001-11-16 Neil Jerram * snarf-check-and-output-texi: Change generated @deffn categories From 2a946b44f4cbe8d08102fe98a5ee8262d4a0a1fb Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sat, 1 Dec 2001 15:53:04 +0000 Subject: [PATCH 246/281] * Improve symbol documentation. * Move variables doc into Modules chapter. * Move Rx doc into Guile Modules part. * Other minor doc changes. --- doc/ref/ChangeLog | 28 +++ doc/ref/Makefile.am | 2 + doc/ref/guile.texi | 40 ++- doc/ref/misc-modules.texi | 135 ++++++++++ doc/ref/scheme-data.texi | 486 ++++++++++-------------------------- doc/ref/scheme-modules.texi | 81 ++++++ 6 files changed, 399 insertions(+), 373 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index f4f9d0167..45392ab27 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,31 @@ +2001-12-01 Neil Jerram + + * scheme-data.texi (Variables): Node moved to modules chapter. + (Symbol Read Syntax): New node, with syntax-related material taken + from old Symbols node. + (Symbol Primitives): Renamed from `Symbols'. + (Symbols and Variables): Renamed to `Symbols'. + (Symbol Props): Renamed from `Symbol Tables'. + (Symbols): General review, improvements and additional material + throughout this section. + + * guile.texi: Updated Notes comment. + + * scheme-data.texi (Rx Interface): Node moved to Guile Modules + part, as the Rx interface is not core Guile. + +2001-11-30 Neil Jerram + + * scheme-data.texi (String Miscellanea): Removed, moving doc for + string-ci->symbol into the node on Symbols. + + * Makefile.am (ETAGS_ARGS): Added. + + * scheme-data.texi (Symbol Tables): Removed doc for gentemp, + intern-symbol, string->obarray-symbol, symbol-binding, + symbol-bound?, symbol-set!, unintern-symbol, symbol-interned?; all + of which no longer exist. + 2001-11-25 Thien-Thi Nguyen * posix.texi: Fix spelling. Thanks to Chris Cramer. diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index 5fbacd8a7..2f976f8bd 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -34,6 +34,8 @@ guile_TEXINFOS = preface.texi intro.texi program.texi scheme-intro.texi \ debugging.texi indices.texi script-getopt.texi data-rep.texi \ extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi +ETAGS_ARGS = $(info_TEXINFOS) $(guile_TEXINFOS) + # Optionally support building an HTML version of the reference manual. if HTMLDOC diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index fdd6df748..f49cdbc24 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -7,18 +7,30 @@ @set MANUAL_EDITION 1.1 @c %**end of header -@c Notes: (distilled from Jim's and Tim's notes, and kept up to date) +@c Notes @c -@c Remember to use "primitive" whereever appropriate. -@c FIXME: gotta change existing "subr" uses to "Primitive". -@c [JimB:] In my text for the Guile snarfer, I've used the term "subr" -@c to denote a C function made available to the Scheme world as a -@c function. This terminology is weird, but consistent with the -@c function names and also with Emacs Lisp, which I assume takes -@c Maclisp's lead. +@c We no longer use the category "primitive" to distinguish C-defined +@c Scheme procedures from those defined in Scheme. Instead, the +@c reference manual now includes a C declaration as well as a Scheme +@c declaration for each procedure that is available in both Scheme and +@c C. @c -@c When adding a new function to the Guile manual, please document -@c it with @deffn as one of `primitive', `procedure', or `syntax'. +@c When adding a new reference entry to the Guile manual, please +@c document it with @deffn using one of the following categories: +@c +@c {Scheme Procedure} +@c {Scheme Syntax} +@c {C Function} +@c {C Macro} +@c +@c If the entry is for a new primitive, it should have both a @deffn +@c {Scheme Procedure} line and a @deffnx {C Function} line; see the +@c manual source for plenty of existing examples of this. +@c +@c For {C Function} entries where the return type and all parameter +@c types are SCM, we omit the SCMs. This is easier to read and also +@c gets round the problem that Texinfo doesn't allow a @deftypefnx +@c inside a @deffn. @c @c For a list of Guile primitives that are not yet incorporated into the @c reference manual, see the file `new-docstrings.texi', which holds all @@ -26,8 +38,9 @@ @c that are not in the reference manual. If you have worked with some @c of these concepts, implemented them, or just happen to know what they @c do, please write up a little explanation -- it would be a big help. -@c Alternatively, if you know of a great reason why some of these should -@c *not* go in the manual, please let me know. +@c Alternatively, if you know of any reason why some of these should +@c *not* go in the manual, please let the mailing list +@c know. @c Define indices that are used in the Guile Scheme part of the @c reference manual to group stuff according to whether it is R5RS or a @@ -81,7 +94,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.6 2001-11-11 15:01:51 ossau Exp $ +@subtitle $Id: guile.texi,v 1.7 2001-12-01 15:53:04 ossau Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -237,6 +250,7 @@ Part IV: Guile Modules * Value History:: Maintaining a value history in the REPL. * Pretty Printing:: Nicely formatting Scheme objects for output. * Formatted Output:: The @code{format} procedure. +* Rx Regexps:: The Rx regular expression library. * Expect:: Controlling interactive programs with Guile. * The Scheme shell (scsh):: Using scsh interfaces in Guile. diff --git a/doc/ref/misc-modules.texi b/doc/ref/misc-modules.texi index be4f2ca46..552a28647 100644 --- a/doc/ref/misc-modules.texi +++ b/doc/ref/misc-modules.texi @@ -55,6 +55,7 @@ Guile's object types as the builtin procedures. This is particularly important for smobs, for which a write procedure can be defined and be used by @code{write}, but not by @code{pretty-print}. + @page @node Formatted Output @chapter Formatted Output @@ -286,6 +287,140 @@ large version of @code{format} by default, so that the start-up time of the interpreter is not unnecessarily increased. +@page +@node Rx Regexps +@chapter The Rx Regular Expression Library + +[FIXME: this is taken from Gary and Mark's quick summaries and should be +reviewed and expanded. Rx is pretty stable, so could already be done!] + +@cindex rx +@cindex finite automaton + +The @file{guile-lang-allover} package provides an interface to Tom +Lord's Rx library (currently only to POSIX regular expressions). Use of +the library requires a two step process: compile a regular expression +into an efficient structure, then use the structure in any number of +string comparisons. + +For example, given the regular expression @samp{abc.} (which matches any +string containing @samp{abc} followed by any single character): + +@smalllisp +guile> @kbd{(define r (regcomp "abc."))} +guile> @kbd{r} +# +guile> @kbd{(regexec r "abc")} +#f +guile> @kbd{(regexec r "abcd")} +#((0 . 4)) +guile> +@end smalllisp + +The definitions of @code{regcomp} and @code{regexec} are as follows: + +@deffn {Scheme Procedure} regcomp pattern [flags] +Compile the regular expression pattern using POSIX rules. Flags is +optional and should be specified using symbolic names: +@defvar REG_EXTENDED +use extended POSIX syntax +@end defvar +@defvar REG_ICASE +use case-insensitive matching +@end defvar +@defvar REG_NEWLINE +allow anchors to match after newline characters in the +string and prevents @code{.} or @code{[^...]} from matching newlines. +@end defvar + +The @code{logior} procedure can be used to combine multiple flags. +The default is to use +POSIX basic syntax, which makes @code{+} and @code{?} literals and @code{\+} +and @code{\?} +operators. Backslashes in @var{pattern} must be escaped if specified in a +literal string e.g., @code{"\\(a\\)\\?"}. +@end deffn + +@deffn {Scheme Procedure} regexec regex string [match-pick] [flags] +Match @var{string} against the compiled POSIX regular expression +@var{regex}. +@var{match-pick} and @var{flags} are optional. Possible flags (which can be +combined using the logior procedure) are: + +@defvar REG_NOTBOL +The beginning of line operator won't match the beginning of +@var{string} (presumably because it's not the beginning of a line) +@end defvar + +@defvar REG_NOTEOL +Similar to REG_NOTBOL, but prevents the end of line operator +from matching the end of @var{string}. +@end defvar + +If no match is possible, regexec returns #f. Otherwise @var{match-pick} +determines the return value: + +@code{#t} or unspecified: a newly-allocated vector is returned, +containing pairs with the indices of the matched part of @var{string} and any +substrings. + +@code{""}: a list is returned: the first element contains a nested list +with the matched part of @var{string} surrounded by the the unmatched parts. +Remaining elements are matched substrings (if any). All returned +substrings share memory with @var{string}. + +@code{#f}: regexec returns #t if a match is made, otherwise #f. + +vector: the supplied vector is returned, with the first element replaced +by a pair containing the indices of the matched portion of @var{string} and +further elements replaced by pairs containing the indices of matched +substrings (if any). + +list: a list will be returned, with each member of the list +specified by a code in the corresponding position of the supplied list: + +a number: the numbered matching substring (0 for the entire match). + +@code{#\<}: the beginning of @var{string} to the beginning of the part matched +by regex. + +@code{#\>}: the end of the matched part of @var{string} to the end of +@var{string}. + +@code{#\c}: the "final tag", which seems to be associated with the "cut +operator", which doesn't seem to be available through the posix +interface. + +e.g., @code{(list #\< 0 1 #\>)}. The returned substrings share memory with +@var{string}. +@end deffn + +Here are some other procedures that might be used when using regular +expressions: + +@deffn {Scheme Procedure} compiled-regexp? obj +Test whether obj is a compiled regular expression. +@end deffn + +@deffn {Scheme Procedure} regexp->dfa regex [flags] +@end deffn + +@deffn {Scheme Procedure} dfa-fork dfa +@end deffn + +@deffn {Scheme Procedure} reset-dfa! dfa +@end deffn + +@deffn {Scheme Procedure} dfa-final-tag dfa +@end deffn + +@deffn {Scheme Procedure} dfa-continuable? dfa +@end deffn + +@deffn {Scheme Procedure} advance-dfa! dfa string +@end deffn + + @c Local Variables: @c TeX-master: "guile.texi" @c End: diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 463233546..6ff70438b 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -47,7 +47,7 @@ sections of this manual that cover them. * Characters:: New character names. * Strings:: Special things about strings. * Regular Expressions:: Pattern matching and substitution. -* Symbols and Variables:: Manipulating the Scheme symbol table. +* Symbols:: Symbols. * Keywords:: Self-quoting, customizable display keywords. * Pairs:: Scheme's basic building block. * Lists:: Special list functions supported by Guile. @@ -1427,7 +1427,6 @@ called with string containing unusal characters. * String Searching:: Searching in strings. * Alphabetic Case Mapping:: Convert the alphabetic case of strings. * Appending Strings:: Appending strings to form a new string. -* String Miscellanea:: Miscellaneous string procedures. @end menu @node String Syntax @@ -1823,19 +1822,6 @@ concatenation of the given strings, @var{args}. @end deffn -@node String Miscellanea -@subsection String Miscellanea - -This section contains all remaining string procedures. - -@deffn {Scheme Procedure} string-ci->symbol str -@deffnx {C Function} scm_string_ci_to_symbol (str) -Return the symbol whose name is @var{str}. @var{str} is -converted to lowercase before the conversion is done, if Guile -is currently reading symbols case-insensitively. -@end deffn - - @node Regular Expressions @section Regular Expressions @tpindex Regular expressions @@ -1861,7 +1847,6 @@ installation includes regular expression support by checking whether the * Regexp Functions:: Functions that create and match regexps. * Match Structures:: Finding what was matched by a regexp. * Backslash Escapes:: Removing the special meaning of regexp metacharacters. -* Rx Interface:: Tom Lord's Rx library does things differently. @end menu [FIXME: it may be useful to include an Examples section. Parts of this @@ -2173,212 +2158,103 @@ support strings with different quoting conventions (an ungainly and confusing extension when implemented in other languages), we must adhere to this cumbersome escape syntax. -@node Rx Interface -@subsection Rx Interface - -@c FIXME::martin: Shouldn't this be removed or moved to the -@c ``Guile Modules'' chapter? The functions are not available in -@c plain Guile... - -[FIXME: this is taken from Gary and Mark's quick summaries and should be -reviewed and expanded. Rx is pretty stable, so could already be done!] - -@cindex rx -@cindex finite automaton - -Guile includes an interface to Tom Lord's Rx library (currently only to -POSIX regular expressions). Use of the library requires a two step -process: compile a regular expression into an efficient structure, then -use the structure in any number of string comparisons. - -For example, given the -regular expression @samp{abc.} (which matches any string containing -@samp{abc} followed by any single character): - -@smalllisp -guile> @kbd{(define r (regcomp "abc."))} -guile> @kbd{r} -# -guile> @kbd{(regexec r "abc")} -#f -guile> @kbd{(regexec r "abcd")} -#((0 . 4)) -guile> -@end smalllisp - -The definitions of @code{regcomp} and @code{regexec} are as follows: - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} regcomp pattern [flags] -Compile the regular expression pattern using POSIX rules. Flags is -optional and should be specified using symbolic names: -@defvar REG_EXTENDED -use extended POSIX syntax -@end defvar -@defvar REG_ICASE -use case-insensitive matching -@end defvar -@defvar REG_NEWLINE -allow anchors to match after newline characters in the -string and prevents @code{.} or @code{[^...]} from matching newlines. -@end defvar - -The @code{logior} procedure can be used to combine multiple flags. -The default is to use -POSIX basic syntax, which makes @code{+} and @code{?} literals and @code{\+} -and @code{\?} -operators. Backslashes in @var{pattern} must be escaped if specified in a -literal string e.g., @code{"\\(a\\)\\?"}. -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} regexec regex string [match-pick] [flags] - -Match @var{string} against the compiled POSIX regular expression -@var{regex}. -@var{match-pick} and @var{flags} are optional. Possible flags (which can be -combined using the logior procedure) are: - -@defvar REG_NOTBOL -The beginning of line operator won't match the beginning of -@var{string} (presumably because it's not the beginning of a line) -@end defvar - -@defvar REG_NOTEOL -Similar to REG_NOTBOL, but prevents the end of line operator -from matching the end of @var{string}. -@end defvar - -If no match is possible, regexec returns #f. Otherwise @var{match-pick} -determines the return value: - -@code{#t} or unspecified: a newly-allocated vector is returned, -containing pairs with the indices of the matched part of @var{string} and any -substrings. - -@code{""}: a list is returned: the first element contains a nested list -with the matched part of @var{string} surrounded by the the unmatched parts. -Remaining elements are matched substrings (if any). All returned -substrings share memory with @var{string}. - -@code{#f}: regexec returns #t if a match is made, otherwise #f. - -vector: the supplied vector is returned, with the first element replaced -by a pair containing the indices of the matched portion of @var{string} and -further elements replaced by pairs containing the indices of matched -substrings (if any). - -list: a list will be returned, with each member of the list -specified by a code in the corresponding position of the supplied list: - -a number: the numbered matching substring (0 for the entire match). - -@code{#\<}: the beginning of @var{string} to the beginning of the part matched -by regex. - -@code{#\>}: the end of the matched part of @var{string} to the end of -@var{string}. - -@code{#\c}: the "final tag", which seems to be associated with the "cut -operator", which doesn't seem to be available through the posix -interface. - -e.g., @code{(list #\< 0 1 #\>)}. The returned substrings share memory with -@var{string}. -@end deffn - -Here are some other procedures that might be used when using regular -expressions: - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} compiled-regexp? obj -Test whether obj is a compiled regular expression. -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} regexp->dfa regex [flags] -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} dfa-fork dfa -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} reset-dfa! dfa -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} dfa-final-tag dfa -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} dfa-continuable? dfa -@end deffn - -@c NJFIXME not in libguile! -@deffn {Scheme Procedure} advance-dfa! dfa string -@end deffn - - -@node Symbols and Variables -@section Symbols and Variables - -@c FIXME::martin: Review me! - -Symbols are a data type with a special property. On the one hand, -symbols are used for denoting variables in a Scheme program, on the -other they can be used as literal data as well. - -The association between symbols and values is maintained in special data -structures, the symbol tables. - -In addition, Guile offers variables as first-class objects. They can -be used for interacting with the module system. - -@menu -* Symbols:: All about symbols as a data type. -* Symbol Tables:: Tables for mapping symbols to values. -* Variables:: First-class variables. -@end menu @node Symbols -@subsection Symbols +@section Symbols @tpindex Symbols -@c FIXME::martin: Review me! +Symbols have two main uses. Crucially, they are used for denoting +variables in a Scheme program. In addition, they are very useful for +describing discrete literal data. -Symbols are especially useful because two symbols which are spelled the -same way are equivalent in the sense of @code{eq?}. That means that -they are actually the same Scheme object. The advantage is that symbols -can be compared extremely efficiently, although they carry more -information for the human reader than, say, numbers. +A symbol is an object with a name that consists of a string of +characters. In the usual case (where the name doesn't include any +characters that could be confused with other elements of Scheme syntax) +a symbol can be written in a Scheme program by writing the sequence of +characters that make up the symbol's name. For example, the read syntax +for the symbol named "multiply-by-2" is simply -It is very common in Scheme programs to use symbols as keys in -association lists (@pxref{Association Lists}) or hash tables -(@pxref{Hash Tables}), because this usage improves the readability a -lot, and does not cause any performance loss. +@lisp +multiply-by-2 +@end lisp + +Symbols, then, look rather like strings but without any quotation marks. +But there are several functional differences between them. The first +big functional difference between symbols and strings concerns +uniqueness. If the same-looking string is read twice from two different +places in a program, the result is two @emph{distinguishable} string +objects whose contents just happen to be the same. If, on the other +hand, the same-looking symbol is read twice from two different places in +a program, the result is the @emph{same} symbol object both times. + +@lisp +(define str1 "hello") +(define str2 "hello") +(eq? str1 str2) @result{} #f + +(define sym1 (quote hello)) +(define sym2 (quote hello)) +(eq? sym1 sym2) @result{} #t +@end lisp + +The second important difference is that symbols, unlike strings, are not +self-evaluating. An unquoted symbol is interpreted as a variable +reference, and the result of evaluating that symbol is the corresponding +variable's value. (By the way, this is why we needed the @code{(quote +@dots{})}s in the example above: @code{(quote hello)} returns the symbol +object named "hello" itself, whereas an unquoted @code{hello} would try +to find and dereference a variable associated with that symbol.) + +For example, when the expression @code{(string-length "abcd")} is read +and evaluated, the sequence of characters @code{string-length} is read +as the symbol whose name is "string-length". This symbol is associated +with a variable whose value is the procedure that implements string +length calculation. Therefore evaluation of the @code{string-length} +symbol results in that procedure. + +Although the use of symbols for variable references is undoubtedly their +most important role in Scheme, it is not documented further here. See +instead @ref{Binding Constructs}, for how associations between symbols +and variables are created, and @ref{Modules}, for how those associations +are affected by Guile's module system. The rest of this section +explains how symbols can also be used to represent discrete values, and +documents the procedures available that relate to symbols as data +objects @i{per se}. + +@menu +* Symbol Read Syntax:: Extended read syntax for symbols. +* Symbol Primitives:: Operations related to symbols. +* Symbol Discrete:: Using symbols as discrete values. +* Symbol Props:: Function slots and property lists. +@end menu + + +@node Symbol Read Syntax +@subsection Extended Read Syntax for Symbols The read syntax for symbols is a sequence of letters, digits, and -@dfn{extended alphabetic characters} that begins with a character that -cannot begin a number is an identifier. In addition, @code{+}, -@code{-}, and @code{...} are identifiers. +@dfn{extended alphabetic characters}, beginning with a character that +cannot begin a number. In addition, the special cases of @code{+}, +@code{-}, and @code{...} are read as symbols even though numbers can +begin with @code{+}, @code{-} or @code{.}. Extended alphabetic characters may be used within identifiers as if -they were letters. The following are extended alphabetic characters: +they were letters. The set of extended alphabetic characters is: @example ! $ % & * + - . / : < = > ? @@ ^ _ ~ @end example -In addition to the read syntax defined above (which is taken from R5RS -(@pxref{Formal syntax,,,r5rs,The Revised^5 Report on Scheme})), Guile -provides a method for writing symbols with unusual characters, such as -space characters. If you (for whatever reason) need to write a symbol -containing characters not mentioned above, you write symbols as follows: +In addition to the standard read syntax defined above (which is taken +from R5RS (@pxref{Formal syntax,,,r5rs,The Revised^5 Report on +Scheme})), Guile provides an extended symbol read syntax that allows the +inclusion of unusual characters such as space characters, newlines and +parentheses. If (for whatever reason) you need to write a symbol +containing characters not mentioned above, you can do so as follows. @itemize @bullet @item -Begin the symbol with the two character @code{#@{}, +Begin the symbol with the characters @code{#@{}, @item write the characters of the symbol and @@ -2387,19 +2263,27 @@ write the characters of the symbol and finish the symbol with the characters @code{@}#}. @end itemize -Here are a few examples of this form of read syntax; the first -containing a space character, the second containing a line break and the -last one looks like a number. +Here are a few examples of this form of read syntax. The first symbol +needs to use extended syntax because it contains a space character, the +second because it contains a line break, and the last because it looks +like a number. @lisp #@{foo bar@}# + #@{what ever@}# + #@{4242@}# @end lisp -Usage of this form of read syntax is discouraged, because it is not -portable at all, and is not very readable. +Although Guile provides this extended read syntax for symbols, +widespread usage of it is discouraged because it is not portable and not +very readable. + + +@node Symbol Primitives +@subsection Operations Related to Symbols @rnindex symbol? @deffn {Scheme Procedure} symbol? obj @@ -2433,6 +2317,13 @@ standard case is lower case: @end lisp @end deffn +@deffn {Scheme Procedure} string-ci->symbol str +@deffnx {C Function} scm_string_ci_to_symbol (str) +Return the symbol whose name is @var{str}. @var{str} is +converted to lowercase before the conversion is done, if Guile +is currently reading symbols case-insensitively. +@end deffn + @rnindex symbol->string @deffn {Scheme Procedure} symbol->string s @deffnx {C Function} scm_symbol_to_string (s) @@ -2461,19 +2352,10 @@ standard case is lower case: @end lisp @end deffn -@node Symbol Tables -@subsection Symbol Tables - -@c FIXME::martin: Review me! - -@c FIXME::martin: Are all these procedures still relevant? - -Guile symbol tables are hash tables. Each hash table, also called an -@dfn{obarray} (for `object array'), is a vector of association lists. -Each entry in the alists is a pair (@var{SYMBOL} . @var{VALUE}). To -@dfn{intern} a symbol in a symbol table means to return its -(@var{SYMBOL} . @var{VALUE}) pair, adding a new entry to the symbol -table (with an undefined value) if none is yet present. +@deffn {Scheme Procedure} symbol-hash symbol +@deffnx {C Function} scm_symbol_hash (symbol) +Return a hash value for @var{symbol}. +@end deffn @deffn {Scheme Procedure} gensym [prefix] @deffnx {C Function} scm_gensym (prefix) @@ -2484,42 +2366,24 @@ is increased by 1 at each call. There is no provision for resetting the counter. @end deffn -@deffn {Scheme Procedure} gentemp [prefix [obarray]] -Create a new symbol with a name unique in an obarray. -The name is constructed from an optional string @var{prefix} -and a counter value. The default prefix is @code{t}. The -@var{obarray} is specified as a second optional argument. -Default is the system obarray where all normal symbols are -interned. The counter is increased by 1 at each -call. There is no provision for resetting the counter. -@end deffn -@deffn {Scheme Procedure} intern-symbol obarray string -Add a new symbol to @var{obarray} with name @var{string}, bound to an -unspecified initial value. The symbol table is not modified if a symbol -with this name is already present. -@end deffn +@node Symbol Discrete +@subsection Using Symbols as Discrete Values -@deffn {Scheme Procedure} string->obarray-symbol obarray string [soft?] -Intern a new symbol in @var{obarray}, a symbol table, with name -@var{string}. -@end deffn +Symbols are especially useful because two symbols which are spelled the +same way are equivalent in the sense of @code{eq?}. That means that +they are actually the same Scheme object. The advantage is that symbols +can be compared extremely efficiently, although they carry more +information for the human reader than, say, numbers. -@deffn {Scheme Procedure} symbol-binding obarray string -Look up in @var{obarray} the symbol whose name is @var{string}, and -return the value to which it is bound. If @var{obarray} is @code{#f}, -use the global symbol table. If @var{string} is not interned in -@var{obarray}, an error is signalled. -@end deffn +It is very common in Scheme programs to use symbols as keys in +association lists (@pxref{Association Lists}) or hash tables +(@pxref{Hash Tables}), because this usage improves the readability a +lot, and does not cause any performance loss. -@deffn {Scheme Procedure} symbol-bound? obarray string -Return @code{#t} if @var{obarray} contains a symbol with name -@var{string} bound to a defined value. This differs from -@var{symbol-interned?} in that the mere mention of a symbol -usually causes it to be interned; @code{symbol-bound?} -determines whether a symbol has been given any meaningful -value. -@end deffn + +@node Symbol Props +@subsection Function Slots and Property Lists @deffn {Scheme Procedure} symbol-fref symbol @deffnx {C Function} scm_symbol_fref (symbol) @@ -2531,16 +2395,6 @@ Return the contents of @var{symbol}'s @dfn{function slot}. Change the binding of @var{symbol}'s function slot. @end deffn -@deffn {Scheme Procedure} symbol-hash symbol -@deffnx {C Function} scm_symbol_hash (symbol) -Return a hash value for @var{symbol}. -@end deffn - -@deffn {Scheme Procedure} symbol-interned? obarray string -Return @code{#t} if @var{obarray} contains a symbol with name -@var{string}, and @code{#f} otherwise. -@end deffn - @deffn {Scheme Procedure} symbol-pref symbol @deffnx {C Function} scm_symbol_pref (symbol) Return the @dfn{property list} currently associated with @var{symbol}. @@ -2551,95 +2405,6 @@ Return the @dfn{property list} currently associated with @var{symbol}. Change the binding of @var{symbol}'s property slot. @end deffn -@deffn {Scheme Procedure} symbol-set! obarray string value -Find the symbol in @var{obarray} whose name is @var{string}, and rebind -it to @var{value}. An error is signalled if @var{string} is not present -in @var{obarray}. -@end deffn - -@deffn {Scheme Procedure} unintern-symbol obarray string -Remove the symbol with name @var{string} from @var{obarray}. This -function returns @code{#t} if the symbol was present and @code{#f} -otherwise. -@end deffn - - -@node Variables -@subsection Variables -@tpindex Variables - -A variable is a box-like object that can hold any Scheme value. It is -said to be @dfn{undefined} if its box holds a special Scheme value that -denotes undefined-ness (which is different from all other Scheme values, -including for example @code{#f}); otherwise the variable is -@dfn{defined}. - -On its own, a variable object is anonymous. A variable is said to be -@dfn{bound} when it is associated with a name in some way, usually a -symbol in a module obarray. When this happens, the relationship is -mutual: the variable is bound to the name (in that module), and the name -(in that module) is bound to the variable. - -(That's the theory, anyway. In practice, defined-ness and bound-ness -sometimes get confused, because Lisp and Scheme implementations have -often conflated --- or deliberately drawn no distinction between --- a -name that is unbound and a name that is bound to a variable whose value -is undefined. We will try to be clear about the difference and explain -any confusion where it is unavoidable.) - -Variables do not have a read syntax. Most commonly they are created and -bound implicitly by @code{define} expressions: a top-level @code{define} -expression of the form - -@lisp -(define @var{name} @var{value}) -@end lisp - -@noindent -creates a variable with initial value @var{value} and binds it to the -name @var{name} in the current module. But they can also be created -dynamically by calling one of the constructor procedures -@code{make-variable} and @code{make-undefined-variable}. - -First-class variables are especially useful for interacting with the -current module system (@pxref{The Guile module system}). - -@deffn {Scheme Procedure} make-undefined-variable -@deffnx {C Function} scm_make_undefined_variable () -Return a variable that is initially unbound. -@end deffn - -@deffn {Scheme Procedure} make-variable init -@deffnx {C Function} scm_make_variable (init) -Return a variable initialized to value @var{init}. -@end deffn - -@deffn {Scheme Procedure} variable-bound? var -@deffnx {C Function} scm_variable_bound_p (var) -Return @code{#t} iff @var{var} is bound to a value. -Throws an error if @var{var} is not a variable object. -@end deffn - -@deffn {Scheme Procedure} variable-ref var -@deffnx {C Function} scm_variable_ref (var) -Dereference @var{var} and return its value. -@var{var} must be a variable object; see @code{make-variable} -and @code{make-undefined-variable}. -@end deffn - -@deffn {Scheme Procedure} variable-set! var val -@deffnx {C Function} scm_variable_set_x (var, val) -Set the value of the variable @var{var} to @var{val}. -@var{var} must be a variable object, @var{val} can be any -value. Return an unspecified value. -@end deffn - -@deffn {Scheme Procedure} variable? obj -@deffnx {C Function} scm_variable_p (obj) -Return @code{#t} iff @var{obj} is a variable object, else -return @code{#f}. -@end deffn - @node Keywords @section Keywords @@ -2777,8 +2542,8 @@ Or, even more economically, like this: @end lisp For further details on @code{let-keywords}, @code{define*} and other -facilities provided by the @code{(ice-9 optargs)} module, @ref{Optional -Arguments}. +facilities provided by the @code{(ice-9 optargs)} module, see +@ref{Optional Arguments}. @node Keyword Read Syntax @@ -2786,10 +2551,11 @@ Arguments}. Guile, by default, only recognizes the keyword syntax specified by R5RS. A token of the form @code{#:NAME}, where @code{NAME} has the same syntax -as a Scheme symbol, is the external representation of the keyword named -@code{NAME}. Keyword objects print using this syntax as well, so values -containing keyword objects can be read back into Guile. When used in an -expression, keywords are self-quoting objects. +as a Scheme symbol (@pxref{Symbol Read Syntax}), is the external +representation of the keyword named @code{NAME}. Keyword objects print +using this syntax as well, so values containing keyword objects can be +read back into Guile. When used in an expression, keywords are +self-quoting objects. If the @code{keyword} read option is set to @code{'prefix}, Guile also recognizes the alternative read syntax @code{:NAME}. Otherwise, tokens @@ -2817,7 +2583,7 @@ interface} and @ref{Reader options}. #:type :type -@result{} +@print{} ERROR: In expression :type: ERROR: Unbound variable: :type ABORT: (unbound-variable) diff --git a/doc/ref/scheme-modules.texi b/doc/ref/scheme-modules.texi index ac6ead1e8..c8d96082f 100644 --- a/doc/ref/scheme-modules.texi +++ b/doc/ref/scheme-modules.texi @@ -32,10 +32,14 @@ designed languages: ML, Python, Perl, and Modula 3 all allow the clutter the global name space. @cindex name space - private +In addition, Guile offers variables as first-class objects. They can +be used for interacting with the module system. + @menu * Scheme and modules:: How modules are handled in standard Scheme. * The Guile module system:: How Guile does it. * Dynamic Libraries:: Loading libraries of compiled code at run time. +* Variables:: First-class variables. @end menu @@ -827,6 +831,83 @@ the same place on all machines (which seems like a good idea to me anyway). +@node Variables +@section Variables +@tpindex Variables + +A variable is a box-like object that can hold any Scheme value. It is +said to be @dfn{undefined} if its box holds a special Scheme value that +denotes undefined-ness (which is different from all other Scheme values, +including for example @code{#f}); otherwise the variable is +@dfn{defined}. + +On its own, a variable object is anonymous. A variable is said to be +@dfn{bound} when it is associated with a name in some way, usually a +symbol in a module obarray. When this happens, the relationship is +mutual: the variable is bound to the name (in that module), and the name +(in that module) is bound to the variable. + +(That's the theory, anyway. In practice, defined-ness and bound-ness +sometimes get confused, because Lisp and Scheme implementations have +often conflated --- or deliberately drawn no distinction between --- a +name that is unbound and a name that is bound to a variable whose value +is undefined. We will try to be clear about the difference and explain +any confusion where it is unavoidable.) + +Variables do not have a read syntax. Most commonly they are created and +bound implicitly by @code{define} expressions: a top-level @code{define} +expression of the form + +@lisp +(define @var{name} @var{value}) +@end lisp + +@noindent +creates a variable with initial value @var{value} and binds it to the +name @var{name} in the current module. But they can also be created +dynamically by calling one of the constructor procedures +@code{make-variable} and @code{make-undefined-variable}. + +First-class variables are especially useful for interacting with the +current module system (@pxref{The Guile module system}). + +@deffn {Scheme Procedure} make-undefined-variable +@deffnx {C Function} scm_make_undefined_variable () +Return a variable that is initially unbound. +@end deffn + +@deffn {Scheme Procedure} make-variable init +@deffnx {C Function} scm_make_variable (init) +Return a variable initialized to value @var{init}. +@end deffn + +@deffn {Scheme Procedure} variable-bound? var +@deffnx {C Function} scm_variable_bound_p (var) +Return @code{#t} iff @var{var} is bound to a value. +Throws an error if @var{var} is not a variable object. +@end deffn + +@deffn {Scheme Procedure} variable-ref var +@deffnx {C Function} scm_variable_ref (var) +Dereference @var{var} and return its value. +@var{var} must be a variable object; see @code{make-variable} +and @code{make-undefined-variable}. +@end deffn + +@deffn {Scheme Procedure} variable-set! var val +@deffnx {C Function} scm_variable_set_x (var, val) +Set the value of the variable @var{var} to @var{val}. +@var{var} must be a variable object, @var{val} can be any +value. Return an unspecified value. +@end deffn + +@deffn {Scheme Procedure} variable? obj +@deffnx {C Function} scm_variable_p (obj) +Return @code{#t} iff @var{obj} is a variable object, else +return @code{#f}. +@end deffn + + @c Local Variables: @c TeX-master: "guile.texi" @c End: From 98347362c7a84985aa78bb6b5c4e5e3424e19517 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sat, 1 Dec 2001 15:54:58 +0000 Subject: [PATCH 247/281] * gh_data.c (gh_module_lookup): Use scm_str2symbol rather than gh_symbol2scm. --- libguile/ChangeLog | 5 +++++ libguile/gh_data.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index eb020f567..2dd1eb699 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-12-01 Neil Jerram + + * gh_data.c (gh_module_lookup): Use scm_str2symbol rather than + gh_symbol2scm. + 2001-11-28 Dirk Herrmann * gc.h (SCM_GC_CELL_WORD, SCM_GC_CELL_OBJECT, diff --git a/libguile/gh_data.c b/libguile/gh_data.c index 116b523fc..738eeb687 100644 --- a/libguile/gh_data.c +++ b/libguile/gh_data.c @@ -701,7 +701,7 @@ gh_module_lookup (SCM module, const char *sname) SCM_VALIDATE_MODULE (SCM_ARG1, module); - sym = gh_symbol2scm (sname); + sym = scm_str2symbol (sname); var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); if (var != SCM_BOOL_F) return SCM_VARIABLE_REF (var); From ee148ae7b9ad89f7bc0b39379349aeec0aa02ab7 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sat, 1 Dec 2001 15:55:54 +0000 Subject: [PATCH 248/281] * Add ETAGS_ARGS decls so that more stuff gets tagged. --- guile-readline/ChangeLog | 6 ++++++ guile-readline/Makefile.am | 3 ++- srfi/ChangeLog | 4 ++++ srfi/Makefile.am | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/guile-readline/ChangeLog b/guile-readline/ChangeLog index 1173e7709..374e655e7 100644 --- a/guile-readline/ChangeLog +++ b/guile-readline/ChangeLog @@ -1,3 +1,9 @@ +2001-11-30 Neil Jerram + + * Makefile.am (EXTRA_DIST): Refer to $(ice9_DATA) rather than + readline.scm explicitly. + (ETAGS_ARGS): Added. + 2001-11-04 Stefan Jahn * configure.in (EXTRA_DEFS): Follow-up patch. Using SCM_IMPORT diff --git a/guile-readline/Makefile.am b/guile-readline/Makefile.am index fe35d398b..d9d8d7d31 100644 --- a/guile-readline/Makefile.am +++ b/guile-readline/Makefile.am @@ -48,7 +48,8 @@ SUFFIXES = .x $(GUILE_SNARF) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \ || { rm $@; false; } -EXTRA_DIST = readline.scm +EXTRA_DIST = $(ice9_DATA) +ETAGS_ARGS = $(ice9_DATA) MKDEP = gcc -M -MG $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) diff --git a/srfi/ChangeLog b/srfi/ChangeLog index ab14c474e..abed6ad56 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,7 @@ +2001-11-30 Neil Jerram + + * Makefile.am (ETAGS_ARGS): Added. + 2001-11-12 Marius Vollmer * srfi-4.c: Use HAVE_LONG_LONG instead of HAVE_LONG_LONGS and test diff --git a/srfi/Makefile.am b/srfi/Makefile.am index 996b6aace..38e6cf1a2 100644 --- a/srfi/Makefile.am +++ b/srfi/Makefile.am @@ -57,6 +57,7 @@ srfi_DATA = srfi-1.scm \ srfi-19.scm EXTRA_DIST = $(srfi_DATA) +ETAGS_ARGS = $(srfi_DATA) GUILE_SNARF = ../libguile/guile-snarf From 4c731ecef3f99de4c4c12ffb3041a715818970f5 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sat, 1 Dec 2001 21:48:30 +0000 Subject: [PATCH 249/281] * Split the Data Types chapter into two; plus a few other smaller changes. --- doc/ref/ChangeLog | 8 + doc/ref/Makefile.am | 3 +- doc/ref/debugging.texi | 6 +- doc/ref/guile.texi | 6 +- doc/ref/scheme-compound.texi | 2439 +++++++++++++++++++++++++++++++ doc/ref/scheme-data.texi | 2601 +--------------------------------- doc/ref/scheme-utility.texi | 147 +- 7 files changed, 2626 insertions(+), 2584 deletions(-) create mode 100644 doc/ref/scheme-compound.texi diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 45392ab27..c835c2136 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,5 +1,9 @@ 2001-12-01 Neil Jerram + * scheme-data.texi (Hooks): Moved into scheme-utility.texi. + + * Makefile.am (guile_TEXINFOS): Added scheme-compound.texi. + * scheme-data.texi (Variables): Node moved to modules chapter. (Symbol Read Syntax): New node, with syntax-related material taken from old Symbols node. @@ -8,6 +12,10 @@ (Symbol Props): Renamed from `Symbol Tables'. (Symbols): General review, improvements and additional material throughout this section. + (Other Data Types): New material: links to object types documented + elsewhere. Also renamed node to `Other Types'. + (Data Types): Split into two: `Simple Data Types' and `Compound + Data Types'. Introductory blurbs rewritten accordingly. * guile.texi: Updated Notes comment. diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index 2f976f8bd..08d73c8a1 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -32,7 +32,8 @@ guile_TEXINFOS = preface.texi intro.texi program.texi scheme-intro.texi \ scheme-reading.texi scheme-indices.texi slib.texi posix.texi \ expect.texi scsh.texi tcltk.texi scripts.texi gh.texi scm.texi \ debugging.texi indices.texi script-getopt.texi data-rep.texi \ - extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi + extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi \ + scheme-compound.texi ETAGS_ARGS = $(info_TEXINFOS) $(guile_TEXINFOS) diff --git a/doc/ref/debugging.texi b/doc/ref/debugging.texi index 045772721..45fef5082 100644 --- a/doc/ref/debugging.texi +++ b/doc/ref/debugging.texi @@ -105,11 +105,13 @@ Since the tail call is effectively optimized to a @code{goto} statement, there is no need for Guile to create a new stack frame for each iteration. Using @code{trace} here helps us see why this is so. + @node Backtrace -@appendixsec Backtrace +@section Backtrace + @node Stacks and Frames -@appendixsec Stacks and Frames +@section Stacks and Frames When a running program is interrupted, usually upon reaching an error or breakpoint, its state is represented by a @dfn{stack} of suspended diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index f49cdbc24..ca21c17c2 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -94,7 +94,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.7 2001-12-01 15:53:04 ossau Exp $ +@subtitle $Id: guile.texi,v 1.8 2001-12-01 21:48:30 ossau Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -225,7 +225,8 @@ Part II: Programming with Guile Part III: Guile API Reference * Reference Intro:: Introduction to the Guile API reference. -* Data Types:: Data types for generic use. +* Simple Data Types:: Numbers, strings, booleans and so on. +* Compound Data Types:: Data types for holding other data. * Procedures and Macros:: Procedures and macros. * Utility Functions:: General utility functions. * Binding Constructs:: Definitions and variable bindings. @@ -306,6 +307,7 @@ options available. @unnumbered Part III: Guile API Reference @include scheme-data.texi +@include scheme-compound.texi @include scheme-procedures.texi @include scheme-utility.texi @include scheme-binding.texi diff --git a/doc/ref/scheme-compound.texi b/doc/ref/scheme-compound.texi new file mode 100644 index 000000000..1a30112be --- /dev/null +++ b/doc/ref/scheme-compound.texi @@ -0,0 +1,2439 @@ +@page +@node Compound Data Types +@chapter Compound Data Types + +This chapter describes Guile's compound data types. By @dfn{compound} +we mean that the primary purpose of these data types is to act as +containers for other kinds of data (including other compound objects). +For instance, a (non-uniform) vector with length 5 is a container that +can hold five arbitrary Scheme objects. + +The various kinds of container object differ from each other in how +their memory is allocated, how they are indexed, and how particular +values can be looked up within them. + +@menu +* Pairs:: Scheme's basic building block. +* Lists:: Special list functions supported by Guile. +* Vectors:: One-dimensional arrays of Scheme objects. +* Records:: +* Structures:: +* Arrays:: Arrays of values. +* Association Lists and Hash Tables:: Dictionary data types. +@end menu + + +@node Pairs +@section Pairs +@tpindex Pairs + +@c FIXME::martin: Review me! + +Pairs are used to combine two Scheme objects into one compound object. +Hence the name: A pair stores a pair of objects. + +The data type @dfn{pair} is extremely important in Scheme, just like in +any other Lisp dialect. The reason is that pairs are not only used to +make two values available as one object, but that pairs are used for +constructing lists of values. Because lists are so important in Scheme, +they are described in a section of their own (@pxref{Lists}). + +Pairs can literally get entered in source code or at the REPL, in the +so-called @dfn{dotted list} syntax. This syntax consists of an opening +parentheses, the first element of the pair, a dot, the second element +and a closing parentheses. The following example shows how a pair +consisting of the two numbers 1 and 2, and a pair containing the symbols +@code{foo} and @code{bar} can be entered. It is very important to write +the whitespace before and after the dot, because otherwise the Scheme +parser whould not be able to figure out where to split the tokens. + +@lisp +(1 . 2) +(foo . bar) +@end lisp + +But beware, if you want to try out these examples, you have to +@dfn{quote} the expressions. More information about quotation is +available in the section (REFFIXME). The correct way to try these +examples is as follows. + +@lisp +'(1 . 2) +@result{} +(1 . 2) +'(foo . bar) +@result{} +(foo . bar) +@end lisp + +A new pair is made by calling the procedure @code{cons} with two +arguments. Then the argument values are stored into a newly allocated +pair, and the pair is returned. The name @code{cons} stands for +"construct". Use the procedure @code{pair?} to test whether a +given Scheme object is a pair or not. + +@rnindex cons +@deffn {Scheme Procedure} cons x y +@deffnx {C Function} scm_cons (x, y) +Return a newly allocated pair whose car is @var{x} and whose +cdr is @var{y}. The pair is guaranteed to be different (in the +sense of @code{eq?}) from every previously existing object. +@end deffn + +@rnindex pair? +@deffn {Scheme Procedure} pair? x +@deffnx {C Function} scm_pair_p (x) +Return @code{#t} if @var{x} is a pair; otherwise return +@code{#f}. +@end deffn + +The two parts of a pair are traditionally called @dfn{car} and +@dfn{cdr}. They can be retrieved with procedures of the same name +(@code{car} and @code{cdr}), and can be modified with the procedures +@code{set-car!} and @code{set-cdr!}. Since a very common operation in +Scheme programs is to access the car of a pair, or the car of the cdr of +a pair, etc., the procedures called @code{caar}, @code{cadr} and so on +are also predefined. + +@rnindex car +@rnindex cdr +@deffn {Scheme Procedure} car pair +@deffnx {Scheme Procedure} cdr pair +Return the car or the cdr of @var{pair}, respectively. +@end deffn + +@deffn {Scheme Procedure} caar pair +@deffnx {Scheme Procedure} cadr pair @dots{} +@deffnx {Scheme Procedure} cdddar pair +@deffnx {Scheme Procedure} cddddr pair +These procedures are compositions of @code{car} and @code{cdr}, where +for example @code{caddr} could be defined by + +@lisp +(define caddr (lambda (x) (car (cdr (cdr x))))) +@end lisp +@end deffn + +@rnindex set-car! +@deffn {Scheme Procedure} set-car! pair value +@deffnx {C Function} scm_set_car_x (pair, value) +Stores @var{value} in the car field of @var{pair}. The value returned +by @code{set-car!} is unspecified. +@end deffn + +@rnindex set-cdr! +@deffn {Scheme Procedure} set-cdr! pair value +@deffnx {C Function} scm_set_cdr_x (pair, value) +Stores @var{value} in the cdr field of @var{pair}. The value returned +by @code{set-cdr!} is unspecified. +@end deffn + + +@node Lists +@section Lists +@tpindex Lists + +@c FIXME::martin: Review me! + +A very important data type in Scheme---as well as in all other Lisp +dialects---is the data type @dfn{list}.@footnote{Strictly speaking, +Scheme does not have a real datatype @dfn{list}. Lists are made up of +@dfn{chained pairs}, and only exist by definition---a list is a chain +of pairs which looks like a list.} + +This is the short definition of what a list is: + +@itemize @bullet +@item +Either the empty list @code{()}, + +@item +or a pair which has a list in its cdr. +@end itemize + +@c FIXME::martin: Describe the pair chaining in more detail. + +@c FIXME::martin: What is a proper, what an improper list? +@c What is a circular list? + +@c FIXME::martin: Maybe steal some graphics from the Elisp reference +@c manual? + +@menu +* List Syntax:: Writing literal lists. +* List Predicates:: Testing lists. +* List Constructors:: Creating new lists. +* List Selection:: Selecting from lists, getting their length. +* Append/Reverse:: Appending and reversing lists. +* List Modification:: Modifying existing lists. +* List Searching:: Searching for list elements +* List Mapping:: Applying procedures to lists. +@end menu + +@node List Syntax +@subsection List Read Syntax + +@c FIXME::martin: Review me! + +The syntax for lists is an opening parentheses, then all the elements of +the list (separated by whitespace) and finally a closing +parentheses.@footnote{Note that there is no separation character between +the list elements, like a comma or a semicolon.}. + +@lisp +(1 2 3) ; @r{a list of the numbers 1, 2 and 3} +("foo" bar 3.1415) ; @r{a string, a symbol and a real number} +() ; @r{the empty list} +@end lisp + +The last example needs a bit more explanation. A list with no elements, +called the @dfn{empty list}, is special in some ways. It is used for +terminating lists by storing it into the cdr of the last pair that makes +up a list. An example will clear that up: + +@lisp +(car '(1)) +@result{} +1 +(cdr '(1)) +@result{} +() +@end lisp + +This example also shows that lists have to be quoted (REFFIXME) when +written, because they would otherwise be mistakingly taken as procedure +applications (@pxref{Simple Invocation}). + + +@node List Predicates +@subsection List Predicates + +@c FIXME::martin: Review me! + +Often it is useful to test whether a given Scheme object is a list or +not. List-processing procedures could use this information to test +whether their input is valid, or they could do different things +depending on the datatype of their arguments. + +@rnindex list? +@deffn {Scheme Procedure} list? x +@deffnx {C Function} scm_list_p (x) +Return @code{#t} iff @var{x} is a proper list, else @code{#f}. +@end deffn + +The predicate @code{null?} is often used in list-processing code to +tell whether a given list has run out of elements. That is, a loop +somehow deals with the elements of a list until the list satisfies +@code{null?}. Then, the algorithm terminates. + +@rnindex null? +@deffn {Scheme Procedure} null? x +@deffnx {C Function} scm_null_p (x) +Return @code{#t} iff @var{x} is the empty list, else @code{#f}. +@end deffn + +@node List Constructors +@subsection List Constructors + +This section describes the procedures for constructing new lists. +@code{list} simply returns a list where the elements are the arguments, +@code{cons*} is similar, but the last argument is stored in the cdr of +the last pair of the list. + +@rnindex list +@deffn {Scheme Procedure} list . objs +@deffnx {C Function} scm_list (objs) +Return a list containing @var{objs}, the arguments to +@code{list}. +@end deffn + +@deffn {Scheme Procedure} cons* arg1 arg2 @dots{} +@deffnx {C Function} scm_cons_star (arg1, rest) +Like @code{list}, but the last arg provides the tail of the +constructed list, returning @code{(cons @var{arg1} (cons +@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one +argument. If given one argument, that argument is returned as +result. This function is called @code{list*} in some other +Schemes and in Common LISP. +@end deffn + +@deffn {Scheme Procedure} list-copy lst +@deffnx {C Function} scm_list_copy (lst) +Return a (newly-created) copy of @var{lst}. +@end deffn + +@deffn {Scheme Procedure} make-list n [init] +Create a list containing of @var{n} elements, where each element is +initialized to @var{init}. @var{init} defaults to the empty list +@code{()} if not given. +@end deffn + +Note that @code{list-copy} only makes a copy of the pairs which make up +the spine of the lists. The list elements are not copied, which means +that modifying the elements of the new list also modyfies the elements +of the old list. On the other hand, applying procedures like +@code{set-cdr!} or @code{delv!} to the new list will not alter the old +list. If you also need to copy the list elements (making a deep copy), +use the procedure @code{copy-tree} (@pxref{Copying}). + +@node List Selection +@subsection List Selection + +@c FIXME::martin: Review me! + +These procedures are used to get some information about a list, or to +retrieve one or more elements of a list. + +@rnindex length +@deffn {Scheme Procedure} length lst +@deffnx {C Function} scm_length (lst) +Return the number of elements in list @var{lst}. +@end deffn + +@deffn {Scheme Procedure} last-pair lst +@deffnx {C Function} scm_last_pair (lst) +Return a pointer to the last pair in @var{lst}, signalling an error if +@var{lst} is circular. +@end deffn + +@rnindex list-ref +@deffn {Scheme Procedure} list-ref list k +@deffnx {C Function} scm_list_ref (list, k) +Return the @var{k}th element from @var{list}. +@end deffn + +@rnindex list-tail +@deffn {Scheme Procedure} list-tail lst k +@deffnx {Scheme Procedure} list-cdr-ref lst k +@deffnx {C Function} scm_list_tail (lst, k) +Return the "tail" of @var{lst} beginning with its @var{k}th element. +The first element of the list is considered to be element 0. + +@code{list-tail} and @code{list-cdr-ref} are identical. It may help to +think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list, +or returning the results of cdring @var{k} times down @var{lst}. +@end deffn + +@deffn {Scheme Procedure} list-head lst k +@deffnx {C Function} scm_list_head (lst, k) +Copy the first @var{k} elements from @var{lst} into a new list, and +return it. +@end deffn + +@node Append/Reverse +@subsection Append and Reverse + +@c FIXME::martin: Review me! + +@code{append} and @code{append!} are used to concatenate two or more +lists in order to form a new list. @code{reverse} and @code{reverse!} +return lists with the same elements as their arguments, but in reverse +order. The procedure variants with an @code{!} directly modify the +pairs which form the list, whereas the other procedures create new +pairs. This is why you should be careful when using the side-effecting +variants. + +@rnindex append +@deffn {Scheme Procedure} append . args +@deffnx {C Function} scm_append (args) +Return a list consisting of the elements the lists passed as +arguments. +@lisp +(append '(x) '(y)) @result{} (x y) +(append '(a) '(b c d)) @result{} (a b c d) +(append '(a (b)) '((c))) @result{} (a (b) (c)) +@end lisp +The resulting list is always newly allocated, except that it +shares structure with the last list argument. The last +argument may actually be any object; an improper list results +if the last argument is not a proper list. +@lisp +(append '(a b) '(c . d)) @result{} (a b c . d) +(append '() 'a) @result{} a +@end lisp +@end deffn + +@deffn {Scheme Procedure} append! . lists +@deffnx {C Function} scm_append_x (lists) +A destructive version of @code{append} (@pxref{Pairs and +Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field +of each list's final pair is changed to point to the head of +the next list, so no consing is performed. Return a pointer to +the mutated list. +@end deffn + +@rnindex reverse +@deffn {Scheme Procedure} reverse lst +@deffnx {C Function} scm_reverse (lst) +Return a new list that contains the elements of @var{lst} but +in reverse order. +@end deffn + +@c NJFIXME explain new_tail +@deffn {Scheme Procedure} reverse! lst [new_tail] +@deffnx {C Function} scm_reverse_x (lst, new_tail) +A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, +The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is +modified to point to the previous list element. Return a pointer to the +head of the reversed list. + +Caveat: because the list is modified in place, the tail of the original +list now becomes its head, and the head of the original list now becomes +the tail. Therefore, the @var{lst} symbol to which the head of the +original list was bound now points to the tail. To ensure that the head +of the modified list is not lost, it is wise to save the return value of +@code{reverse!} +@end deffn + +@node List Modification +@subsection List Modification + +The following procedures modify an existing list, either by changing +elements of the list, or by changing the list structure itself. + +@deffn {Scheme Procedure} list-set! list k val +@deffnx {C Function} scm_list_set_x (list, k, val) +Set the @var{k}th element of @var{list} to @var{val}. +@end deffn + +@deffn {Scheme Procedure} list-cdr-set! list k val +@deffnx {C Function} scm_list_cdr_set_x (list, k, val) +Set the @var{k}th cdr of @var{list} to @var{val}. +@end deffn + +@deffn {Scheme Procedure} delq item lst +@deffnx {C Function} scm_delq (item, lst) +Return a newly-created copy of @var{lst} with elements +@code{eq?} to @var{item} removed. This procedure mirrors +@code{memq}: @code{delq} compares elements of @var{lst} against +@var{item} with @code{eq?}. +@end deffn + +@deffn {Scheme Procedure} delv item lst +@deffnx {C Function} scm_delv (item, lst) +Return a newly-created copy of @var{lst} with elements +@code{eqv?} to @var{item} removed. This procedure mirrors +@code{memv}: @code{delv} compares elements of @var{lst} against +@var{item} with @code{eqv?}. +@end deffn + +@deffn {Scheme Procedure} delete item lst +@deffnx {C Function} scm_delete (item, lst) +Return a newly-created copy of @var{lst} with elements +@code{equal?} to @var{item} removed. This procedure mirrors +@code{member}: @code{delete} compares elements of @var{lst} +against @var{item} with @code{equal?}. +@end deffn + +@deffn {Scheme Procedure} delq! item lst +@deffnx {Scheme Procedure} delv! item lst +@deffnx {Scheme Procedure} delete! item lst +@deffnx {C Function} scm_delq_x (item, lst) +@deffnx {C Function} scm_delv_x (item, lst) +@deffnx {C Function} scm_delete_x (item, lst) +These procedures are destructive versions of @code{delq}, @code{delv} +and @code{delete}: they modify the pointers in the existing @var{lst} +rather than creating a new list. Caveat evaluator: Like other +destructive list functions, these functions cannot modify the binding of +@var{lst}, and so cannot be used to delete the first element of +@var{lst} destructively. +@end deffn + +@deffn {Scheme Procedure} delq1! item lst +@deffnx {C Function} scm_delq1_x (item, lst) +Like @code{delq!}, but only deletes the first occurrence of +@var{item} from @var{lst}. Tests for equality using +@code{eq?}. See also @code{delv1!} and @code{delete1!}. +@end deffn + +@deffn {Scheme Procedure} delv1! item lst +@deffnx {C Function} scm_delv1_x (item, lst) +Like @code{delv!}, but only deletes the first occurrence of +@var{item} from @var{lst}. Tests for equality using +@code{eqv?}. See also @code{delq1!} and @code{delete1!}. +@end deffn + +@deffn {Scheme Procedure} delete1! item lst +@deffnx {C Function} scm_delete1_x (item, lst) +Like @code{delete!}, but only deletes the first occurrence of +@var{item} from @var{lst}. Tests for equality using +@code{equal?}. See also @code{delq1!} and @code{delv1!}. +@end deffn + +@node List Searching +@subsection List Searching + +@c FIXME::martin: Review me! + +The following procedures search lists for particular elements. They use +different comparison predicates for comparing list elements with the +object to be searched. When they fail, they return @code{#f}, otherwise +they return the sublist whose car is equal to the search object, where +equality depends on the equality predicate used. + +@rnindex memq +@deffn {Scheme Procedure} memq x lst +@deffnx {C Function} scm_memq (x, lst) +Return the first sublist of @var{lst} whose car is @code{eq?} +to @var{x} where the sublists of @var{lst} are the non-empty +lists returned by @code{(list-tail @var{lst} @var{k})} for +@var{k} less than the length of @var{lst}. If @var{x} does not +occur in @var{lst}, then @code{#f} (not the empty list) is +returned. +@end deffn + +@rnindex memv +@deffn {Scheme Procedure} memv x lst +@deffnx {C Function} scm_memv (x, lst) +Return the first sublist of @var{lst} whose car is @code{eqv?} +to @var{x} where the sublists of @var{lst} are the non-empty +lists returned by @code{(list-tail @var{lst} @var{k})} for +@var{k} less than the length of @var{lst}. If @var{x} does not +occur in @var{lst}, then @code{#f} (not the empty list) is +returned. +@end deffn + +@rnindex member +@deffn {Scheme Procedure} member x lst +@deffnx {C Function} scm_member (x, lst) +Return the first sublist of @var{lst} whose car is +@code{equal?} to @var{x} where the sublists of @var{lst} are +the non-empty lists returned by @code{(list-tail @var{lst} +@var{k})} for @var{k} less than the length of @var{lst}. If +@var{x} does not occur in @var{lst}, then @code{#f} (not the +empty list) is returned. +@end deffn + +[FIXME: Is there any reason to have the `sloppy' functions available at +high level at all? Maybe these docs should be relegated to a "Guile +Internals" node or something. -twp] + +@deffn {Scheme Procedure} sloppy-memq x lst +This procedure behaves like @code{memq}, but does no type or error checking. +Its use is recommended only in writing Guile internals, +not for high-level Scheme programs. +@end deffn + +@deffn {Scheme Procedure} sloppy-memv x lst +This procedure behaves like @code{memv}, but does no type or error checking. +Its use is recommended only in writing Guile internals, +not for high-level Scheme programs. +@end deffn + +@deffn {Scheme Procedure} sloppy-member x lst +This procedure behaves like @code{member}, but does no type or error checking. +Its use is recommended only in writing Guile internals, +not for high-level Scheme programs. +@end deffn + +@node List Mapping +@subsection List Mapping + +@c FIXME::martin: Review me! + +List processing is very convenient in Scheme because the process of +iterating over the elements of a list can be highly abstracted. The +procedures in this section are the most basic iterating procedures for +lists. They take a procedure and one or more lists as arguments, and +apply the procedure to each element of the list. They differ in their +return value. + +@rnindex map +@c begin (texi-doc-string "guile" "map") +@deffn {Scheme Procedure} map proc arg1 arg2 @dots{} +@deffnx {Scheme Procedure} map-in-order proc arg1 arg2 @dots{} +@deffnx {C Function} scm_map (proc, arg1, args) +Apply @var{proc} to each element of the list @var{arg1} (if only two +arguments are given), or to the corresponding elements of the argument +lists (if more than two arguments are given). The result(s) of the +procedure applications are saved and returned in a list. For +@code{map}, the order of procedure applications is not specified, +@code{map-in-order} applies the procedure from left to right to the list +elements. +@end deffn + +@rnindex for-each +@c begin (texi-doc-string "guile" "for-each") +@deffn {Scheme Procedure} for-each proc arg1 arg2 @dots{} +Like @code{map}, but the procedure is always applied from left to right, +and the result(s) of the procedure applications are thrown away. The +return value is not specified. +@end deffn + + +@node Vectors +@section Vectors +@tpindex Vectors + +@c FIXME::martin: Review me! + +@c FIXME::martin: Should the subsections of this section be nodes +@c of their own, or are the resulting nodes too short, then? + +Vectors are sequences of Scheme objects. Unlike lists, the length of a +vector, once the vector is created, cannot be changed. The advantage of +vectors over lists is that the time required to access one element of a vector +given its @dfn{position} (synonymous with @dfn{index}), a zero-origin number, +is constant, whereas lists have an access time linear to the position of the +accessed element in the list. + +Vectors can contain any kind of Scheme object; it is even possible to have +different types of objects in the same vector. For vectors containing +vectors, you may wish to use arrays, instead. Note, too, that some array +procedures operate happily on vectors (@pxref{Arrays}). + +@subsection Vector Read Syntax + +Vectors can literally be entered in source code, just like strings, +characters or some of the other data types. The read syntax for vectors +is as follows: A sharp sign (@code{#}), followed by an opening +parentheses, all elements of the vector in their respective read syntax, +and finally a closing parentheses. The following are examples of the +read syntax for vectors; where the first vector only contains numbers +and the second three different object types: a string, a symbol and a +number in hexadecimal notation. + +@lisp +#(1 2 3) +#("Hello" foo #xdeadbeef) +@end lisp + +@subsection Vector Predicates + +@rnindex vector? +@deffn {Scheme Procedure} vector? obj +@deffnx {C Function} scm_vector_p (obj) +Return @code{#t} if @var{obj} is a vector, otherwise return +@code{#f}. +@end deffn + +@subsection Vector Constructors + +@rnindex make-vector +@deffn {Scheme Procedure} make-vector k [fill] +@deffnx {C Function} scm_make_vector (k, fill) +Return a newly allocated vector of @var{k} elements. If a +second argument is given, then each position is initialized to +@var{fill}. Otherwise the initial contents of each position is +unspecified. +@end deffn + +@rnindex vector +@rnindex list->vector +@deffn {Scheme Procedure} vector . l +@deffnx {Scheme Procedure} list->vector l +@deffnx {C Function} scm_vector (l) +Return a newly allocated vector composed of the +given arguments. Analogous to @code{list}. + +@lisp +(vector 'a 'b 'c) @result{} #(a b c) +@end lisp +@end deffn + +@rnindex vector->list +@deffn {Scheme Procedure} vector->list v +@deffnx {C Function} scm_vector_to_list (v) +Return a newly allocated list composed of the elements of @var{v}. + +@lisp +(vector->list '#(dah dah didah)) @result{} (dah dah didah) +(list->vector '(dididit dah)) @result{} #(dididit dah) +@end lisp +@end deffn + +@subsection Vector Modification + +A vector created by any of the vector constructor procedures +(@pxref{Vectors}) documented above can be modified using the +following procedures. + +@emph{NOTE:} According to R5RS, using any of these procedures on +literally entered vectors is an error, because these vectors are +considered to be constant, although Guile currently does not detect this +error. + +@rnindex vector-set! +@deffn {Scheme Procedure} vector-set! vector k obj +Store @var{obj} in position @var{k} of @var{vector}. +@var{k} must be a valid index of @var{vector}. +The value returned by @samp{vector-set!} is unspecified. +@lisp +(let ((vec (vector 0 '(2 2 2 2) "Anna"))) + (vector-set! vec 1 '("Sue" "Sue")) + vec) @result{} #(0 ("Sue" "Sue") "Anna") +@end lisp +@end deffn + +@rnindex vector-fill! +@deffn {Scheme Procedure} vector-fill! v fill +@deffnx {C Function} scm_vector_fill_x (v, fill) +Store @var{fill} in every position of @var{vector}. The value +returned by @code{vector-fill!} is unspecified. +@end deffn + +@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2 +@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2) +Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, +to @var{vec2} starting at position @var{start2}. @var{start1} and +@var{start2} are inclusive indices; @var{end1} is exclusive. + +@code{vector-move-left!} copies elements in leftmost order. +Therefore, in the case where @var{vec1} and @var{vec2} refer to the +same vector, @code{vector-move-left!} is usually appropriate when +@var{start1} is greater than @var{start2}. +@end deffn + +@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2 +@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2) +Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, +to @var{vec2} starting at position @var{start2}. @var{start1} and +@var{start2} are inclusive indices; @var{end1} is exclusive. + +@code{vector-move-right!} copies elements in rightmost order. +Therefore, in the case where @var{vec1} and @var{vec2} refer to the +same vector, @code{vector-move-right!} is usually appropriate when +@var{start1} is less than @var{start2}. +@end deffn + +@subsection Vector Selection + +These procedures return information about a given vector, such as the +size or what elements are contained in the vector. + +@rnindex vector-length +@deffn {Scheme Procedure} vector-length vector +Return the number of elements in @var{vector} as an exact integer. +@end deffn + +@rnindex vector-ref +@deffn {Scheme Procedure} vector-ref vector k +Return the contents of position @var{k} of @var{vector}. +@var{k} must be a valid index of @var{vector}. +@lisp +(vector-ref '#(1 1 2 3 5 8 13 21) 5) @result{} 8 +(vector-ref '#(1 1 2 3 5 8 13 21) + (let ((i (round (* 2 (acos -1))))) + (if (inexact? i) + (inexact->exact i) + i))) @result{} 13 +@end lisp +@end deffn + + +@node Records +@section Records + +A @dfn{record type} is a first class object representing a user-defined +data type. A @dfn{record} is an instance of a record type. + +@deffn {Scheme Procedure} record? obj +Return @code{#t} if @var{obj} is a record of any type and @code{#f} +otherwise. + +Note that @code{record?} may be true of any Scheme value; there is no +promise that records are disjoint with other Scheme types. +@end deffn + +@deffn {Scheme Procedure} make-record-type type-name field-names +Return a @dfn{record-type descriptor}, a value representing a new data +type disjoint from all others. The @var{type-name} argument must be a +string, but is only used for debugging purposes (such as the printed +representation of a record of the new type). The @var{field-names} +argument is a list of symbols naming the @dfn{fields} of a record of the +new type. It is an error if the list contains any duplicates. It is +unspecified how record-type descriptors are represented. +@end deffn + +@deffn {Scheme Procedure} record-constructor rtd [field-names] +Return a procedure for constructing new members of the type represented +by @var{rtd}. The returned procedure accepts exactly as many arguments +as there are symbols in the given list, @var{field-names}; these are +used, in order, as the initial values of those fields in a new record, +which is returned by the constructor procedure. The values of any +fields not named in that list are unspecified. The @var{field-names} +argument defaults to the list of field names in the call to +@code{make-record-type} that created the type represented by @var{rtd}; +if the @var{field-names} argument is provided, it is an error if it +contains any duplicates or any symbols not in the default list. +@end deffn + +@deffn {Scheme Procedure} record-predicate rtd +Return a procedure for testing membership in the type represented by +@var{rtd}. The returned procedure accepts exactly one argument and +returns a true value if the argument is a member of the indicated record +type; it returns a false value otherwise. +@end deffn + +@deffn {Scheme Procedure} record-accessor rtd field-name +Return a procedure for reading the value of a particular field of a +member of the type represented by @var{rtd}. The returned procedure +accepts exactly one argument which must be a record of the appropriate +type; it returns the current value of the field named by the symbol +@var{field-name} in that record. The symbol @var{field-name} must be a +member of the list of field-names in the call to @code{make-record-type} +that created the type represented by @var{rtd}. +@end deffn + +@deffn {Scheme Procedure} record-modifier rtd field-name +Return a procedure for writing the value of a particular field of a +member of the type represented by @var{rtd}. The returned procedure +accepts exactly two arguments: first, a record of the appropriate type, +and second, an arbitrary Scheme value; it modifies the field named by +the symbol @var{field-name} in that record to contain the given value. +The returned value of the modifier procedure is unspecified. The symbol +@var{field-name} must be a member of the list of field-names in the call +to @code{make-record-type} that created the type represented by +@var{rtd}. +@end deffn + +@deffn {Scheme Procedure} record-type-descriptor record +Return a record-type descriptor representing the type of the given +record. That is, for example, if the returned descriptor were passed to +@code{record-predicate}, the resulting predicate would return a true +value when passed the given record. Note that it is not necessarily the +case that the returned descriptor is the one that was passed to +@code{record-constructor} in the call that created the constructor +procedure that created the given record. +@end deffn + +@deffn {Scheme Procedure} record-type-name rtd +Return the type-name associated with the type represented by rtd. The +returned value is @code{eqv?} to the @var{type-name} argument given in +the call to @code{make-record-type} that created the type represented by +@var{rtd}. +@end deffn + +@deffn {Scheme Procedure} record-type-fields rtd +Return a list of the symbols naming the fields in members of the type +represented by @var{rtd}. The returned value is @code{equal?} to the +field-names argument given in the call to @code{make-record-type} that +created the type represented by @var{rtd}. +@end deffn + + +@node Structures +@section Structures +@tpindex Structures + +[FIXME: this is pasted in from Tom Lord's original guile.texi and should +be reviewed] + +A @dfn{structure type} is a first class user-defined data type. A +@dfn{structure} is an instance of a structure type. A structure type is +itself a structure. + +Structures are less abstract and more general than traditional records. +In fact, in Guile Scheme, records are implemented using structures. + +@menu +* Structure Concepts:: The structure of Structures +* Structure Layout:: Defining the layout of structure types +* Structure Basics:: make-, -ref and -set! procedures for structs +* Vtables:: Accessing type-specific data +@end menu + +@node Structure Concepts +@subsection Structure Concepts + +A structure object consists of a handle, structure data, and a vtable. +The handle is a Scheme value which points to both the vtable and the +structure's data. Structure data is a dynamically allocated region of +memory, private to the structure, divided up into typed fields. A +vtable is another structure used to hold type-specific data. Multiple +structures can share a common vtable. + +Three concepts are key to understanding structures. + +@itemize @bullet{} +@item @dfn{layout specifications} + +Layout specifications determine how memory allocated to structures is +divided up into fields. Programmers must write a layout specification +whenever a new type of structure is defined. + +@item @dfn{structural accessors} + +Structure access is by field number. There is only one set of +accessors common to all structure objects. + +@item @dfn{vtables} + +Vtables, themselves structures, are first class representations of +disjoint sub-types of structures in general. In most cases, when a +new structure is created, programmers must specifiy a vtable for the +new structure. Each vtable has a field describing the layout of its +instances. Vtables can have additional, user-defined fields as well. +@end itemize + + + +@node Structure Layout +@subsection Structure Layout + +When a structure is created, a region of memory is allocated to hold its +state. The @dfn{layout} of the structure's type determines how that +memory is divided into fields. + +Each field has a specified type. There are only three types allowed, each +corresponding to a one letter code. The allowed types are: + +@itemize @bullet{} +@item 'u' -- unprotected + +The field holds binary data that is not GC protected. + +@item 'p' -- protected + +The field holds a Scheme value and is GC protected. + +@item 's' -- self + +The field holds a Scheme value and is GC protected. When a structure is +created with this type of field, the field is initialized to refer to +the structure's own handle. This kind of field is mainly useful when +mixing Scheme and C code in which the C code may need to compute a +structure's handle given only the address of its malloced data. +@end itemize + + +Each field also has an associated access protection. There are only +three kinds of protection, each corresponding to a one letter code. +The allowed protections are: + +@itemize @bullet{} +@item 'w' -- writable + +The field can be read and written. + +@item 'r' -- readable + +The field can be read, but not written. + +@item 'o' -- opaque + +The field can be neither read nor written. This kind +of protection is for fields useful only to built-in routines. +@end itemize + +A layout specification is described by stringing together pairs +of letters: one to specify a field type and one to specify a field +protection. For example, a traditional cons pair type object could +be described as: + +@example +; cons pairs have two writable fields of Scheme data +"pwpw" +@end example + +A pair object in which the first field is held constant could be: + +@example +"prpw" +@end example + +Binary fields, (fields of type "u"), hold one @dfn{word} each. The +size of a word is a machine dependent value defined to be equal to the +value of the C expression: @code{sizeof (long)}. + +The last field of a structure layout may specify a tail array. +A tail array is indicated by capitalizing the field's protection +code ('W', 'R' or 'O'). A tail-array field is replaced by +a read-only binary data field containing an array size. The array +size is determined at the time the structure is created. It is followed +by a corresponding number of fields of the type specified for the +tail array. For example, a conventional Scheme vector can be +described as: + +@example +; A vector is an arbitrary number of writable fields holding Scheme +; values: +"pW" +@end example + +In the above example, field 0 contains the size of the vector and +fields beginning at 1 contain the vector elements. + +A kind of tagged vector (a constant tag followed by conventioal +vector elements) might be: + +@example +"prpW" +@end example + + +Structure layouts are represented by specially interned symbols whose +name is a string of type and protection codes. To create a new +structure layout, use this procedure: + +@deffn {Scheme Procedure} make-struct-layout fields +@deffnx {C Function} scm_make_struct_layout (fields) +Return a new structure layout object. + +@var{fields} must be a string made up of pairs of characters +strung together. The first character of each pair describes a field +type, the second a field protection. Allowed types are 'p' for +GC-protected Scheme data, 'u' for unprotected binary data, and 's' for +a field that points to the structure itself. Allowed protections +are 'w' for mutable fields, 'r' for read-only fields, and 'o' for opaque +fields. The last field protection specification may be capitalized to +indicate that the field is a tail-array. +@end deffn + + + +@node Structure Basics +@subsection Structure Basics + +This section describes the basic procedures for creating and accessing +structures. + +@deffn {Scheme Procedure} make-struct vtable tail_array_size . init +@deffnx {C Function} scm_make_struct (vtable, tail_array_size, init) +Create a new structure. + +@var{type} must be a vtable structure (@pxref{Vtables}). + +@var{tail-elts} must be a non-negative integer. If the layout +specification indicated by @var{type} includes a tail-array, +this is the number of elements allocated to that array. + +The @var{init1}, @dots{} are optional arguments describing how +successive fields of the structure should be initialized. Only fields +with protection 'r' or 'w' can be initialized, except for fields of +type 's', which are automatically initialized to point to the new +structure itself; fields with protection 'o' can not be initialized by +Scheme programs. + +If fewer optional arguments than initializable fields are supplied, +fields of type 'p' get default value #f while fields of type 'u' are +initialized to 0. + +Structs are currently the basic representation for record-like data +structures in Guile. The plan is to eventually replace them with a +new representation which will at the same time be easier to use and +more powerful. + +For more information, see the documentation for @code{make-vtable-vtable}. +@end deffn + +@deffn {Scheme Procedure} struct? x +@deffnx {C Function} scm_struct_p (x) +Return @code{#t} iff @var{x} is a structure object, else +@code{#f}. +@end deffn + + +@deffn {Scheme Procedure} struct-ref handle pos +@deffnx {Scheme Procedure} struct-set! struct n value +@deffnx {C Function} scm_struct_ref (handle, pos) +@deffnx {C Function} scm_struct_set_x (struct, n, value) +Access (or modify) the @var{n}th field of @var{struct}. + +If the field is of type 'p', then it can be set to an arbitrary value. + +If the field is of type 'u', then it can only be set to a non-negative +integer value small enough to fit in one machine word. +@end deffn + + + +@node Vtables +@subsection Vtables + +Vtables are structures that are used to represent structure types. Each +vtable contains a layout specification in field +@code{vtable-index-layout} -- instances of the type are laid out +according to that specification. Vtables contain additional fields +which are used only internally to libguile. The variable +@code{vtable-offset-user} is bound to a field number. Vtable fields +at that position or greater are user definable. + +@deffn {Scheme Procedure} struct-vtable handle +@deffnx {C Function} scm_struct_vtable (handle) +Return the vtable structure that describes the type of @var{struct}. +@end deffn + +@deffn {Scheme Procedure} struct-vtable? x +@deffnx {C Function} scm_struct_vtable_p (x) +Return @code{#t} iff @var{x} is a vtable structure. +@end deffn + +If you have a vtable structure, @code{V}, you can create an instance of +the type it describes by using @code{(make-struct V ...)}. But where +does @code{V} itself come from? One possibility is that @code{V} is an +instance of a user-defined vtable type, @code{V'}, so that @code{V} is +created by using @code{(make-struct V' ...)}. Another possibility is +that @code{V} is an instance of the type it itself describes. Vtable +structures of the second sort are created by this procedure: + +@deffn {Scheme Procedure} make-vtable-vtable user_fields tail_array_size . init +@deffnx {C Function} scm_make_vtable_vtable (user_fields, tail_array_size, init) +Return a new, self-describing vtable structure. + +@var{user-fields} is a string describing user defined fields of the +vtable beginning at index @code{vtable-offset-user} +(see @code{make-struct-layout}). + +@var{tail-size} specifies the size of the tail-array (if any) of +this vtable. + +@var{init1}, @dots{} are the optional initializers for the fields of +the vtable. + +Vtables have one initializable system field---the struct printer. +This field comes before the user fields in the initializers passed +to @code{make-vtable-vtable} and @code{make-struct}, and thus works as +a third optional argument to @code{make-vtable-vtable} and a fourth to +@code{make-struct} when creating vtables: + +If the value is a procedure, it will be called instead of the standard +printer whenever a struct described by this vtable is printed. +The procedure will be called with arguments STRUCT and PORT. + +The structure of a struct is described by a vtable, so the vtable is +in essence the type of the struct. The vtable is itself a struct with +a vtable. This could go on forever if it weren't for the +vtable-vtables which are self-describing vtables, and thus terminate +the chain. + +There are several potential ways of using structs, but the standard +one is to use three kinds of structs, together building up a type +sub-system: one vtable-vtable working as the root and one or several +"types", each with a set of "instances". (The vtable-vtable should be +compared to the class which is the class of itself.) + +@lisp +(define ball-root (make-vtable-vtable "pr" 0)) + +(define (make-ball-type ball-color) + (make-struct ball-root 0 + (make-struct-layout "pw") + (lambda (ball port) + (format port "#" + (color ball) + (owner ball))) + ball-color)) +(define (color ball) (struct-ref (struct-vtable ball) vtable-offset-user)) +(define (owner ball) (struct-ref ball 0)) + +(define red (make-ball-type 'red)) +(define green (make-ball-type 'green)) + +(define (make-ball type owner) (make-struct type 0 owner)) + +(define ball (make-ball green 'Nisse)) +ball @result{} # +@end lisp +@end deffn + +@deffn {Scheme Procedure} struct-vtable-name vtable +@deffnx {C Function} scm_struct_vtable_name (vtable) +Return the name of the vtable @var{vtable}. +@end deffn + +@deffn {Scheme Procedure} set-struct-vtable-name! vtable name +@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name) +Set the name of the vtable @var{vtable} to @var{name}. +@end deffn + +@deffn {Scheme Procedure} struct-vtable-tag handle +@deffnx {C Function} scm_struct_vtable_tag (handle) +Return the vtable tag of the structure @var{handle}. +@end deffn + + +@node Arrays +@section Arrays +@tpindex Arrays + +@menu +* Conventional Arrays:: Arrays with arbitrary data. +* Array Mapping:: Applying a procedure to the contents of an array. +* Uniform Arrays:: Arrays with data of a single type. +* Bit Vectors:: Vectors of bits. +@end menu + +@node Conventional Arrays +@subsection Conventional Arrays + +@dfn{Conventional arrays} are a collection of cells organized into an +arbitrary number of dimensions. Each cell can hold any kind of Scheme +value and can be accessed in constant time by supplying an index for +each dimension. This contrasts with uniform arrays, which use memory +more efficiently but can hold data of only a single type, and lists +where inserting and deleting cells is more efficient, but more time +is usually required to access a particular cell. + +A conventional array is displayed as @code{#} followed by the @dfn{rank} +(number of dimensions) followed by the cells, organized into dimensions +using parentheses. The nesting depth of the parentheses is equal to +the rank. + +When an array is created, the number of dimensions and range of each +dimension must be specified, e.g., to create a 2x3 array with a +zero-based index: + +@example +(make-array 'ho 2 3) @result{} +#2((ho ho ho) (ho ho ho)) +@end example + +The range of each dimension can also be given explicitly, e.g., another +way to create the same array: + +@example +(make-array 'ho '(0 1) '(0 2)) @result{} +#2((ho ho ho) (ho ho ho)) +@end example + +A conventional array with one dimension based at zero is identical to +a vector: + +@example +(make-array 'ho 3) @result{} +#(ho ho ho) +@end example + +The following procedures can be used with conventional arrays (or vectors). + +@deffn {Scheme Procedure} array? v [prot] +@deffnx {C Function} scm_array_p (v, prot) +Return @code{#t} if the @var{obj} is an array, and @code{#f} if +not. The @var{prototype} argument is used with uniform arrays +and is described elsewhere. +@end deffn + +@deffn {Scheme Procedure} make-array initial-value bound1 bound2 @dots{} +Create and return an array that has as many dimensions as there are +@var{bound}s and fill it with @var{initial-value}. Each @var{bound} +may be a positive non-zero integer @var{N}, in which case the index for +that dimension can range from 0 through @var{N-1}; or an explicit index +range specifier in the form @code{(LOWER UPPER)}, where both @var{lower} +and @var{upper} are integers, possibly less than zero, and possibly the +same number (however, @var{lower} cannot be greater than @var{upper}). +@end deffn + +@c array-ref's type is `compiled-closure'. There's some weird stuff +@c going on in array.c, too. Let's call it a primitive. -twp + +@deffn {Scheme Procedure} uniform-vector-ref v args +@deffnx {Scheme Procedure} array-ref v . args +@deffnx {C Function} scm_uniform_vector_ref (v, args) +Return the element at the @code{(index1, index2)} element in +@var{array}. +@end deffn + +@deffn {Scheme Procedure} array-in-bounds? v . args +@deffnx {C Function} scm_array_in_bounds_p (v, args) +Return @code{#t} if its arguments would be acceptable to +@code{array-ref}. +@end deffn + +@c fixme: why do these sigs differ? -ttn 2001/07/19 01:14:12 +@deffn {Scheme Procedure} array-set! v obj . args +@deffnx {Scheme Procedure} uniform-array-set1! v obj args +@deffnx {C Function} scm_array_set_x (v, obj, args) +Set the element at the @code{(index1, index2)} element in @var{array} to +@var{new-value}. The value returned by array-set! is unspecified. +@end deffn + +@deffn {Scheme Procedure} make-shared-array oldra mapfunc . dims +@deffnx {C Function} scm_make_shared_array (oldra, mapfunc, dims) +@code{make-shared-array} can be used to create shared subarrays of other +arrays. The @var{mapper} is a function that translates coordinates in +the new array into coordinates in the old array. A @var{mapper} must be +linear, and its range must stay within the bounds of the old array, but +it can be otherwise arbitrary. A simple example: +@lisp +(define fred (make-array #f 8 8)) +(define freds-diagonal + (make-shared-array fred (lambda (i) (list i i)) 8)) +(array-set! freds-diagonal 'foo 3) +(array-ref fred 3 3) @result{} foo +(define freds-center + (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) +(array-ref freds-center 0 0) @result{} foo +@end lisp +@end deffn + +@deffn {Scheme Procedure} shared-array-increments ra +@deffnx {C Function} scm_shared_array_increments (ra) +For each dimension, return the distance between elements in the root vector. +@end deffn + +@deffn {Scheme Procedure} shared-array-offset ra +@deffnx {C Function} scm_shared_array_offset (ra) +Return the root vector index of the first element in the array. +@end deffn + +@deffn {Scheme Procedure} shared-array-root ra +@deffnx {C Function} scm_shared_array_root (ra) +Return the root vector of a shared array. +@end deffn + +@deffn {Scheme Procedure} transpose-array ra . args +@deffnx {C Function} scm_transpose_array (ra, args) +Return an array sharing contents with @var{array}, but with +dimensions arranged in a different order. There must be one +@var{dim} argument for each dimension of @var{array}. +@var{dim0}, @var{dim1}, @dots{} should be integers between 0 +and the rank of the array to be returned. Each integer in that +range must appear at least once in the argument list. + +The values of @var{dim0}, @var{dim1}, @dots{} correspond to +dimensions in the array to be returned, their positions in the +argument list to dimensions of @var{array}. Several @var{dim}s +may have the same value, in which case the returned array will +have smaller rank than @var{array}. + +@lisp +(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d)) +(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d) +(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{} + #2((a 4) (b 5) (c 6)) +@end lisp +@end deffn + +@deffn {Scheme Procedure} enclose-array ra . axes +@deffnx {C Function} scm_enclose_array (ra, axes) +@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than +the rank of @var{array}. @var{enclose-array} returns an array +resembling an array of shared arrays. The dimensions of each shared +array are the same as the @var{dim}th dimensions of the original array, +the dimensions of the outer array are the same as those of the original +array that did not match a @var{dim}. + +An enclosed array is not a general Scheme array. Its elements may not +be set using @code{array-set!}. Two references to the same element of +an enclosed array will be @code{equal?} but will not in general be +@code{eq?}. The value returned by @var{array-prototype} when given an +enclosed array is unspecified. + +examples: +@lisp +(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{} + # + +(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{} + # +@end lisp +@end deffn + +@deffn {Scheme Procedure} array-shape array +Return a list of inclusive bounds of integers. +@example +(array-shape (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) (0 4)) +@end example +@end deffn + +@deffn {Scheme Procedure} array-dimensions ra +@deffnx {C Function} scm_array_dimensions (ra) +@code{Array-dimensions} is similar to @code{array-shape} but replaces +elements with a @code{0} minimum with one greater than the maximum. So: +@lisp +(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5) +@end lisp +@end deffn + +@deffn {Scheme Procedure} array-rank ra +@deffnx {C Function} scm_array_rank (ra) +Return the number of dimensions of @var{obj}. If @var{obj} is +not an array, @code{0} is returned. +@end deffn + +@deffn {Scheme Procedure} array->list v +@deffnx {C Function} scm_t_arrayo_list (v) +Return a list consisting of all the elements, in order, of +@var{array}. +@end deffn + +@deffn {Scheme Procedure} array-copy! src dst +@deffnx {Scheme Procedure} array-copy-in-order! src dst +@deffnx {C Function} scm_array_copy_x (src, dst) +Copy every element from vector or array @var{source} to the +corresponding element of @var{destination}. @var{destination} must have +the same rank as @var{source}, and be at least as large in each +dimension. The order is unspecified. +@end deffn + +@deffn {Scheme Procedure} array-fill! ra fill +@deffnx {C Function} scm_array_fill_x (ra, fill) +Store @var{fill} in every element of @var{array}. The value returned +is unspecified. +@end deffn + +@c begin (texi-doc-string "guile" "array-equal?") +@deffn {Scheme Procedure} array-equal? ra0 ra1 +Return @code{#t} iff all arguments are arrays with the same shape, the +same type, and have corresponding elements which are either +@code{equal?} or @code{array-equal?}. This function differs from +@code{equal?} in that a one dimensional shared array may be +@var{array-equal?} but not @var{equal?} to a vector or uniform vector. +@end deffn + +@deffn {Scheme Procedure} array-contents array [strict] +@deffnx {C Function} scm_array_contents (array, strict) +If @var{array} may be @dfn{unrolled} into a one dimensional shared array +without changing their order (last subscript changing fastest), then +@code{array-contents} returns that shared array, otherwise it returns +@code{#f}. All arrays made by @var{make-array} and +@var{make-uniform-array} may be unrolled, some arrays made by +@var{make-shared-array} may not be. + +If the optional argument @var{strict} is provided, a shared array will +be returned only if its elements are stored internally contiguous in +memory. +@end deffn + +@node Array Mapping +@subsection Array Mapping + +@deffn {Scheme Procedure} array-map! ra0 proc . lra +@deffnx {Scheme Procedure} array-map-in-order! ra0 proc . lra +@deffnx {C Function} scm_array_map_x (ra0, proc, lra) +@var{array1}, @dots{} must have the same number of dimensions as +@var{array0} and have a range for each index which includes the range +for the corresponding index in @var{array0}. @var{proc} is applied to +each tuple of elements of @var{array1} @dots{} and the result is stored +as the corresponding element in @var{array0}. The value returned is +unspecified. The order of application is unspecified. +@end deffn + +@deffn {Scheme Procedure} array-for-each proc ra0 . lra +@deffnx {C Function} scm_array_for_each (proc, ra0, lra) +Apply @var{proc} to each tuple of elements of @var{array0} @dots{} +in row-major order. The value returned is unspecified. +@end deffn + +@deffn {Scheme Procedure} array-index-map! ra proc +@deffnx {C Function} scm_array_index_map_x (ra, proc) +Apply @var{proc} to the indices of each element of @var{array} in +turn, storing the result in the corresponding element. The value +returned and the order of application are unspecified. + +One can implement @var{array-indexes} as +@lisp +(define (array-indexes array) + (let ((ra (apply make-array #f (array-shape array)))) + (array-index-map! ra (lambda x x)) + ra)) +@end lisp +Another example: +@lisp +(define (apl:index-generator n) + (let ((v (make-uniform-vector n 1))) + (array-index-map! v (lambda (i) i)) + v)) +@end lisp +@end deffn + +@node Uniform Arrays +@subsection Uniform Arrays +@tpindex Uniform Arrays + +@noindent +@dfn{Uniform arrays} have elements all of the +same type and occupy less storage than conventional +arrays. Uniform arrays with a single zero-based dimension +are also known as @dfn{uniform vectors}. The procedures in +this section can also be used on conventional arrays, vectors, +bit-vectors and strings. + +@noindent +When creating a uniform array, the type of data to be stored +is indicated with a @var{prototype} argument. The following table +lists the types available and example prototypes: + +@example +prototype type printing character + +#t boolean (bit-vector) b +#\a char (string) a +#\nul byte (integer) y +'s short (integer) h +1 unsigned long (integer) u +-1 signed long (integer) e +'l signed long long (integer) l +1.0 float (single precision) s +1/3 double (double precision float) i +0+i complex (double precision) c +() conventional vector +@end example + +@noindent +Unshared uniform arrays of characters with a single zero-based dimension +are identical to strings: + +@example +(make-uniform-array #\a 3) @result{} +"aaa" +@end example + +@noindent +Unshared uniform arrays of booleans with a single zero-based dimension +are identical to @ref{Bit Vectors, bit-vectors}. + +@example +(make-uniform-array #t 3) @result{} +#*111 +@end example + +@noindent +Other uniform vectors are written in a form similar to that of vectors, +except that a single character from the above table is put between +@code{#} and @code{(}. For example, a uniform vector of signed +long integers is displayed in the form @code{'#e(3 5 9)}. + +@deffn {Scheme Procedure} array? v [prot] +Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. + +The @var{prototype} argument is used with uniform arrays and is described +elsewhere. +@end deffn + +@deffn {Scheme Procedure} make-uniform-array prototype bound1 bound2 @dots{} +Create and return a uniform array of type corresponding to +@var{prototype} that has as many dimensions as there are @var{bound}s +and fill it with @var{prototype}. +@end deffn + +@deffn {Scheme Procedure} array-prototype ra +@deffnx {C Function} scm_array_prototype (ra) +Return an object that would produce an array of the same type +as @var{array}, if used as the @var{prototype} for +@code{make-uniform-array}. +@end deffn + +@deffn {Scheme Procedure} list->uniform-array ndim prot lst +@deffnx {Scheme Procedure} list->uniform-vector prot lst +@deffnx {C Function} scm_list_to_uniform_array (ndim, prot, lst) +Return a uniform array of the type indicated by prototype +@var{prot} with elements the same as those of @var{lst}. +Elements must be of the appropriate type, no coercions are +done. +@end deffn + +@deffn {Scheme Procedure} uniform-vector-fill! uve fill +Store @var{fill} in every element of @var{uve}. The value returned is +unspecified. +@end deffn + +@deffn {Scheme Procedure} uniform-vector-length v +@deffnx {C Function} scm_uniform_vector_length (v) +Return the number of elements in @var{uve}. +@end deffn + +@deffn {Scheme Procedure} dimensions->uniform-array dims prot [fill] +@deffnx {Scheme Procedure} make-uniform-vector length prototype [fill] +@deffnx {C Function} scm_dimensions_to_uniform_array (dims, prot, fill) +Create and return a uniform array or vector of type +corresponding to @var{prototype} with dimensions @var{dims} or +length @var{length}. If @var{fill} is supplied, it's used to +fill the array, otherwise @var{prototype} is used. +@end deffn + +@c Another compiled-closure. -twp + +@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]] +@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end] +@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end) +Attempt to read all elements of @var{ura}, in lexicographic order, as +binary objects from @var{port-or-fdes}. +If an end of file is encountered, +the objects up to that point are put into @var{ura} +(starting at the beginning) and the remainder of the array is +unchanged. + +The optional arguments @var{start} and @var{end} allow +a specified region of a vector (or linearized array) to be read, +leaving the remainder of the vector unchanged. + +@code{uniform-array-read!} returns the number of objects read. +@var{port-or-fdes} may be omitted, in which case it defaults to the value +returned by @code{(current-input-port)}. +@end deffn + +@deffn {Scheme Procedure} uniform-array-write v [port_or_fd [start [end]]] +@deffnx {Scheme Procedure} uniform-vector-write uve [port-or-fdes] [start] [end] +@deffnx {C Function} scm_uniform_array_write (v, port_or_fd, start, end) +Writes all elements of @var{ura} as binary objects to +@var{port-or-fdes}. + +The optional arguments @var{start} +and @var{end} allow +a specified region of a vector (or linearized array) to be written. + +The number of objects actually written is returned. +@var{port-or-fdes} may be +omitted, in which case it defaults to the value returned by +@code{(current-output-port)}. +@end deffn + +@node Bit Vectors +@subsection Bit Vectors + +@noindent +Bit vectors are a specific type of uniform array: an array of booleans +with a single zero-based index. + +@noindent +They are displayed as a sequence of @code{0}s and +@code{1}s prefixed by @code{#*}, e.g., + +@example +(make-uniform-vector 8 #t #f) @result{} +#*00000000 + +#b(#t #f #t) @result{} +#*101 +@end example + +@deffn {Scheme Procedure} bit-count b bitvector +@deffnx {C Function} scm_bit_count (b, bitvector) +Return the number of occurrences of the boolean @var{b} in +@var{bitvector}. +@end deffn + +@deffn {Scheme Procedure} bit-position item v k +@deffnx {C Function} scm_bit_position (item, v, k) +Return the minimum index of an occurrence of @var{bool} in +@var{bv} which is at least @var{k}. If no @var{bool} occurs +within the specified range @code{#f} is returned. +@end deffn + +@deffn {Scheme Procedure} bit-invert! v +@deffnx {C Function} scm_bit_invert_x (v) +Modify @var{bv} by replacing each element with its negation. +@end deffn + +@deffn {Scheme Procedure} bit-set*! v kv obj +@deffnx {C Function} scm_bit_set_star_x (v, kv, obj) +If uve is a bit-vector @var{bv} and uve must be of the same +length. If @var{bool} is @code{#t}, uve is OR'ed into +@var{bv}; If @var{bool} is @code{#f}, the inversion of uve is +AND'ed into @var{bv}. + +If uve is a unsigned long integer vector all the elements of uve +must be between 0 and the @code{length} of @var{bv}. The bits +of @var{bv} corresponding to the indexes in uve are set to +@var{bool}. The return value is unspecified. +@end deffn + +@deffn {Scheme Procedure} bit-count* v kv obj +@deffnx {C Function} scm_bit_count_star (v, kv, obj) +Return +@lisp +(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t). +@end lisp +@var{bv} is not modified. +@end deffn + + +@node Association Lists and Hash Tables +@section Association Lists and Hash Tables + +This chapter discusses dictionary objects: data structures that are +useful for organizing and indexing large bodies of information. + +@menu +* Dictionary Types:: About dictionary types; what they're good for. +* Association Lists:: List-based dictionaries. +* Hash Tables:: Table-based dictionaries. +@end menu + +@node Dictionary Types +@subsection Dictionary Types + +A @dfn{dictionary} object is a data structure used to index +information in a user-defined way. In standard Scheme, the main +aggregate data types are lists and vectors. Lists are not really +indexed at all, and vectors are indexed only by number +(e.g. @code{(vector-ref foo 5)}). Often you will find it useful +to index your data on some other type; for example, in a library +catalog you might want to look up a book by the name of its +author. Dictionaries are used to help you organize information in +such a way. + +An @dfn{association list} (or @dfn{alist} for short) is a list of +key-value pairs. Each pair represents a single quantity or +object; the @code{car} of the pair is a key which is used to +identify the object, and the @code{cdr} is the object's value. + +A @dfn{hash table} also permits you to index objects with +arbitrary keys, but in a way that makes looking up any one object +extremely fast. A well-designed hash system makes hash table +lookups almost as fast as conventional array or vector references. + +Alists are popular among Lisp programmers because they use only +the language's primitive operations (lists, @dfn{car}, @dfn{cdr} +and the equality primitives). No changes to the language core are +necessary. Therefore, with Scheme's built-in list manipulation +facilities, it is very convenient to handle data stored in an +association list. Also, alists are highly portable and can be +easily implemented on even the most minimal Lisp systems. + +However, alists are inefficient, especially for storing large +quantities of data. Because we want Guile to be useful for large +software systems as well as small ones, Guile provides a rich set +of tools for using either association lists or hash tables. + +@node Association Lists +@subsection Association Lists +@tpindex Association Lists +@tpindex Alist + +@cindex Association List +@cindex Alist +@cindex Database + +An association list is a conventional data structure that is often used +to implement simple key-value databases. It consists of a list of +entries in which each entry is a pair. The @dfn{key} of each entry is +the @code{car} of the pair and the @dfn{value} of each entry is the +@code{cdr}. + +@example +ASSOCIATION LIST ::= '( (KEY1 . VALUE1) + (KEY2 . VALUE2) + (KEY3 . VALUE3) + @dots{} + ) +@end example + +@noindent +Association lists are also known, for short, as @dfn{alists}. + +The structure of an association list is just one example of the infinite +number of possible structures that can be built using pairs and lists. +As such, the keys and values in an association list can be manipulated +using the general list structure procedures @code{cons}, @code{car}, +@code{cdr}, @code{set-car!}, @code{set-cdr!} and so on. However, +because association lists are so useful, Guile also provides specific +procedures for manipulating them. + +@menu +* Alist Key Equality:: +* Adding or Setting Alist Entries:: +* Retrieving Alist Entries:: +* Removing Alist Entries:: +* Sloppy Alist Functions:: +* Alist Example:: +@end menu + +@node Alist Key Equality +@subsubsection Alist Key Equality + +All of Guile's dedicated association list procedures, apart from +@code{acons}, come in three flavours, depending on the level of equality +that is required to decide whether an existing key in the association +list is the same as the key that the procedure call uses to identify the +required entry. + +@itemize @bullet +@item +Procedures with @dfn{assq} in their name use @code{eq?} to determine key +equality. + +@item +Procedures with @dfn{assv} in their name use @code{eqv?} to determine +key equality. + +@item +Procedures with @dfn{assoc} in their name use @code{equal?} to +determine key equality. +@end itemize + +@code{acons} is an exception because it is used to build association +lists which do not require their entries' keys to be unique. + +@node Adding or Setting Alist Entries +@subsubsection Adding or Setting Alist Entries + +@code{acons} adds a new entry to an association list and returns the +combined association list. The combined alist is formed by consing the +new entry onto the head of the alist specified in the @code{acons} +procedure call. So the specified alist is not modified, but its +contents become shared with the tail of the combined alist that +@code{acons} returns. + +In the most common usage of @code{acons}, a variable holding the +original association list is updated with the combined alist: + +@example +(set! address-list (acons name address address-list)) +@end example + +In such cases, it doesn't matter that the old and new values of +@code{address-list} share some of their contents, since the old value is +usually no longer independently accessible. + +Note that @code{acons} adds the specified new entry regardless of +whether the alist may already contain entries with keys that are, in +some sense, the same as that of the new entry. Thus @code{acons} is +ideal for building alists where there is no concept of key uniqueness. + +@example +(set! task-list (acons 3 "pay gas bill" '())) +task-list +@result{} +((3 . "pay gas bill")) + +(set! task-list (acons 3 "tidy bedroom" task-list)) +task-list +@result{} +((3 . "tidy bedroom") (3 . "pay gas bill")) +@end example + +@code{assq-set!}, @code{assv-set!} and @code{assoc-set!} are used to add +or replace an entry in an association list where there @emph{is} a +concept of key uniqueness. If the specified association list already +contains an entry whose key is the same as that specified in the +procedure call, the existing entry is replaced by the new one. +Otherwise, the new entry is consed onto the head of the old association +list to create the combined alist. In all cases, these procedures +return the combined alist. + +@code{assq-set!} and friends @emph{may} destructively modify the +structure of the old association list in such a way that an existing +variable is correctly updated without having to @code{set!} it to the +value returned: + +@example +address-list +@result{} +(("mary" . "34 Elm Road") ("james" . "16 Bow Street")) + +(assoc-set! address-list "james" "1a London Road") +@result{} +(("mary" . "34 Elm Road") ("james" . "1a London Road")) + +address-list +@result{} +(("mary" . "34 Elm Road") ("james" . "1a London Road")) +@end example + +Or they may not: + +@example +(assoc-set! address-list "bob" "11 Newington Avenue") +@result{} +(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road") + ("james" . "1a London Road")) + +address-list +@result{} +(("mary" . "34 Elm Road") ("james" . "1a London Road")) +@end example + +The only safe way to update an association list variable when adding or +replacing an entry like this is to @code{set!} the variable to the +returned value: + +@example +(set! address-list + (assoc-set! address-list "bob" "11 Newington Avenue")) +address-list +@result{} +(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road") + ("james" . "1a London Road")) +@end example + +Because of this slight inconvenience, you may find it more convenient to +use hash tables to store dictionary data. If your application will not +be modifying the contents of an alist very often, this may not make much +difference to you. + +If you need to keep the old value of an association list in a form +independent from the list that results from modification by +@code{acons}, @code{assq-set!}, @code{assv-set!} or @code{assoc-set!}, +use @code{list-copy} to copy the old association list before modifying +it. + +@deffn {Scheme Procedure} acons key value alist +@deffnx {C Function} scm_acons (key, value, alist) +Add a new key-value pair to @var{alist}. A new pair is +created whose car is @var{key} and whose cdr is @var{value}, and the +pair is consed onto @var{alist}, and the new list is returned. This +function is @emph{not} destructive; @var{alist} is not modified. +@end deffn + +@deffn {Scheme Procedure} assq-set! alist key val +@deffnx {Scheme Procedure} assv-set! alist key value +@deffnx {Scheme Procedure} assoc-set! alist key value +@deffnx {C Function} scm_assq_set_x (alist, key, val) +@deffnx {C Function} scm_assv_set_x (alist, key, val) +@deffnx {C Function} scm_assoc_set_x (alist, key, val) +Reassociate @var{key} in @var{alist} with @var{value}: find any existing +@var{alist} entry for @var{key} and associate it with the new +@var{value}. If @var{alist} does not contain an entry for @var{key}, +add a new one. Return the (possibly new) alist. + +These functions do not attempt to verify the structure of @var{alist}, +and so may cause unusual results if passed an object that is not an +association list. +@end deffn + +@node Retrieving Alist Entries +@subsubsection Retrieving Alist Entries +@rnindex assq +@rnindex assv +@rnindex assoc + +@code{assq}, @code{assv} and @code{assoc} take an alist and a key as +arguments and return the entry for that key if an entry exists, or +@code{#f} if there is no entry for that key. Note that, in the cases +where an entry exists, these procedures return the complete entry, that +is @code{(KEY . VALUE)}, not just the value. + +@deffn {Scheme Procedure} assq key alist +@deffnx {Scheme Procedure} assv key alist +@deffnx {Scheme Procedure} assoc key alist +@deffnx {C Function} scm_assq (key, alist) +@deffnx {C Function} scm_assv (key, alist) +@deffnx {C Function} scm_assoc (key, alist) +Fetch the entry in @var{alist} that is associated with @var{key}. To +decide whether the argument @var{key} matches a particular entry in +@var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv} +uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key} +cannot be found in @var{alist} (according to whichever equality +predicate is in use), then return @code{#f}. These functions +return the entire alist entry found (i.e. both the key and the value). +@end deffn + +@code{assq-ref}, @code{assv-ref} and @code{assoc-ref}, on the other +hand, take an alist and a key and return @emph{just the value} for that +key, if an entry exists. If there is no entry for the specified key, +these procedures return @code{#f}. + +This creates an ambiguity: if the return value is @code{#f}, it means +either that there is no entry with the specified key, or that there +@emph{is} an entry for the specified key, with value @code{#f}. +Consequently, @code{assq-ref} and friends should only be used where it +is known that an entry exists, or where the ambiguity doesn't matter +for some other reason. + +@deffn {Scheme Procedure} assq-ref alist key +@deffnx {Scheme Procedure} assv-ref alist key +@deffnx {Scheme Procedure} assoc-ref alist key +@deffnx {C Function} scm_assq_ref (alist, key) +@deffnx {C Function} scm_assv_ref (alist, key) +@deffnx {C Function} scm_assoc_ref (alist, key) +Like @code{assq}, @code{assv} and @code{assoc}, except that only the +value associated with @var{key} in @var{alist} is returned. These +functions are equivalent to + +@lisp +(let ((ent (@var{associator} @var{key} @var{alist}))) + (and ent (cdr ent))) +@end lisp + +where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}. +@end deffn + +@node Removing Alist Entries +@subsubsection Removing Alist Entries + +To remove the element from an association list whose key matches a +specified key, use @code{assq-remove!}, @code{assv-remove!} or +@code{assoc-remove!} (depending, as usual, on the level of equality +required between the key that you specify and the keys in the +association list). + +As with @code{assq-set!} and friends, the specified alist may or may not +be modified destructively, and the only safe way to update a variable +containing the alist is to @code{set!} it to the value that +@code{assq-remove!} and friends return. + +@example +address-list +@result{} +(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road") + ("james" . "1a London Road")) + +(set! address-list (assoc-remove! address-list "mary")) +address-list +@result{} +(("bob" . "11 Newington Avenue") ("james" . "1a London Road")) +@end example + +Note that, when @code{assq/v/oc-remove!} is used to modify an +association list that has been constructed only using the corresponding +@code{assq/v/oc-set!}, there can be at most one matching entry in the +alist, so the question of multiple entries being removed in one go does +not arise. If @code{assq/v/oc-remove!} is applied to an association +list that has been constructed using @code{acons}, or an +@code{assq/v/oc-set!} with a different level of equality, or any mixture +of these, it removes only the first matching entry from the alist, even +if the alist might contain further matching entries. For example: + +@example +(define address-list '()) +(set! address-list (assq-set! address-list "mary" "11 Elm Street")) +(set! address-list (assq-set! address-list "mary" "57 Pine Drive")) +address-list +@result{} +(("mary" . "57 Pine Drive") ("mary" . "11 Elm Street")) + +(set! address-list (assoc-remove! address-list "mary")) +address-list +@result{} +(("mary" . "11 Elm Street")) +@end example + +In this example, the two instances of the string "mary" are not the same +when compared using @code{eq?}, so the two @code{assq-set!} calls add +two distinct entries to @code{address-list}. When compared using +@code{equal?}, both "mary"s in @code{address-list} are the same as the +"mary" in the @code{assoc-remove!} call, but @code{assoc-remove!} stops +after removing the first matching entry that it finds, and so one of the +"mary" entries is left in place. + +@deffn {Scheme Procedure} assq-remove! alist key +@deffnx {Scheme Procedure} assv-remove! alist key +@deffnx {Scheme Procedure} assoc-remove! alist key +@deffnx {C Function} scm_assq_remove_x (alist, key) +@deffnx {C Function} scm_assv_remove_x (alist, key) +@deffnx {C Function} scm_assoc_remove_x (alist, key) +Delete the first entry in @var{alist} associated with @var{key}, and return +the resulting alist. +@end deffn + +@node Sloppy Alist Functions +@subsubsection Sloppy Alist Functions + +@code{sloppy-assq}, @code{sloppy-assv} and @code{sloppy-assoc} behave +like the corresponding non-@code{sloppy-} procedures, except that they +return @code{#f} when the specified association list is not well-formed, +where the non-@code{sloppy-} versions would signal an error. + +Specifically, there are two conditions for which the non-@code{sloppy-} +procedures signal an error, which the @code{sloppy-} procedures handle +instead by returning @code{#f}. Firstly, if the specified alist as a +whole is not a proper list: + +@example +(assoc "mary" '((1 . 2) ("key" . "door") . "open sesame")) +@result{} +ERROR: In procedure assoc in expression (assoc "mary" (quote #)): +ERROR: Wrong type argument in position 2 (expecting NULLP): "open sesame" +ABORT: (wrong-type-arg) + +(sloppy-assoc "mary" '((1 . 2) ("key" . "door") . "open sesame")) +@result{} +#f +@end example + +@noindent +Secondly, if one of the entries in the specified alist is not a pair: + +@example +(assoc 2 '((1 . 1) 2 (3 . 9))) +@result{} +ERROR: In procedure assoc in expression (assoc 2 (quote #)): +ERROR: Wrong type argument in position 2 (expecting CONSP): 2 +ABORT: (wrong-type-arg) + +(sloppy-assoc 2 '((1 . 1) 2 (3 . 9))) +@result{} +#f +@end example + +Unless you are explicitly working with badly formed association lists, +it is much safer to use the non-@code{sloppy-} procedures, because they +help to highlight coding and data errors that the @code{sloppy-} +versions would silently cover up. + +@deffn {Scheme Procedure} sloppy-assq key alist +@deffnx {C Function} scm_sloppy_assq (key, alist) +Behaves like @code{assq} but does not do any error checking. +Recommended only for use in Guile internals. +@end deffn + +@deffn {Scheme Procedure} sloppy-assv key alist +@deffnx {C Function} scm_sloppy_assv (key, alist) +Behaves like @code{assv} but does not do any error checking. +Recommended only for use in Guile internals. +@end deffn + +@deffn {Scheme Procedure} sloppy-assoc key alist +@deffnx {C Function} scm_sloppy_assoc (key, alist) +Behaves like @code{assoc} but does not do any error checking. +Recommended only for use in Guile internals. +@end deffn + +@node Alist Example +@subsubsection Alist Example + +Here is a longer example of how alists may be used in practice. + +@lisp +(define capitals '(("New York" . "Albany") + ("Oregon" . "Salem") + ("Florida" . "Miami"))) + +;; What's the capital of Oregon? +(assoc "Oregon" capitals) @result{} ("Oregon" . "Salem") +(assoc-ref capitals "Oregon") @result{} "Salem" + +;; We left out South Dakota. +(set! capitals + (assoc-set! capitals "South Dakota" "Bismarck")) +capitals +@result{} (("South Dakota" . "Bismarck") + ("New York" . "Albany") + ("Oregon" . "Salem") + ("Florida" . "Miami")) + +;; And we got Florida wrong. +(set! capitals + (assoc-set! capitals "Florida" "Tallahassee")) +capitals +@result{} (("South Dakota" . "Bismarck") + ("New York" . "Albany") + ("Oregon" . "Salem") + ("Florida" . "Tallahassee")) + +;; After Oregon secedes, we can remove it. +(set! capitals + (assoc-remove! capitals "Oregon")) +capitals +@result{} (("South Dakota" . "Bismarck") + ("New York" . "Albany") + ("Florida" . "Tallahassee")) +@end lisp + +@node Hash Tables +@subsection Hash Tables +@tpindex Hash Tables + +@c FIXME::martin: Review me! + +Hash tables are dictionaries which offer similar functionality as +association lists: They provide a mapping from keys to values. The +difference is that association lists need time linear in the size of +elements when searching for entries, whereas hash tables can normally +search in constant time. The drawback is that hash tables require a +little bit more memory, and that you can not use the normal list +procedures (@pxref{Lists}) for working with them. + +@menu +* Hash Table Examples:: Demonstration of hash table usage. +* Hash Table Reference:: Hash table procedure descriptions. +@end menu + + +@node Hash Table Examples +@subsubsection Hash Table Examples + +@c FIXME::martin: Review me! + +For demonstration purposes, this section gives a few usage examples of +some hash table procedures, together with some explanation what they do. + +First we start by creating a new hash table with 31 slots, and +populate it with two key/value pairs. + +@lisp +(define h (make-hash-table 31)) + +(hashq-create-handle! h 'foo "bar") +@result{} +(foo . "bar") + +(hashq-create-handle! h 'braz "zonk") +@result{} +(braz . "zonk") + +(hashq-create-handle! h 'frob #f) +@result{} +(frob . #f) +@end lisp + +You can get the value for a given key with the procedure +@code{hashq-ref}, but the problem with this procedure is that you +cannot reliably determine whether a key does exists in the table. The +reason is that the procedure returns @code{#f} if the key is not in +the table, but it will return the same value if the key is in the +table and just happens to have the value @code{#f}, as you can see in +the following examples. + +@lisp +(hashq-ref h 'foo) +@result{} +"bar" + +(hashq-ref h 'frob) +@result{} +#f + +(hashq-ref h 'not-there) +@result{} +#f +@end lisp + +Better is to use the procedure @code{hashq-get-handle}, which makes a +distinction between the two cases. Just like @code{assq}, this +procedure returns a key/value-pair on success, and @code{#f} if the +key is not found. + +@lisp +(hashq-get-handle h 'foo) +@result{} +(foo . "bar") + +(hashq-get-handle h 'not-there) +@result{} +#f +@end lisp + +There is no procedure for calculating the number of key/value-pairs in +a hash table, but @code{hash-fold} can be used for doing exactly that. + +@lisp +(hash-fold (lambda (key value seed) (+ 1 seed)) 0 h) +@result{} +3 +@end lisp + +@node Hash Table Reference +@subsubsection Hash Table Reference + +Like the association list functions, the hash table functions come +in several varieties: @code{hashq}, @code{hashv}, and @code{hash}. +The @code{hashq} functions use @code{eq?} to determine whether two +keys match. The @code{hashv} functions use @code{eqv?}, and the +@code{hash} functions use @code{equal?}. + +In each of the functions that follow, the @var{table} argument +must be a vector. The @var{key} and @var{value} arguments may be +any Scheme object. + +@deffn {Scheme Procedure} make-hash-table size +Create a new hash table of @var{size} slots. Note that the number of +slots does not limit the size of the table, it just tells how large +the underlying vector will be. The @var{size} should be similar to +the expected number of elements which will be added to the table, but +they need not match. For good performance, it might be a good idea to +use a prime number as the @var{size}. +@end deffn + +@deffn {Scheme Procedure} hashq-ref table key [dflt] +@deffnx {C Function} scm_hashq_ref (table, key, dflt) +Look up @var{key} in the hash table @var{table}, and return the +value (if any) associated with it. If @var{key} is not found, +return @var{default} (or @code{#f} if no @var{default} argument +is supplied). Uses @code{eq?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hashv-ref table key [dflt] +@deffnx {C Function} scm_hashv_ref (table, key, dflt) +Look up @var{key} in the hash table @var{table}, and return the +value (if any) associated with it. If @var{key} is not found, +return @var{default} (or @code{#f} if no @var{default} argument +is supplied). Uses @code{eqv?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hash-ref table key [dflt] +@deffnx {C Function} scm_hash_ref (table, key, dflt) +Look up @var{key} in the hash table @var{table}, and return the +value (if any) associated with it. If @var{key} is not found, +return @var{default} (or @code{#f} if no @var{default} argument +is supplied). Uses @code{equal?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hashq-set! table key val +@deffnx {C Function} scm_hashq_set_x (table, key, val) +Find the entry in @var{table} associated with @var{key}, and +store @var{value} there. Uses @code{eq?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hashv-set! table key val +@deffnx {C Function} scm_hashv_set_x (table, key, val) +Find the entry in @var{table} associated with @var{key}, and +store @var{value} there. Uses @code{eqv?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hash-set! table key val +@deffnx {C Function} scm_hash_set_x (table, key, val) +Find the entry in @var{table} associated with @var{key}, and +store @var{value} there. Uses @code{equal?} for equality +testing. +@end deffn + +@deffn {Scheme Procedure} hashq-remove! table key +@deffnx {C Function} scm_hashq_remove_x (table, key) +Remove @var{key} (and any value associated with it) from +@var{table}. Uses @code{eq?} for equality tests. +@end deffn + +@deffn {Scheme Procedure} hashv-remove! table key +@deffnx {C Function} scm_hashv_remove_x (table, key) +Remove @var{key} (and any value associated with it) from +@var{table}. Uses @code{eqv?} for equality tests. +@end deffn + +@deffn {Scheme Procedure} hash-remove! table key +@deffnx {C Function} scm_hash_remove_x (table, key) +Remove @var{key} (and any value associated with it) from +@var{table}. Uses @code{equal?} for equality tests. +@end deffn + +The standard hash table functions may be too limited for some +applications. For example, you may want a hash table to store +strings in a case-insensitive manner, so that references to keys +named ``foobar'', ``FOOBAR'' and ``FooBaR'' will all yield the +same item. Guile provides you with @dfn{extended} hash tables +that permit you to specify a hash function and associator function +of your choosing. The functions described in the rest of this section +can be used to implement such custom hash table structures. + +If you are unfamiliar with the inner workings of hash tables, then +this facility will probably be a little too abstract for you to +use comfortably. If you are interested in learning more, see an +introductory textbook on data structures or algorithms for an +explanation of how hash tables are implemented. + +@deffn {Scheme Procedure} hashq key size +@deffnx {C Function} scm_hashq (key, size) +Determine a hash value for @var{key} that is suitable for +lookups in a hashtable of size @var{size}, where @code{eq?} is +used as the equality predicate. The function returns an +integer in the range 0 to @var{size} - 1. Note that +@code{hashq} may use internal addresses. Thus two calls to +hashq where the keys are @code{eq?} are not guaranteed to +deliver the same value if the key object gets garbage collected +in between. This can happen, for example with symbols: +@code{(hashq 'foo n) (gc) (hashq 'foo n)} may produce two +different values, since @code{foo} will be garbage collected. +@end deffn + +@deffn {Scheme Procedure} hashv key size +@deffnx {C Function} scm_hashv (key, size) +Determine a hash value for @var{key} that is suitable for +lookups in a hashtable of size @var{size}, where @code{eqv?} is +used as the equality predicate. The function returns an +integer in the range 0 to @var{size} - 1. Note that +@code{(hashv key)} may use internal addresses. Thus two calls +to hashv where the keys are @code{eqv?} are not guaranteed to +deliver the same value if the key object gets garbage collected +in between. This can happen, for example with symbols: +@code{(hashv 'foo n) (gc) (hashv 'foo n)} may produce two +different values, since @code{foo} will be garbage collected. +@end deffn + +@deffn {Scheme Procedure} hash key size +@deffnx {C Function} scm_hash (key, size) +Determine a hash value for @var{key} that is suitable for +lookups in a hashtable of size @var{size}, where @code{equal?} +is used as the equality predicate. The function returns an +integer in the range 0 to @var{size} - 1. +@end deffn + +@deffn {Scheme Procedure} hashx-ref hash assoc table key [dflt] +@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt) +This behaves the same way as the corresponding @code{ref} +function, but uses @var{hash} as a hash function and +@var{assoc} to compare keys. @code{hash} must be a function +that takes two arguments, a key to be hashed and a table size. +@code{assoc} must be an associator function, like @code{assoc}, +@code{assq} or @code{assv}. + +By way of illustration, @code{hashq-ref table key} is +equivalent to @code{hashx-ref hashq assq table key}. +@end deffn + +@deffn {Scheme Procedure} hashx-set! hash assoc table key val +@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val) +This behaves the same way as the corresponding @code{set!} +function, but uses @var{hash} as a hash function and +@var{assoc} to compare keys. @code{hash} must be a function +that takes two arguments, a key to be hashed and a table size. +@code{assoc} must be an associator function, like @code{assoc}, +@code{assq} or @code{assv}. + + By way of illustration, @code{hashq-set! table key} is +equivalent to @code{hashx-set! hashq assq table key}. +@end deffn + +@deffn {Scheme Procedure} hashq-get-handle table key +@deffnx {C Function} scm_hashq_get_handle (table, key) +This procedure returns the @code{(key . value)} pair from the +hash table @var{table}. If @var{table} does not hold an +associated value for @var{key}, @code{#f} is returned. +Uses @code{eq?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hashv-get-handle table key +@deffnx {C Function} scm_hashv_get_handle (table, key) +This procedure returns the @code{(key . value)} pair from the +hash table @var{table}. If @var{table} does not hold an +associated value for @var{key}, @code{#f} is returned. +Uses @code{eqv?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hash-get-handle table key +@deffnx {C Function} scm_hash_get_handle (table, key) +This procedure returns the @code{(key . value)} pair from the +hash table @var{table}. If @var{table} does not hold an +associated value for @var{key}, @code{#f} is returned. +Uses @code{equal?} for equality testing. +@end deffn + +@deffn {Scheme Procedure} hashx-get-handle hash assoc table key +@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key) +This behaves the same way as the corresponding +@code{-get-handle} function, but uses @var{hash} as a hash +function and @var{assoc} to compare keys. @code{hash} must be +a function that takes two arguments, a key to be hashed and a +table size. @code{assoc} must be an associator function, like +@code{assoc}, @code{assq} or @code{assv}. +@end deffn + +@deffn {Scheme Procedure} hashq-create-handle! table key init +@deffnx {C Function} scm_hashq_create_handle_x (table, key, init) +This function looks up @var{key} in @var{table} and returns its handle. +If @var{key} is not already present, a new handle is created which +associates @var{key} with @var{init}. +@end deffn + +@deffn {Scheme Procedure} hashv-create-handle! table key init +@deffnx {C Function} scm_hashv_create_handle_x (table, key, init) +This function looks up @var{key} in @var{table} and returns its handle. +If @var{key} is not already present, a new handle is created which +associates @var{key} with @var{init}. +@end deffn + +@deffn {Scheme Procedure} hash-create-handle! table key init +@deffnx {C Function} scm_hash_create_handle_x (table, key, init) +This function looks up @var{key} in @var{table} and returns its handle. +If @var{key} is not already present, a new handle is created which +associates @var{key} with @var{init}. +@end deffn + +@deffn {Scheme Procedure} hashx-create-handle! hash assoc table key init +@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init) +This behaves the same way as the corresponding +@code{-create-handle} function, but uses @var{hash} as a hash +function and @var{assoc} to compare keys. @code{hash} must be +a function that takes two arguments, a key to be hashed and a +table size. @code{assoc} must be an associator function, like +@code{assoc}, @code{assq} or @code{assv}. +@end deffn + +@deffn {Scheme Procedure} hash-fold proc init table +@deffnx {C Function} scm_hash_fold (proc, init, table) +An iterator over hash-table elements. +Accumulates and returns a result by applying PROC successively. +The arguments to PROC are "(key value prior-result)" where key +and value are successive pairs from the hash table TABLE, and +prior-result is either INIT (for the first application of PROC) +or the return value of the previous application of PROC. +For example, @code{(hash-fold acons '() tab)} will convert a hash +table into an a-list of key-value pairs. +@end deffn + + +@c Local Variables: +@c TeX-master: "guile.texi" +@c End: diff --git a/doc/ref/scheme-data.texi b/doc/ref/scheme-data.texi index 6ff70438b..bfed3bd4c 100755 --- a/doc/ref/scheme-data.texi +++ b/doc/ref/scheme-data.texi @@ -1,9 +1,13 @@ @page -@node Data Types -@chapter Data Types for Generic Use +@node Simple Data Types +@chapter Simple Generic Data Types -This chapter describes all the data types that Guile provides for -``generic use''. +This chapter describes those of Guile's simple data types which are +primarily are used for their role as items of generic data. By +@dfn{simple} we mean data types that are not primarily used as +containers to hold other data --- i.e. pairs, lists, vectors and so on. +For the documentation of such @dfn{compound} data types, see +@ref{Compound Data Types}. One of the great strengths of Scheme is that there is no straightforward distinction between ``data'' and ``functionality''. For example, @@ -22,24 +26,12 @@ module system. @end itemize The contents of this chapter are, therefore, a matter of judgement. By -``generic use'', we mean to select those data types whose typical use as +@dfn{generic}, we mean to select those data types whose typical use as @emph{data} in a wide variety of programming contexts is more important than their use in the implementation of a particular piece of -@emph{functionality}. - -@ifinfo -The following menu -@end ifinfo -@iftex -The table of contents for this chapter -@end iftex -@ifhtml -The following table of contents -@end ifhtml -shows the data types that are documented in this chapter. The final -section of this chapter lists all the core Guile data types that are not -documented here, and provides links to the ``functionality-centric'' -sections of this manual that cover them. +@emph{functionality}. The last section of this chapter provides +references for all the data types that are documented not here but in a +``functionality-centric'' way elsewhere in the manual. @menu * Booleans:: True/false values. @@ -49,15 +41,7 @@ sections of this manual that cover them. * Regular Expressions:: Pattern matching and substitution. * Symbols:: Symbols. * Keywords:: Self-quoting, customizable display keywords. -* Pairs:: Scheme's basic building block. -* Lists:: Special list functions supported by Guile. -* Vectors:: One-dimensional arrays of Scheme objects. -* Records:: -* Structures:: -* Arrays:: Arrays of values. -* Association Lists and Hash Tables:: Dictionary data types. -* Hooks:: User-customizable event lists. -* Other Data Types:: Data types that are documented elsewhere. +* Other Types:: "Functionality-centric" data types. @end menu @@ -2639,2561 +2623,24 @@ Return the dash symbol for @var{keyword}. This is the inverse of @code{make-keyword-from-dash-symbol}. @end deffn -@node Pairs -@section Pairs -@tpindex Pairs -@c FIXME::martin: Review me! +@node Other Types +@section ``Functionality-Centric'' Data Types -Pairs are used to combine two Scheme objects into one compound object. -Hence the name: A pair stores a pair of objects. +Procedures and macros are documented in their own chapter: see +@ref{Procedures and Macros}. -The data type @dfn{pair} is extremely important in Scheme, just like in -any other Lisp dialect. The reason is that pairs are not only used to -make two values available as one object, but that pairs are used for -constructing lists of values. Because lists are so important in Scheme, -they are described in a section of their own (@pxref{Lists}). +Variable objects are documented as part of the description of Guile's +module system: see @ref{Variables}. -Pairs can literally get entered in source code or at the REPL, in the -so-called @dfn{dotted list} syntax. This syntax consists of an opening -parentheses, the first element of the pair, a dot, the second element -and a closing parentheses. The following example shows how a pair -consisting of the two numbers 1 and 2, and a pair containing the symbols -@code{foo} and @code{bar} can be entered. It is very important to write -the whitespace before and after the dot, because otherwise the Scheme -parser whould not be able to figure out where to split the tokens. +Asyncs, dynamic roots and fluids are described in the chapter on +scheduling: see @ref{Scheduling}. -@lisp -(1 . 2) -(foo . bar) -@end lisp +Hooks are documented in the chapter on general utility functions: see +@ref{Hooks}. -But beware, if you want to try out these examples, you have to -@dfn{quote} the expressions. More information about quotation is -available in the section (REFFIXME). The correct way to try these -examples is as follows. +Ports are described in the chapter on I/O: see @ref{Input and Output}. -@lisp -'(1 . 2) -@result{} -(1 . 2) -'(foo . bar) -@result{} -(foo . bar) -@end lisp - -A new pair is made by calling the procedure @code{cons} with two -arguments. Then the argument values are stored into a newly allocated -pair, and the pair is returned. The name @code{cons} stands for -"construct". Use the procedure @code{pair?} to test whether a -given Scheme object is a pair or not. - -@rnindex cons -@deffn {Scheme Procedure} cons x y -@deffnx {C Function} scm_cons (x, y) -Return a newly allocated pair whose car is @var{x} and whose -cdr is @var{y}. The pair is guaranteed to be different (in the -sense of @code{eq?}) from every previously existing object. -@end deffn - -@rnindex pair? -@deffn {Scheme Procedure} pair? x -@deffnx {C Function} scm_pair_p (x) -Return @code{#t} if @var{x} is a pair; otherwise return -@code{#f}. -@end deffn - -The two parts of a pair are traditionally called @dfn{car} and -@dfn{cdr}. They can be retrieved with procedures of the same name -(@code{car} and @code{cdr}), and can be modified with the procedures -@code{set-car!} and @code{set-cdr!}. Since a very common operation in -Scheme programs is to access the car of a pair, or the car of the cdr of -a pair, etc., the procedures called @code{caar}, @code{cadr} and so on -are also predefined. - -@rnindex car -@rnindex cdr -@deffn {Scheme Procedure} car pair -@deffnx {Scheme Procedure} cdr pair -Return the car or the cdr of @var{pair}, respectively. -@end deffn - -@deffn {Scheme Procedure} caar pair -@deffnx {Scheme Procedure} cadr pair @dots{} -@deffnx {Scheme Procedure} cdddar pair -@deffnx {Scheme Procedure} cddddr pair -These procedures are compositions of @code{car} and @code{cdr}, where -for example @code{caddr} could be defined by - -@lisp -(define caddr (lambda (x) (car (cdr (cdr x))))) -@end lisp -@end deffn - -@rnindex set-car! -@deffn {Scheme Procedure} set-car! pair value -@deffnx {C Function} scm_set_car_x (pair, value) -Stores @var{value} in the car field of @var{pair}. The value returned -by @code{set-car!} is unspecified. -@end deffn - -@rnindex set-cdr! -@deffn {Scheme Procedure} set-cdr! pair value -@deffnx {C Function} scm_set_cdr_x (pair, value) -Stores @var{value} in the cdr field of @var{pair}. The value returned -by @code{set-cdr!} is unspecified. -@end deffn - - -@node Lists -@section Lists -@tpindex Lists - -@c FIXME::martin: Review me! - -A very important data type in Scheme---as well as in all other Lisp -dialects---is the data type @dfn{list}.@footnote{Strictly speaking, -Scheme does not have a real datatype @dfn{list}. Lists are made up of -@dfn{chained pairs}, and only exist by definition---a list is a chain -of pairs which looks like a list.} - -This is the short definition of what a list is: - -@itemize @bullet -@item -Either the empty list @code{()}, - -@item -or a pair which has a list in its cdr. -@end itemize - -@c FIXME::martin: Describe the pair chaining in more detail. - -@c FIXME::martin: What is a proper, what an improper list? -@c What is a circular list? - -@c FIXME::martin: Maybe steal some graphics from the Elisp reference -@c manual? - -@menu -* List Syntax:: Writing literal lists. -* List Predicates:: Testing lists. -* List Constructors:: Creating new lists. -* List Selection:: Selecting from lists, getting their length. -* Append/Reverse:: Appending and reversing lists. -* List Modification:: Modifying existing lists. -* List Searching:: Searching for list elements -* List Mapping:: Applying procedures to lists. -@end menu - -@node List Syntax -@subsection List Read Syntax - -@c FIXME::martin: Review me! - -The syntax for lists is an opening parentheses, then all the elements of -the list (separated by whitespace) and finally a closing -parentheses.@footnote{Note that there is no separation character between -the list elements, like a comma or a semicolon.}. - -@lisp -(1 2 3) ; @r{a list of the numbers 1, 2 and 3} -("foo" bar 3.1415) ; @r{a string, a symbol and a real number} -() ; @r{the empty list} -@end lisp - -The last example needs a bit more explanation. A list with no elements, -called the @dfn{empty list}, is special in some ways. It is used for -terminating lists by storing it into the cdr of the last pair that makes -up a list. An example will clear that up: - -@lisp -(car '(1)) -@result{} -1 -(cdr '(1)) -@result{} -() -@end lisp - -This example also shows that lists have to be quoted (REFFIXME) when -written, because they would otherwise be mistakingly taken as procedure -applications (@pxref{Simple Invocation}). - - -@node List Predicates -@subsection List Predicates - -@c FIXME::martin: Review me! - -Often it is useful to test whether a given Scheme object is a list or -not. List-processing procedures could use this information to test -whether their input is valid, or they could do different things -depending on the datatype of their arguments. - -@rnindex list? -@deffn {Scheme Procedure} list? x -@deffnx {C Function} scm_list_p (x) -Return @code{#t} iff @var{x} is a proper list, else @code{#f}. -@end deffn - -The predicate @code{null?} is often used in list-processing code to -tell whether a given list has run out of elements. That is, a loop -somehow deals with the elements of a list until the list satisfies -@code{null?}. Then, the algorithm terminates. - -@rnindex null? -@deffn {Scheme Procedure} null? x -@deffnx {C Function} scm_null_p (x) -Return @code{#t} iff @var{x} is the empty list, else @code{#f}. -@end deffn - -@node List Constructors -@subsection List Constructors - -This section describes the procedures for constructing new lists. -@code{list} simply returns a list where the elements are the arguments, -@code{cons*} is similar, but the last argument is stored in the cdr of -the last pair of the list. - -@rnindex list -@deffn {Scheme Procedure} list . objs -@deffnx {C Function} scm_list (objs) -Return a list containing @var{objs}, the arguments to -@code{list}. -@end deffn - -@deffn {Scheme Procedure} cons* arg1 arg2 @dots{} -@deffnx {C Function} scm_cons_star (arg1, rest) -Like @code{list}, but the last arg provides the tail of the -constructed list, returning @code{(cons @var{arg1} (cons -@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one -argument. If given one argument, that argument is returned as -result. This function is called @code{list*} in some other -Schemes and in Common LISP. -@end deffn - -@deffn {Scheme Procedure} list-copy lst -@deffnx {C Function} scm_list_copy (lst) -Return a (newly-created) copy of @var{lst}. -@end deffn - -@deffn {Scheme Procedure} make-list n [init] -Create a list containing of @var{n} elements, where each element is -initialized to @var{init}. @var{init} defaults to the empty list -@code{()} if not given. -@end deffn - -Note that @code{list-copy} only makes a copy of the pairs which make up -the spine of the lists. The list elements are not copied, which means -that modifying the elements of the new list also modyfies the elements -of the old list. On the other hand, applying procedures like -@code{set-cdr!} or @code{delv!} to the new list will not alter the old -list. If you also need to copy the list elements (making a deep copy), -use the procedure @code{copy-tree} (@pxref{Copying}). - -@node List Selection -@subsection List Selection - -@c FIXME::martin: Review me! - -These procedures are used to get some information about a list, or to -retrieve one or more elements of a list. - -@rnindex length -@deffn {Scheme Procedure} length lst -@deffnx {C Function} scm_length (lst) -Return the number of elements in list @var{lst}. -@end deffn - -@deffn {Scheme Procedure} last-pair lst -@deffnx {C Function} scm_last_pair (lst) -Return a pointer to the last pair in @var{lst}, signalling an error if -@var{lst} is circular. -@end deffn - -@rnindex list-ref -@deffn {Scheme Procedure} list-ref list k -@deffnx {C Function} scm_list_ref (list, k) -Return the @var{k}th element from @var{list}. -@end deffn - -@rnindex list-tail -@deffn {Scheme Procedure} list-tail lst k -@deffnx {Scheme Procedure} list-cdr-ref lst k -@deffnx {C Function} scm_list_tail (lst, k) -Return the "tail" of @var{lst} beginning with its @var{k}th element. -The first element of the list is considered to be element 0. - -@code{list-tail} and @code{list-cdr-ref} are identical. It may help to -think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list, -or returning the results of cdring @var{k} times down @var{lst}. -@end deffn - -@deffn {Scheme Procedure} list-head lst k -@deffnx {C Function} scm_list_head (lst, k) -Copy the first @var{k} elements from @var{lst} into a new list, and -return it. -@end deffn - -@node Append/Reverse -@subsection Append and Reverse - -@c FIXME::martin: Review me! - -@code{append} and @code{append!} are used to concatenate two or more -lists in order to form a new list. @code{reverse} and @code{reverse!} -return lists with the same elements as their arguments, but in reverse -order. The procedure variants with an @code{!} directly modify the -pairs which form the list, whereas the other procedures create new -pairs. This is why you should be careful when using the side-effecting -variants. - -@rnindex append -@deffn {Scheme Procedure} append . args -@deffnx {C Function} scm_append (args) -Return a list consisting of the elements the lists passed as -arguments. -@lisp -(append '(x) '(y)) @result{} (x y) -(append '(a) '(b c d)) @result{} (a b c d) -(append '(a (b)) '((c))) @result{} (a (b) (c)) -@end lisp -The resulting list is always newly allocated, except that it -shares structure with the last list argument. The last -argument may actually be any object; an improper list results -if the last argument is not a proper list. -@lisp -(append '(a b) '(c . d)) @result{} (a b c . d) -(append '() 'a) @result{} a -@end lisp -@end deffn - -@deffn {Scheme Procedure} append! . lists -@deffnx {C Function} scm_append_x (lists) -A destructive version of @code{append} (@pxref{Pairs and -Lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field -of each list's final pair is changed to point to the head of -the next list, so no consing is performed. Return a pointer to -the mutated list. -@end deffn - -@rnindex reverse -@deffn {Scheme Procedure} reverse lst -@deffnx {C Function} scm_reverse (lst) -Return a new list that contains the elements of @var{lst} but -in reverse order. -@end deffn - -@c NJFIXME explain new_tail -@deffn {Scheme Procedure} reverse! lst [new_tail] -@deffnx {C Function} scm_reverse_x (lst, new_tail) -A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r5rs, -The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is -modified to point to the previous list element. Return a pointer to the -head of the reversed list. - -Caveat: because the list is modified in place, the tail of the original -list now becomes its head, and the head of the original list now becomes -the tail. Therefore, the @var{lst} symbol to which the head of the -original list was bound now points to the tail. To ensure that the head -of the modified list is not lost, it is wise to save the return value of -@code{reverse!} -@end deffn - -@node List Modification -@subsection List Modification - -The following procedures modify an existing list, either by changing -elements of the list, or by changing the list structure itself. - -@deffn {Scheme Procedure} list-set! list k val -@deffnx {C Function} scm_list_set_x (list, k, val) -Set the @var{k}th element of @var{list} to @var{val}. -@end deffn - -@deffn {Scheme Procedure} list-cdr-set! list k val -@deffnx {C Function} scm_list_cdr_set_x (list, k, val) -Set the @var{k}th cdr of @var{list} to @var{val}. -@end deffn - -@deffn {Scheme Procedure} delq item lst -@deffnx {C Function} scm_delq (item, lst) -Return a newly-created copy of @var{lst} with elements -@code{eq?} to @var{item} removed. This procedure mirrors -@code{memq}: @code{delq} compares elements of @var{lst} against -@var{item} with @code{eq?}. -@end deffn - -@deffn {Scheme Procedure} delv item lst -@deffnx {C Function} scm_delv (item, lst) -Return a newly-created copy of @var{lst} with elements -@code{eqv?} to @var{item} removed. This procedure mirrors -@code{memv}: @code{delv} compares elements of @var{lst} against -@var{item} with @code{eqv?}. -@end deffn - -@deffn {Scheme Procedure} delete item lst -@deffnx {C Function} scm_delete (item, lst) -Return a newly-created copy of @var{lst} with elements -@code{equal?} to @var{item} removed. This procedure mirrors -@code{member}: @code{delete} compares elements of @var{lst} -against @var{item} with @code{equal?}. -@end deffn - -@deffn {Scheme Procedure} delq! item lst -@deffnx {Scheme Procedure} delv! item lst -@deffnx {Scheme Procedure} delete! item lst -@deffnx {C Function} scm_delq_x (item, lst) -@deffnx {C Function} scm_delv_x (item, lst) -@deffnx {C Function} scm_delete_x (item, lst) -These procedures are destructive versions of @code{delq}, @code{delv} -and @code{delete}: they modify the pointers in the existing @var{lst} -rather than creating a new list. Caveat evaluator: Like other -destructive list functions, these functions cannot modify the binding of -@var{lst}, and so cannot be used to delete the first element of -@var{lst} destructively. -@end deffn - -@deffn {Scheme Procedure} delq1! item lst -@deffnx {C Function} scm_delq1_x (item, lst) -Like @code{delq!}, but only deletes the first occurrence of -@var{item} from @var{lst}. Tests for equality using -@code{eq?}. See also @code{delv1!} and @code{delete1!}. -@end deffn - -@deffn {Scheme Procedure} delv1! item lst -@deffnx {C Function} scm_delv1_x (item, lst) -Like @code{delv!}, but only deletes the first occurrence of -@var{item} from @var{lst}. Tests for equality using -@code{eqv?}. See also @code{delq1!} and @code{delete1!}. -@end deffn - -@deffn {Scheme Procedure} delete1! item lst -@deffnx {C Function} scm_delete1_x (item, lst) -Like @code{delete!}, but only deletes the first occurrence of -@var{item} from @var{lst}. Tests for equality using -@code{equal?}. See also @code{delq1!} and @code{delv1!}. -@end deffn - -@node List Searching -@subsection List Searching - -@c FIXME::martin: Review me! - -The following procedures search lists for particular elements. They use -different comparison predicates for comparing list elements with the -object to be searched. When they fail, they return @code{#f}, otherwise -they return the sublist whose car is equal to the search object, where -equality depends on the equality predicate used. - -@rnindex memq -@deffn {Scheme Procedure} memq x lst -@deffnx {C Function} scm_memq (x, lst) -Return the first sublist of @var{lst} whose car is @code{eq?} -to @var{x} where the sublists of @var{lst} are the non-empty -lists returned by @code{(list-tail @var{lst} @var{k})} for -@var{k} less than the length of @var{lst}. If @var{x} does not -occur in @var{lst}, then @code{#f} (not the empty list) is -returned. -@end deffn - -@rnindex memv -@deffn {Scheme Procedure} memv x lst -@deffnx {C Function} scm_memv (x, lst) -Return the first sublist of @var{lst} whose car is @code{eqv?} -to @var{x} where the sublists of @var{lst} are the non-empty -lists returned by @code{(list-tail @var{lst} @var{k})} for -@var{k} less than the length of @var{lst}. If @var{x} does not -occur in @var{lst}, then @code{#f} (not the empty list) is -returned. -@end deffn - -@rnindex member -@deffn {Scheme Procedure} member x lst -@deffnx {C Function} scm_member (x, lst) -Return the first sublist of @var{lst} whose car is -@code{equal?} to @var{x} where the sublists of @var{lst} are -the non-empty lists returned by @code{(list-tail @var{lst} -@var{k})} for @var{k} less than the length of @var{lst}. If -@var{x} does not occur in @var{lst}, then @code{#f} (not the -empty list) is returned. -@end deffn - -[FIXME: Is there any reason to have the `sloppy' functions available at -high level at all? Maybe these docs should be relegated to a "Guile -Internals" node or something. -twp] - -@deffn {Scheme Procedure} sloppy-memq x lst -This procedure behaves like @code{memq}, but does no type or error checking. -Its use is recommended only in writing Guile internals, -not for high-level Scheme programs. -@end deffn - -@deffn {Scheme Procedure} sloppy-memv x lst -This procedure behaves like @code{memv}, but does no type or error checking. -Its use is recommended only in writing Guile internals, -not for high-level Scheme programs. -@end deffn - -@deffn {Scheme Procedure} sloppy-member x lst -This procedure behaves like @code{member}, but does no type or error checking. -Its use is recommended only in writing Guile internals, -not for high-level Scheme programs. -@end deffn - -@node List Mapping -@subsection List Mapping - -@c FIXME::martin: Review me! - -List processing is very convenient in Scheme because the process of -iterating over the elements of a list can be highly abstracted. The -procedures in this section are the most basic iterating procedures for -lists. They take a procedure and one or more lists as arguments, and -apply the procedure to each element of the list. They differ in their -return value. - -@rnindex map -@c begin (texi-doc-string "guile" "map") -@deffn {Scheme Procedure} map proc arg1 arg2 @dots{} -@deffnx {Scheme Procedure} map-in-order proc arg1 arg2 @dots{} -@deffnx {C Function} scm_map (proc, arg1, args) -Apply @var{proc} to each element of the list @var{arg1} (if only two -arguments are given), or to the corresponding elements of the argument -lists (if more than two arguments are given). The result(s) of the -procedure applications are saved and returned in a list. For -@code{map}, the order of procedure applications is not specified, -@code{map-in-order} applies the procedure from left to right to the list -elements. -@end deffn - -@rnindex for-each -@c begin (texi-doc-string "guile" "for-each") -@deffn {Scheme Procedure} for-each proc arg1 arg2 @dots{} -Like @code{map}, but the procedure is always applied from left to right, -and the result(s) of the procedure applications are thrown away. The -return value is not specified. -@end deffn - - -@node Vectors -@section Vectors -@tpindex Vectors - -@c FIXME::martin: Review me! - -@c FIXME::martin: Should the subsections of this section be nodes -@c of their own, or are the resulting nodes too short, then? - -Vectors are sequences of Scheme objects. Unlike lists, the length of a -vector, once the vector is created, cannot be changed. The advantage of -vectors over lists is that the time required to access one element of a vector -given its @dfn{position} (synonymous with @dfn{index}), a zero-origin number, -is constant, whereas lists have an access time linear to the position of the -accessed element in the list. - -Vectors can contain any kind of Scheme object; it is even possible to have -different types of objects in the same vector. For vectors containing -vectors, you may wish to use arrays, instead. Note, too, that some array -procedures operate happily on vectors (@pxref{Arrays}). - -@subsection Vector Read Syntax - -Vectors can literally be entered in source code, just like strings, -characters or some of the other data types. The read syntax for vectors -is as follows: A sharp sign (@code{#}), followed by an opening -parentheses, all elements of the vector in their respective read syntax, -and finally a closing parentheses. The following are examples of the -read syntax for vectors; where the first vector only contains numbers -and the second three different object types: a string, a symbol and a -number in hexadecimal notation. - -@lisp -#(1 2 3) -#("Hello" foo #xdeadbeef) -@end lisp - -@subsection Vector Predicates - -@rnindex vector? -@deffn {Scheme Procedure} vector? obj -@deffnx {C Function} scm_vector_p (obj) -Return @code{#t} if @var{obj} is a vector, otherwise return -@code{#f}. -@end deffn - -@subsection Vector Constructors - -@rnindex make-vector -@deffn {Scheme Procedure} make-vector k [fill] -@deffnx {C Function} scm_make_vector (k, fill) -Return a newly allocated vector of @var{k} elements. If a -second argument is given, then each position is initialized to -@var{fill}. Otherwise the initial contents of each position is -unspecified. -@end deffn - -@rnindex vector -@rnindex list->vector -@deffn {Scheme Procedure} vector . l -@deffnx {Scheme Procedure} list->vector l -@deffnx {C Function} scm_vector (l) -Return a newly allocated vector composed of the -given arguments. Analogous to @code{list}. - -@lisp -(vector 'a 'b 'c) @result{} #(a b c) -@end lisp -@end deffn - -@rnindex vector->list -@deffn {Scheme Procedure} vector->list v -@deffnx {C Function} scm_vector_to_list (v) -Return a newly allocated list composed of the elements of @var{v}. - -@lisp -(vector->list '#(dah dah didah)) @result{} (dah dah didah) -(list->vector '(dididit dah)) @result{} #(dididit dah) -@end lisp -@end deffn - -@subsection Vector Modification - -A vector created by any of the vector constructor procedures -(@pxref{Vectors}) documented above can be modified using the -following procedures. - -@emph{NOTE:} According to R5RS, using any of these procedures on -literally entered vectors is an error, because these vectors are -considered to be constant, although Guile currently does not detect this -error. - -@rnindex vector-set! -@deffn {Scheme Procedure} vector-set! vector k obj -Store @var{obj} in position @var{k} of @var{vector}. -@var{k} must be a valid index of @var{vector}. -The value returned by @samp{vector-set!} is unspecified. -@lisp -(let ((vec (vector 0 '(2 2 2 2) "Anna"))) - (vector-set! vec 1 '("Sue" "Sue")) - vec) @result{} #(0 ("Sue" "Sue") "Anna") -@end lisp -@end deffn - -@rnindex vector-fill! -@deffn {Scheme Procedure} vector-fill! v fill -@deffnx {C Function} scm_vector_fill_x (v, fill) -Store @var{fill} in every position of @var{vector}. The value -returned by @code{vector-fill!} is unspecified. -@end deffn - -@deffn {Scheme Procedure} vector-move-left! vec1 start1 end1 vec2 start2 -@deffnx {C Function} scm_vector_move_left_x (vec1, start1, end1, vec2, start2) -Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, -to @var{vec2} starting at position @var{start2}. @var{start1} and -@var{start2} are inclusive indices; @var{end1} is exclusive. - -@code{vector-move-left!} copies elements in leftmost order. -Therefore, in the case where @var{vec1} and @var{vec2} refer to the -same vector, @code{vector-move-left!} is usually appropriate when -@var{start1} is greater than @var{start2}. -@end deffn - -@deffn {Scheme Procedure} vector-move-right! vec1 start1 end1 vec2 start2 -@deffnx {C Function} scm_vector_move_right_x (vec1, start1, end1, vec2, start2) -Copy elements from @var{vec1}, positions @var{start1} to @var{end1}, -to @var{vec2} starting at position @var{start2}. @var{start1} and -@var{start2} are inclusive indices; @var{end1} is exclusive. - -@code{vector-move-right!} copies elements in rightmost order. -Therefore, in the case where @var{vec1} and @var{vec2} refer to the -same vector, @code{vector-move-right!} is usually appropriate when -@var{start1} is less than @var{start2}. -@end deffn - -@subsection Vector Selection - -These procedures return information about a given vector, such as the -size or what elements are contained in the vector. - -@rnindex vector-length -@deffn {Scheme Procedure} vector-length vector -Return the number of elements in @var{vector} as an exact integer. -@end deffn - -@rnindex vector-ref -@deffn {Scheme Procedure} vector-ref vector k -Return the contents of position @var{k} of @var{vector}. -@var{k} must be a valid index of @var{vector}. -@lisp -(vector-ref '#(1 1 2 3 5 8 13 21) 5) @result{} 8 -(vector-ref '#(1 1 2 3 5 8 13 21) - (let ((i (round (* 2 (acos -1))))) - (if (inexact? i) - (inexact->exact i) - i))) @result{} 13 -@end lisp -@end deffn - - -@node Records -@section Records - -A @dfn{record type} is a first class object representing a user-defined -data type. A @dfn{record} is an instance of a record type. - -@deffn {Scheme Procedure} record? obj -Return @code{#t} if @var{obj} is a record of any type and @code{#f} -otherwise. - -Note that @code{record?} may be true of any Scheme value; there is no -promise that records are disjoint with other Scheme types. -@end deffn - -@deffn {Scheme Procedure} make-record-type type-name field-names -Return a @dfn{record-type descriptor}, a value representing a new data -type disjoint from all others. The @var{type-name} argument must be a -string, but is only used for debugging purposes (such as the printed -representation of a record of the new type). The @var{field-names} -argument is a list of symbols naming the @dfn{fields} of a record of the -new type. It is an error if the list contains any duplicates. It is -unspecified how record-type descriptors are represented. -@end deffn - -@deffn {Scheme Procedure} record-constructor rtd [field-names] -Return a procedure for constructing new members of the type represented -by @var{rtd}. The returned procedure accepts exactly as many arguments -as there are symbols in the given list, @var{field-names}; these are -used, in order, as the initial values of those fields in a new record, -which is returned by the constructor procedure. The values of any -fields not named in that list are unspecified. The @var{field-names} -argument defaults to the list of field names in the call to -@code{make-record-type} that created the type represented by @var{rtd}; -if the @var{field-names} argument is provided, it is an error if it -contains any duplicates or any symbols not in the default list. -@end deffn - -@deffn {Scheme Procedure} record-predicate rtd -Return a procedure for testing membership in the type represented by -@var{rtd}. The returned procedure accepts exactly one argument and -returns a true value if the argument is a member of the indicated record -type; it returns a false value otherwise. -@end deffn - -@deffn {Scheme Procedure} record-accessor rtd field-name -Return a procedure for reading the value of a particular field of a -member of the type represented by @var{rtd}. The returned procedure -accepts exactly one argument which must be a record of the appropriate -type; it returns the current value of the field named by the symbol -@var{field-name} in that record. The symbol @var{field-name} must be a -member of the list of field-names in the call to @code{make-record-type} -that created the type represented by @var{rtd}. -@end deffn - -@deffn {Scheme Procedure} record-modifier rtd field-name -Return a procedure for writing the value of a particular field of a -member of the type represented by @var{rtd}. The returned procedure -accepts exactly two arguments: first, a record of the appropriate type, -and second, an arbitrary Scheme value; it modifies the field named by -the symbol @var{field-name} in that record to contain the given value. -The returned value of the modifier procedure is unspecified. The symbol -@var{field-name} must be a member of the list of field-names in the call -to @code{make-record-type} that created the type represented by -@var{rtd}. -@end deffn - -@deffn {Scheme Procedure} record-type-descriptor record -Return a record-type descriptor representing the type of the given -record. That is, for example, if the returned descriptor were passed to -@code{record-predicate}, the resulting predicate would return a true -value when passed the given record. Note that it is not necessarily the -case that the returned descriptor is the one that was passed to -@code{record-constructor} in the call that created the constructor -procedure that created the given record. -@end deffn - -@deffn {Scheme Procedure} record-type-name rtd -Return the type-name associated with the type represented by rtd. The -returned value is @code{eqv?} to the @var{type-name} argument given in -the call to @code{make-record-type} that created the type represented by -@var{rtd}. -@end deffn - -@deffn {Scheme Procedure} record-type-fields rtd -Return a list of the symbols naming the fields in members of the type -represented by @var{rtd}. The returned value is @code{equal?} to the -field-names argument given in the call to @code{make-record-type} that -created the type represented by @var{rtd}. -@end deffn - - -@node Structures -@section Structures -@tpindex Structures - -[FIXME: this is pasted in from Tom Lord's original guile.texi and should -be reviewed] - -A @dfn{structure type} is a first class user-defined data type. A -@dfn{structure} is an instance of a structure type. A structure type is -itself a structure. - -Structures are less abstract and more general than traditional records. -In fact, in Guile Scheme, records are implemented using structures. - -@menu -* Structure Concepts:: The structure of Structures -* Structure Layout:: Defining the layout of structure types -* Structure Basics:: make-, -ref and -set! procedures for structs -* Vtables:: Accessing type-specific data -@end menu - -@node Structure Concepts -@subsection Structure Concepts - -A structure object consists of a handle, structure data, and a vtable. -The handle is a Scheme value which points to both the vtable and the -structure's data. Structure data is a dynamically allocated region of -memory, private to the structure, divided up into typed fields. A -vtable is another structure used to hold type-specific data. Multiple -structures can share a common vtable. - -Three concepts are key to understanding structures. - -@itemize @bullet{} -@item @dfn{layout specifications} - -Layout specifications determine how memory allocated to structures is -divided up into fields. Programmers must write a layout specification -whenever a new type of structure is defined. - -@item @dfn{structural accessors} - -Structure access is by field number. There is only one set of -accessors common to all structure objects. - -@item @dfn{vtables} - -Vtables, themselves structures, are first class representations of -disjoint sub-types of structures in general. In most cases, when a -new structure is created, programmers must specifiy a vtable for the -new structure. Each vtable has a field describing the layout of its -instances. Vtables can have additional, user-defined fields as well. -@end itemize - - - -@node Structure Layout -@subsection Structure Layout - -When a structure is created, a region of memory is allocated to hold its -state. The @dfn{layout} of the structure's type determines how that -memory is divided into fields. - -Each field has a specified type. There are only three types allowed, each -corresponding to a one letter code. The allowed types are: - -@itemize @bullet{} -@item 'u' -- unprotected - -The field holds binary data that is not GC protected. - -@item 'p' -- protected - -The field holds a Scheme value and is GC protected. - -@item 's' -- self - -The field holds a Scheme value and is GC protected. When a structure is -created with this type of field, the field is initialized to refer to -the structure's own handle. This kind of field is mainly useful when -mixing Scheme and C code in which the C code may need to compute a -structure's handle given only the address of its malloced data. -@end itemize - - -Each field also has an associated access protection. There are only -three kinds of protection, each corresponding to a one letter code. -The allowed protections are: - -@itemize @bullet{} -@item 'w' -- writable - -The field can be read and written. - -@item 'r' -- readable - -The field can be read, but not written. - -@item 'o' -- opaque - -The field can be neither read nor written. This kind -of protection is for fields useful only to built-in routines. -@end itemize - -A layout specification is described by stringing together pairs -of letters: one to specify a field type and one to specify a field -protection. For example, a traditional cons pair type object could -be described as: - -@example -; cons pairs have two writable fields of Scheme data -"pwpw" -@end example - -A pair object in which the first field is held constant could be: - -@example -"prpw" -@end example - -Binary fields, (fields of type "u"), hold one @dfn{word} each. The -size of a word is a machine dependent value defined to be equal to the -value of the C expression: @code{sizeof (long)}. - -The last field of a structure layout may specify a tail array. -A tail array is indicated by capitalizing the field's protection -code ('W', 'R' or 'O'). A tail-array field is replaced by -a read-only binary data field containing an array size. The array -size is determined at the time the structure is created. It is followed -by a corresponding number of fields of the type specified for the -tail array. For example, a conventional Scheme vector can be -described as: - -@example -; A vector is an arbitrary number of writable fields holding Scheme -; values: -"pW" -@end example - -In the above example, field 0 contains the size of the vector and -fields beginning at 1 contain the vector elements. - -A kind of tagged vector (a constant tag followed by conventioal -vector elements) might be: - -@example -"prpW" -@end example - - -Structure layouts are represented by specially interned symbols whose -name is a string of type and protection codes. To create a new -structure layout, use this procedure: - -@deffn {Scheme Procedure} make-struct-layout fields -@deffnx {C Function} scm_make_struct_layout (fields) -Return a new structure layout object. - -@var{fields} must be a string made up of pairs of characters -strung together. The first character of each pair describes a field -type, the second a field protection. Allowed types are 'p' for -GC-protected Scheme data, 'u' for unprotected binary data, and 's' for -a field that points to the structure itself. Allowed protections -are 'w' for mutable fields, 'r' for read-only fields, and 'o' for opaque -fields. The last field protection specification may be capitalized to -indicate that the field is a tail-array. -@end deffn - - - -@node Structure Basics -@subsection Structure Basics - -This section describes the basic procedures for creating and accessing -structures. - -@deffn {Scheme Procedure} make-struct vtable tail_array_size . init -@deffnx {C Function} scm_make_struct (vtable, tail_array_size, init) -Create a new structure. - -@var{type} must be a vtable structure (@pxref{Vtables}). - -@var{tail-elts} must be a non-negative integer. If the layout -specification indicated by @var{type} includes a tail-array, -this is the number of elements allocated to that array. - -The @var{init1}, @dots{} are optional arguments describing how -successive fields of the structure should be initialized. Only fields -with protection 'r' or 'w' can be initialized, except for fields of -type 's', which are automatically initialized to point to the new -structure itself; fields with protection 'o' can not be initialized by -Scheme programs. - -If fewer optional arguments than initializable fields are supplied, -fields of type 'p' get default value #f while fields of type 'u' are -initialized to 0. - -Structs are currently the basic representation for record-like data -structures in Guile. The plan is to eventually replace them with a -new representation which will at the same time be easier to use and -more powerful. - -For more information, see the documentation for @code{make-vtable-vtable}. -@end deffn - -@deffn {Scheme Procedure} struct? x -@deffnx {C Function} scm_struct_p (x) -Return @code{#t} iff @var{x} is a structure object, else -@code{#f}. -@end deffn - - -@deffn {Scheme Procedure} struct-ref handle pos -@deffnx {Scheme Procedure} struct-set! struct n value -@deffnx {C Function} scm_struct_ref (handle, pos) -@deffnx {C Function} scm_struct_set_x (struct, n, value) -Access (or modify) the @var{n}th field of @var{struct}. - -If the field is of type 'p', then it can be set to an arbitrary value. - -If the field is of type 'u', then it can only be set to a non-negative -integer value small enough to fit in one machine word. -@end deffn - - - -@node Vtables -@subsection Vtables - -Vtables are structures that are used to represent structure types. Each -vtable contains a layout specification in field -@code{vtable-index-layout} -- instances of the type are laid out -according to that specification. Vtables contain additional fields -which are used only internally to libguile. The variable -@code{vtable-offset-user} is bound to a field number. Vtable fields -at that position or greater are user definable. - -@deffn {Scheme Procedure} struct-vtable handle -@deffnx {C Function} scm_struct_vtable (handle) -Return the vtable structure that describes the type of @var{struct}. -@end deffn - -@deffn {Scheme Procedure} struct-vtable? x -@deffnx {C Function} scm_struct_vtable_p (x) -Return @code{#t} iff @var{x} is a vtable structure. -@end deffn - -If you have a vtable structure, @code{V}, you can create an instance of -the type it describes by using @code{(make-struct V ...)}. But where -does @code{V} itself come from? One possibility is that @code{V} is an -instance of a user-defined vtable type, @code{V'}, so that @code{V} is -created by using @code{(make-struct V' ...)}. Another possibility is -that @code{V} is an instance of the type it itself describes. Vtable -structures of the second sort are created by this procedure: - -@deffn {Scheme Procedure} make-vtable-vtable user_fields tail_array_size . init -@deffnx {C Function} scm_make_vtable_vtable (user_fields, tail_array_size, init) -Return a new, self-describing vtable structure. - -@var{user-fields} is a string describing user defined fields of the -vtable beginning at index @code{vtable-offset-user} -(see @code{make-struct-layout}). - -@var{tail-size} specifies the size of the tail-array (if any) of -this vtable. - -@var{init1}, @dots{} are the optional initializers for the fields of -the vtable. - -Vtables have one initializable system field---the struct printer. -This field comes before the user fields in the initializers passed -to @code{make-vtable-vtable} and @code{make-struct}, and thus works as -a third optional argument to @code{make-vtable-vtable} and a fourth to -@code{make-struct} when creating vtables: - -If the value is a procedure, it will be called instead of the standard -printer whenever a struct described by this vtable is printed. -The procedure will be called with arguments STRUCT and PORT. - -The structure of a struct is described by a vtable, so the vtable is -in essence the type of the struct. The vtable is itself a struct with -a vtable. This could go on forever if it weren't for the -vtable-vtables which are self-describing vtables, and thus terminate -the chain. - -There are several potential ways of using structs, but the standard -one is to use three kinds of structs, together building up a type -sub-system: one vtable-vtable working as the root and one or several -"types", each with a set of "instances". (The vtable-vtable should be -compared to the class which is the class of itself.) - -@lisp -(define ball-root (make-vtable-vtable "pr" 0)) - -(define (make-ball-type ball-color) - (make-struct ball-root 0 - (make-struct-layout "pw") - (lambda (ball port) - (format port "#" - (color ball) - (owner ball))) - ball-color)) -(define (color ball) (struct-ref (struct-vtable ball) vtable-offset-user)) -(define (owner ball) (struct-ref ball 0)) - -(define red (make-ball-type 'red)) -(define green (make-ball-type 'green)) - -(define (make-ball type owner) (make-struct type 0 owner)) - -(define ball (make-ball green 'Nisse)) -ball @result{} # -@end lisp -@end deffn - -@deffn {Scheme Procedure} struct-vtable-name vtable -@deffnx {C Function} scm_struct_vtable_name (vtable) -Return the name of the vtable @var{vtable}. -@end deffn - -@deffn {Scheme Procedure} set-struct-vtable-name! vtable name -@deffnx {C Function} scm_set_struct_vtable_name_x (vtable, name) -Set the name of the vtable @var{vtable} to @var{name}. -@end deffn - -@deffn {Scheme Procedure} struct-vtable-tag handle -@deffnx {C Function} scm_struct_vtable_tag (handle) -Return the vtable tag of the structure @var{handle}. -@end deffn - - -@node Arrays -@section Arrays -@tpindex Arrays - -@menu -* Conventional Arrays:: Arrays with arbitrary data. -* Array Mapping:: Applying a procedure to the contents of an array. -* Uniform Arrays:: Arrays with data of a single type. -* Bit Vectors:: Vectors of bits. -@end menu - -@node Conventional Arrays -@subsection Conventional Arrays - -@dfn{Conventional arrays} are a collection of cells organized into an -arbitrary number of dimensions. Each cell can hold any kind of Scheme -value and can be accessed in constant time by supplying an index for -each dimension. This contrasts with uniform arrays, which use memory -more efficiently but can hold data of only a single type, and lists -where inserting and deleting cells is more efficient, but more time -is usually required to access a particular cell. - -A conventional array is displayed as @code{#} followed by the @dfn{rank} -(number of dimensions) followed by the cells, organized into dimensions -using parentheses. The nesting depth of the parentheses is equal to -the rank. - -When an array is created, the number of dimensions and range of each -dimension must be specified, e.g., to create a 2x3 array with a -zero-based index: - -@example -(make-array 'ho 2 3) @result{} -#2((ho ho ho) (ho ho ho)) -@end example - -The range of each dimension can also be given explicitly, e.g., another -way to create the same array: - -@example -(make-array 'ho '(0 1) '(0 2)) @result{} -#2((ho ho ho) (ho ho ho)) -@end example - -A conventional array with one dimension based at zero is identical to -a vector: - -@example -(make-array 'ho 3) @result{} -#(ho ho ho) -@end example - -The following procedures can be used with conventional arrays (or vectors). - -@deffn {Scheme Procedure} array? v [prot] -@deffnx {C Function} scm_array_p (v, prot) -Return @code{#t} if the @var{obj} is an array, and @code{#f} if -not. The @var{prototype} argument is used with uniform arrays -and is described elsewhere. -@end deffn - -@deffn {Scheme Procedure} make-array initial-value bound1 bound2 @dots{} -Create and return an array that has as many dimensions as there are -@var{bound}s and fill it with @var{initial-value}. Each @var{bound} -may be a positive non-zero integer @var{N}, in which case the index for -that dimension can range from 0 through @var{N-1}; or an explicit index -range specifier in the form @code{(LOWER UPPER)}, where both @var{lower} -and @var{upper} are integers, possibly less than zero, and possibly the -same number (however, @var{lower} cannot be greater than @var{upper}). -@end deffn - -@c array-ref's type is `compiled-closure'. There's some weird stuff -@c going on in array.c, too. Let's call it a primitive. -twp - -@deffn {Scheme Procedure} uniform-vector-ref v args -@deffnx {Scheme Procedure} array-ref v . args -@deffnx {C Function} scm_uniform_vector_ref (v, args) -Return the element at the @code{(index1, index2)} element in -@var{array}. -@end deffn - -@deffn {Scheme Procedure} array-in-bounds? v . args -@deffnx {C Function} scm_array_in_bounds_p (v, args) -Return @code{#t} if its arguments would be acceptable to -@code{array-ref}. -@end deffn - -@c fixme: why do these sigs differ? -ttn 2001/07/19 01:14:12 -@deffn {Scheme Procedure} array-set! v obj . args -@deffnx {Scheme Procedure} uniform-array-set1! v obj args -@deffnx {C Function} scm_array_set_x (v, obj, args) -Set the element at the @code{(index1, index2)} element in @var{array} to -@var{new-value}. The value returned by array-set! is unspecified. -@end deffn - -@deffn {Scheme Procedure} make-shared-array oldra mapfunc . dims -@deffnx {C Function} scm_make_shared_array (oldra, mapfunc, dims) -@code{make-shared-array} can be used to create shared subarrays of other -arrays. The @var{mapper} is a function that translates coordinates in -the new array into coordinates in the old array. A @var{mapper} must be -linear, and its range must stay within the bounds of the old array, but -it can be otherwise arbitrary. A simple example: -@lisp -(define fred (make-array #f 8 8)) -(define freds-diagonal - (make-shared-array fred (lambda (i) (list i i)) 8)) -(array-set! freds-diagonal 'foo 3) -(array-ref fred 3 3) @result{} foo -(define freds-center - (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) -(array-ref freds-center 0 0) @result{} foo -@end lisp -@end deffn - -@deffn {Scheme Procedure} shared-array-increments ra -@deffnx {C Function} scm_shared_array_increments (ra) -For each dimension, return the distance between elements in the root vector. -@end deffn - -@deffn {Scheme Procedure} shared-array-offset ra -@deffnx {C Function} scm_shared_array_offset (ra) -Return the root vector index of the first element in the array. -@end deffn - -@deffn {Scheme Procedure} shared-array-root ra -@deffnx {C Function} scm_shared_array_root (ra) -Return the root vector of a shared array. -@end deffn - -@deffn {Scheme Procedure} transpose-array ra . args -@deffnx {C Function} scm_transpose_array (ra, args) -Return an array sharing contents with @var{array}, but with -dimensions arranged in a different order. There must be one -@var{dim} argument for each dimension of @var{array}. -@var{dim0}, @var{dim1}, @dots{} should be integers between 0 -and the rank of the array to be returned. Each integer in that -range must appear at least once in the argument list. - -The values of @var{dim0}, @var{dim1}, @dots{} correspond to -dimensions in the array to be returned, their positions in the -argument list to dimensions of @var{array}. Several @var{dim}s -may have the same value, in which case the returned array will -have smaller rank than @var{array}. - -@lisp -(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d)) -(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d) -(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{} - #2((a 4) (b 5) (c 6)) -@end lisp -@end deffn - -@deffn {Scheme Procedure} enclose-array ra . axes -@deffnx {C Function} scm_enclose_array (ra, axes) -@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than -the rank of @var{array}. @var{enclose-array} returns an array -resembling an array of shared arrays. The dimensions of each shared -array are the same as the @var{dim}th dimensions of the original array, -the dimensions of the outer array are the same as those of the original -array that did not match a @var{dim}. - -An enclosed array is not a general Scheme array. Its elements may not -be set using @code{array-set!}. Two references to the same element of -an enclosed array will be @code{equal?} but will not in general be -@code{eq?}. The value returned by @var{array-prototype} when given an -enclosed array is unspecified. - -examples: -@lisp -(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{} - # - -(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{} - # -@end lisp -@end deffn - -@deffn {Scheme Procedure} array-shape array -Return a list of inclusive bounds of integers. -@example -(array-shape (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) (0 4)) -@end example -@end deffn - -@deffn {Scheme Procedure} array-dimensions ra -@deffnx {C Function} scm_array_dimensions (ra) -@code{Array-dimensions} is similar to @code{array-shape} but replaces -elements with a @code{0} minimum with one greater than the maximum. So: -@lisp -(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5) -@end lisp -@end deffn - -@deffn {Scheme Procedure} array-rank ra -@deffnx {C Function} scm_array_rank (ra) -Return the number of dimensions of @var{obj}. If @var{obj} is -not an array, @code{0} is returned. -@end deffn - -@deffn {Scheme Procedure} array->list v -@deffnx {C Function} scm_t_arrayo_list (v) -Return a list consisting of all the elements, in order, of -@var{array}. -@end deffn - -@deffn {Scheme Procedure} array-copy! src dst -@deffnx {Scheme Procedure} array-copy-in-order! src dst -@deffnx {C Function} scm_array_copy_x (src, dst) -Copy every element from vector or array @var{source} to the -corresponding element of @var{destination}. @var{destination} must have -the same rank as @var{source}, and be at least as large in each -dimension. The order is unspecified. -@end deffn - -@deffn {Scheme Procedure} array-fill! ra fill -@deffnx {C Function} scm_array_fill_x (ra, fill) -Store @var{fill} in every element of @var{array}. The value returned -is unspecified. -@end deffn - -@c begin (texi-doc-string "guile" "array-equal?") -@deffn {Scheme Procedure} array-equal? ra0 ra1 -Return @code{#t} iff all arguments are arrays with the same shape, the -same type, and have corresponding elements which are either -@code{equal?} or @code{array-equal?}. This function differs from -@code{equal?} in that a one dimensional shared array may be -@var{array-equal?} but not @var{equal?} to a vector or uniform vector. -@end deffn - -@deffn {Scheme Procedure} array-contents array [strict] -@deffnx {C Function} scm_array_contents (array, strict) -If @var{array} may be @dfn{unrolled} into a one dimensional shared array -without changing their order (last subscript changing fastest), then -@code{array-contents} returns that shared array, otherwise it returns -@code{#f}. All arrays made by @var{make-array} and -@var{make-uniform-array} may be unrolled, some arrays made by -@var{make-shared-array} may not be. - -If the optional argument @var{strict} is provided, a shared array will -be returned only if its elements are stored internally contiguous in -memory. -@end deffn - -@node Array Mapping -@subsection Array Mapping - -@deffn {Scheme Procedure} array-map! ra0 proc . lra -@deffnx {Scheme Procedure} array-map-in-order! ra0 proc . lra -@deffnx {C Function} scm_array_map_x (ra0, proc, lra) -@var{array1}, @dots{} must have the same number of dimensions as -@var{array0} and have a range for each index which includes the range -for the corresponding index in @var{array0}. @var{proc} is applied to -each tuple of elements of @var{array1} @dots{} and the result is stored -as the corresponding element in @var{array0}. The value returned is -unspecified. The order of application is unspecified. -@end deffn - -@deffn {Scheme Procedure} array-for-each proc ra0 . lra -@deffnx {C Function} scm_array_for_each (proc, ra0, lra) -Apply @var{proc} to each tuple of elements of @var{array0} @dots{} -in row-major order. The value returned is unspecified. -@end deffn - -@deffn {Scheme Procedure} array-index-map! ra proc -@deffnx {C Function} scm_array_index_map_x (ra, proc) -Apply @var{proc} to the indices of each element of @var{array} in -turn, storing the result in the corresponding element. The value -returned and the order of application are unspecified. - -One can implement @var{array-indexes} as -@lisp -(define (array-indexes array) - (let ((ra (apply make-array #f (array-shape array)))) - (array-index-map! ra (lambda x x)) - ra)) -@end lisp -Another example: -@lisp -(define (apl:index-generator n) - (let ((v (make-uniform-vector n 1))) - (array-index-map! v (lambda (i) i)) - v)) -@end lisp -@end deffn - -@node Uniform Arrays -@subsection Uniform Arrays -@tpindex Uniform Arrays - -@noindent -@dfn{Uniform arrays} have elements all of the -same type and occupy less storage than conventional -arrays. Uniform arrays with a single zero-based dimension -are also known as @dfn{uniform vectors}. The procedures in -this section can also be used on conventional arrays, vectors, -bit-vectors and strings. - -@noindent -When creating a uniform array, the type of data to be stored -is indicated with a @var{prototype} argument. The following table -lists the types available and example prototypes: - -@example -prototype type printing character - -#t boolean (bit-vector) b -#\a char (string) a -#\nul byte (integer) y -'s short (integer) h -1 unsigned long (integer) u --1 signed long (integer) e -'l signed long long (integer) l -1.0 float (single precision) s -1/3 double (double precision float) i -0+i complex (double precision) c -() conventional vector -@end example - -@noindent -Unshared uniform arrays of characters with a single zero-based dimension -are identical to strings: - -@example -(make-uniform-array #\a 3) @result{} -"aaa" -@end example - -@noindent -Unshared uniform arrays of booleans with a single zero-based dimension -are identical to @ref{Bit Vectors, bit-vectors}. - -@example -(make-uniform-array #t 3) @result{} -#*111 -@end example - -@noindent -Other uniform vectors are written in a form similar to that of vectors, -except that a single character from the above table is put between -@code{#} and @code{(}. For example, a uniform vector of signed -long integers is displayed in the form @code{'#e(3 5 9)}. - -@deffn {Scheme Procedure} array? v [prot] -Return @code{#t} if the @var{obj} is an array, and @code{#f} if not. - -The @var{prototype} argument is used with uniform arrays and is described -elsewhere. -@end deffn - -@deffn {Scheme Procedure} make-uniform-array prototype bound1 bound2 @dots{} -Create and return a uniform array of type corresponding to -@var{prototype} that has as many dimensions as there are @var{bound}s -and fill it with @var{prototype}. -@end deffn - -@deffn {Scheme Procedure} array-prototype ra -@deffnx {C Function} scm_array_prototype (ra) -Return an object that would produce an array of the same type -as @var{array}, if used as the @var{prototype} for -@code{make-uniform-array}. -@end deffn - -@deffn {Scheme Procedure} list->uniform-array ndim prot lst -@deffnx {Scheme Procedure} list->uniform-vector prot lst -@deffnx {C Function} scm_list_to_uniform_array (ndim, prot, lst) -Return a uniform array of the type indicated by prototype -@var{prot} with elements the same as those of @var{lst}. -Elements must be of the appropriate type, no coercions are -done. -@end deffn - -@deffn {Scheme Procedure} uniform-vector-fill! uve fill -Store @var{fill} in every element of @var{uve}. The value returned is -unspecified. -@end deffn - -@deffn {Scheme Procedure} uniform-vector-length v -@deffnx {C Function} scm_uniform_vector_length (v) -Return the number of elements in @var{uve}. -@end deffn - -@deffn {Scheme Procedure} dimensions->uniform-array dims prot [fill] -@deffnx {Scheme Procedure} make-uniform-vector length prototype [fill] -@deffnx {C Function} scm_dimensions_to_uniform_array (dims, prot, fill) -Create and return a uniform array or vector of type -corresponding to @var{prototype} with dimensions @var{dims} or -length @var{length}. If @var{fill} is supplied, it's used to -fill the array, otherwise @var{prototype} is used. -@end deffn - -@c Another compiled-closure. -twp - -@deffn {Scheme Procedure} uniform-array-read! ra [port_or_fd [start [end]]] -@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end] -@deffnx {C Function} scm_uniform_array_read_x (ra, port_or_fd, start, end) -Attempt to read all elements of @var{ura}, in lexicographic order, as -binary objects from @var{port-or-fdes}. -If an end of file is encountered, -the objects up to that point are put into @var{ura} -(starting at the beginning) and the remainder of the array is -unchanged. - -The optional arguments @var{start} and @var{end} allow -a specified region of a vector (or linearized array) to be read, -leaving the remainder of the vector unchanged. - -@code{uniform-array-read!} returns the number of objects read. -@var{port-or-fdes} may be omitted, in which case it defaults to the value -returned by @code{(current-input-port)}. -@end deffn - -@deffn {Scheme Procedure} uniform-array-write v [port_or_fd [start [end]]] -@deffnx {Scheme Procedure} uniform-vector-write uve [port-or-fdes] [start] [end] -@deffnx {C Function} scm_uniform_array_write (v, port_or_fd, start, end) -Writes all elements of @var{ura} as binary objects to -@var{port-or-fdes}. - -The optional arguments @var{start} -and @var{end} allow -a specified region of a vector (or linearized array) to be written. - -The number of objects actually written is returned. -@var{port-or-fdes} may be -omitted, in which case it defaults to the value returned by -@code{(current-output-port)}. -@end deffn - -@node Bit Vectors -@subsection Bit Vectors - -@noindent -Bit vectors are a specific type of uniform array: an array of booleans -with a single zero-based index. - -@noindent -They are displayed as a sequence of @code{0}s and -@code{1}s prefixed by @code{#*}, e.g., - -@example -(make-uniform-vector 8 #t #f) @result{} -#*00000000 - -#b(#t #f #t) @result{} -#*101 -@end example - -@deffn {Scheme Procedure} bit-count b bitvector -@deffnx {C Function} scm_bit_count (b, bitvector) -Return the number of occurrences of the boolean @var{b} in -@var{bitvector}. -@end deffn - -@deffn {Scheme Procedure} bit-position item v k -@deffnx {C Function} scm_bit_position (item, v, k) -Return the minimum index of an occurrence of @var{bool} in -@var{bv} which is at least @var{k}. If no @var{bool} occurs -within the specified range @code{#f} is returned. -@end deffn - -@deffn {Scheme Procedure} bit-invert! v -@deffnx {C Function} scm_bit_invert_x (v) -Modify @var{bv} by replacing each element with its negation. -@end deffn - -@deffn {Scheme Procedure} bit-set*! v kv obj -@deffnx {C Function} scm_bit_set_star_x (v, kv, obj) -If uve is a bit-vector @var{bv} and uve must be of the same -length. If @var{bool} is @code{#t}, uve is OR'ed into -@var{bv}; If @var{bool} is @code{#f}, the inversion of uve is -AND'ed into @var{bv}. - -If uve is a unsigned long integer vector all the elements of uve -must be between 0 and the @code{length} of @var{bv}. The bits -of @var{bv} corresponding to the indexes in uve are set to -@var{bool}. The return value is unspecified. -@end deffn - -@deffn {Scheme Procedure} bit-count* v kv obj -@deffnx {C Function} scm_bit_count_star (v, kv, obj) -Return -@lisp -(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t). -@end lisp -@var{bv} is not modified. -@end deffn - - -@node Association Lists and Hash Tables -@section Association Lists and Hash Tables - -This chapter discusses dictionary objects: data structures that are -useful for organizing and indexing large bodies of information. - -@menu -* Dictionary Types:: About dictionary types; what they're good for. -* Association Lists:: List-based dictionaries. -* Hash Tables:: Table-based dictionaries. -@end menu - -@node Dictionary Types -@subsection Dictionary Types - -A @dfn{dictionary} object is a data structure used to index -information in a user-defined way. In standard Scheme, the main -aggregate data types are lists and vectors. Lists are not really -indexed at all, and vectors are indexed only by number -(e.g. @code{(vector-ref foo 5)}). Often you will find it useful -to index your data on some other type; for example, in a library -catalog you might want to look up a book by the name of its -author. Dictionaries are used to help you organize information in -such a way. - -An @dfn{association list} (or @dfn{alist} for short) is a list of -key-value pairs. Each pair represents a single quantity or -object; the @code{car} of the pair is a key which is used to -identify the object, and the @code{cdr} is the object's value. - -A @dfn{hash table} also permits you to index objects with -arbitrary keys, but in a way that makes looking up any one object -extremely fast. A well-designed hash system makes hash table -lookups almost as fast as conventional array or vector references. - -Alists are popular among Lisp programmers because they use only -the language's primitive operations (lists, @dfn{car}, @dfn{cdr} -and the equality primitives). No changes to the language core are -necessary. Therefore, with Scheme's built-in list manipulation -facilities, it is very convenient to handle data stored in an -association list. Also, alists are highly portable and can be -easily implemented on even the most minimal Lisp systems. - -However, alists are inefficient, especially for storing large -quantities of data. Because we want Guile to be useful for large -software systems as well as small ones, Guile provides a rich set -of tools for using either association lists or hash tables. - -@node Association Lists -@subsection Association Lists -@tpindex Association Lists -@tpindex Alist - -@cindex Association List -@cindex Alist -@cindex Database - -An association list is a conventional data structure that is often used -to implement simple key-value databases. It consists of a list of -entries in which each entry is a pair. The @dfn{key} of each entry is -the @code{car} of the pair and the @dfn{value} of each entry is the -@code{cdr}. - -@example -ASSOCIATION LIST ::= '( (KEY1 . VALUE1) - (KEY2 . VALUE2) - (KEY3 . VALUE3) - @dots{} - ) -@end example - -@noindent -Association lists are also known, for short, as @dfn{alists}. - -The structure of an association list is just one example of the infinite -number of possible structures that can be built using pairs and lists. -As such, the keys and values in an association list can be manipulated -using the general list structure procedures @code{cons}, @code{car}, -@code{cdr}, @code{set-car!}, @code{set-cdr!} and so on. However, -because association lists are so useful, Guile also provides specific -procedures for manipulating them. - -@menu -* Alist Key Equality:: -* Adding or Setting Alist Entries:: -* Retrieving Alist Entries:: -* Removing Alist Entries:: -* Sloppy Alist Functions:: -* Alist Example:: -@end menu - -@node Alist Key Equality -@subsubsection Alist Key Equality - -All of Guile's dedicated association list procedures, apart from -@code{acons}, come in three flavours, depending on the level of equality -that is required to decide whether an existing key in the association -list is the same as the key that the procedure call uses to identify the -required entry. - -@itemize @bullet -@item -Procedures with @dfn{assq} in their name use @code{eq?} to determine key -equality. - -@item -Procedures with @dfn{assv} in their name use @code{eqv?} to determine -key equality. - -@item -Procedures with @dfn{assoc} in their name use @code{equal?} to -determine key equality. -@end itemize - -@code{acons} is an exception because it is used to build association -lists which do not require their entries' keys to be unique. - -@node Adding or Setting Alist Entries -@subsubsection Adding or Setting Alist Entries - -@code{acons} adds a new entry to an association list and returns the -combined association list. The combined alist is formed by consing the -new entry onto the head of the alist specified in the @code{acons} -procedure call. So the specified alist is not modified, but its -contents become shared with the tail of the combined alist that -@code{acons} returns. - -In the most common usage of @code{acons}, a variable holding the -original association list is updated with the combined alist: - -@example -(set! address-list (acons name address address-list)) -@end example - -In such cases, it doesn't matter that the old and new values of -@code{address-list} share some of their contents, since the old value is -usually no longer independently accessible. - -Note that @code{acons} adds the specified new entry regardless of -whether the alist may already contain entries with keys that are, in -some sense, the same as that of the new entry. Thus @code{acons} is -ideal for building alists where there is no concept of key uniqueness. - -@example -(set! task-list (acons 3 "pay gas bill" '())) -task-list -@result{} -((3 . "pay gas bill")) - -(set! task-list (acons 3 "tidy bedroom" task-list)) -task-list -@result{} -((3 . "tidy bedroom") (3 . "pay gas bill")) -@end example - -@code{assq-set!}, @code{assv-set!} and @code{assoc-set!} are used to add -or replace an entry in an association list where there @emph{is} a -concept of key uniqueness. If the specified association list already -contains an entry whose key is the same as that specified in the -procedure call, the existing entry is replaced by the new one. -Otherwise, the new entry is consed onto the head of the old association -list to create the combined alist. In all cases, these procedures -return the combined alist. - -@code{assq-set!} and friends @emph{may} destructively modify the -structure of the old association list in such a way that an existing -variable is correctly updated without having to @code{set!} it to the -value returned: - -@example -address-list -@result{} -(("mary" . "34 Elm Road") ("james" . "16 Bow Street")) - -(assoc-set! address-list "james" "1a London Road") -@result{} -(("mary" . "34 Elm Road") ("james" . "1a London Road")) - -address-list -@result{} -(("mary" . "34 Elm Road") ("james" . "1a London Road")) -@end example - -Or they may not: - -@example -(assoc-set! address-list "bob" "11 Newington Avenue") -@result{} -(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road") - ("james" . "1a London Road")) - -address-list -@result{} -(("mary" . "34 Elm Road") ("james" . "1a London Road")) -@end example - -The only safe way to update an association list variable when adding or -replacing an entry like this is to @code{set!} the variable to the -returned value: - -@example -(set! address-list - (assoc-set! address-list "bob" "11 Newington Avenue")) -address-list -@result{} -(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road") - ("james" . "1a London Road")) -@end example - -Because of this slight inconvenience, you may find it more convenient to -use hash tables to store dictionary data. If your application will not -be modifying the contents of an alist very often, this may not make much -difference to you. - -If you need to keep the old value of an association list in a form -independent from the list that results from modification by -@code{acons}, @code{assq-set!}, @code{assv-set!} or @code{assoc-set!}, -use @code{list-copy} to copy the old association list before modifying -it. - -@deffn {Scheme Procedure} acons key value alist -@deffnx {C Function} scm_acons (key, value, alist) -Add a new key-value pair to @var{alist}. A new pair is -created whose car is @var{key} and whose cdr is @var{value}, and the -pair is consed onto @var{alist}, and the new list is returned. This -function is @emph{not} destructive; @var{alist} is not modified. -@end deffn - -@deffn {Scheme Procedure} assq-set! alist key val -@deffnx {Scheme Procedure} assv-set! alist key value -@deffnx {Scheme Procedure} assoc-set! alist key value -@deffnx {C Function} scm_assq_set_x (alist, key, val) -@deffnx {C Function} scm_assv_set_x (alist, key, val) -@deffnx {C Function} scm_assoc_set_x (alist, key, val) -Reassociate @var{key} in @var{alist} with @var{value}: find any existing -@var{alist} entry for @var{key} and associate it with the new -@var{value}. If @var{alist} does not contain an entry for @var{key}, -add a new one. Return the (possibly new) alist. - -These functions do not attempt to verify the structure of @var{alist}, -and so may cause unusual results if passed an object that is not an -association list. -@end deffn - -@node Retrieving Alist Entries -@subsubsection Retrieving Alist Entries -@rnindex assq -@rnindex assv -@rnindex assoc - -@code{assq}, @code{assv} and @code{assoc} take an alist and a key as -arguments and return the entry for that key if an entry exists, or -@code{#f} if there is no entry for that key. Note that, in the cases -where an entry exists, these procedures return the complete entry, that -is @code{(KEY . VALUE)}, not just the value. - -@deffn {Scheme Procedure} assq key alist -@deffnx {Scheme Procedure} assv key alist -@deffnx {Scheme Procedure} assoc key alist -@deffnx {C Function} scm_assq (key, alist) -@deffnx {C Function} scm_assv (key, alist) -@deffnx {C Function} scm_assoc (key, alist) -Fetch the entry in @var{alist} that is associated with @var{key}. To -decide whether the argument @var{key} matches a particular entry in -@var{alist}, @code{assq} compares keys with @code{eq?}, @code{assv} -uses @code{eqv?} and @code{assoc} uses @code{equal?}. If @var{key} -cannot be found in @var{alist} (according to whichever equality -predicate is in use), then return @code{#f}. These functions -return the entire alist entry found (i.e. both the key and the value). -@end deffn - -@code{assq-ref}, @code{assv-ref} and @code{assoc-ref}, on the other -hand, take an alist and a key and return @emph{just the value} for that -key, if an entry exists. If there is no entry for the specified key, -these procedures return @code{#f}. - -This creates an ambiguity: if the return value is @code{#f}, it means -either that there is no entry with the specified key, or that there -@emph{is} an entry for the specified key, with value @code{#f}. -Consequently, @code{assq-ref} and friends should only be used where it -is known that an entry exists, or where the ambiguity doesn't matter -for some other reason. - -@deffn {Scheme Procedure} assq-ref alist key -@deffnx {Scheme Procedure} assv-ref alist key -@deffnx {Scheme Procedure} assoc-ref alist key -@deffnx {C Function} scm_assq_ref (alist, key) -@deffnx {C Function} scm_assv_ref (alist, key) -@deffnx {C Function} scm_assoc_ref (alist, key) -Like @code{assq}, @code{assv} and @code{assoc}, except that only the -value associated with @var{key} in @var{alist} is returned. These -functions are equivalent to - -@lisp -(let ((ent (@var{associator} @var{key} @var{alist}))) - (and ent (cdr ent))) -@end lisp - -where @var{associator} is one of @code{assq}, @code{assv} or @code{assoc}. -@end deffn - -@node Removing Alist Entries -@subsubsection Removing Alist Entries - -To remove the element from an association list whose key matches a -specified key, use @code{assq-remove!}, @code{assv-remove!} or -@code{assoc-remove!} (depending, as usual, on the level of equality -required between the key that you specify and the keys in the -association list). - -As with @code{assq-set!} and friends, the specified alist may or may not -be modified destructively, and the only safe way to update a variable -containing the alist is to @code{set!} it to the value that -@code{assq-remove!} and friends return. - -@example -address-list -@result{} -(("bob" . "11 Newington Avenue") ("mary" . "34 Elm Road") - ("james" . "1a London Road")) - -(set! address-list (assoc-remove! address-list "mary")) -address-list -@result{} -(("bob" . "11 Newington Avenue") ("james" . "1a London Road")) -@end example - -Note that, when @code{assq/v/oc-remove!} is used to modify an -association list that has been constructed only using the corresponding -@code{assq/v/oc-set!}, there can be at most one matching entry in the -alist, so the question of multiple entries being removed in one go does -not arise. If @code{assq/v/oc-remove!} is applied to an association -list that has been constructed using @code{acons}, or an -@code{assq/v/oc-set!} with a different level of equality, or any mixture -of these, it removes only the first matching entry from the alist, even -if the alist might contain further matching entries. For example: - -@example -(define address-list '()) -(set! address-list (assq-set! address-list "mary" "11 Elm Street")) -(set! address-list (assq-set! address-list "mary" "57 Pine Drive")) -address-list -@result{} -(("mary" . "57 Pine Drive") ("mary" . "11 Elm Street")) - -(set! address-list (assoc-remove! address-list "mary")) -address-list -@result{} -(("mary" . "11 Elm Street")) -@end example - -In this example, the two instances of the string "mary" are not the same -when compared using @code{eq?}, so the two @code{assq-set!} calls add -two distinct entries to @code{address-list}. When compared using -@code{equal?}, both "mary"s in @code{address-list} are the same as the -"mary" in the @code{assoc-remove!} call, but @code{assoc-remove!} stops -after removing the first matching entry that it finds, and so one of the -"mary" entries is left in place. - -@deffn {Scheme Procedure} assq-remove! alist key -@deffnx {Scheme Procedure} assv-remove! alist key -@deffnx {Scheme Procedure} assoc-remove! alist key -@deffnx {C Function} scm_assq_remove_x (alist, key) -@deffnx {C Function} scm_assv_remove_x (alist, key) -@deffnx {C Function} scm_assoc_remove_x (alist, key) -Delete the first entry in @var{alist} associated with @var{key}, and return -the resulting alist. -@end deffn - -@node Sloppy Alist Functions -@subsubsection Sloppy Alist Functions - -@code{sloppy-assq}, @code{sloppy-assv} and @code{sloppy-assoc} behave -like the corresponding non-@code{sloppy-} procedures, except that they -return @code{#f} when the specified association list is not well-formed, -where the non-@code{sloppy-} versions would signal an error. - -Specifically, there are two conditions for which the non-@code{sloppy-} -procedures signal an error, which the @code{sloppy-} procedures handle -instead by returning @code{#f}. Firstly, if the specified alist as a -whole is not a proper list: - -@example -(assoc "mary" '((1 . 2) ("key" . "door") . "open sesame")) -@result{} -ERROR: In procedure assoc in expression (assoc "mary" (quote #)): -ERROR: Wrong type argument in position 2 (expecting NULLP): "open sesame" -ABORT: (wrong-type-arg) - -(sloppy-assoc "mary" '((1 . 2) ("key" . "door") . "open sesame")) -@result{} -#f -@end example - -@noindent -Secondly, if one of the entries in the specified alist is not a pair: - -@example -(assoc 2 '((1 . 1) 2 (3 . 9))) -@result{} -ERROR: In procedure assoc in expression (assoc 2 (quote #)): -ERROR: Wrong type argument in position 2 (expecting CONSP): 2 -ABORT: (wrong-type-arg) - -(sloppy-assoc 2 '((1 . 1) 2 (3 . 9))) -@result{} -#f -@end example - -Unless you are explicitly working with badly formed association lists, -it is much safer to use the non-@code{sloppy-} procedures, because they -help to highlight coding and data errors that the @code{sloppy-} -versions would silently cover up. - -@deffn {Scheme Procedure} sloppy-assq key alist -@deffnx {C Function} scm_sloppy_assq (key, alist) -Behaves like @code{assq} but does not do any error checking. -Recommended only for use in Guile internals. -@end deffn - -@deffn {Scheme Procedure} sloppy-assv key alist -@deffnx {C Function} scm_sloppy_assv (key, alist) -Behaves like @code{assv} but does not do any error checking. -Recommended only for use in Guile internals. -@end deffn - -@deffn {Scheme Procedure} sloppy-assoc key alist -@deffnx {C Function} scm_sloppy_assoc (key, alist) -Behaves like @code{assoc} but does not do any error checking. -Recommended only for use in Guile internals. -@end deffn - -@node Alist Example -@subsubsection Alist Example - -Here is a longer example of how alists may be used in practice. - -@lisp -(define capitals '(("New York" . "Albany") - ("Oregon" . "Salem") - ("Florida" . "Miami"))) - -;; What's the capital of Oregon? -(assoc "Oregon" capitals) @result{} ("Oregon" . "Salem") -(assoc-ref capitals "Oregon") @result{} "Salem" - -;; We left out South Dakota. -(set! capitals - (assoc-set! capitals "South Dakota" "Bismarck")) -capitals -@result{} (("South Dakota" . "Bismarck") - ("New York" . "Albany") - ("Oregon" . "Salem") - ("Florida" . "Miami")) - -;; And we got Florida wrong. -(set! capitals - (assoc-set! capitals "Florida" "Tallahassee")) -capitals -@result{} (("South Dakota" . "Bismarck") - ("New York" . "Albany") - ("Oregon" . "Salem") - ("Florida" . "Tallahassee")) - -;; After Oregon secedes, we can remove it. -(set! capitals - (assoc-remove! capitals "Oregon")) -capitals -@result{} (("South Dakota" . "Bismarck") - ("New York" . "Albany") - ("Florida" . "Tallahassee")) -@end lisp - -@node Hash Tables -@subsection Hash Tables -@tpindex Hash Tables - -@c FIXME::martin: Review me! - -Hash tables are dictionaries which offer similar functionality as -association lists: They provide a mapping from keys to values. The -difference is that association lists need time linear in the size of -elements when searching for entries, whereas hash tables can normally -search in constant time. The drawback is that hash tables require a -little bit more memory, and that you can not use the normal list -procedures (@pxref{Lists}) for working with them. - -@menu -* Hash Table Examples:: Demonstration of hash table usage. -* Hash Table Reference:: Hash table procedure descriptions. -@end menu - - -@node Hash Table Examples -@subsubsection Hash Table Examples - -@c FIXME::martin: Review me! - -For demonstration purposes, this section gives a few usage examples of -some hash table procedures, together with some explanation what they do. - -First we start by creating a new hash table with 31 slots, and -populate it with two key/value pairs. - -@lisp -(define h (make-hash-table 31)) - -(hashq-create-handle! h 'foo "bar") -@result{} -(foo . "bar") - -(hashq-create-handle! h 'braz "zonk") -@result{} -(braz . "zonk") - -(hashq-create-handle! h 'frob #f) -@result{} -(frob . #f) -@end lisp - -You can get the value for a given key with the procedure -@code{hashq-ref}, but the problem with this procedure is that you -cannot reliably determine whether a key does exists in the table. The -reason is that the procedure returns @code{#f} if the key is not in -the table, but it will return the same value if the key is in the -table and just happens to have the value @code{#f}, as you can see in -the following examples. - -@lisp -(hashq-ref h 'foo) -@result{} -"bar" - -(hashq-ref h 'frob) -@result{} -#f - -(hashq-ref h 'not-there) -@result{} -#f -@end lisp - -Better is to use the procedure @code{hashq-get-handle}, which makes a -distinction between the two cases. Just like @code{assq}, this -procedure returns a key/value-pair on success, and @code{#f} if the -key is not found. - -@lisp -(hashq-get-handle h 'foo) -@result{} -(foo . "bar") - -(hashq-get-handle h 'not-there) -@result{} -#f -@end lisp - -There is no procedure for calculating the number of key/value-pairs in -a hash table, but @code{hash-fold} can be used for doing exactly that. - -@lisp -(hash-fold (lambda (key value seed) (+ 1 seed)) 0 h) -@result{} -3 -@end lisp - -@node Hash Table Reference -@subsubsection Hash Table Reference - -Like the association list functions, the hash table functions come -in several varieties: @code{hashq}, @code{hashv}, and @code{hash}. -The @code{hashq} functions use @code{eq?} to determine whether two -keys match. The @code{hashv} functions use @code{eqv?}, and the -@code{hash} functions use @code{equal?}. - -In each of the functions that follow, the @var{table} argument -must be a vector. The @var{key} and @var{value} arguments may be -any Scheme object. - -@deffn {Scheme Procedure} make-hash-table size -Create a new hash table of @var{size} slots. Note that the number of -slots does not limit the size of the table, it just tells how large -the underlying vector will be. The @var{size} should be similar to -the expected number of elements which will be added to the table, but -they need not match. For good performance, it might be a good idea to -use a prime number as the @var{size}. -@end deffn - -@deffn {Scheme Procedure} hashq-ref table key [dflt] -@deffnx {C Function} scm_hashq_ref (table, key, dflt) -Look up @var{key} in the hash table @var{table}, and return the -value (if any) associated with it. If @var{key} is not found, -return @var{default} (or @code{#f} if no @var{default} argument -is supplied). Uses @code{eq?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hashv-ref table key [dflt] -@deffnx {C Function} scm_hashv_ref (table, key, dflt) -Look up @var{key} in the hash table @var{table}, and return the -value (if any) associated with it. If @var{key} is not found, -return @var{default} (or @code{#f} if no @var{default} argument -is supplied). Uses @code{eqv?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hash-ref table key [dflt] -@deffnx {C Function} scm_hash_ref (table, key, dflt) -Look up @var{key} in the hash table @var{table}, and return the -value (if any) associated with it. If @var{key} is not found, -return @var{default} (or @code{#f} if no @var{default} argument -is supplied). Uses @code{equal?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hashq-set! table key val -@deffnx {C Function} scm_hashq_set_x (table, key, val) -Find the entry in @var{table} associated with @var{key}, and -store @var{value} there. Uses @code{eq?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hashv-set! table key val -@deffnx {C Function} scm_hashv_set_x (table, key, val) -Find the entry in @var{table} associated with @var{key}, and -store @var{value} there. Uses @code{eqv?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hash-set! table key val -@deffnx {C Function} scm_hash_set_x (table, key, val) -Find the entry in @var{table} associated with @var{key}, and -store @var{value} there. Uses @code{equal?} for equality -testing. -@end deffn - -@deffn {Scheme Procedure} hashq-remove! table key -@deffnx {C Function} scm_hashq_remove_x (table, key) -Remove @var{key} (and any value associated with it) from -@var{table}. Uses @code{eq?} for equality tests. -@end deffn - -@deffn {Scheme Procedure} hashv-remove! table key -@deffnx {C Function} scm_hashv_remove_x (table, key) -Remove @var{key} (and any value associated with it) from -@var{table}. Uses @code{eqv?} for equality tests. -@end deffn - -@deffn {Scheme Procedure} hash-remove! table key -@deffnx {C Function} scm_hash_remove_x (table, key) -Remove @var{key} (and any value associated with it) from -@var{table}. Uses @code{equal?} for equality tests. -@end deffn - -The standard hash table functions may be too limited for some -applications. For example, you may want a hash table to store -strings in a case-insensitive manner, so that references to keys -named ``foobar'', ``FOOBAR'' and ``FooBaR'' will all yield the -same item. Guile provides you with @dfn{extended} hash tables -that permit you to specify a hash function and associator function -of your choosing. The functions described in the rest of this section -can be used to implement such custom hash table structures. - -If you are unfamiliar with the inner workings of hash tables, then -this facility will probably be a little too abstract for you to -use comfortably. If you are interested in learning more, see an -introductory textbook on data structures or algorithms for an -explanation of how hash tables are implemented. - -@deffn {Scheme Procedure} hashq key size -@deffnx {C Function} scm_hashq (key, size) -Determine a hash value for @var{key} that is suitable for -lookups in a hashtable of size @var{size}, where @code{eq?} is -used as the equality predicate. The function returns an -integer in the range 0 to @var{size} - 1. Note that -@code{hashq} may use internal addresses. Thus two calls to -hashq where the keys are @code{eq?} are not guaranteed to -deliver the same value if the key object gets garbage collected -in between. This can happen, for example with symbols: -@code{(hashq 'foo n) (gc) (hashq 'foo n)} may produce two -different values, since @code{foo} will be garbage collected. -@end deffn - -@deffn {Scheme Procedure} hashv key size -@deffnx {C Function} scm_hashv (key, size) -Determine a hash value for @var{key} that is suitable for -lookups in a hashtable of size @var{size}, where @code{eqv?} is -used as the equality predicate. The function returns an -integer in the range 0 to @var{size} - 1. Note that -@code{(hashv key)} may use internal addresses. Thus two calls -to hashv where the keys are @code{eqv?} are not guaranteed to -deliver the same value if the key object gets garbage collected -in between. This can happen, for example with symbols: -@code{(hashv 'foo n) (gc) (hashv 'foo n)} may produce two -different values, since @code{foo} will be garbage collected. -@end deffn - -@deffn {Scheme Procedure} hash key size -@deffnx {C Function} scm_hash (key, size) -Determine a hash value for @var{key} that is suitable for -lookups in a hashtable of size @var{size}, where @code{equal?} -is used as the equality predicate. The function returns an -integer in the range 0 to @var{size} - 1. -@end deffn - -@deffn {Scheme Procedure} hashx-ref hash assoc table key [dflt] -@deffnx {C Function} scm_hashx_ref (hash, assoc, table, key, dflt) -This behaves the same way as the corresponding @code{ref} -function, but uses @var{hash} as a hash function and -@var{assoc} to compare keys. @code{hash} must be a function -that takes two arguments, a key to be hashed and a table size. -@code{assoc} must be an associator function, like @code{assoc}, -@code{assq} or @code{assv}. - -By way of illustration, @code{hashq-ref table key} is -equivalent to @code{hashx-ref hashq assq table key}. -@end deffn - -@deffn {Scheme Procedure} hashx-set! hash assoc table key val -@deffnx {C Function} scm_hashx_set_x (hash, assoc, table, key, val) -This behaves the same way as the corresponding @code{set!} -function, but uses @var{hash} as a hash function and -@var{assoc} to compare keys. @code{hash} must be a function -that takes two arguments, a key to be hashed and a table size. -@code{assoc} must be an associator function, like @code{assoc}, -@code{assq} or @code{assv}. - - By way of illustration, @code{hashq-set! table key} is -equivalent to @code{hashx-set! hashq assq table key}. -@end deffn - -@deffn {Scheme Procedure} hashq-get-handle table key -@deffnx {C Function} scm_hashq_get_handle (table, key) -This procedure returns the @code{(key . value)} pair from the -hash table @var{table}. If @var{table} does not hold an -associated value for @var{key}, @code{#f} is returned. -Uses @code{eq?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hashv-get-handle table key -@deffnx {C Function} scm_hashv_get_handle (table, key) -This procedure returns the @code{(key . value)} pair from the -hash table @var{table}. If @var{table} does not hold an -associated value for @var{key}, @code{#f} is returned. -Uses @code{eqv?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hash-get-handle table key -@deffnx {C Function} scm_hash_get_handle (table, key) -This procedure returns the @code{(key . value)} pair from the -hash table @var{table}. If @var{table} does not hold an -associated value for @var{key}, @code{#f} is returned. -Uses @code{equal?} for equality testing. -@end deffn - -@deffn {Scheme Procedure} hashx-get-handle hash assoc table key -@deffnx {C Function} scm_hashx_get_handle (hash, assoc, table, key) -This behaves the same way as the corresponding -@code{-get-handle} function, but uses @var{hash} as a hash -function and @var{assoc} to compare keys. @code{hash} must be -a function that takes two arguments, a key to be hashed and a -table size. @code{assoc} must be an associator function, like -@code{assoc}, @code{assq} or @code{assv}. -@end deffn - -@deffn {Scheme Procedure} hashq-create-handle! table key init -@deffnx {C Function} scm_hashq_create_handle_x (table, key, init) -This function looks up @var{key} in @var{table} and returns its handle. -If @var{key} is not already present, a new handle is created which -associates @var{key} with @var{init}. -@end deffn - -@deffn {Scheme Procedure} hashv-create-handle! table key init -@deffnx {C Function} scm_hashv_create_handle_x (table, key, init) -This function looks up @var{key} in @var{table} and returns its handle. -If @var{key} is not already present, a new handle is created which -associates @var{key} with @var{init}. -@end deffn - -@deffn {Scheme Procedure} hash-create-handle! table key init -@deffnx {C Function} scm_hash_create_handle_x (table, key, init) -This function looks up @var{key} in @var{table} and returns its handle. -If @var{key} is not already present, a new handle is created which -associates @var{key} with @var{init}. -@end deffn - -@deffn {Scheme Procedure} hashx-create-handle! hash assoc table key init -@deffnx {C Function} scm_hashx_create_handle_x (hash, assoc, table, key, init) -This behaves the same way as the corresponding -@code{-create-handle} function, but uses @var{hash} as a hash -function and @var{assoc} to compare keys. @code{hash} must be -a function that takes two arguments, a key to be hashed and a -table size. @code{assoc} must be an associator function, like -@code{assoc}, @code{assq} or @code{assv}. -@end deffn - -@deffn {Scheme Procedure} hash-fold proc init table -@deffnx {C Function} scm_hash_fold (proc, init, table) -An iterator over hash-table elements. -Accumulates and returns a result by applying PROC successively. -The arguments to PROC are "(key value prior-result)" where key -and value are successive pairs from the hash table TABLE, and -prior-result is either INIT (for the first application of PROC) -or the return value of the previous application of PROC. -For example, @code{(hash-fold acons '() tab)} will convert a hash -table into an a-list of key-value pairs. -@end deffn - - -@node Hooks -@section Hooks -@tpindex Hooks - -@c FIXME::martin: Review me! - -A hook is basically a list of procedures to be called at well defined -points in time. Hooks are used internally for several debugging -facilities, but they can be used in user code, too. - -Hooks are created with @code{make-hook}, then procedures can be added to -a hook with @code{add-hook!} or removed with @code{remove-hook!} or -@code{reset-hook!}. The procedures stored in a hook can be invoked with -@code{run-hook}. - -@menu -* Hook Examples:: Hook usage by example. -* Hook Reference:: Reference of all hook procedures. -@end menu - -@node Hook Examples -@subsection Hook Examples - -Hook usage is shown by some examples in this section. First, we will -define a hook of arity 2 --- that is, the procedures stored in the hook -will have to accept two arguments. - -@lisp -(define hook (make-hook 2)) -hook -@result{} # -@end lisp - -Now we are ready to add some procedures to the newly created hook with -@code{add-hook!}. In the following example, two procedures are added, -which print different messages and do different things with their -arguments. When the procedures have been added, we can invoke them -using @code{run-hook}. - -@lisp -(add-hook! hook (lambda (x y) - (display "Foo: ") - (display (+ x y)) - (newline))) -(add-hook! hook (lambda (x y) - (display "Bar: ") - (display (* x y)) - (newline))) -(run-hook hook 3 4) -@print{} Bar: 12 -@print{} Foo: 7 -@end lisp - -Note that the procedures are called in reverse order than they were -added. This can be changed by providing the optional third argument -on the second call to @code{add-hook!}. - -@lisp -(add-hook! hook (lambda (x y) - (display "Foo: ") - (display (+ x y)) - (newline))) -(add-hook! hook (lambda (x y) - (display "Bar: ") - (display (* x y)) - (newline)) - #t) ; @r{<- Change here!} -(run-hook hook 3 4) -@print{} Foo: 7 -@print{} Bar: 12 -@end lisp - -@node Hook Reference -@subsection Hook Reference - -When a hook is created with @code{make-hook}, you can supply the arity -of the procedures which can be added to the hook. The arity defaults to -zero. All procedures of a hook must have the same arity, and when the -procedures are invoked using @code{run-hook}, the number of arguments -must match the arity of the procedures. - -The order in which procedures are added to a hook matters. If the third -parameter to @var{add-hook!} is omitted or is equal to @code{#f}, the -procedure is added in front of the procedures which might already be on -that hook, otherwise the procedure is added at the end. The procedures -are always called from first to last when they are invoked via -@code{run-hook}. - -When calling @code{hook->list}, the procedures in the resulting list are -in the same order as they would have been called by @code{run-hook}. - -@deffn {Scheme Procedure} make-hook [n_args] -@deffnx {C Function} scm_make_hook (n_args) -Create a hook for storing procedure of arity @var{n_args}. -@var{n_args} defaults to zero. The returned value is a hook -object to be used with the other hook procedures. -@end deffn - -@deffn {Scheme Procedure} hook? x -@deffnx {C Function} scm_hook_p (x) -Return @code{#t} if @var{x} is a hook, @code{#f} otherwise. -@end deffn - -@deffn {Scheme Procedure} hook-empty? hook -@deffnx {C Function} scm_hook_empty_p (hook) -Return @code{#t} if @var{hook} is an empty hook, @code{#f} -otherwise. -@end deffn - -@deffn {Scheme Procedure} add-hook! hook proc [append_p] -@deffnx {C Function} scm_add_hook_x (hook, proc, append_p) -Add the procedure @var{proc} to the hook @var{hook}. The -procedure is added to the end if @var{append_p} is true, -otherwise it is added to the front. The return value of this -procedure is not specified. -@end deffn - -@deffn {Scheme Procedure} remove-hook! hook proc -@deffnx {C Function} scm_remove_hook_x (hook, proc) -Remove the procedure @var{proc} from the hook @var{hook}. The -return value of this procedure is not specified. -@end deffn - -@deffn {Scheme Procedure} reset-hook! hook -@deffnx {C Function} scm_reset_hook_x (hook) -Remove all procedures from the hook @var{hook}. The return -value of this procedure is not specified. -@end deffn - -@deffn {Scheme Procedure} run-hook hook . args -@deffnx {C Function} scm_run_hook (hook, args) -Apply all procedures from the hook @var{hook} to the arguments -@var{args}. The order of the procedure application is first to -last. The return value of this procedure is not specified. -@end deffn - -@deffn {Scheme Procedure} hook->list hook -@deffnx {C Function} scm_hook_to_list (hook) -Convert the procedure list of @var{hook} to a list. -@end deffn - - -@node Other Data Types -@section Other Core Guile Data Types @c Local Variables: @c TeX-master: "guile.texi" diff --git a/doc/ref/scheme-utility.texi b/doc/ref/scheme-utility.texi index cc44f42ce..d4e2de14d 100644 --- a/doc/ref/scheme-utility.texi +++ b/doc/ref/scheme-utility.texi @@ -6,15 +6,16 @@ This chapter contains information about procedures which are not cleanly tied to a specific data type. Because of their wide range of -applications, they are collected in a @dfn{utlity} chapter. +applications, they are collected in a @dfn{utility} chapter. @menu * Equality:: When are two values `the same'? * Property Lists:: Managing metainformation about Scheme objects. -* Primitive Properties:: A modern low-level interface to object properties. +* Primitive Properties:: A modern interface to object properties. * Sorting:: Sort utility procedures. * Copying:: Copying deep structures. * General Conversion:: Converting objects to strings. +* Hooks:: User-customizable event lists. @end menu @@ -308,6 +309,148 @@ argument @var{printer} (default: @code{write}). @end deffn +@node Hooks +@section Hooks +@tpindex Hooks + +@c FIXME::martin: Review me! + +A hook is basically a list of procedures to be called at well defined +points in time. Hooks are used internally for several debugging +facilities, but they can be used in user code, too. + +Hooks are created with @code{make-hook}, then procedures can be added to +a hook with @code{add-hook!} or removed with @code{remove-hook!} or +@code{reset-hook!}. The procedures stored in a hook can be invoked with +@code{run-hook}. + +@menu +* Hook Examples:: Hook usage by example. +* Hook Reference:: Reference of all hook procedures. +@end menu + +@node Hook Examples +@subsection Hook Examples + +Hook usage is shown by some examples in this section. First, we will +define a hook of arity 2 --- that is, the procedures stored in the hook +will have to accept two arguments. + +@lisp +(define hook (make-hook 2)) +hook +@result{} # +@end lisp + +Now we are ready to add some procedures to the newly created hook with +@code{add-hook!}. In the following example, two procedures are added, +which print different messages and do different things with their +arguments. When the procedures have been added, we can invoke them +using @code{run-hook}. + +@lisp +(add-hook! hook (lambda (x y) + (display "Foo: ") + (display (+ x y)) + (newline))) +(add-hook! hook (lambda (x y) + (display "Bar: ") + (display (* x y)) + (newline))) +(run-hook hook 3 4) +@print{} Bar: 12 +@print{} Foo: 7 +@end lisp + +Note that the procedures are called in reverse order than they were +added. This can be changed by providing the optional third argument +on the second call to @code{add-hook!}. + +@lisp +(add-hook! hook (lambda (x y) + (display "Foo: ") + (display (+ x y)) + (newline))) +(add-hook! hook (lambda (x y) + (display "Bar: ") + (display (* x y)) + (newline)) + #t) ; @r{<- Change here!} +(run-hook hook 3 4) +@print{} Foo: 7 +@print{} Bar: 12 +@end lisp + +@node Hook Reference +@subsection Hook Reference + +When a hook is created with @code{make-hook}, you can supply the arity +of the procedures which can be added to the hook. The arity defaults to +zero. All procedures of a hook must have the same arity, and when the +procedures are invoked using @code{run-hook}, the number of arguments +must match the arity of the procedures. + +The order in which procedures are added to a hook matters. If the third +parameter to @var{add-hook!} is omitted or is equal to @code{#f}, the +procedure is added in front of the procedures which might already be on +that hook, otherwise the procedure is added at the end. The procedures +are always called from first to last when they are invoked via +@code{run-hook}. + +When calling @code{hook->list}, the procedures in the resulting list are +in the same order as they would have been called by @code{run-hook}. + +@deffn {Scheme Procedure} make-hook [n_args] +@deffnx {C Function} scm_make_hook (n_args) +Create a hook for storing procedure of arity @var{n_args}. +@var{n_args} defaults to zero. The returned value is a hook +object to be used with the other hook procedures. +@end deffn + +@deffn {Scheme Procedure} hook? x +@deffnx {C Function} scm_hook_p (x) +Return @code{#t} if @var{x} is a hook, @code{#f} otherwise. +@end deffn + +@deffn {Scheme Procedure} hook-empty? hook +@deffnx {C Function} scm_hook_empty_p (hook) +Return @code{#t} if @var{hook} is an empty hook, @code{#f} +otherwise. +@end deffn + +@deffn {Scheme Procedure} add-hook! hook proc [append_p] +@deffnx {C Function} scm_add_hook_x (hook, proc, append_p) +Add the procedure @var{proc} to the hook @var{hook}. The +procedure is added to the end if @var{append_p} is true, +otherwise it is added to the front. The return value of this +procedure is not specified. +@end deffn + +@deffn {Scheme Procedure} remove-hook! hook proc +@deffnx {C Function} scm_remove_hook_x (hook, proc) +Remove the procedure @var{proc} from the hook @var{hook}. The +return value of this procedure is not specified. +@end deffn + +@deffn {Scheme Procedure} reset-hook! hook +@deffnx {C Function} scm_reset_hook_x (hook) +Remove all procedures from the hook @var{hook}. The return +value of this procedure is not specified. +@end deffn + +@deffn {Scheme Procedure} run-hook hook . args +@deffnx {C Function} scm_run_hook (hook, args) +Apply all procedures from the hook @var{hook} to the arguments +@var{args}. The order of the procedure application is first to +last. The return value of this procedure is not specified. +@end deffn + +@deffn {Scheme Procedure} hook->list hook +@deffnx {C Function} scm_hook_to_list (hook) +Convert the procedure list of @var{hook} to a list. +@end deffn + + @c Local Variables: @c TeX-master: "guile.texi" @c End: From a056b7708ba216c2af93894243e58c1767311eea Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 2 Dec 2001 01:38:56 +0000 Subject: [PATCH 250/281] Fix virulent typo. --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 671b8ae21..6151d0d8c 100644 --- a/README +++ b/README @@ -121,17 +121,17 @@ It works like this: variable GUILE_WARN_DEPRECATED. A value of "yes" is changed to "summary" and "shutup" is changed to "no", however. - When GUILE_WARN_DEPRECATION has the value "no", nothing special will + When GUILE_WARN_DEPRECATED has the value "no", nothing special will happen when a deprecated feature is used. - When GUILE_WARN_DEPRECATION has the value "summary", and a deprecated + When GUILE_WARN_DEPRECATED has the value "summary", and a deprecated feature has been used, Guile will print this message at exit: Some deprecated features have been used. Set the environment variable GUILE_WARN_DEPRECATED to "detailed" and rerun the program to get more information. Set it to "no" to suppress this message. - When GUILE_WARN_DEPRECATION has the value "detailed", a detailed + When GUILE_WARN_DEPRECATED has the value "detailed", a detailed warning is emitted immediatly for the first use of a deprecated feature. From 6d852be383d1fc6dece16b9248c8d6fc0e503cd1 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 2 Dec 2001 01:40:53 +0000 Subject: [PATCH 251/281] *** empty log message *** --- ChangeLog | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee6d80cab..7b34465c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,14 @@ +2001-12-01 Thien-Thi Nguyen + + * README: Fix virulent typo. + 2001-11-25 Marius Vollmer - * acconfig.h (HAVE_INLINE): Added template. + * acconfig.h (HAVE_INLINE): Added template. * configure.in (HAVE_INLINE): Define it when the compiler supports inline functions. - * libguile.h: Include "libguile/inline.h". + * libguile.h: Include "libguile/inline.h". 2001-11-22 Gary Houston From ddee39a16b61b11f15297cc3670e24d4f3fccca4 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 3 Dec 2001 11:24:44 +0000 Subject: [PATCH 252/281] Grammar fix. --- doc/goops/goops.texi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/goops/goops.texi b/doc/goops/goops.texi index 2e1909f36..230bd3eb2 100644 --- a/doc/goops/goops.texi +++ b/doc/goops/goops.texi @@ -92,9 +92,9 @@ The GOOPS tutorial * Tutorial:: -* Index:: -* Concept Index:: -* Function and Variable Index:: +* Index:: +* Concept Index:: +* Function and Variable Index:: @end menu @iftex @@ -136,7 +136,7 @@ info (goops.info) and texinfo format. @node Running GOOPS, Methods, Getting Started, Getting Started @subsection Running GOOPS - + @enumerate @item Type @@ -277,7 +277,7 @@ concerned with internals and customization. In general, this reference manual assumes familiarity with standard object oriented concepts and terminology. However, some of the terms -used in GOOPS is less well known, so the Terminology subsection +used in GOOPS are less well known, so the Terminology subsection provides definitions for these terms. @menu @@ -1121,7 +1121,7 @@ allocation to do this. (c #:allocation #:batched) ... #:metaclass ) -@end example +@end example The usage of @code{compute-getter-method} and @code{compute-setter-method} is described in @ref{MOP Specification}. @@ -2687,7 +2687,7 @@ Actually it sometimes calls @code{change-class} and sometimes @code{change-object-class}, and I don't understand why. ] The default @code{change-class} method copies slot values from the old -to the modified instance, and initializes new slots, as described in +to the modified instance, and initializes new slots, as described in @ref{Changing the Class of an Instance}. After doing so, it makes a generic function invocation that can be used to customize the instance update algorithm. From 2b02270392652518a73e8a4d2dfb754c04914416 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Mon, 3 Dec 2001 11:25:28 +0000 Subject: [PATCH 253/281] *** empty log message *** --- doc/goops/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/goops/ChangeLog b/doc/goops/ChangeLog index 2328d10d8..e95e04352 100644 --- a/doc/goops/ChangeLog +++ b/doc/goops/ChangeLog @@ -1,3 +1,7 @@ +2001-12-03 Thien-Thi Nguyen + + * goops.texi: Grammar fix. + 2001-08-27 Neil Jerram * Makefile.am (goops_TEXINFOS): Remove ../AUTHORS. From a5df04d5d5d12edc02346d01e7983796cb505ca5 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Mon, 3 Dec 2001 18:35:15 +0000 Subject: [PATCH 254/281] *** empty log message *** --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 7b34465c0..1c877dd51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ * HACKING: Modified the Hacking It Yourself section. Removed the version numbers from the tools. + HACKING, README, ANON-CVS: updates. 2001-11-21 Gary Houston From 923d5b87d7261c76bd4510081d58d13fe131b7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grabm=C3=BCller?= Date: Tue, 4 Dec 2001 11:24:43 +0000 Subject: [PATCH 255/281] Small typo fix in scheme-procedures.texi. --- doc/ref/ChangeLog | 5 +++++ doc/ref/scheme-procedures.texi | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index c835c2136..d77e48653 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-12-04 Martin Grabmueller + + * scheme-procedures.texi (Optional Arguments): Typo fix: wither -> + either. + 2001-12-01 Neil Jerram * scheme-data.texi (Hooks): Moved into scheme-utility.texi. diff --git a/doc/ref/scheme-procedures.texi b/doc/ref/scheme-procedures.texi index bc186c9e5..2ba773ebf 100644 --- a/doc/ref/scheme-procedures.texi +++ b/doc/ref/scheme-procedures.texi @@ -86,7 +86,7 @@ order when the procedure is invoked. @c FIXME::martin: Review me! -Scheme procedures, as defined in R5RS, can wither handle a fixed number +Scheme procedures, as defined in R5RS, can either handle a fixed number of actual arguments, or a fixed number of actual arguments followed by arbitrarily many additional arguments. Writing procedures of variable arity can be useful, but unfortunately, the syntactic means for handling From 5a8164b26077188a9e918e4182bfb001ec7fafbf Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Tue, 4 Dec 2001 12:48:28 +0000 Subject: [PATCH 256/281] * some discussion in extension/dynamic-root.text. --- devel/ChangeLog | 4 +++ devel/extension/dynamic-root.text | 50 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/devel/ChangeLog b/devel/ChangeLog index 6d6c09813..b60980387 100644 --- a/devel/ChangeLog +++ b/devel/ChangeLog @@ -1,3 +1,7 @@ +2001-12-04 Gary Houston + + * some discussion in extension/dynamic-root.text. + 2001-11-28 Gary Houston * added extension directory and extension/dynamic-root.text with diff --git a/devel/extension/dynamic-root.text b/devel/extension/dynamic-root.text index edf714f78..184e81940 100644 --- a/devel/extension/dynamic-root.text +++ b/devel/extension/dynamic-root.text @@ -24,5 +24,55 @@ whether a new interface should also be available to Scheme code. Discussion ========== +There are two ways that longjmp may be invoked from a Scheme callback: +raising an exception or invoking a continuation. Exceptions can be +caught using scm_internal_catch, so it could be argued that the new +interface only needs to block continuations. + +However there are two problems with this: firstly it's unlikely that +anybody would want to block continuations without also catching +exceptions, so it's more convenient to use a single facility set up +both types of blocking. Secondly, the fact that exceptions and +continuations can be treated separately in Guile is just an +implementation detail: in general in Scheme it's possible to use +continuations to implement an exception mechanism, and it's +undesirable to tie a new language feature to an implementation detail +when it can be avoided, even at the C level. + +Hence, the interface should take at least a) the callback to be +protected b) and exception handler and associated handler data to be +passed to scm_internal_catch. + +On which side of the continuation barrier should be exception handler +be installed? Logically it belongs on the same side as the callback: +i.e., if the callback raises an exception then the handler can catch +it without crossing it the continuation barrier. But what happens if +the handler raises another exception? This doesn't seem like an +important concern, since the hander is under control of the same C +code that is trying to protect itself. It should be sufficient to +warn in the documentation that such exceptions produce undefined +behaviour and allow them to cross the continuation barrier. + +How should the callback procedure be passed to the interface and +invoked? Should it be like scm_internal_catch where it's passed as a +C procedure (scm_t_catch_body) which is applied to user data (void *)? +For a procedure designed to be used from C, this is the most +convenient, since constructing closures in C is not very convenient. +It also gives symmetry with scm_internal_catch. + +Hence the first four arguments to the C interface should be the same as for +the old scm_internal_cwdr: + +scm_t_catch_body body, void *body_data, +scm_t_catch_handler handler, void *handler_data + +The return value from the interface should be the result of calling +the body, unless an exception occurred in which case it's the result +of calling the handler. So the return type is SCM, as for +scm_internal_catch. + +Yet to be discussed: libguile usage and threads, error handling and +reporting, convenience of use, Scheme-level interface. + Proposal ======== From 11923b5d40fea9e67c00bbbe88b488318b2157e2 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Tue, 4 Dec 2001 15:10:16 +0000 Subject: [PATCH 257/281] *** empty log message *** --- devel/extension/dynamic-root.text | 32 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/devel/extension/dynamic-root.text b/devel/extension/dynamic-root.text index 184e81940..87d351854 100644 --- a/devel/extension/dynamic-root.text +++ b/devel/extension/dynamic-root.text @@ -48,31 +48,39 @@ be installed? Logically it belongs on the same side as the callback: i.e., if the callback raises an exception then the handler can catch it without crossing it the continuation barrier. But what happens if the handler raises another exception? This doesn't seem like an -important concern, since the hander is under control of the same C -code that is trying to protect itself. It should be sufficient to -warn in the documentation that such exceptions produce undefined -behaviour and allow them to cross the continuation barrier. +important concern, since the hander is under control of the code that +is trying to protect itself. It should be sufficient to warn in the +documentation that such exceptions produce undefined behaviour and +allow them to cross the continuation barrier. How should the callback procedure be passed to the interface and invoked? Should it be like scm_internal_catch where it's passed as a C procedure (scm_t_catch_body) which is applied to user data (void *)? For a procedure designed to be used from C, this is the most -convenient, since constructing closures in C is not very convenient. -It also gives symmetry with scm_internal_catch. +convenient, since constructing closures in C is difficult. It also +gives symmetry with scm_internal_catch. -Hence the first four arguments to the C interface should be the same as for -the old scm_internal_cwdr: +On the other hand, the body procedure is expected to be a Scheme +closure in most cases. This suggests implementing two C procedures, +the first taking four arguments: scm_t_catch_body body, void *body_data, scm_t_catch_handler handler, void *handler_data -The return value from the interface should be the result of calling +and the second taking three arguments: +SCM body, scm_t_catch_handler handler, void *handler_data + +If there is also to be a Scheme interface, then it would be implemented +with a third variant: +SCM body, SCM handler + +The second and third variants would be implemented by calling the +first, similar to the old scm_call_with_dynamic_root and its wrappers. + +The return value from all variants should be the result of calling the body, unless an exception occurred in which case it's the result of calling the handler. So the return type is SCM, as for scm_internal_catch. Yet to be discussed: libguile usage and threads, error handling and reporting, convenience of use, Scheme-level interface. - -Proposal -======== From de513fa003cb441437176ff4cecd4d07ef47d14b Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Fri, 7 Dec 2001 17:03:15 +0000 Subject: [PATCH 258/281] * Fix comment typo. --- libguile/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libguile/eval.c b/libguile/eval.c index 126015e1c..ec0118f8e 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -247,7 +247,7 @@ scm_ilookup (SCM iloc, SCM env) reconsider the complete special form. SCM_LOOKUPCAR is still there, of course. It just calls - SCM_LOOKUPCAR1 and aborts on recieving NULL. So SCM_LOOKUPCAR + SCM_LOOKUPCAR1 and aborts on receiving NULL. So SCM_LOOKUPCAR should only be called when it is known that VLOC is not the first pair of a special form. Otherwise, use SCM_LOOKUPCAR1 and check for NULL. I think I've found the only places where this From a7a7bb95eb2d62ceeac14b236c5b6c9f80b002af Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Fri, 7 Dec 2001 17:08:19 +0000 Subject: [PATCH 259/281] * Various small manual improvements. --- doc/ref/ChangeLog | 13 +++++++ doc/ref/guile.texi | 11 ++++-- doc/ref/intro.texi | 4 +-- doc/ref/program.texi | 28 ++++++--------- doc/ref/scheme-ideas.texi | 59 ++++++++++++++++---------------- doc/ref/scm.texi | 71 ++++++++++++++++++++++++++++++++++++--- 6 files changed, 131 insertions(+), 55 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index d77e48653..69b8a4847 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,16 @@ +2001-12-07 Neil Jerram + + * scm.texi (Guile API): Renamed from `Scheme Primitives' and + broadened so that this chapter discusses the Guile API as a whole. + + * program.texi (Available Functionality): Revise so that text + reads better. + + * guile.texi (Programming Intro): New introductory text. + + * scheme-ideas.texi (Definition): Reorder reference bullets in + ascending page number order. + 2001-12-04 Martin Grabmueller * scheme-procedures.texi (Optional Arguments): Typo fix: wither -> diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index ca21c17c2..7761cffb7 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -94,7 +94,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.8 2001-12-01 21:48:30 ossau Exp $ +@subtitle $Id: guile.texi,v 1.9 2001-12-07 17:08:19 ossau Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -216,7 +216,7 @@ Part II: Programming with Guile * Guile Scripting:: How to write Guile scripts. * Command Line Handling:: Command line options and arguments. * Libguile Intro:: Using Guile as an extension language. -* Scheme Primitives:: Writing Scheme primitives in C. +* Guile API:: Overview of the Guile API. * Data Representation:: Data representation in Guile. * GH:: The deprecated GH interface. * Debugger User Interface:: @@ -285,7 +285,7 @@ guidelines and tips for @emph{how} to program in Guile, and to document the tools that are available to help you with your programming. For detailed reference information on the variables, functions etc. that make up Guile's application programming interface (API), please refer to -Part III (@pxref{Reference Intro,,Part III: Programming with Guile}). +Part III (@pxref{Reference Intro,,Part III --- Guile API Reference}). We begin in the first chapter of this part by looking at the programming options available. @@ -306,6 +306,11 @@ options available. @node Reference Intro @unnumbered Part III: Guile API Reference +Guile provides an application programming interface (@dfn{API}) to +developers in two core languages: Scheme and C. This part of the manual +contains reference documentation for all of the functionality that is +available through both Scheme and C interfaces. + @include scheme-data.texi @include scheme-compound.texi @include scheme-procedures.texi diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi index 09da686c6..8b786fe47 100644 --- a/doc/ref/intro.texi +++ b/doc/ref/intro.texi @@ -1,4 +1,4 @@ -@c $Id: intro.texi,v 1.4 2001-11-16 15:04:16 ossau Exp $ +@c $Id: intro.texi,v 1.5 2001-12-07 17:08:19 ossau Exp $ @page @@ -352,7 +352,7 @@ with Guile on a typical POSIX system. Parts III and IV of this manual describe the C functions Guile provides. Furthermore, any Scheme function described in this manual as a -``Primitive'' is also callable from C; see @ref{Scheme Primitives}. +``Primitive'' is also callable from C; see @ref{Primitives}. The header file @code{} provides declarations for all of Guile's functions and constants. You should @code{#include} it at the diff --git a/doc/ref/program.texi b/doc/ref/program.texi index e9c3dccd4..4f5ff2e1d 100644 --- a/doc/ref/program.texi +++ b/doc/ref/program.texi @@ -83,24 +83,18 @@ is growing quickly and already includes such useful examples as Scheme, and @code{(database postgres)}, which provides SQL access to a Postgres database. -In practice, therefore, it is quite feasible that your application can -be implemented by combining together a selection of pre-existing modules -with new application code written in Scheme, and approach may -suffice for the application that you want to write. +Given the growing collection of pre-existing modules, it is quite +feasible that your application could be implemented by combining a +selection of these modules together with new application code written in +Scheme. -If it does not suffice, because the functionality that your application -needs is not already available in this form (and assuming that it's -impossible or unacceptable for performance reasons to write the new -functionality in Scheme), you will need to write some C code. - -@itemize @bullet -@item -If the required function is already written (e.g. in a library), you -only need a little glue to connect it to the world of Guile. - -@item -If not, you need to write the basic code as well. -@end itemize +If this approach is not enough, because the functionality that your +application needs is not already available in this form, or because it +is impossible or unacceptable (e.g. for performance reasons) to write +the new functionality in Scheme, you will need to write some C code. If +the required function is already available in C (e.g. in a library), all +you need is a little glue to connect it to the world of Guile. If not, +you need both to write the basic code and to plumb it into Guile. In either case, two general considerations are important. Firstly, what is the interface by which the functionality is presented to the Scheme diff --git a/doc/ref/scheme-ideas.texi b/doc/ref/scheme-ideas.texi index 7de9d9376..3ef2afe32 100644 --- a/doc/ref/scheme-ideas.texi +++ b/doc/ref/scheme-ideas.texi @@ -177,12 +177,6 @@ about those missing pieces immediately by jumping ahead to the following references. @itemize @bullet -@item -@xref{Internal Definitions}, to read about using @code{define} other -than at top level in a Scheme program, including a discussion of when it -works to use @code{define} rather than @code{set!} to change the value -of an existing variable. - @item @ref{Lambda Alternatives}, to read about an alternative form of the @code{define} syntax that can be used when defining new procedures. @@ -191,6 +185,12 @@ of an existing variable. @ref{Procedures with Setters}, to read about an alternative form of the @code{set!} syntax that helps with changing a single value in the depths of a compound data structure.) + +@item +@xref{Internal Definitions}, to read about using @code{define} other +than at top level in a Scheme program, including a discussion of when it +works to use @code{define} rather than @code{set!} to change the value +of an existing variable. @end itemize @@ -384,7 +384,7 @@ this: @end lisp @noindent -This is a valid procedure invocation expression, whose result is the +This is a valid procedure invocation expression, and its result is the string @code{"Name=FSF:Address=Cambridge"}. It it more common, though, to store the procedure value in a variable --- @@ -756,9 +756,9 @@ answers yes. If the outermost @code{(if @dots{})} expression here was a procedure invocation expression, the expression @code{(delete-file file)}, whose -effect is to actually delete a file, would already have been executed -before the @code{if} procedure even got invoked! Clearly this is no use ---- the whole point of an @code{if} expression is that the +side effect is to actually delete a file, would already have been +evaluated before the @code{if} procedure even got invoked! Clearly this +is no use --- the whole point of an @code{if} expression is that the @dfn{consequent} expression is only evaluated if the condition of the @code{if} expression is ``true''. @@ -815,21 +815,14 @@ expressions, simply so that you will recognize common special syntax when you see it. For a full description of each of these syntaxes, follow the appropriate reference. -@code{if} and @code{cond} (@pxref{if cond case}) provide conditional -evaluation of argument expressions depending on whether one or more -conditions evaluate to ``true'' or ``false''. - -@code{case} (@pxref{if cond case}) provides conditional evaluation of -argument expressions depending on whether a variable has one of a -specified group of values. - -@code{define} (REFFIXME) is used to create a new variable and set its -initial value. - -@code{set!} (REFFIXME) is used to modify an existing variable's value. - @code{lambda} (@pxref{Lambda}) is used to construct procedure objects. +@code{define} (@pxref{Top Level}) is used to create a new variable and +set its initial value. + +@code{set!} (@pxref{Top Level}) is used to modify an existing variable's +value. + @code{let}, @code{let*} and @code{letrec} (@pxref{Local Bindings}) create an inner lexical environment for the evaluation of a sequence of expressions, in which a specified set of local variables is bound to the @@ -842,6 +835,14 @@ same as a procedure which returns its last argument, because the evaluation of a procedure invocation expression does not guarantee to evaluate the arguments in order. +@code{if} and @code{cond} (@pxref{if cond case}) provide conditional +evaluation of argument expressions depending on whether one or more +conditions evaluate to ``true'' or ``false''. + +@code{case} (@pxref{if cond case}) provides conditional evaluation of +argument expressions depending on whether a variable has one of a +specified group of values. + @code{and} (@pxref{and or}) executes a sequence of expressions in order until either there are no expressions left, or one of them evaluates to ``false''. @@ -1312,12 +1313,12 @@ It can only be accessed indirectly via @code{get-balance} or -25 @end lisp -A detail here is that the @code{get-balance} and @code{deposit} -variables must be set up by @code{define}ing them at top level and then -@code{set!}ing their values inside the @code{let} body. Using -@code{define} within the @code{let} body would not work: this would -create variable bindings within the local @code{let} environment that -would not be accessible at top level. +An important detail here is that the @code{get-balance} and +@code{deposit} variables must be set up by @code{define}ing them at top +level and then @code{set!}ing their values inside the @code{let} body. +Using @code{define} within the @code{let} body would not work: this +would create variable bindings within the local @code{let} environment +that would not be accessible at top level. @node Callback Closure diff --git a/doc/ref/scm.texi b/doc/ref/scm.texi index 948823afb..5e5e521bd 100644 --- a/doc/ref/scm.texi +++ b/doc/ref/scm.texi @@ -1,8 +1,58 @@ @page -@node Scheme Primitives +@node Guile API +@chapter Overview of the Guile API + +Guile's application programming interface (@dfn{API}) makes +functionality available that an application developer can use in either +C or Scheme programming. The interface consists of @dfn{elements} that +may be macros, functions or variables in C, and procedures, variables, +syntax or other types of object in Scheme. Broadly speaking, the +interface as a whole can be divided into three groups. + +@enumerate +@item +Elements that are available equivalently as C functions or Scheme +procedures. + +@item +Elements that are only available as macros, functions or variables for C +programming. + +@item +Elements that are only available as procedures or other objects in +Scheme. +@end enumerate + +Functions/procedures in the first group are often known as +@dfn{primitives}, @dfn{subrs} or @dfn{builtins}. An example is the +@code{assq} Scheme procedure, which is also available as @code{scm_assq} +in C. + +Elements in the second and third groups exist because they provide +additional language-specific benefits in either Scheme or C. Examples +are the C macro @code{SCM_CONSP}, which is faster and more convenient in +C programming than the primitive @code{scm_pair_p}, and the +procedure-with-setter @code{make-object-property}, which provides a +more convenient property handling interface in Scheme than the +primitives on which it is based. + +@menu +* Primitives:: Identical function for Scheme and C. +* C Only:: Elements only available in C. +* Scheme Only:: Elements only available in Scheme. +@end menu + + +@node Primitives +@section Identical Function in both Scheme and C + +They form the majority of the API, and allow both C and Scheme +programmers to perform identical operations. + +@c @node Scheme Primitives @c @chapter Writing Scheme primitives in C @c - according to the menu in guile.texi - NJ 2001/1/26 -@chapter Relationship between Scheme and C functions +@c @chapter Relationship between Scheme and C functions @c Chapter contents contributed by Thien-Thi Nguyen . @@ -19,8 +69,9 @@ the convention for passing non-required arguments to this function. @c * Exceptions to the regularity:: @end menu + @node Transforming Scheme name to C name -@section Transforming Scheme name to C name +@subsection Transforming Scheme name to C name Normally, the name of a C function can be derived given its Scheme name, using some simple textual transformations: @@ -93,11 +144,23 @@ Prefix arg non-nil means use \"gh_\" prefix, otherwise use \"scm_\" prefix." (insert (if use-gh "gh_" "scm_") name)) @end example + @node Structuring argument lists for C functions -@section Structuring argument lists for C functions +@subsection Structuring argument lists for C functions The C function's arguments will be all of the Scheme procedure's argumements, both required and optional; if the Scheme procedure takes a ``rest'' argument, that will be a final argument to the C function. The C function's arguments, as well as its return type, will be @code{SCM}. + +@node C Only +@section Elements Available Only in C + +For C this is usually a matter of better performance (e.g. the +@code{SCM_CONSP} macro) or of accepting C language types rather than the +generic @code{SCM}. + + +@node Scheme Only +@section Elements Available Only in Scheme From 4d4528e79a13ac73e4278fe877a8a37bdc260240 Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Sat, 8 Dec 2001 12:50:37 +0000 Subject: [PATCH 260/281] 2001-12-08 Stefan Jahn * strings.c (scm_c_string2str): New function. Converts a given Scheme string into a C string. Also put in two THINKME's regarding the malloc policy for the missing converter routines. --- devel/policy/api.text | 64 ++++++++++++++++++++++++++++++++++++++++++- libguile/ChangeLog | 7 +++++ libguile/strings.c | 36 ++++++++++++++++++++++++ libguile/strings.h | 1 + 4 files changed, 107 insertions(+), 1 deletion(-) diff --git a/devel/policy/api.text b/devel/policy/api.text index f59825091..f73dfc6c7 100644 --- a/devel/policy/api.text +++ b/devel/policy/api.text @@ -1,4 +1,4 @@ -* Intro / Index (last modified: $Date: 2001-11-14 20:47:40 $) +* Intro / Index (last modified: $Date: 2001-12-08 12:50:37 $) This working document explains the design of the libguile API, specifically the interface to the C programming language. @@ -74,3 +74,65 @@ malloc with respect to libguile? Some specific questions: * Should we provide something like scm_c_free() for pointers returned by these kind of functions? +The first proposal regarding a malloc policy has been rejected for the +following resons: + +That would mean, users of guile - even on non M$ systems - would have to +keep track where their memory came from? +Assume there are users which have some kind of hash table where they store +strings in. The hash table is responsible for removing entries from the +table. Now, if you want to put strings from guile as well as other +strings into that table you would have to store a pointer to the +corresponding version of 'free' with every string? We should demand such +coding from all guile users? + +The proposal itself read: For a clean memory interface of a client program +to libguile we use the following functions from libguile: + + * scm_c_malloc -- should be used to allocate memory returned by some + of the SCM to C converter functions in libguile if the + client program does not supply memory + * scm_c_free -- must be used by the client program to free the memory + returned by the SCM to C converter functions in + libguile if the client program did not supply a buffer + * scm_c_realloc -- to be complete, do not know a real purpose yet + + +Yet another proposal regarding this problem reads as follows: We could make +life easier, if we supplied the following: + +[in gc.h] +typedef void * (* scm_t_malloc_func) (size_t); +typedef void (* svz_t_free_func) (void *); +SCM_API scm_t_malloc_func scm_c_malloc; +SCM_API scm_t_free_func scm_c_free; + +[in gc.c] +{ + /* At some library initialization point. */ + scm_c_malloc = malloc; + scm_c_free = free; +} + +Then the SCM to C converters allocating memory to store their results use +scm_c_malloc() instead of simply malloc(). This way all libguile/Unix users +can stick to the previous free() policy, saying that you need to free() +pointers delivered by libguile. On the other hand M$-Windows users can pass +their own malloc()-function-pointer to the library and use their own free() +then. Basically this can be achieved in the following order: + +{ + char *str; + scm_boot_guile (...); + scm_c_malloc = malloc; + str = scm_c_string2str (obj, NULL, NULL); + free (str); +} + +This policy is still discussed: +If there is one global variable scm_c_malloc, then setting it within one +thread may interfere with another thread that expects scm_c_malloc to be +set differently. In other words, you would have to introduce some locking +mechanism to guarantee that the sequence of setting scm_c_malloc and +calling scm_string2str can not be interrupted by a different thread that +sets scm_c_malloc to a different value. diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 2dd1eb699..4a1e683bc 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,10 @@ +2001-12-08 Stefan Jahn + + * strings.c (scm_c_string2str): New function. Converts a + given Scheme string into a C string. Also put in two + THINKME's regarding the malloc policy for the missing converter + routines. + 2001-12-01 Neil Jerram * gh_data.c (gh_module_lookup): Use scm_str2symbol rather than diff --git a/libguile/strings.c b/libguile/strings.c index 680707261..dab7a18f8 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -336,6 +336,42 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1, } #undef FUNC_NAME +/* Converts the given Scheme string OBJ into a C string, containing a copy + of OBJ's content with a trailing null byte. If LENP is non-NULL, set + *LENP to the string's length. + + When STR is non-NULL it receives the copy and is returned by the function, + otherwise new memory is allocated and the caller is responsible for + freeing it via free(). If out of memory, NULL is returned. + + Note that Scheme strings may contain arbitrary data, including null + characters. This means that null termination is not a reliable way to + determine the length of the returned value. However, the function always + copies the complete contents of OBJ, and sets *LENP to the true length + of the string (if LENP is non-null). */ +char * +scm_c_string2str (SCM obj, char *str, size_t *lenp) +{ + size_t len; + + SCM_ASSERT (SCM_STRINGP (obj), obj, SCM_ARG1, "scm_c_string2str"); + len = SCM_STRING_LENGTH (obj); + + /* THINKME: What malloc policy? */ + if (str == NULL) + str = (char *) malloc ((len + 1) * sizeof (char)); + if (str == NULL) + return NULL; + + memcpy (str, SCM_STRING_CHARS (obj), len); + /* THINKME: Is this necessary for arguments? I do not think so... */ + scm_remember_upto_here_1 (obj); + str[len] = '\0'; + + if (lenp != NULL) + *lenp = len; + return str; +} void scm_init_strings () diff --git a/libguile/strings.h b/libguile/strings.h index e7952cae2..ea1bf7132 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -78,6 +78,7 @@ SCM_API SCM scm_string_set_x (SCM str, SCM k, SCM chr); SCM_API SCM scm_substring (SCM str, SCM start, SCM end); SCM_API SCM scm_string_append (SCM args); SCM_API void scm_init_strings (void); +SCM_API char *scm_c_string2str (SCM obj, char *str, size_t *lenp); From 762e289af546ad81483a63b3d87525194bf29ca5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 16 Dec 2001 21:57:52 +0000 Subject: [PATCH 261/281] (scm_t_stackype): Renamed to scm_stack_type everywhere. --- libguile/stacks.c | 10 +++++----- libguile/stacks.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libguile/stacks.c b/libguile/stacks.c index c00b47bf5..7c73f4671 100644 --- a/libguile/stacks.c +++ b/libguile/stacks.c @@ -404,7 +404,7 @@ narrow_stack (SCM stack,long inner,SCM inner_key,long outer,SCM outer_key) /* Stacks */ -SCM scm_t_stackype; +SCM scm_stack_type; SCM_DEFINE (scm_stack_p, "stack?", 1, 0, 0, (SCM obj), @@ -484,7 +484,7 @@ SCM_DEFINE (scm_make_stack, "make-stack", 1, 0, 1, size = n * SCM_FRAME_N_SLOTS; /* Make the stack object. */ - stack = scm_make_struct (scm_t_stackype, SCM_MAKINUM (size), SCM_EOL); + stack = scm_make_struct (scm_stack_type, SCM_MAKINUM (size), SCM_EOL); SCM_STACK (stack) -> id = id; iframe = &SCM_STACK (stack) -> tail[0]; SCM_STACK (stack) -> frames = iframe; @@ -641,7 +641,7 @@ SCM_DEFINE (scm_last_stack_frame, "last-stack-frame", 1, 0, 0, if (!dframe || SCM_VOIDFRAMEP (*dframe)) return SCM_BOOL_F; - stack = scm_make_struct (scm_t_stackype, SCM_MAKINUM (SCM_FRAME_N_SLOTS), + stack = scm_make_struct (scm_stack_type, SCM_MAKINUM (SCM_FRAME_N_SLOTS), SCM_EOL); SCM_STACK (stack) -> length = 1; SCM_STACK (stack) -> frames = &SCM_STACK (stack) -> tail[0]; @@ -776,11 +776,11 @@ scm_init_stacks () SCM stack_layout = scm_make_struct_layout (scm_makfrom0str (SCM_STACK_LAYOUT)); vtable = scm_make_vtable_vtable (scm_nullstr, SCM_INUM0, SCM_EOL); - scm_t_stackype + scm_stack_type = scm_permanent_object (scm_make_struct (vtable, SCM_INUM0, scm_cons (stack_layout, SCM_EOL))); - scm_set_struct_vtable_name_x (scm_t_stackype, scm_str2symbol ("stack")); + scm_set_struct_vtable_name_x (scm_stack_type, scm_str2symbol ("stack")); #ifndef SCM_MAGIC_SNARFER #include "libguile/stacks.x" #endif diff --git a/libguile/stacks.h b/libguile/stacks.h index f49e34b82..cdef664de 100644 --- a/libguile/stacks.h +++ b/libguile/stacks.h @@ -73,9 +73,9 @@ typedef struct scm_t_stack { scm_t_info_frame tail[1]; } scm_t_stack; -SCM_API SCM scm_t_stackype; +SCM_API SCM scm_stack_type; -#define SCM_STACKP(obj) (SCM_STRUCTP (obj) && SCM_EQ_P (SCM_STRUCT_VTABLE (obj), scm_t_stackype)) +#define SCM_STACKP(obj) (SCM_STRUCTP (obj) && SCM_EQ_P (SCM_STRUCT_VTABLE (obj), scm_stack_type)) #define SCM_STACK_LENGTH(stack) (SCM_STACK (stack) -> length) #define SCM_FRAMEP(obj) \ From 3c468478d88b601cf09225a1d6689f8bfb5fc72a Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 16 Dec 2001 21:58:02 +0000 Subject: [PATCH 262/281] (scm_make_continuation): Do not retain the throw_value when the continuation is invoked. --- libguile/continuations.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libguile/continuations.c b/libguile/continuations.c index 769bbfc84..cd89110fa 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -183,14 +183,18 @@ scm_make_continuation (int *first) } else { + SCM ret = continuation->throw_value; *first = 0; - return continuation->throw_value; + continuation->throw_value = SCM_BOOL_F; + return ret; } #else /* !__ia64__ */ if (setjmp (continuation->jmpbuf)) { + SCM ret = continuation->throw_value; *first = 0; - return continuation->throw_value; + continuation->throw_value = SCM_BOOL_F; + return ret; } else { From 7733436f7b24f3c65a8d202682830a6e8c1d04f5 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 16 Dec 2001 21:58:24 +0000 Subject: [PATCH 263/281] (let-values): Use `gensym' instead of `gentemp'. --- srfi/srfi-11.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srfi/srfi-11.scm b/srfi/srfi-11.scm index e60ef43f9..32f35a8d7 100644 --- a/srfi/srfi-11.scm +++ b/srfi/srfi-11.scm @@ -194,7 +194,7 @@ (define (let-values-helper vars body prev-let-vars) (let* ((var-binding (car vars)) - (new-tmps (map-1-dot (lambda (sym) (gentemp)) + (new-tmps (map-1-dot (lambda (sym) (gensym)) (car var-binding))) (let-vars (map (lambda (sym tmp) (list sym tmp)) (undot-list (car var-binding)) From 197ee3d38864f3346322a06142a84ddffd47bb79 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 16 Dec 2001 21:58:33 +0000 Subject: [PATCH 264/281] *** empty log message *** --- libguile/ChangeLog | 8 ++++++++ srfi/ChangeLog | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 4a1e683bc..5c82866c0 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,11 @@ +2001-12-16 Marius Vollmer + + * stacks.c, stacks.h (scm_t_stackype): Renamed to scm_stack_type + everywhere. + + * continuations.c (scm_make_continuation): Do not retain the + throw_value when the continuation is invoked. + 2001-12-08 Stefan Jahn * strings.c (scm_c_string2str): New function. Converts a diff --git a/srfi/ChangeLog b/srfi/ChangeLog index abed6ad56..41540976a 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,7 @@ +2001-12-16 Marius Vollmer + + * srfi-11.scm (let-values): Use `gensym' instead of `gentemp'. + 2001-11-30 Neil Jerram * Makefile.am (ETAGS_ARGS): Added. From 226297eb51b2a44f84345666350e5cdc8c7e2907 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sat, 22 Dec 2001 12:39:10 +0000 Subject: [PATCH 265/281] * Work on Programming Overview chapter. --- doc/ref/ChangeLog | 5 ++ doc/ref/guile.texi | 6 +- doc/ref/program.texi | 155 +++++++++++++++++++++++++++++++++---------- 3 files changed, 128 insertions(+), 38 deletions(-) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 69b8a4847..d0a871e8d 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-12-22 Neil Jerram + + * program.texi (Programming Overview): Chapter renamed from + `Programming Options'; some new material added. + 2001-12-07 Neil Jerram * scm.texi (Guile API): Renamed from `Scheme Primitives' and diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index 7761cffb7..090130c07 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -94,7 +94,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.9 2001-12-07 17:08:19 ossau Exp $ +@subtitle $Id: guile.texi,v 1.10 2001-12-22 12:39:10 ossau Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -209,8 +209,8 @@ Part I: Introduction to Guile Part II: Programming with Guile -* Programming Intro:: Intoduction to programming with Guile. -* Programming Options:: Programming Options in Guile. +* Programming Intro:: Intoduction to this part. +* Programming Overview:: An overview of Guile programming. * Scheme Intro:: Introduction to Guile Scheme. * Basic Ideas:: Basic ideas in Scheme. * Guile Scripting:: How to write Guile scripts. diff --git a/doc/ref/program.texi b/doc/ref/program.texi index 4f5ff2e1d..728944c09 100644 --- a/doc/ref/program.texi +++ b/doc/ref/program.texi @@ -1,33 +1,120 @@ @page -@node Programming Options -@chapter Programming Options in Guile +@node Programming Overview +@chapter An Overview of Guile Programming -What does it mean to program using Guile? +Guile is designed as an extension language interpreter that is +straightforward to integrate with applications written in C (and C++). +The big win here for the application developer is that Guile +integration, as the Guile web page says, ``lowers your project's +hacktivation energy.'' Lowering the hacktivation energy means that you, +as the application developer, @emph{and your users}, reap the benefits +that flow from being able to extend the application in a high level +extension language rather than in plain old C. -If you are an application developer, and want to combine Guile in some -way with your application, there is a range of possibilities available -to you@dots{} +Underlying this argument is the assumption that programming in a high +level language, specifically Guile's implementation of Scheme, is +necessarily better in some way than programming in C. What do we mean +by this claim, and how can we be so sure? + +One class of advantages applies not only to Scheme, but more generally +to any interpretable, high level, scripting language, such as Emacs +Lisp, Python, Ruby, or @TeX{}'s macro language. Common features of all +such languages, when compared to C, are that: @itemize @bullet @item -You could choose to write your whole application in Scheme (or one of -the other high level languages that Guile supports through translation), -and simply use Guile as an interpreter (and hopefully in the future a -compiler) for Scheme. +They lend themselves to rapid and experimental development cycles, +owing usually to a combination of their interpretability and the +integrated development environment in which they are used. @item -You could write a small amount of C code that implements domain-specific -@dfn{primitive} functions for your application and connects these to the -Scheme level of Guile, and then write the rest of your application, -using these application-specific primitives, in Scheme. +They free developers from some of the low level bookkeeping tasks +associated with C programming, notably memory management. @item -You could write almost all of your application in C, and only call out -to Guile occasionally for specific actions such as reading a -configuration file or executing a user-specified extension. +They provide high level features such as container objects and exception +handling that make common programming tasks easier. @end itemize -Underlying these choices are two basic questions. +In the case of Scheme, further features that make programming easier --- +and more fun! --- are its powerful mechanisms for abstracting parts of +programs (closures --- @pxref{About Closure}) and for iteration +(@pxref{while do}). + +The evidence in support of this argument is empirical: the huge amount +of code that has been written in extension languages for applications +that support this mechanism. Most notable are extensions written in +Emacs Lisp for GNU Emacs, in @TeX{}'s macro language for @TeX{}, and in +Script-Fu for the Gimp, but there is increasingly now a significant code +eco-system for Guile-based applications as well, such as Lilypond and +GnuCash. It is close to inconceivable that similar amounts of +functionality could have been added to these applications just by +writing new code in their base implementation languages. + +@menu +* Testbed Example:: Example: using Guile in a testbed. +* Programming Options:: Options for Guile programming. +* User Programming:: How about application users? +@end menu + + +@node Testbed Example +@section Example: Using Guile for an Application Testbed + +As an example of what this means in practice, imagine writing a testbed +for an application that is tested by submitting various requests (via a +C interface) and validating the output received. Suppose further that +the application keeps an idea of its current state, and that the +``correct'' output for a given request may depend on the current +application state. A complete ``white box''@footnote{A @dfn{white box} +test plan is one that incorporates knowledge of the internal design of +the application under test.} test plan for this application would aim to +submit all possible requests in each distinguishable state, and validate +the output for all request/state combinations. + +To write all this test code in C would be very tedious. Suppose instead +that the testbed code adds a single new C function, to submit an +arbitrary request and return the response, and then uses Guile to export +this function as a Scheme procedure. The rest of the testbed can then +be written in Scheme, and so benefits from all the advantages of +programming in Scheme that were described in the previous section. + +(In this particular example, there is an additional benefit of writing +most of the testbed in Scheme. A common problem for white box testing +is that mistakes and mistaken assumptions in the application under test +can easily be reproduced in the testbed code. It is more difficult to +copy mistakes like this when the testbed is written in a different +language from the application.) + + +@node Programming Options +@section A Choice of Programming Options + +The preceding arguments and example point to a model of Guile +programming that is applicable in many cases. According to this model, +Guile programming involves a balance between C and Scheme programming, +with the aim being to extract the greatest possible Scheme level benefit +from the least amount of C level work. + +The C level work required in this model usually consists of packaging +and exporting functions and application objects such that they can be +seen and manipulated on the Scheme level. To help with this, Guile's C +language interface includes utility features that aim to make this kind +of integration very easy for the application developer. These features +are documented later in this part of the manual: see REFFIXME. + +This model, though, is really just one of a range of possible +programming options. If all of the functionality that you need is +available from Scheme, you could choose instead to write your whole +application in Scheme (or one of the other high level languages that +Guile supports through translation), and simply use Guile as an +interpreter for Scheme. (In the future, we hope that Guile will also be +able to compile Scheme code, so lessening the performance gap between C +and Scheme code.) Or, at the other end of the C--Scheme scale, you +could write the majority of your application in C, and only call out to +Guile occasionally for specific actions such as reading a configuration +file or executing a user-specified extension. The choices boil down to +two basic questions: @itemize @bullet @item @@ -41,21 +128,20 @@ application? These are of course design questions, and the right design for any given application will always depend upon the particular requirements that you -are trying to meet. In the Guile world, however, there are some -generally applicable considerations that can help you when searching for -the answers. +are trying to meet. In the context of Guile, however, there are some +generally applicable considerations that can help you when designing +your answers. @menu * Available Functionality:: What functionality is already available? * Basic Constraints:: Functional and performance constraints. * Style Choices:: Your preferred programming style. * Program Control:: What controls program execution? -* User Programming:: How about application users? @end menu @node Available Functionality -@section What Functionality is Already Available? +@subsection What Functionality is Already Available? Suppose, for the sake of argument, that you would prefer to write your whole application in Scheme. Then the API available to you consists of: @@ -89,12 +175,12 @@ selection of these modules together with new application code written in Scheme. If this approach is not enough, because the functionality that your -application needs is not already available in this form, or because it -is impossible or unacceptable (e.g. for performance reasons) to write -the new functionality in Scheme, you will need to write some C code. If -the required function is already available in C (e.g. in a library), all -you need is a little glue to connect it to the world of Guile. If not, -you need both to write the basic code and to plumb it into Guile. +application needs is not already available in this form, and it is +impossible to write the new functionality in Scheme, you will need to +write some C code. If the required function is already available in C +(e.g. in a library), all you need is a little glue to connect it to the +world of Guile. If not, you need both to write the basic code and to +plumb it into Guile. In either case, two general considerations are important. Firstly, what is the interface by which the functionality is presented to the Scheme @@ -107,21 +193,20 @@ of Scheme objects? In the case where the basic C code is not already written, most of the difficulties of memory management can be avoided by using Guile's C interface features from the start. -For further information, tips and guidelines on writing C code for -Guile, or for connecting existing C code to the Guile world, see -REFFIXME. +For the full documentation on writing C code for Guile and connecting +existing C code to the Guile world, see REFFIXME. @node Basic Constraints -@section Functional and Performance Constraints +@subsection Functional and Performance Constraints @node Style Choices -@section Your Preferred Programming Style +@subsection Your Preferred Programming Style @node Program Control -@section What Controls Program Execution? +@subsection What Controls Program Execution? @node User Programming From 5ad5a7b6ca8bf2bc8730211ecb9fdce371e7f8f4 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 22 Dec 2001 13:49:05 +0000 Subject: [PATCH 266/281] (Alist Example): Changed "Bismarck" to "Pierre". Thanks to Ron Peterson! --- doc/ref/scheme-compound.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/ref/scheme-compound.texi b/doc/ref/scheme-compound.texi index 1a30112be..d790dc65b 100644 --- a/doc/ref/scheme-compound.texi +++ b/doc/ref/scheme-compound.texi @@ -2078,9 +2078,9 @@ Here is a longer example of how alists may be used in practice. ;; We left out South Dakota. (set! capitals - (assoc-set! capitals "South Dakota" "Bismarck")) + (assoc-set! capitals "South Dakota" "Pierre")) capitals -@result{} (("South Dakota" . "Bismarck") +@result{} (("South Dakota" . "Pierre") ("New York" . "Albany") ("Oregon" . "Salem") ("Florida" . "Miami")) @@ -2089,7 +2089,7 @@ capitals (set! capitals (assoc-set! capitals "Florida" "Tallahassee")) capitals -@result{} (("South Dakota" . "Bismarck") +@result{} (("South Dakota" . "Pierre") ("New York" . "Albany") ("Oregon" . "Salem") ("Florida" . "Tallahassee")) @@ -2098,7 +2098,7 @@ capitals (set! capitals (assoc-remove! capitals "Oregon")) capitals -@result{} (("South Dakota" . "Bismarck") +@result{} (("South Dakota" . "Pierre") ("New York" . "Albany") ("Florida" . "Tallahassee")) @end lisp From 0fabb4257327b6c1f6abffab4ab3dbc36c4f7103 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 22 Dec 2001 13:49:47 +0000 Subject: [PATCH 267/281] *** empty log message *** --- doc/ref/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index d0a871e8d..a3f220184 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2001-12-22 Marius Vollmer + + * scheme-compound.texi (Alist Example): Changed "Bismarck" to + "Pierre". Thanks to Ron Peterson! + 2001-12-22 Neil Jerram * program.texi (Programming Overview): Chapter renamed from From 27f9e3731a80e579d3ca561ac46e982c99feae4e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 22 Dec 2001 13:50:01 +0000 Subject: [PATCH 268/281] Added Ron Peterson. --- THANKS | 1 + 1 file changed, 1 insertion(+) diff --git a/THANKS b/THANKS index f0c170e4c..14ec4bd67 100644 --- a/THANKS +++ b/THANKS @@ -20,6 +20,7 @@ For fixes or providing information which led to a fix: Eric Gillespie, Jr John Goerzen Han-Wen Nienhuys + Ron Peterson Ken Raeburn Bill Schottstaedt Momchil Velikov From a9d78896d1737c429ca8640d5e2fe0814a2ea20c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 26 Dec 2001 15:36:43 +0000 Subject: [PATCH 269/281] (HAVE_MAKEINFO): Check for the makeinfo program and set this conditional accordingly. --- configure.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.in b/configure.in index fb5a8e814..d0f4b34f4 100644 --- a/configure.in +++ b/configure.in @@ -172,6 +172,9 @@ AC_MINIX AM_PROG_CC_STDC AM_PROG_LIBTOOL +AC_CHECK_PROG(have_makeinfo, maakeinfo, yes, no) +AM_CONDITIONAL(HAVE_MAKEINFO, test "$have_makeinfo" = yes) + AC_C_CONST AC_C_INLINE AC_C_BIGENDIAN From 9df3eecce426a91fb5085e8d6f8476dfa34c806c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 26 Dec 2001 15:37:01 +0000 Subject: [PATCH 270/281] (guile-procedures.txt): When we don't have makeinfo, use "cp" instead. --- libguile/Makefile.am | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 49f0e49a2..14aae5521 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -221,10 +221,19 @@ guile-procedures.texi: $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) guile-snarf-docs- cat $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) | ./guile-snarf-docs-texi > $@ \ || { rm $@; false; } +if HAVE_MAKEINFO + guile-procedures.txt: guile-procedures.texi rm -f $@ makeinfo --force -o $@ $< || test -f $@ +else + +guile-procedures.txt: guile-procedures.texi + cp $< $@ + +endif + c-tokenize.c: c-tokenize.lex flex -t $< > $@ || { rm $@; false; } From 5dc64f6434841e8439b08235d7d7ff76476dc2f6 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 26 Dec 2001 15:37:14 +0000 Subject: [PATCH 271/281] *** empty log message *** --- ChangeLog | 5 +++++ libguile/ChangeLog | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1c877dd51..d5cdb8c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-12-26 Marius Vollmer + + * configure.in (HAVE_MAKEINFO): Check for the makeinfo program and + set this conditional accordingly. + 2001-12-01 Thien-Thi Nguyen * README: Fix virulent typo. diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 5c82866c0..db2319ff5 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2001-12-26 Marius Vollmer + + * Makefile.am (guile-procedures.txt): When we don't have makeinfo, + use "cp" instead. + 2001-12-16 Marius Vollmer * stacks.c, stacks.h (scm_t_stackype): Renamed to scm_stack_type From ff26bc56315c4e2c440aa08e3c09d139888cceaa Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 26 Dec 2001 15:39:06 +0000 Subject: [PATCH 272/281] Really check for "makeinfo", not for "maakeinfo", which I put there for testing the failure case. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index d0f4b34f4..5a4195f57 100644 --- a/configure.in +++ b/configure.in @@ -172,7 +172,7 @@ AC_MINIX AM_PROG_CC_STDC AM_PROG_LIBTOOL -AC_CHECK_PROG(have_makeinfo, maakeinfo, yes, no) +AC_CHECK_PROG(have_makeinfo, makeinfo, yes, no) AM_CONDITIONAL(HAVE_MAKEINFO, test "$have_makeinfo" = yes) AC_C_CONST From d00012159ad349d02a444b11c92b7637f84de44e Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 28 Dec 2001 10:18:39 +0000 Subject: [PATCH 273/281] Update copyright. Add index in header comments. (AC_GUILE_MODULE_CHECK, AC_GUILE_MODULE_AVAILABLE, AC_GUILE_MODULE_REQUIRED): New macros. --- guile-config/guile.m4 | 80 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/guile-config/guile.m4 b/guile-config/guile.m4 index d8958cb1b..1deb12e71 100644 --- a/guile-config/guile.m4 +++ b/guile-config/guile.m4 @@ -1,34 +1,34 @@ -dnl Automake macros for working with Guile. -dnl -dnl Copyright (C) 1998 Free Software Foundation, Inc. -dnl +dnl Autoconf macros for working with Guile. +dnl +dnl Copyright (C) 1998,2001 Free Software Foundation, Inc. +dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2, or (at your option) dnl any later version. -dnl +dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. -dnl +dnl dnl You should have received a copy of the GNU General Public License dnl along with this software; see the file COPYING. If not, write to dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330, dnl Boston, MA 02111-1307 USA -dnl +dnl dnl As a special exception, the Free Software Foundation gives permission dnl for additional uses of the text contained in its release of GUILE. -dnl +dnl dnl The exception is that, if you link the GUILE library with other files dnl to produce an executable, this does not by itself cause the dnl resulting executable to be covered by the GNU General Public License. dnl Your use of that executable is in no way restricted on account of dnl linking the GUILE library code into it. -dnl +dnl dnl This exception does not however invalidate any other reasons why dnl the executable file might be covered by the GNU General Public License. -dnl +dnl dnl This exception applies only to the code released by the dnl Free Software Foundation under the name GUILE. If you copy dnl code from other Free Software Foundation releases into a copy of @@ -36,14 +36,26 @@ dnl GUILE, as the General Public License permits, the exception does dnl not apply to the code that you add in this way. To avoid misleading dnl anyone as to the status of such modified files, you must delete dnl this exception notice from them. -dnl +dnl dnl If you write modifications of your own for GUILE, it is your choice dnl whether to permit this exception to apply to your modifications. dnl If you do not wish that, delete this exception notice. +dnl INDEX +dnl ----- + dnl GUILE_FLAGS --- set flags for compiling and linking with Guile -dnl +dnl AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module +dnl AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module +dnl AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable + + +dnl Code +dnl ---- + +dnl GUILE_FLAGS --- set flags for compiling and linking with Guile +dnl dnl This macro runs the `guile-config' script, installed with Guile, dnl to find out where Guile's header files and libraries are dnl installed. It sets two variables, marked for substitution, as @@ -74,3 +86,47 @@ AC_DEFUN([GUILE_FLAGS],[ AC_SUBST(GUILE_LDFLAGS) AC_MSG_RESULT(yes) ]) + + +dnl AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module +dnl +dnl AC_GUILE_MODULE_CHECK(var,module,featuretest,description) +dnl $1 is a shell variable name to be set to "yes" or "no" +dnl $2 is a list of symbols, like: (ice-9 common-list) +dnl $3 is a thunk, like: (lambda () BODY ...) +dnl which returns either 0 or #t to indicate the check passed. +dnl avoid using the character "#" since that confuses autoconf. +dnl $4 is a noun phrase passed to AC_MSG_CHECKING + +AC_DEFUN([AC_GUILE_MODULE_CHECK], + [AC_MSG_CHECKING([$2 $4]) + $1=no + echo '(use-modules $2) (exit ($3))' > conftest + guile -s conftest > /dev/null 2>&1 && $1=yes + rm -f conftest + AC_MSG_RESULT($[$1]) + ]) + +dnl AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module +dnl +dnl AC_GUILE_MODULE_AVAILABLE(var,module) +dnl $1 is a shell variable name to be set to "yes" or "no" +dnl $2 is a list of symbols, like: (ice-9 common-list) + +AC_DEFUN([AC_GUILE_MODULE_AVAILABLE], + [AC_GUILE_MODULE_CHECK($1,$2,(lambda () 0),availability) + ]) + +dnl AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable +dnl +dnl $1 is a list of symbols, WITHOUT the surrounding parens + +AC_DEFUN([AC_GUILE_MODULE_REQUIRED], + [AC_GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) + if test "$ac_guile_module_required" = "no" ; then + AC_MSG_ERROR([required guile module not found: ($1)]) + fi + ]) + + +dnl guile.m4 ends here From 68c807838ebb873618568d1d0db67325589c39fe Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 28 Dec 2001 10:29:39 +0000 Subject: [PATCH 274/281] *** empty log message *** --- guile-config/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guile-config/ChangeLog b/guile-config/ChangeLog index a9920b31e..017a76023 100644 --- a/guile-config/ChangeLog +++ b/guile-config/ChangeLog @@ -1,3 +1,11 @@ +2001-12-28 Thien-Thi Nguyen + + * Update copyright. + Add index in header comments. + + (AC_GUILE_MODULE_CHECK, AC_GUILE_MODULE_AVAILABLE, + AC_GUILE_MODULE_REQUIRED): New macros. + 2001-07-18 Martin Grabmueller * guile-config.in, Makefile.am: Updated copyright notice. From b6aaeeac17b55224eb7b5e50448f89029dbab65d Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 29 Dec 2001 03:55:52 +0000 Subject: [PATCH 275/281] (GUILE_PROGS, GUILE_SITE_DIR, GUILE_CHECK, GUILE_MODULE_EXPORTS, GUILE_MODULE_REQUIRED_EXPORTS): New macros. (GUILE_MODULE_CHECK): Renamed from AC_GUILE_MODULE_CHECK. Rewritten to expect `description' as a present-tense verb phrase. (GUILE_MODULE_AVAILABLE, GUILE_MODULE_REQUIRED): Renamed likewise. --- guile-config/guile.m4 | 289 +++++++++++++++++++++++++++--------------- 1 file changed, 188 insertions(+), 101 deletions(-) diff --git a/guile-config/guile.m4 b/guile-config/guile.m4 index 1deb12e71..bb1dc274d 100644 --- a/guile-config/guile.m4 +++ b/guile-config/guile.m4 @@ -1,77 +1,106 @@ -dnl Autoconf macros for working with Guile. -dnl -dnl Copyright (C) 1998,2001 Free Software Foundation, Inc. -dnl -dnl This program is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2, or (at your option) -dnl any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this software; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330, -dnl Boston, MA 02111-1307 USA -dnl -dnl As a special exception, the Free Software Foundation gives permission -dnl for additional uses of the text contained in its release of GUILE. -dnl -dnl The exception is that, if you link the GUILE library with other files -dnl to produce an executable, this does not by itself cause the -dnl resulting executable to be covered by the GNU General Public License. -dnl Your use of that executable is in no way restricted on account of -dnl linking the GUILE library code into it. -dnl -dnl This exception does not however invalidate any other reasons why -dnl the executable file might be covered by the GNU General Public License. -dnl -dnl This exception applies only to the code released by the -dnl Free Software Foundation under the name GUILE. If you copy -dnl code from other Free Software Foundation releases into a copy of -dnl GUILE, as the General Public License permits, the exception does -dnl not apply to the code that you add in this way. To avoid misleading -dnl anyone as to the status of such modified files, you must delete -dnl this exception notice from them. -dnl -dnl If you write modifications of your own for GUILE, it is your choice -dnl whether to permit this exception to apply to your modifications. -dnl If you do not wish that, delete this exception notice. +## Autoconf macros for working with Guile. +## +## Copyright (C) 1998,2001 Free Software Foundation, Inc. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this software; see the file COPYING. If not, write to +## the Free Software Foundation, Inc., 59 Temple Place, Suite 330, +## Boston, MA 02111-1307 USA +## +## As a special exception, the Free Software Foundation gives permission +## for additional uses of the text contained in its release of GUILE. +## +## The exception is that, if you link the GUILE library with other files +## to produce an executable, this does not by itself cause the +## resulting executable to be covered by the GNU General Public License. +## Your use of that executable is in no way restricted on account of +## linking the GUILE library code into it. +## +## This exception does not however invalidate any other reasons why +## the executable file might be covered by the GNU General Public License. +## +## This exception applies only to the code released by the +## Free Software Foundation under the name GUILE. If you copy +## code from other Free Software Foundation releases into a copy of +## GUILE, as the General Public License permits, the exception does +## not apply to the code that you add in this way. To avoid misleading +## anyone as to the status of such modified files, you must delete +## this exception notice from them. +## +## If you write modifications of your own for GUILE, it is your choice +## whether to permit this exception to apply to your modifications. +## If you do not wish that, delete this exception notice. +## Index +## ----- +## +## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs +## GUILE_FLAGS -- set flags for compiling and linking with Guile +## GUILE_SITE_DIR -- find path to Guile "site" directory +## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value +## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module +## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module +## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable +## GUILE_MODULE_EXPORTS -- check if a module exports a variable +## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable -dnl INDEX -dnl ----- +## Code +## ---- -dnl GUILE_FLAGS --- set flags for compiling and linking with Guile -dnl AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module -dnl AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module -dnl AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable - - -dnl Code -dnl ---- - -dnl GUILE_FLAGS --- set flags for compiling and linking with Guile -dnl -dnl This macro runs the `guile-config' script, installed with Guile, -dnl to find out where Guile's header files and libraries are -dnl installed. It sets two variables, marked for substitution, as -dnl by AC_SUBST. -dnl -dnl GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build -dnl code that uses Guile header files. This is almost -dnl always just a -I flag. -dnl -dnl GUILE_LDFLAGS --- flags to pass to the linker to link a -dnl program against Guile. This includes `-lguile' for -dnl the Guile library itself, any libraries that Guile -dnl itself requires (like -lqthreads), and so on. It may -dnl also include a -L flag to tell the compiler where to -dnl find the libraries. +# GUILE_PROGS -- set paths to Guile interpreter, config and tool programs +# +# Usage: GUILE_PROGS +# +# This macro looks for programs `guile', `guile-config' and `guile-tools', +# and sets variables GUILE, GUILE_CONFIG and GUILE_TOOLS, to their paths, +# respectively. If either of the first two are not found, signal error. +# +# The variables are marked for substitution, as by AC_SUBST. +# +AC_DEFUN([GUILE_PROGS], + [AC_PATH_PROG(GUILE,guile) + if test "$GUILE" = "" ; then + AC_MSG_ERROR([guile required but not found]) + fi + AC_SUBST(GUILE) + AC_PATH_PROG(GUILE_CONFIG,guile-config) + if test "$GUILE_CONFIG" = "" ; then + AC_MSG_ERROR([guile-config required but not found]) + fi + AC_SUBST(GUILE_CONFIG) + AC_PATH_PROG(GUILE_TOOLS,guile-tools) + AC_SUBST(GUILE_TOOLS) + ]) +# GUILE_FLAGS -- set flags for compiling and linking with Guile +# +# Usage: GUILE_FLAGS +# +# This macro runs the `guile-config' script, installed with Guile, +# to find out where Guile's header files and libraries are +# installed. It sets two variables, GUILE_CFLAGS and GUILE_LDFLAGS. +# +# GUILE_CFLAGS: flags to pass to a C or C++ compiler to build code that +# uses Guile header files. This is almost always just a -I flag. +# +# GUILE_LDFLAGS: flags to pass to the linker to link a program against +# Guile. This includes `-lguile' for the Guile library itself, any +# libraries that Guile itself requires (like -lqthreads), and so on. It +# may also include a -L flag to tell the compiler where to find the +# libraries. +# +# The variables are marked for substitution, as by AC_SUBST. +# AC_DEFUN([GUILE_FLAGS],[ ## The GUILE_FLAGS macro. ## First, let's just see if we can find Guile at all. @@ -87,46 +116,104 @@ AC_DEFUN([GUILE_FLAGS],[ AC_MSG_RESULT(yes) ]) +# GUILE_SITE_DIR -- find path to Guile "site" directory +# +# Usage: GUILE_SITE_DIR +# +# This looks for Guile's "site" directory, usually something like +# PREFIX/share/guile/site, and sets var GUILE_SITE to the path. +# Note that the var name is different from the macro name. +# +# The variable is marked for substitution, as by AC_SUBST. +# +AC_DEFUN([GUILE_SITE_DIR], + [AC_REQUIRE([GUILE_PROGS])dnl + AC_MSG_CHECKING(for Guile site directory) + GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site + AC_MSG_RESULT($GUILE_SITE) + AC_SUBST(GUILE_SITE) + ]) -dnl AC_GUILE_MODULE_CHECK --- check feature of a Guile Scheme module -dnl -dnl AC_GUILE_MODULE_CHECK(var,module,featuretest,description) -dnl $1 is a shell variable name to be set to "yes" or "no" -dnl $2 is a list of symbols, like: (ice-9 common-list) -dnl $3 is a thunk, like: (lambda () BODY ...) -dnl which returns either 0 or #t to indicate the check passed. -dnl avoid using the character "#" since that confuses autoconf. -dnl $4 is a noun phrase passed to AC_MSG_CHECKING +# GUILE_CHECK -- evaluate Guile Scheme code and capture the return value +# +# Usage: GUILE_CHECK_RETVAL(var,check) +# +# $1 is a shell variable name to be set to the return value +# $2 is a Guile Scheme expression, evaluated with "$GUILE -c", and +# returning either 0 or non-#f to indicate the check passed. +# Non-0 number or #f indicates failure. +# Avoid using the character "#" since that confuses autoconf. +# +AC_DEFUN([GUILE_CHECK], + [AC_REQUIRE([GUILE_PROGS]) + $GUILE -c "$2" > /dev/null 2>&1 + $1=$? + ]) -AC_DEFUN([AC_GUILE_MODULE_CHECK], - [AC_MSG_CHECKING([$2 $4]) - $1=no - echo '(use-modules $2) (exit ($3))' > conftest - guile -s conftest > /dev/null 2>&1 && $1=yes - rm -f conftest - AC_MSG_RESULT($[$1]) +# GUILE_MODULE_CHECK -- check feature of a Guile Scheme module +# +# Usage: GUILE_MODULE_CHECK(var,module,featuretest,description) +# +# $1 is a shell variable name to be set to "yes" or "no" +# $2 is a list of symbols, like: (ice-9 common-list) +# $3 is an expression acceptable to GUILE_CHECK, q.v. +# $4 is a present-tense verb phrase (passed to AC_MSG_CHECKING) +# +AC_DEFUN([GUILE_MODULE_CHECK], + [AC_MSG_CHECKING([if $2 $4]) + GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3)))) + if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi + AC_MSG_RESULT($$1) ]) -dnl AC_GUILE_MODULE_AVAILABLE --- check availability of a Guile Scheme module -dnl -dnl AC_GUILE_MODULE_AVAILABLE(var,module) -dnl $1 is a shell variable name to be set to "yes" or "no" -dnl $2 is a list of symbols, like: (ice-9 common-list) - -AC_DEFUN([AC_GUILE_MODULE_AVAILABLE], - [AC_GUILE_MODULE_CHECK($1,$2,(lambda () 0),availability) +# GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module +# +# Usage: GUILE_MODULE_AVAILABLE(var,module) +# +# $1 is a shell variable name to be set to "yes" or "no" +# $2 is a list of symbols, like: (ice-9 common-list) +# +AC_DEFUN([GUILE_MODULE_AVAILABLE], + [GUILE_MODULE_CHECK($1,$2,0,is available) ]) -dnl AC_GUILE_MODULE_REQUIRED --- fail if a Guile Scheme module is unavailable -dnl -dnl $1 is a list of symbols, WITHOUT the surrounding parens - -AC_DEFUN([AC_GUILE_MODULE_REQUIRED], - [AC_GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) +# GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable +# +# Usage: GUILE_MODULE_REQUIRED(symlist) +# +# $1 is a list of symbols, WITHOUT surrounding parens, like: ice-9 common-list +# +AC_DEFUN([GUILE_MODULE_REQUIRED], + [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) if test "$ac_guile_module_required" = "no" ; then AC_MSG_ERROR([required guile module not found: ($1)]) fi ]) +# GUILE_MODULE_EXPORTS -- check if a module exports a variable +# +# Usage: GUILE_MODULE_EXPORTS(var,module,modvar) +# +# $1 is a shell variable to be set to "yes" or "no" +# $2 is a list of symbols, like: (ice-9 common-list) +# $3 is the Guile Scheme variable to check +# +AC_DEFUN([GUILE_MODULE_EXPORTS], + [GUILE_MODULE_CHECK($1,$2,$3,exports `$3') + ]) -dnl guile.m4 ends here +# GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable +# +# Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar) +# +# $1 is a list of symbols, like: (ice-9 common-list) +# $2 is the Guile Scheme variable to check +# +AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT], + [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2) + if test "$guile_module_required_export" = "no" ; then + AC_MSG_ERROR([module $1 does not export $2; required]) + fi + ]) + +## guile.m4 ends here From c07e3628a5b0d7bb699831c7567d3a8cbee5050b Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 29 Dec 2001 03:57:34 +0000 Subject: [PATCH 276/281] *** empty log message *** --- guile-config/ChangeLog | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/guile-config/ChangeLog b/guile-config/ChangeLog index 017a76023..7183c80da 100644 --- a/guile-config/ChangeLog +++ b/guile-config/ChangeLog @@ -1,6 +1,16 @@ 2001-12-28 Thien-Thi Nguyen - * Update copyright. + * guile.m4 (GUILE_PROGS, GUILE_SITE_DIR, GUILE_CHECK, + GUILE_MODULE_EXPORTS, GUILE_MODULE_REQUIRED_EXPORTS): New macros. + + (GUILE_MODULE_CHECK): Renamed from AC_GUILE_MODULE_CHECK. + Rewritten to expect `description' as a present-tense verb phrase. + + (GUILE_MODULE_AVAILABLE, GUILE_MODULE_REQUIRED): Renamed likewise. + +2001-12-28 Thien-Thi Nguyen + + * guile.m4: Update copyright. Add index in header comments. (AC_GUILE_MODULE_CHECK, AC_GUILE_MODULE_AVAILABLE, From f00eb43f8dde320bba061325223394c3ab642d0d Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Mon, 31 Dec 2001 13:32:18 +0000 Subject: [PATCH 277/281] * TODO: Added two items. --- ChangeLog | 4 ++++ TODO | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index d5cdb8c2a..ce4cc0e6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-12-31 Dirk Herrmann + + * TODO: Added two items. + 2001-12-26 Marius Vollmer * configure.in (HAVE_MAKEINFO): Check for the makeinfo program and diff --git a/TODO b/TODO index 07c4478f3..381b941e2 100644 --- a/TODO +++ b/TODO @@ -59,10 +59,13 @@ that user-visible changes are reflected in NEWS. - make the set of error signalling functions more consistent - Fix bug reported by Sven.Hartrumpf@fernuni-hagen.de 2001-08-31: (debug-disable 'debug) has no effect if it is the first form in ~/.guile. +- provide a non-extended implementation of 'define' for the R5RS module. * Before releasing 1.8.0: +- deprecate old uniform vector interface. + - add DLL support [ela] <-- set by ttn (my bad) - write emacs/patch.el [ttn] From 8c4b7ca35f43118d8ddee055bb3e4a635dfed5cb Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 2 Jan 2002 23:50:38 +0000 Subject: [PATCH 278/281] Rewrite comments in texi. (GUILE_FLAGS): Rewrite. Thanks to Alexandre Duret-Lutz. --- guile-config/guile.m4 | 86 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/guile-config/guile.m4 b/guile-config/guile.m4 index bb1dc274d..fa098eecf 100644 --- a/guile-config/guile.m4 +++ b/guile-config/guile.m4 @@ -57,15 +57,19 @@ ## Code ## ---- +## NOTE: Comments preceding an AC_DEFUN (starting from "Usage:") are massaged +## into doc/ref/autoconf-macros.texi (see Makefile.am in that directory). + # GUILE_PROGS -- set paths to Guile interpreter, config and tool programs # # Usage: GUILE_PROGS # -# This macro looks for programs `guile', `guile-config' and `guile-tools', -# and sets variables GUILE, GUILE_CONFIG and GUILE_TOOLS, to their paths, -# respectively. If either of the first two are not found, signal error. +# This macro looks for programs @code{guile}, @code{guile-config} and +# @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and +# @var{GUILE_TOOLS}, to their paths, respectively. If either of the first two +# are not found, signal error. # -# The variables are marked for substitution, as by AC_SUBST. +# The variables are marked for substitution, as by @code{AC_SUBST}. # AC_DEFUN([GUILE_PROGS], [AC_PATH_PROG(GUILE,guile) @@ -86,45 +90,42 @@ AC_DEFUN([GUILE_PROGS], # # Usage: GUILE_FLAGS # -# This macro runs the `guile-config' script, installed with Guile, -# to find out where Guile's header files and libraries are -# installed. It sets two variables, GUILE_CFLAGS and GUILE_LDFLAGS. +# This macro runs the @code{guile-config} script, installed with Guile, to +# find out where Guile's header files and libraries are installed. It sets +# two variables, @var{GUILE_CFLAGS} and @var{GUILE_LDFLAGS}. # -# GUILE_CFLAGS: flags to pass to a C or C++ compiler to build code that -# uses Guile header files. This is almost always just a -I flag. +# @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that +# uses Guile header files. This is almost always just a @code{-I} flag. # -# GUILE_LDFLAGS: flags to pass to the linker to link a program against -# Guile. This includes `-lguile' for the Guile library itself, any -# libraries that Guile itself requires (like -lqthreads), and so on. It -# may also include a -L flag to tell the compiler where to find the +# @var{GUILE_LDFLAGS}: flags to pass to the linker to link a program against +# Guile. This includes @code{-lguile} for the Guile library itself, any +# libraries that Guile itself requires (like -lqthreads), and so on. It may +# also include a @code{-L} flag to tell the compiler where to find the # libraries. # -# The variables are marked for substitution, as by AC_SUBST. +# The variables are marked for substitution, as by @code{AC_SUBST}. # -AC_DEFUN([GUILE_FLAGS],[ -## The GUILE_FLAGS macro. - ## First, let's just see if we can find Guile at all. - AC_MSG_CHECKING(for Guile) - guile-config link > /dev/null || { - echo "configure: cannot find guile-config; is Guile installed?" 1>&2 - exit 1 - } - GUILE_CFLAGS="`guile-config compile`" - GUILE_LDFLAGS="`guile-config link`" +AC_DEFUN([GUILE_FLAGS], + [AC_REQUIRE([GUILE_PROGS])dnl + AC_MSG_CHECKING([libguile compile flags]) + GUILE_CFLAGS="`$GUILE_CONFIG compile`" + AC_MSG_RESULT([$GUILE_CFLAGS]) + AC_MSG_CHECKING([libguile link flags]) + GUILE_LDFLAGS="`$GUILE_CONFIG link`" + AC_MSG_RESULT([$GUILE_LDFLAGS]) AC_SUBST(GUILE_CFLAGS) AC_SUBST(GUILE_LDFLAGS) - AC_MSG_RESULT(yes) -]) + ]) # GUILE_SITE_DIR -- find path to Guile "site" directory # # Usage: GUILE_SITE_DIR # # This looks for Guile's "site" directory, usually something like -# PREFIX/share/guile/site, and sets var GUILE_SITE to the path. +# PREFIX/share/guile/site, and sets var @var{GUILE_SITE} to the path. # Note that the var name is different from the macro name. # -# The variable is marked for substitution, as by AC_SUBST. +# The variable is marked for substitution, as by @code{AC_SUBST}. # AC_DEFUN([GUILE_SITE_DIR], [AC_REQUIRE([GUILE_PROGS])dnl @@ -138,8 +139,8 @@ AC_DEFUN([GUILE_SITE_DIR], # # Usage: GUILE_CHECK_RETVAL(var,check) # -# $1 is a shell variable name to be set to the return value -# $2 is a Guile Scheme expression, evaluated with "$GUILE -c", and +# @var{var} is a shell variable name to be set to the return value. +# @var{check} is a Guile Scheme expression, evaluated with "$GUILE -c", and # returning either 0 or non-#f to indicate the check passed. # Non-0 number or #f indicates failure. # Avoid using the character "#" since that confuses autoconf. @@ -154,10 +155,10 @@ AC_DEFUN([GUILE_CHECK], # # Usage: GUILE_MODULE_CHECK(var,module,featuretest,description) # -# $1 is a shell variable name to be set to "yes" or "no" -# $2 is a list of symbols, like: (ice-9 common-list) -# $3 is an expression acceptable to GUILE_CHECK, q.v. -# $4 is a present-tense verb phrase (passed to AC_MSG_CHECKING) +# @var{var} is a shell variable name to be set to "yes" or "no". +# @var{module} is a list of symbols, like: (ice-9 common-list). +# @var{featuretest} is an expression acceptable to GUILE_CHECK, q.v. +# @var{description} is a present-tense verb phrase (passed to AC_MSG_CHECKING). # AC_DEFUN([GUILE_MODULE_CHECK], [AC_MSG_CHECKING([if $2 $4]) @@ -170,8 +171,8 @@ AC_DEFUN([GUILE_MODULE_CHECK], # # Usage: GUILE_MODULE_AVAILABLE(var,module) # -# $1 is a shell variable name to be set to "yes" or "no" -# $2 is a list of symbols, like: (ice-9 common-list) +# @var{var} is a shell variable name to be set to "yes" or "no". +# @var{module} is a list of symbols, like: (ice-9 common-list). # AC_DEFUN([GUILE_MODULE_AVAILABLE], [GUILE_MODULE_CHECK($1,$2,0,is available) @@ -181,7 +182,8 @@ AC_DEFUN([GUILE_MODULE_AVAILABLE], # # Usage: GUILE_MODULE_REQUIRED(symlist) # -# $1 is a list of symbols, WITHOUT surrounding parens, like: ice-9 common-list +# @var{symlist} is a list of symbols, WITHOUT surrounding parens, +# like: ice-9 common-list. # AC_DEFUN([GUILE_MODULE_REQUIRED], [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) @@ -194,9 +196,9 @@ AC_DEFUN([GUILE_MODULE_REQUIRED], # # Usage: GUILE_MODULE_EXPORTS(var,module,modvar) # -# $1 is a shell variable to be set to "yes" or "no" -# $2 is a list of symbols, like: (ice-9 common-list) -# $3 is the Guile Scheme variable to check +# @var{var} is a shell variable to be set to "yes" or "no". +# @var{module} is a list of symbols, like: (ice-9 common-list). +# @var{modvar} is the Guile Scheme variable to check. # AC_DEFUN([GUILE_MODULE_EXPORTS], [GUILE_MODULE_CHECK($1,$2,$3,exports `$3') @@ -206,8 +208,8 @@ AC_DEFUN([GUILE_MODULE_EXPORTS], # # Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar) # -# $1 is a list of symbols, like: (ice-9 common-list) -# $2 is the Guile Scheme variable to check +# @var{module} is a list of symbols, like: (ice-9 common-list). +# @var{modvar} is the Guile Scheme variable to check. # AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT], [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2) From 3055e49377ff90e8b4f4164eb77b2f0b5114c7d9 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 2 Jan 2002 23:51:42 +0000 Subject: [PATCH 279/281] Add Alexandre Duret-Lutz. --- THANKS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 14ec4bd67..60a6b5398 100644 --- a/THANKS +++ b/THANKS @@ -16,9 +16,10 @@ For fixes or providing information which led to a fix: Michael Carmack Brian Crowder Christopher Cramer + Alexandre Duret-Lutz Aubrey Jaffer Eric Gillespie, Jr - John Goerzen + John Goerzen Han-Wen Nienhuys Ron Peterson Ken Raeburn From 154fbc89576c8076db66112e6af6403b28ffa3bd Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 2 Jan 2002 23:55:12 +0000 Subject: [PATCH 280/281] *** empty log message *** --- guile-config/ChangeLog | 7 +++++++ scripts/ChangeLog | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/guile-config/ChangeLog b/guile-config/ChangeLog index 7183c80da..0fce8d321 100644 --- a/guile-config/ChangeLog +++ b/guile-config/ChangeLog @@ -1,3 +1,10 @@ +2002-01-02 Thien-Thi Nguyen + + * guile.m4: Rewrite comments in texi. + + (GUILE_FLAGS): Rewrite. + Thanks to Alexandre Duret-Lutz. + 2001-12-28 Thien-Thi Nguyen * guile.m4 (GUILE_PROGS, GUILE_SITE_DIR, GUILE_CHECK, diff --git a/scripts/ChangeLog b/scripts/ChangeLog index 50dd4d0fe..bced333d6 100644 --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2002-01-02 Thien-Thi Nguyen + + * snarf-guile-m4-docs: New script. + 2001-11-28 Thien-Thi Nguyen * punify (write-punily): Handle symbols w/ ":" prefix specially. From d928d47fc39d8b6e2951e1e10d129bb50d368259 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 2 Jan 2002 23:56:17 +0000 Subject: [PATCH 281/281] Initial revision --- doc/ref/autoconf.texi | 123 ++++++++++++++++++++++++++++++++++++ scripts/snarf-guile-m4-docs | 85 +++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 doc/ref/autoconf.texi create mode 100755 scripts/snarf-guile-m4-docs diff --git a/doc/ref/autoconf.texi b/doc/ref/autoconf.texi new file mode 100644 index 000000000..37f1a24ab --- /dev/null +++ b/doc/ref/autoconf.texi @@ -0,0 +1,123 @@ +@page +@node Autoconf Support +@chapter Autoconf Support + +When Guile is installed, a set of autoconf macros is also installed as +PREFIX/share/aclocal/guile.m4. This chapter documents the macros provided in +that file. @xref{Top,The GNU Autoconf Manual,,autoconf}, for more info. + +@menu +* Autoconf Background:: Why use autoconf? +* Autoconf Macros:: The GUILE_* macros. +* Using Autoconf Macros:: How to use them, plus examples. +@end menu + + +@node Autoconf Background +@section Autoconf Background + +As explained elsewhere (@pxref{Top,The GNU Autoconf Manual,,autoconf}), any +package needs configuration at build-time. If your package uses Guile (or +uses a package that in turn uses Guile), you probably need to know what +specific Guile features are available and details about them. + +The way to do this is to write feature tests and arrange for their execution +by the @file{configure} script, typically by adding the tests to +@file{configure.ac}, and running @code{autoconf} to create @file{configure}. +Users of your package then run @file{configure} in the normal way. + +Macros are a way to make common feature tests easy to express. Autoconf +provides a wide range macros (@pxref{Existing Tests,,,autoconf}), and Guile +installation provides Guile-specific tests in the areas of: program detection, +compilation flags reporting, and Scheme module checks. + + +@node Autoconf Macros +@section Autoconf Macros + +The macro names all begin with "GUILE_". + +@c see Makefile.am +@include autoconf-macros.texi + + +@node Using Autoconf Macros +@section Using Autoconf Macros + +Using the autoconf macros is straightforward: Add the macro "calls" (actually +instantiations) to @file{configure.ac}, run @code{aclocal}, and finally, +run @code{autoconf}. If your system doesn't have guile.m4 installed, place +the desired macro definitions (@code{AC_DEFUN} forms) in @file{acinclude.m4}, +and @code{aclocal} will do the right thing. + +Some of the macros can be used inside normal shell constructs: @code{if foo ; +then GUILE_BAZ ; fi}, but this is not guaranteed. It's probably a good idea +to instantiate macros at top-level. + +We now include two examples, one simple and one complicated. + +The first example is for a package that uses libguile, and thus needs to know +how to compile and link against it. So we use @code{GUILE_FLAGS} to set the +vars @code{GUILE_CFLAGS} and @code{GUILE_LDFLAGS}, which are automatically +substituted in the Makefile. + +@example +In configure.ac: + + GUILE_FLAGS + +In Makefile.in: + + GUILE_CFLAGS = @@GUILE_CFLAGS@@ + GUILE_LDFLAGS = @@GUILE_LDFLAGS@@ + + myprog.o: myprog.c + $(CC) -o $@ $(GUILE_CFLAGS) $< + myprog: myprog.o + $(CC) -o $@ $< $(GUILE_LDFLAGS) +@end example + +The second example is for a package of Guile Scheme modules that uses an +external program and other Guile Scheme modules (some might call this a "pure +scheme" package). So we use the @code{GUILE_SITE_DIR} macro, a regular +@code{AC_PATH_PROG} macro, and the @code{GUILE_MODULE_AVAILABLE} macro. + +@example +In configure.ac: + + GUILE_SITE_DIR + + probably_wont_work="" + + # pgtype pgtable + GUILE_MODULE_AVAILABLE(have_guile_pg, (database postgres)) + test $have_guile_pg = no && + probably_wont_work="(my pgtype) (my pgtable) $probably_wont_work" + + # gpgutils + AC_PATH_PROG(GNUPG,gpg) + test x"$GNUPG" = x && + probably_wont_work="(my gpgutils) $probably_wont_work" + + if test ! "$probably_wont_work" = "" ; then + p=" ***" + echo + echo "$p" + echo "$p NOTE:" + echo "$p The following modules probably won't work:" + echo "$p $probably_wont_work" + echo "$p They can be installed anyway, and will work if their" + echo "$p dependencies are installed later. Please see README." + echo "$p" + echo + fi + +In Makefile.in: + + instdir = @@GUILE_SITE@@/my + + install: + $(INSTALL) my/*.scm $(instdir) +@end example + +@c autoconf.texi ends here diff --git a/scripts/snarf-guile-m4-docs b/scripts/snarf-guile-m4-docs new file mode 100755 index 000000000..8a724ca67 --- /dev/null +++ b/scripts/snarf-guile-m4-docs @@ -0,0 +1,85 @@ +#!/bin/sh +# aside from this initial boilerplate, this is actually -*- scheme -*- code +main='(module-ref (resolve-module '\''(scripts snarf-guile-m4-docs)) '\'main')' +exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" +!# +;;; snarf-guile-m4-docs --- Parse guile.m4 comments for texi documentation + +;; Copyright (C) 2002 Free Software Foundation, Inc. +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this software; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, +;; Boston, MA 02111-1307 USA + +;;; Author: Thien-Thi Nguyen + +;;; Commentary: + +;; Usage: snarf-guile-m4-docs FILE +;; +;; Grep FILE for comments preceding macro definitions, massage +;; them into valid texi, and display to stdout. For each comment, +;; lines preceding "^# Usage:" are discarded. +;; +;; TODO: Generalize. + +;;; Code: + +(define-module (scripts snarf-guile-m4-docs) + :use-module (ice-9 rdelim) + :export (snarf-guile-m4-docs)) + +(define (display-texi lines) + (display "@deffn {Autoconf Macro}") + (for-each (lambda (line) + (display (if (string=? "#" (substring line 0 1)) + (substring line 1) + line)) + (newline)) + lines) + (display "@end deffn") + (newline) (newline)) + +(define (prefix? line sub) + (false-if-exception + (string=? sub (substring line 0 (string-length sub))))) + +(define (massage-usage line) + (let loop ((line (string->list line)) (acc '())) + (if (null? line) + (list (list->string (reverse acc))) + (loop (cdr line) + (cons (case (car line) + ((#\( #\) #\,) #\space) + (else (car line))) + acc))))) + +(define (snarf-guile-m4-docs . args) + (let* ((p (open-file (car args) "r")) + (next (lambda () (read-line p)))) + (let loop ((line (next)) (acc #f)) + (or (eof-object? line) + (cond ((prefix? line "# Usage:") + (loop (next) (massage-usage (substring line 8)))) + ((prefix? line "AC_DEFUN") + (display-texi (reverse acc)) + (loop (next) #f)) + ((and acc (prefix? line "#")) + (loop (next) (cons line acc))) + (else + (loop (next) #f))))))) + +(define main snarf-guile-m4-docs) + +;;; snarf-guile-m4-docs ends here