load sym-context problem

Started by Tim Johnson, May 17, 2008, 03:53:56 PM

Previous topic - Next topic

Tim Johnson

I have a file created by 'save. session.lsp
(context 'g)
(set 'action "Viewing file: testcgi.dbg")
(set 'home "/home/http/run/newlisp")
(set 'log-ex '(".dbg" ".err" ".ok"))
(set 'target-file "testcgi.dbg")
(set 'top-dir "/home/http/run/")
(context 'MAIN)

When I attempt to load this file without the option sym-context parameter,

all is good:
> (load "session.lsp")
MAIN
> g:top-dir
"/home/http/run/"

When  I load with 'sym-context I expected the symbol to contain

all members and values as the original but the following is not what I expected.

> (load "session.lsp" 'gg)
MAIN
> gg:top-dir
nil
> (symbols 'gg)
(gg:g gg:top-dir)

 I guess I need some clarification.

FYI: What I want to be able to do is

save variables from a session, reload them at

the next execution of the script without overwriting the

current variables.

Thanks

Tim
Programmer since 1987. Unix environment.

rickyboy

#1
If your session.lsp just looked like this:
(set 'action "Viewing file: testcgi.dbg")
(set 'home "/home/http/run/newlisp")
(set 'log-ex '(".dbg" ".err" ".ok"))
(set 'target-file "testcgi.dbg")
(set 'top-dir "/home/http/run/")

i.e. no context expressions, then evaluating this in newlisp:
(load "session.lsp" 'gg)
would give you what you need.



In the original case, load still has to respect the context expressions.  And since you loaded everything "under" the gg context, when the loader gets to (context 'g), it's gonna create the context "under" gg.  That's why you're getting gg:g when you inspect the symbols.  But the rest, go in the g context, and this makes sense, since you had noticed earlier that all contexts are under MAIN (i.e. no cascading contexts in newlisp).
(λx. x x) (λx. x x)

Tim Johnson

#2
Ah!

I think I misread the documentation.

I believe that the following should get me what I'm looking for:

> (load "session.lsp")
MAIN
> (new g 'prv)

So now I have a copy of the previous session in 'prv

and subsequent writes to 'g would not change 'prv.



Thanks

Tim
Programmer since 1987. Unix environment.