scsh-users
[Top] [All Lists]

general tables don't handle pairs

To: scsh-bugs@martigny.ai.mit.edu
Subject: general tables don't handle pairs
From: Scott Draves <spot@cs.cmu.edu>
Date: Thu, 25 May 95 00:48 EDT
scsh 0.3, linux 1.48

> (define tab (make-table))
> (let loop ((i 0)) (table-set! tab (list i) i) (loop (+ i 1)))

Error: value cannot be used as a table key
       (14)
1> 

once the table is converted from linear to hash at size 15, the
`general' hash function is invoked, but it doesn't handle pairs:

;; scsh-0.3/big/general-table.scm
(define (default-table-hash-function obj)
  (cond ((symbol? obj) (string-hash (symbol->string obj)))
        ((integer? obj)
         (if (< obj 0) (- -1 obj) obj))
        ((char? obj) (+ 333 (char->integer obj)))
        ((eq? obj #f) 3001)
        ((eq? obj #t) 3003)
        ((null? obj) 3005)
        (else (error "value cannot be used as a table key" obj))))


neither does it handle procedures...  imo the default hash function
shouldn't produce an error when it crosses an unrecognized type, but
should just return 0.

<Prev in Thread] Current Thread [Next in Thread>
  • general tables don't handle pairs, Scott Draves <=