$ symbols always in MAIN?

For the Compleat Fan
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

$ symbols always in MAIN?

Post by cormullion »

Are symbols with a preceding $ sign always defined in MAIN?

Code: Select all

> (context 'Fred)
Fred
Fred> (set '$fred "hi!")
"hi!"
Fred> (symbols)
()
Fred> (context MAIN)
MAIN
> (symbols)
(! != $ $0 $1 $10 $11 $12 $13 $14 $15 $2 $3 $4 $5 $6 $7 $8 $9 $args $fred $idx $main-args 
 % & * + - / : < << <= = > >= >> ? @ Fred MAIN NaN?...
Although it makes sense, I didn't realise that this was the case...!

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

Post by Lutz »

Symbols starting with $ are variables changed/maintained by newLISP and in MAIN and globally accessible. The variables $0 to $15 are used to hold info from regular expressions and $0 also holds the replaced expression for several set- and the replace function. $idx is the current 'dolist' index. $args contains the list returned by the function 'args' and $main-args contains the list returned by the function 'main-args'. All of these are global and all except $0 to $15 are protected cannot be changed by the user. $0 to $15 can be set by the user because there are instances where this is necessary when working with regular expressions.

Symbols starting with $ also do not get saved when saving a context as in (save 'MyContext) or when serializing newLISP objects with 'source'.

Locked