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

For the Compleat Fan
Locked
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

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

Post by ssqq »

I meet a strange problem:

When I load the module with content below:

Code: Select all

(define Token-char:Token-char)

(Token-char "key" 123)
REPL output:
ERR: context expected in function define : Token-char
When I use other context name like:

Code: Select all

(define Token:Token)

(Token "key" 123)
That is ok.

If have any reserved context name in newLISP?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

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

Post by Lutz »

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/newlis ... em_symbols

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

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

Post by rickyboy »

Lutz wrote: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.

Code: Select all

 ~ $ 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)

Locked