Return a context from a function
Posted: Sat May 10, 2008 1:17 am
I'd like to have a function that creates and returns a new context from an existing source context:
I evaluate the following with result:
And then evaluate 'y with (obviously) not the results I'm looking for.
Help and examples are welcome. I haven't been able to find any
examples of this specific topic in documentation.
Thanks
Tim
Code: Select all
(context 'hash)
(setq context-name "hash" ## name of context
object-name "[none]" ## name of object
lst '() ## list - may be nested
)
(context 'MAIN)
(define (Hash! l oname)
(local (newhash)
(set 'newhash(new hash 'newhash))
(println "newhash = [" newhash:lst "]") ;; DEBUG newhash
(if l (set 'newhash:lst l))
(println "newhash = [" newhash:lst "]") ;; DEBUG newhash
(if oname (set 'newhash:object-name oname))
(println "newhash = [" newhash:object-name "]") ;; DEBUG newhash
newhash))
Code: Select all
> (set 'y (Hash! '((name "tim")) "myhash"))
newhash = [()]
newhash = [((name "tim"))]
newhash = [myhash]
newhash
Code: Select all
> y:lst
?
> y:object-name
?
examples of this specific topic in documentation.
Thanks
Tim