guile-user
[Top][All Lists]
Advanced

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

Re: goops and equal?


From: Mark H Weaver
Subject: Re: goops and equal?
Date: Thu, 13 Nov 2014 11:56:29 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Jan Nieuwenhuizen <address@hidden> writes:

> Mark H Weaver writes:
>
>> 'equal?' is actually a "primitive generic", which means that it's a core
>> C function that handles the cases it knows about, and only calls out to
>> user-defined GOOPS methods for cases that aren't handled internally.
>>
>> One of the facts known by core 'equal?' is that objects of different
>> types are not equal.
>
> That makes sense; once you know it.
>
>> It may be that we should relax this somewhat, but IMO it's probably a
>> bad idea to allow instances of your user-defined type to be 'equal?' to
>> symbols.  Out of curiosity, why do you want this?
>
> Mainly because of surprise/symmetry.  The manual says equal? becomes
> a generic once Goops is loaded.

I agree that we should improve that bit in the manual.

> I agree that it's unwise or at least bad taste to implement equal?
> for different objects to be the same.
>
> I have a situation where the compared objects could be the same,
> or one could be a symbol which has the same semantics.

They may have the same semantics in some of your code, but they have
different semantics for most other code in your Guile session.  The
problem with modifying 'equal?' in this way is that it would be a global
change, which could cause existing code to start misbehaving.

    Regards,
      Mark



reply via email to

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