[plt-scheme] equal? operator

From: Hans Oesterholt-Dijkema (hdnews at gawab.com)
Date: Mon Nov 21 19:16:22 EST 2005

> So, what I will do, is indead take your advice and try to create a 
> weak hash table holding
> all the proos variables currently active in memory.
I implemented this:

(define PROOS-STORE (make-hash-table 'equal 'weak))

(define (proos-store->list)
  (hash-table-map PROOS-STORE
          (lambda (key val)
            (list key val))))

(define (pobject-from-oid oid _class)
  (let ((class (proos-class _class)))
    (if (eq? class #f)
    (error (string-append "proos class definition for " _class " not 
    (let* ((obj (hash-table-get PROOS-STORE (list oid) (lambda () #f))))
      (oodb-dbg "PROOS-STORE: " oid obj)
      (if (eq? obj #f)
          (let ((obj (class 'from-oid oid)))
        (hash-table-put! PROOS-STORE (list oid) (make-weak-box obj))
        (oodb-dbg "PROOS-STORE: " oid obj)
          (weak-box-value obj))))))

oid's are 32<oid<64bit integers. I noticed a normal hash table 
(make-hash-table 'weak)
will not find my oids (they're to big). Now I resorted to (list oid) for 
the key in the hash
table *and* an 'equal property on the hash tables. But can It be done 
safely without the
(list ...)?

I don't know what will happen on a 64bit architecture.

> Hans
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.