unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#18223: [PATCH] Fix thinko concerning object property docs
@ 2014-08-08 13:42 David Kastrup
  2014-08-09  9:46 ` bug#18223: Duplicate of issue 14792 David Kastrup
  2014-08-09 10:20 ` bug#18223: And here's direct proof that the doc is wrong: David Kastrup
  0 siblings, 2 replies; 6+ messages in thread
From: David Kastrup @ 2014-08-08 13:42 UTC (permalink / raw)
  To: 18223; +Cc: David Kastrup

Numeric values cannot reliably be distinguished using eq? and have no
guaranteed object identity.

Signed-off-by: David Kastrup <dak@gnu.org>
---
 doc/ref/api-utility.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/ref/api-utility.texi b/doc/ref/api-utility.texi
index ffdf276..e2b60e2 100644
--- a/doc/ref/api-utility.texi
+++ b/doc/ref/api-utility.texi
@@ -222,7 +222,7 @@ setting of @var{obj}'s @var{property}.
 
 A single object property created by @code{make-object-property} can
 associate distinct property values with all Scheme values that are
-distinguishable by @code{eq?} (including, for example, integers).
+distinguishable by @code{eq?} (ruling out numeric values).
 
 Internally, object properties are implemented using a weak key hash
 table.  This means that, as long as a Scheme value with property values
-- 
1.9.1






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#18223: Duplicate of issue 14792
  2014-08-08 13:42 bug#18223: [PATCH] Fix thinko concerning object property docs David Kastrup
@ 2014-08-09  9:46 ` David Kastrup
  2014-08-09 12:16   ` Nala Ginrut
  2014-08-11  3:00   ` bug#14792: " Mark H Weaver
  2014-08-09 10:20 ` bug#18223: And here's direct proof that the doc is wrong: David Kastrup
  1 sibling, 2 replies; 6+ messages in thread
From: David Kastrup @ 2014-08-09  9:46 UTC (permalink / raw)
  To: 18223


This is actually a duplicate of issue 14792 which has been ignored for
over a year by now.

Please see <URL:http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14792#35>
for the reason the provided patch (namely discouraging the use of
numbers for object properties) is the only one making sense.

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

Guile and/or Scheme do not store the equivalence relation in the
hashtable itself, and user-definable hash functions may establish
arbitrary relations regarding key uniqueness that have no clear relation
to the object identity used by garbage collection.

-- 
David Kastrup





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#18223: And here's direct proof that the doc is wrong:
  2014-08-08 13:42 bug#18223: [PATCH] Fix thinko concerning object property docs David Kastrup
  2014-08-09  9:46 ` bug#18223: Duplicate of issue 14792 David Kastrup
@ 2014-08-09 10:20 ` David Kastrup
  1 sibling, 0 replies; 6+ messages in thread
From: David Kastrup @ 2014-08-09 10:20 UTC (permalink / raw)
  To: 18223


scheme@(guile-user)> (define wooziness (make-object-property))
scheme@(guile-user)> (set! (wooziness 5) #t)
$1 = #t
scheme@(guile-user)> (wooziness 5)
$2 = #t
scheme@(guile-user)> (set! (wooziness 1000000000000000000) #t)
$3 = #t
scheme@(guile-user)> (wooziness 1000000000000000000)
$4 = #f
scheme@(guile-user)> 

The property persists for 5 and evaporates for 1000000000000000000.
There is no reliable way to know whether it will persist for numbers.

And since Guile refuses to commit to guaranteeing (lambda (x) (eq? x x))
to return #t when x may be a number and since there is no guarantee just
which numbers may be represented by immediate values, there is no
context in which an object property on a number may safely be retrieved.

-- 
David Kastrup





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#18223: Duplicate of issue 14792
  2014-08-09  9:46 ` bug#18223: Duplicate of issue 14792 David Kastrup
@ 2014-08-09 12:16   ` Nala Ginrut
  2014-08-09 12:21     ` David Kastrup
  2014-08-11  3:00   ` bug#14792: " Mark H Weaver
  1 sibling, 1 reply; 6+ messages in thread
From: Nala Ginrut @ 2014-08-09 12:16 UTC (permalink / raw)
  To: David Kastrup; +Cc: 18223

[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]

I can't reproduce it, but I'm using the latest mater. Could you provide
your version?
 2014年8月9日 下午5:47于 "David Kastrup" <dak@gnu.org>写道:

>
> This is actually a duplicate of issue 14792 which has been ignored for
> over a year by now.
>
> Please see <URL:http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14792#35>
> for the reason the provided patch (namely discouraging the use of
> numbers for object properties) is the only one making sense.
>
> 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
>
> Guile and/or Scheme do not store the equivalence relation in the
> hashtable itself, and user-definable hash functions may establish
> arbitrary relations regarding key uniqueness that have no clear relation
> to the object identity used by garbage collection.
>
> --
> David Kastrup
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 1704 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#18223: Duplicate of issue 14792
  2014-08-09 12:16   ` Nala Ginrut
@ 2014-08-09 12:21     ` David Kastrup
  0 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2014-08-09 12:21 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: 18223

Nala Ginrut <nalaginrut@gmail.com> writes:

> I can't reproduce it, but I'm using the latest mater. Could you provide
> your version?

My version is 2.0.9, but more importantly my architecture is 32bit.
Just add enough zeros to move beyond the largest immediate integer, and
you'll likely see the same effect.

-- 
David Kastrup





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#14792: bug#18223: Duplicate of issue 14792
  2014-08-09  9:46 ` bug#18223: Duplicate of issue 14792 David Kastrup
  2014-08-09 12:16   ` Nala Ginrut
@ 2014-08-11  3:00   ` Mark H Weaver
  1 sibling, 0 replies; 6+ messages in thread
From: Mark H Weaver @ 2014-08-11  3:00 UTC (permalink / raw)
  To: David Kastrup; +Cc: 14792, 18223, request

merge 18223 14792
close 18223
close 14792
thanks

David Kastrup <dak@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-11  3:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-08 13:42 bug#18223: [PATCH] Fix thinko concerning object property docs David Kastrup
2014-08-09  9:46 ` bug#18223: Duplicate of issue 14792 David Kastrup
2014-08-09 12:16   ` Nala Ginrut
2014-08-09 12:21     ` David Kastrup
2014-08-11  3:00   ` bug#14792: " Mark H Weaver
2014-08-09 10:20 ` bug#18223: And here's direct proof that the doc is wrong: David Kastrup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).