]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow any non-nil value to count as true in bool-vector.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 May 2014 19:19:05 +0000 (12:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 May 2014 19:19:05 +0000 (12:19 -0700)
Likewise for xd_signature in dbusbind.c.
This is more consistent with the usual practice in Emacs, which is
that any non-nil value counts as true.
* doc/lispref/sequences.texi (Bool-Vectors): Coalesce discussion of how to
print them.  bool-vector's args need not be t or nil.
* src/alloc.c (Fbool_vector): Don't require args to be t or nil.
* src/dbusbind.c (xd_signature): Likewise, for booleans.
* src/data.c, lisp.h (Qbooleanp):
* src/lisp.h (CHECK_BOOLEAN): Remove.  All uses removed.

doc/lispref/ChangeLog
doc/lispref/sequences.texi
src/ChangeLog
src/alloc.c
src/data.c
src/dbusbind.c
src/lisp.h

index 9614b89f66eacbee1ec218b9f20be8564ac1e5f4..6de8adf1215694a7f1b97927dc3e74927ce3f7bf 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Allow any non-nil value to count as true in bool-vector.
+       * sequences.texi (Bool-Vectors): Coalesce discussion of how to
+       print them.  bool-vector's args need not be t or nil.
+
 2014-05-19  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * sequences.texi (Bool-vectors): Mention bool-vector.
index 1f7cd435cf6e2b1f61eac0c67043775616bdd44b..68467830a670f26c72b404d73f285108232755d4 100644 (file)
@@ -811,7 +811,7 @@ value into an element of the bool-vector, the effect is to store
 and the length cannot be changed once the bool-vector is created.
 Bool-vectors are constants when evaluated.
 
-  There are three special functions for working with bool-vectors; aside
+  Several functions work specifically with bool-vectors; aside
 from that, you manipulate them with same functions used for other kinds
 of arrays.
 
@@ -822,28 +822,7 @@ each one initialized to @var{initial}.
 
 @defun bool-vector &rest objects
 This function creates and returns a bool-vector whose elements are the
-arguments, @var{objects}, each of them should be either @code{t} or @code{nil}.
-Note that the printed form represents up to 8 boolean values as a single
-character:
-
-@example
-@group
-(bool-vector t nil t nil)
-     @result{} #&4"^E"
-(bool-vector)
-     @result{} #&0""
-@end group
-@end example
-
-If you want to print a bool-vector in a way similar to other vectors,
-you can use @code{vconcat} function:
-
-@example
-@group
-(vconcat (bool-vector nil t nil t))
-     @result{} [nil t nil t]
-@end group
-@end example
+arguments, @var{objects}.
 @end defun
 
 @defun bool-vector-p object
@@ -899,6 +878,27 @@ or @code{nil}, and @var{i} is an index into @code{a}.
 Return the number of elements that are @code{t} in bool vector @var{a}.
 @end defun
 
+  The printed form represents up to 8 boolean values as a single
+character:
+
+@example
+@group
+(bool-vector t nil t nil)
+     @result{} #&4"^E"
+(bool-vector)
+     @result{} #&0""
+@end group
+@end example
+
+You can use @code{vconcat} to print a bool-vector like other vectors:
+
+@example
+@group
+(vconcat (bool-vector nil t nil t))
+     @result{} [nil t nil t]
+@end group
+@end example
+
   Here is another example of creating, examining, and updating a
 bool-vector:
 
index 751076f4b8e5f0511609a4a4f77b4ca2a2ab2946..5cea85350b7016c8eb0992151efb357f3f942cff 100644 (file)
@@ -1,3 +1,14 @@
+2014-05-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Allow any non-nil value to count as true in bool-vector.
+       Likewise for xd_signature in dbusbind.c.
+       This is more consistent with the usual practice in Emacs, which is
+       that any non-nil value counts as true.
+       * alloc.c (Fbool_vector): Don't require args to be t or nil.
+       * dbusbind.c (xd_signature): Likewise, for booleans.
+       * data.c, lisp.h (Qbooleanp):
+       * lisp.h (CHECK_BOOLEAN): Remove.  All uses removed.
+
 2014-05-19  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * lisp.h (CHECK_BOOLEAN): New function.
index e808c3d4bf336847641f94318879e3a170cdfe7a..1dc33b72520aabe1a34093162cae570a3ec56164 100644 (file)
@@ -2177,16 +2177,12 @@ LENGTH must be a number.  INIT matters only in whether it is t or nil.  */)
 DEFUN ("bool-vector", Fbool_vector, Sbool_vector, 0, MANY, 0,
        doc: /* Return a new bool-vector with specified arguments as elements.
 Any number of arguments, even zero arguments, are allowed.
-Each argument should be either t or nil.
 usage: (bool-vector &rest OBJECTS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
   ptrdiff_t i;
   Lisp_Object vector;
 
-  for (i = 0; i < nargs; i++)
-    CHECK_BOOLEAN (args[i]);
-
   vector = make_uninit_bool_vector (nargs);
   for (i = 0; i < nargs; i++)
     bool_vector_set (vector, i, !NILP (args[i]));
index 4061311e7ba88e855ecc15b040cf4009d79355c0..bf863aaed79a903f12cb555725fec8cb85e86c33 100644 (file)
@@ -54,7 +54,7 @@ Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive;
 Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only;
 Lisp_Object Qtext_read_only;
 
-Lisp_Object Qintegerp, Qwholenump, Qsymbolp, Qlistp, Qconsp, Qbooleanp;
+Lisp_Object Qintegerp, Qwholenump, Qsymbolp, Qlistp, Qconsp;
 static Lisp_Object Qnatnump;
 Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp;
 Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp;
@@ -3442,7 +3442,6 @@ syms_of_data (void)
 
   DEFSYM (Qlistp, "listp");
   DEFSYM (Qconsp, "consp");
-  DEFSYM (Qbooleanp, "booleanp");
   DEFSYM (Qsymbolp, "symbolp");
   DEFSYM (Qkeywordp, "keywordp");
   DEFSYM (Qintegerp, "integerp");
index 768e0a11b1c0dc090db79ff166b9837c6396bbc5..9e15d7f199a8b0272936d4b48d66fbbc6ed1077b 100644 (file)
@@ -387,7 +387,8 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
       break;
 
     case DBUS_TYPE_BOOLEAN:
-      CHECK_BOOLEAN (object);
+      /* Every Emacs Lisp object serves as a boolean, so there's nothing
+        to check.  */
       sprintf (signature, "%c", dtype);
       break;
 
index 88ccaec40700965fd40d87ce649d13159d5aa6db..67b26ef91c7a13f46f45aeaba1dbf74a19e30716 100644 (file)
@@ -796,7 +796,7 @@ extern int char_table_translate (Lisp_Object, int);
 /* Defined in data.c.  */
 extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p;
 extern Lisp_Object Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp, Qnil;
-extern Lisp_Object Qnumberp, Qstringp, Qsymbolp, Qt, Qvectorp, Qbooleanp;
+extern Lisp_Object Qnumberp, Qstringp, Qsymbolp, Qt, Qvectorp;
 extern Lisp_Object Qbool_vector_p;
 extern Lisp_Object Qvector_or_char_table_p, Qwholenump;
 extern Lisp_Object Qwindow;
@@ -2510,11 +2510,6 @@ CHECK_CONS (Lisp_Object x)
   CHECK_TYPE (CONSP (x), Qconsp, x);
 }
 INLINE void
-CHECK_BOOLEAN (Lisp_Object x)
-{
-  CHECK_TYPE (EQ (x, Qt) || EQ (x, Qnil), Qbooleanp, x);
-}
-INLINE void
 CHECK_VECTOR (Lisp_Object x)
 {
   CHECK_TYPE (VECTORP (x), Qvectorp, x);