Rather than specifying a default value for a table at lookup, it would be easier to set it when the table is created. I'm not sure how best to implement it, but this is what I have so far (ac.scm): (define hash-table-default (ar-gensym))
(xdef table (lambda args
(let ((h (make-hash-table 'equal)))
(hash-table-put! h hash-table-default
(if (pair? args) (car args) 'nil))
h)))
Each table is given an initial default value. ar-apply then looks for the value of a key or returns the default: ((hash-table? fn)
(ar-nill (or (hash-table-get fn (car args) #f)
(hash-table-get fn hash-table-default #f))))
Test: arc> (= h (table))
#hash((gs1 . nil))
arc> h!k
nil
arc> (= h (table 0))
#hash((gs1 . 0))
arc> h!k
0
|