GNU bug report logs - #14792
Error in manual "(guile-2) Object Properties"

Previous Next

Package: guile;

Reported by: David Kastrup <dak <at> gnu.org>

Date: Thu, 4 Jul 2013 18:05:02 UTC

Severity: normal

Tags: patch

Merged with 18223

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mark H Weaver <mhw <at> netris.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 14792 <at> debbugs.gnu.org, David Kastrup <dak <at> gnu.org>
Subject: bug#14792: Error in manual "(guile-2) Object Properties"
Date: Tue, 16 Jul 2013 11:59:01 -0400
Hi Ludovic,

ludo <at> gnu.org (Ludovic Courtès) writes:

> Mark H Weaver <mhw <at> netris.org> skribis:
>
>> David Kastrup <dak <at> gnu.org> writes:
>>
>>> The manual states in "Object Properties":
>>>
>>>        A single object property created by `make-object-property' can
>>>     associate distinct property values with all Scheme values that are
>>>     distinguishable by `eq?' (including, for example, integers).
>>>
>>> Integers are not documented to be reliably distinguishable by eq? (which
>>> means that equal integers might not be eq).
>>
>> Indeed, good point!
>>
>> I think we should change object-properties to use 'eqv?' hash operations
>> instead of 'eq?'.  The only advantage to 'eq?' is a marginal efficiency
>> benefit, but that's no doubt lost in the noise, not only from the hash
>> table operations but from the use of fat mutexes.
>>
>> The only functional difference between Guile's 'eq?' and 'eqv?' is that
>> 'eq?' is not reliable on numbers.  Our manual has been telling people
>> for years that integers can be used as keys for object properties.
>> Therefore, we should make it so.  IMO, anyway.
>>
>> What do other people think?
>
> Associating object properties with numbers doesn’t seem useful to me, so
> my inclination would be to fix the manual, FWIW.

I can easily think of many possible uses for this, e.g. for memoizing
unary numeric functions, associating application-specific data
structures with file descriptors or array indices, etc.

Regardless, our manual has been telling people they could do this for a
long time.  To make matters worse, those who have tried using
object-properties have likely observed that it works as advertised.
They probably don't realize that it will silently fail for large
integers.

'eqv?' is Scheme's fundamental "operational equivalence" predicate.
'eq?' is just an ugly efficiency hack, a poor cousin of 'eqv?' that
fails in surprising ways.  No _correct_ program is ever broken by making
'eq?' an alias to 'eqv?'.  Many programs contain subtle bugs because of
their inappropriate use of 'eq?'.

What's the argument on the other side?  Is there a compelling reason to
use 'eq?' instead of 'eqv?' for object properties?

     Regards,
       Mark




This bug report was last modified 10 years and 344 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.