variable and symbol

Started by csfreebird, April 04, 2013, 11:50:56 PM

Previous topic - Next topic

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/newlisp_manual.html#destructive">http://www.newlisp.org/downloads/newlis ... estructive">http://www.newlisp.org/downloads/newlisp_manual.html#destructive

I find:

set   sets the contents of a variable



And when looking into the detail of set, I see

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

#1
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

#2
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.