GNU bug report logs -
#14792
Error in manual "(guile-2) Object Properties"
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14792 in the body.
You can then email your comments to 14792 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Thu, 04 Jul 2013 18:05:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
David Kastrup <dak <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Thu, 04 Jul 2013 18:05:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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). So something seems wrong in
that description. Either integer values can _not_ be given properties
reliably, or the above needs to specify "distinguishable by `eqv?'" or
whatever else may be the underlying reality.
--
David Kastrup
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Fri, 05 Jul 2013 16:39:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Hi David,
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?
Mark
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Sat, 06 Jul 2013 21:22:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 14792 <at> debbugs.gnu.org (full text, mbox):
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.
Ludo’.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 16:00:05 GMT)
Full text and
rfc822 format available.
Message #14 received at 14792 <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 18:47:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Mark H Weaver <mhw <at> netris.org> writes:
> 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.
Fixing the documentation will not change the behavior. So they are not
worse off than before.
> '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?
object identity is checked by eq? and is conceptually different from
value equality.
When calling a thing an "object property", it is not helpful when it
does not behave like one.
--
David Kastrup
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 18:54:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Mark H Weaver <mhw <at> netris.org> skribis:
> 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.
[...]
> What's the argument on the other side? Is there a compelling reason to
> use 'eq?' instead of 'eqv?' for object properties?
The argument would be the “ugly efficiency hack”.
But I hear your argument, and I’m fine with changing this accordingly.
Thanks,
Ludo’.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 19:01:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Hi David,
David Kastrup <dak <at> gnu.org> writes:
> Mark H Weaver <mhw <at> netris.org> writes:
>
>> '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?
>
> object identity is checked by eq? and is conceptually different from
> value equality.
The Scheme standards don't support your view. The _only_ difference
between 'eq?' and 'eqv?' is that 'eqv?' is well-defined on numbers and
characters, whereas 'eq?' is unspecified for those types.
Numbers and characters do not have any notion of "object identity",
apart from operational equivalence. For all values where "object
identity" makes any sense at all, 'eqv?' does what you want.
Regards,
Mark
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 19:31:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Mark H Weaver <mhw <at> netris.org> writes:
> Hi David,
>
> David Kastrup <dak <at> gnu.org> writes:
>
>> Mark H Weaver <mhw <at> netris.org> writes:
>>
>>> '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?
>>
>> object identity is checked by eq? and is conceptually different from
>> value equality.
>
> The Scheme standards don't support your view. The _only_ difference
> between 'eq?' and 'eqv?' is that 'eqv?' is well-defined on numbers and
> characters, whereas 'eq?' is unspecified for those types.
And why would that be if numbers were proper objects? The difference is
_exactly_ there because they aren't.
> Numbers and characters do not have any notion of "object identity",
> apart from operational equivalence.
Which is why it does not make a lot of sense to assign "object
properties" to them.
--
David Kastrup
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 19:53:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 14792 <at> debbugs.gnu.org (full text, mbox):
David Kastrup <dak <at> gnu.org> writes:
> Mark H Weaver <mhw <at> netris.org> writes:
>
>> David Kastrup <dak <at> gnu.org> writes:
>>
>>> Mark H Weaver <mhw <at> netris.org> writes:
>>>
>>> object identity is checked by eq? and is conceptually different from
>>> value equality.
>>
>> The Scheme standards don't support your view. The _only_ difference
>> between 'eq?' and 'eqv?' is that 'eqv?' is well-defined on numbers and
>> characters, whereas 'eq?' is unspecified for those types.
>
> And why would that be if numbers were proper objects? The difference is
> _exactly_ there because they aren't.
I don't know what you mean by "proper objects". I guess maybe you mean
"objects with identity".
>> Numbers and characters do not have any notion of "object identity",
>> apart from operational equivalence.
>
> Which is why it does not make a lot of sense to assign "object
> properties" to them.
I understand that in the dominant "object oriented" programming
communities of today, the word "object" usually implies mutability and
identity, but the Scheme standards use the term differently.
In the Scheme standards, the word "object" is synonymous with "value".
R5RS section 1.1 states "Types are associated with values (also called
objects) rather than with variables." Furthermore, R6RS consistently
calls numbers "objects", even though they lack "object identity" in the
sense that you mean.
Mark
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Tue, 16 Jul 2013 20:02:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Mark H Weaver <mhw <at> netris.org> writes:
> David Kastrup <dak <at> gnu.org> writes:
>
>> Mark H Weaver <mhw <at> netris.org> writes:
>>
>>> David Kastrup <dak <at> gnu.org> writes:
>>>
>>>> Mark H Weaver <mhw <at> netris.org> writes:
>>>>
>>>> object identity is checked by eq? and is conceptually different from
>>>> value equality.
>>>
>>> The Scheme standards don't support your view. The _only_ difference
>>> between 'eq?' and 'eqv?' is that 'eqv?' is well-defined on numbers and
>>> characters, whereas 'eq?' is unspecified for those types.
>>
>> And why would that be if numbers were proper objects? The difference is
>> _exactly_ there because they aren't.
>
> I don't know what you mean by "proper objects". I guess maybe you mean
> "objects with identity".
>
>>> Numbers and characters do not have any notion of "object identity",
>>> apart from operational equivalence.
>>
>> Which is why it does not make a lot of sense to assign "object
>> properties" to them.
>
> I understand that in the dominant "object oriented" programming
> communities of today, the word "object" usually implies mutability and
> identity, but the Scheme standards use the term differently.
>
> In the Scheme standards, the word "object" is synonymous with "value".
> R5RS section 1.1 states "Types are associated with values (also called
> objects) rather than with variables." Furthermore, R6RS consistently
> calls numbers "objects", even though they lack "object identity" in the
> sense that you mean.
Well, eq?/eqv? are an inheritance from Lisp's eq/eql. If there is no
clear conceptual difference any more, it would seem like a mistake to
keep two different operators around.
--
David Kastrup
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Sat, 27 Jul 2013 21:21:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 14792 <at> debbugs.gnu.org (full text, mbox):
Object properties are implemented via key-weak hash tables and those
only support eq? as hash equality in a reliable way.
I actually can't determine how key-weak hash tables would deal with
immediate Scheme values: will they never get released, or will they get
released immediately?
From reading the documentation, I'd lean towards guessing the latter (as
for immediate Scheme values, there _never_ is a remaining reference).
That would likely make for some surprises to people, while the other
option would be good for memory leaks.
Either way, numbers seem like a bad idea for use in key-weak hash
tables.
--
David Kastrup
Merged 14792 18223.
Request was from
David Kastrup <dak <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sun, 10 Aug 2014 13:06:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#14792
; Package
guile
.
(Mon, 11 Aug 2014 03:02:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 14792 <at> debbugs.gnu.org (full text, mbox):
merge 18223 14792
close 18223
close 14792
thanks
David Kastrup <dak <at> gnu.org> writes:
> Here is the rationale in code: object properties are implemented via
> key-weak hash tables, and weak hash tables will not work with eqv? as
> equivalence since key-weakness is related to garbage collection which
> cannot consider anything but eq?-equivalence.
>
> scheme@(guile-user)> (define x (make-weak-key-hash-table))
> scheme@(guile-user)> (hashv-set! x 100000000000000000000 #t)
> $6 = #t
> scheme@(guile-user)> (gc)
> scheme@(guile-user)> (hashv-ref x 100000000000000000000)
> $7 = #f
Indeed, you are right. I added a proper commit message to your patch,
and have applied it to the stable-2.0 branch. I'm closing both bugs.
Thanks!
Mark
Merged 14792 18223.
Request was from
Mark H Weaver <mhw <at> netris.org>
to
control <at> debbugs.gnu.org
.
(Mon, 11 Aug 2014 03:02:03 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
18223 <at> debbugs.gnu.org and David Kastrup <dak <at> gnu.org>
Request was from
Mark H Weaver <mhw <at> netris.org>
to
control <at> debbugs.gnu.org
.
(Mon, 11 Aug 2014 03:02:04 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 08 Sep 2014 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 343 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.