* list.c: Moved append docs to append! Thanks Dirk Hermann. Also,
[bpt/guile.git] / libguile / unif.c
index 2158976..4a96198 100644 (file)
  * 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.  */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+   gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
+
 \f
 
 #include <stdio.h>
@@ -49,6 +53,7 @@
 #include "strop.h"
 #include "feature.h"
 
+#include "scm_validate.h"
 #include "unif.h"
 #include "ramap.h"
 
  * double              dvect
  * complex double      cvect
  * short               svect
- * long_long           llvect
+ * long long           llvect
  */
 
 long scm_tc16_array;
 
-/* 
- * This complicates things too much if allowed on any array.
- * C code can safely call it on arrays known to be used in a single
- * threaded manner.
- *
- * SCM_PROC(s_vector_set_length_x, "vector-set-length!", 2, 0, 0, scm_vector_set_length_x); 
- */
-static char s_vector_set_length_x[] = "vector-set-length!";
-
-
-SCM 
-scm_vector_set_length_x (vect, len)
-     SCM vect;
-     SCM len;
+/* return the size of an element in a uniform array or 0 if type not
+   found.  */
+scm_sizet
+scm_uniform_element_size (SCM obj)
 {
-  long l;
-  scm_sizet siz;
-  scm_sizet sz;
+  scm_sizet result;
 
-  l = SCM_INUM (len);
-  SCM_ASRTGO (SCM_NIMP (vect), badarg1);
-  switch (SCM_TYP7 (vect))
+  switch (SCM_TYP7 (obj))
     {
-    default:
-    badarg1: scm_wta (vect, (char *) SCM_ARG1, s_vector_set_length_x);
-    case scm_tc7_string:
-      SCM_ASRTGO (vect != scm_nullstr, badarg1);
-      sz = sizeof (char);
-      l++;
-      break;
-    case scm_tc7_vector:
-    case scm_tc7_wvect:
-      SCM_ASRTGO (vect != scm_nullvect, badarg1);
-      sz = sizeof (SCM);
-      break;
-#ifdef ARRAYS
     case scm_tc7_bvect:
-      l = (l + SCM_LONG_BIT - 1) / SCM_LONG_BIT;
     case scm_tc7_uvect:
     case scm_tc7_ivect:
-      sz = sizeof (long);
+      result = sizeof (long);
       break;
+
     case scm_tc7_byvect:
-      sz = sizeof (char);
+      result = sizeof (char);
       break;
 
     case scm_tc7_svect:
-      sz = sizeof (short);
+      result = sizeof (short);
       break;
-#ifdef LONGLONGS
+
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
-      sz = sizeof (long_long);
+      result = sizeof (long_long);
       break;
 #endif 
 
 #ifdef SCM_FLOATS
 #ifdef SCM_SINGLES
     case scm_tc7_fvect:
-      sz = sizeof (float);
+      result = sizeof (float);
       break;
 #endif
+
     case scm_tc7_dvect:
-      sz = sizeof (double);
+      result = sizeof (double);
       break;
+
     case scm_tc7_cvect:
-      sz = 2 * sizeof (double);
+      result = 2 * sizeof (double);
       break;
 #endif
-#endif
+      
+    default:
+      result = 0;
     }
-  SCM_ASSERT (SCM_INUMP (len), len, SCM_ARG2, s_vector_set_length_x);
-  if (!l)
-    l = 1L;
-  siz = l * sz;
-  if (siz != l * sz)
-    scm_wta (SCM_MAKINUM (l * sz), (char *) SCM_NALLOC, s_vector_set_length_x);
-  SCM_REDEFER_INTS;
-  SCM_SETCHARS (vect,
-           ((char *)
-            scm_must_realloc (SCM_CHARS (vect),
-                              (long) SCM_LENGTH (vect) * sz,
-                              (long) siz,
-                              s_vector_set_length_x)));
-  if (SCM_VECTORP (vect))
-    {
-      sz = SCM_LENGTH (vect);
-      while (l > sz)
-       SCM_VELTS (vect)[--l] = SCM_UNSPECIFIED;
-    }
-  else if (SCM_STRINGP (vect))
-    SCM_CHARS (vect)[l - 1] = 0;
-  SCM_SETLENGTH (vect, SCM_INUM (len), SCM_TYP7 (vect));
-  SCM_REALLOW_INTS;
-  return vect;
+  return result;
 }
 
 
-#ifdef ARRAYS
-
 #ifdef SCM_FLOATS
 #ifdef SCM_SINGLES
 
@@ -194,9 +152,7 @@ scm_makflo (float x)
 
 
 SCM 
-scm_make_uve (k, prot)
-     long k;
-     SCM prot;
+scm_make_uve (long k, SCM prot)
 {
   SCM v;
   long i, type;
@@ -205,12 +161,12 @@ scm_make_uve (k, prot)
       i = sizeof (long) * ((k + SCM_LONG_BIT - 1) / SCM_LONG_BIT);
       type = scm_tc7_bvect;
     }
-  else if (SCM_ICHRP (prot) && (prot == SCM_MAKICHR ('\0')))
+  else if (SCM_CHARP (prot) && (prot == SCM_MAKE_CHAR ('\0')))
     {
       i = sizeof (char) * k;
       type = scm_tc7_byvect;
     }    
-  else if (SCM_ICHRP (prot))
+  else if (SCM_CHARP (prot))
     {
       i = sizeof (char) * k;
       type = scm_tc7_string;
@@ -223,7 +179,7 @@ scm_make_uve (k, prot)
       else
        type = scm_tc7_ivect;
     }
-  else if (SCM_NIMP (prot) && SCM_SYMBOLP (prot) && (1 == SCM_LENGTH (prot)))
+  else if (SCM_SYMBOLP (prot) && (1 == SCM_LENGTH (prot)))
     {
       char s;
 
@@ -233,7 +189,7 @@ scm_make_uve (k, prot)
          i = sizeof (short) * k;
          type = scm_tc7_svect;
        }
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
       else if (s == 'l')
        {
          i = sizeof (long_long) * k;
@@ -250,7 +206,8 @@ scm_make_uve (k, prot)
   if (SCM_IMP (prot) || !SCM_INEXP (prot))
 #endif
     /* Huge non-unif vectors are NOT supported. */
-    return scm_make_vector (SCM_MAKINUM (k), SCM_UNDEFINED);   /* no special scm_vector */
+    /* no special scm_vector */
+    return scm_make_vector (SCM_MAKINUM (k), SCM_UNDEFINED);
 #ifdef SCM_FLOATS
 #ifdef SCM_SINGLES
   else if (SCM_SINGP (prot))
@@ -274,28 +231,23 @@ scm_make_uve (k, prot)
 
   SCM_NEWCELL (v);
   SCM_DEFER_INTS;
-  {
-    char *m;
-    m = scm_must_malloc ((i ? i : 1L), "vector");
-    SCM_SETCHARS (v, (char *) m);
-  }
+  SCM_SETCHARS (v, (char *) scm_must_malloc (i ? i : 1, "vector"));
   SCM_SETLENGTH (v, (k < SCM_LENGTH_MAX ? k : SCM_LENGTH_MAX), type);
   SCM_ALLOW_INTS;
   return v;
 }
 
-SCM_PROC(s_uniform_vector_length, "uniform-vector-length", 1, 0, 0, scm_uniform_vector_length);
-
-SCM 
-scm_uniform_vector_length (v)
-     SCM v;
+SCM_DEFINE (scm_uniform_vector_length, "uniform-vector-length", 1, 0, 0, 
+           (SCM v),
+           "Returns the number of elements in @var{uve}.")
+#define FUNC_NAME s_scm_uniform_vector_length
 {
   SCM_ASRTGO (SCM_NIMP (v), badarg1);
   switch SCM_TYP7
     (v)
     {
     default:
-    badarg1:scm_wta (v, (char *) SCM_ARG1, s_uniform_vector_length);
+    badarg1:SCM_WTA(1,v);
     case scm_tc7_bvect:
     case scm_tc7_string:
     case scm_tc7_byvect:
@@ -307,19 +259,20 @@ scm_uniform_vector_length (v)
     case scm_tc7_vector:
     case scm_tc7_wvect:
     case scm_tc7_svect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
       return SCM_MAKINUM (SCM_LENGTH (v));
     }
 }
-
-SCM_PROC(s_array_p, "array?", 1, 1, 0, scm_array_p);
-
-SCM 
-scm_array_p (v, prot)
-     SCM v;
-     SCM prot;
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_array_p, "array?", 1, 1, 0,
+           (SCM v, SCM prot),
+           "Returns @code{#t} if the @var{obj} is an array, and @code{#f} if not.\n\n"
+           "The @var{prototype} argument is used with uniform arrays and is described\n"
+           "elsewhere.")
+#define FUNC_NAME s_scm_array_p
 {
   int nprot;
   int enclosed;
@@ -340,56 +293,55 @@ loop:
       v = SCM_ARRAY_V (v);
       goto loop;
     case scm_tc7_bvect:
-      return nprot || SCM_BOOL_T==prot ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_BOOL_T==prot);
     case scm_tc7_string:
-      return nprot || (SCM_ICHRP(prot) && (prot != SCM_MAKICHR('\0'))) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_CHARP(prot) && (prot != SCM_MAKE_CHAR('\0')));
     case scm_tc7_byvect:
-      return nprot || (prot == SCM_MAKICHR('\0')) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(prot == SCM_MAKE_CHAR('\0'));
     case scm_tc7_uvect:
-      return nprot || (SCM_INUMP(prot) && SCM_INUM(prot)>0) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_INUMP(prot) && SCM_INUM(prot)>0);
     case scm_tc7_ivect:
-      return nprot || (SCM_INUMP(prot) && SCM_INUM(prot)<=0) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_INUMP(prot) && SCM_INUM(prot)<=0);
     case scm_tc7_svect:
       return (   nprot
-             || (SCM_NIMP (prot)
-                 && SCM_SYMBOLP (prot)
+             || (SCM_SYMBOLP (prot)
                  && (1 == SCM_LENGTH (prot))
                  && ('s' == SCM_CHARS (prot)[0])));
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
       return (   nprot
-             || (SCM_NIMP (prot)
-                 && SCM_SYMBOLP (prot)
+             || (SCM_SYMBOLP (prot)
                  && (1 == SCM_LENGTH (prot))
                  && ('s' == SCM_CHARS (prot)[0])));
 #endif
 # ifdef SCM_FLOATS
 #  ifdef SCM_SINGLES
     case scm_tc7_fvect:
-      return nprot || (SCM_NIMP(prot) && SCM_SINGP(prot)) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_SINGP(prot));
 #  endif
     case scm_tc7_dvect:
-      return nprot || (SCM_NIMP(prot) && SCM_REALP(prot)) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_REALP(prot));
     case scm_tc7_cvect:
-      return nprot || (SCM_NIMP(prot) && SCM_CPLXP(prot)) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_CPLXP(prot));
 # endif
     case scm_tc7_vector:
     case scm_tc7_wvect:
-      return nprot || SCM_NULLP(prot) ? SCM_BOOL_T : SCM_BOOL_F;
+      return nprot || SCM_BOOL(SCM_NULLP(prot));
     default:;
     }
   return SCM_BOOL_F;
 }
+#undef FUNC_NAME
 
 
-SCM_PROC(s_array_rank, "array-rank", 1, 0, 0, scm_array_rank);
-
-SCM 
-scm_array_rank (ra)
-     SCM ra;
+SCM_DEFINE (scm_array_rank, "array-rank", 1, 0, 0, 
+           (SCM ra),
+           "Returns the number of dimensions of @var{obj}.  If @var{obj} is not an\n"
+           "array, @code{0} is returned.")
+#define FUNC_NAME s_scm_array_rank
 {
   if (SCM_IMP (ra))
- return SCM_INUM0;
   return SCM_INUM0;
   switch (SCM_TYP7 (ra))
     {
     default:
@@ -403,7 +355,7 @@ scm_array_rank (ra)
     case scm_tc7_fvect:
     case scm_tc7_cvect:
     case scm_tc7_dvect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
     case scm_tc7_svect:
@@ -414,19 +366,23 @@ scm_array_rank (ra)
       return SCM_INUM0;
     }
 }
+#undef FUNC_NAME
 
 
-SCM_PROC(s_array_dimensions, "array-dimensions", 1, 0, 0, scm_array_dimensions);
-
-SCM 
-scm_array_dimensions (ra)
-     SCM ra;
+SCM_DEFINE (scm_array_dimensions, "array-dimensions", 1, 0, 0, 
+           (SCM ra),
+           "@code{Array-dimensions} is similar to @code{array-shape} but replaces\n"
+           "elements with a @code{0} minimum with one greater than the maximum. So:\n"
+           "@example\n"
+           "(array-dimensions (make-array 'foo '(-1 3) 5)) @result{} ((-1 3) 5)\n"
+           "@end example")
+#define FUNC_NAME s_scm_array_dimensions
 {
   SCM res = SCM_EOL;
   scm_sizet k;
   scm_array_dim *s;
   if (SCM_IMP (ra))
- return SCM_BOOL_F;
   return SCM_BOOL_F;
   switch (SCM_TYP7 (ra))
     {
     default:
@@ -442,7 +398,7 @@ scm_array_dimensions (ra)
     case scm_tc7_cvect:
     case scm_tc7_dvect:
     case scm_tc7_svect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
       return scm_cons (SCM_MAKINUM (SCM_LENGTH (ra)), SCM_EOL);
@@ -458,16 +414,14 @@ scm_array_dimensions (ra)
       return res;
     }
 }
+#undef FUNC_NAME
 
 
 static char s_bad_ind[] = "Bad scm_array index";
 
 
 long 
-scm_aind (ra, args, what)
-     SCM ra;
-     SCM args;
-     const char *what;
+scm_aind (SCM ra, SCM args, const char *what)
 {
   SCM ind;
   register long j;
@@ -498,8 +452,7 @@ scm_aind (ra, args, what)
 
 
 SCM 
-scm_make_ra (ndim)
-     int ndim;
+scm_make_ra (int ndim)
 {
   SCM ra;
   SCM_NEWCELL (ra);
@@ -517,9 +470,7 @@ static char s_bad_spec[] = "Bad scm_array dimension";
 
 
 SCM 
-scm_shap2ra (args, what)
-     SCM args;
-     const char *what;
+scm_shap2ra (SCM args, const char *what)
 {
   scm_array_dim *s;
   SCM ra, spec, sp;
@@ -546,7 +497,7 @@ scm_shap2ra (args, what)
                      s_bad_spec, what);
          s->lbnd = SCM_INUM (SCM_CAR (spec));
          sp = SCM_CDR (spec);
-         SCM_ASSERT (SCM_NIMP (sp) && SCM_CONSP (sp)
+         SCM_ASSERT (SCM_CONSP (sp)
                      && SCM_INUMP (SCM_CAR (sp)) && SCM_NULLP (SCM_CDR (sp)),
                      spec, s_bad_spec, what);
          s->ubnd = SCM_INUM (SCM_CAR (sp));
@@ -556,13 +507,14 @@ scm_shap2ra (args, what)
   return ra;
 }
 
-SCM_PROC(s_dimensions_to_uniform_array, "dimensions->uniform-array", 2, 0, 1, scm_dimensions_to_uniform_array);
-
-SCM 
-scm_dimensions_to_uniform_array (dims, prot, fill)
-     SCM dims;
-     SCM prot;
-     SCM fill;
+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"
+           "Creates and returns a uniform array or vector of type corresponding to\n"
+           "@var{prototype} with dimensions @var{dims} or length @var{length}.  If\n"
+           "@var{fill} is supplied, it's used to fill the array, otherwise \n"
+           "@var{prototype} is used.")
+#define FUNC_NAME s_scm_dimensions_to_uniform_array
 {
   scm_sizet k, vlen = 1;
   long rlen = 1;
@@ -572,16 +524,11 @@ scm_dimensions_to_uniform_array (dims, prot, fill)
     {
       if (SCM_INUM (dims) < SCM_LENGTH_MAX)
        {
-         SCM answer;
-         answer = scm_make_uve (SCM_INUM (dims), prot);
-         if (SCM_NNULLP (fill))
-           {
-             SCM_ASSERT (1 == scm_ilength (fill),
-                         scm_makfrom0str (s_dimensions_to_uniform_array),
-                         SCM_WNA, NULL);
-             scm_array_fill_x (answer, SCM_CAR (fill));
-           }
-         else if (SCM_NIMP (prot) && SCM_SYMBOLP (prot))
+         SCM answer = scm_make_uve (SCM_INUM (dims), prot);
+
+         if (!SCM_UNBNDP (fill))
+           scm_array_fill_x (answer, fill);
+         else if (SCM_SYMBOLP (prot))
            scm_array_fill_x (answer, SCM_MAKINUM (0));
          else
            scm_array_fill_x (answer, prot);
@@ -590,9 +537,9 @@ scm_dimensions_to_uniform_array (dims, prot, fill)
     else
       dims = scm_cons (dims, SCM_EOL);
     }
-  SCM_ASSERT (SCM_NULLP (dims) || (SCM_NIMP (dims) && SCM_CONSP (dims)),
-         dims, SCM_ARG1, s_dimensions_to_uniform_array);
-  ra = scm_shap2ra (dims, s_dimensions_to_uniform_array);
+  SCM_ASSERT (SCM_NULLP (dims) || SCM_CONSP (dims),
+              dims, SCM_ARG1, FUNC_NAME);
+  ra = scm_shap2ra (dims, FUNC_NAME);
   SCM_SETOR_CAR (ra, SCM_ARRAY_CONTIGUOUS);
   s = SCM_ARRAY_DIMS (ra);
   k = SCM_ARRAY_NDIM (ra);
@@ -633,14 +580,11 @@ scm_dimensions_to_uniform_array (dims, prot, fill)
       SCM_ARRAY_V (ra) = scm_make_uve (rlen, prot);
       *((long *) SCM_VELTS (SCM_ARRAY_V (ra))) = rlen;
     }
-  if (SCM_NNULLP (fill))
+  if (!SCM_UNBNDP (fill))
     {
-      SCM_ASSERT (1 == scm_ilength (fill),
-                 scm_makfrom0str (s_dimensions_to_uniform_array), SCM_WNA,
-                 NULL);
-      scm_array_fill_x (ra, SCM_CAR (fill));
+      scm_array_fill_x (ra, fill);
     }
-  else if (SCM_NIMP (prot) && SCM_SYMBOLP (prot))
+  else if (SCM_SYMBOLP (prot))
     scm_array_fill_x (ra, SCM_MAKINUM (0));
   else
     scm_array_fill_x (ra, prot);
@@ -649,11 +593,11 @@ scm_dimensions_to_uniform_array (dims, prot, fill)
       return SCM_ARRAY_V (ra);
   return ra;
 }
+#undef FUNC_NAME
 
 
 void 
-scm_ra_set_contp (ra)
-     SCM ra;
+scm_ra_set_contp (SCM ra)
 {
   scm_sizet k = SCM_ARRAY_NDIM (ra);
   if (k)
@@ -674,13 +618,24 @@ scm_ra_set_contp (ra)
 }
 
 
-SCM_PROC(s_make_shared_array, "make-shared-array", 2, 0, 1, scm_make_shared_array);
-
-SCM 
-scm_make_shared_array (oldra, mapfunc, dims)
-     SCM oldra;
-     SCM mapfunc;
-     SCM dims;
+SCM_DEFINE (scm_make_shared_array, "make-shared-array", 2, 0, 1,
+           (SCM oldra, SCM mapfunc, SCM dims),
+           "@code{make-shared-array} can be used to create shared subarrays of other\n"
+           "arrays.  The @var{mapper} is a function that translates coordinates in\n"
+           "the new array into coordinates in the old array.  A @var{mapper} must be\n"
+           "linear, and its range must stay within the bounds of the old array, but\n"
+           "it can be otherwise arbitrary.  A simple example:\n"
+           "@example\n"
+           "(define fred (make-array #f 8 8))\n"
+           "(define freds-diagonal\n"
+           "  (make-shared-array fred (lambda (i) (list i i)) 8))\n"
+           "(array-set! freds-diagonal 'foo 3)\n"
+           "(array-ref fred 3 3) @result{} foo\n"
+           "(define freds-center\n"
+           "  (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2))\n"
+           "(array-ref freds-center 0 0) @result{} foo\n"
+           "@end example")
+#define FUNC_NAME s_scm_make_shared_array
 {
   SCM ra;
   SCM inds, indptr;
@@ -688,9 +643,9 @@ scm_make_shared_array (oldra, mapfunc, dims)
   scm_sizet i, k;
   long old_min, new_min, old_max, new_max;
   scm_array_dim *s;
-  SCM_ASSERT (SCM_BOOL_T == scm_procedure_p (mapfunc), mapfunc, SCM_ARG2, s_make_shared_array);
-  SCM_ASSERT (SCM_NIMP (oldra) && (SCM_BOOL_F != scm_array_p (oldra, SCM_UNDEFINED)), oldra, SCM_ARG1, s_make_shared_array);
-  ra = scm_shap2ra (dims, s_make_shared_array);
+  SCM_VALIDATE_ARRAY (1,oldra);
+  SCM_VALIDATE_PROC (2,mapfunc);
+  ra = scm_shap2ra (dims, FUNC_NAME);
   if (SCM_ARRAYP (oldra))
     {
       SCM_ARRAY_V (ra) = SCM_ARRAY_V (oldra);
@@ -727,14 +682,14 @@ scm_make_shared_array (oldra, mapfunc, dims)
     }
   imap = scm_apply (mapfunc, scm_reverse (inds), SCM_EOL);
   if (SCM_ARRAYP (oldra))
-      i = (scm_sizet) scm_aind (oldra, imap, s_make_shared_array);
+      i = (scm_sizet) scm_aind (oldra, imap, FUNC_NAME);
   else
     {
       if (SCM_NINUMP (imap))
 
        {
          SCM_ASSERT (1 == scm_ilength (imap) && SCM_INUMP (SCM_CAR (imap)),
-                 imap, s_bad_ind, s_make_shared_array);
+                 imap, s_bad_ind, FUNC_NAME);
          imap = SCM_CAR (imap);
        }
       i = SCM_INUM (imap);
@@ -750,14 +705,14 @@ scm_make_shared_array (oldra, mapfunc, dims)
          imap = scm_apply (mapfunc, scm_reverse (inds), SCM_EOL);
          if (SCM_ARRAYP (oldra))
 
-             s[k].inc = scm_aind (oldra, imap, s_make_shared_array) - i;
+             s[k].inc = scm_aind (oldra, imap, FUNC_NAME) - i;
          else
            {
              if (SCM_NINUMP (imap))
 
                {
                  SCM_ASSERT (1 == scm_ilength (imap) && SCM_INUMP (SCM_CAR (imap)),
-                         imap, s_bad_ind, s_make_shared_array);
+                              imap, s_bad_ind, FUNC_NAME);
                  imap = SCM_CAR (imap);
                }
              s[k].inc = (long) SCM_INUM (imap) - i;
@@ -773,7 +728,7 @@ scm_make_shared_array (oldra, mapfunc, dims)
       indptr = SCM_CDR (indptr);
     }
   SCM_ASSERT (old_min <= new_min && old_max >= new_max, SCM_UNDEFINED,
-         "mapping out of range", s_make_shared_array);
+         "mapping out of range", FUNC_NAME);
   if (1 == SCM_ARRAY_NDIM (ra) && 0 == SCM_ARRAY_BASE (ra))
     {
       if (1 == s->inc && 0 == s->lbnd
@@ -785,27 +740,43 @@ scm_make_shared_array (oldra, mapfunc, dims)
   scm_ra_set_contp (ra);
   return ra;
 }
+#undef FUNC_NAME
 
 
 /* args are RA . DIMS */
-SCM_PROC(s_transpose_array, "transpose-array", 0, 0, 1, scm_transpose_array);
-
-SCM 
-scm_transpose_array (args)
-     SCM args;
+SCM_DEFINE (scm_transpose_array, "transpose-array", 0, 0, 1, 
+           (SCM args),
+           "Returns an array sharing contents with @var{array}, but with dimensions\n"
+           "arranged in a different order.  There must be one @var{dim} argument for\n"
+           "each dimension of @var{array}.  @var{dim0}, @var{dim1}, @dots{} should\n"
+           "be integers between 0 and the rank of the array to be returned.  Each\n"
+           "integer in that range must appear at least once in the argument list.\n\n"
+           "The values of @var{dim0}, @var{dim1}, @dots{} correspond to dimensions\n"
+           "in the array to be returned, their positions in the argument list to\n"
+           "dimensions of @var{array}.  Several @var{dim}s may have the same value,\n"
+           "in which case the returned array will have smaller rank than\n"
+           "@var{array}.\n\n"
+           "examples:\n"
+           "@example\n"
+           "(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d))\n"
+           "(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d)\n"
+           "(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{}\n"
+           "                #2((a 4) (b 5) (c 6))\n"
+           "@end example")
+#define FUNC_NAME s_scm_transpose_array
 {
   SCM ra, res, vargs, *ve = &vargs;
   scm_array_dim *s, *r;
   int ndim, i, k;
-  SCM_ASSERT (SCM_NNULLP (args), scm_makfrom0str (s_transpose_array),
+  SCM_ASSERT (SCM_NNULLP (args), scm_makfrom0str (FUNC_NAME),
              SCM_WNA, NULL);
   ra = SCM_CAR (args);
-  SCM_ASSERT (SCM_NIMP (ra), ra, SCM_ARG1, s_transpose_array);
+  SCM_ASSERT (SCM_NIMP (ra), ra, SCM_ARG1, FUNC_NAME);
   args = SCM_CDR (args);
   switch (SCM_TYP7 (ra))
     {
     default:
-    badarg:scm_wta (ra, (char *) SCM_ARG1, s_transpose_array);
+    badarg:SCM_WTA (1,ra);
     case scm_tc7_bvect:
     case scm_tc7_string:
     case scm_tc7_byvect:
@@ -815,30 +786,30 @@ scm_transpose_array (args)
     case scm_tc7_dvect:
     case scm_tc7_cvect:
     case scm_tc7_svect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
       SCM_ASSERT (SCM_NIMP (args) && SCM_NULLP (SCM_CDR (args)),
-                 scm_makfrom0str (s_transpose_array), SCM_WNA, NULL);
+                 scm_makfrom0str (FUNC_NAME), SCM_WNA, NULL);
       SCM_ASSERT (SCM_INUMP (SCM_CAR (args)), SCM_CAR (args), SCM_ARG2,
-                 s_transpose_array);
+                 FUNC_NAME);
       SCM_ASSERT (SCM_INUM0 == SCM_CAR (args), SCM_CAR (args), SCM_OUTOFRANGE,
-                 s_transpose_array);
+                 FUNC_NAME);
       return ra;
     case scm_tc7_smob:
       SCM_ASRTGO (SCM_ARRAYP (ra), badarg);
       vargs = scm_vector (args);
       SCM_ASSERT (SCM_LENGTH (vargs) == SCM_ARRAY_NDIM (ra),
-                 scm_makfrom0str (s_transpose_array), SCM_WNA, NULL);
+                 scm_makfrom0str (FUNC_NAME), SCM_WNA, NULL);
                  ve = SCM_VELTS (vargs);
       ndim = 0;
       for (k = 0; k < SCM_ARRAY_NDIM (ra); k++)
        {
          SCM_ASSERT (SCM_INUMP (ve[k]), ve[k], (SCM_ARG2 + k),
-                     s_transpose_array);
+                     FUNC_NAME);
          i = SCM_INUM (ve[k]);
          SCM_ASSERT (i >= 0 && i < SCM_ARRAY_NDIM (ra), ve[k],
-                     SCM_OUTOFRANGE, s_transpose_array);
+                     SCM_OUTOFRANGE, FUNC_NAME);
          if (ndim < i)
            ndim = i;
        }
@@ -875,28 +846,44 @@ scm_transpose_array (args)
              r->inc += s->inc;
            }
        }
-      SCM_ASSERT (ndim <= 0, args, "bad argument list", s_transpose_array);
+      SCM_ASSERT (ndim <= 0, args, "bad argument list", FUNC_NAME);
       scm_ra_set_contp (res);
       return res;
     }
 }
+#undef FUNC_NAME
 
 /* args are RA . AXES */
-SCM_PROC(s_enclose_array, "enclose-array", 0, 0, 1, scm_enclose_array);
-
-SCM 
-scm_enclose_array (axes)
-     SCM axes;
+SCM_DEFINE (scm_enclose_array, "enclose-array", 0, 0, 1, 
+           (SCM axes),
+           "@var{dim0}, @var{dim1} @dots{} should be nonnegative integers less than\n"
+           "the rank of @var{array}.  @var{enclose-array} returns an array\n"
+           "resembling an array of shared arrays.  The dimensions of each shared\n"
+           "array are the same as the @var{dim}th dimensions of the original array,\n"
+           "the dimensions of the outer array are the same as those of the original\n"
+           "array that did not match a @var{dim}.\n\n"
+           "An enclosed array is not a general Scheme array.  Its elements may not\n"
+           "be set using @code{array-set!}.  Two references to the same element of\n"
+           "an enclosed array will be @code{equal?} but will not in general be\n"
+           "@code{eq?}.  The value returned by @var{array-prototype} when given an\n"
+           "enclosed array is unspecified.\n\n"
+           "examples:\n"
+           "@example\n"
+           "(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) @result{}\n"
+           "   #<enclosed-array (#1(a d) #1(b e) #1(c f)) (#1(1 4) #1(2 5) #1(3 6))>\n\n"
+           "(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) @result{}\n"
+           "   #<enclosed-array #2((a 1) (d 4)) #2((b 2) (e 5)) #2((c 3) (f 6))>\n"
+           "@end example")
+#define FUNC_NAME s_scm_enclose_array
 {
   SCM axv, ra, res, ra_inr;
   scm_array_dim vdim, *s = &vdim;
   int ndim, j, k, ninr, noutr;
-  SCM_ASSERT (SCM_NIMP (axes), scm_makfrom0str (s_enclose_array), SCM_WNA,
+  SCM_ASSERT (SCM_NIMP (axes), scm_makfrom0str (FUNC_NAME), SCM_WNA,
              NULL);
   ra = SCM_CAR (axes);
   axes = SCM_CDR (axes);
   if (SCM_NULLP (axes))
-
       axes = scm_cons ((SCM_ARRAYP (ra) ? SCM_MAKINUM (SCM_ARRAY_NDIM (ra) - 1) : SCM_INUM0), SCM_EOL);
   ninr = scm_ilength (axes);
   ra_inr = scm_make_ra (ninr);
@@ -905,7 +892,7 @@ scm_enclose_array (axes)
     (ra)
     {
     default:
-    badarg1:scm_wta (ra, (char *) SCM_ARG1, s_enclose_array);
+    badarg1:SCM_WTA (1,ra);
     case scm_tc7_string:
     case scm_tc7_bvect:
     case scm_tc7_byvect:
@@ -917,7 +904,7 @@ scm_enclose_array (axes)
     case scm_tc7_vector:
     case scm_tc7_wvect:
     case scm_tc7_svect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
       s->lbnd = 0;
@@ -936,15 +923,15 @@ scm_enclose_array (axes)
       break;
     }
   noutr = ndim - ninr;
-  axv = scm_make_string (SCM_MAKINUM (ndim), SCM_MAKICHR (0));
-  SCM_ASSERT (0 <= noutr && 0 <= ninr, scm_makfrom0str (s_enclose_array),
+  axv = scm_make_string (SCM_MAKINUM (ndim), SCM_MAKE_CHAR (0));
+  SCM_ASSERT (0 <= noutr && 0 <= ninr, scm_makfrom0str (FUNC_NAME),
              SCM_WNA, NULL);
   res = scm_make_ra (noutr);
   SCM_ARRAY_BASE (res) = SCM_ARRAY_BASE (ra_inr);
   SCM_ARRAY_V (res) = ra_inr;
   for (k = 0; k < ninr; k++, axes = SCM_CDR (axes))
     {
-      SCM_ASSERT (SCM_INUMP (SCM_CAR (axes)), SCM_CAR (axes), "bad axis", s_enclose_array);
+      SCM_ASSERT (SCM_INUMP (SCM_CAR (axes)), SCM_CAR (axes), "bad axis", FUNC_NAME);
       j = SCM_INUM (SCM_CAR (axes));
       SCM_ARRAY_DIMS (ra_inr)[k].lbnd = s[j].lbnd;
       SCM_ARRAY_DIMS (ra_inr)[k].ubnd = s[j].ubnd;
@@ -963,21 +950,21 @@ scm_enclose_array (axes)
   scm_ra_set_contp (res);
   return res;
 }
+#undef FUNC_NAME
 
 
 
-SCM_PROC(s_array_in_bounds_p, "array-in-bounds?", 0, 0, 1, scm_array_in_bounds_p);
-
-SCM 
-scm_array_in_bounds_p (args)
-     SCM args;
+SCM_DEFINE (scm_array_in_bounds_p, "array-in-bounds?", 0, 0, 1, 
+           (SCM args),
+           "Returns @code{#t} if its arguments would be acceptable to array-ref.")
+#define FUNC_NAME s_scm_array_in_bounds_p
 {
   SCM v, ind = SCM_EOL;
   long pos = 0;
   register scm_sizet k;
   register long j;
   scm_array_dim *s;
-  SCM_ASSERT (SCM_NIMP (args), scm_makfrom0str (s_array_in_bounds_p),
+  SCM_ASSERT (SCM_NIMP (args), scm_makfrom0str (FUNC_NAME),
              SCM_WNA, NULL);
   v = SCM_CAR (args);
   args = SCM_CDR (args);
@@ -987,7 +974,7 @@ scm_array_in_bounds_p (args)
     {
       ind = SCM_CAR (args);
       args = SCM_CDR (args);
-      SCM_ASSERT (SCM_INUMP (ind), ind, SCM_ARG2, s_array_in_bounds_p);
+      SCM_ASSERT (SCM_INUMP (ind), ind, SCM_ARG2, FUNC_NAME);
       pos = SCM_INUM (ind);
     }
 tail:
@@ -995,8 +982,8 @@ tail:
     (v)
     {
     default:
-    badarg1:scm_wta (v, (char *) SCM_ARG1, s_array_in_bounds_p);
-    wna: scm_wrong_num_args (scm_makfrom0str (s_array_in_bounds_p));
+    badarg1:SCM_WTA (1,v);
+    wna: scm_wrong_num_args (scm_makfrom0str (FUNC_NAME));
     case scm_tc7_smob:
       k = SCM_ARRAY_NDIM (v);
       s = SCM_ARRAY_DIMS (v);
@@ -1021,7 +1008,7 @@ tail:
            ind = SCM_CAR (args);
            args = SCM_CDR (args);
            s++;
-           SCM_ASSERT (SCM_INUMP (ind), ind, s_bad_ind, s_array_in_bounds_p);
+           SCM_ASSERT (SCM_INUMP (ind), ind, s_bad_ind, FUNC_NAME);
          }
       SCM_ASRTGO (0 == k, wna);
       v = SCM_ARRAY_V (v);
@@ -1035,24 +1022,25 @@ tail:
     case scm_tc7_dvect:
     case scm_tc7_cvect:
     case scm_tc7_svect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
     case scm_tc7_vector:
     case scm_tc7_wvect:
       SCM_ASRTGO (SCM_NULLP (args) && SCM_INUMP (ind), wna);
-      return pos >= 0 && pos < SCM_LENGTH (v) ? SCM_BOOL_T : SCM_BOOL_F;
+      return SCM_BOOL(pos >= 0 && pos < SCM_LENGTH (v));
     }
 }
+#undef FUNC_NAME
 
 
-SCM_PROC(s_array_ref, "array-ref", 1, 0, 1, scm_uniform_vector_ref);
-SCM_PROC(s_uniform_vector_ref, "uniform-vector-ref", 2, 0, 0, scm_uniform_vector_ref);
+SCM_REGISTER_PROC(s_array_ref, "array-ref", 1, 0, 1, scm_uniform_vector_ref);
 
-SCM 
-scm_uniform_vector_ref (v, args)
-     SCM v;
-     SCM args;
+
+SCM_DEFINE (scm_uniform_vector_ref, "uniform-vector-ref", 2, 0, 0,
+           (SCM v, SCM args),
+           "Returns the element at the @code{(index1, index2)} element in @var{array}.")
+#define FUNC_NAME s_scm_uniform_vector_ref
 {
   long pos;
 
@@ -1063,7 +1051,7 @@ scm_uniform_vector_ref (v, args)
     }
   else if (SCM_ARRAYP (v))
     {
-      pos = scm_aind (v, args, s_uniform_vector_ref);
+      pos = scm_aind (v, args, FUNC_NAME);
       v = SCM_ARRAY_V (v);
     }
   else
@@ -1071,13 +1059,13 @@ scm_uniform_vector_ref (v, args)
       if (SCM_NIMP (args))
 
        {
-         SCM_ASSERT (SCM_CONSP (args) && SCM_INUMP (SCM_CAR (args)), args, SCM_ARG2, s_uniform_vector_ref);
+         SCM_ASSERT (SCM_CONSP (args) && SCM_INUMP (SCM_CAR (args)), args, SCM_ARG2, FUNC_NAME);
          pos = SCM_INUM (SCM_CAR (args));
          SCM_ASRTGO (SCM_NULLP (SCM_CDR (args)), wna);
        }
       else
        {
-         SCM_ASSERT (SCM_INUMP (args), args, SCM_ARG2, s_uniform_vector_ref);
+          SCM_VALIDATE_INUM (2,args);
          pos = SCM_INUM (args);
        }
       SCM_ASRTGO (pos >= 0 && pos < SCM_LENGTH (v), outrng);
@@ -1089,10 +1077,10 @@ scm_uniform_vector_ref (v, args)
       if (SCM_NULLP (args))
  return v;
     badarg:
-      scm_wta (v, (char *) SCM_ARG1, s_uniform_vector_ref);
+      SCM_WTA (1,v);
       abort ();
-    outrng:scm_out_of_range (s_uniform_vector_ref, SCM_MAKINUM (pos));
-    wna: scm_wrong_num_args (scm_makfrom0str (s_uniform_vector_ref));
+    outrng:scm_out_of_range (FUNC_NAME, SCM_MAKINUM (pos));
+    wna: scm_wrong_num_args (SCM_FUNC_NAME);
     case scm_tc7_smob:
       {                                /* enclosed */
        int k = SCM_ARRAY_NDIM (v);
@@ -1113,7 +1101,7 @@ scm_uniform_vector_ref (v, args)
       else
        return SCM_BOOL_F;
     case scm_tc7_string:
-      return SCM_MAKICHR (SCM_UCHARS (v)[pos]);
+      return SCM_MAKE_CHAR (SCM_UCHARS (v)[pos]);
     case scm_tc7_byvect:
       return SCM_MAKINUM (((char *)SCM_CHARS (v))[pos]);
 # ifdef SCM_INUMS_ONLY
@@ -1129,7 +1117,7 @@ scm_uniform_vector_ref (v, args)
 
     case scm_tc7_svect:
       return SCM_MAKINUM (((short *) SCM_CDR (v))[pos]);
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
       return scm_long_long2num (((long_long *) SCM_CDR (v))[pos]);
 #endif
@@ -1150,18 +1138,15 @@ scm_uniform_vector_ref (v, args)
       return SCM_VELTS (v)[pos];
     }
 }
+#undef FUNC_NAME
 
 /* Internal version of scm_uniform_vector_ref for uves that does no error checking and
    tries to recycle conses.  (Make *sure* you want them recycled.) */
 
 SCM 
-scm_cvref (v, pos, last)
-     SCM v;
-     scm_sizet pos;
-     SCM last;
+scm_cvref (SCM v, scm_sizet pos, SCM last)
 {
-  switch SCM_TYP7
-    (v)
+  switch SCM_TYP7 (v)
     {
     default:
       scm_wta (v, (char *) SCM_ARG1, "PROGRAMMING ERROR: scm_cvref");
@@ -1171,7 +1156,7 @@ scm_cvref (v, pos, last)
       else
        return SCM_BOOL_F;
     case scm_tc7_string:
-      return SCM_MAKICHR (SCM_UCHARS (v)[pos]);
+      return SCM_MAKE_CHAR (SCM_UCHARS (v)[pos]);
     case scm_tc7_byvect:
       return SCM_MAKINUM (((char *)SCM_CHARS (v))[pos]);
 # ifdef SCM_INUMS_ONLY
@@ -1186,7 +1171,7 @@ scm_cvref (v, pos, last)
 # endif    
     case scm_tc7_svect:
       return SCM_MAKINUM (((short *) SCM_CDR (v))[pos]);
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
       return scm_long_long2num (((long_long *) SCM_CDR (v))[pos]);
 #endif
@@ -1241,22 +1226,22 @@ scm_cvref (v, pos, last)
     }
 }
 
-SCM_PROC(s_uniform_array_set1_x, "uniform-array-set1!", 3, 0, 0, scm_array_set_x);
-SCM_PROC(s_array_set_x, "array-set!", 2, 0, 1, scm_array_set_x);
+SCM_REGISTER_PROC(s_uniform_array_set1_x, "uniform-array-set1!", 3, 0, 0, scm_array_set_x);
+
 
 /* Note that args may be a list or an immediate object, depending which
    PROC is used (and it's called from C too).  */
-SCM 
-scm_array_set_x (v, obj, args)
-     SCM v;
-     SCM obj;
-     SCM args;
+SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1, 
+           (SCM v, SCM obj, SCM args),
+           "Sets 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           
 {
   long pos = 0;
   SCM_ASRTGO (SCM_NIMP (v), badarg1);
   if (SCM_ARRAYP (v))
     {
-      pos = scm_aind (v, args, s_array_set_x);
+      pos = scm_aind (v, args, FUNC_NAME);
       v = SCM_ARRAY_V (v);
     }
   else
@@ -1264,24 +1249,23 @@ scm_array_set_x (v, obj, args)
       if (SCM_NIMP (args))
        {
          SCM_ASSERT (SCM_CONSP(args) && SCM_INUMP (SCM_CAR (args)), args,
-                SCM_ARG3, s_array_set_x);
+                SCM_ARG3, FUNC_NAME);
          SCM_ASRTGO (SCM_NULLP (SCM_CDR (args)), wna);
          pos = SCM_INUM (SCM_CAR (args));
        }
       else
        {
-         SCM_ASSERT (SCM_INUMP (args), args, SCM_ARG3, s_array_set_x);
-         pos = SCM_INUM (args);
+          SCM_VALIDATE_INUM_COPY (3,args,pos);
        }
       SCM_ASRTGO (pos >= 0 && pos < SCM_LENGTH (v), outrng);
     }
   switch (SCM_TYP7 (v))
     {
     default: badarg1:
-      scm_wta (v, (char *) SCM_ARG1, s_array_set_x);
+      SCM_WTA (1,v);
       abort ();
-    outrng:scm_out_of_range (s_array_set_x, SCM_MAKINUM (pos));
-    wna: scm_wrong_num_args (scm_makfrom0str (s_array_set_x));
+    outrng:scm_out_of_range (FUNC_NAME, SCM_MAKINUM (pos));
+    wna: scm_wrong_num_args (SCM_FUNC_NAME);
     case scm_tc7_smob:         /* enclosed */
       goto badarg1;
     case scm_tc7_bvect:
@@ -1290,38 +1274,37 @@ scm_array_set_x (v, obj, args)
       else if (SCM_BOOL_T == obj)
        SCM_VELTS (v)[pos / SCM_LONG_BIT] |= (1L << (pos % SCM_LONG_BIT));
       else
-      badobj:scm_wta (obj, (char *) SCM_ARG2, s_array_set_x);
+      badobj:SCM_WTA (2,obj);
       break;
     case scm_tc7_string:
-      SCM_ASRTGO (SCM_ICHRP (obj), badobj);
-      SCM_UCHARS (v)[pos] = SCM_ICHR (obj);
+      SCM_ASRTGO (SCM_CHARP (obj), badobj);
+      SCM_UCHARS (v)[pos] = SCM_CHAR (obj);
       break;
     case scm_tc7_byvect:
-      if (SCM_ICHRP (obj))
-       obj = SCM_MAKINUM ((char) SCM_ICHR (obj));
+      if (SCM_CHARP (obj))
+       obj = SCM_MAKINUM ((char) SCM_CHAR (obj));
       SCM_ASRTGO (SCM_INUMP (obj), badobj);
       ((char *)SCM_CHARS (v))[pos] = SCM_INUM (obj);
       break;
 # ifdef SCM_INUMS_ONLY
     case scm_tc7_uvect:
-      SCM_ASRTGO (SCM_INUM (obj) >= 0, badobj);
+      SCM_ASRTGO (SCM_INUM (obj) >= 0, badobj); 
+      /* fall through */
     case scm_tc7_ivect:
-    SCM_ASRTGO(SCM_INUMP(obj), badobj); SCM_VELTS(v)[pos] = SCM_INUM(obj); break;
+      SCM_ASRTGO(SCM_INUMP(obj), badobj); SCM_VELTS(v)[pos] = SCM_INUM(obj); break;
 # else
-  case scm_tc7_uvect:
-    SCM_VELTS(v)[pos] = scm_num2ulong(obj, (char *)SCM_ARG2, s_array_set_x); break;
-  case scm_tc7_ivect:
-    SCM_VELTS(v)[pos] = scm_num2long(obj, (char *)SCM_ARG2, s_array_set_x); break;
+    case scm_tc7_uvect:
+      SCM_VELTS(v)[pos] = scm_num2ulong(obj, (char *)SCM_ARG2, FUNC_NAME); break;
+    case scm_tc7_ivect:
+      SCM_VELTS(v)[pos] = scm_num2long(obj, (char *)SCM_ARG2, FUNC_NAME); break;
 # endif
-      break;
-
     case scm_tc7_svect:
       SCM_ASRTGO (SCM_INUMP (obj), badobj);
       ((short *) SCM_CDR (v))[pos] = SCM_INUM (obj);
       break;
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
-      ((long_long *) SCM_CDR (v))[pos] = scm_num2long_long (obj, (char *)SCM_ARG2, s_array_set_x);
+      ((long_long *) SCM_CDR (v))[pos] = scm_num2long_long (obj, (char *)SCM_ARG2, FUNC_NAME);
       break;
 #endif
 
@@ -1329,14 +1312,14 @@ scm_array_set_x (v, obj, args)
 #ifdef SCM_FLOATS
 #ifdef SCM_SINGLES
     case scm_tc7_fvect:
-      ((float *) SCM_CDR (v))[pos] = (float)scm_num2dbl(obj, s_array_set_x); break;
+      ((float *) SCM_CDR (v))[pos] = (float)scm_num2dbl(obj, FUNC_NAME); break;
       break;
 #endif
     case scm_tc7_dvect:
-      ((double *) SCM_CDR (v))[pos] = scm_num2dbl(obj, s_array_set_x); break;
+      ((double *) SCM_CDR (v))[pos] = scm_num2dbl(obj, FUNC_NAME); break;
       break;
     case scm_tc7_cvect:
-      SCM_ASRTGO (SCM_NIMP (obj) && SCM_INEXP (obj), badobj);
+      SCM_ASRTGO (SCM_INEXP (obj), badobj);
       ((double *) SCM_CDR (v))[2 * pos] = SCM_REALPART (obj);
       ((double *) SCM_CDR (v))[2 * pos + 1] = SCM_CPLXP (obj) ? SCM_IMAG (obj) : 0.0;
       break;
@@ -1348,19 +1331,30 @@ scm_array_set_x (v, obj, args)
     }
   return SCM_UNSPECIFIED;
 }
-
-SCM_PROC(s_array_contents, "array-contents", 1, 1, 0, scm_array_contents);
-
-SCM 
-scm_array_contents (ra, strict)
-     SCM ra;
-     SCM strict;
+#undef FUNC_NAME
+
+/* attempts to unroll an array into a one-dimensional array.
+   returns the unrolled array or #f if it can't be done.  */
+  /* if strict is not SCM_UNDEFINED, return #f if returned array
+                    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"
+           "@code{#f}.  All arrays made by @var{make-array} and\n"
+           "@var{make-uniform-array} may be unrolled, some arrays made by\n"
+           "@var{make-shared-array} may not be.\n\n"
+           "If the optional argument @var{strict} is provided, a shared array will\n"
+           "be returned only if its elements are stored internally contiguous in\n"
+           "memory.")
+#define FUNC_NAME s_scm_array_contents
 {
   SCM sra;
   if (SCM_IMP (ra))
     return SCM_BOOL_F;
-  switch SCM_TYP7
-    (ra)
+  switch SCM_TYP7 (ra)
     {
     default:
       return SCM_BOOL_F;
@@ -1375,7 +1369,7 @@ scm_array_contents (ra, strict)
     case scm_tc7_dvect:
     case scm_tc7_cvect:
     case scm_tc7_svect:
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
 #endif
       return ra;
@@ -1410,12 +1404,11 @@ scm_array_contents (ra, strict)
       }
     }
 }
+#undef FUNC_NAME
 
 
 SCM 
-scm_ra2contig (ra, copy)
-     SCM ra;
-     int copy;
+scm_ra2contig (SCM ra, int copy)
 {
   SCM ret;
   long inc = 1;
@@ -1449,14 +1442,22 @@ scm_ra2contig (ra, copy)
 
 
 
-SCM_PROC(s_uniform_array_read_x, "uniform-array-read!", 1, 3, 0, scm_uniform_array_read_x);
-
-SCM 
-scm_uniform_array_read_x (ra, port_or_fd, start, end)
-     SCM ra;
-     SCM port_or_fd;
-     SCM start;
-     SCM end;
+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"
+           "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"
+           "(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"
+           "a specified region of a vector (or linearized array) to be read,\n"
+           "leaving the remainder of the vector unchanged.\n\n"
+           "@code{uniform-array-read!} returns the number of objects read.\n"
+           "@var{port-or-fdes} may be omitted, in which case it defaults to the value\n"
+           "returned by @code{(current-input-port)}.")
+#define FUNC_NAME s_scm_uniform_array_read_x
 {
   SCM cra = SCM_UNDEFINED, v = ra;
   long sz, vlen, ans;
@@ -1469,15 +1470,15 @@ scm_uniform_array_read_x (ra, port_or_fd, start, end)
     port_or_fd = scm_cur_inp;
   else
     SCM_ASSERT (SCM_INUMP (port_or_fd)
-               || (SCM_NIMP (port_or_fd) && SCM_OPINPORTP (port_or_fd)),
-               port_or_fd, SCM_ARG2, s_uniform_array_read_x);
+               || (SCM_OPINPORTP (port_or_fd)),
+               port_or_fd, SCM_ARG2, FUNC_NAME);
   vlen = SCM_LENGTH (v);
 
 loop:
   switch SCM_TYP7 (v)
     {
     default:
-    badarg1:scm_wta (v, (char *) SCM_ARG1, s_uniform_array_read_x);
+    badarg1:SCM_WTA (SCM_ARG1,v);
     case scm_tc7_smob:
       SCM_ASRTGO (SCM_ARRAYP (v), badarg1);
       cra = scm_ra2contig (ra, 0);
@@ -1500,7 +1501,7 @@ loop:
     case scm_tc7_svect:
       sz = sizeof (short);
       break;
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
       sz = sizeof (long_long);
       break;
@@ -1524,18 +1525,18 @@ loop:
   if (!SCM_UNBNDP (start))
     {
       offset = 
-       scm_num2long (start, (char *) SCM_ARG3, s_uniform_array_read_x);
+       SCM_NUM2LONG (3, start);
 
       if (offset < 0 || offset >= cend)
-       scm_out_of_range (s_uniform_array_read_x, start);
+       scm_out_of_range (FUNC_NAME, start);
 
       if (!SCM_UNBNDP (end))
        {
          long tend =
-           scm_num2long (end, (char *) SCM_ARG4, s_uniform_array_read_x);
+           SCM_NUM2LONG (4, end);
       
          if (tend <= offset || tend > cend)
-           scm_out_of_range (s_uniform_array_read_x, end);
+           scm_out_of_range (FUNC_NAME, end);
          cend = tend;
        }
     }
@@ -1568,9 +1569,7 @@ loop:
                {
                  if (remaining % sz != 0)
                    {
-                     scm_misc_error (s_uniform_array_read_x,
-                                     "unexpected EOF",
-                                     SCM_EOL);
+                     SCM_MISC_ERROR ("unexpected EOF", SCM_EOL);
                    }
                  ans -= remaining / sz;
                  break;
@@ -1587,7 +1586,7 @@ loop:
                               SCM_CHARS (v) + (cstart + offset) * sz,
                               (scm_sizet) (sz * (cend - offset))));
       if (ans == -1)
-       scm_syserror (s_uniform_array_read_x);
+       SCM_SYSERROR;
     }
   if (SCM_TYP7 (v) == scm_tc7_bvect)
     ans *= SCM_LONG_BIT;
@@ -1597,15 +1596,21 @@ loop:
 
   return SCM_MAKINUM (ans);
 }
-
-SCM_PROC(s_uniform_array_write, "uniform-array-write", 1, 3, 0, scm_uniform_array_write);
-
-SCM 
-scm_uniform_array_write (v, port_or_fd, start, end)
-     SCM v;
-     SCM port_or_fd;
-     SCM start;
-     SCM end;
+#undef FUNC_NAME
+
+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"
+           "Writes all elements of @var{ura} as binary objects to\n"
+           "@var{port-or-fdes}.\n\n"
+           "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"
+           "@var{port-or-fdes} may be\n"
+           "omitted, in which case it defaults to the value returned by\n"
+           "@code{(current-output-port)}.")
+#define FUNC_NAME s_scm_uniform_array_write
 {
   long sz, vlen, ans;
   long offset = 0;
@@ -1619,15 +1624,15 @@ scm_uniform_array_write (v, port_or_fd, start, end)
     port_or_fd = scm_cur_outp;
   else
     SCM_ASSERT (SCM_INUMP (port_or_fd)
-               || (SCM_NIMP (port_or_fd) && SCM_OPOUTPORTP (port_or_fd)),
-               port_or_fd, SCM_ARG2, s_uniform_array_write);
+               || (SCM_OPOUTPORTP (port_or_fd)),
+               port_or_fd, SCM_ARG2, FUNC_NAME);
   vlen = SCM_LENGTH (v);
 
 loop:
   switch SCM_TYP7 (v)
     {
     default:
-    badarg1:scm_wta (v, (char *) SCM_ARG1, s_uniform_array_write);
+    badarg1:SCM_WTA (1, v);
     case scm_tc7_smob:
       SCM_ASRTGO (SCM_ARRAYP (v), badarg1);
       v = scm_ra2contig (v, 1);
@@ -1650,7 +1655,7 @@ loop:
     case scm_tc7_svect:
       sz = sizeof (short);
       break;
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
       sz = sizeof (long_long);
       break;
@@ -1674,18 +1679,18 @@ loop:
   if (!SCM_UNBNDP (start))
     {
       offset = 
-       scm_num2long (start, (char *) SCM_ARG3, s_uniform_array_write);
+       SCM_NUM2LONG (3, start);
 
       if (offset < 0 || offset >= cend)
-       scm_out_of_range (s_uniform_array_write, start);
+       scm_out_of_range (FUNC_NAME, start);
 
       if (!SCM_UNBNDP (end))
        {
          long tend = 
-           scm_num2long (end, (char *) SCM_ARG4, s_uniform_array_write);
+           SCM_NUM2LONG (4, end);
       
          if (tend <= offset || tend > cend)
-           scm_out_of_range (s_uniform_array_write, end);
+           scm_out_of_range (FUNC_NAME, end);
          cend = tend;
        }
     }
@@ -1703,33 +1708,31 @@ loop:
                                SCM_CHARS (v) + (cstart + offset) * sz,
                                (scm_sizet) (sz * (cend - offset))));
       if (ans == -1)
-       scm_syserror (s_uniform_array_write);
+       SCM_SYSERROR;
     }
   if (SCM_TYP7 (v) == scm_tc7_bvect)
     ans *= SCM_LONG_BIT;
 
   return SCM_MAKINUM (ans);
 }
+#undef FUNC_NAME
 
 
 static char cnt_tab[16] =
 {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
 
-SCM_PROC(s_bit_count, "bit-count", 2, 0, 0, scm_bit_count);
-
-SCM 
-scm_bit_count (item, seq)
-     SCM item;
-     SCM seq;
+SCM_DEFINE (scm_bit_count, "bit-count", 2, 0, 0,
+           (SCM item, SCM seq),
+           "Returns the number occurrences of @var{bool} in @var{bv}.")
+#define FUNC_NAME s_scm_bit_count
 {
   long i;
   register unsigned long cnt = 0, w;
-  SCM_ASSERT (SCM_NIMP (seq), seq, SCM_ARG2, s_bit_count);
-  switch SCM_TYP7
-    (seq)
+  SCM_VALIDATE_INUM (2,seq);
+  switch SCM_TYP7 (seq)
     {
     default:
-      scm_wta (seq, (char *) SCM_ARG2, s_bit_count);
+      SCM_WTA (2,seq);
     case scm_tc7_bvect:
       if (0 == SCM_LENGTH (seq))
        return SCM_INUM0;
@@ -1750,29 +1753,28 @@ scm_bit_count (item, seq)
        }
     }
 }
+#undef FUNC_NAME
 
 
-SCM_PROC(s_bit_position, "bit-position", 3, 0, 0, scm_bit_position);
-
-SCM 
-scm_bit_position (item, v, k)
-     SCM item;
-     SCM v;
-     SCM k;
+SCM_DEFINE (scm_bit_position, "bit-position", 3, 0, 0,
+           (SCM item, SCM v, SCM k),
+           "Returns the minimum index of an occurrence of @var{bool} in @var{bv}\n"
+           "which is at least @var{k}.  If no @var{bool} occurs within the specified\n"
+           "range @code{#f} is returned.")
+#define FUNC_NAME s_scm_bit_position
 {
-  long i, lenw, xbits, pos = SCM_INUM (k);
+  long i, lenw, xbits, pos;
   register unsigned long w;
-  SCM_ASSERT (SCM_NIMP (v), v, SCM_ARG2, s_bit_position);
-  SCM_ASSERT (SCM_INUMP (k), k, SCM_ARG3, s_bit_position);
+  SCM_VALIDATE_NIM (2,v);
+  SCM_VALIDATE_INUM_COPY (3,k,pos);
   SCM_ASSERT ((pos <= SCM_LENGTH (v)) && (pos >= 0),
-         k, SCM_OUTOFRANGE, s_bit_position);
+         k, SCM_OUTOFRANGE, FUNC_NAME);
   if (pos == SCM_LENGTH (v))
     return SCM_BOOL_F;
-  switch SCM_TYP7
-    (v)
+  switch SCM_TYP7 (v)
     {
     default:
-      scm_wta (v, (char *) SCM_ARG2, s_bit_position);
+      SCM_WTA (2,v);
     case scm_tc7_bvect:
       if (0 == SCM_LENGTH (v))
        return SCM_MAKINUM (-1L);
@@ -1819,48 +1821,50 @@ scm_bit_position (item, v, k)
       return SCM_BOOL_F;
     }
 }
-
-
-SCM_PROC(s_bit_set_star_x, "bit-set*!", 3, 0, 0, scm_bit_set_star_x);
-
-SCM 
-scm_bit_set_star_x (v, kv, obj)
-     SCM v;
-     SCM kv;
-     SCM obj;
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_bit_set_star_x, "bit-set*!", 3, 0, 0,
+           (SCM v, SCM kv, SCM obj),
+           "If uve is a bit-vector @var{bv} and uve must be of the same length.  If\n"
+           "@var{bool} is @code{#t}, uve is OR'ed into @var{bv}; If @var{bool} is @code{#f}, the\n"
+           "inversion of uve is AND'ed into @var{bv}.\n\n"
+           "If uve is a unsigned integer vector all the elements of uve must be\n"
+           "between 0 and the @code{LENGTH} of @var{bv}.  The bits of @var{bv}\n"
+           "corresponding to the indexes in uve are set to @var{bool}.\n\n"
+           "The return value is unspecified.")
+#define FUNC_NAME s_scm_bit_set_star_x
 {
   register long i, k, vlen;
   SCM_ASRTGO (SCM_NIMP (v), badarg1);
   SCM_ASRTGO (SCM_NIMP (kv), badarg2);
-  switch SCM_TYP7
-    (kv)
+  switch SCM_TYP7 (kv)
     {
     default:
-    badarg2:scm_wta (kv, (char *) SCM_ARG2, s_bit_set_star_x);
+    badarg2:SCM_WTA (2,kv);
     case scm_tc7_uvect:
-      switch SCM_TYP7
-       (v)
+      switch SCM_TYP7 (v)
        {
        default:
-       badarg1:scm_wta (v, (char *) SCM_ARG1, s_bit_set_star_x);
+       badarg1:SCM_WTA (1,v);
        case scm_tc7_bvect:
          vlen = SCM_LENGTH (v);
          if (SCM_BOOL_F == obj)
            for (i = SCM_LENGTH (kv); i;)
              {
                k = SCM_VELTS (kv)[--i];
-               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, s_bit_set_star_x);
+               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, FUNC_NAME);
                SCM_VELTS (v)[k / SCM_LONG_BIT] &= ~(1L << (k % SCM_LONG_BIT));
              }
          else if (SCM_BOOL_T == obj)
            for (i = SCM_LENGTH (kv); i;)
              {
                k = SCM_VELTS (kv)[--i];
-               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, s_bit_set_star_x);
+               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, FUNC_NAME);
                SCM_VELTS (v)[k / SCM_LONG_BIT] |= (1L << (k % SCM_LONG_BIT));
              }
          else
-         badarg3:scm_wta (obj, (char *) SCM_ARG3, s_bit_set_star_x);
+         badarg3:SCM_WTA (3,obj);
        }
       break;
     case scm_tc7_bvect:
@@ -1877,38 +1881,39 @@ scm_bit_set_star_x (v, kv, obj)
     }
   return SCM_UNSPECIFIED;
 }
+#undef FUNC_NAME
 
 
-SCM_PROC(s_bit_count_star, "bit-count*", 3, 0, 0, scm_bit_count_star);
-
-SCM 
-scm_bit_count_star (v, kv, obj)
-     SCM v;
-     SCM kv;
-     SCM obj;
+SCM_DEFINE (scm_bit_count_star, "bit-count*", 3, 0, 0,
+           (SCM v, SCM kv, SCM obj),
+           "Returns\n"
+           "@example\n"
+           "(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t).\n"
+           "@end example\n"
+           "@var{bv} is not modified.")
+#define FUNC_NAME s_scm_bit_count_star
 {
   register long i, vlen, count = 0;
   register unsigned long k;
   SCM_ASRTGO (SCM_NIMP (v), badarg1);
   SCM_ASRTGO (SCM_NIMP (kv), badarg2);
-  switch SCM_TYP7
-    (kv)
+  switch SCM_TYP7 (kv)
     {
     default:
-    badarg2:scm_wta (kv, (char *) SCM_ARG2, s_bit_count_star);
+    badarg2:SCM_WTA (2,kv);
     case scm_tc7_uvect:
       switch SCM_TYP7
        (v)
        {
        default:
-       badarg1:scm_wta (v, (char *) SCM_ARG1, s_bit_count_star);
+       badarg1:SCM_WTA (1,v);
        case scm_tc7_bvect:
          vlen = SCM_LENGTH (v);
          if (SCM_BOOL_F == obj)
            for (i = SCM_LENGTH (kv); i;)
              {
                k = SCM_VELTS (kv)[--i];
-               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, s_bit_count_star);
+               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, FUNC_NAME);
                if (!(SCM_VELTS (v)[k / SCM_LONG_BIT] & (1L << (k % SCM_LONG_BIT))))
                  count++;
              }
@@ -1916,12 +1921,12 @@ scm_bit_count_star (v, kv, obj)
            for (i = SCM_LENGTH (kv); i;)
              {
                k = SCM_VELTS (kv)[--i];
-               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, s_bit_count_star);
+               SCM_ASSERT ((k < vlen), SCM_MAKINUM (k), SCM_OUTOFRANGE, FUNC_NAME);
                if (SCM_VELTS (v)[k / SCM_LONG_BIT] & (1L << (k % SCM_LONG_BIT)))
                  count++;
              }
          else
-         badarg3:scm_wta (obj, (char *) SCM_ARG3, s_bit_count_star);
+         badarg3:SCM_WTA (3,obj);
        }
       break;
     case scm_tc7_bvect:
@@ -1944,13 +1949,13 @@ scm_bit_count_star (v, kv, obj)
     }
   return SCM_MAKINUM (count);
 }
+#undef FUNC_NAME
 
 
-SCM_PROC(s_bit_invert_x, "bit-invert!", 1, 0, 0, scm_bit_invert_x);
-
-SCM 
-scm_bit_invert_x (v)
-     SCM v;
+SCM_DEFINE (scm_bit_invert_x, "bit-invert!", 1, 0, 0, 
+           (SCM v),
+           "Modifies @var{bv} by replacing each element with its negation.")
+#define FUNC_NAME s_scm_bit_invert_x
 {
   register long k;
   SCM_ASRTGO (SCM_NIMP (v), badarg1);
@@ -1963,16 +1968,15 @@ scm_bit_invert_x (v)
        SCM_VELTS (v)[k] = ~SCM_VELTS (v)[k];
       break;
     default:
-    badarg1:scm_wta (v, (char *) SCM_ARG1, s_bit_invert_x);
+    badarg1:SCM_WTA (1,v);
     }
   return SCM_UNSPECIFIED;
 }
+#undef FUNC_NAME
 
 
 SCM 
-scm_istr2bve (str, len)
-     char *str;
-     long len;
+scm_istr2bve (char *str, long len)
 {
   SCM v = scm_make_uve (len, SCM_BOOL_T);
   long *data = (long *) SCM_VELTS (v);
@@ -2002,13 +2006,8 @@ scm_istr2bve (str, len)
 
 
 
-static SCM ra2l SCM_P ((SCM ra, scm_sizet base, scm_sizet k));
-
 static SCM 
-ra2l (ra, base, k)
-     SCM ra;
-     scm_sizet base;
-     scm_sizet k;
+ra2l (SCM ra,scm_sizet base,scm_sizet k)
 {
   register SCM res = SCM_EOL;
   register long inc = SCM_ARRAY_DIMS (ra)[k].inc;
@@ -2036,11 +2035,10 @@ ra2l (ra, base, k)
 }
 
 
-SCM_PROC(s_array_to_list, "array->list", 1, 0, 0, scm_array_to_list);
-
-SCM 
-scm_array_to_list (v)
-     SCM v;
+SCM_DEFINE (scm_array_to_list, "array->list", 1, 0, 0, 
+           (SCM v),
+           "Returns a list consisting of all the elements, in order, of @var{array}.")
+#define FUNC_NAME s_scm_array_to_list
 {
   SCM res = SCM_EOL;
   register long k;
@@ -2049,7 +2047,7 @@ scm_array_to_list (v)
     (v)
     {
     default:
-    badarg1:scm_wta (v, (char *) SCM_ARG1, s_array_to_list);
+    badarg1:SCM_WTA (1,v);
     case scm_tc7_smob:
       SCM_ASRTGO (SCM_ARRAYP (v), badarg1);
       return ra2l (v, SCM_ARRAY_BASE (v), 0);
@@ -2064,9 +2062,9 @@ scm_array_to_list (v)
        register unsigned long mask;
        for (k = (SCM_LENGTH (v) - 1) / SCM_LONG_BIT; k > 0; k--)
          for (mask = 1UL << (SCM_LONG_BIT - 1); mask; mask >>= 1)
-           res = scm_cons (((long *) data)[k] & mask ? SCM_BOOL_T : SCM_BOOL_F, res);
+           res = scm_cons (SCM_BOOL(((long *) data)[k] & mask), res);
        for (mask = 1L << ((SCM_LENGTH (v) % SCM_LONG_BIT) - 1); mask; mask >>= 1)
-         res = scm_cons (((long *) data)[k] & mask ? SCM_BOOL_T : SCM_BOOL_F, res);
+         res = scm_cons (SCM_BOOL(((long *) data)[k] & mask), res);
        return res;
       }
 # ifdef SCM_INUMS_ONLY
@@ -2099,7 +2097,7 @@ scm_array_to_list (v)
        res = scm_cons(SCM_MAKINUM (data[k]), res);
       return res;
     }
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect: {
       long_long *data;
       data = (long_long *)SCM_VELTS(v);
@@ -2137,36 +2135,37 @@ scm_array_to_list (v)
 #endif /*SCM_FLOATS*/
     }
 }
+#undef FUNC_NAME
 
 
 static char s_bad_ralst[] = "Bad scm_array contents list";
 
-static int l2ra SCM_P ((SCM lst, SCM ra, scm_sizet base, scm_sizet k));
+static int l2ra(SCM lst, SCM ra, scm_sizet base, scm_sizet k);
 
-SCM_PROC(s_list_to_uniform_array, "list->uniform-array", 3, 0, 0, scm_list_to_uniform_array);
-
-SCM 
-scm_list_to_uniform_array (ndim, prot, lst)
-     SCM ndim;
-     SCM prot;
-     SCM lst;
+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"
+           "Returns a uniform array of the type indicated by prototype @var{prot}\n"
+           "with elements the same as those of @var{lst}.  Elements must be of the\n"
+           "appropriate type, no coercions are done.")
+#define FUNC_NAME s_scm_list_to_uniform_array
 {
   SCM shp = SCM_EOL;
   SCM row = lst;
   SCM ra;
   scm_sizet k;
   long n;
-  SCM_ASSERT (SCM_INUMP (ndim), ndim, SCM_ARG1, s_list_to_uniform_array);
-  k = SCM_INUM (ndim);
+  SCM_VALIDATE_INUM_COPY (1,ndim,k);
   while (k--)
     {
       n = scm_ilength (row);
-      SCM_ASSERT (n >= 0, lst, SCM_ARG3, s_list_to_uniform_array);
+      SCM_ASSERT (n >= 0, lst, SCM_ARG3, FUNC_NAME);
       shp = scm_cons (SCM_MAKINUM (n), shp);
       if (SCM_NIMP (row))
        row = SCM_CAR (row);
     }
-  ra = scm_dimensions_to_uniform_array (scm_reverse (shp), prot, SCM_EOL);
+  ra = scm_dimensions_to_uniform_array (scm_reverse (shp), prot,
+                                       SCM_UNDEFINED);
   if (SCM_NULLP (shp))
 
     {
@@ -2183,16 +2182,13 @@ scm_list_to_uniform_array (ndim, prot, lst)
   if (l2ra (lst, ra, SCM_ARRAY_BASE (ra), 0))
     return ra;
   else
-  badlst:scm_wta (lst, s_bad_ralst, s_list_to_uniform_array);
+    badlst:scm_wta (lst, s_bad_ralst, FUNC_NAME);
   return SCM_BOOL_F;
 }
+#undef FUNC_NAME
 
 static int 
-l2ra (lst, ra, base, k)
-     SCM lst;
-     SCM ra;
-     scm_sizet base;
-     scm_sizet k;
+l2ra (SCM lst, SCM ra, scm_sizet base, scm_sizet k)
 {
   register long inc = SCM_ARRAY_DIMS (ra)[k].inc;
   register long n = (1 + SCM_ARRAY_DIMS (ra)[k].ubnd - SCM_ARRAY_DIMS (ra)[k].lbnd);
@@ -2229,22 +2225,14 @@ l2ra (lst, ra, base, k)
 }
 
 
-static void rapr1 SCM_P ((SCM ra, scm_sizet j, scm_sizet k, SCM port, scm_print_state *pstate));
-
 static void 
-rapr1 (ra, j, k, port, pstate)
-     SCM ra;
-     scm_sizet j;
-     scm_sizet k;
-     SCM port;
-     scm_print_state *pstate;
+rapr1 (SCM ra,scm_sizet j,scm_sizet k,SCM port,scm_print_state *pstate)
 {
   long inc = 1;
   long n = SCM_LENGTH (ra);
   int enclosed = 0;
 tail:
-  switch SCM_TYP7
-    (ra)
+  switch SCM_TYP7 (ra)
     {
     case scm_tc7_smob:
       if (enclosed++)
@@ -2290,6 +2278,7 @@ tail:
       ra = SCM_ARRAY_V (ra);
       goto tail;
     default:
+      /* scm_tc7_bvect and scm_tc7_llvect only?  */
       if (n-- > 0)
        scm_iprin1 (scm_uniform_vector_ref (ra, SCM_MAKINUM (j)), port, pstate);
       for (j += inc; n-- > 0; j += inc)
@@ -2300,12 +2289,12 @@ tail:
       break;
     case scm_tc7_string:
       if (n-- > 0)
-       scm_iprin1 (SCM_MAKICHR (SCM_UCHARS (ra)[j]), port, pstate);
+       scm_iprin1 (SCM_MAKE_CHAR (SCM_UCHARS (ra)[j]), port, pstate);
       if (SCM_WRITINGP (pstate))
        for (j += inc; n-- > 0; j += inc)
          {
            scm_putc (' ', port);
-           scm_iprin1 (SCM_MAKICHR (SCM_UCHARS (ra)[j]), port, pstate);
+           scm_iprin1 (SCM_MAKE_CHAR (SCM_UCHARS (ra)[j]), port, pstate);
          }
       else
        for (j += inc; n-- > 0; j += inc)
@@ -2322,6 +2311,22 @@ tail:
       break;
 
     case scm_tc7_uvect:
+      {
+       char str[11];
+
+       if (n-- > 0)
+         {
+           /* intprint can't handle >= 2^31.  */
+           sprintf (str, "%lu", (unsigned long) SCM_VELTS (ra)[j]);
+           scm_puts (str, port);
+         }
+       for (j += inc; n-- > 0; j += inc)
+         {
+           scm_putc (' ', port);
+           sprintf (str, "%lu", (unsigned long) SCM_VELTS (ra)[j]);
+           scm_puts (str, port);
+         }
+      }
     case scm_tc7_ivect:
       if (n-- > 0)
        scm_intprint (SCM_VELTS (ra)[j], 10, port);
@@ -2396,17 +2401,13 @@ tail:
 
 
 int 
-scm_raprin1 (exp, port, pstate)
-     SCM exp;
-     SCM port;
-     scm_print_state *pstate;
+scm_raprin1 (SCM exp, SCM port, scm_print_state *pstate)
 {
   SCM v = exp;
   scm_sizet base = 0;
   scm_putc ('#', port);
 tail:
-  switch SCM_TYP7
-    (v)
+  switch SCM_TYP7 (v)
     {
     case scm_tc7_smob:
       {
@@ -2471,9 +2472,9 @@ tail:
     case scm_tc7_svect:
       scm_putc ('h', port);
       break;
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
-      scm_puts ("long_long", port);
+      scm_putc ('l', port);
       break;
 #endif
 #ifdef SCM_FLOATS
@@ -2496,11 +2497,12 @@ tail:
   return 1;
 }
 
-SCM_PROC(s_array_prototype, "array-prototype", 1, 0, 0, scm_array_prototype);
-
-SCM 
-scm_array_prototype (ra)
-     SCM ra;
+SCM_DEFINE (scm_array_prototype, "array-prototype", 1, 0, 0, 
+           (SCM ra),
+           "Returns an object that would produce an array of the same type as\n"
+           "@var{array}, if used as the @var{prototype} for\n"
+           "@code{make-uniform-array}.")
+#define FUNC_NAME s_scm_array_prototype
 {
   int enclosed = 0;
   SCM_ASRTGO (SCM_NIMP (ra), badarg);
@@ -2509,7 +2511,7 @@ loop:
     (ra)
     {
     default:
-    badarg:scm_wta (ra, (char *) SCM_ARG1, s_array_prototype);
+    badarg:SCM_WTA (1,ra);
     case scm_tc7_smob:
       SCM_ASRTGO (SCM_ARRAYP (ra), badarg);
       if (enclosed++)
@@ -2522,16 +2524,16 @@ loop:
     case scm_tc7_bvect:
       return SCM_BOOL_T;
     case scm_tc7_string:
-      return SCM_MAKICHR ('a');
+      return SCM_MAKE_CHAR ('a');
     case scm_tc7_byvect:
-      return SCM_MAKICHR ('\0');
+      return SCM_MAKE_CHAR ('\0');
     case scm_tc7_uvect:
       return SCM_MAKINUM (1L);
     case scm_tc7_ivect:
       return SCM_MAKINUM (-1L);
     case scm_tc7_svect:
       return SCM_CDR (scm_intern ("s", 1));
-#ifdef LONGLONGS
+#ifdef HAVE_LONG_LONGS
     case scm_tc7_llvect:
       return SCM_CDR (scm_intern ("l", 1));
 #endif
@@ -2547,30 +2549,23 @@ loop:
 #endif
     }
 }
+#undef FUNC_NAME
 
 
-static SCM markra SCM_P ((SCM ptr));
-
 static SCM
-markra (ptr)
-     SCM ptr;
+markra (SCM ptr)
 {
   return SCM_ARRAY_V (ptr);
 }
 
 
-static scm_sizet freera SCM_P ((SCM ptr));
-
 static scm_sizet
-freera (ptr)
-     SCM ptr;
+freera (SCM ptr)
 {
   scm_must_free (SCM_CHARS (ptr));
   return sizeof (scm_array) + SCM_ARRAY_NDIM (ptr) * sizeof (scm_array_dim);
 }
 
-/* This must be done after scm_init_scl() */
-
 void
 scm_init_unif ()
 {
@@ -2582,33 +2577,3 @@ scm_init_unif ()
   scm_add_feature ("array");
 #include "unif.x"
 }
-
-#else /* ARRAYS */
-
-
-int 
-scm_raprin1 (exp, port, pstate)
-     SCM exp;
-     SCM port;
-     scm_print_state *pstate;
-{
-  return 0;
-}
-
-
-SCM 
-scm_istr2bve (str, len)
-     char *str;
-     long len;
-{
-  return SCM_BOOL_F;
-}
-
-void 
-scm_init_unif ()
-{
-#include "unif.x"
-  scm_make_subr (s_resizuve, scm_tc7_subr_2, scm_vector_set_length_x);
-}
-
-#endif /* ARRAYS */