aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref/objects.texi
diff options
context:
space:
mode:
authorChong Yidong2012-01-22 00:04:55 +0800
committerChong Yidong2012-01-22 00:04:55 +0800
commitfead402dddeefba612ab1222b392d5bd0c636400 (patch)
tree20af4be88f0e75c3a8310e223d0d971568a95409 /doc/lispref/objects.texi
parentcc6d5805ba054948ee5151e93b4b1318e2a4f5b2 (diff)
downloademacs-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.texi207
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
4282**26 4282**26
429@end ifnottex 429@end ifnottex
430bit as well as the code for the corresponding non-control 430bit as well as the code for the corresponding non-control character.
431character. Ordinary terminals have no way of generating non-@acronym{ASCII} 431Ordinary text terminals have no way of generating non-@acronym{ASCII}
432control characters, but you can generate them straightforwardly using X 432control characters, but you can generate them straightforwardly using
433and other window systems. 433X 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
436the control equivalent of @kbd{?}: 436the control equivalent of @kbd{?}:
@@ -501,10 +501,10 @@ character is upper case or lower case. Emacs uses the
501@end ifnottex 501@end ifnottex
502bit to indicate that the shift key was used in typing a control 502bit to indicate that the shift key was used in typing a control
503character. This distinction is possible only when you use X terminals 503character. This distinction is possible only when you use X terminals
504or other special terminals; ordinary terminals do not report the 504or other special terminals; ordinary text terminals do not report the
505distinction to the computer in any way. The Lisp syntax for 505distinction. The Lisp syntax for the shift bit is @samp{\S-}; thus,
506the 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
507represents the shifted-control-o character. 507character.
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,
541independently. 541independently.
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,
545are normally used only by comparing an unknown symbol with a few 545and are normally used only by comparing an unknown symbol with a few
546specific alternatives. 546specific 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
620elements. There are two kinds of sequence in Emacs Lisp, lists and 620elements. There are two kinds of sequence in Emacs Lisp: @dfn{lists}
621arrays. Thus, an object of type list or of type array is also 621and @dfn{arrays}.
622considered 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 624elements of any type, and its length can be easily changed by adding
625bool-vectors. Vectors can hold elements of any type, but string 625or removing elements. See the next subsection for more about lists.
626elements must be characters, and bool-vector elements must be @code{t} 626
627or @code{nil}. Char-tables are like vectors except that they are 627 Arrays are fixed-length sequences. They are further subdivided into
628indexed by any valid character code. The characters in a string can 628strings, vectors, char-tables and bool-vectors. Vectors can hold
629have text properties like characters in a buffer (@pxref{Text 629elements of any type, whereas string elements must be characters, and
630Properties}), but vectors do not support text properties, even when 630bool-vector elements must be @code{t} or @code{nil}. Char-tables are
631their elements happen to be characters. 631like vectors except that they are indexed by any valid character code.
632 632The characters in a string can have text properties like characters in
633 Lists, strings and the other array types are different, but they have 633a buffer (@pxref{Text Properties}), but vectors do not support text
634important similarities. For example, all have a length @var{l}, and all 634properties, even when their elements happen to be characters.
635have elements which can be indexed from zero to @var{l} minus one. 635
636Several functions, called sequence functions, accept any kind of 636 Lists, strings and the other array types also share important
637sequence. For example, the function @code{elt} can be used to extract 637similarities. For example, all have a length @var{l}, and all have
638an element of a sequence, given its index. @xref{Sequences Arrays 638elements which can be indexed from zero to @var{l} minus one. Several
639Vectors}. 639functions, called sequence functions, accept any kind of sequence.
640For example, the function @code{length} reports the length of any kind
641of 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
642sequences are always created anew upon reading. If you read the read 644sequences 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 656the @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 657Lisp object. We also say that ``the @sc{car} of this cons cell is''
656this cons cell is'' whatever object its @sc{car} slot currently holds, 658whatever object its @sc{car} slot currently holds, and likewise for
657and likewise for the @sc{cdr}. 659the @sc{cdr}.
658
659@quotation
660A note to C programmers: in Lisp, we do not distinguish between
661``holding'' a value and ``pointing to'' the value, because pointers in
662Lisp 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
667empty list. The empty list is actually the symbol @code{nil}. 664empty 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
669cells are used as part of lists, the phrase @dfn{list structure} has 666of lists, we refer to any structure made out of cons cells as a
670come to refer to any structure made out of cons cells. 667@dfn{list structure}.
668
669@cindex linked list
670@quotation
671A note to C programmers: a Lisp list thus works as a @dfn{linked list}
672built up of cons cells. Because pointers in Lisp are implicit, we do
673not 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
1029constant by writing it literally. There are two text representations 1034string constant by writing it literally. There are two text
1030for non-@acronym{ASCII} characters in Emacs strings (and in buffers): unibyte 1035representations for non-@acronym{ASCII} characters in Emacs strings
1031and multibyte. If the string constant is read from a multibyte source, 1036(and in buffers): unibyte and multibyte (@pxref{Text
1032such as a multibyte buffer or string, or a file that would be visited as 1037Representations}). If the string constant is read from a multibyte
1033multibyte, then the character is read as a multibyte character, and that 1038source, such as a multibyte buffer or string, or a file that would be
1034makes the string multibyte. If the string constant is read from a 1039visited as multibyte, then Emacs reads the non-@acronym{ASCII}
1035unibyte source, then the character is read as unibyte and that makes the 1040character as a multibyte character and automatically makes the string
1036string unibyte. 1041a multibyte string. If the string constant is read from a unibyte
1037 1042source, then Emacs reads the non-@acronym{ASCII} character as unibyte,
1038 You can also represent a multibyte non-@acronym{ASCII} character with its 1043and makes the string unibyte.
1039character code: use a hex escape, @samp{\x@var{nnnnnnn}}, with as many 1044
1040digits as necessary. (Multibyte non-@acronym{ASCII} character codes are all 1045 Instead of writing a non-@acronym{ASCII} character literally into a
1041greater than 256.) Any character which is not a valid hex digit 1046multibyte string, you can write it as its character code using a hex
1042terminates this construct. If the next character in the string could be 1047escape, @samp{\x@var{nnnnnnn}}, with as many digits as necessary.
1043interpreted as a hex digit, write @w{@samp{\ }} (backslash and space) to 1048(Multibyte non-@acronym{ASCII} character codes are all greater than
1044terminate the hex escape---for example, @w{@samp{\xe0\ }} represents 1049256.) You can also specify a character in a multibyte string using
1045one character, @samp{a} with grave accent. @w{@samp{\ }} in a string 1050the @samp{\u} or @samp{\U} Unicode escape syntax (@pxref{General
1046constant is just like backslash-newline; it does not contribute any 1051Escape Syntax}). In either case, any character which is not a valid
1047character to the string, but it does terminate the preceding hex escape. 1052hex digit terminates the construct. If the next character in the
1053string 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
1056accent. @w{@samp{\ }} in a string constant is just like
1057backslash-newline; it does not contribute any character to the string,
1058but it does terminate the preceding hex escape. Using any hex escape
1059in a string (even for an @acronym{ASCII} character) automatically
1060forces 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
1050character code, which must be in the range from 128 (0200 octal) to 1063character code, which must be in the range from 128 (0200 octal) to
1051255 (0377 octal). If you write all such character codes in octal and 1064255 (0377 octal). If you write all such character codes in octal and
1052the string contains no other characters forcing it to be multibyte, 1065the string contains no other characters forcing it to be multibyte,
1053this produces a unibyte string. However, using any hex escape in a 1066this produces a unibyte string.
1054string (even for an @acronym{ASCII} character) forces the string to be
1055multibyte.
1056
1057 You can also specify characters in a string by their numeric values
1058in Unicode, using @samp{\u} and @samp{\U} (@pxref{Character Type}).
1059
1060 @xref{Text Representations}, for more information about the two
1061text 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
1926objects. Other functions test equality of contents between objects of specific 1931objects. Other functions test equality of contents between objects of
1927types, e.g., strings. For these predicates, see the appropriate chapter 1932specific types, e.g.@: strings. For these predicates, see the
1928describing the data type. 1933appropriate chapter describing the data type.
1929 1934
1930@defun eq object1 object2 1935@defun eq object1 object2
1931This function returns @code{t} if @var{object1} and @var{object2} are 1936This function returns @code{t} if @var{object1} and @var{object2} are
1932the same object, @code{nil} otherwise. 1937the same object, and @code{nil} otherwise.
1933 1938
1934@code{eq} returns @code{t} if @var{object1} and @var{object2} are 1939If @var{object1} and @var{object2} are integers with the same value,
1935integers with the same value. Also, since symbol names are normally 1940they are considered to be the same object (i.e.@: @code{eq} returns
1936unique, 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 1942same name, they are normally the same object---but see @ref{Creating
1938arguments with the same contents or elements are not necessarily 1943Symbols} 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 1944strings), two arguments with the same contents or elements are not
1940object, meaning that a change in the contents of one will be reflected 1945necessarily @code{eq} to each other: they are @code{eq} only if they
1941by the same change in the contents of the other. 1946are the same object, meaning that a change in the contents of one will
1947be 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
1991The @code{make-symbol} function returns an uninterned symbol, distinct 1998The @code{make-symbol} function returns an uninterned symbol, distinct
1992from the symbol that is used if you write the name in a Lisp expression. 1999from the symbol that is used if you write the name in a Lisp expression.
1993Distinct symbols with the same name are not @code{eq}. @xref{Creating 2000Distinct 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
2005This function returns @code{t} if @var{object1} and @var{object2} have 2012This function returns @code{t} if @var{object1} and @var{object2} have
2006equal components, @code{nil} otherwise. Whereas @code{eq} tests if its 2013equal components, and @code{nil} otherwise. Whereas @code{eq} tests
2007arguments are the same object, @code{equal} looks inside nonidentical 2014if its arguments are the same object, @code{equal} looks inside
2008arguments to see if their elements or contents are the same. So, if two 2015nonidentical arguments to see if their elements or contents are the
2009objects are @code{eq}, they are @code{equal}, but the converse is not 2016same. So, if two objects are @code{eq}, they are @code{equal}, but
2010always true. 2017the 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
2061Comparison of strings is case-sensitive, but does not take account of 2068Comparison of strings is case-sensitive, but does not take account of
2062text properties---it compares only the characters in the strings. Use 2069text 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
2064technical reasons, a unibyte string and a multibyte string are 2071compare text properties. For technical reasons, a unibyte string and
2065@code{equal} if and only if they contain the same sequence of 2072a multibyte string are @code{equal} if and only if they contain the
2066character codes and all these codes are either in the range 0 through 2073same sequence of character codes and all these codes are either in the
2067127 (@acronym{ASCII}) or 160 through 255 (@code{eight-bit-graphic}). 2074range 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