Had an idea for nested hashes

For the Compleat Fan
Locked
Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Had an idea for nested hashes

Post by 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:

Code: Select all

(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...

Artful code

Locked