diff options
| author | Richard M. Stallman | 1998-04-20 17:43:57 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-20 17:43:57 +0000 |
| commit | 969fe9b5696c9d9d31f2faf1ca2e8af107013dcb (patch) | |
| tree | 5d7d0399caf410b5c4849aa9d43352b18f68d4c9 /lispref/objects.texi | |
| parent | b933f645ac70a31659f364cabf7da730d27eb244 (diff) | |
| download | emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.tar.gz emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.zip | |
*** empty log message ***
Diffstat (limited to 'lispref/objects.texi')
| -rw-r--r-- | lispref/objects.texi | 335 |
1 files changed, 187 insertions, 148 deletions
diff --git a/lispref/objects.texi b/lispref/objects.texi index 66734920de9..ea1e8fb1632 100644 --- a/lispref/objects.texi +++ b/lispref/objects.texi | |||
| @@ -25,7 +25,7 @@ but not for ``the'' type of an object. | |||
| 25 | which all other types are constructed, are called @dfn{primitive | 25 | which all other types are constructed, are called @dfn{primitive |
| 26 | types}. Each object belongs to one and only one primitive type. These | 26 | types}. Each object belongs to one and only one primitive type. These |
| 27 | types include @dfn{integer}, @dfn{float}, @dfn{cons}, @dfn{symbol}, | 27 | types include @dfn{integer}, @dfn{float}, @dfn{cons}, @dfn{symbol}, |
| 28 | @dfn{string}, @dfn{vector}, @dfn{subr}, @dfn{byte-code function}, and | 28 | @dfn{string}, @dfn{vector}, @dfn{subr}, @dfn{byte-code function}, plus |
| 29 | several special types, such as @dfn{buffer}, that are related to | 29 | several special types, such as @dfn{buffer}, that are related to |
| 30 | editing. (@xref{Editing Types}.) | 30 | editing. (@xref{Editing Types}.) |
| 31 | 31 | ||
| @@ -69,8 +69,9 @@ input accepted by the Lisp reader (the function @code{read}) for that | |||
| 69 | object. @xref{Read and Print}. | 69 | object. @xref{Read and Print}. |
| 70 | 70 | ||
| 71 | Most objects have more than one possible read syntax. Some types of | 71 | Most objects have more than one possible read syntax. Some types of |
| 72 | object have no read syntax; except for these cases, the printed | 72 | object have no read syntax, since it may not make sense to enter objects |
| 73 | representation of an object is also a read syntax for it. | 73 | of these types directly in a Lisp program. Except for these cases, the |
| 74 | printed representation of an object is also a read syntax for it. | ||
| 74 | 75 | ||
| 75 | In other languages, an expression is text; it has no other form. In | 76 | In other languages, an expression is text; it has no other form. In |
| 76 | Lisp, an expression is primarily a Lisp object and only secondarily the | 77 | Lisp, an expression is primarily a Lisp object and only secondarily the |
| @@ -80,14 +81,12 @@ mind, or you will occasionally be very confused. | |||
| 80 | 81 | ||
| 81 | @cindex hash notation | 82 | @cindex hash notation |
| 82 | Every type has a printed representation. Some types have no read | 83 | Every type has a printed representation. Some types have no read |
| 83 | syntax, since it may not make sense to enter objects of these types | 84 | syntax---for example, the buffer type has none. Objects of these types |
| 84 | directly in a Lisp program. For example, the buffer type does not have | 85 | are printed in @dfn{hash notation}: the characters @samp{#<} followed by |
| 85 | a read syntax. Objects of these types are printed in @dfn{hash | 86 | a descriptive string (typically the type name followed by the name of |
| 86 | notation}: the characters @samp{#<} followed by a descriptive string | 87 | the object), and closed with a matching @samp{>}. Hash notation cannot |
| 87 | (typically the type name followed by the name of the object), and closed | 88 | be read at all, so the Lisp reader signals the error |
| 88 | with a matching @samp{>}. Hash notation cannot be read at all, so the | 89 | @code{invalid-read-syntax} whenever it encounters @samp{#<}. |
| 89 | Lisp reader signals the error @code{invalid-read-syntax} whenever it | ||
| 90 | encounters @samp{#<}. | ||
| 91 | @kindex invalid-read-syntax | 90 | @kindex invalid-read-syntax |
| 92 | 91 | ||
| 93 | @example | 92 | @example |
| @@ -190,8 +189,7 @@ leading @samp{+} or a final @samp{.}. | |||
| 190 | 1 ; @r{The integer 1.} | 189 | 1 ; @r{The integer 1.} |
| 191 | 1. ; @r{Also The integer 1.} | 190 | 1. ; @r{Also The integer 1.} |
| 192 | +1 ; @r{Also the integer 1.} | 191 | +1 ; @r{Also the integer 1.} |
| 193 | 268435457 ; @r{Also the integer 1!} | 192 | 268435457 ; @r{Also the integer 1 on a 28-bit implementation.} |
| 194 | ; @r{ (on a 28-bit implementation)} | ||
| 195 | @end group | 193 | @end group |
| 196 | @end example | 194 | @end example |
| 197 | 195 | ||
| @@ -226,9 +224,10 @@ characters. @xref{String Type}. | |||
| 226 | 224 | ||
| 227 | Characters in strings, buffers, and files are currently limited to the | 225 | Characters in strings, buffers, and files are currently limited to the |
| 228 | range of 0 to 524287---nineteen bits. But not all values in that range | 226 | range of 0 to 524287---nineteen bits. But not all values in that range |
| 229 | are valid character codes. Characters that represent keyboard input | 227 | are valid character codes. Codes 0 through 127 are ASCII codes; the |
| 230 | have a much wider range, so they can modifier keys such as Control, Meta | 228 | rest are non-ASCII (@pxref{Non-ASCII Characters}). Characters that represent |
| 231 | and Shift. | 229 | keyboard input have a much wider range, to encode modifier keys such as |
| 230 | Control, Meta and Shift. | ||
| 232 | 231 | ||
| 233 | @cindex read syntax for characters | 232 | @cindex read syntax for characters |
| 234 | @cindex printed representation for characters | 233 | @cindex printed representation for characters |
| @@ -283,7 +282,7 @@ respectively. Thus, | |||
| 283 | ?\a @result{} 7 ; @r{@kbd{C-g}} | 282 | ?\a @result{} 7 ; @r{@kbd{C-g}} |
| 284 | ?\b @result{} 8 ; @r{backspace, @key{BS}, @kbd{C-h}} | 283 | ?\b @result{} 8 ; @r{backspace, @key{BS}, @kbd{C-h}} |
| 285 | ?\t @result{} 9 ; @r{tab, @key{TAB}, @kbd{C-i}} | 284 | ?\t @result{} 9 ; @r{tab, @key{TAB}, @kbd{C-i}} |
| 286 | ?\n @result{} 10 ; @r{newline, @key{LFD}, @kbd{C-j}} | 285 | ?\n @result{} 10 ; @r{newline, @kbd{C-j}} |
| 287 | ?\v @result{} 11 ; @r{vertical tab, @kbd{C-k}} | 286 | ?\v @result{} 11 ; @r{vertical tab, @kbd{C-k}} |
| 288 | ?\f @result{} 12 ; @r{formfeed character, @kbd{C-l}} | 287 | ?\f @result{} 12 ; @r{formfeed character, @kbd{C-l}} |
| 289 | ?\r @result{} 13 ; @r{carriage return, @key{RET}, @kbd{C-m}} | 288 | ?\r @result{} 13 ; @r{carriage return, @key{RET}, @kbd{C-m}} |
| @@ -314,9 +313,9 @@ equivalent to @samp{?\^I} and to @samp{?\^i}: | |||
| 314 | that exist in @sc{ASCII}; but for keyboard input purposes, you can turn | 313 | that exist in @sc{ASCII}; but for keyboard input purposes, you can turn |
| 315 | any character into a control character with @samp{C-}. The character | 314 | any character into a control character with @samp{C-}. The character |
| 316 | codes for these non-@sc{ASCII} control characters include the | 315 | codes for these non-@sc{ASCII} control characters include the |
| 317 | @iftex | 316 | @tex |
| 318 | $2^{26}$ | 317 | $2^{26}$ |
| 319 | @end iftex | 318 | @end tex |
| 320 | @ifinfo | 319 | @ifinfo |
| 321 | 2**26 | 320 | 2**26 |
| 322 | @end ifinfo | 321 | @end ifinfo |
| @@ -334,21 +333,22 @@ the control equivalent of @kbd{?}: | |||
| 334 | 333 | ||
| 335 | @noindent | 334 | @noindent |
| 336 | As a result, it is currently not possible to represent the character | 335 | As a result, it is currently not possible to represent the character |
| 337 | @kbd{Control-?}, which is a meaningful input character under X. It is | 336 | @kbd{Control-?}, which is a meaningful input character under X, using |
| 338 | not easy to change this as various Lisp files refer to @key{DEL} in this | 337 | @samp{\C-}. It is not easy to change this, as various Lisp files refer |
| 339 | way. | 338 | to @key{DEL} in this way. |
| 340 | 339 | ||
| 341 | For representing control characters to be found in files or strings, | 340 | For representing control characters to be found in files or strings, |
| 342 | we recommend the @samp{^} syntax; for control characters in keyboard | 341 | we recommend the @samp{^} syntax; for control characters in keyboard |
| 343 | input, we prefer the @samp{C-} syntax. This does not affect the meaning | 342 | input, we prefer the @samp{C-} syntax. Which one you use does not |
| 344 | of the program, but may guide the understanding of people who read it. | 343 | affect the meaning of the program, but may guide the understanding of |
| 344 | people who read it. | ||
| 345 | 345 | ||
| 346 | @cindex meta characters | 346 | @cindex meta characters |
| 347 | A @dfn{meta character} is a character typed with the @key{META} | 347 | A @dfn{meta character} is a character typed with the @key{META} |
| 348 | modifier key. The integer that represents such a character has the | 348 | modifier key. The integer that represents such a character has the |
| 349 | @iftex | 349 | @tex |
| 350 | $2^{27}$ | 350 | $2^{27}$ |
| 351 | @end iftex | 351 | @end tex |
| 352 | @ifinfo | 352 | @ifinfo |
| 353 | 2**27 | 353 | 2**27 |
| 354 | @end ifinfo | 354 | @end ifinfo |
| @@ -357,9 +357,9 @@ use high bits for this and other modifiers to make possible a wide range | |||
| 357 | of basic character codes. | 357 | of basic character codes. |
| 358 | 358 | ||
| 359 | In a string, the | 359 | In a string, the |
| 360 | @iftex | 360 | @tex |
| 361 | $2^{7}$ | 361 | $2^{7}$ |
| 362 | @end iftex | 362 | @end tex |
| 363 | @ifinfo | 363 | @ifinfo |
| 364 | 2**7 | 364 | 2**7 |
| 365 | @end ifinfo | 365 | @end ifinfo |
| @@ -380,15 +380,15 @@ or as @samp{?\M-\101}. Likewise, you can write @kbd{C-M-b} as | |||
| 380 | for example, @sc{ASCII} distinguishes between the characters @samp{a} | 380 | for example, @sc{ASCII} distinguishes between the characters @samp{a} |
| 381 | and @samp{A}. But @sc{ASCII} has no way to represent whether a control | 381 | and @samp{A}. But @sc{ASCII} has no way to represent whether a control |
| 382 | character is upper case or lower case. Emacs uses the | 382 | character is upper case or lower case. Emacs uses the |
| 383 | @iftex | 383 | @tex |
| 384 | $2^{25}$ | 384 | $2^{25}$ |
| 385 | @end iftex | 385 | @end tex |
| 386 | @ifinfo | 386 | @ifinfo |
| 387 | 2**25 | 387 | 2**25 |
| 388 | @end ifinfo | 388 | @end ifinfo |
| 389 | bit to indicate that the shift key was used for typing a control | 389 | bit to indicate that the shift key was used in typing a control |
| 390 | character. This distinction is possible only when you use X terminals | 390 | character. This distinction is possible only when you use X terminals |
| 391 | or other special terminals; ordinary terminals do not indicate the | 391 | or other special terminals; ordinary terminals do not report the |
| 392 | distinction to the computer in any way. | 392 | distinction to the computer in any way. |
| 393 | 393 | ||
| 394 | @cindex hyper characters | 394 | @cindex hyper characters |
| @@ -398,10 +398,10 @@ distinction to the computer in any way. | |||
| 398 | in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes | 398 | in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes |
| 399 | for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}. Thus, | 399 | for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}. Thus, |
| 400 | @samp{?\H-\M-\A-x} represents @kbd{Alt-Hyper-Meta-x}. | 400 | @samp{?\H-\M-\A-x} represents @kbd{Alt-Hyper-Meta-x}. |
| 401 | @iftex | 401 | @tex |
| 402 | Numerically, the | 402 | Numerically, the |
| 403 | bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper. | 403 | bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper. |
| 404 | @end iftex | 404 | @end tex |
| 405 | @ifinfo | 405 | @ifinfo |
| 406 | Numerically, the | 406 | Numerically, the |
| 407 | bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper. | 407 | bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper. |
| @@ -434,7 +434,7 @@ digits, so you can represent any character code in this way. | |||
| 434 | Thus, @samp{?\x41} for the character @kbd{A}, @samp{?\x1} for the | 434 | Thus, @samp{?\x41} for the character @kbd{A}, @samp{?\x1} for the |
| 435 | character @kbd{C-a}, and @code{?\x8c0} for the character | 435 | character @kbd{C-a}, and @code{?\x8c0} for the character |
| 436 | @iftex | 436 | @iftex |
| 437 | @`a. | 437 | @samp{@`a}. |
| 438 | @end iftex | 438 | @end iftex |
| 439 | @ifinfo | 439 | @ifinfo |
| 440 | @samp{a} with grave accent. | 440 | @samp{a} with grave accent. |
| @@ -478,7 +478,7 @@ backslash. In contrast to its use in strings, however, a backslash in | |||
| 478 | the name of a symbol simply quotes the single character that follows the | 478 | the name of a symbol simply quotes the single character that follows the |
| 479 | backslash. For example, in a string, @samp{\t} represents a tab | 479 | backslash. For example, in a string, @samp{\t} represents a tab |
| 480 | character; in the name of a symbol, however, @samp{\t} merely quotes the | 480 | character; in the name of a symbol, however, @samp{\t} merely quotes the |
| 481 | letter @kbd{t}. To have a symbol with a tab character in its name, you | 481 | letter @samp{t}. To have a symbol with a tab character in its name, you |
| 482 | must actually use a tab (preceded with a backslash). But it's rare to | 482 | must actually use a tab (preceded with a backslash). But it's rare to |
| 483 | do such a thing. | 483 | do such a thing. |
| 484 | 484 | ||
| @@ -525,26 +525,28 @@ elements. There are two kinds of sequence in Emacs Lisp, lists and | |||
| 525 | arrays. Thus, an object of type list or of type array is also | 525 | arrays. Thus, an object of type list or of type array is also |
| 526 | considered a sequence. | 526 | considered a sequence. |
| 527 | 527 | ||
| 528 | Arrays are further subdivided into strings and vectors. Vectors can | 528 | Arrays are further subdivided into strings, vectors, char-tables and |
| 529 | hold elements of any type, but string elements must be characters in the | 529 | bool-vectors. Vectors can hold elements of any type, but string |
| 530 | range from 0 to 255. However, the characters in a string can have text | 530 | elements must be characters, and bool-vector elements must be @code{t} |
| 531 | properties like characters in a buffer (@pxref{Text Properties}); | 531 | or @code{nil}. The characters in a string can have text properties like |
| 532 | vectors do not support text properties even when their elements happen | 532 | characters in a buffer (@pxref{Text Properties}); vectors and |
| 533 | to be characters. | 533 | bool-vectors do not support text properties even when their elements |
| 534 | 534 | happen to be characters. Char-tables are like vectors except that they | |
| 535 | Lists, strings and vectors are different, but they have important | 535 | are indexed by any valid character code. |
| 536 | similarities. For example, all have a length @var{l}, and all have | 536 | |
| 537 | elements which can be indexed from zero to @var{l} minus one. Also, | 537 | Lists, strings and the other array types are different, but they have |
| 538 | several functions, called sequence functions, accept any kind of | 538 | important similarities. For example, all have a length @var{l}, and all |
| 539 | have elements which can be indexed from zero to @var{l} minus one. | ||
| 540 | Several functions, called sequence functions, accept any kind of | ||
| 539 | sequence. For example, the function @code{elt} can be used to extract | 541 | sequence. For example, the function @code{elt} can be used to extract |
| 540 | an element of a sequence, given its index. @xref{Sequences Arrays | 542 | an element of a sequence, given its index. @xref{Sequences Arrays |
| 541 | Vectors}. | 543 | Vectors}. |
| 542 | 544 | ||
| 543 | It is impossible to read the same sequence twice, since sequences are | 545 | It is generally impossible to read the same sequence twice, since |
| 544 | always created anew upon reading. If you read the read syntax for a | 546 | sequences are always created anew upon reading. If you read the read |
| 545 | sequence twice, you get two sequences with equal contents. There is one | 547 | syntax for a sequence twice, you get two sequences with equal contents. |
| 546 | exception: the empty list @code{()} always stands for the same object, | 548 | There is one exception: the empty list @code{()} always stands for the |
| 547 | @code{nil}. | 549 | same object, @code{nil}. |
| 548 | 550 | ||
| 549 | @node Cons Cell Type | 551 | @node Cons Cell Type |
| 550 | @subsection Cons Cell and List Types | 552 | @subsection Cons Cell and List Types |
| @@ -596,8 +598,9 @@ violet buttercup)}: | |||
| 596 | 598 | ||
| 597 | @example | 599 | @example |
| 598 | @group | 600 | @group |
| 599 | ___ ___ ___ ___ ___ ___ | 601 | --- --- --- --- --- --- |
| 600 | |___|___|--> |___|___|--> |___|___|--> nil | 602 | | | |--> | | |--> | | |--> nil |
| 603 | --- --- --- --- --- --- | ||
| 601 | | | | | 604 | | | | |
| 602 | | | | | 605 | | | | |
| 603 | --> rose --> violet --> buttercup | 606 | --> rose --> violet --> buttercup |
| @@ -653,8 +656,9 @@ depicted with boxes and arrows: | |||
| 653 | 656 | ||
| 654 | @example | 657 | @example |
| 655 | @group | 658 | @group |
| 656 | ___ ___ ___ ___ | 659 | --- --- --- --- |
| 657 | |___|___|--> |___|___|--> nil | 660 | | | |--> | | |--> nil |
| 661 | --- --- --- --- | ||
| 658 | | | | 662 | | | |
| 659 | | | | 663 | | | |
| 660 | --> A --> nil | 664 | --> A --> nil |
| @@ -688,8 +692,9 @@ shows the pair @code{(rose . violet)}: | |||
| 688 | 692 | ||
| 689 | @example | 693 | @example |
| 690 | @group | 694 | @group |
| 691 | ___ ___ | 695 | --- --- |
| 692 | |___|___|--> violet | 696 | | | |--> violet |
| 697 | --- --- | ||
| 693 | | | 698 | | |
| 694 | | | 699 | | |
| 695 | --> rose | 700 | --> rose |
| @@ -703,8 +708,9 @@ chain of cons cells with a non-@code{nil} final @sc{cdr}. For example, | |||
| 703 | 708 | ||
| 704 | @example | 709 | @example |
| 705 | @group | 710 | @group |
| 706 | ___ ___ ___ ___ | 711 | --- --- --- --- |
| 707 | |___|___|--> |___|___|--> buttercup | 712 | | | |--> | | |--> buttercup |
| 713 | --- --- --- --- | ||
| 708 | | | | 714 | | | |
| 709 | | | | 715 | | | |
| 710 | --> rose --> violet | 716 | --> rose --> violet |
| @@ -720,8 +726,9 @@ and looks like this: | |||
| 720 | 726 | ||
| 721 | @example | 727 | @example |
| 722 | @group | 728 | @group |
| 723 | ___ ___ ___ ___ | 729 | --- --- --- --- |
| 724 | |___|___|--> |___|___|--> nil | 730 | | | |--> | | |--> nil |
| 731 | --- --- --- --- | ||
| 725 | | | | 732 | | | |
| 726 | | | | 733 | | | |
| 727 | --> rose --> violet | 734 | --> rose --> violet |
| @@ -735,8 +742,9 @@ It looks like this: | |||
| 735 | 742 | ||
| 736 | @example | 743 | @example |
| 737 | @group | 744 | @group |
| 738 | ___ ___ ___ ___ ___ ___ | 745 | --- --- --- --- --- --- |
| 739 | |___|___|--> |___|___|--> |___|___|--> nil | 746 | | | |--> | | |--> | | |--> nil |
| 747 | --- --- --- --- --- --- | ||
| 740 | | | | | 748 | | | | |
| 741 | | | | | 749 | | | | |
| 742 | --> rose --> violet --> buttercup | 750 | --> rose --> violet --> buttercup |
| @@ -775,27 +783,35 @@ functions that work on alists. | |||
| 775 | 783 | ||
| 776 | An @dfn{array} is composed of an arbitrary number of slots for | 784 | An @dfn{array} is composed of an arbitrary number of slots for |
| 777 | referring to other Lisp objects, arranged in a contiguous block of | 785 | referring to other Lisp objects, arranged in a contiguous block of |
| 778 | memory. Accessing any element of an array takes the same amount of | 786 | memory. Accessing any element of an array takes approximately the same |
| 779 | time. In contrast, accessing an element of a list requires time | 787 | amount of time. In contrast, accessing an element of a list requires |
| 780 | proportional to the position of the element in the list. (Elements at | 788 | time proportional to the position of the element in the list. (Elements |
| 781 | the end of a list take longer to access than elements at the beginning | 789 | at the end of a list take longer to access than elements at the |
| 782 | of a list.) | 790 | beginning of a list.) |
| 783 | 791 | ||
| 784 | Emacs defines two types of array, strings and vectors. A string is an | 792 | Emacs defines four types of array: strings, vectors, bool-vectors, and |
| 785 | array of characters and a vector is an array of arbitrary objects. Both | 793 | char-tables. |
| 786 | are one-dimensional. (Most other programming languages support | 794 | |
| 787 | multidimensional arrays, but they are not essential; you can get the | 795 | A string is an array of characters and a vector is an array of |
| 788 | same effect with an array of arrays.) Each type of array has its own | 796 | arbitrary objects. A bool-vector can hold only @code{t} or @code{nil}. |
| 789 | read syntax; see @ref{String Type}, and @ref{Vector Type}. | 797 | These kinds of array may have any length up to the largest integer. |
| 790 | 798 | Char-tables are sparse arrays indexed by any valid character code; they | |
| 791 | An array may have any length up to the largest integer; but once | 799 | can hold arbitrary objects. |
| 792 | created, it has a fixed size. The first element of an array has index | 800 | |
| 793 | zero, the second element has index 1, and so on. This is called | 801 | The first element of an array has index zero, the second element has |
| 794 | @dfn{zero-origin} indexing. For example, an array of four elements has | 802 | index 1, and so on. This is called @dfn{zero-origin} indexing. For |
| 795 | indices 0, 1, 2, @w{and 3}. | 803 | example, an array of four elements has indices 0, 1, 2, @w{and 3}. The |
| 796 | 804 | largest possible index value is one less than the length of the array. | |
| 797 | The array type is contained in the sequence type and contains both the | 805 | Once an array is created, its length is fixed. |
| 798 | string type and the vector type. | 806 | |
| 807 | All Emacs Lisp arrays are one-dimensional. (Most other programming | ||
| 808 | languages support multidimensional arrays, but they are not essential; | ||
| 809 | you can get the same effect with an array of arrays.) Each type of | ||
| 810 | array has its own read syntax; see the following sections for details. | ||
| 811 | |||
| 812 | The array type is contained in the sequence type and | ||
| 813 | contains the string type, the vector type, the bool-vector type, and the | ||
| 814 | char-table type. | ||
| 799 | 815 | ||
| 800 | @node String Type | 816 | @node String Type |
| 801 | @subsection String Type | 817 | @subsection String Type |
| @@ -854,10 +870,13 @@ but the newline is ignored if escaped." | |||
| 854 | constant by writing it literally. There are two text representations | 870 | constant by writing it literally. There are two text representations |
| 855 | for non-@sc{ASCII} characters in Emacs strings (and in buffers): unibyte | 871 | for non-@sc{ASCII} characters in Emacs strings (and in buffers): unibyte |
| 856 | and multibyte. If the string constant is read from a multibyte source, | 872 | and multibyte. If the string constant is read from a multibyte source, |
| 857 | then the character is read as a multibyte character, and that makes the | 873 | such as a multibyte buffer or string, or a file that would be visited as |
| 858 | string multibyte. If the string constant is read from a unibyte source, | 874 | multibyte, then the character is read as a multibyte character, and that |
| 859 | then the character is read as unibyte and that makes the string unibyte. | 875 | makes the string multibyte. If the string constant is read from a |
| 876 | unibyte source, then the character is read as unibyte and that makes the | ||
| 877 | string unibyte. | ||
| 860 | 878 | ||
| 879 | @c ??? Change this? | ||
| 861 | You can also represent a multibyte non-@sc{ASCII} character with its | 880 | You can also represent a multibyte non-@sc{ASCII} character with its |
| 862 | character code, using a hex escape, @samp{\x@var{nnnnnnn}}, with as many | 881 | character code, using a hex escape, @samp{\x@var{nnnnnnn}}, with as many |
| 863 | digits as necessary. (Multibyte non-@sc{ASCII} character codes are all | 882 | digits as necessary. (Multibyte non-@sc{ASCII} character codes are all |
| @@ -895,9 +914,9 @@ characters. | |||
| 895 | 914 | ||
| 896 | If you use the @samp{\M-} syntax to indicate a meta character in a | 915 | If you use the @samp{\M-} syntax to indicate a meta character in a |
| 897 | string constant, this sets the | 916 | string constant, this sets the |
| 898 | @iftex | 917 | @tex |
| 899 | $2^{7}$ | 918 | $2^{7}$ |
| 900 | @end iftex | 919 | @end tex |
| 901 | @ifinfo | 920 | @ifinfo |
| 902 | 2**7 | 921 | 2**7 |
| 903 | @end ifinfo | 922 | @end ifinfo |
| @@ -975,9 +994,24 @@ special purposes. A char-table can also specify a single value for | |||
| 975 | a whole character set. | 994 | a whole character set. |
| 976 | 995 | ||
| 977 | The printed representation of a char-table is like a vector | 996 | The printed representation of a char-table is like a vector |
| 978 | except that there is an extra @samp{#} at the beginning. | 997 | except that there is an extra @samp{#^} at the beginning. |
| 979 | 998 | ||
| 980 | @xref{Char-Tables}, for special functions to operate on char-tables. | 999 | @xref{Char-Tables}, for special functions to operate on char-tables. |
| 1000 | Uses of char-tables include: | ||
| 1001 | |||
| 1002 | @itemize @bullet | ||
| 1003 | @item | ||
| 1004 | Case tables (@pxref{Case Tables}). | ||
| 1005 | |||
| 1006 | @item | ||
| 1007 | Character category tables (@pxref{Categories}). | ||
| 1008 | |||
| 1009 | @item | ||
| 1010 | Display Tables (@pxref{Display Tables}). | ||
| 1011 | |||
| 1012 | @item | ||
| 1013 | Syntax tables (@pxref{Syntax Tables}). | ||
| 1014 | @end itemize | ||
| 981 | 1015 | ||
| 982 | @node Bool-Vector Type | 1016 | @node Bool-Vector Type |
| 983 | @subsection Bool-Vector Type | 1017 | @subsection Bool-Vector Type |
| @@ -999,6 +1033,9 @@ make no difference. | |||
| 999 | @result{} #&3"\377" | 1033 | @result{} #&3"\377" |
| 1000 | (make-bool-vector 3 nil) | 1034 | (make-bool-vector 3 nil) |
| 1001 | @result{} #&3"\0"" | 1035 | @result{} #&3"\0"" |
| 1036 | ;; @r{These are equal since only the first 3 bits are used.} | ||
| 1037 | (equal #&3"\377" #&3"\340") | ||
| 1038 | @result{} t | ||
| 1002 | @end example | 1039 | @end example |
| 1003 | 1040 | ||
| 1004 | @node Function Type | 1041 | @node Function Type |
| @@ -1027,7 +1064,7 @@ functions @code{funcall} and @code{apply}. @xref{Calling Functions}. | |||
| 1027 | 1064 | ||
| 1028 | A @dfn{Lisp macro} is a user-defined construct that extends the Lisp | 1065 | A @dfn{Lisp macro} is a user-defined construct that extends the Lisp |
| 1029 | language. It is represented as an object much like a function, but with | 1066 | language. It is represented as an object much like a function, but with |
| 1030 | different parameter-passing semantics. A Lisp macro has the form of a | 1067 | different argument-passing semantics. A Lisp macro has the form of a |
| 1031 | list whose first element is the symbol @code{macro} and whose @sc{cdr} | 1068 | list whose first element is the symbol @code{macro} and whose @sc{cdr} |
| 1032 | is a Lisp function object, including the @code{lambda} symbol. | 1069 | is a Lisp function object, including the @code{lambda} symbol. |
| 1033 | 1070 | ||
| @@ -1053,12 +1090,12 @@ not evaluate all its arguments is called a @dfn{special form} | |||
| 1053 | (@pxref{Special Forms}).@refill | 1090 | (@pxref{Special Forms}).@refill |
| 1054 | 1091 | ||
| 1055 | It does not matter to the caller of a function whether the function is | 1092 | It does not matter to the caller of a function whether the function is |
| 1056 | primitive. However, this does matter if you try to substitute a | 1093 | primitive. However, this does matter if you try to redefine a primitive |
| 1057 | function written in Lisp for a primitive of the same name. The reason | 1094 | with a function written in Lisp. The reason is that the primitive |
| 1058 | is that the primitive function may be called directly from C code. | 1095 | function may be called directly from C code. Calls to the redefined |
| 1059 | Calls to the redefined function from Lisp will use the new definition, | 1096 | function from Lisp will use the new definition, but calls from C code |
| 1060 | but calls from C code may still use the built-in definition. Therefore, | 1097 | may still use the built-in definition. Therefore, @strong{we discourage |
| 1061 | @strong{we discourage redefinition of primitive functions}. | 1098 | redefinition of primitive functions}. |
| 1062 | 1099 | ||
| 1063 | The term @dfn{function} refers to all Emacs functions, whether written | 1100 | The term @dfn{function} refers to all Emacs functions, whether written |
| 1064 | in Lisp or C. @xref{Function Type}, for information about the | 1101 | in Lisp or C. @xref{Function Type}, for information about the |
| @@ -1114,9 +1151,10 @@ symbol. @xref{Autoload}, for more details. | |||
| 1114 | @section Editing Types | 1151 | @section Editing Types |
| 1115 | @cindex editing types | 1152 | @cindex editing types |
| 1116 | 1153 | ||
| 1117 | The types in the previous section are common to many Lisp dialects. | 1154 | The types in the previous section used for general programming |
| 1118 | Emacs Lisp provides several additional data types for purposes connected | 1155 | purposes, and most of them are common to most Lisp dialects. Emacs Lisp |
| 1119 | with editing. | 1156 | provides several additional data types for purposes connected with |
| 1157 | editing. | ||
| 1120 | 1158 | ||
| 1121 | @menu | 1159 | @menu |
| 1122 | * Buffer Type:: The basic object of editing. | 1160 | * Buffer Type:: The basic object of editing. |
| @@ -1124,11 +1162,10 @@ with editing. | |||
| 1124 | * Window Type:: Buffers are displayed in windows. | 1162 | * Window Type:: Buffers are displayed in windows. |
| 1125 | * Frame Type:: Windows subdivide frames. | 1163 | * Frame Type:: Windows subdivide frames. |
| 1126 | * Window Configuration Type:: Recording the way a frame is subdivided. | 1164 | * Window Configuration Type:: Recording the way a frame is subdivided. |
| 1165 | * Frame Configuration Type:: Recording the status of all frames. | ||
| 1127 | * Process Type:: A process running on the underlying OS. | 1166 | * Process Type:: A process running on the underlying OS. |
| 1128 | * Stream Type:: Receive or send characters. | 1167 | * Stream Type:: Receive or send characters. |
| 1129 | * Keymap Type:: What function a keystroke invokes. | 1168 | * Keymap Type:: What function a keystroke invokes. |
| 1130 | * Syntax Table Type:: What a character means. | ||
| 1131 | * Display Table Type:: How display tables are represented. | ||
| 1132 | * Overlay Type:: How an overlay is represented. | 1169 | * Overlay Type:: How an overlay is represented. |
| 1133 | @end menu | 1170 | @end menu |
| 1134 | 1171 | ||
| @@ -1144,8 +1181,8 @@ buffer need not be displayed in any window. | |||
| 1144 | 1181 | ||
| 1145 | The contents of a buffer are much like a string, but buffers are not | 1182 | The contents of a buffer are much like a string, but buffers are not |
| 1146 | used like strings in Emacs Lisp, and the available operations are | 1183 | used like strings in Emacs Lisp, and the available operations are |
| 1147 | different. For example, insertion of text into a buffer is very | 1184 | different. For example, you can insert text efficiently into an |
| 1148 | efficient, whereas ``inserting'' text into a string requires | 1185 | existing buffer, whereas ``inserting'' text into a string requires |
| 1149 | concatenating substrings, and the result is an entirely new string | 1186 | concatenating substrings, and the result is an entirely new string |
| 1150 | object. | 1187 | object. |
| 1151 | 1188 | ||
| @@ -1167,10 +1204,10 @@ a local syntax table (@pxref{Syntax Tables}); | |||
| 1167 | a local keymap (@pxref{Keymaps}); and, | 1204 | a local keymap (@pxref{Keymaps}); and, |
| 1168 | 1205 | ||
| 1169 | @item | 1206 | @item |
| 1170 | a local variable binding list (@pxref{Buffer-Local Variables}). | 1207 | a list of buffer-local variable bindings (@pxref{Buffer-Local Variables}). |
| 1171 | 1208 | ||
| 1172 | @item | 1209 | @item |
| 1173 | a list of overlays (@pxref{Overlays}). | 1210 | overlays (@pxref{Overlays}). |
| 1174 | 1211 | ||
| 1175 | @item | 1212 | @item |
| 1176 | text properties for the text in the buffer (@pxref{Text Properties}). | 1213 | text properties for the text in the buffer (@pxref{Text Properties}). |
| @@ -1183,7 +1220,7 @@ behavior of programs in different buffers, without actually changing the | |||
| 1183 | programs. | 1220 | programs. |
| 1184 | 1221 | ||
| 1185 | A buffer may be @dfn{indirect}, which means it shares the text | 1222 | A buffer may be @dfn{indirect}, which means it shares the text |
| 1186 | of another buffer. @xref{Indirect Buffers}. | 1223 | of another buffer, but presents it differently. @xref{Indirect Buffers}. |
| 1187 | 1224 | ||
| 1188 | Buffers have no read syntax. They print in hash notation, showing the | 1225 | Buffers have no read syntax. They print in hash notation, showing the |
| 1189 | buffer name. | 1226 | buffer name. |
| @@ -1263,7 +1300,7 @@ uniquely). | |||
| 1263 | @example | 1300 | @example |
| 1264 | @group | 1301 | @group |
| 1265 | (selected-frame) | 1302 | (selected-frame) |
| 1266 | @result{} #<frame xemacs@@mole.gnu.ai.mit.edu 0xdac80> | 1303 | @result{} #<frame emacs@@mole.gnu.ai.mit.edu 0xdac80> |
| 1267 | @end group | 1304 | @end group |
| 1268 | @end example | 1305 | @end example |
| 1269 | 1306 | ||
| @@ -1282,6 +1319,19 @@ looks like @samp{#<window-configuration>}. @xref{Window | |||
| 1282 | Configurations}, for a description of several functions related to | 1319 | Configurations}, for a description of several functions related to |
| 1283 | window configurations. | 1320 | window configurations. |
| 1284 | 1321 | ||
| 1322 | @node Frame Configuration Type | ||
| 1323 | @subsection Frame Configuration Type | ||
| 1324 | @cindex screen layout | ||
| 1325 | |||
| 1326 | A @dfn{frame configuration} stores information about the positions, | ||
| 1327 | sizes, and contents of the windows in all frames. It is actually | ||
| 1328 | a list whose @sc{car} is @code{frame-configuration} and whose | ||
| 1329 | @sc{cdr} is an alist. Each alist element describes one frame, | ||
| 1330 | which appears as the @sc{car} of that element. | ||
| 1331 | |||
| 1332 | @xref{Frame Configurations}, for a description of several functions | ||
| 1333 | related to frame configurations. | ||
| 1334 | |||
| 1285 | @node Process Type | 1335 | @node Process Type |
| 1286 | @subsection Process Type | 1336 | @subsection Process Type |
| 1287 | 1337 | ||
| @@ -1343,36 +1393,6 @@ a list whose @sc{car} is the symbol @code{keymap}. | |||
| 1343 | @xref{Keymaps}, for information about creating keymaps, handling prefix | 1393 | @xref{Keymaps}, for information about creating keymaps, handling prefix |
| 1344 | keys, local as well as global keymaps, and changing key bindings. | 1394 | keys, local as well as global keymaps, and changing key bindings. |
| 1345 | 1395 | ||
| 1346 | @node Syntax Table Type | ||
| 1347 | @subsection Syntax Table Type | ||
| 1348 | |||
| 1349 | A @dfn{syntax table} is a char-table which specifies the syntax of | ||
| 1350 | each character, for word and list parsing. Each element of the syntax | ||
| 1351 | table defines how one character is interpreted when it appears in a | ||
| 1352 | buffer. For example, in C mode (@pxref{Major Modes}), the @samp{+} | ||
| 1353 | character is punctuation, but in Lisp mode it is a valid character in a | ||
| 1354 | symbol. These modes specify different interpretations by changing the | ||
| 1355 | syntax table entry for @samp{+}, at index 43 in the syntax table. | ||
| 1356 | |||
| 1357 | Syntax tables are used only to control primitives that scan text in | ||
| 1358 | buffers, not for reading Lisp expressions. The syntax that the Lisp | ||
| 1359 | interpreter uses to read expressions is built into the Emacs source code | ||
| 1360 | and cannot be changed; thus, to change the list delimiters to be | ||
| 1361 | @samp{@{} and @samp{@}} instead of @samp{(} and @samp{)} would be | ||
| 1362 | impossible. (Some Lisp systems provide ways to redefine the read | ||
| 1363 | syntax, but we decided to leave this feature out of Emacs Lisp for | ||
| 1364 | simplicity.) | ||
| 1365 | |||
| 1366 | @xref{Syntax Tables}, for details about syntax classes and how to make | ||
| 1367 | and modify syntax tables. | ||
| 1368 | |||
| 1369 | @node Display Table Type | ||
| 1370 | @subsection Display Table Type | ||
| 1371 | |||
| 1372 | A @dfn{display table} specifies how to display each character code. | ||
| 1373 | Each buffer and each window can have its own display table. A display | ||
| 1374 | table is actually a char-table. @xref{Display Tables}. | ||
| 1375 | |||
| 1376 | @node Overlay Type | 1396 | @node Overlay Type |
| 1377 | @subsection Overlay Type | 1397 | @subsection Overlay Type |
| 1378 | 1398 | ||
| @@ -1437,7 +1457,7 @@ a list and @code{symbolp} to check for a symbol. | |||
| 1437 | (setq list (append x list))) | 1457 | (setq list (append x list))) |
| 1438 | @need 3000 | 1458 | @need 3000 |
| 1439 | (t | 1459 | (t |
| 1440 | ;; We only handle symbols and lists. | 1460 | ;; We handle only symbols and lists. |
| 1441 | (error "Invalid argument %s in add-on" x)))) | 1461 | (error "Invalid argument %s in add-on" x)))) |
| 1442 | @end example | 1462 | @end example |
| 1443 | 1463 | ||
| @@ -1451,6 +1471,9 @@ with references to further information. | |||
| 1451 | @item arrayp | 1471 | @item arrayp |
| 1452 | @xref{Array Functions, arrayp}. | 1472 | @xref{Array Functions, arrayp}. |
| 1453 | 1473 | ||
| 1474 | @item bool-vector-p | ||
| 1475 | @xref{Bool-Vectors, bool-vector-p}. | ||
| 1476 | |||
| 1454 | @item bufferp | 1477 | @item bufferp |
| 1455 | @xref{Buffer Basics, bufferp}. | 1478 | @xref{Buffer Basics, bufferp}. |
| 1456 | 1479 | ||
| @@ -1458,20 +1481,29 @@ with references to further information. | |||
| 1458 | @xref{Byte-Code Type, byte-code-function-p}. | 1481 | @xref{Byte-Code Type, byte-code-function-p}. |
| 1459 | 1482 | ||
| 1460 | @item case-table-p | 1483 | @item case-table-p |
| 1461 | @xref{Case Table, case-table-p}. | 1484 | @xref{Case Tables, case-table-p}. |
| 1462 | 1485 | ||
| 1463 | @item char-or-string-p | 1486 | @item char-or-string-p |
| 1464 | @xref{Predicates for Strings, char-or-string-p}. | 1487 | @xref{Predicates for Strings, char-or-string-p}. |
| 1465 | 1488 | ||
| 1489 | @item char-table-p | ||
| 1490 | @xref{Char-Tables, char-table-p}. | ||
| 1491 | |||
| 1466 | @item commandp | 1492 | @item commandp |
| 1467 | @xref{Interactive Call, commandp}. | 1493 | @xref{Interactive Call, commandp}. |
| 1468 | 1494 | ||
| 1469 | @item consp | 1495 | @item consp |
| 1470 | @xref{List-related Predicates, consp}. | 1496 | @xref{List-related Predicates, consp}. |
| 1471 | 1497 | ||
| 1498 | @item display-table-p | ||
| 1499 | @xref{Display Tables, display-table-p}. | ||
| 1500 | |||
| 1472 | @item floatp | 1501 | @item floatp |
| 1473 | @xref{Predicates on Numbers, floatp}. | 1502 | @xref{Predicates on Numbers, floatp}. |
| 1474 | 1503 | ||
| 1504 | @item frame-configuration-p | ||
| 1505 | @xref{Frame Configurations, frame-configuration-p}. | ||
| 1506 | |||
| 1475 | @item frame-live-p | 1507 | @item frame-live-p |
| 1476 | @xref{Deleting Frames, frame-live-p}. | 1508 | @xref{Deleting Frames, frame-live-p}. |
| 1477 | 1509 | ||
| @@ -1556,8 +1588,9 @@ types. In most cases, it is more convenient to use type predicates than | |||
| 1556 | This function returns a symbol naming the primitive type of | 1588 | This function returns a symbol naming the primitive type of |
| 1557 | @var{object}. The value is one of the symbols @code{symbol}, | 1589 | @var{object}. The value is one of the symbols @code{symbol}, |
| 1558 | @code{integer}, @code{float}, @code{string}, @code{cons}, @code{vector}, | 1590 | @code{integer}, @code{float}, @code{string}, @code{cons}, @code{vector}, |
| 1559 | @code{marker}, @code{overlay}, @code{window}, @code{buffer}, | 1591 | @code{char-table}, @code{bool-vector}, @code{subr}, |
| 1560 | @code{subr}, @code{compiled-function}, @code{process}, or | 1592 | @code{compiled-function}, @code{marker}, @code{overlay}, @code{window}, |
| 1593 | @code{buffer}, @code{frame}, @code{process}, or | ||
| 1561 | @code{window-configuration}. | 1594 | @code{window-configuration}. |
| 1562 | 1595 | ||
| 1563 | @example | 1596 | @example |
| @@ -1594,11 +1627,6 @@ arguments with the same contents or elements are not necessarily | |||
| 1594 | @code{eq} to each other: they are @code{eq} only if they are the same | 1627 | @code{eq} to each other: they are @code{eq} only if they are the same |
| 1595 | object. | 1628 | object. |
| 1596 | 1629 | ||
| 1597 | (The @code{make-symbol} function returns an uninterned symbol that is | ||
| 1598 | not interned in the standard @code{obarray}. When uninterned symbols | ||
| 1599 | are in use, symbol names are no longer unique. Distinct symbols with | ||
| 1600 | the same name are not @code{eq}. @xref{Creating Symbols}.) | ||
| 1601 | |||
| 1602 | @example | 1630 | @example |
| 1603 | @group | 1631 | @group |
| 1604 | (eq 'foo 'foo) | 1632 | (eq 'foo 'foo) |
| @@ -1640,6 +1668,17 @@ the same name are not @code{eq}. @xref{Creating Symbols}.) | |||
| 1640 | @end group | 1668 | @end group |
| 1641 | @end example | 1669 | @end example |
| 1642 | 1670 | ||
| 1671 | (The @code{make-symbol} function returns an uninterned symbol that is | ||
| 1672 | not interned in the standard @code{obarray}. When uninterned symbols | ||
| 1673 | are in use, symbol names are no longer unique. Distinct symbols with | ||
| 1674 | the same name are not @code{eq}. @xref{Creating Symbols}.) | ||
| 1675 | |||
| 1676 | @example | ||
| 1677 | @group | ||
| 1678 | (eq (make-symbol "foo") 'foo) | ||
| 1679 | @result{} nil | ||
| 1680 | @end group | ||
| 1681 | @end example | ||
| 1643 | @end defun | 1682 | @end defun |
| 1644 | 1683 | ||
| 1645 | @defun equal object1 object2 | 1684 | @defun equal object1 object2 |