help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Qs on obarrays


From: Drew Adams
Subject: Qs on obarrays
Date: Tue, 11 Oct 2005 17:52:57 -0700

The Elisp manual hints that you can create and fill an obarray like this:

(let ((my-obarray (make-vector 7 0)))
  (dolist (name my-names) (intern name my-obarray))
  (completing-read "XXX: " my-obarray))

That works. And this also works:

(let ((my-obarray (make-vector 7 0)))
  (dolist (name my-names) (intern name my-obarray))
  (all-completions "" my-obarray))

However, this does not seem to work for me:

(let ((my-obarray (make-vector 7 0)))
  (dolist (name my-names) (intern name my-obarray))
  (all-completions "" my-obarray 'commandp))

Even if all of my-names are symbol-names of commands, this always returns
nil. Any idea why?

Also, the obarray length must be supplied to make-vector. Anyone know a
heuristic for a good vector length to use when you expect a certain number
of symbols? I notice that the length of standard variable `obarray's value
is 1511 (prime, presumably). If I expect on the order of N symbols, what is
a good length to use? Or is there no simple formula? If not, anyone know a
good length for, say, 100 symbols?

(BTW - The obarray vector itself does not show all of the interned symbols,
when printed. I assume this is because if there are multiple symbols in the
same bucket only one of them can be printed when the vector is shown.)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]