Alex, Tomas, Axel (and all other picolisp coders out there), Another newbie question here, this time using (symbols) inside a function.
The intention behind the code (see below) is pretty simple. (mk) will create a new namespace (well, a new symbol table), and (dset) should set a variable in a specified namespace. However: + even though (dset) switches the active symbol table with (symbols Dict-ns) + and (symbols) returns <Dict-ns> as the active symbol table + but the variable |Key| is still only set in the pico symbol table Some questions (in addition to the obvious "why isn't this working?"): 1) What am I doing wrong when I'm trying to (setq) the variable? 2) is there a way to create a new symbol-table/namespace without it becoming the active one? 3) is there a way to check if a symbol is interned, without actually interning it and setting it to NIL (if it didn't previously exist). Basically, some way to do (interned? 'sym) => T/NIL . 4) is there a way to concatenate two symbol-names together, without creating a transient symbol? (symbol+ 'foo 'bar) => 'foobar As always, thanks in advance :) ### code (dicts2.l) (de mk X # switch back to orig ns, after creating new ns (symbols (symbols (car X) 'pico)) ) (de dset X (let ( Dict-ns (car X) # switch to Dict-ns Orig-ns (symbols Dict-ns) Key (cadr X) Value (eval (caddr X)) ) (prinl (pack "Current namespace is " (symbols))) (prinl (pack "Setting " Key " to " Value)) (eval (list 'setq Key Value)) (symbols Orig-ns) (prinl (pack "Current namespace is " (symbols))) )) (mk Dc) (dset Dc k1 (pack (time) " elapsed seconds")) (prinl (pack "pico~k1 => " pico~k1)) (prinl (pack "Dc~k1 => " Dc~k1)) ### output # note: this is with (de *Prompt (pack (symbols) " λ")) pico λ: (load "/home/imran/src/picolisp/labs/dicts2.l") Current namespace is Dc Setting k1 to 17820 elapsed seconds Current namespace is pico pico~k1 => 17820 elapsed seconds Dc~k1 => -- Regards, Imran Rafique (skype: imran_rafique) -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe