variable and symbol

Q&A's, tips, howto's
Locked
csfreebird
Posts: 107
Joined: Tue Jan 15, 2013 11:54 am
Location: China, Beijing
Contact:

variable and symbol

Post by csfreebird »

When reading the document today, I see there are two terms that are used for describing set.
In the following table:
http://www.newlisp.org/downloads/newlis ... estructive
I find:
set sets the contents of a variable

And when looking into the detail of set, I see

Code: Select all

syntax: (set sym-1 exp-1 [sym-2 exp-2 ... ])
Evaluates both arguments and then assigns the result of exp to the symbol found in sym. 
I am confused, is symbol same as variable?

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

Re: variable and symbol

Post by cormullion »

I'm aware of the inconsistency too, since I sometimes find myself using the two terms interchangeably, although I don't think they're entirely equivalent, so I probably shouldn't...

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

Re: variable and symbol

Post by Lutz »

A variable is an identifier for an object value, which could be either a boolean value, number, string, list, lambda-list, symbol or the machine address of a built in native function or operator.

In newLISP all variables are symbols but not all symbols are used as variables. For example int the following s-expression (symbolic expression):

(set 'x '(a b c))

... we have the symbols: x, a, b , c. But only the symbol x is used as variable holding a list of symbols a, b and c. In the case of x, it is is both a symbol and a variable.

Manipulating symbols - not only their variable values - is unique to Lisp. So, although any symbol in newLISP could be used as a variable, not all of them are used that way.

Locked