Hi all,<br><br>I've found needs to track variables/values that I've instantiated to aid meta programming, and hash-table seems to work well for this purpose. Below is a sample for motivation.<br><br>;;; the struct that holds the metadata info
<br>(define-struct type (name isa? cast) (make-inspector))<br><br>;;; have a register to keep track of the types <br>(define-values (type:register type:get) <br> (let ((register (make-hash-table 'equal)))<br> (define (type:register key value)
<br> (hash-table-put! register key value))<br> (define (type:get key)<br> (hash-table-get register key #f))))<br><br>;;; macro to wrap around the definition + registration<br>(define-syntax define-type<br> (syntax-rules (isa? cast)
<br> ((_ name (isa? isa?-exp) (cast cast-exp))<br> (define name <br> (let ((t (make-type 'name isa?-exp cast-exp)))<br> (foo:register 'name t)<br> t)))))<br><br>Of course - any data stored in a hash table would live until the hash table goes out of scope or until the data gets overwritten, and it doesn't obey lexical rules.
<br><br>Are there ways to make it obey lexical rules so the register can behave more like an actual symbol table? i.e. if a type is declared within a lexical scope as it goes out of scope the value is removed from the register. I assume that if this is possible there needs to be a way to know that I'm in a different lexical scope then before.
<br><br>Any thoughts are appreciated - thanks.<br><br>yc<br><br><br>