On Sat, 23 May 2026, Ludovic Courtès <[email protected]> wrote:
> Hello,
>
> Olivier Dion <[email protected]> skribis:
>
>>   scheme@(guile-user)> (= (hash '(1 2 3 4 5) most-positive-fixnum)
>>                           (hash '(1 2 3 4 5 6) most-positive-fixnum))
>>     => #t
>>
>> To me this screams that list hashing are fundamentally broken.  Only the
>> first 5 elements are used for hashing.  This is why you got the same
>> hash for both transformations.
>
> One of the design goals for ‘hash’ is that it must be constant-time.

I don't think this hold true for other types like string.

> Thus, by definition, it cannot traverse entire lists or vectors.

I think the `depth' logic is more to handle cycles in containers.  I
also don't quite understand why the depth is divided by two when
traversing a flat list/vector.  To me the depth should be incremented
when going down into a sub-container, not when getting the next element.
However, I would need to read the git history to understand the
rationale fully.

> I don’t see how to avoid that.

If we can't avoid this, e.g. we want to keep the constant-time behavior,
then we should at least document that limitation in the manual and
recommend some alternative to users.

Also, I think that psyntax should maybe do it's own recursive traversal
of the form for hashing.  That would avoid the issue that Tomas
mentionned with duplicated top-level identifiers.

Thanks,
Olivier
-- 
Olivier Dion

Reply via email to