Had an idea for nested hashes

Started by Jeff, June 21, 2007, 01:34:58 PM

Previous topic - Next topic

Jeff

Of course, we can assign to context a a symbol that points to context b to create nested contexts, but it gets mucky from there when you want to access context b from outside context a, so we can wrap it in a function:


(define (@ tree)
  (cond
    ((null? tree) (throw-error "List expected in @get."))
    ((>= (length tree) 2)
      (if (> (length tree) 2)
          (@ (cons (context (tree 0) (name (tree 1))) (2 tree)))
          (context (tree 0) (name (tree 1)))))))

(context 'bar "test" "test value")
(context 'foo "child-hash" 'bar)
(println (@ '(foo child-hash test))) ; => test value


I think we should be able to go as deep as we want this this, although I only tried it a few levels down.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code