diff options
| author | Alan Mackenzie | 2018-03-21 17:36:34 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2018-03-21 17:36:34 +0000 |
| commit | 4ab455147069d4b7247ba3aff0da3dba3a671df6 (patch) | |
| tree | 09c13924b0f9c03e97d6c5ccd7ff4a455f3ed34a | |
| parent | a5bf09900836dd6199c7630b88f8fdf9f2d89d7f (diff) | |
| download | emacs-4ab455147069d4b7247ba3aff0da3dba3a671df6.tar.gz emacs-4ab455147069d4b7247ba3aff0da3dba3a671df6.zip | |
Firm up documentation of generalized variables
* doc/lispref/variables.texi (Generalized Variables)
(Setting Generalized Variables): Define a generalized variable as something
setf can write to. Remove the insinuation that hackers have poor memories.
State explicitly that the list of GVs given is complete. Remove the
suggestion that `setf' has superseded, or is in the process of superseding,
`setq'. Make minor corrections to the English.
| -rw-r--r-- | doc/lispref/variables.texi | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index aecee6f3056..b80bc88a585 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi | |||
| @@ -2317,11 +2317,12 @@ Attempting to assign them any other value will result in an error: | |||
| 2317 | 2317 | ||
| 2318 | @cindex generalized variable | 2318 | @cindex generalized variable |
| 2319 | @cindex place form | 2319 | @cindex place form |
| 2320 | A @dfn{generalized variable} or @dfn{place form} is one of the many places | 2320 | A @dfn{generalized variable} or @dfn{place form} is one of the many |
| 2321 | in Lisp memory where values can be stored. The simplest place form is | 2321 | places in Lisp memory where values can be stored using the @code{setf} |
| 2322 | a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of lists, elements | 2322 | macro (@pxref{Setting Generalized Variables}). The simplest place |
| 2323 | of arrays, properties of symbols, and many other locations are also | 2323 | form is a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of |
| 2324 | places where Lisp values are stored. | 2324 | lists, elements of arrays, properties of symbols, and many other |
| 2325 | locations are also places where Lisp values get stored. | ||
| 2325 | 2326 | ||
| 2326 | Generalized variables are analogous to lvalues in the C | 2327 | Generalized variables are analogous to lvalues in the C |
| 2327 | language, where @samp{x = a[i]} gets an element from an array | 2328 | language, where @samp{x = a[i]} gets an element from an array |
| @@ -2342,8 +2343,8 @@ variables. The @code{setf} form is like @code{setq}, except that it | |||
| 2342 | accepts arbitrary place forms on the left side rather than just | 2343 | accepts arbitrary place forms on the left side rather than just |
| 2343 | symbols. For example, @code{(setf (car a) b)} sets the car of | 2344 | symbols. For example, @code{(setf (car a) b)} sets the car of |
| 2344 | @code{a} to @code{b}, doing the same operation as @code{(setcar a b)}, | 2345 | @code{a} to @code{b}, doing the same operation as @code{(setcar a b)}, |
| 2345 | but without having to remember two separate functions for setting and | 2346 | but without you having to use two separate functions for setting and |
| 2346 | accessing every type of place. | 2347 | accessing this type of place. |
| 2347 | 2348 | ||
| 2348 | @defmac setf [place form]@dots{} | 2349 | @defmac setf [place form]@dots{} |
| 2349 | This macro evaluates @var{form} and stores it in @var{place}, which | 2350 | This macro evaluates @var{form} and stores it in @var{place}, which |
| @@ -2353,18 +2354,19 @@ just as with @code{setq}. @code{setf} returns the value of the last | |||
| 2353 | @var{form}. | 2354 | @var{form}. |
| 2354 | @end defmac | 2355 | @end defmac |
| 2355 | 2356 | ||
| 2356 | The following Lisp forms will work as generalized variables, and | 2357 | The following Lisp forms are the forms in Emacs that will work as |
| 2357 | so may appear in the @var{place} argument of @code{setf}: | 2358 | generalized variables, and so may appear in the @var{place} argument |
| 2359 | of @code{setf}: | ||
| 2358 | 2360 | ||
| 2359 | @itemize | 2361 | @itemize |
| 2360 | @item | 2362 | @item |
| 2361 | A symbol naming a variable. In other words, @code{(setf x y)} is | 2363 | A symbol. In other words, @code{(setf x y)} is exactly equivalent to |
| 2362 | exactly equivalent to @code{(setq x y)}, and @code{setq} itself is | 2364 | @code{(setq x y)}, and @code{setq} itself is strictly speaking |
| 2363 | strictly speaking redundant given that @code{setf} exists. Many | 2365 | redundant given that @code{setf} exists. Most programmers will |
| 2364 | programmers continue to prefer @code{setq} for setting simple | 2366 | continue to prefer @code{setq} for setting simple variables, though, |
| 2365 | variables, though, purely for stylistic or historical reasons. | 2367 | for stylistic and historical reasons. The macro @code{(setf x y)} |
| 2366 | The macro @code{(setf x y)} actually expands to @code{(setq x y)}, | 2368 | actually expands to @code{(setq x y)}, so there is no performance |
| 2367 | so there is no performance penalty for using it in compiled code. | 2369 | penalty for using it in compiled code. |
| 2368 | 2370 | ||
| 2369 | @item | 2371 | @item |
| 2370 | A call to any of the following standard Lisp functions: | 2372 | A call to any of the following standard Lisp functions: |