bug#41354: equal? has no sensible code path for symbols

David Kastrup <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Ludovic Courtès <[email protected]> writes:

> Hi David,
>
> David Kastrup <[email protected]> skribis:
>
>> In Scheme, symbols can be compared using eq? for equality.  However,
>> since they have garbage-collected content attached, they do not meet the
>> predicate SCM_IMP in the short-circuit evaluation at the start of equal?
>> This means that unequal symbols compared using equal? fall through a
>> whole bunch of tests and end up in a general structural comparison
>> comparing their underlying string names.
>
> ‘equal?’ starts by checking for eq-ness, which LGTM:
>
>   SCM
>   scm_equal_p (SCM x, SCM y)
>   #define FUNC_NAME s_scm_i_equal_p
>   {
>     SCM_CHECK_STACK;
>    tailrecurse:
>     SCM_TICK;
>     if (scm_is_eq (x, y))
>       return SCM_BOOL_T;
>
> Or were you referring to something else?

I repeat: "This means that UNEQUAL symbols compared using equal? fall
through a whole bunch of tests and end up in a general structural
comparison comparing their underlying string names".

Lots of searches _end_ with an equal comparison (which is fast) but do a
lot of unequal comparisons before that (which is slow, even though
symbols that are not eq? will also not be equal?, so if you know you are
checking _symbols_, if they are not eq? you are done).

Symbols comparing as _unequal_ have no special path in equal?.

-- 
David Kastrup
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.