diff options
| author | Daniel Colascione | 2015-03-02 19:08:06 -0800 |
|---|---|---|
| committer | Daniel Colascione | 2015-03-02 19:08:06 -0800 |
| commit | 2cc23f170f920cbfc9df4c28bce6ca9d82c4e6cd (patch) | |
| tree | ba2ba78402bf75eed26d3f20abeac5c02eb74694 /doc | |
| parent | 8af3e1848cbdc570b6c173480c2988a552f3f74d (diff) | |
| download | emacs-2cc23f170f920cbfc9df4c28bce6ca9d82c4e6cd.tar.gz emacs-2cc23f170f920cbfc9df4c28bce6ca9d82c4e6cd.zip | |
Finalizer documentation, minor improvements
* doc/lispref/objects.texi (Finalizer Type): New section
(Type Predicates): Mention finalizers in `type-of' documentation.
* doc/lispref/elisp.texi (Top): Link to finalizer type.
* src/data.c (Ftype_of): Make `type-of' work with finalizers.
(syms_of_data): Register Qfinalizer.
* src/print.c (print_object): Print whether a finalizer has
been called.
* test/automated/finalizer-tests.el (finalizer-object-type): Test that
`type-of' works correctly for finalizers.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 1 | ||||
| -rw-r--r-- | doc/lispref/objects.texi | 37 |
3 files changed, 39 insertions, 5 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index e7d79d55c7e..c27805b3d6e 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2015-03-03 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * objects.texi (Finalizer Type): New section for finalizer objects. | ||
| 4 | (Type Predicates): Mention finalizers in `type-of' documentation. | ||
| 5 | * elisp.texi (Top): Link to finalizer type. | ||
| 6 | |||
| 1 | 2015-03-02 Daniel Colascione <dancol@dancol.org> | 7 | 2015-03-02 Daniel Colascione <dancol@dancol.org> |
| 2 | 8 | ||
| 3 | * control.texi (Generators): New section | 9 | * control.texi (Generators): New section |
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index 3802e49ec3d..fc552be161b 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -316,6 +316,7 @@ Programming Types | |||
| 316 | * Byte-Code Type:: A function written in Lisp, then compiled. | 316 | * Byte-Code Type:: A function written in Lisp, then compiled. |
| 317 | * Autoload Type:: A type used for automatically loading seldom-used | 317 | * Autoload Type:: A type used for automatically loading seldom-used |
| 318 | functions. | 318 | functions. |
| 319 | * Finalizer Type:: Runs code when no longer reachable. | ||
| 319 | 320 | ||
| 320 | Character Type | 321 | Character Type |
| 321 | 322 | ||
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi index ba28b63f0de..b28b3b00898 100644 --- a/doc/lispref/objects.texi +++ b/doc/lispref/objects.texi | |||
| @@ -156,6 +156,8 @@ latter are unique to Emacs Lisp. | |||
| 156 | * Byte-Code Type:: A function written in Lisp, then compiled. | 156 | * Byte-Code Type:: A function written in Lisp, then compiled. |
| 157 | * Autoload Type:: A type used for automatically loading seldom-used | 157 | * Autoload Type:: A type used for automatically loading seldom-used |
| 158 | functions. | 158 | functions. |
| 159 | * Finalizer Type:: Runs code when no longer reachable. | ||
| 160 | |||
| 159 | @end menu | 161 | @end menu |
| 160 | 162 | ||
| 161 | @node Integer Type | 163 | @node Integer Type |
| @@ -1361,6 +1363,31 @@ in the loaded file. | |||
| 1361 | @code{autoload}, which stores the object in the function cell of a | 1363 | @code{autoload}, which stores the object in the function cell of a |
| 1362 | symbol. @xref{Autoload}, for more details. | 1364 | symbol. @xref{Autoload}, for more details. |
| 1363 | 1365 | ||
| 1366 | @node Finalizer Type | ||
| 1367 | @subsection Finalizer Type | ||
| 1368 | |||
| 1369 | A @dfn{finalizer object} helps Lisp code clean up after objects that | ||
| 1370 | are no longer needed. A finalizer holds a Lisp function object. | ||
| 1371 | When a finalizer object becomes unreachable after a garbage collection | ||
| 1372 | pass, Emacs calls the finalizer's associated function object. | ||
| 1373 | When deciding whether a finalizer is reachable, Emacs does not count | ||
| 1374 | references from finalizer objects themselves, allowing you to use | ||
| 1375 | finalizers without having to worry about accidentally capturing | ||
| 1376 | references to finalized objects themselves. | ||
| 1377 | |||
| 1378 | Errors in finalizers are printed to @code{*Messages*}. Emacs runs | ||
| 1379 | a given finalizer object's associated function exactly once, even | ||
| 1380 | if that function fails. | ||
| 1381 | |||
| 1382 | @defun make-finalizer function | ||
| 1383 | Make a finalizer that will run @var{function}. @var{function} will be | ||
| 1384 | called after garbage collection when the returned finalizer object | ||
| 1385 | becomes unreachable. If the finalizer object is reachable only | ||
| 1386 | through references from finalizer objects, it does not count as | ||
| 1387 | reachable for the purpose of deciding whether to run @var{function}. | ||
| 1388 | @var{function} will be run once per finalizer object. | ||
| 1389 | @end defun | ||
| 1390 | |||
| 1364 | @node Editing Types | 1391 | @node Editing Types |
| 1365 | @section Editing Types | 1392 | @section Editing Types |
| 1366 | @cindex editing types | 1393 | @cindex editing types |
| @@ -1907,11 +1934,11 @@ types. In most cases, it is more convenient to use type predicates than | |||
| 1907 | This function returns a symbol naming the primitive type of | 1934 | This function returns a symbol naming the primitive type of |
| 1908 | @var{object}. The value is one of the symbols @code{bool-vector}, | 1935 | @var{object}. The value is one of the symbols @code{bool-vector}, |
| 1909 | @code{buffer}, @code{char-table}, @code{compiled-function}, | 1936 | @code{buffer}, @code{char-table}, @code{compiled-function}, |
| 1910 | @code{cons}, @code{float}, @code{font-entity}, @code{font-object}, | 1937 | @code{cons}, @code{finalizer}, @code{float}, @code{font-entity}, |
| 1911 | @code{font-spec}, @code{frame}, @code{hash-table}, @code{integer}, | 1938 | @code{font-object}, @code{font-spec}, @code{frame}, @code{hash-table}, |
| 1912 | @code{marker}, @code{overlay}, @code{process}, @code{string}, | 1939 | @code{integer}, @code{marker}, @code{overlay}, @code{process}, |
| 1913 | @code{subr}, @code{symbol}, @code{vector}, @code{window}, or | 1940 | @code{string}, @code{subr}, @code{symbol}, @code{vector}, |
| 1914 | @code{window-configuration}. | 1941 | @code{window}, or @code{window-configuration}. |
| 1915 | 1942 | ||
| 1916 | @example | 1943 | @example |
| 1917 | (type-of 1) | 1944 | (type-of 1) |