aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2024-02-17 13:27:25 +0100
committerMattias EngdegÄrd2024-02-17 20:29:54 +0100
commit1b20fe7dff234a8660d8a73c9a183c19863331a7 (patch)
tree9de544f8c0e489d5320761dab55c581d5085deed
parent934046990b5cbe48d863559d3d1f9c07d7dd949a (diff)
downloademacs-scratch/obarray.tar.gz
emacs-scratch/obarray.zip
Update NEWS and manual after obarray changesscratch/obarray
* doc/lispref/abbrevs.texi (Abbrev Tables): * doc/lispref/symbols.texi (Creating Symbols): * doc/lispref/objects.texi (Type Predicates): Update text for obarray now being an opaque type. * etc/NEWS: Announce.
-rw-r--r--doc/lispref/abbrevs.texi2
-rw-r--r--doc/lispref/objects.texi5
-rw-r--r--doc/lispref/symbols.texi59
-rw-r--r--etc/NEWS20
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
67This function creates and returns a new, empty abbrev table---an 67This function creates and returns a new, empty abbrev table---an
68obarray containing no symbols. It is a vector filled with zeros. 68obarray 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}.
2187However, if @var{object} is a record, the type specified by its first 2190However, 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
177symbol every time it reads the same sequence of characters in the same 177symbol every time it reads the same sequence of characters in the same
178context. Failure to do so would cause complete confusion. 178context. 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
185the source code, it reads all the characters of that name. Then it 183the source code, it reads all the characters of that name. Then it
186looks up that name in a table called an @dfn{obarray} to find the 184looks up that name in a table called an @dfn{obarray} to find the
187symbol that the programmer meant. The technique used in this lookup 185symbol that the programmer meant. An obarray is an unordered container
188is called ``hashing'', an efficient method of looking something up by 186of symbols.
189converting a sequence of characters to a number, known as a ``hash
190code''. For example, instead of searching a telephone book cover to
191cover when looking up Jan Jones, you start with the J's and go from
192there. That is a simple version of hashing. Each element of the
193obarray is a @dfn{bucket} which holds all the symbols with a given
194hash code; to look for a given name, it is sufficient to look through
195all the symbols in the bucket for that name's hash code. (The same
196idea is used for general Emacs hash tables, but they are a different
197data type; see @ref{Hash Tables}.)
198 187
199When looking up names, the Lisp reader also considers ``shorthands''. 188When looking up names, the Lisp reader also considers ``shorthands''.
200If the programmer supplied them, this allows the reader to find a 189If the programmer supplied them, this allows the reader to find a
201symbol even if its name isn't present in its full form in the source 190symbol even if its name isn't present in its full form in the source
202code. Of course, the reader needs to be aware of some pre-established 191code. @xref{Shorthands}.
203context about such shorthands, much as one needs context to be to able
204to refer uniquely to Jan Jones by just the name ``Jan'': it's probably
205fine when amongst the Joneses, or when Jan has been mentioned
206recently, 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
236value of a variable. Uninterned symbols are sometimes useful in 220value of a variable. Uninterned symbols are sometimes useful in
237generating Lisp code, see below. 221generating Lisp code, see below.
238 222
239 In Emacs Lisp, an obarray is actually a vector. Each element of the
240vector is a bucket; its value is either an interned symbol whose name
241hashes to that bucket, or 0 if the bucket is empty. Each interned
242symbol has an internal link (invisible to the user) to the next symbol
243in the bucket. Because these links are invisible, there is no way to
244find all the symbols in an obarray except using @code{mapatoms} (below).
245The 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
248with @code{(make-vector @var{length} 0)}. @strong{This is the only
249valid way to create an obarray.} Prime numbers as lengths tend
250to result in good hashing; lengths one less than a power of two are also
251good.
252
253 @strong{Do not try to put symbols in an obarray yourself.} This does
254not 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
233This function creates and returns an empty obarray object.
234The optional @var{size} may be used to specify the number of symbols
235that it is expected to hold, but since obarrays grow automatically
236as needed, this rarely provide any benefit.
237@end defun
238
239@defun obarrayp object
240This 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
266arguments. A @code{wrong-type-argument} error is signaled if the name 245arguments. A @code{wrong-type-argument} error is signaled if the name
267is not a string, or if the obarray is not a vector. 246is not a string, or if the obarray is not an obarray object.
268 247
269@defun symbol-name symbol 248@defun symbol-name symbol
270This function returns the string that is @var{symbol}'s name. For example: 249This 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
416it returns @code{nil}. 395it returns @code{nil}.
417@end defun 396@end defun
418 397
398@defun obarray-clear obarray
399This 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
diff --git a/etc/NEWS b/etc/NEWS
index 4477116248e..d8acebc7eef 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
1986always omitted, and ignored if present when the object is read back in. 1986always omitted, and ignored if present when the object is read back in.
1987 1987
1988** Obarrays
1989
1990+++
1991*** New 'obarray' type.
1992Obarrays are now represented by an opaque type instead of using vectors.
1993They are created by 'obarray-make' and manage their internal storage
1994dynamically, which means that the size parameter to 'obarray-make' can
1995safely be omitted. That is, they do not become slower as they fill up.
1996
1997The old vector representation is still accepted by functions operating
1998on 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.
2006They 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.
1990It is now possible to pass a directory of a local repository as URL 2010It is now possible to pass a directory of a local repository as URL