4 ms·
> What is the difference between setp, setf, defvar, and defparameter? In very simplified terms: Use defparameter to define a variable at top level (let's cal
by flavio81 9y ago
> What is the difference between setp, setf, defvar, and defparameter?
In very simplified terms:
Use defparameter to define a variable at top level (let's call it "global" for simplification.)
Defvar does the same, but if the variable already had a value, then it won't change that value.
Once you define them you can later change the value using setq or setf.
Setf does everything setq does and more. Setf can change the value of "places". "Places" is a great fundamental concept of CL.
> Why is the documentation so technical and dense?
Because Common Lisp is technical and dense. But it is that way for a reason, and as a reward, it "just works" and allows you to do things impossible or really difficult on other languages. It has no limits. CL is dense in features. It isn't a "watered down" language like python (btw i like python and use it). Python is restrained on features (compared to CL) thus there is less to learn. Thus it is easier to learn.
> What are multiple return values and how do I get to them?
Functions can return more than one value. This is not the same as putting many values on a list and returning said list. CL also allows true multiple return values.
This is explained on the CLHS. Use "multiple-value-bind" to get them.
- kazinator 9y agoIn Common Lisp, setq is just a variant of setf whose argument syntax must be a symbol. However, that symbol may be a symbol macro which expands to a compound form! Through a suitably defined intermediate symbol macro, setq can operate on any place on which setf can operate.