newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Jeff on June 21, 2007, 01:34:58 PM

Title: Had an idea for nested hashes
Post by: Jeff on June 21, 2007, 01:34:58 PM
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.