diff options
| author | Chong Yidong | 2012-01-22 00:04:55 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-01-22 00:04:55 +0800 |
| commit | fead402dddeefba612ab1222b392d5bd0c636400 (patch) | |
| tree | 20af4be88f0e75c3a8310e223d0d971568a95409 /doc/lispref/objects.texi | |
| parent | cc6d5805ba054948ee5151e93b4b1318e2a4f5b2 (diff) | |
| download | emacs-fead402dddeefba612ab1222b392d5bd0c636400.tar.gz emacs-fead402dddeefba612ab1222b392d5bd0c636400.zip | |
Emacs Lisp manual updates.
* doc/lispref/intro.texi (A Sample Function Description): Special notation
used for macros too.
* doc/lispref/objects.texi (Ctl-Char Syntax, Other Char Bits): Copyedits.
(Symbol Type): Add xref for keyword symbols.
(Sequence Type): Clarify differences between sequence types.
(Cons Cell Type): Add "linked list" index entry.
(Non-ASCII in Strings): Copyedits.
(Equality Predicates): Symbols with same name need not be eq.
* doc/lispref/numbers.texi (Float Basics): Document isnan, copysign, frexp and
ldexp. Move float-e and float-pi to Math Functions node.
Diffstat (limited to 'doc/lispref/objects.texi')
| -rw-r--r-- | doc/lispref/objects.texi | 207 |
1 files changed, 107 insertions, 100 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi index 3fb676edcd4..87bcc20daba 100644 --- a/doc/lispref/objects.texi +++ b/doc/lispref/objects.texi | |||
| @@ -427,10 +427,10 @@ codes for these non-@acronym{ASCII} control characters include the | |||
| 427 | @ifnottex | 427 | @ifnottex |
| 428 | 2**26 | 428 | 2**26 |
| 429 | @end ifnottex | 429 | @end ifnottex |
| 430 | bit as well as the code for the corresponding non-control | 430 | bit as well as the code for the corresponding non-control character. |
| 431 | character. Ordinary terminals have no way of generating non-@acronym{ASCII} | 431 | Ordinary text terminals have no way of generating non-@acronym{ASCII} |
| 432 | control characters, but you can generate them straightforwardly using X | 432 | control characters, but you can generate them straightforwardly using |
| 433 | and other window systems. | 433 | X and other window systems. |
| 434 | 434 | ||
| 435 | For historical reasons, Emacs treats the @key{DEL} character as | 435 | For historical reasons, Emacs treats the @key{DEL} character as |
| 436 | the control equivalent of @kbd{?}: | 436 | the control equivalent of @kbd{?}: |
| @@ -501,10 +501,10 @@ character is upper case or lower case. Emacs uses the | |||
| 501 | @end ifnottex | 501 | @end ifnottex |
| 502 | bit to indicate that the shift key was used in typing a control | 502 | bit to indicate that the shift key was used in typing a control |
| 503 | character. This distinction is possible only when you use X terminals | 503 | character. This distinction is possible only when you use X terminals |
| 504 | or other special terminals; ordinary terminals do not report the | 504 | or other special terminals; ordinary text terminals do not report the |
| 505 | distinction to the computer in any way. The Lisp syntax for | 505 | distinction. The Lisp syntax for the shift bit is @samp{\S-}; thus, |
| 506 | the shift bit is @samp{\S-}; thus, @samp{?\C-\S-o} or @samp{?\C-\S-O} | 506 | @samp{?\C-\S-o} or @samp{?\C-\S-O} represents the shifted-control-o |
| 507 | represents the shifted-control-o character. | 507 | character. |
| 508 | 508 | ||
| 509 | @cindex hyper characters | 509 | @cindex hyper characters |
| 510 | @cindex super characters | 510 | @cindex super characters |
| @@ -541,9 +541,9 @@ intended. But you can use one symbol in all of these ways, | |||
| 541 | independently. | 541 | independently. |
| 542 | 542 | ||
| 543 | A symbol whose name starts with a colon (@samp{:}) is called a | 543 | A symbol whose name starts with a colon (@samp{:}) is called a |
| 544 | @dfn{keyword symbol}. These symbols automatically act as constants, and | 544 | @dfn{keyword symbol}. These symbols automatically act as constants, |
| 545 | are normally used only by comparing an unknown symbol with a few | 545 | and are normally used only by comparing an unknown symbol with a few |
| 546 | specific alternatives. | 546 | specific alternatives. @xref{Constant Variables}. |
| 547 | 547 | ||
| 548 | @cindex @samp{\} in symbols | 548 | @cindex @samp{\} in symbols |
| 549 | @cindex backslash in symbols | 549 | @cindex backslash in symbols |
| @@ -617,26 +617,28 @@ all symbols; @pxref{Creating Symbols}.) | |||
| 617 | @subsection Sequence Types | 617 | @subsection Sequence Types |
| 618 | 618 | ||
| 619 | A @dfn{sequence} is a Lisp object that represents an ordered set of | 619 | A @dfn{sequence} is a Lisp object that represents an ordered set of |
| 620 | elements. There are two kinds of sequence in Emacs Lisp, lists and | 620 | elements. There are two kinds of sequence in Emacs Lisp: @dfn{lists} |
| 621 | arrays. Thus, an object of type list or of type array is also | 621 | and @dfn{arrays}. |
| 622 | considered a sequence. | 622 | |
| 623 | 623 | Lists are the most commonly-used sequences. A list can hold | |
| 624 | Arrays are further subdivided into strings, vectors, char-tables and | 624 | elements of any type, and its length can be easily changed by adding |
| 625 | bool-vectors. Vectors can hold elements of any type, but string | 625 | or removing elements. See the next subsection for more about lists. |
| 626 | elements must be characters, and bool-vector elements must be @code{t} | 626 | |
| 627 | or @code{nil}. Char-tables are like vectors except that they are | 627 | Arrays are fixed-length sequences. They are further subdivided into |
| 628 | indexed by any valid character code. The characters in a string can | 628 | strings, vectors, char-tables and bool-vectors. Vectors can hold |
| 629 | have text properties like characters in a buffer (@pxref{Text | 629 | elements of any type, whereas string elements must be characters, and |
| 630 | Properties}), but vectors do not support text properties, even when | 630 | bool-vector elements must be @code{t} or @code{nil}. Char-tables are |
| 631 | their elements happen to be characters. | 631 | like vectors except that they are indexed by any valid character code. |
| 632 | 632 | The characters in a string can have text properties like characters in | |
| 633 | Lists, strings and the other array types are different, but they have | 633 | a buffer (@pxref{Text Properties}), but vectors do not support text |
| 634 | important similarities. For example, all have a length @var{l}, and all | 634 | properties, even when their elements happen to be characters. |
| 635 | have elements which can be indexed from zero to @var{l} minus one. | 635 | |
| 636 | Several functions, called sequence functions, accept any kind of | 636 | Lists, strings and the other array types also share important |
| 637 | sequence. For example, the function @code{elt} can be used to extract | 637 | similarities. For example, all have a length @var{l}, and all have |
| 638 | an element of a sequence, given its index. @xref{Sequences Arrays | 638 | elements which can be indexed from zero to @var{l} minus one. Several |
| 639 | Vectors}. | 639 | functions, called sequence functions, accept any kind of sequence. |
| 640 | For example, the function @code{length} reports the length of any kind | ||
| 641 | of sequence. @xref{Sequences Arrays Vectors}. | ||
| 640 | 642 | ||
| 641 | It is generally impossible to read the same sequence twice, since | 643 | It is generally impossible to read the same sequence twice, since |
| 642 | sequences are always created anew upon reading. If you read the read | 644 | sequences are always created anew upon reading. If you read the read |
| @@ -650,24 +652,27 @@ same object, @code{nil}. | |||
| 650 | @cindex decrement field of register | 652 | @cindex decrement field of register |
| 651 | @cindex pointers | 653 | @cindex pointers |
| 652 | 654 | ||
| 653 | A @dfn{cons cell} is an object that consists of two slots, called the | 655 | A @dfn{cons cell} is an object that consists of two slots, called |
| 654 | @sc{car} slot and the @sc{cdr} slot. Each slot can @dfn{hold} or | 656 | the @sc{car} slot and the @sc{cdr} slot. Each slot can @dfn{hold} any |
| 655 | @dfn{refer to} any Lisp object. We also say that ``the @sc{car} of | 657 | Lisp object. We also say that ``the @sc{car} of this cons cell is'' |
| 656 | this cons cell is'' whatever object its @sc{car} slot currently holds, | 658 | whatever object its @sc{car} slot currently holds, and likewise for |
| 657 | and likewise for the @sc{cdr}. | 659 | the @sc{cdr}. |
| 658 | |||
| 659 | @quotation | ||
| 660 | A note to C programmers: in Lisp, we do not distinguish between | ||
| 661 | ``holding'' a value and ``pointing to'' the value, because pointers in | ||
| 662 | Lisp are implicit. | ||
| 663 | @end quotation | ||
| 664 | 660 | ||
| 661 | @cindex list structure | ||
| 665 | A @dfn{list} is a series of cons cells, linked together so that the | 662 | A @dfn{list} is a series of cons cells, linked together so that the |
| 666 | @sc{cdr} slot of each cons cell holds either the next cons cell or the | 663 | @sc{cdr} slot of each cons cell holds either the next cons cell or the |
| 667 | empty list. The empty list is actually the symbol @code{nil}. | 664 | empty list. The empty list is actually the symbol @code{nil}. |
| 668 | @xref{Lists}, for functions that work on lists. Because most cons | 665 | @xref{Lists}, for details. Because most cons cells are used as part |
| 669 | cells are used as part of lists, the phrase @dfn{list structure} has | 666 | of lists, we refer to any structure made out of cons cells as a |
| 670 | come to refer to any structure made out of cons cells. | 667 | @dfn{list structure}. |
| 668 | |||
| 669 | @cindex linked list | ||
| 670 | @quotation | ||
| 671 | A note to C programmers: a Lisp list thus works as a @dfn{linked list} | ||
| 672 | built up of cons cells. Because pointers in Lisp are implicit, we do | ||
| 673 | not distinguish between a cons cell slot ``holding'' a value versus | ||
| 674 | ``pointing to'' the value. | ||
| 675 | @end quotation | ||
| 671 | 676 | ||
| 672 | @cindex atoms | 677 | @cindex atoms |
| 673 | Because cons cells are so central to Lisp, we also have a word for | 678 | Because cons cells are so central to Lisp, we also have a word for |
| @@ -1025,40 +1030,40 @@ but the newline is ignored if escaped." | |||
| 1025 | @node Non-ASCII in Strings | 1030 | @node Non-ASCII in Strings |
| 1026 | @subsubsection Non-@acronym{ASCII} Characters in Strings | 1031 | @subsubsection Non-@acronym{ASCII} Characters in Strings |
| 1027 | 1032 | ||
| 1028 | You can include a non-@acronym{ASCII} international character in a string | 1033 | You can include a non-@acronym{ASCII} international character in a |
| 1029 | constant by writing it literally. There are two text representations | 1034 | string constant by writing it literally. There are two text |
| 1030 | for non-@acronym{ASCII} characters in Emacs strings (and in buffers): unibyte | 1035 | representations for non-@acronym{ASCII} characters in Emacs strings |
| 1031 | and multibyte. If the string constant is read from a multibyte source, | 1036 | (and in buffers): unibyte and multibyte (@pxref{Text |
| 1032 | such as a multibyte buffer or string, or a file that would be visited as | 1037 | Representations}). If the string constant is read from a multibyte |
| 1033 | multibyte, then the character is read as a multibyte character, and that | 1038 | source, such as a multibyte buffer or string, or a file that would be |
| 1034 | makes the string multibyte. If the string constant is read from a | 1039 | visited as multibyte, then Emacs reads the non-@acronym{ASCII} |
| 1035 | unibyte source, then the character is read as unibyte and that makes the | 1040 | character as a multibyte character and automatically makes the string |
| 1036 | string unibyte. | 1041 | a multibyte string. If the string constant is read from a unibyte |
| 1037 | 1042 | source, then Emacs reads the non-@acronym{ASCII} character as unibyte, | |
| 1038 | You can also represent a multibyte non-@acronym{ASCII} character with its | 1043 | and makes the string unibyte. |
| 1039 | character code: use a hex escape, @samp{\x@var{nnnnnnn}}, with as many | 1044 | |
| 1040 | digits as necessary. (Multibyte non-@acronym{ASCII} character codes are all | 1045 | Instead of writing a non-@acronym{ASCII} character literally into a |
| 1041 | greater than 256.) Any character which is not a valid hex digit | 1046 | multibyte string, you can write it as its character code using a hex |
| 1042 | terminates this construct. If the next character in the string could be | 1047 | escape, @samp{\x@var{nnnnnnn}}, with as many digits as necessary. |
| 1043 | interpreted as a hex digit, write @w{@samp{\ }} (backslash and space) to | 1048 | (Multibyte non-@acronym{ASCII} character codes are all greater than |
| 1044 | terminate the hex escape---for example, @w{@samp{\xe0\ }} represents | 1049 | 256.) You can also specify a character in a multibyte string using |
| 1045 | one character, @samp{a} with grave accent. @w{@samp{\ }} in a string | 1050 | the @samp{\u} or @samp{\U} Unicode escape syntax (@pxref{General |
| 1046 | constant is just like backslash-newline; it does not contribute any | 1051 | Escape Syntax}). In either case, any character which is not a valid |
| 1047 | character to the string, but it does terminate the preceding hex escape. | 1052 | hex digit terminates the construct. If the next character in the |
| 1053 | string could be interpreted as a hex digit, write @w{@samp{\ }} | ||
| 1054 | (backslash and space) to terminate the hex escape---for example, | ||
| 1055 | @w{@samp{\xe0\ }} represents one character, @samp{a} with grave | ||
| 1056 | accent. @w{@samp{\ }} in a string constant is just like | ||
| 1057 | backslash-newline; it does not contribute any character to the string, | ||
| 1058 | but it does terminate the preceding hex escape. Using any hex escape | ||
| 1059 | in a string (even for an @acronym{ASCII} character) automatically | ||
| 1060 | forces the string to be multibyte. | ||
| 1048 | 1061 | ||
| 1049 | You can represent a unibyte non-@acronym{ASCII} character with its | 1062 | You can represent a unibyte non-@acronym{ASCII} character with its |
| 1050 | character code, which must be in the range from 128 (0200 octal) to | 1063 | character code, which must be in the range from 128 (0200 octal) to |
| 1051 | 255 (0377 octal). If you write all such character codes in octal and | 1064 | 255 (0377 octal). If you write all such character codes in octal and |
| 1052 | the string contains no other characters forcing it to be multibyte, | 1065 | the string contains no other characters forcing it to be multibyte, |
| 1053 | this produces a unibyte string. However, using any hex escape in a | 1066 | this produces a unibyte string. |
| 1054 | string (even for an @acronym{ASCII} character) forces the string to be | ||
| 1055 | multibyte. | ||
| 1056 | |||
| 1057 | You can also specify characters in a string by their numeric values | ||
| 1058 | in Unicode, using @samp{\u} and @samp{\U} (@pxref{Character Type}). | ||
| 1059 | |||
| 1060 | @xref{Text Representations}, for more information about the two | ||
| 1061 | text representations. | ||
| 1062 | 1067 | ||
| 1063 | @node Nonprinting Characters | 1068 | @node Nonprinting Characters |
| 1064 | @subsubsection Nonprinting Characters in Strings | 1069 | @subsubsection Nonprinting Characters in Strings |
| @@ -1922,23 +1927,24 @@ This function returns a symbol naming the primitive type of | |||
| 1922 | @section Equality Predicates | 1927 | @section Equality Predicates |
| 1923 | @cindex equality | 1928 | @cindex equality |
| 1924 | 1929 | ||
| 1925 | Here we describe functions that test for equality between any two | 1930 | Here we describe functions that test for equality between two |
| 1926 | objects. Other functions test equality of contents between objects of specific | 1931 | objects. Other functions test equality of contents between objects of |
| 1927 | types, e.g., strings. For these predicates, see the appropriate chapter | 1932 | specific types, e.g.@: strings. For these predicates, see the |
| 1928 | describing the data type. | 1933 | appropriate chapter describing the data type. |
| 1929 | 1934 | ||
| 1930 | @defun eq object1 object2 | 1935 | @defun eq object1 object2 |
| 1931 | This function returns @code{t} if @var{object1} and @var{object2} are | 1936 | This function returns @code{t} if @var{object1} and @var{object2} are |
| 1932 | the same object, @code{nil} otherwise. | 1937 | the same object, and @code{nil} otherwise. |
| 1933 | 1938 | ||
| 1934 | @code{eq} returns @code{t} if @var{object1} and @var{object2} are | 1939 | If @var{object1} and @var{object2} are integers with the same value, |
| 1935 | integers with the same value. Also, since symbol names are normally | 1940 | they are considered to be the same object (i.e.@: @code{eq} returns |
| 1936 | unique, if the arguments are symbols with the same name, they are | 1941 | @code{t}). If @var{object1} and @var{object2} are symbols with the |
| 1937 | @code{eq}. For other types (e.g., lists, vectors, strings), two | 1942 | same name, they are normally the same object---but see @ref{Creating |
| 1938 | arguments with the same contents or elements are not necessarily | 1943 | Symbols} for exceptions. For other types (e.g.@: lists, vectors, |
| 1939 | @code{eq} to each other: they are @code{eq} only if they are the same | 1944 | strings), two arguments with the same contents or elements are not |
| 1940 | object, meaning that a change in the contents of one will be reflected | 1945 | necessarily @code{eq} to each other: they are @code{eq} only if they |
| 1941 | by the same change in the contents of the other. | 1946 | are the same object, meaning that a change in the contents of one will |
| 1947 | be reflected by the same change in the contents of the other. | ||
| 1942 | 1948 | ||
| 1943 | @example | 1949 | @example |
| 1944 | @group | 1950 | @group |
| @@ -1988,6 +1994,7 @@ by the same change in the contents of the other. | |||
| 1988 | @end group | 1994 | @end group |
| 1989 | @end example | 1995 | @end example |
| 1990 | 1996 | ||
| 1997 | @noindent | ||
| 1991 | The @code{make-symbol} function returns an uninterned symbol, distinct | 1998 | The @code{make-symbol} function returns an uninterned symbol, distinct |
| 1992 | from the symbol that is used if you write the name in a Lisp expression. | 1999 | from the symbol that is used if you write the name in a Lisp expression. |
| 1993 | Distinct symbols with the same name are not @code{eq}. @xref{Creating | 2000 | Distinct symbols with the same name are not @code{eq}. @xref{Creating |
| @@ -2003,11 +2010,11 @@ Symbols}. | |||
| 2003 | 2010 | ||
| 2004 | @defun equal object1 object2 | 2011 | @defun equal object1 object2 |
| 2005 | This function returns @code{t} if @var{object1} and @var{object2} have | 2012 | This function returns @code{t} if @var{object1} and @var{object2} have |
| 2006 | equal components, @code{nil} otherwise. Whereas @code{eq} tests if its | 2013 | equal components, and @code{nil} otherwise. Whereas @code{eq} tests |
| 2007 | arguments are the same object, @code{equal} looks inside nonidentical | 2014 | if its arguments are the same object, @code{equal} looks inside |
| 2008 | arguments to see if their elements or contents are the same. So, if two | 2015 | nonidentical arguments to see if their elements or contents are the |
| 2009 | objects are @code{eq}, they are @code{equal}, but the converse is not | 2016 | same. So, if two objects are @code{eq}, they are @code{equal}, but |
| 2010 | always true. | 2017 | the converse is not always true. |
| 2011 | 2018 | ||
| 2012 | @example | 2019 | @example |
| 2013 | @group | 2020 | @group |
| @@ -2059,13 +2066,13 @@ always true. | |||
| 2059 | @end example | 2066 | @end example |
| 2060 | 2067 | ||
| 2061 | Comparison of strings is case-sensitive, but does not take account of | 2068 | Comparison of strings is case-sensitive, but does not take account of |
| 2062 | text properties---it compares only the characters in the strings. Use | 2069 | text properties---it compares only the characters in the strings. |
| 2063 | @code{equal-including-properties} to also compare text properties. For | 2070 | @xref{Text Properties}. Use @code{equal-including-properties} to also |
| 2064 | technical reasons, a unibyte string and a multibyte string are | 2071 | compare text properties. For technical reasons, a unibyte string and |
| 2065 | @code{equal} if and only if they contain the same sequence of | 2072 | a multibyte string are @code{equal} if and only if they contain the |
| 2066 | character codes and all these codes are either in the range 0 through | 2073 | same sequence of character codes and all these codes are either in the |
| 2067 | 127 (@acronym{ASCII}) or 160 through 255 (@code{eight-bit-graphic}). | 2074 | range 0 through 127 (@acronym{ASCII}) or 160 through 255 |
| 2068 | (@pxref{Text Representations}). | 2075 | (@code{eight-bit-graphic}). (@pxref{Text Representations}). |
| 2069 | 2076 | ||
| 2070 | @example | 2077 | @example |
| 2071 | @group | 2078 | @group |