load default functor Token-char:Token-char failed.

Started by ssqq, June 11, 2014, 08:33:44 PM

Previous topic - Next topic

ssqq

I meet a strange problem:



When I load the module with content below:


(define Token-char:Token-char)

(Token-char "key" 123)


REPL output:


QuoteERR: context expected in function define : Token-char


When I use other context name like:

(define Token:Token)

(Token "key" 123)


That is ok.



If have any reserved context name in newLISP?

Lutz

#1
Most likely Token-char was used before as a simple variable / symbols in the same newLISP session. Then when creating the defaut functor with (define Token-char:Token-char) the error is thrown. The error message protects you against programming errors.



Only the context function can convert normal symbols to context symbols. But if trying to use the context symbols after that as a normal variable you would get an error that the symbol is protected.



To see any symbols already defined execute symbols. As it is good programming practice to start context names with an upper-case letter, they will be high up in the list, preceded by system owned symbols starting with $. More about these here: http://www.newlisp.org/downloads/newlisp_manual.html#system_symbols">http://www.newlisp.org/downloads/newlis ... em_symbols">http://www.newlisp.org/downloads/newlisp_manual.html#system_symbols

rickyboy

#2
Quote from: "Lutz"Most likely Token-char was used before as a simple variable / symbols in the same newLISP session.

Yes, because if you try doing this in a clean session, you'll get no errors.


~ $ newlisp
newLISP v.10.5.8 32-bit on Win32 IPv4/6 libffi, options: newlisp -h

> (define Token-char:Token-char)
nil
> (Token-char "key" 123)
123
>
(λx. x x) (λx. x x)