Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: ding@gnus.org
Subject: Re: Symbol's function definition is void: remove-if-not
Date: Mon, 04 Oct 2010 16:15:56 +0900	[thread overview]
Message-ID: <b4mk4lyctsj.fsf@jpl.org> (raw)
In-Reply-To: <87eic6hb2h.fsf@lifelogs.com>

Ted Zlatanov wrote:
[...]
> Can you use `gnus-remove-if' with the predicate inverted?

It can be used, if the type of a sequence is `list'.  For a non-
list sequence, we can convert it to a list as the function `coerce'
does (see cl-extra.el).  Though the type of a modified sequence has
to be changed again into that of the original (if needed).  However,
it may be hard to make it work for a hash table.  So is the genuine
`remove-if-not'!

> It looks like `remove-if-not' is used in several places actually:

> gnus-art.el:         (remove-if-not pred (mailcap-mime-types))
> gnus-group.el:                          (remove-if-not 'symbolp collection)))
> gnus-score.el:                                            (remove-if-not
> gnus-sum.el:             (remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb)
> gnus-sum.el:             prom (remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb)

The use of `remove-if-not' in gnus-sum.el is a wrong approach since
it doesn't necessarily recognize all the group names in
`gnus-active-hashtb'.  That looks like a normal vector of which
the length is 4096, however it can hold more than 4096 group names
and `remove-if-not' cannot access all of them.  For instance:

;; Make a hash table of which the length is 1.
(let ((hashtable (make-vector 1 0)))
  (length hashtable))
 => 1

;; We can put more than 1 symbol to it,
;; but it still looks like a vector of which the size is 1.
(let ((hashtable (make-vector 1 0)))
  (intern "A" hashtable)
  (intern "B" hashtable)
  (intern "C" hashtable)
  (intern "D" hashtable)
  (list (length hashtable) hashtable))
 => (1 [D])

;; It actually holds four symbols.
(let ((hashtable (make-vector 1 0)))
  (intern "A" hashtable)
  (intern "B" hashtable)
  (intern "C" hashtable)
  (intern "D" hashtable)
  (let (rest)
    (mapatoms (lambda (symbol) (push symbol rest)) hashtable)
    rest))
 => (A B C D)

;; `remove-if-not' recognize the hash table in question as [D],
;; therefore:
(let ((hashtable (make-vector 1 0)))
  (intern "A" hashtable)
  (intern "B" hashtable)
  (intern "C" hashtable)
  (intern "D" hashtable)
  (remove-if-not (lambda (symbol) (string-lessp symbol 'C)) hashtable))
 => []

;; But the expected result of it is like the following, isn't it?
(let ((sequence [A B C D]))
  (remove-if-not (lambda (symbol) (string-lessp symbol 'C)) sequence))
 => [A B]



  reply	other threads:[~2010-10-04  7:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-03 15:13 Stephen Berman
2010-10-03 15:23 ` Julien Danjou
2010-10-04  3:49   ` Ted Zlatanov
2010-10-04  7:15     ` Katsumi Yamaoka [this message]
2010-10-04 16:36       ` Ted Zlatanov
2010-10-04 16:42         ` Lars Magne Ingebrigtsen
2010-10-05  7:32         ` Katsumi Yamaoka
2010-10-08 16:35           ` Ted Zlatanov
2010-10-04 16:30     ` Ted Zlatanov
2010-10-04 16:42       ` Lars Magne Ingebrigtsen
2010-10-08 16:36         ` Ted Zlatanov

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=b4mk4lyctsj.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=ding@gnus.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).