From: Paul Eggert <eggert@cs.ucla.edu>
To: dancol@dancol.org, 15912@debbugs.gnu.org
Subject: bug#15912: Improve API of recently-added bool vector functions.
Date: Mon, 18 Nov 2013 11:44:56 -0800 [thread overview]
Message-ID: <528A6E38.6020502@cs.ucla.edu> (raw)
In-Reply-To: <528926D9.3090205@dancol.org>
On 11/17/2013 12:28 PM, Daniel Colascione wrote:
> the revised patch is fine
Thanks, installed as trunk bzr 15912.
I noticed another problem. bool-vector-subset-p is backwards
of what I'd normally expect, i.e., (bool-vector-subsetp A B)
tests whether B is a subset of A, not whether A is a subset of B.
Another thing: it might be more intuitive if this function returns
a boolean. Also, this function isn't documented. One possibility
is to remove the function if nobody's using it; another possibility
would be the following patch.
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2013-11-18 19:31:05 +0000
+++ src/ChangeLog 2013-11-18 19:43:41 +0000
@@ -1,5 +1,10 @@
2013-11-18 Paul Eggert <eggert@cs.ucla.edu>
+ bool-vector-subsetp is now the normal direction and returns a boolean.
+ * data.c (bool_vector_binop_driver): When implementing subsetp,
+ test whether the first argument is a subset of the second one,
+ and return t or nil. Tune.
+
* data.c (bool_vector_binop_driver): Rename locals for sanity's sake.
The old names predated the API change that put destination at end.
=== modified file 'src/data.c'
--- src/data.c 2013-11-18 19:31:05 +0000
+++ src/data.c 2013-11-18 19:43:41 +0000
@@ -3060,6 +3060,12 @@
break;
case bool_vector_subsetp:
+ eassert (bdata == destdata);
+ while (! (adata[i] & ~bdata[i]))
+ if (! (++i < nr_words))
+ return Qt;
+ return Qnil;
+
case bool_vector_union:
while (destdata[i] == (adata[i] | bdata[i]))
if (! (++i < nr_words))
@@ -3088,9 +3094,6 @@
while (++i < nr_words);
break;
- case bool_vector_subsetp:
- break;
-
case bool_vector_union:
do
destdata[i] = adata[i] | bdata[i];
@@ -3108,6 +3111,9 @@
destdata[i] = adata[i] &~ bdata[i];
while (++i < nr_words);
break;
+
+ default:
+ eassume (0);
}
return dest;
@@ -3234,11 +3240,11 @@
DEFUN ("bool-vector-subsetp", Fbool_vector_subsetp,
Sbool_vector_subsetp, 2, 2, 0,
- doc: )
+ doc: /* Return t if every t value in A is also t in B, nil otherwise.
+A and B must be bool vectors of the same length. */)
(Lisp_Object a, Lisp_Object b)
{
- /* Like bool_vector_union, but doesn't modify b. */
- return bool_vector_binop_driver (b, a, b, bool_vector_subsetp);
+ return bool_vector_binop_driver (a, b, b, bool_vector_subsetp);
}
DEFUN ("bool-vector-not", Fbool_vector_not,
next prev parent reply other threads:[~2013-11-18 19:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-17 8:39 bug#15912: Improve API of recently-added bool vector functions Paul Eggert
2013-11-17 11:07 ` Daniel Colascione
2013-11-17 20:17 ` Paul Eggert
2013-11-17 20:28 ` Daniel Colascione
2013-11-18 19:44 ` Paul Eggert [this message]
2013-11-25 23:26 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=528A6E38.6020502@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=15912@debbugs.gnu.org \
--cc=dancol@dancol.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.