It is not normal, I think.G:\>newlisp
newLISP v.8.7.2 on Win32 MinGW, execute 'newlisp -h' for more info.
> (setq zzz:aaa 1)
1
> (context? zzz)
true
> (exit)
G:\>newlisp
newLISP v.8.7.2 on Win32 MinGW, execute 'newlisp -h' for more info.
> (context? zzz)
nil
> (setq zzz:aaa 1)
context expected in function setq : zzz
>
Unexpected error
Unexpected error
Unexpected error. See below:
This looks strange to me too:
Fanda
Code: Select all
newLISP v.8.7.4 on Win32 MinGW.
> (context 'ctx)
ctx
ctx> (symbols)
()
ctx> (symbol? x)
nil
ctx> (symbols)
(x)
ctx> x
nil
ctx>
When newLISP reads:
it first translates the code and creates a 'x' symbol in the current context ctx.
When newLISP reads the expression (context? zzz), it does not find the symbol 'zzz' and creates it in the current context. When you do a (setq zzz:aaa 1) it finds that 'zzz' is not a context symbol but a normal symbol and throws an error.
newLISP creates symbols in the current context if they don't exist.
Lutz
ps: there are some chapters about this in the manual.
Code: Select all
ctx> (symbol? x)
Code: Select all
> (context? zzz)
nil
> (setq zzz:aaa 1)
context expected in function setq : zzz
>
When newLISP reads the expression (context? zzz), it does not find the symbol 'zzz' and creates it in the current context. When you do a (setq zzz:aaa 1) it finds that 'zzz' is not a context symbol but a normal symbol and throws an error.
newLISP creates symbols in the current context if they don't exist.
Lutz
ps: there are some chapters about this in the manual.
it first translates the code and creates a 'x' symbol in the current context ctx.
Code: Select all
> (context 'ctx)
ctx
ctx> (symbol? x) #symbol 'x' creates
nil
ctx> (symbols) #Yes, symbol 'x' exists
(x)
ctx> (symbol? x) #No, we have no symbol 'x' !?
nil
ctx>
The function 'symbol' evaluates it's argument first. In (symbol? x) you are asking if the contents of 'x' is a symbol. You have to quote it:
evaluation is a central topic in newLISP (and any LISP), there is a chapter about this in the manual you could read.
Lutz
Code: Select all
> (symbol? x)
nil
> (symbol? 'x)
true
> (set 'y 'z)
z
> (symbol? y)
true
> y
z
Lutz