(setq a 6) assigns the value 6 to variable a. Returns 6
(setq b 8 c 3.12) assigns 8 to b, 3.12 to c. Returns 3.12
(setq w "table'') assigns the string "table" to variable w. Returns "table"
(setq p (list 4.0 6.5 2.0)) assigns the list containing 4.0, 6.5, and 2.0 to variable p. Returns the same list.
(setq p '(4.0 6.5 2.0)) same as above
The last two examples illustrate the fact that you can create a data list either by using the list function, or by quoting a data list. However, using the list function allows you to use variables within the list, whereas quoting a data list does not allow you to use variables. Since the list function is more versatile, we usually illustrate its use in these pages, even when the data list does not contain variables.
setq stands for "set quote," which means that setq always considers
the variable as quoted, so the variable does not need to be quoted explicitly.
Compare set below.
(set (quote a) 3.1) or (set 'a 3.1) assigns 3.1 to variable a and returns 3.1 The variable must be explicitly quoted. If it is not, it win be evaluated and the value assignment will go to the result of that evaluation. Compare setq above.
After (setq x 2 y 'x)
(set y 3) assigns 3 to x (because y evaluates to x) and returns 3. The value of y remains unchanged.
This function is needed in advanced programs which create and manipulate
variables on-the-fly. Unless needed, you should use the setq function
(see setq above) for all simple assignments.