diff options
| -rw-r--r-- | doc/lispref/abbrevs.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/objects.texi | 5 | ||||
| -rw-r--r-- | doc/lispref/symbols.texi | 59 | ||||
| -rw-r--r-- | etc/NEWS | 20 |
4 files changed, 46 insertions, 40 deletions
diff --git a/doc/lispref/abbrevs.texi b/doc/lispref/abbrevs.texi index 9b719145584..d89cec4bc2b 100644 --- a/doc/lispref/abbrevs.texi +++ b/doc/lispref/abbrevs.texi | |||
| @@ -65,7 +65,7 @@ expanded in the buffer. For the user-level commands for abbrevs, see | |||
| 65 | 65 | ||
| 66 | @defun make-abbrev-table &optional props | 66 | @defun make-abbrev-table &optional props |
| 67 | This function creates and returns a new, empty abbrev table---an | 67 | This function creates and returns a new, empty abbrev table---an |
| 68 | obarray containing no symbols. It is a vector filled with zeros. | 68 | obarray containing no symbols. |
| 69 | @var{props} is a property list that is applied to the new table | 69 | @var{props} is a property list that is applied to the new table |
| 70 | (@pxref{Abbrev Table Properties}). | 70 | (@pxref{Abbrev Table Properties}). |
| 71 | @end defun | 71 | @end defun |
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi index b8fd5ed4345..e6def69454e 100644 --- a/doc/lispref/objects.texi +++ b/doc/lispref/objects.texi | |||
| @@ -2121,6 +2121,9 @@ with references to further information. | |||
| 2121 | @item numberp | 2121 | @item numberp |
| 2122 | @xref{Predicates on Numbers, numberp}. | 2122 | @xref{Predicates on Numbers, numberp}. |
| 2123 | 2123 | ||
| 2124 | @item obarrayp | ||
| 2125 | @xref{Creating Symbols, obarrayp}. | ||
| 2126 | |||
| 2124 | @item overlayp | 2127 | @item overlayp |
| 2125 | @xref{Overlays, overlayp}. | 2128 | @xref{Overlays, overlayp}. |
| 2126 | 2129 | ||
| @@ -2181,7 +2184,7 @@ This function returns a symbol naming the primitive type of | |||
| 2181 | @code{condition-variable}, @code{cons}, @code{finalizer}, | 2184 | @code{condition-variable}, @code{cons}, @code{finalizer}, |
| 2182 | @code{float}, @code{font-entity}, @code{font-object}, | 2185 | @code{float}, @code{font-entity}, @code{font-object}, |
| 2183 | @code{font-spec}, @code{frame}, @code{hash-table}, @code{integer}, | 2186 | @code{font-spec}, @code{frame}, @code{hash-table}, @code{integer}, |
| 2184 | @code{marker}, @code{mutex}, @code{overlay}, @code{process}, | 2187 | @code{marker}, @code{mutex}, @code{obarray}, @code{overlay}, @code{process}, |
| 2185 | @code{string}, @code{subr}, @code{symbol}, @code{thread}, | 2188 | @code{string}, @code{subr}, @code{symbol}, @code{thread}, |
| 2186 | @code{vector}, @code{window}, or @code{window-configuration}. | 2189 | @code{vector}, @code{window}, or @code{window-configuration}. |
| 2187 | However, if @var{object} is a record, the type specified by its first | 2190 | However, if @var{object} is a record, the type specified by its first |
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index e95e53d972d..5adf69fa9db 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi | |||
| @@ -177,34 +177,18 @@ know how Lisp reads them. Lisp must ensure that it finds the same | |||
| 177 | symbol every time it reads the same sequence of characters in the same | 177 | symbol every time it reads the same sequence of characters in the same |
| 178 | context. Failure to do so would cause complete confusion. | 178 | context. Failure to do so would cause complete confusion. |
| 179 | 179 | ||
| 180 | @cindex symbol name hashing | 180 | @cindex symbol name |
| 181 | @cindex hashing | ||
| 182 | @cindex obarray | 181 | @cindex obarray |
| 183 | @cindex bucket (in obarray) | ||
| 184 | When the Lisp reader encounters a name that references a symbol in | 182 | When the Lisp reader encounters a name that references a symbol in |
| 185 | the source code, it reads all the characters of that name. Then it | 183 | the source code, it reads all the characters of that name. Then it |
| 186 | looks up that name in a table called an @dfn{obarray} to find the | 184 | looks up that name in a table called an @dfn{obarray} to find the |
| 187 | symbol that the programmer meant. The technique used in this lookup | 185 | symbol that the programmer meant. An obarray is an unordered container |
| 188 | is called ``hashing'', an efficient method of looking something up by | 186 | of symbols. |
| 189 | converting a sequence of characters to a number, known as a ``hash | ||
| 190 | code''. For example, instead of searching a telephone book cover to | ||
| 191 | cover when looking up Jan Jones, you start with the J's and go from | ||
| 192 | there. That is a simple version of hashing. Each element of the | ||
| 193 | obarray is a @dfn{bucket} which holds all the symbols with a given | ||
| 194 | hash code; to look for a given name, it is sufficient to look through | ||
| 195 | all the symbols in the bucket for that name's hash code. (The same | ||
| 196 | idea is used for general Emacs hash tables, but they are a different | ||
| 197 | data type; see @ref{Hash Tables}.) | ||
| 198 | 187 | ||
| 199 | When looking up names, the Lisp reader also considers ``shorthands''. | 188 | When looking up names, the Lisp reader also considers ``shorthands''. |
| 200 | If the programmer supplied them, this allows the reader to find a | 189 | If the programmer supplied them, this allows the reader to find a |
| 201 | symbol even if its name isn't present in its full form in the source | 190 | symbol even if its name isn't present in its full form in the source |
| 202 | code. Of course, the reader needs to be aware of some pre-established | 191 | code. @xref{Shorthands}. |
| 203 | context about such shorthands, much as one needs context to be to able | ||
| 204 | to refer uniquely to Jan Jones by just the name ``Jan'': it's probably | ||
| 205 | fine when amongst the Joneses, or when Jan has been mentioned | ||
| 206 | recently, but very ambiguous in any other situation. | ||
| 207 | @xref{Shorthands}. | ||
| 208 | 192 | ||
| 209 | @cindex interning | 193 | @cindex interning |
| 210 | If a symbol with the desired name is found, the reader uses that | 194 | If a symbol with the desired name is found, the reader uses that |
| @@ -236,23 +220,6 @@ to gain access to it is by finding it in some other object or as the | |||
| 236 | value of a variable. Uninterned symbols are sometimes useful in | 220 | value of a variable. Uninterned symbols are sometimes useful in |
| 237 | generating Lisp code, see below. | 221 | generating Lisp code, see below. |
| 238 | 222 | ||
| 239 | In Emacs Lisp, an obarray is actually a vector. Each element of the | ||
| 240 | vector is a bucket; its value is either an interned symbol whose name | ||
| 241 | hashes to that bucket, or 0 if the bucket is empty. Each interned | ||
| 242 | symbol has an internal link (invisible to the user) to the next symbol | ||
| 243 | in the bucket. Because these links are invisible, there is no way to | ||
| 244 | find all the symbols in an obarray except using @code{mapatoms} (below). | ||
| 245 | The order of symbols in a bucket is not significant. | ||
| 246 | |||
| 247 | In an empty obarray, every element is 0, so you can create an obarray | ||
| 248 | with @code{(make-vector @var{length} 0)}. @strong{This is the only | ||
| 249 | valid way to create an obarray.} Prime numbers as lengths tend | ||
| 250 | to result in good hashing; lengths one less than a power of two are also | ||
| 251 | good. | ||
| 252 | |||
| 253 | @strong{Do not try to put symbols in an obarray yourself.} This does | ||
| 254 | not work---only @code{intern} can enter a symbol in an obarray properly. | ||
| 255 | |||
| 256 | @cindex CL note---symbol in obarrays | 223 | @cindex CL note---symbol in obarrays |
| 257 | @quotation | 224 | @quotation |
| 258 | @b{Common Lisp note:} Unlike Common Lisp, Emacs Lisp does not provide | 225 | @b{Common Lisp note:} Unlike Common Lisp, Emacs Lisp does not provide |
| @@ -262,9 +229,21 @@ Emacs Lisp provides a different namespacing system called | |||
| 262 | ``shorthands'' (@pxref{Shorthands}). | 229 | ``shorthands'' (@pxref{Shorthands}). |
| 263 | @end quotation | 230 | @end quotation |
| 264 | 231 | ||
| 232 | @defun obarray-make &optional size | ||
| 233 | This function creates and returns an empty obarray object. | ||
| 234 | The optional @var{size} may be used to specify the number of symbols | ||
| 235 | that it is expected to hold, but since obarrays grow automatically | ||
| 236 | as needed, this rarely provide any benefit. | ||
| 237 | @end defun | ||
| 238 | |||
| 239 | @defun obarrayp object | ||
| 240 | This function returns @code{t} if @var{object} is an obarray, | ||
| 241 | @code{nil} otherwise. | ||
| 242 | @end defun | ||
| 243 | |||
| 265 | Most of the functions below take a name and sometimes an obarray as | 244 | Most of the functions below take a name and sometimes an obarray as |
| 266 | arguments. A @code{wrong-type-argument} error is signaled if the name | 245 | arguments. A @code{wrong-type-argument} error is signaled if the name |
| 267 | is not a string, or if the obarray is not a vector. | 246 | is not a string, or if the obarray is not an obarray object. |
| 268 | 247 | ||
| 269 | @defun symbol-name symbol | 248 | @defun symbol-name symbol |
| 270 | This function returns the string that is @var{symbol}'s name. For example: | 249 | This function returns the string that is @var{symbol}'s name. For example: |
| @@ -416,6 +395,10 @@ If @code{unintern} does delete a symbol, it returns @code{t}. Otherwise | |||
| 416 | it returns @code{nil}. | 395 | it returns @code{nil}. |
| 417 | @end defun | 396 | @end defun |
| 418 | 397 | ||
| 398 | @defun obarray-clear obarray | ||
| 399 | This function removes all symbols from @var{obarray}. | ||
| 400 | @end defun | ||
| 401 | |||
| 419 | @node Symbol Properties | 402 | @node Symbol Properties |
| 420 | @section Symbol Properties | 403 | @section Symbol Properties |
| 421 | @cindex symbol property | 404 | @cindex symbol property |
| @@ -1985,6 +1985,26 @@ The 'test' parameter is omitted if it is 'eql' (the default), as is | |||
| 1985 | 'data' if empty. 'rehash-size', 'rehash-threshold' and 'size' are | 1985 | 'data' if empty. 'rehash-size', 'rehash-threshold' and 'size' are |
| 1986 | always omitted, and ignored if present when the object is read back in. | 1986 | always omitted, and ignored if present when the object is read back in. |
| 1987 | 1987 | ||
| 1988 | ** Obarrays | ||
| 1989 | |||
| 1990 | +++ | ||
| 1991 | *** New 'obarray' type. | ||
| 1992 | Obarrays are now represented by an opaque type instead of using vectors. | ||
| 1993 | They are created by 'obarray-make' and manage their internal storage | ||
| 1994 | dynamically, which means that the size parameter to 'obarray-make' can | ||
| 1995 | safely be omitted. That is, they do not become slower as they fill up. | ||
| 1996 | |||
| 1997 | The old vector representation is still accepted by functions operating | ||
| 1998 | on obarrays, but 'obarrayp' only returns 't' for obarray objects. | ||
| 1999 | 'type-of' now returns 'obarray' for obarray objects. | ||
| 2000 | |||
| 2001 | +++ | ||
| 2002 | *** New function 'obarray-clear' removes all symbols from an obarray. | ||
| 2003 | |||
| 2004 | --- | ||
| 2005 | *** 'obarray-size' and 'obarray-default-size' are now obsolete. | ||
| 2006 | They pertained to the internal storage size which is now irrelevant. | ||
| 2007 | |||
| 1988 | +++ | 2008 | +++ |
| 1989 | ** 'treesit-install-language-grammar' can handle local directory instead of URL. | 2009 | ** 'treesit-install-language-grammar' can handle local directory instead of URL. |
| 1990 | It is now possible to pass a directory of a local repository as URL | 2010 | It is now possible to pass a directory of a local repository as URL |