GNU bug report logs -
#58338
29.0.50; mapatoms called on more elements than in obarray?
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Thu, 6 Oct 2022 16:17:02 UTC
Severity: normal
Found in version 29.0.50
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> Philip Kaludercic <philipk <at> posteo.net> writes:
>
>>>From reading the docstring of `mapatoms', I would assume that this would
>> evaluate to t:
>>
>> (let ((i 0))
>> (mapatoms (lambda (_) (setq i (1+ i))) obarray)
>> (= (length obarray) i))
>>
>> But instead on my system I get (length obarray) ↝ 15121 and and i ↝
>> 78050, which is are at a ratio of 5.16169565505.
>
> obarray is a hash table. with each array element being a list of symbols
> if not empty, for hash collisions. And it's not a hash table of the
> kind that make-hash-table makes, which I added much later. And not a
> Lisp list of symbols.
I see, from the value it appeared to be a flat vector.
> With your figures, it seems that there are on average 5 symbols per
> bucket. For details you'd have to look at the C code.
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Philip Kaludercic <philipk <at> posteo.net>
>> Date: Thu, 06 Oct 2022 16:16:03 +0000
>>
>>
>> >From reading the docstring of `mapatoms', I would assume that this would
>> evaluate to t:
>>
>> (let ((i 0))
>> (mapatoms (lambda (_) (setq i (1+ i))) obarray)
>> (= (length obarray) i))
>>
>> But instead on my system I get (length obarray) ↝ 15121 and and i ↝
>> 78050, which is are at a ratio of 5.16169565505.
>>
>> Also interesting, if I intern a variable "foo", the value of i increases
>> to 83106, while (length obarray) stays the same (?)
>
> You assume that obarray is a flat vector or something? Or how about
> if you explain why the above surprised you?
In that case what confuses me is that (length obarray) doesn't throw an
error. Or what useful information does that give me?
This bug report was last modified 2 years and 225 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.