Mercurial > hg > xemacs-beta
annotate man/lispref/objects.texi @ 5937:9e308c7501d1 cygwin
6 years later, not sure about movemail
| author | Henry Thompson <ht@markup.co.uk> |
|---|---|
| date | Thu, 02 Dec 2021 14:34:45 +0000 |
| parents | 9fae6227ede5 |
| children |
| rev | line source |
|---|---|
| 428 | 1 @c -*-texinfo-*- |
| 2 @c This is part of the XEmacs Lisp Reference Manual. | |
| 3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
| 4 @c See the file lispref.texi for copying conditions. | |
| 5 @setfilename ../../info/objects.info | |
| 693 | 6 @node Lisp Data Types, Numbers, Packaging, Top |
| 428 | 7 @chapter Lisp Data Types |
| 8 @cindex object | |
| 9 @cindex Lisp object | |
| 10 @cindex type | |
| 11 @cindex data type | |
| 12 | |
| 13 A Lisp @dfn{object} is a piece of data used and manipulated by Lisp | |
| 14 programs. For our purposes, a @dfn{type} or @dfn{data type} is a set of | |
| 15 possible objects. | |
| 16 | |
| 17 Every object belongs to at least one type. Objects of the same type | |
| 18 have similar structures and may usually be used in the same contexts. | |
| 19 Types can overlap, and objects can belong to two or more types. | |
| 20 Consequently, we can ask whether an object belongs to a particular type, | |
| 21 but not for ``the'' type of an object. | |
| 22 | |
| 23 @cindex primitive type | |
| 24 A few fundamental object types are built into XEmacs. These, from | |
| 25 which all other types are constructed, are called @dfn{primitive types}. | |
| 26 Each object belongs to one and only one primitive type. These types | |
| 27 include @dfn{integer}, @dfn{character} (starting with XEmacs 20.0), | |
| 28 @dfn{float}, @dfn{cons}, @dfn{symbol}, @dfn{string}, @dfn{vector}, | |
| 29 @dfn{bit-vector}, @dfn{subr}, @dfn{compiled-function}, @dfn{hash-table}, | |
| 30 @dfn{range-table}, @dfn{char-table}, @dfn{weak-list}, and several | |
| 31 special types, such as @dfn{buffer}, that are related to editing. | |
| 32 (@xref{Editing Types}.) | |
| 33 | |
| 34 Each primitive type has a corresponding Lisp function that checks | |
| 35 whether an object is a member of that type. | |
| 36 | |
| 37 Note that Lisp is unlike many other languages in that Lisp objects are | |
| 38 @dfn{self-typing}: the primitive type of the object is implicit in the | |
| 39 object itself. For example, if an object is a vector, nothing can treat | |
| 40 it as a number; Lisp knows it is a vector, not a number. | |
| 41 | |
| 42 In most languages, the programmer must declare the data type of each | |
| 43 variable, and the type is known by the compiler but not represented in | |
| 44 the data. Such type declarations do not exist in XEmacs Lisp. A Lisp | |
| 45 variable can have any type of value, and it remembers whatever value | |
| 46 you store in it, type and all. | |
| 47 | |
| 48 This chapter describes the purpose, printed representation, and read | |
| 49 syntax of each of the standard types in Emacs Lisp. Details on how | |
| 50 to use these types can be found in later chapters. | |
| 51 | |
| 52 @menu | |
| 53 * Printed Representation:: How Lisp objects are represented as text. | |
| 54 * Comments:: Comments and their formatting conventions. | |
| 55 * Primitive Types:: List of all primitive types in XEmacs. | |
| 56 * Programming Types:: Types found in all Lisp systems. | |
| 57 * Editing Types:: Types specific to XEmacs. | |
| 58 * Window-System Types:: Types specific to windowing systems. | |
| 59 * Type Predicates:: Tests related to types. | |
| 60 * Equality Predicates:: Tests of equality between any two objects. | |
| 61 @end menu | |
| 62 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
63 @node Printed Representation, Comments, Lisp Data Types, Lisp Data Types |
| 428 | 64 @section Printed Representation and Read Syntax |
| 65 @cindex printed representation | |
| 66 @cindex read syntax | |
| 67 | |
| 68 The @dfn{printed representation} of an object is the format of the | |
| 69 output generated by the Lisp printer (the function @code{prin1}) for | |
| 70 that object. The @dfn{read syntax} of an object is the format of the | |
| 71 input accepted by the Lisp reader (the function @code{read}) for that | |
| 72 object. Most objects have more than one possible read syntax. Some | |
| 73 types of object have no read syntax; except for these cases, the printed | |
| 74 representation of an object is also a read syntax for it. | |
| 75 | |
| 76 In other languages, an expression is text; it has no other form. In | |
| 77 Lisp, an expression is primarily a Lisp object and only secondarily the | |
| 78 text that is the object's read syntax. Often there is no need to | |
| 79 emphasize this distinction, but you must keep it in the back of your | |
| 80 mind, or you will occasionally be very confused. | |
| 81 | |
| 82 @cindex hash notation | |
| 83 Every type has a printed representation. Some types have no read | |
| 84 syntax, since it may not make sense to enter objects of these types | |
| 85 directly in a Lisp program. For example, the buffer type does not have | |
| 86 a read syntax. Objects of these types are printed in @dfn{hash | |
| 87 notation}: the characters @samp{#<} followed by a descriptive string | |
| 88 (typically the type name followed by the name of the object), and closed | |
| 89 with a matching @samp{>}. Hash notation cannot be read at all, so the | |
| 90 Lisp reader signals the error @code{invalid-read-syntax} whenever it | |
| 91 encounters @samp{#<}. | |
| 92 @kindex invalid-read-syntax | |
| 93 | |
| 94 @example | |
| 95 (current-buffer) | |
| 96 @result{} #<buffer "objects.texi"> | |
| 97 @end example | |
| 98 | |
| 99 When you evaluate an expression interactively, the Lisp interpreter | |
| 100 first reads the textual representation of it, producing a Lisp object, | |
| 101 and then evaluates that object (@pxref{Evaluation}). However, | |
| 102 evaluation and reading are separate activities. Reading returns the | |
| 103 Lisp object represented by the text that is read; the object may or may | |
| 104 not be evaluated later. @xref{Input Functions}, for a description of | |
| 105 @code{read}, the basic function for reading objects. | |
| 106 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
107 @node Comments, Primitive Types, Printed Representation, Lisp Data Types |
| 428 | 108 @section Comments |
| 109 @cindex comments | |
| 110 @cindex @samp{;} in comment | |
| 111 | |
| 112 A @dfn{comment} is text that is written in a program only for the sake | |
| 113 of humans that read the program, and that has no effect on the meaning | |
| 114 of the program. In Lisp, a semicolon (@samp{;}) starts a comment if it | |
| 115 is not within a string or character constant. The comment continues to | |
| 116 the end of line. The Lisp reader discards comments; they do not become | |
| 117 part of the Lisp objects which represent the program within the Lisp | |
| 118 system. | |
| 119 | |
| 120 The @samp{#@@@var{count}} construct, which skips the next @var{count} | |
| 121 characters, is useful for program-generated comments containing binary | |
| 122 data. The XEmacs Lisp byte compiler uses this in its output files | |
| 123 (@pxref{Byte Compilation}). It isn't meant for source files, however. | |
| 124 | |
| 125 @xref{Comment Tips}, for conventions for formatting comments. | |
| 126 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
127 @node Primitive Types, Programming Types, Comments, Lisp Data Types |
| 428 | 128 @section Primitive Types |
| 129 @cindex primitive types | |
| 130 | |
| 131 For reference, here is a list of all the primitive types that may | |
| 132 exist in XEmacs. Note that some of these types may not exist | |
| 133 in some XEmacs executables; that depends on the options that | |
| 134 XEmacs was configured with. | |
| 135 | |
| 136 @itemize @bullet | |
| 137 @item | |
| 138 bit-vector | |
| 139 @item | |
| 140 buffer | |
| 141 @item | |
| 142 char-table | |
| 143 @item | |
| 144 character | |
| 145 @item | |
| 146 charset | |
| 147 @item | |
| 148 coding-system | |
| 149 @item | |
| 150 cons | |
| 151 @item | |
| 152 color-instance | |
| 153 @item | |
| 154 compiled-function | |
| 155 @item | |
| 156 console | |
| 157 @item | |
| 158 database | |
| 159 @item | |
| 160 device | |
| 161 @item | |
| 162 event | |
| 163 @item | |
| 164 extent | |
| 165 @item | |
| 166 face | |
| 167 @item | |
| 168 float | |
| 169 @item | |
| 170 font-instance | |
| 171 @item | |
| 172 frame | |
| 173 @item | |
| 174 glyph | |
| 175 @item | |
| 176 hash-table | |
| 177 @item | |
| 178 image-instance | |
| 179 @item | |
| 180 integer | |
| 181 @item | |
| 182 keymap | |
| 183 @item | |
| 184 marker | |
| 185 @item | |
| 186 process | |
| 187 @item | |
| 188 range-table | |
| 189 @item | |
| 190 specifier | |
| 191 @item | |
| 192 string | |
| 193 @item | |
| 194 subr | |
| 195 @item | |
| 196 subwindow | |
| 197 @item | |
| 198 symbol | |
| 199 @item | |
| 200 toolbar-button | |
| 201 @item | |
| 202 tooltalk-message | |
| 203 @item | |
| 204 tooltalk-pattern | |
| 205 @item | |
| 206 vector | |
| 207 @item | |
| 208 weak-list | |
| 209 @item | |
| 210 window | |
| 211 @item | |
| 212 window-configuration | |
| 213 @item | |
| 214 x-resource | |
| 215 @end itemize | |
| 216 | |
| 217 In addition, the following special types are created internally | |
| 218 but will never be seen by Lisp code. You may encounter them, | |
| 219 however, if you are debugging XEmacs. The printed representation | |
| 220 of these objects begins @samp{#<INTERNAL EMACS BUG}, which indicates | |
| 221 to the Lisp programmer that he has found an internal bug in XEmacs | |
| 222 if he ever encounters any of these objects. | |
| 223 | |
| 224 @itemize @bullet | |
| 225 @item | |
| 226 char-table-entry | |
| 227 @item | |
| 228 command-builder | |
| 229 @item | |
| 230 extent-auxiliary | |
| 231 @item | |
| 232 extent-info | |
| 233 @item | |
| 234 lcrecord-list | |
| 235 @item | |
| 236 lstream | |
| 237 @item | |
| 238 opaque | |
| 239 @item | |
| 240 opaque-list | |
| 241 @item | |
| 242 popup-data | |
| 243 @item | |
| 244 symbol-value-buffer-local | |
| 245 @item | |
| 246 symbol-value-forward | |
| 247 @item | |
| 248 symbol-value-lisp-magic | |
| 249 @item | |
| 250 symbol-value-varalias | |
| 251 @item | |
| 252 toolbar-data | |
| 253 @end itemize | |
| 254 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
255 @node Programming Types, Editing Types, Primitive Types, Lisp Data Types |
| 428 | 256 @section Programming Types |
| 257 @cindex programming types | |
| 258 | |
| 259 There are two general categories of types in XEmacs Lisp: those having | |
| 260 to do with Lisp programming, and those having to do with editing. The | |
| 261 former exist in many Lisp implementations, in one form or another. The | |
| 262 latter are unique to XEmacs Lisp. | |
| 263 | |
| 264 @menu | |
| 265 * Integer Type:: Numbers without fractional parts. | |
| 266 * Floating Point Type:: Numbers with fractional parts and with a large range. | |
| 267 * Character Type:: The representation of letters, numbers and | |
| 268 control characters. | |
| 269 * Symbol Type:: A multi-use object that refers to a function, | |
| 270 variable, or property list, and has a unique identity. | |
| 271 * Sequence Type:: Both lists and arrays are classified as sequences. | |
| 272 * Cons Cell Type:: Cons cells, and lists (which are made from cons cells). | |
| 273 * Array Type:: Arrays include strings and vectors. | |
| 274 * String Type:: An (efficient) array of characters. | |
| 275 * Vector Type:: One-dimensional arrays. | |
| 276 * Bit Vector Type:: An (efficient) array of bits. | |
| 277 * Function Type:: A piece of executable code you can call from elsewhere. | |
| 278 * Macro Type:: A method of expanding an expression into another | |
| 279 expression, more fundamental but less pretty. | |
| 280 * Primitive Function Type:: A function written in C, callable from Lisp. | |
| 281 * Compiled-Function Type:: A function written in Lisp, then compiled. | |
| 282 * Autoload Type:: A type used for automatically loading seldom-used | |
| 283 functions. | |
| 284 * Char Table Type:: A mapping from characters to Lisp objects. | |
| 285 * Hash Table Type:: A fast mapping between Lisp objects. | |
| 286 * Range Table Type:: A mapping from ranges of integers to Lisp objects. | |
| 287 * Weak List Type:: A list with special garbage-collection properties. | |
| 288 @end menu | |
| 289 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
290 @node Integer Type, Floating Point Type, Programming Types, Programming Types |
| 428 | 291 @subsection Integer Type |
| 292 | |
|
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
293 In XEmacs Lisp, integers can be fixnums (that is, fixed-precision |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
294 integers) or bignums (arbitrary-precision integers), if compile-time |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
295 configuration supports this. The read syntax for the two types is the |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
296 same, the type chosen depending on the numeric values involved. |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
297 |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
298 The range of values for fixnums in XEmacs Lisp is given by the |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
299 constants @code{most-positive-fixnum} and @code{most-negative-fixnum}. |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
300 On 32-bit machines, these constants reflect 31 value bits, ranging from |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
301 @minus{}1073741824 to 1073741823. |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
302 |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
303 In the absence of @xref{The Bignum Extension}, XEmacs Lisp |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
304 arithmetic functions do not check for overflow; so the code snippet |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
305 @code{(= most-negative-fixnum (1+ most-positive-fixnum))} will give |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
306 @code{t}. However, you @emph{will} get an error if you attempt to read |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
307 an out-of-range number using the Lisp reader. |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
308 |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
309 The main read syntax for integers is a sequence of base ten digits |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
310 with an optional sign at the beginning. (The printed representation |
|
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
311 produced by the Lisp interpreter never has a leading @samp{+}.) |
| 428 | 312 |
| 313 @example | |
| 314 @group | |
| 315 -1 ; @r{The integer -1.} | |
| 316 1 ; @r{The integer 1.} | |
| 317 +1 ; @r{Also the integer 1.} | |
| 318 268435457 ; @r{Causes an error on a 28-bit implementation.} | |
| 319 @end group | |
| 320 @end example | |
| 321 | |
| 322 @xref{Numbers}, for more information. | |
| 323 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
324 @node Floating Point Type, Character Type, Integer Type, Programming Types |
| 428 | 325 @subsection Floating Point Type |
| 326 | |
| 327 XEmacs supports floating point numbers. The precise range of floating | |
| 328 point numbers is machine-specific. | |
| 329 | |
| 330 The printed representation for floating point numbers requires either | |
| 331 a decimal point (with at least one digit following), an exponent, or | |
| 332 both. For example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2}, | |
| 333 @samp{1.5e3}, and @samp{.15e4} are five ways of writing a floating point | |
| 334 number whose value is 1500. They are all equivalent. | |
| 335 | |
| 336 @xref{Numbers}, for more information. | |
| 337 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
338 @node Character Type, Symbol Type, Floating Point Type, Programming Types |
| 428 | 339 @subsection Character Type |
| 340 @cindex @sc{ascii} character codes | |
| 341 @cindex char-int confoundance disease | |
| 342 | |
| 343 In XEmacs version 19, and in all versions of FSF GNU Emacs, a | |
| 344 @dfn{character} in XEmacs Lisp is nothing more than an integer. | |
| 345 This is yet another holdover from XEmacs Lisp's derivation from | |
| 346 vintage-1980 Lisps; modern versions of Lisp consider this equivalence | |
| 347 a bad idea, and have separate character types. In XEmacs version 20, | |
| 348 the modern convention is followed, and characters are their own | |
| 349 primitive types. (This change was necessary in order for @sc{mule}, | |
| 350 i.e. Asian-language, support to be correctly implemented.) | |
| 351 | |
| 352 Every character has an equivalent integer, called the @dfn{character | |
| 353 code}. For example, the character @kbd{A} is represented as the | |
| 354 @w{integer 65}, following the standard @sc{ascii} representation of | |
| 355 characters. If XEmacs was not compiled with @sc{mule} support, the | |
| 440 | 356 range of this integer will always be 0 to 255---eight bits, or one |
| 428 | 357 byte. (Integers outside this range are accepted but silently truncated; |
| 358 however, you should most decidedly @emph{not} rely on this, because it | |
| 359 will not work under XEmacs with @sc{mule} support.) When @sc{mule} | |
| 360 support is present, the range of character codes is much | |
| 361 larger. (Currently, 19 bits are used.) | |
| 362 | |
| 363 FSF GNU Emacs uses kludgy character codes above 255 to represent | |
| 364 keyboard input of @sc{ascii} characters in combination with certain | |
| 365 modifiers. XEmacs does not use this (a more general mechanism is | |
| 366 used that does not distinguish between @sc{ascii} keys and other | |
| 367 keys), so you will never find character codes above 255 in a | |
| 368 non-@sc{mule} XEmacs. | |
| 369 | |
| 370 Individual characters are not often used in programs. It is far more | |
| 371 common to work with @emph{strings}, which are sequences composed of | |
| 372 characters. @xref{String Type}. | |
| 373 | |
| 374 @cindex read syntax for characters | |
| 375 @cindex printed representation for characters | |
| 376 @cindex syntax for characters | |
| 377 | |
| 378 The read syntax for characters begins with a question mark, followed | |
| 379 by the character (if it's printable) or some symbolic representation of | |
| 380 it. In XEmacs 20, where characters are their own type, this is also the | |
| 381 print representation. In XEmacs 19, however, where characters are | |
| 382 really integers, the printed representation of a character is a decimal | |
| 383 number. This is also a possible read syntax for a character, but | |
| 384 writing characters that way in Lisp programs is a very bad idea. You | |
| 385 should @emph{always} use the special read syntax formats that XEmacs Lisp | |
| 386 provides for characters. | |
| 387 | |
| 388 The usual read syntax for alphanumeric characters is a question mark | |
| 389 followed by the character; thus, @samp{?A} for the character | |
| 390 @kbd{A}, @samp{?B} for the character @kbd{B}, and @samp{?a} for the | |
| 391 character @kbd{a}. | |
| 392 | |
| 393 For example: | |
| 394 | |
| 395 @example | |
| 396 ;; @r{Under XEmacs 20:} | |
| 397 ?Q @result{} ?Q ?q @result{} ?q | |
| 398 (char-int ?Q) @result{} 81 | |
| 399 ;; @r{Under XEmacs 19:} | |
| 400 ?Q @result{} 81 ?q @result{} 113 | |
| 401 @end example | |
| 402 | |
| 403 You can use the same syntax for punctuation characters, but it is | |
| 404 often a good idea to add a @samp{\} so that the Emacs commands for | |
| 405 editing Lisp code don't get confused. For example, @samp{?\ } is the | |
| 406 way to write the space character. If the character is @samp{\}, you | |
| 407 @emph{must} use a second @samp{\} to quote it: @samp{?\\}. XEmacs 20 | |
| 408 always prints punctuation characters with a @samp{\} in front of them, | |
| 409 to avoid confusion. | |
| 410 | |
| 411 @cindex whitespace | |
| 412 @cindex bell character | |
| 413 @cindex @samp{\a} | |
| 414 @cindex backspace | |
| 415 @cindex @samp{\b} | |
| 416 @cindex tab | |
| 417 @cindex @samp{\t} | |
| 418 @cindex vertical tab | |
| 419 @cindex @samp{\v} | |
| 420 @cindex formfeed | |
| 421 @cindex @samp{\f} | |
| 422 @cindex newline | |
| 423 @cindex @samp{\n} | |
| 424 @cindex return | |
| 425 @cindex @samp{\r} | |
| 426 @cindex escape | |
| 427 @cindex @samp{\e} | |
| 428 You can express the characters Control-g, backspace, tab, newline, | |
| 429 vertical tab, formfeed, return, and escape as @samp{?\a}, @samp{?\b}, | |
| 430 @samp{?\t}, @samp{?\n}, @samp{?\v}, @samp{?\f}, @samp{?\r}, @samp{?\e}, | |
| 431 respectively. Their character codes are 7, 8, 9, 10, 11, 12, 13, and 27 | |
| 432 in decimal. Thus, | |
| 433 | |
| 434 @example | |
| 435 ;; @r{Under XEmacs 20:} | |
| 436 ?\a @result{} ?\^G ; @r{@kbd{C-g}} | |
| 437 (char-int ?\a) @result{} 7 | |
| 438 ?\b @result{} ?\^H ; @r{backspace, @key{BS}, @kbd{C-h}} | |
| 439 (char-int ?\b) @result{} 8 | |
| 440 ?\t @result{} ?\t ; @r{tab, @key{TAB}, @kbd{C-i}} | |
| 441 (char-int ?\t) @result{} 9 | |
| 442 ?\n @result{} ?\n ; @r{newline, @key{LFD}, @kbd{C-j}} | |
| 443 ?\v @result{} ?\^K ; @r{vertical tab, @kbd{C-k}} | |
| 444 ?\f @result{} ?\^L ; @r{formfeed character, @kbd{C-l}} | |
| 445 ?\r @result{} ?\r ; @r{carriage return, @key{RET}, @kbd{C-m}} | |
| 446 ?\e @result{} ?\^[ ; @r{escape character, @key{ESC}, @kbd{C-[}} | |
| 447 ?\\ @result{} ?\\ ; @r{backslash character, @kbd{\}} | |
| 448 ;; @r{Under XEmacs 19:} | |
| 449 ?\a @result{} 7 ; @r{@kbd{C-g}} | |
| 450 ?\b @result{} 8 ; @r{backspace, @key{BS}, @kbd{C-h}} | |
| 451 ?\t @result{} 9 ; @r{tab, @key{TAB}, @kbd{C-i}} | |
| 452 ?\n @result{} 10 ; @r{newline, @key{LFD}, @kbd{C-j}} | |
| 453 ?\v @result{} 11 ; @r{vertical tab, @kbd{C-k}} | |
| 454 ?\f @result{} 12 ; @r{formfeed character, @kbd{C-l}} | |
| 455 ?\r @result{} 13 ; @r{carriage return, @key{RET}, @kbd{C-m}} | |
| 456 ?\e @result{} 27 ; @r{escape character, @key{ESC}, @kbd{C-[}} | |
| 457 ?\\ @result{} 92 ; @r{backslash character, @kbd{\}} | |
| 458 @end example | |
| 459 | |
| 460 @cindex escape sequence | |
| 461 These sequences which start with backslash are also known as | |
| 462 @dfn{escape sequences}, because backslash plays the role of an escape | |
| 463 character; this usage has nothing to do with the character @key{ESC}. | |
| 464 | |
| 465 @cindex control characters | |
| 466 Control characters may be represented using yet another read syntax. | |
| 467 This consists of a question mark followed by a backslash, caret, and the | |
| 468 corresponding non-control character, in either upper or lower case. For | |
| 469 example, both @samp{?\^I} and @samp{?\^i} are valid read syntax for the | |
| 470 character @kbd{C-i}, the character whose value is 9. | |
| 471 | |
| 472 Instead of the @samp{^}, you can use @samp{C-}; thus, @samp{?\C-i} is | |
| 473 equivalent to @samp{?\^I} and to @samp{?\^i}: | |
| 474 | |
| 475 @example | |
| 476 ;; @r{Under XEmacs 20:} | |
| 477 ?\^I @result{} ?\t ?\C-I @result{} ?\t | |
| 478 (char-int ?\^I) @result{} 9 | |
| 479 ;; @r{Under XEmacs 19:} | |
| 480 ?\^I @result{} 9 ?\C-I @result{} 9 | |
| 481 @end example | |
| 482 | |
| 483 There is also a character read syntax beginning with @samp{\M-}. This | |
| 484 sets the high bit of the character code (same as adding 128 to the | |
| 485 character code). For example, @samp{?\M-A} stands for the character | |
| 486 with character code 193, or 128 plus 65. You should @emph{not} use this | |
| 487 syntax in your programs. It is a holdover of yet another confoundance | |
| 488 disease from earlier Emacsen. (This was used to represent keyboard input | |
| 489 with the @key{META} key set, thus the @samp{M}; however, it conflicts | |
| 490 with the legitimate @sc{iso}-8859-1 interpretation of the character code. | |
| 491 For example, character code 193 is a lowercase @samp{a} with an acute | |
| 492 accent, in @sc{iso}-8859-1.) | |
| 493 | |
| 3367 | 494 @cindex unicode character escape |
| 495 From version 21.5.25 onwards, XEmacs provides a syntax for specifying | |
| 496 characters by their Unicode code points. @samp{?\uABCD} will give you | |
| 497 an XEmacs character that maps to the code point @samp{U+ABCD} in | |
| 498 Unicode-based representations (UTF-8 text files, Unicode-oriented fonts, | |
| 499 etc.) Just as in the C# language, there is a slightly different syntax | |
| 500 for specifying characters with code points above @samp{#xFFFF}; | |
| 501 @samp{\U00ABCDEF} will give you an XEmacs character that maps to the | |
| 502 code point @samp{U+ABCDEF} in Unicode-based representations, if such an | |
| 503 XEmacs character exists. | |
| 504 | |
| 505 Unlike in C#, while this syntax is available for character literals, | |
| 506 and (see later) in strings, it is not available elsewhere in your Lisp | |
| 507 source code. | |
| 508 | |
| 428 | 509 @ignore @c None of this crap applies to XEmacs. |
| 510 For use in strings and buffers, you are limited to the control | |
| 511 characters that exist in @sc{ascii}, but for keyboard input purposes, | |
| 512 you can turn any character into a control character with @samp{C-}. The | |
| 513 character codes for these non-@sc{ascii} control characters include the | |
| 514 @iftex | |
| 515 $2^{26}$ | |
| 516 @end iftex | |
| 517 @ifinfo | |
| 518 2**26 | |
| 519 @end ifinfo | |
| 520 bit as well as the code for the corresponding non-control | |
| 521 character. Ordinary terminals have no way of generating non-@sc{ASCII} | |
| 522 control characters, but you can generate them straightforwardly using an | |
| 523 X terminal. | |
| 524 | |
| 525 For historical reasons, Emacs treats the @key{DEL} character as | |
| 526 the control equivalent of @kbd{?}: | |
| 527 | |
| 528 @example | |
| 529 ?\^? @result{} 127 ?\C-? @result{} 127 | |
| 530 @end example | |
| 531 | |
| 532 @noindent | |
| 533 As a result, it is currently not possible to represent the character | |
| 534 @kbd{Control-?}, which is a meaningful input character under X. It is | |
| 535 not easy to change this as various Lisp files refer to @key{DEL} in this | |
| 536 way. | |
| 537 | |
| 538 For representing control characters to be found in files or strings, | |
| 539 we recommend the @samp{^} syntax; for control characters in keyboard | |
| 540 input, we prefer the @samp{C-} syntax. This does not affect the meaning | |
| 541 of the program, but may guide the understanding of people who read it. | |
| 542 | |
| 543 @cindex meta characters | |
| 544 A @dfn{meta character} is a character typed with the @key{META} | |
| 545 modifier key. The integer that represents such a character has the | |
| 546 @iftex | |
| 547 $2^{27}$ | |
| 548 @end iftex | |
| 549 @ifinfo | |
| 550 2**27 | |
| 551 @end ifinfo | |
| 552 bit set (which on most machines makes it a negative number). We | |
| 553 use high bits for this and other modifiers to make possible a wide range | |
| 554 of basic character codes. | |
| 555 | |
| 556 In a string, the | |
| 557 @iftex | |
| 558 $2^{7}$ | |
| 559 @end iftex | |
| 560 @ifinfo | |
| 561 2**7 | |
| 562 @end ifinfo | |
| 563 bit indicates a meta character, so the meta | |
| 564 characters that can fit in a string have codes in the range from 128 to | |
| 565 255, and are the meta versions of the ordinary @sc{ASCII} characters. | |
| 566 (In Emacs versions 18 and older, this convention was used for characters | |
| 567 outside of strings as well.) | |
| 568 | |
| 569 The read syntax for meta characters uses @samp{\M-}. For example, | |
| 570 @samp{?\M-A} stands for @kbd{M-A}. You can use @samp{\M-} together with | |
| 571 octal character codes (see below), with @samp{\C-}, or with any other | |
| 572 syntax for a character. Thus, you can write @kbd{M-A} as @samp{?\M-A}, | |
| 573 or as @samp{?\M-\101}. Likewise, you can write @kbd{C-M-b} as | |
| 574 @samp{?\M-\C-b}, @samp{?\C-\M-b}, or @samp{?\M-\002}. | |
| 575 | |
| 576 The case of an ordinary letter is indicated by its character code as | |
| 577 part of @sc{ASCII}, but @sc{ASCII} has no way to represent whether a | |
| 578 control character is upper case or lower case. Emacs uses the | |
| 579 @iftex | |
| 580 $2^{25}$ | |
| 581 @end iftex | |
| 582 @ifinfo | |
| 583 2**25 | |
| 584 @end ifinfo | |
| 585 bit to indicate that the shift key was used for typing a control | |
| 586 character. This distinction is possible only when you use X terminals | |
| 587 or other special terminals; ordinary terminals do not indicate the | |
| 588 distinction to the computer in any way. | |
| 589 | |
| 590 @cindex hyper characters | |
| 591 @cindex super characters | |
| 592 @cindex alt characters | |
| 593 The X Window System defines three other modifier bits that can be set | |
| 594 in a character: @dfn{hyper}, @dfn{super} and @dfn{alt}. The syntaxes | |
| 595 for these bits are @samp{\H-}, @samp{\s-} and @samp{\A-}. Thus, | |
| 596 @samp{?\H-\M-\A-x} represents @kbd{Alt-Hyper-Meta-x}. | |
| 597 @iftex | |
| 598 Numerically, the | |
| 599 bit values are $2^{22}$ for alt, $2^{23}$ for super and $2^{24}$ for hyper. | |
| 600 @end iftex | |
| 601 @ifinfo | |
| 602 Numerically, the | |
| 603 bit values are 2**22 for alt, 2**23 for super and 2**24 for hyper. | |
| 604 @end ifinfo | |
| 605 @end ignore | |
| 606 | |
| 607 @cindex @samp{?} in character constant | |
| 608 @cindex question mark in character constant | |
| 609 @cindex @samp{\} in character constant | |
| 610 @cindex backslash in character constant | |
| 611 @cindex octal character code | |
| 1549 | 612 @cindex hexadecimal character code |
|
5247
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
613 @cindex Overlong hex character escape |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
614 @cindex Non-ISO-8859-1 octal character escape |
| 3367 | 615 |
| 1549 | 616 Finally, there are two read syntaxes involving character codes. |
| 617 It is not possible to represent multibyte or wide characters in this | |
| 618 way; the permissible range of codes is from 0 to 255 (@emph{i.e.}, | |
| 619 @samp{0377} octal or @samp{0xFF} hexadecimal). If you wish to convert | |
| 620 code points to other characters, you must use the @samp{make-char} or | |
| 621 @samp{unicode-to-char} primitives in Mule. (Non-Mule XEmacsen cannot | |
| 622 represent codes out of that range at all, although you can set the font | |
| 623 to a registry other than ISO 8859/1 to get the appearance of a greater | |
| 624 range of characters.) Although these syntaxes can represent any | |
| 625 @sc{ascii} or Latin-1 character, they are preferred only when the | |
| 626 precise integral value is more important than the @sc{ascii} | |
| 627 representation. | |
| 628 | |
| 629 The first consists of a question mark | |
| 428 | 630 followed by a backslash and the character code in octal (up to three |
| 631 octal digits); thus, @samp{?\101} for the character @kbd{A}, | |
| 632 @samp{?\001} for the character @kbd{C-a}, and @code{?\002} for the | |
|
4486
f9104f0e9b91
Document the error on over-long hex character constants.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4472
diff
changeset
|
633 character @kbd{C-b}. The reader will finalize the character and start |
|
f9104f0e9b91
Document the error on over-long hex character constants.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4472
diff
changeset
|
634 reading the next token when a non-octal-digit is encountered or three |
|
5247
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
635 octal digits are read. When a given character code is above |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
636 @code{#o377}, the Lisp reader signals an @code{invalid-read-syntax} |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
637 error. Such errors are typically provoked by code written for older |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
638 versions of GNU Emacs, where the absence of the #o octal syntax for |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
639 integers made the character syntax convenient for non-character |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
640 values. Those older versions of GNU Emacs are long obsolete, so |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
641 changing the code to use the #o integer escape is the best |
|
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
642 solution. @pxref{Numbers}. |
| 1549 | 643 |
| 644 The second consists of a question mark followed by a backslash, the | |
| 645 character @samp{x}, and the character code in hexadecimal (up to two | |
| 646 hexadecimal digits); thus, @samp{?\x41} for the character @kbd{A}, | |
| 647 @samp{?\x1} for the character @kbd{C-a}, and @code{?\x2} for the | |
|
4486
f9104f0e9b91
Document the error on over-long hex character constants.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4472
diff
changeset
|
648 character @kbd{C-b}. If more than two hexadecimal codes are given, the |
|
5247
02d875ebd1ea
Make Lisp reader errors more informative with over-long hex, octal characters
Aidan Kehoe <kehoea@parhasard.net>
parents:
4905
diff
changeset
|
649 reader signals an @code{invalid-read-syntax} error. |
| 428 | 650 |
| 651 @example | |
| 652 @group | |
| 653 ;; @r{Under XEmacs 20:} | |
| 654 ?\012 @result{} ?\n ?\n @result{} ?\n ?\C-j @result{} ?\n | |
| 1549 | 655 ?\101 @result{} ?A ?A @result{} ?A ?\x0A @result{} ?\n |
| 656 ?\x41 @result{} ?A '(?\xAZ) @result{} '(?\n Z) '(?\0123) @result{} (?\n 3) | |
| 428 | 657 @end group |
| 658 @group | |
| 659 ;; @r{Under XEmacs 19:} | |
| 660 ?\012 @result{} 10 ?\n @result{} 10 ?\C-j @result{} 10 | |
| 661 ?\101 @result{} 65 ?A @result{} 65 | |
| 1549 | 662 ;; ?\x41 @r{is a syntax error.} |
| 428 | 663 @end group |
| 664 @end example | |
| 665 | |
| 666 A backslash is allowed, and harmless, preceding any character without | |
| 667 a special escape meaning; thus, @samp{?\+} is equivalent to @samp{?+}. | |
| 668 There is no reason to add a backslash before most characters. However, | |
| 669 you should add a backslash before any of the characters | |
| 670 @samp{()\|;'`"#.,} to avoid confusing the Emacs commands for editing | |
| 671 Lisp code. Also add a backslash before whitespace characters such as | |
| 672 space, tab, newline and formfeed. However, it is cleaner to use one of | |
| 673 the easily readable escape sequences, such as @samp{\t}, instead of an | |
| 674 actual whitespace character such as a tab. | |
| 675 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
676 @node Symbol Type, Sequence Type, Character Type, Programming Types |
| 428 | 677 @subsection Symbol Type |
| 678 | |
| 679 A @dfn{symbol} in XEmacs Lisp is an object with a name. The symbol | |
| 680 name serves as the printed representation of the symbol. In ordinary | |
| 681 use, the name is unique---no two symbols have the same name. | |
| 682 | |
| 683 A symbol can serve as a variable, as a function name, or to hold a | |
| 684 property list. Or it may serve only to be distinct from all other Lisp | |
| 685 objects, so that its presence in a data structure may be recognized | |
| 686 reliably. In a given context, usually only one of these uses is | |
| 687 intended. But you can use one symbol in all of these ways, | |
| 688 independently. | |
| 689 | |
| 690 @cindex @samp{\} in symbols | |
| 691 @cindex backslash in symbols | |
| 692 A symbol name can contain any characters whatever. Most symbol names | |
| 693 are written with letters, digits, and the punctuation characters | |
| 694 @samp{-+=*/}. Such names require no special punctuation; the characters | |
| 695 of the name suffice as long as the name does not look like a number. | |
| 696 (If it does, write a @samp{\} at the beginning of the name to force | |
| 697 interpretation as a symbol.) The characters @samp{_~!@@$%^&:<>@{@}} are | |
| 698 less often used but also require no special punctuation. Any other | |
| 699 characters may be included in a symbol's name by escaping them with a | |
| 700 backslash. In contrast to its use in strings, however, a backslash in | |
| 701 the name of a symbol simply quotes the single character that follows the | |
| 702 backslash. For example, in a string, @samp{\t} represents a tab | |
| 703 character; in the name of a symbol, however, @samp{\t} merely quotes the | |
| 704 letter @kbd{t}. To have a symbol with a tab character in its name, you | |
| 705 must actually use a tab (preceded with a backslash). But it's rare to | |
| 706 do such a thing. | |
| 707 | |
| 708 @cindex CL note---case of letters | |
| 709 @quotation | |
| 710 @b{Common Lisp note:} In Common Lisp, lower case letters are always | |
| 711 ``folded'' to upper case, unless they are explicitly escaped. In Emacs | |
| 712 Lisp, upper case and lower case letters are distinct. | |
| 713 @end quotation | |
| 714 | |
| 715 Here are several examples of symbol names. Note that the @samp{+} in | |
| 716 the fifth example is escaped to prevent it from being read as a number. | |
| 717 This is not necessary in the sixth example because the rest of the name | |
| 718 makes it invalid as a number. | |
| 719 | |
| 720 @example | |
| 721 @group | |
| 722 foo ; @r{A symbol named @samp{foo}.} | |
| 723 FOO ; @r{A symbol named @samp{FOO}, different from @samp{foo}.} | |
| 724 char-to-string ; @r{A symbol named @samp{char-to-string}.} | |
| 725 @end group | |
| 726 @group | |
| 727 1+ ; @r{A symbol named @samp{1+}} | |
| 728 ; @r{(not @samp{+1}, which is an integer).} | |
| 729 @end group | |
| 730 @group | |
| 731 \+1 ; @r{A symbol named @samp{+1}} | |
| 732 ; @r{(not a very readable name).} | |
| 733 @end group | |
| 734 @group | |
| 735 \(*\ 1\ 2\) ; @r{A symbol named @samp{(* 1 2)} (a worse name).} | |
| 736 @c the @'s in this next line use up three characters, hence the | |
| 737 @c apparent misalignment of the comment. | |
| 738 +-*/_~!@@$%^&=:<>@{@} ; @r{A symbol named @samp{+-*/_~!@@$%^&=:<>@{@}}.} | |
| 739 ; @r{These characters need not be escaped.} | |
| 740 @end group | |
| 741 @end example | |
| 742 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
743 @node Sequence Type, Cons Cell Type, Symbol Type, Programming Types |
| 428 | 744 @subsection Sequence Types |
| 745 | |
| 746 A @dfn{sequence} is a Lisp object that represents an ordered set of | |
| 747 elements. There are two kinds of sequence in XEmacs Lisp, lists and | |
| 748 arrays. Thus, an object of type list or of type array is also | |
| 749 considered a sequence. | |
| 750 | |
| 751 Arrays are further subdivided into strings, vectors, and bit vectors. | |
| 752 Vectors can hold elements of any type, but string elements must be | |
| 753 characters, and bit vector elements must be either 0 or 1. However, the | |
| 754 characters in a string can have extents (@pxref{Extents}) and text | |
| 755 properties (@pxref{Text Properties}) like characters in a buffer; | |
| 756 vectors do not support extents or text properties even when their | |
| 757 elements happen to be characters. | |
| 758 | |
| 759 Lists, strings, vectors, and bit vectors are different, but they have | |
| 760 important similarities. For example, all have a length @var{l}, and all | |
| 761 have elements which can be indexed from zero to @var{l} minus one. | |
| 762 Also, several functions, called sequence functions, accept any kind of | |
| 763 sequence. For example, the function @code{elt} can be used to extract | |
| 764 an element of a sequence, given its index. @xref{Sequences Arrays | |
| 765 Vectors}. | |
| 766 | |
| 767 It is impossible to read the same sequence twice, since sequences are | |
| 768 always created anew upon reading. If you read the read syntax for a | |
| 769 sequence twice, you get two sequences with equal contents. There is one | |
| 770 exception: the empty list @code{()} always stands for the same object, | |
| 771 @code{nil}. | |
| 772 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
773 @node Cons Cell Type, Array Type, Sequence Type, Programming Types |
| 428 | 774 @subsection Cons Cell and List Types |
| 775 @cindex address field of register | |
| 776 @cindex decrement field of register | |
| 777 | |
| 778 A @dfn{cons cell} is an object comprising two pointers named the | |
| 779 @sc{car} and the @sc{cdr}. Each of them can point to any Lisp object. | |
| 780 | |
| 781 A @dfn{list} is a series of cons cells, linked together so that the | |
| 782 @sc{cdr} of each cons cell points either to another cons cell or to the | |
| 783 empty list. @xref{Lists}, for functions that work on lists. Because | |
| 784 most cons cells are used as part of lists, the phrase @dfn{list | |
| 785 structure} has come to refer to any structure made out of cons cells. | |
| 786 | |
| 787 The names @sc{car} and @sc{cdr} have only historical meaning now. The | |
| 788 original Lisp implementation ran on an @w{IBM 704} computer which | |
| 789 divided words into two parts, called the ``address'' part and the | |
| 790 ``decrement''; @sc{car} was an instruction to extract the contents of | |
| 791 the address part of a register, and @sc{cdr} an instruction to extract | |
| 792 the contents of the decrement. By contrast, ``cons cells'' are named | |
| 793 for the function @code{cons} that creates them, which in turn is named | |
| 794 for its purpose, the construction of cells. | |
| 795 | |
| 796 @cindex atom | |
| 797 Because cons cells are so central to Lisp, we also have a word for | |
| 798 ``an object which is not a cons cell''. These objects are called | |
| 799 @dfn{atoms}. | |
| 800 | |
| 801 @cindex parenthesis | |
| 802 The read syntax and printed representation for lists are identical, and | |
| 803 consist of a left parenthesis, an arbitrary number of elements, and a | |
| 804 right parenthesis. | |
| 805 | |
| 806 Upon reading, each object inside the parentheses becomes an element | |
| 807 of the list. That is, a cons cell is made for each element. The | |
| 808 @sc{car} of the cons cell points to the element, and its @sc{cdr} points | |
| 809 to the next cons cell of the list, which holds the next element in the | |
| 810 list. The @sc{cdr} of the last cons cell is set to point to @code{nil}. | |
| 811 | |
| 812 @cindex box diagrams, for lists | |
| 813 @cindex diagrams, boxed, for lists | |
| 814 A list can be illustrated by a diagram in which the cons cells are | |
| 815 shown as pairs of boxes. (The Lisp reader cannot read such an | |
| 816 illustration; unlike the textual notation, which can be understood by | |
| 817 both humans and computers, the box illustrations can be understood only | |
| 818 by humans.) The following represents the three-element list @code{(rose | |
| 819 violet buttercup)}: | |
| 820 | |
| 821 @example | |
| 822 @group | |
| 823 ___ ___ ___ ___ ___ ___ | |
| 824 |___|___|--> |___|___|--> |___|___|--> nil | |
| 825 | | | | |
| 826 | | | | |
| 827 --> rose --> violet --> buttercup | |
| 828 @end group | |
| 829 @end example | |
| 830 | |
| 831 In this diagram, each box represents a slot that can refer to any Lisp | |
| 832 object. Each pair of boxes represents a cons cell. Each arrow is a | |
| 833 reference to a Lisp object, either an atom or another cons cell. | |
| 834 | |
| 835 In this example, the first box, the @sc{car} of the first cons cell, | |
| 836 refers to or ``contains'' @code{rose} (a symbol). The second box, the | |
| 837 @sc{cdr} of the first cons cell, refers to the next pair of boxes, the | |
| 838 second cons cell. The @sc{car} of the second cons cell refers to | |
| 839 @code{violet} and the @sc{cdr} refers to the third cons cell. The | |
| 840 @sc{cdr} of the third (and last) cons cell refers to @code{nil}. | |
| 841 | |
| 842 Here is another diagram of the same list, @code{(rose violet | |
| 843 buttercup)}, sketched in a different manner: | |
| 844 | |
| 845 @smallexample | |
| 846 @group | |
| 847 --------------- ---------------- ------------------- | |
| 848 | car | cdr | | car | cdr | | car | cdr | | |
| 849 | rose | o-------->| violet | o-------->| buttercup | nil | | |
| 850 | | | | | | | | | | |
| 851 --------------- ---------------- ------------------- | |
| 852 @end group | |
| 853 @end smallexample | |
| 854 | |
| 855 @cindex @samp{(@dots{})} in lists | |
| 856 @cindex @code{nil} in lists | |
| 857 @cindex empty list | |
| 858 A list with no elements in it is the @dfn{empty list}; it is identical | |
| 859 to the symbol @code{nil}. In other words, @code{nil} is both a symbol | |
| 860 and a list. | |
| 861 | |
| 862 Here are examples of lists written in Lisp syntax: | |
| 863 | |
| 864 @example | |
| 865 (A 2 "A") ; @r{A list of three elements.} | |
| 866 () ; @r{A list of no elements (the empty list).} | |
| 867 nil ; @r{A list of no elements (the empty list).} | |
| 868 ("A ()") ; @r{A list of one element: the string @code{"A ()"}.} | |
| 869 (A ()) ; @r{A list of two elements: @code{A} and the empty list.} | |
| 870 (A nil) ; @r{Equivalent to the previous.} | |
| 871 ((A B C)) ; @r{A list of one element} | |
| 872 ; @r{(which is a list of three elements).} | |
| 873 @end example | |
| 874 | |
| 875 Here is the list @code{(A ())}, or equivalently @code{(A nil)}, | |
| 876 depicted with boxes and arrows: | |
| 877 | |
| 878 @example | |
| 879 @group | |
| 880 ___ ___ ___ ___ | |
| 881 |___|___|--> |___|___|--> nil | |
| 882 | | | |
| 883 | | | |
| 884 --> A --> nil | |
| 885 @end group | |
| 886 @end example | |
| 887 | |
| 888 @menu | |
| 889 * Dotted Pair Notation:: An alternative syntax for lists. | |
| 890 * Association List Type:: A specially constructed list. | |
| 891 @end menu | |
| 892 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
893 @node Dotted Pair Notation, Association List Type, Cons Cell Type, Cons Cell Type |
| 428 | 894 @subsubsection Dotted Pair Notation |
| 895 @cindex dotted pair notation | |
| 896 @cindex @samp{.} in lists | |
| 897 | |
| 898 @dfn{Dotted pair notation} is an alternative syntax for cons cells | |
| 899 that represents the @sc{car} and @sc{cdr} explicitly. In this syntax, | |
| 900 @code{(@var{a} .@: @var{b})} stands for a cons cell whose @sc{car} is | |
| 901 the object @var{a}, and whose @sc{cdr} is the object @var{b}. Dotted | |
| 902 pair notation is therefore more general than list syntax. In the dotted | |
| 903 pair notation, the list @samp{(1 2 3)} is written as @samp{(1 . (2 . (3 | |
| 904 . nil)))}. For @code{nil}-terminated lists, the two notations produce | |
| 905 the same result, but list notation is usually clearer and more | |
| 906 convenient when it is applicable. When printing a list, the dotted pair | |
| 907 notation is only used if the @sc{cdr} of a cell is not a list. | |
| 908 | |
| 909 Here's how box notation can illustrate dotted pairs. This example | |
| 910 shows the pair @code{(rose . violet)}: | |
| 911 | |
| 912 @example | |
| 913 @group | |
| 914 ___ ___ | |
| 915 |___|___|--> violet | |
| 916 | | |
| 917 | | |
| 918 --> rose | |
| 919 @end group | |
| 920 @end example | |
| 921 | |
| 922 Dotted pair notation can be combined with list notation to represent a | |
| 923 chain of cons cells with a non-@code{nil} final @sc{cdr}. For example, | |
| 924 @code{(rose violet . buttercup)} is equivalent to @code{(rose . (violet | |
| 925 . buttercup))}. The object looks like this: | |
| 926 | |
| 927 @example | |
| 928 @group | |
| 929 ___ ___ ___ ___ | |
| 930 |___|___|--> |___|___|--> buttercup | |
| 931 | | | |
| 932 | | | |
| 933 --> rose --> violet | |
| 934 @end group | |
| 935 @end example | |
| 936 | |
| 937 These diagrams make it evident why @w{@code{(rose .@: violet .@: | |
| 938 buttercup)}} is invalid syntax; it would require a cons cell that has | |
| 939 three parts rather than two. | |
| 940 | |
| 941 The list @code{(rose violet)} is equivalent to @code{(rose . (violet))} | |
| 942 and looks like this: | |
| 943 | |
| 944 @example | |
| 945 @group | |
| 946 ___ ___ ___ ___ | |
| 947 |___|___|--> |___|___|--> nil | |
| 948 | | | |
| 949 | | | |
| 950 --> rose --> violet | |
| 951 @end group | |
| 952 @end example | |
| 953 | |
| 954 Similarly, the three-element list @code{(rose violet buttercup)} | |
| 955 is equivalent to @code{(rose . (violet . (buttercup)))}. | |
| 956 @ifinfo | |
| 957 It looks like this: | |
| 958 | |
| 959 @example | |
| 960 @group | |
| 961 ___ ___ ___ ___ ___ ___ | |
| 962 |___|___|--> |___|___|--> |___|___|--> nil | |
| 963 | | | | |
| 964 | | | | |
| 965 --> rose --> violet --> buttercup | |
| 966 @end group | |
| 967 @end example | |
| 968 @end ifinfo | |
| 969 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
970 @node Association List Type, , Dotted Pair Notation, Cons Cell Type |
| 428 | 971 @subsubsection Association List Type |
| 972 | |
| 973 An @dfn{association list} or @dfn{alist} is a specially-constructed | |
| 974 list whose elements are cons cells. In each element, the @sc{car} is | |
| 975 considered a @dfn{key}, and the @sc{cdr} is considered an | |
| 976 @dfn{associated value}. (In some cases, the associated value is stored | |
| 977 in the @sc{car} of the @sc{cdr}.) Association lists are often used as | |
| 978 stacks, since it is easy to add or remove associations at the front of | |
| 979 the list. | |
| 980 | |
| 981 For example, | |
| 982 | |
| 983 @example | |
| 984 (setq alist-of-colors | |
| 985 '((rose . red) (lily . white) (buttercup . yellow))) | |
| 986 @end example | |
| 987 | |
| 988 @noindent | |
| 989 sets the variable @code{alist-of-colors} to an alist of three elements. In the | |
| 990 first element, @code{rose} is the key and @code{red} is the value. | |
| 991 | |
| 992 @xref{Association Lists}, for a further explanation of alists and for | |
| 993 functions that work on alists. | |
| 994 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
995 @node Array Type, String Type, Cons Cell Type, Programming Types |
| 428 | 996 @subsection Array Type |
| 997 | |
| 998 An @dfn{array} is composed of an arbitrary number of slots for | |
| 999 referring to other Lisp objects, arranged in a contiguous block of | |
| 1000 memory. Accessing any element of an array takes the same amount of | |
| 1001 time. In contrast, accessing an element of a list requires time | |
| 1002 proportional to the position of the element in the list. (Elements at | |
| 1003 the end of a list take longer to access than elements at the beginning | |
| 1004 of a list.) | |
| 1005 | |
| 1006 XEmacs defines three types of array, strings, vectors, and bit | |
| 1007 vectors. A string is an array of characters, a vector is an array of | |
| 1008 arbitrary objects, and a bit vector is an array of 1's and 0's. All are | |
| 1009 one-dimensional. (Most other programming languages support | |
| 1010 multidimensional arrays, but they are not essential; you can get the | |
| 1011 same effect with an array of arrays.) Each type of array has its own | |
| 1012 read syntax; see @ref{String Type}, @ref{Vector Type}, and @ref{Bit | |
| 1013 Vector Type}. | |
| 1014 | |
|
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
1015 An array may have any length up to the largest fixnum; but once |
| 428 | 1016 created, it has a fixed size. The first element of an array has index |
| 1017 zero, the second element has index 1, and so on. This is called | |
| 1018 @dfn{zero-origin} indexing. For example, an array of four elements has | |
| 1019 indices 0, 1, 2, @w{and 3}. | |
| 1020 | |
| 1021 The array type is contained in the sequence type and contains the | |
| 1022 string type, the vector type, and the bit vector type. | |
| 1023 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1024 @node String Type, Vector Type, Array Type, Programming Types |
| 428 | 1025 @subsection String Type |
| 1026 | |
| 1027 A @dfn{string} is an array of characters. Strings are used for many | |
| 1028 purposes in XEmacs, as can be expected in a text editor; for example, as | |
| 1029 the names of Lisp symbols, as messages for the user, and to represent | |
| 1030 text extracted from buffers. Strings in Lisp are constants: evaluation | |
| 1031 of a string returns the same string. | |
| 1032 | |
| 1033 @cindex @samp{"} in strings | |
| 1034 @cindex double-quote in strings | |
| 1035 @cindex @samp{\} in strings | |
| 1036 @cindex backslash in strings | |
| 1037 The read syntax for strings is a double-quote, an arbitrary number of | |
| 1038 characters, and another double-quote, @code{"like this"}. The Lisp | |
| 1039 reader accepts the same formats for reading the characters of a string | |
| 1040 as it does for reading single characters (without the question mark that | |
| 1041 begins a character literal). You can enter a nonprinting character such | |
| 1042 as tab or @kbd{C-a} using the convenient escape sequences, like this: | |
| 1043 @code{"\t, \C-a"}. You can include a double-quote in a string by | |
| 1044 preceding it with a backslash; thus, @code{"\""} is a string containing | |
| 1045 just a single double-quote character. (@xref{Character Type}, for a | |
| 1046 description of the read syntax for characters.) | |
| 1047 | |
| 1048 @ignore @c More ill-conceived FSF Emacs crap. | |
| 1049 If you use the @samp{\M-} syntax to indicate a meta character in a | |
| 1050 string constant, this sets the | |
| 1051 @iftex | |
| 1052 $2^{7}$ | |
| 1053 @end iftex | |
| 1054 @ifinfo | |
| 1055 2**7 | |
| 1056 @end ifinfo | |
| 1057 bit of the character in the string. | |
| 1058 This is not the same representation that the meta modifier has in a | |
| 1059 character on its own (not inside a string). @xref{Character Type}. | |
| 1060 | |
| 1061 Strings cannot hold characters that have the hyper, super, or alt | |
| 1062 modifiers; they can hold @sc{ASCII} control characters, but no others. | |
| 1063 They do not distinguish case in @sc{ASCII} control characters. | |
| 1064 @end ignore | |
| 1065 | |
| 1066 The printed representation of a string consists of a double-quote, the | |
| 1067 characters it contains, and another double-quote. However, you must | |
| 1068 escape any backslash or double-quote characters in the string with a | |
| 1069 backslash, like this: @code{"this \" is an embedded quote"}. | |
| 1070 | |
| 3543 | 1071 An alternative syntax allows insertion of raw backslashes into a |
| 1072 string, like this: @code{#r"this \ is an embedded backslash"}. In such | |
| 1073 a string, each character following a backslash is included literally in | |
| 1074 the string, and all backslashes are left in the string. This means that | |
| 1075 @code{#r"\""} is a valid string literal with two characters, a backslash and a | |
| 4265 | 1076 double-quote. It also means that a string with this syntax cannot end |
| 1077 in a single backslash. As with Python, from where this syntax was | |
| 3543 | 1078 taken, you can specify @code{u} or @code{U} after the @code{#r} to |
| 4265 | 1079 specify that interpretation of Unicode escapes should be |
| 1080 done---@pxref{Character Type}---and if you use @code{#ru} for your raw | |
| 1081 strings, the restriction on the trailing backslash can be worked around | |
| 1082 like so: @code{#ru"Backslash: \u005C"}. | |
| 3543 | 1083 |
| 428 | 1084 The newline character is not special in the read syntax for strings; |
| 1085 if you write a new line between the double-quotes, it becomes a | |
| 1086 character in the string. But an escaped newline---one that is preceded | |
| 1087 by @samp{\}---does not become part of the string; i.e., the Lisp reader | |
| 1088 ignores an escaped newline while reading a string. | |
| 1089 @cindex newline in strings | |
| 1090 | |
| 1091 @example | |
| 1092 "It is useful to include newlines | |
| 1093 in documentation strings, | |
| 1094 but the newline is \ | |
| 1095 ignored if escaped." | |
| 1096 @result{} "It is useful to include newlines | |
| 1097 in documentation strings, | |
| 1098 but the newline is ignored if escaped." | |
| 1099 @end example | |
| 1100 | |
| 1101 A string can hold extents and properties of the text it contains, in | |
| 1102 addition to the characters themselves. This enables programs that copy | |
| 1103 text between strings and buffers to preserve the extents and properties | |
| 1104 with no special effort. @xref{Extents}, @xref{Text Properties}. | |
| 1105 | |
| 1106 Note that FSF GNU Emacs has a special read and print syntax for | |
| 1107 strings with text properties, but XEmacs does not currently implement | |
| 1108 this. It was judged better not to include this in XEmacs because it | |
| 1109 entails that @code{equal} return @code{nil} when passed a string with | |
| 1110 text properties and the equivalent string without text properties, which | |
| 1111 is often counter-intuitive. | |
| 1112 | |
| 1113 @ignore @c Not in XEmacs | |
| 1114 Strings with text | |
| 1115 properties have a special read and print syntax: | |
| 1116 | |
| 1117 @example | |
| 1118 #("@var{characters}" @var{property-data}...) | |
| 1119 @end example | |
| 1120 | |
| 1121 @noindent | |
| 1122 where @var{property-data} consists of zero or more elements, in groups | |
| 1123 of three as follows: | |
| 1124 | |
| 1125 @example | |
| 444 | 1126 @var{start} @var{end} @var{plist} |
| 428 | 1127 @end example |
| 1128 | |
| 1129 @noindent | |
| 444 | 1130 The elements @var{start} and @var{end} are integers, and together specify |
| 428 | 1131 a range of indices in the string; @var{plist} is the property list for |
| 1132 that range. | |
| 1133 @end ignore | |
| 1134 | |
| 1135 @xref{Strings and Characters}, for functions that work on strings. | |
| 1136 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1137 @node Vector Type, Bit Vector Type, String Type, Programming Types |
| 428 | 1138 @subsection Vector Type |
| 1139 | |
| 1140 A @dfn{vector} is a one-dimensional array of elements of any type. It | |
| 1141 takes a constant amount of time to access any element of a vector. (In | |
| 1142 a list, the access time of an element is proportional to the distance of | |
| 1143 the element from the beginning of the list.) | |
| 1144 | |
| 1145 The printed representation of a vector consists of a left square | |
| 1146 bracket, the elements, and a right square bracket. This is also the | |
| 1147 read syntax. Like numbers and strings, vectors are considered constants | |
| 1148 for evaluation. | |
| 1149 | |
| 1150 @example | |
| 1151 [1 "two" (three)] ; @r{A vector of three elements.} | |
| 1152 @result{} [1 "two" (three)] | |
| 1153 @end example | |
| 1154 | |
| 1155 @xref{Vectors}, for functions that work with vectors. | |
| 1156 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1157 @node Bit Vector Type, Function Type, Vector Type, Programming Types |
| 428 | 1158 @subsection Bit Vector Type |
| 1159 | |
| 1160 A @dfn{bit vector} is a one-dimensional array of 1's and 0's. It | |
| 1161 takes a constant amount of time to access any element of a bit vector, | |
| 1162 as for vectors. Bit vectors have an extremely compact internal | |
| 1163 representation (one machine bit per element), which makes them ideal | |
| 1164 for keeping track of unordered sets, large collections of boolean values, | |
| 1165 etc. | |
| 1166 | |
| 1167 The printed representation of a bit vector consists of @samp{#*} | |
| 1168 followed by the bits in the vector. This is also the read syntax. Like | |
| 1169 numbers, strings, and vectors, bit vectors are considered constants for | |
| 1170 evaluation. | |
| 1171 | |
| 1172 @example | |
| 1173 #*00101000 ; @r{A bit vector of eight elements.} | |
| 1174 @result{} #*00101000 | |
| 1175 @end example | |
| 1176 | |
| 1177 @xref{Bit Vectors}, for functions that work with bit vectors. | |
| 1178 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1179 @node Function Type, Macro Type, Bit Vector Type, Programming Types |
| 428 | 1180 @subsection Function Type |
| 1181 | |
| 1182 Just as functions in other programming languages are executable, | |
| 1183 @dfn{Lisp function} objects are pieces of executable code. However, | |
| 1184 functions in Lisp are primarily Lisp objects, and only secondarily the | |
| 1185 text which represents them. These Lisp objects are lambda expressions: | |
| 1186 lists whose first element is the symbol @code{lambda} (@pxref{Lambda | |
| 1187 Expressions}). | |
| 1188 | |
| 1189 In most programming languages, it is impossible to have a function | |
| 1190 without a name. In Lisp, a function has no intrinsic name. A lambda | |
| 1191 expression is also called an @dfn{anonymous function} (@pxref{Anonymous | |
| 1192 Functions}). A named function in Lisp is actually a symbol with a valid | |
| 1193 function in its function cell (@pxref{Defining Functions}). | |
| 1194 | |
| 1195 Most of the time, functions are called when their names are written in | |
| 1196 Lisp expressions in Lisp programs. However, you can construct or obtain | |
| 1197 a function object at run time and then call it with the primitive | |
| 1198 functions @code{funcall} and @code{apply}. @xref{Calling Functions}. | |
| 1199 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1200 @node Macro Type, Primitive Function Type, Function Type, Programming Types |
| 428 | 1201 @subsection Macro Type |
| 1202 | |
| 1203 A @dfn{Lisp macro} is a user-defined construct that extends the Lisp | |
| 1204 language. It is represented as an object much like a function, but with | |
| 1205 different parameter-passing semantics. A Lisp macro has the form of a | |
| 1206 list whose first element is the symbol @code{macro} and whose @sc{cdr} | |
| 1207 is a Lisp function object, including the @code{lambda} symbol. | |
| 1208 | |
| 1209 Lisp macro objects are usually defined with the built-in | |
| 1210 @code{defmacro} function, but any list that begins with @code{macro} is | |
| 1211 a macro as far as XEmacs is concerned. @xref{Macros}, for an explanation | |
| 1212 of how to write a macro. | |
| 1213 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1214 @node Primitive Function Type, Compiled-Function Type, Macro Type, Programming Types |
| 428 | 1215 @subsection Primitive Function Type |
|
4905
755ae5b97edb
Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4885
diff
changeset
|
1216 @cindex special operators |
| 428 | 1217 |
| 1218 A @dfn{primitive function} is a function callable from Lisp but | |
| 1219 written in the C programming language. Primitive functions are also | |
| 1220 called @dfn{subrs} or @dfn{built-in functions}. (The word ``subr'' is | |
| 1221 derived from ``subroutine''.) Most primitive functions evaluate all | |
| 1222 their arguments when they are called. A primitive function that does | |
|
4905
755ae5b97edb
Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4885
diff
changeset
|
1223 not evaluate all its arguments is called a @dfn{special operator} |
|
755ae5b97edb
Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4885
diff
changeset
|
1224 (@pxref{Special Operators}).@refill |
| 428 | 1225 |
| 1226 It does not matter to the caller of a function whether the function is | |
| 1227 primitive. However, this does matter if you try to substitute a | |
| 1228 function written in Lisp for a primitive of the same name. The reason | |
| 1229 is that the primitive function may be called directly from C code. | |
| 1230 Calls to the redefined function from Lisp will use the new definition, | |
| 1231 but calls from C code may still use the built-in definition. | |
| 1232 | |
| 1233 The term @dfn{function} refers to all Emacs functions, whether written | |
| 1234 in Lisp or C. @xref{Function Type}, for information about the | |
| 1235 functions written in Lisp. | |
| 1236 | |
| 1237 Primitive functions have no read syntax and print in hash notation | |
| 1238 with the name of the subroutine. | |
| 1239 | |
| 1240 @example | |
| 1241 @group | |
| 1242 (symbol-function 'car) ; @r{Access the function cell} | |
| 1243 ; @r{of the symbol.} | |
| 1244 @result{} #<subr car> | |
| 1245 (subrp (symbol-function 'car)) ; @r{Is this a primitive function?} | |
| 1246 @result{} t ; @r{Yes.} | |
| 1247 @end group | |
| 1248 @end example | |
| 1249 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1250 @node Compiled-Function Type, Autoload Type, Primitive Function Type, Programming Types |
| 428 | 1251 @subsection Compiled-Function Type |
| 1252 | |
| 1253 The byte compiler produces @dfn{compiled-function objects}. The | |
| 1254 evaluator handles this data type specially when it appears as a function | |
| 1255 to be called. @xref{Byte Compilation}, for information about the byte | |
| 1256 compiler. | |
| 1257 | |
| 1258 The printed representation for a compiled-function object is normally | |
| 1259 @samp{#<compiled-function...>}. If @code{print-readably} is true, | |
| 1260 however, it is @samp{#[...]}. | |
| 1261 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1262 @node Autoload Type, Char Table Type, Compiled-Function Type, Programming Types |
| 428 | 1263 @subsection Autoload Type |
| 1264 | |
| 1265 An @dfn{autoload object} is a list whose first element is the symbol | |
| 1266 @code{autoload}. It is stored as the function definition of a symbol as | |
| 1267 a placeholder for the real definition; it says that the real definition | |
| 1268 is found in a file of Lisp code that should be loaded when necessary. | |
| 1269 The autoload object contains the name of the file, plus some other | |
| 1270 information about the real definition. | |
| 1271 | |
| 1272 After the file has been loaded, the symbol should have a new function | |
| 1273 definition that is not an autoload object. The new definition is then | |
| 1274 called as if it had been there to begin with. From the user's point of | |
| 1275 view, the function call works as expected, using the function definition | |
| 1276 in the loaded file. | |
| 1277 | |
| 1278 An autoload object is usually created with the function | |
| 1279 @code{autoload}, which stores the object in the function cell of a | |
| 1280 symbol. @xref{Autoload}, for more details. | |
| 1281 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1282 @node Char Table Type, Hash Table Type, Autoload Type, Programming Types |
| 428 | 1283 @subsection Char Table Type |
| 1284 @cindex char table type | |
| 1285 | |
| 1286 (not yet documented) | |
| 1287 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1288 @node Hash Table Type, Range Table Type, Char Table Type, Programming Types |
| 428 | 1289 @subsection Hash Table Type |
| 1290 @cindex hash table type | |
| 1291 | |
| 1292 A @dfn{hash table} is a table providing an arbitrary mapping from | |
| 1293 one Lisp object to another, using an internal indexing method | |
| 1294 called @dfn{hashing}. Hash tables are very fast (much more efficient | |
| 1295 that using an association list, when there are a large number of | |
| 1296 elements in the table). | |
| 1297 | |
| 1298 Hash tables have a special read syntax beginning with | |
| 1299 @samp{#s(hash-table} (this is an example of @dfn{structure} read | |
| 1300 syntax. This notation is also used for printing when | |
| 1301 @code{print-readably} is @code{t}. | |
| 1302 | |
| 1303 Otherwise they print in hash notation (The ``hash'' in ``hash notation'' | |
| 1304 has nothing to do with the ``hash'' in ``hash table''), giving the | |
| 1305 number of elements, total space allocated for elements, and a unique | |
| 1306 number assigned at the time the hash table was created. (Hash tables | |
| 1307 automatically resize as necessary so there is no danger of running out | |
| 1308 of space for elements.) | |
| 1309 | |
| 1310 @example | |
| 1311 @group | |
| 1312 (make-hash-table :size 50) | |
|
4820
e6dec75ded0e
Use keywords, not ordinary symbols, in the structure syntax for hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4792
diff
changeset
|
1313 @result{} #<hash-table :size 0/107 0x3babb0e4> |
| 428 | 1314 @end group |
| 1315 @end example | |
| 1316 | |
| 1317 @xref{Hash Tables}, for information on how to create and work with hash | |
| 1318 tables. | |
| 1319 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1320 @node Range Table Type, Weak List Type, Hash Table Type, Programming Types |
| 428 | 1321 @subsection Range Table Type |
| 1322 @cindex range table type | |
| 1323 | |
|
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
1324 A @dfn{range table} is a table that maps from ranges of fixnums to |
| 428 | 1325 arbitrary Lisp objects. Range tables automatically combine overlapping |
| 1326 ranges that map to the same Lisp object, and operations are provided | |
| 1327 for mapping over all of the ranges in a range table. | |
| 1328 | |
| 1329 Range tables have a special read syntax beginning with | |
| 1330 @samp{#s(range-table} (this is an example of @dfn{structure} read syntax, | |
| 1331 which is also used for char tables and faces). | |
| 1332 | |
| 1333 @example | |
| 1334 @group | |
| 1335 (setq x (make-range-table)) | |
| 1336 (put-range-table 20 50 'foo x) | |
| 1337 (put-range-table 100 200 "bar" x) | |
| 1338 x | |
| 1339 @result{} #s(range-table data ((20 50) foo (100 200) "bar")) | |
| 1340 @end group | |
| 1341 @end example | |
| 1342 | |
| 1343 @xref{Range Tables}, for information on how to create and work with range | |
| 1344 tables. | |
| 1345 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1346 @node Weak List Type, , Range Table Type, Programming Types |
| 428 | 1347 @subsection Weak List Type |
| 1348 @cindex weak list type | |
| 1349 | |
| 1350 (not yet documented) | |
| 1351 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1352 @node Editing Types, Window-System Types, Programming Types, Lisp Data Types |
| 428 | 1353 @section Editing Types |
| 1354 @cindex editing types | |
| 1355 | |
| 1356 The types in the previous section are common to many Lisp dialects. | |
| 1357 XEmacs Lisp provides several additional data types for purposes connected | |
| 1358 with editing. | |
| 1359 | |
| 1360 @menu | |
| 1361 * Buffer Type:: The basic object of editing. | |
| 1362 * Marker Type:: A position in a buffer. | |
| 1363 * Extent Type:: A range in a buffer or string, maybe with properties. | |
| 1364 * Window Type:: Buffers are displayed in windows. | |
| 1365 * Frame Type:: Windows subdivide frames. | |
| 1366 * Device Type:: Devices group all frames on a display. | |
| 1367 * Console Type:: Consoles group all devices with the same keyboard. | |
| 1368 * Window Configuration Type:: Recording the way a frame is subdivided. | |
| 1369 * Event Type:: An interesting occurrence in the system. | |
| 1370 * Process Type:: A process running on the underlying OS. | |
| 1371 * Stream Type:: Receive or send characters. | |
| 1372 * Keymap Type:: What function a keystroke invokes. | |
| 1373 * Syntax Table Type:: What a character means. | |
| 1374 * Display Table Type:: How display tables are represented. | |
| 1375 * Database Type:: A connection to an external DBM or DB database. | |
| 1376 * Charset Type:: A character set (e.g. all Kanji characters), | |
| 1377 under XEmacs/MULE. | |
| 1378 * Coding System Type:: An object encapsulating a way of converting between | |
| 1379 different textual encodings, under XEmacs/MULE. | |
| 1380 * ToolTalk Message Type:: A message, in the ToolTalk IPC protocol. | |
| 1381 * ToolTalk Pattern Type:: A pattern, in the ToolTalk IPC protocol. | |
| 1382 @end menu | |
| 1383 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1384 @node Buffer Type, Marker Type, Editing Types, Editing Types |
| 428 | 1385 @subsection Buffer Type |
| 1386 | |
| 1387 A @dfn{buffer} is an object that holds text that can be edited | |
| 1388 (@pxref{Buffers}). Most buffers hold the contents of a disk file | |
| 1389 (@pxref{Files}) so they can be edited, but some are used for other | |
| 1390 purposes. Most buffers are also meant to be seen by the user, and | |
| 1391 therefore displayed, at some time, in a window (@pxref{Windows}). But a | |
| 1392 buffer need not be displayed in any window. | |
| 1393 | |
| 1394 The contents of a buffer are much like a string, but buffers are not | |
| 1395 used like strings in XEmacs Lisp, and the available operations are | |
| 1396 different. For example, insertion of text into a buffer is very | |
| 1397 efficient, whereas ``inserting'' text into a string requires | |
| 1398 concatenating substrings, and the result is an entirely new string | |
| 1399 object. | |
| 1400 | |
| 1401 Each buffer has a designated position called @dfn{point} | |
| 1402 (@pxref{Positions}). At any time, one buffer is the @dfn{current | |
| 1403 buffer}. Most editing commands act on the contents of the current | |
| 1404 buffer in the neighborhood of point. Many of the standard Emacs | |
| 1405 functions manipulate or test the characters in the current buffer; a | |
| 1406 whole chapter in this manual is devoted to describing these functions | |
| 1407 (@pxref{Text}). | |
| 1408 | |
| 1409 Several other data structures are associated with each buffer: | |
| 1410 | |
| 1411 @itemize @bullet | |
| 1412 @item | |
| 1413 a local syntax table (@pxref{Syntax Tables}); | |
| 1414 | |
| 1415 @item | |
| 1416 a local keymap (@pxref{Keymaps}); | |
| 1417 | |
| 1418 @item | |
| 1419 a local variable binding list (@pxref{Buffer-Local Variables}); | |
| 1420 | |
| 1421 @item | |
| 1422 a list of extents (@pxref{Extents}); | |
| 1423 | |
| 1424 @item | |
| 1425 and various other related properties. | |
| 1426 @end itemize | |
| 1427 | |
| 1428 @noindent | |
| 1429 The local keymap and variable list contain entries that individually | |
| 1430 override global bindings or values. These are used to customize the | |
| 1431 behavior of programs in different buffers, without actually changing the | |
| 1432 programs. | |
| 1433 | |
| 1434 A buffer may be @dfn{indirect}, which means it shares the text | |
| 1435 of another buffer. @xref{Indirect Buffers}. | |
| 1436 | |
| 1437 Buffers have no read syntax. They print in hash notation, showing the | |
| 1438 buffer name. | |
| 1439 | |
| 1440 @example | |
| 1441 @group | |
| 1442 (current-buffer) | |
| 1443 @result{} #<buffer "objects.texi"> | |
| 1444 @end group | |
| 1445 @end example | |
| 1446 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1447 @node Marker Type, Extent Type, Buffer Type, Editing Types |
| 428 | 1448 @subsection Marker Type |
| 1449 | |
| 1450 A @dfn{marker} denotes a position in a specific buffer. Markers | |
| 1451 therefore have two components: one for the buffer, and one for the | |
| 1452 position. Changes in the buffer's text automatically relocate the | |
| 1453 position value as necessary to ensure that the marker always points | |
| 1454 between the same two characters in the buffer. | |
| 1455 | |
| 1456 Markers have no read syntax. They print in hash notation, giving the | |
| 1457 current character position and the name of the buffer. | |
| 1458 | |
| 1459 @example | |
| 1460 @group | |
| 1461 (point-marker) | |
| 1462 @result{} #<marker at 50661 in objects.texi> | |
| 1463 @end group | |
| 1464 @end example | |
| 1465 | |
| 1466 @xref{Markers}, for information on how to test, create, copy, and move | |
| 1467 markers. | |
| 1468 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1469 @node Extent Type, Window Type, Marker Type, Editing Types |
| 428 | 1470 @subsection Extent Type |
| 1471 | |
| 1472 An @dfn{extent} specifies temporary alteration of the display | |
| 1473 appearance of a part of a buffer (or string). It contains markers | |
| 1474 delimiting a range of the buffer, plus a property list (a list whose | |
| 1475 elements are alternating property names and values). Extents are used | |
| 1476 to present parts of the buffer temporarily in a different display style. | |
| 1477 They have no read syntax, and print in hash notation, giving the buffer | |
| 1478 name and range of positions. | |
| 1479 | |
| 1480 Extents can exist over strings as well as buffers; the primary use | |
| 1481 of this is to preserve extent and text property information as text | |
| 1482 is copied from one buffer to another or between different parts of | |
| 1483 a buffer. | |
| 1484 | |
| 1485 Extents have no read syntax. They print in hash notation, giving the | |
| 1486 range of text they cover, the name of the buffer or string they are in, | |
| 1487 the address in core, and a summary of some of the properties attached to | |
| 1488 the extent. | |
| 1489 | |
| 1490 @example | |
| 1491 @group | |
| 1492 (extent-at (point)) | |
| 1493 @result{} #<extent [51742, 51748) font-lock text-prop 0x90121e0 in buffer objects.texi> | |
| 1494 @end group | |
| 1495 @end example | |
| 1496 | |
| 1497 @xref{Extents}, for how to create and use extents. | |
| 1498 | |
| 1499 Extents are used to implement text properties. @xref{Text Properties}. | |
| 1500 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1501 @node Window Type, Frame Type, Extent Type, Editing Types |
| 428 | 1502 @subsection Window Type |
| 1503 | |
| 1504 A @dfn{window} describes the portion of the frame that XEmacs uses to | |
| 1505 display a buffer. (In standard window-system usage, a @dfn{window} is | |
| 1506 what XEmacs calls a @dfn{frame}; XEmacs confusingly uses the term | |
| 1507 ``window'' to refer to what is called a @dfn{pane} in standard | |
| 1508 window-system usage.) Every window has one associated buffer, whose | |
| 1509 contents appear in the window. By contrast, a given buffer may appear | |
| 1510 in one window, no window, or several windows. | |
| 1511 | |
| 1512 Though many windows may exist simultaneously, at any time one window | |
| 1513 is designated the @dfn{selected window}. This is the window where the | |
| 1514 cursor is (usually) displayed when XEmacs is ready for a command. The | |
| 1515 selected window usually displays the current buffer, but this is not | |
| 1516 necessarily the case. | |
| 1517 | |
| 1518 Windows are grouped on the screen into frames; each window belongs to | |
| 1519 one and only one frame. @xref{Frame Type}. | |
| 1520 | |
| 1521 Windows have no read syntax. They print in hash notation, giving the | |
| 1522 name of the buffer being displayed and a unique number assigned at the | |
| 1523 time the window was created. (This number can be useful because the | |
| 1524 buffer displayed in any given window can change frequently.) | |
| 1525 | |
| 1526 @example | |
| 1527 @group | |
| 1528 (selected-window) | |
| 1529 @result{} #<window on "objects.texi" 0x266c> | |
| 1530 @end group | |
| 1531 @end example | |
| 1532 | |
| 1533 @xref{Windows}, for a description of the functions that work on windows. | |
| 1534 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1535 @node Frame Type, Device Type, Window Type, Editing Types |
| 428 | 1536 @subsection Frame Type |
| 1537 | |
| 1538 A @var{frame} is a rectangle on the screen (a @dfn{window} in standard | |
| 1539 window-system terminology) that contains one or more non-overlapping | |
| 1540 Emacs windows (@dfn{panes} in standard window-system terminology). A | |
| 1541 frame initially contains a single main window (plus perhaps a minibuffer | |
| 1542 window) which you can subdivide vertically or horizontally into smaller | |
| 1543 windows. | |
| 1544 | |
| 1545 Frames have no read syntax. They print in hash notation, giving the | |
| 1546 frame's type, name as used for resourcing, and a unique number assigned | |
| 1547 at the time the frame was created. | |
| 1548 | |
| 1549 @example | |
| 1550 @group | |
| 1551 (selected-frame) | |
| 1552 @result{} #<x-frame "emacs" 0x9db> | |
| 1553 @end group | |
| 1554 @end example | |
| 1555 | |
| 1556 @xref{Frames}, for a description of the functions that work on frames. | |
| 1557 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1558 @node Device Type, Console Type, Frame Type, Editing Types |
| 428 | 1559 @subsection Device Type |
| 1560 | |
| 1561 A @dfn{device} represents a single display on which frames exist. | |
| 1562 Normally, there is only one device object, but there may be more | |
| 1563 than one if XEmacs is being run on a multi-headed display (e.g. an | |
| 1564 X server with attached color and mono screens) or if XEmacs is | |
| 1565 simultaneously driving frames attached to different consoles, e.g. | |
| 1566 an X display and a @sc{tty} connection. | |
| 1567 | |
| 1568 Devices do not have a read syntax. They print in hash notation, | |
| 1569 giving the device's type, connection name, and a unique number assigned | |
| 1570 at the time the device was created. | |
| 1571 | |
| 1572 @example | |
| 1573 @group | |
| 1574 (selected-device) | |
| 1575 @result{} #<x-device on ":0.0" 0x5b9> | |
| 1576 @end group | |
| 1577 @end example | |
| 1578 | |
| 1579 @xref{Consoles and Devices}, for a description of several functions | |
| 1580 related to devices. | |
| 1581 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1582 @node Console Type, Window Configuration Type, Device Type, Editing Types |
| 428 | 1583 @subsection Console Type |
| 1584 | |
| 1585 A @dfn{console} represents a single keyboard to which devices | |
| 1586 (i.e. displays on which frames exist) are connected. Normally, there is | |
| 1587 only one console object, but there may be more than one if XEmacs is | |
| 1588 simultaneously driving frames attached to different X servers and/or | |
| 1589 @sc{tty} connections. (XEmacs is capable of driving multiple X and | |
| 1590 @sc{tty} connections at the same time, and provides a robust mechanism | |
| 1591 for handling the differing display capabilities of such heterogeneous | |
| 1592 environments. A buffer with embedded glyphs and multiple fonts and | |
| 1593 colors, for example, will display reasonably if it simultaneously | |
| 1594 appears on a frame on a color X display, a frame on a mono X display, | |
| 1595 and a frame on a @sc{tty} connection.) | |
| 1596 | |
| 1597 Consoles do not have a read syntax. They print in hash notation, | |
| 1598 giving the console's type, connection name, and a unique number assigned | |
| 1599 at the time the console was created. | |
| 1600 | |
| 1601 @example | |
| 1602 @group | |
| 1603 (selected-console) | |
| 1604 @result{} #<x-console on "localhost:0" 0x5b7> | |
| 1605 @end group | |
| 1606 @end example | |
| 1607 | |
| 1608 @xref{Consoles and Devices}, for a description of several functions | |
| 1609 related to consoles. | |
| 1610 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1611 @node Window Configuration Type, Event Type, Console Type, Editing Types |
| 428 | 1612 @subsection Window Configuration Type |
| 1613 @cindex screen layout | |
| 1614 | |
| 1615 A @dfn{window configuration} stores information about the positions, | |
| 1616 sizes, and contents of the windows in a frame, so you can recreate the | |
| 1617 same arrangement of windows later. | |
| 1618 | |
| 1619 Window configurations do not have a read syntax. They print in hash | |
| 1620 notation, giving a unique number assigned at the time the window | |
| 1621 configuration was created. | |
| 1622 | |
| 1623 @example | |
| 1624 @group | |
| 1625 (current-window-configuration) | |
| 1626 @result{} #<window-configuration 0x2db4> | |
| 1627 @end group | |
| 1628 @end example | |
| 1629 | |
| 1630 @xref{Window Configurations}, for a description of several functions | |
| 1631 related to window configurations. | |
| 1632 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1633 @node Event Type, Process Type, Window Configuration Type, Editing Types |
| 428 | 1634 @subsection Event Type |
| 1635 | |
| 1636 (not yet documented) | |
| 1637 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1638 @node Process Type, Stream Type, Event Type, Editing Types |
| 428 | 1639 @subsection Process Type |
| 1640 | |
| 1641 The word @dfn{process} usually means a running program. XEmacs itself | |
| 1642 runs in a process of this sort. However, in XEmacs Lisp, a process is a | |
| 1643 Lisp object that designates a subprocess created by the XEmacs process. | |
| 1644 Programs such as shells, GDB, ftp, and compilers, running in | |
| 1645 subprocesses of XEmacs, extend the capabilities of XEmacs. | |
| 1646 | |
| 1647 An Emacs subprocess takes textual input from Emacs and returns textual | |
| 1648 output to Emacs for further manipulation. Emacs can also send signals | |
| 1649 to the subprocess. | |
| 1650 | |
| 1651 Process objects have no read syntax. They print in hash notation, | |
| 1652 giving the name of the process, its associated process ID, and the | |
| 1653 current state of the process: | |
| 1654 | |
| 1655 @example | |
| 1656 @group | |
| 1657 (process-list) | |
| 1658 @result{} (#<process "shell" pid 2909 state:run>) | |
| 1659 @end group | |
| 1660 @end example | |
| 1661 | |
| 1662 @xref{Processes}, for information about functions that create, delete, | |
| 1663 return information about, send input or signals to, and receive output | |
| 1664 from processes. | |
| 1665 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1666 @node Stream Type, Keymap Type, Process Type, Editing Types |
| 428 | 1667 @subsection Stream Type |
| 1668 | |
| 1669 A @dfn{stream} is an object that can be used as a source or sink for | |
| 1670 characters---either to supply characters for input or to accept them as | |
| 1671 output. Many different types can be used this way: markers, buffers, | |
| 1672 strings, and functions. Most often, input streams (character sources) | |
| 1673 obtain characters from the keyboard, a buffer, or a file, and output | |
| 1674 streams (character sinks) send characters to a buffer, such as a | |
| 1675 @file{*Help*} buffer, or to the echo area. | |
| 1676 | |
| 1677 The object @code{nil}, in addition to its other meanings, may be used | |
| 1678 as a stream. It stands for the value of the variable | |
| 1679 @code{standard-input} or @code{standard-output}. Also, the object | |
| 1680 @code{t} as a stream specifies input using the minibuffer | |
| 1681 (@pxref{Minibuffers}) or output in the echo area (@pxref{The Echo | |
| 1682 Area}). | |
| 1683 | |
| 1684 Streams have no special printed representation or read syntax, and | |
| 1685 print as whatever primitive type they are. | |
| 1686 | |
| 1687 @xref{Read and Print}, for a description of functions | |
| 1688 related to streams, including parsing and printing functions. | |
| 1689 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1690 @node Keymap Type, Syntax Table Type, Stream Type, Editing Types |
| 428 | 1691 @subsection Keymap Type |
| 1692 | |
| 1693 A @dfn{keymap} maps keys typed by the user to commands. This mapping | |
| 1694 controls how the user's command input is executed. | |
| 1695 | |
| 1696 NOTE: In XEmacs, a keymap is a separate primitive type. In FSF GNU | |
| 1697 Emacs, a keymap is actually a list whose @sc{car} is the symbol | |
| 1698 @code{keymap}. | |
| 1699 | |
| 1700 @xref{Keymaps}, for information about creating keymaps, handling prefix | |
| 1701 keys, local as well as global keymaps, and changing key bindings. | |
| 1702 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1703 @node Syntax Table Type, Display Table Type, Keymap Type, Editing Types |
| 428 | 1704 @subsection Syntax Table Type |
| 1705 | |
| 1706 Under XEmacs 20, a @dfn{syntax table} is a particular type of char | |
|
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
1707 table. Under XEmacs 19, a syntax table is a vector of 256 integers. In |
| 428 | 1708 both cases, each element defines how one character is interpreted when it |
| 1709 appears in a buffer. For example, in C mode (@pxref{Major Modes}), the | |
| 1710 @samp{+} character is punctuation, but in Lisp mode it is a valid | |
| 1711 character in a symbol. These modes specify different interpretations by | |
| 1712 changing the syntax table entry for @samp{+}. | |
| 1713 | |
| 1714 Syntax tables are used only for scanning text in buffers, not for | |
| 1715 reading Lisp expressions. The table the Lisp interpreter uses to read | |
| 1716 expressions is built into the XEmacs source code and cannot be changed; | |
| 1717 thus, to change the list delimiters to be @samp{@{} and @samp{@}} | |
| 1718 instead of @samp{(} and @samp{)} would be impossible. | |
| 1719 | |
| 1720 @xref{Syntax Tables}, for details about syntax classes and how to make | |
| 1721 and modify syntax tables. | |
| 1722 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1723 @node Display Table Type, Database Type, Syntax Table Type, Editing Types |
| 428 | 1724 @subsection Display Table Type |
| 1725 | |
| 1726 A @dfn{display table} specifies how to display each character code. | |
| 1727 Each buffer and each window can have its own display table. A display | |
| 1728 table is actually a vector of length 256, although in XEmacs 20 this may | |
| 1729 change to be a particular type of char table. @xref{Display Tables}. | |
| 1730 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1731 @node Database Type, Charset Type, Display Table Type, Editing Types |
| 428 | 1732 @subsection Database Type |
| 1733 @cindex database type | |
| 1734 | |
| 1735 (not yet documented) | |
| 1736 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1737 @node Charset Type, Coding System Type, Database Type, Editing Types |
| 428 | 1738 @subsection Charset Type |
| 1739 @cindex charset type | |
| 1740 | |
| 1741 (not yet documented) | |
| 1742 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1743 @node Coding System Type, ToolTalk Message Type, Charset Type, Editing Types |
| 428 | 1744 @subsection Coding System Type |
| 1745 @cindex coding system type | |
| 1746 | |
| 1747 (not yet documented) | |
| 1748 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1749 @node ToolTalk Message Type, ToolTalk Pattern Type, Coding System Type, Editing Types |
| 428 | 1750 @subsection ToolTalk Message Type |
| 1751 | |
| 1752 (not yet documented) | |
| 1753 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1754 @node ToolTalk Pattern Type, , ToolTalk Message Type, Editing Types |
| 428 | 1755 @subsection ToolTalk Pattern Type |
| 1756 | |
| 1757 (not yet documented) | |
| 1758 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1759 @node Window-System Types, Type Predicates, Editing Types, Lisp Data Types |
| 428 | 1760 @section Window-System Types |
| 1761 @cindex window system types | |
| 1762 | |
| 1763 XEmacs also has some types that represent objects such as faces | |
| 1764 (collections of display characters), fonts, and pixmaps that are | |
| 1765 commonly found in windowing systems. | |
| 1766 | |
| 1767 @menu | |
| 1768 * Face Type:: A collection of display characteristics. | |
| 1769 * Glyph Type:: An image appearing in a buffer or elsewhere. | |
| 1770 * Specifier Type:: A way of controlling display characteristics on | |
| 1771 a per-buffer, -frame, -window, or -device level. | |
| 1772 * Font Instance Type:: The way a font appears on a particular device. | |
| 1773 * Color Instance Type:: The way a color appears on a particular device. | |
| 1774 * Image Instance Type:: The way an image appears on a particular device. | |
| 1775 * Toolbar Button Type:: An object representing a button in a toolbar. | |
| 1776 * Subwindow Type:: An externally-controlled window-system window | |
| 1777 appearing in a buffer. | |
| 1778 * X Resource Type:: A miscellaneous X resource, if Epoch support was | |
| 1779 compiled into XEmacs. | |
| 1780 @end menu | |
| 1781 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1782 @node Face Type, Glyph Type, Window-System Types, Window-System Types |
| 428 | 1783 @subsection Face Type |
| 1784 @cindex face type | |
| 1785 | |
| 1786 (not yet documented) | |
| 1787 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1788 @node Glyph Type, Specifier Type, Face Type, Window-System Types |
| 428 | 1789 @subsection Glyph Type |
| 1790 @cindex glyph type | |
| 1791 | |
| 1792 (not yet documented) | |
| 1793 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1794 @node Specifier Type, Font Instance Type, Glyph Type, Window-System Types |
| 428 | 1795 @subsection Specifier Type |
| 1796 @cindex specifier type | |
| 1797 | |
| 1798 (not yet documented) | |
| 1799 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1800 @node Font Instance Type, Color Instance Type, Specifier Type, Window-System Types |
| 428 | 1801 @subsection Font Instance Type |
| 1802 @cindex font instance type | |
| 1803 | |
| 1804 (not yet documented) | |
| 1805 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1806 @node Color Instance Type, Image Instance Type, Font Instance Type, Window-System Types |
| 428 | 1807 @subsection Color Instance Type |
| 1808 @cindex color instance type | |
| 1809 | |
| 1810 (not yet documented) | |
| 1811 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1812 @node Image Instance Type, Toolbar Button Type, Color Instance Type, Window-System Types |
| 428 | 1813 @subsection Image Instance Type |
| 1814 @cindex image instance type | |
| 1815 | |
| 1816 (not yet documented) | |
| 1817 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1818 @node Toolbar Button Type, Subwindow Type, Image Instance Type, Window-System Types |
| 428 | 1819 @subsection Toolbar Button Type |
| 1820 @cindex toolbar button type | |
| 1821 | |
| 1822 (not yet documented) | |
| 1823 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1824 @node Subwindow Type, X Resource Type, Toolbar Button Type, Window-System Types |
| 428 | 1825 @subsection Subwindow Type |
| 1826 @cindex subwindow type | |
| 1827 | |
| 1828 (not yet documented) | |
| 1829 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1830 @node X Resource Type, , Subwindow Type, Window-System Types |
| 428 | 1831 @subsection X Resource Type |
| 1832 @cindex X resource type | |
| 1833 | |
| 1834 (not yet documented) | |
| 1835 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
1836 @node Type Predicates, Equality Predicates, Window-System Types, Lisp Data Types |
| 428 | 1837 @section Type Predicates |
| 1838 @cindex predicates | |
| 1839 @cindex type checking | |
| 1840 @kindex wrong-type-argument | |
| 1841 | |
| 1842 The XEmacs Lisp interpreter itself does not perform type checking on | |
| 1843 the actual arguments passed to functions when they are called. It could | |
| 1844 not do so, since function arguments in Lisp do not have declared data | |
| 1845 types, as they do in other programming languages. It is therefore up to | |
| 1846 the individual function to test whether each actual argument belongs to | |
| 1847 a type that the function can use. | |
| 1848 | |
| 1849 All built-in functions do check the types of their actual arguments | |
| 1850 when appropriate, and signal a @code{wrong-type-argument} error if an | |
| 1851 argument is of the wrong type. For example, here is what happens if you | |
| 1852 pass an argument to @code{+} that it cannot handle: | |
| 1853 | |
| 1854 @example | |
| 1855 @group | |
| 1856 (+ 2 'a) | |
| 1857 @error{} Wrong type argument: integer-or-marker-p, a | |
| 1858 @end group | |
| 1859 @end example | |
| 1860 | |
| 1861 @cindex type predicates | |
| 1862 @cindex testing types | |
| 1863 If you want your program to handle different types differently, you | |
| 1864 must do explicit type checking. The most common way to check the type | |
| 1865 of an object is to call a @dfn{type predicate} function. Emacs has a | |
| 1866 type predicate for each type, as well as some predicates for | |
| 1867 combinations of types. | |
| 1868 | |
| 1869 A type predicate function takes one argument; it returns @code{t} if | |
| 1870 the argument belongs to the appropriate type, and @code{nil} otherwise. | |
| 1871 Following a general Lisp convention for predicate functions, most type | |
| 1872 predicates' names end with @samp{p}. | |
| 1873 | |
| 1874 Here is an example which uses the predicates @code{listp} to check for | |
| 1875 a list and @code{symbolp} to check for a symbol. | |
| 1876 | |
| 1877 @example | |
| 1878 (defun add-on (x) | |
| 1879 (cond ((symbolp x) | |
| 1880 ;; If X is a symbol, put it on LIST. | |
| 1881 (setq list (cons x list))) | |
| 1882 ((listp x) | |
| 1883 ;; If X is a list, add its elements to LIST. | |
| 1884 (setq list (append x list))) | |
| 1885 @need 3000 | |
| 1886 (t | |
| 1887 ;; We only handle symbols and lists. | |
| 1888 (error "Invalid argument %s in add-on" x)))) | |
| 1889 @end example | |
| 1890 | |
| 1891 Here is a table of predefined type predicates, in alphabetical order, | |
| 1892 with references to further information. | |
| 1893 | |
| 1894 @table @code | |
| 1895 @item annotationp | |
| 1896 @xref{Annotation Primitives, annotationp}. | |
| 1897 | |
| 1898 @item arrayp | |
| 1899 @xref{Array Functions, arrayp}. | |
| 1900 | |
| 1901 @item atom | |
| 1902 @xref{List-related Predicates, atom}. | |
| 1903 | |
| 1904 @item bit-vector-p | |
| 1905 @xref{Bit Vector Functions, bit-vector-p}. | |
| 1906 | |
| 1907 @item bitp | |
| 1908 @xref{Bit Vector Functions, bitp}. | |
| 1909 | |
| 1910 @item boolean-specifier-p | |
| 1911 @xref{Specifier Types, boolean-specifier-p}. | |
| 1912 | |
| 1913 @item buffer-glyph-p | |
| 1914 @xref{Glyph Types, buffer-glyph-p}. | |
| 1915 | |
| 1916 @item buffer-live-p | |
| 1917 @xref{Killing Buffers, buffer-live-p}. | |
| 1918 | |
| 1919 @item bufferp | |
| 1920 @xref{Buffer Basics, bufferp}. | |
| 1921 | |
| 1922 @item button-event-p | |
| 1923 @xref{Event Predicates, button-event-p}. | |
| 1924 | |
| 1925 @item button-press-event-p | |
| 1926 @xref{Event Predicates, button-press-event-p}. | |
| 1927 | |
| 1928 @item button-release-event-p | |
| 1929 @xref{Event Predicates, button-release-event-p}. | |
| 1930 | |
| 1931 @item case-table-p | |
| 1932 @xref{Case Tables, case-table-p}. | |
| 1933 | |
| 1934 @item char-int-p | |
| 1935 @xref{Character Codes, char-int-p}. | |
| 1936 | |
| 1937 @item char-or-char-int-p | |
| 1938 @xref{Character Codes, char-or-char-int-p}. | |
| 1939 | |
| 1940 @item char-or-string-p | |
| 1941 @xref{Predicates for Strings, char-or-string-p}. | |
| 1942 | |
| 1943 @item char-table-p | |
| 1944 @xref{Char Tables, char-table-p}. | |
| 1945 | |
| 1946 @item characterp | |
| 1947 @xref{Predicates for Characters, characterp}. | |
| 1948 | |
| 1949 @item color-instance-p | |
| 1950 @xref{Colors, color-instance-p}. | |
| 1951 | |
| 1952 @item color-pixmap-image-instance-p | |
| 1953 @xref{Image Instance Types, color-pixmap-image-instance-p}. | |
| 1954 | |
| 1955 @item color-specifier-p | |
| 1956 @xref{Specifier Types, color-specifier-p}. | |
| 1957 | |
| 1958 @item commandp | |
| 1959 @xref{Interactive Call, commandp}. | |
| 1960 | |
| 1961 @item compiled-function-p | |
| 1962 @xref{Compiled-Function Type, compiled-function-p}. | |
| 1963 | |
| 1964 @item console-live-p | |
| 1965 @xref{Connecting to a Console or Device, console-live-p}. | |
| 1966 | |
| 1967 @item consolep | |
| 1968 @xref{Consoles and Devices, consolep}. | |
| 1969 | |
| 1970 @item consp | |
| 1971 @xref{List-related Predicates, consp}. | |
| 1972 | |
| 1973 @item database-live-p | |
| 1974 @xref{Connecting to a Database, database-live-p}. | |
| 1975 | |
| 1976 @item databasep | |
| 1977 @xref{Databases, databasep}. | |
| 1978 | |
| 1979 @item device-live-p | |
| 1980 @xref{Connecting to a Console or Device, device-live-p}. | |
| 1981 | |
| 1982 @item device-or-frame-p | |
| 1983 @xref{Basic Device Functions, device-or-frame-p}. | |
| 1984 | |
| 1985 @item devicep | |
| 1986 @xref{Consoles and Devices, devicep}. | |
| 1987 | |
| 1988 @item eval-event-p | |
| 1989 @xref{Event Predicates, eval-event-p}. | |
| 1990 | |
| 1991 @item event-live-p | |
| 1992 @xref{Event Predicates, event-live-p}. | |
| 1993 | |
| 1994 @item eventp | |
| 1995 @xref{Events, eventp}. | |
| 1996 | |
| 1997 @item extent-live-p | |
| 1998 @xref{Creating and Modifying Extents, extent-live-p}. | |
| 1999 | |
| 2000 @item extentp | |
| 2001 @xref{Extents, extentp}. | |
| 2002 | |
| 2003 @item face-boolean-specifier-p | |
| 2004 @xref{Specifier Types, face-boolean-specifier-p}. | |
| 2005 | |
| 2006 @item facep | |
| 2007 @xref{Basic Face Functions, facep}. | |
| 2008 | |
| 2009 @item floatp | |
| 2010 @xref{Predicates on Numbers, floatp}. | |
| 2011 | |
| 2012 @item font-instance-p | |
| 2013 @xref{Fonts, font-instance-p}. | |
| 2014 | |
| 2015 @item font-specifier-p | |
| 2016 @xref{Specifier Types, font-specifier-p}. | |
| 2017 | |
| 2018 @item frame-live-p | |
| 2019 @xref{Deleting Frames, frame-live-p}. | |
| 2020 | |
| 2021 @item framep | |
| 2022 @xref{Frames, framep}. | |
| 2023 | |
| 2024 @item functionp | |
| 2025 (not yet documented) | |
| 2026 | |
| 2027 @item generic-specifier-p | |
| 2028 @xref{Specifier Types, generic-specifier-p}. | |
| 2029 | |
| 2030 @item glyphp | |
| 2031 @xref{Glyphs, glyphp}. | |
| 2032 | |
| 2033 @item hash-table-p | |
| 2034 @xref{Hash Tables, hash-table-p}. | |
| 2035 | |
| 2036 @item icon-glyph-p | |
| 2037 @xref{Glyph Types, icon-glyph-p}. | |
| 2038 | |
| 2039 @item image-instance-p | |
| 2040 @xref{Images, image-instance-p}. | |
| 2041 | |
| 2042 @item image-specifier-p | |
| 2043 @xref{Specifier Types, image-specifier-p}. | |
| 2044 | |
| 2045 @item integer-char-or-marker-p | |
| 2046 @xref{Predicates on Markers, integer-char-or-marker-p}. | |
| 2047 | |
| 2048 @item integer-or-char-p | |
| 2049 @xref{Predicates for Characters, integer-or-char-p}. | |
| 2050 | |
| 2051 @item integer-or-marker-p | |
| 2052 @xref{Predicates on Markers, integer-or-marker-p}. | |
| 2053 | |
| 2054 @item integer-specifier-p | |
| 2055 @xref{Specifier Types, integer-specifier-p}. | |
| 2056 | |
| 2057 @item integerp | |
| 2058 @xref{Predicates on Numbers, integerp}. | |
| 2059 | |
| 2060 @item itimerp | |
| 2061 (not yet documented) | |
| 2062 | |
| 2063 @item key-press-event-p | |
| 2064 @xref{Event Predicates, key-press-event-p}. | |
| 2065 | |
| 2066 @item keymapp | |
| 2067 @xref{Creating Keymaps, keymapp}. | |
| 2068 | |
| 2069 @item keywordp | |
| 2070 (not yet documented) | |
| 2071 | |
| 2072 @item listp | |
| 2073 @xref{List-related Predicates, listp}. | |
| 2074 | |
| 2075 @item markerp | |
| 2076 @xref{Predicates on Markers, markerp}. | |
| 2077 | |
| 2078 @item misc-user-event-p | |
| 2079 @xref{Event Predicates, misc-user-event-p}. | |
| 2080 | |
| 2081 @item mono-pixmap-image-instance-p | |
| 2082 @xref{Image Instance Types, mono-pixmap-image-instance-p}. | |
| 2083 | |
| 2084 @item motion-event-p | |
| 2085 @xref{Event Predicates, motion-event-p}. | |
| 2086 | |
| 2087 @item mouse-event-p | |
| 2088 @xref{Event Predicates, mouse-event-p}. | |
| 2089 | |
| 2090 @item natnum-specifier-p | |
| 2091 @xref{Specifier Types, natnum-specifier-p}. | |
| 2092 | |
| 2093 @item natnump | |
| 2094 @xref{Predicates on Numbers, natnump}. | |
| 2095 | |
| 2096 @item nlistp | |
| 2097 @xref{List-related Predicates, nlistp}. | |
| 2098 | |
| 2099 @item nothing-image-instance-p | |
| 2100 @xref{Image Instance Types, nothing-image-instance-p}. | |
| 2101 | |
| 2102 @item number-char-or-marker-p | |
| 2103 @xref{Predicates on Markers, number-char-or-marker-p}. | |
| 2104 | |
| 2105 @item number-or-marker-p | |
| 2106 @xref{Predicates on Markers, number-or-marker-p}. | |
| 2107 | |
| 2108 @item numberp | |
| 2109 @xref{Predicates on Numbers, numberp}. | |
| 2110 | |
| 2111 @item pointer-glyph-p | |
| 2112 @xref{Glyph Types, pointer-glyph-p}. | |
| 2113 | |
| 2114 @item pointer-image-instance-p | |
| 2115 @xref{Image Instance Types, pointer-image-instance-p}. | |
| 2116 | |
| 2117 @item process-event-p | |
| 2118 @xref{Event Predicates, process-event-p}. | |
| 2119 | |
| 2120 @item processp | |
| 2121 @xref{Processes, processp}. | |
| 2122 | |
| 2123 @item range-table-p | |
| 2124 @xref{Range Tables, range-table-p}. | |
| 2125 | |
| 2126 @item ringp | |
| 2127 (not yet documented) | |
| 2128 | |
| 2129 @item sequencep | |
| 2130 @xref{Sequence Functions, sequencep}. | |
| 2131 | |
| 2132 @item specifierp | |
| 2133 @xref{Specifiers, specifierp}. | |
| 2134 | |
| 2135 @item stringp | |
| 2136 @xref{Predicates for Strings, stringp}. | |
| 2137 | |
| 2138 @item subrp | |
| 2139 @xref{Function Cells, subrp}. | |
| 2140 | |
| 2141 @item subwindow-image-instance-p | |
| 2142 @xref{Image Instance Types, subwindow-image-instance-p}. | |
| 2143 | |
| 2144 @item subwindowp | |
| 2145 @xref{Subwindows, subwindowp}. | |
| 2146 | |
| 2147 @item symbolp | |
| 2148 @xref{Symbols, symbolp}. | |
| 2149 | |
| 2150 @item syntax-table-p | |
| 2151 @xref{Syntax Tables, syntax-table-p}. | |
| 2152 | |
| 2153 @item text-image-instance-p | |
| 2154 @xref{Image Instance Types, text-image-instance-p}. | |
| 2155 | |
| 2156 @item timeout-event-p | |
| 2157 @xref{Event Predicates, timeout-event-p}. | |
| 2158 | |
| 2159 @item toolbar-button-p | |
| 2160 @xref{Toolbar, toolbar-button-p}. | |
| 2161 | |
| 2162 @item toolbar-specifier-p | |
| 2163 @xref{Toolbar, toolbar-specifier-p}. | |
| 2164 | |
| 2165 @item user-variable-p | |
| 2166 @xref{Defining Variables, user-variable-p}. | |
| 2167 | |
| 2168 @item vectorp | |
| 2169 @xref{Vectors, vectorp}. | |
| 2170 | |
| 2171 @item weak-list-p | |
| 2172 @xref{Weak Lists, weak-list-p}. | |
| 2173 | |
| 2174 @ignore | |
| 2175 @item wholenump | |
| 2176 @xref{Predicates on Numbers, wholenump}. | |
| 2177 @end ignore | |
| 2178 | |
| 2179 @item window-configuration-p | |
| 2180 @xref{Window Configurations, window-configuration-p}. | |
| 2181 | |
| 2182 @item window-live-p | |
| 2183 @xref{Deleting Windows, window-live-p}. | |
| 2184 | |
| 2185 @item windowp | |
| 2186 @xref{Basic Windows, windowp}. | |
| 2187 @end table | |
| 2188 | |
| 2189 The most general way to check the type of an object is to call the | |
| 2190 function @code{type-of}. Recall that each object belongs to one and | |
| 2191 only one primitive type; @code{type-of} tells you which one (@pxref{Lisp | |
| 2192 Data Types}). But @code{type-of} knows nothing about non-primitive | |
| 2193 types. In most cases, it is more convenient to use type predicates than | |
| 2194 @code{type-of}. | |
| 2195 | |
| 2196 @defun type-of object | |
| 2197 This function returns a symbol naming the primitive type of | |
| 2198 @var{object}. The value is one of @code{bit-vector}, @code{buffer}, | |
| 2199 @code{char-table}, @code{character}, @code{charset}, | |
| 2200 @code{coding-system}, @code{cons}, @code{color-instance}, | |
| 2201 @code{compiled-function}, @code{console}, @code{database}, | |
| 2202 @code{device}, @code{event}, @code{extent}, @code{face}, @code{float}, | |
| 2203 @code{font-instance}, @code{frame}, @code{glyph}, @code{hash-table}, | |
| 2204 @code{image-instance}, @code{integer}, @code{keymap}, @code{marker}, | |
| 2205 @code{process}, @code{range-table}, @code{specifier}, @code{string}, | |
| 2206 @code{subr}, @code{subwindow}, @code{symbol}, @code{toolbar-button}, | |
| 2207 @code{tooltalk-message}, @code{tooltalk-pattern}, @code{vector}, | |
| 2208 @code{weak-list}, @code{window}, @code{window-configuration}, or | |
| 2209 @code{x-resource}. | |
| 2210 | |
| 2211 @example | |
| 2212 (type-of 1) | |
| 2213 @result{} integer | |
| 2214 (type-of 'nil) | |
| 2215 @result{} symbol | |
| 2216 (type-of '()) ; @r{@code{()} is @code{nil}.} | |
| 2217 @result{} symbol | |
| 2218 (type-of '(x)) | |
| 2219 @result{} cons | |
| 2220 @end example | |
| 2221 @end defun | |
| 2222 | |
|
5791
9fae6227ede5
Silence texinfo 5.2 warnings, primarily by adding next, prev, and up
Jerry James <james@xemacs.org>
parents:
5374
diff
changeset
|
2223 @node Equality Predicates, , Type Predicates, Lisp Data Types |
| 428 | 2224 @section Equality Predicates |
| 2225 @cindex equality | |
| 2226 | |
|
5359
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2227 Here we describe functions that test for equality between any two |
| 428 | 2228 objects. Other functions test equality between objects of specific |
| 2229 types, e.g., strings. For these predicates, see the appropriate chapter | |
| 2230 describing the data type. | |
| 2231 | |
| 2232 @defun eq object1 object2 | |
| 2233 This function returns @code{t} if @var{object1} and @var{object2} are | |
| 2234 the same object, @code{nil} otherwise. The ``same object'' means that a | |
| 2235 change in one will be reflected by the same change in the other. | |
| 2236 | |
| 2237 @code{eq} returns @code{t} if @var{object1} and @var{object2} are | |
|
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4820
diff
changeset
|
2238 fixnums with the same value. It is preferable to use @code{=} or |
|
4472
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2239 @code{eql} in many contexts for numeric comparison, especially since |
|
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2240 bignums (integers with values that would have otherwise overflowed, only |
|
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2241 available on some builds) with the same value are not @code{eq}; |
|
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2242 @pxref{Comparison of Numbers}. @code{eq} also returns @code{t} if |
|
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2243 @var{object1} and @var{object2} are identical characters, though in this |
|
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2244 case you may prefer to use @code{char=}. |
|
4471
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2245 |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2246 Also, since symbol names are normally unique, if the arguments are |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2247 symbols with the same name, they are @code{eq}. For other types (e.g., |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2248 lists, vectors, strings), two arguments with the same contents or |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2249 elements are not necessarily @code{eq} to each other: they are @code{eq} |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2250 only if they are the same object. |
| 428 | 2251 |
| 2252 (The @code{make-symbol} function returns an uninterned symbol that is | |
| 2253 not interned in the standard @code{obarray}. When uninterned symbols | |
| 2254 are in use, symbol names are no longer unique. Distinct symbols with | |
| 2255 the same name are not @code{eq}. @xref{Creating Symbols}.) | |
| 2256 | |
| 2257 NOTE: Under XEmacs 19, characters are really just integers, and thus | |
|
4472
a99eb40f0b5b
Correct an omitted word, expand on bignum equality in the lispref.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4471
diff
changeset
|
2258 characters and integers with the same numeric code are @code{eq}. Under |
|
4471
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2259 XEmacs 20, it was necessary to preserve remnants of this in function |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2260 such as @code{old-eq} in order to maintain byte-code compatibility. |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2261 Byte code compiled under any Emacs 19 will automatically have calls to |
|
2d39535e1f9d
Say explicitly that eq is useful for chars; xref number comparison, lispref
Aidan Kehoe <kehoea@parhasard.net>
parents:
4265
diff
changeset
|
2262 @code{eq} mapped to @code{old-eq} when executed under XEmacs 20. |
| 428 | 2263 |
| 2264 @example | |
| 2265 @group | |
| 2266 (eq 'foo 'foo) | |
| 2267 @result{} t | |
| 2268 @end group | |
| 2269 | |
| 2270 @group | |
| 2271 (eq 456 456) | |
| 2272 @result{} t | |
| 2273 @end group | |
| 2274 | |
| 2275 @group | |
| 2276 (eq "asdf" "asdf") | |
| 2277 @result{} nil | |
| 2278 @end group | |
| 2279 | |
| 2280 @group | |
| 2281 (eq '(1 (2 (3))) '(1 (2 (3)))) | |
| 2282 @result{} nil | |
| 2283 @end group | |
| 2284 | |
| 2285 @group | |
| 2286 (setq foo '(1 (2 (3)))) | |
| 2287 @result{} (1 (2 (3))) | |
| 2288 (eq foo foo) | |
| 2289 @result{} t | |
| 2290 (eq foo '(1 (2 (3)))) | |
| 2291 @result{} nil | |
| 2292 @end group | |
| 2293 | |
| 2294 @group | |
| 2295 (eq [(1 2) 3] [(1 2) 3]) | |
| 2296 @result{} nil | |
| 2297 @end group | |
| 2298 | |
| 2299 @group | |
| 2300 (eq (point-marker) (point-marker)) | |
| 2301 @result{} nil | |
| 2302 @end group | |
| 2303 @end example | |
| 2304 | |
| 2305 @end defun | |
| 2306 | |
|
5359
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2307 @defun eql object1 object2 |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2308 |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2309 This function returns @code{t} if the two arguments are the same object, |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2310 as with @code{eq}. In addition, it returns @code{t} if @var{object1} |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2311 and @var{object2} are numeric objects of the same type and with equal |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2312 values. Otherwise it returns @code{nil}. @code{eql} is the default |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2313 test for hash tables, and for many sequence-oriented functions inherited |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2314 from Common Lisp. |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2315 |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2316 @example |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2317 @group |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2318 (eql 1 1) |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2319 @result{} t |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2320 (eql 1 1.0) ; different types |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2321 @result{} nil |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2322 (eq (+ 0.0 pi) pi) |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2323 @result{} nil ; in some contexts can be t, but don't rely on this! |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2324 (eql (+ 0.0 pi) pi) |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2325 @result{} t ; this is more reliable. |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2326 (position (+ 0 pi) (list 0 1 2 pi 4)) |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2327 @result{} 3 ; function's test defaults to eql |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2328 @end group |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2329 @end example |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2330 @end defun |
|
f5a5501814f5
Document the CL set functions and #'eql in the Lispref, not just cl.texi
Aidan Kehoe <kehoea@parhasard.net>
parents:
5247
diff
changeset
|
2331 |
| 428 | 2332 @defun equal object1 object2 |
| 2333 This function returns @code{t} if @var{object1} and @var{object2} have | |
| 2334 equal components, @code{nil} otherwise. Whereas @code{eq} tests if its | |
| 2335 arguments are the same object, @code{equal} looks inside nonidentical | |
| 2336 arguments to see if their elements are the same. So, if two objects are | |
| 2337 @code{eq}, they are @code{equal}, but the converse is not always true. | |
| 2338 | |
| 2339 @example | |
| 2340 @group | |
| 2341 (equal 'foo 'foo) | |
| 2342 @result{} t | |
| 2343 @end group | |
| 2344 | |
| 2345 @group | |
| 2346 (equal 456 456) | |
| 2347 @result{} t | |
| 2348 @end group | |
| 2349 | |
| 2350 @group | |
| 2351 (equal "asdf" "asdf") | |
| 2352 @result{} t | |
| 2353 @end group | |
| 2354 @group | |
| 2355 (eq "asdf" "asdf") | |
| 2356 @result{} nil | |
| 2357 @end group | |
| 2358 | |
| 2359 @group | |
| 2360 (equal '(1 (2 (3))) '(1 (2 (3)))) | |
| 2361 @result{} t | |
| 2362 @end group | |
| 2363 @group | |
| 2364 (eq '(1 (2 (3))) '(1 (2 (3)))) | |
| 2365 @result{} nil | |
| 2366 @end group | |
| 2367 | |
| 2368 @group | |
| 2369 (equal [(1 2) 3] [(1 2) 3]) | |
| 2370 @result{} t | |
| 2371 @end group | |
| 2372 @group | |
| 2373 (eq [(1 2) 3] [(1 2) 3]) | |
| 2374 @result{} nil | |
| 2375 @end group | |
| 2376 | |
| 2377 @group | |
| 2378 (equal (point-marker) (point-marker)) | |
| 2379 @result{} t | |
| 2380 @end group | |
| 2381 | |
| 2382 @group | |
| 2383 (eq (point-marker) (point-marker)) | |
| 2384 @result{} nil | |
| 2385 @end group | |
| 2386 @end example | |
| 2387 | |
| 2388 Comparison of strings is case-sensitive. | |
| 2389 | |
| 2390 Note that in FSF GNU Emacs, comparison of strings takes into account | |
| 2391 their text properties, and you have to use @code{string-equal} if you | |
| 2392 want only the strings themselves compared. This difference does not | |
| 2393 exist in XEmacs; @code{equal} and @code{string-equal} always return | |
| 2394 the same value on the same strings. | |
| 2395 | |
| 2396 @ignore @c Not true in XEmacs | |
| 2397 Comparison of strings is case-sensitive and takes account of text | |
| 2398 properties as well as the characters in the strings. To compare | |
| 2399 two strings' characters without comparing their text properties, | |
| 2400 use @code{string=} (@pxref{Text Comparison}). | |
| 2401 @end ignore | |
| 2402 | |
| 2403 @example | |
| 2404 @group | |
| 2405 (equal "asdf" "ASDF") | |
| 2406 @result{} nil | |
| 2407 @end group | |
| 2408 @end example | |
| 2409 | |
| 2410 Two distinct buffers are never @code{equal}, even if their contents | |
| 2411 are the same. | |
| 2412 @end defun | |
| 2413 | |
| 2414 The test for equality is implemented recursively, and circular lists may | |
| 2415 therefore cause infinite recursion (leading to an error). | |
|
4792
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2416 |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2417 @defun equalp object1 object2 |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2418 This function is like @code{equal}, but compares characters and strings |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2419 case-insensitively; numbers are compared using @code{=}; arrays (that |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2420 is, strings, bit-vectors and vectors) are regarded as being |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2421 @code{equalp} if their contents are @code{equalp}; and |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2422 @code{hash-tables} are @code{equalp} if their values are @code{equalp} |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2423 and they would otherwise be @code{equal}. |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2424 |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2425 @code{equalp} is recursive with vectors, lists and hash-tables, but not |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2426 with other complex types. For types without a defined @code{equalp} |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2427 behavior, @code{equalp} behaves as @code{equal} does. |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2428 |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2429 @example |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2430 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2431 (equalp "asdf" "ASDF") |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2432 @result{} t |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2433 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2434 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2435 (equalp "asdf" [?a ?s ?D ?F]) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2436 @result{} t |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2437 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2438 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2439 (equalp "asdf" [?a ?s ?D ?F ?g]) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2440 @result{} nil |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2441 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2442 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2443 (equalp "" (bit-vector)) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2444 @result{} t |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2445 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2446 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2447 (equalp #s(hash-table) (make-hash-table)) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2448 @result{} t |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2449 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2450 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2451 (equalp #s(hash-table data (t "hi there")) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2452 (let ((ht (make-hash-table))) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2453 (puthash t "HI THERE" ht) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2454 ht)) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2455 @result{} t |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2456 @group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2457 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2458 (equalp #s(hash-table test eq data (1.0 "hi there")) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2459 (let ((ht (make-hash-table :test 'eql))) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2460 (puthash 1.0 "HI THERE" ht) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2461 ht)) |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2462 @result{} nil |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2463 @end group |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2464 @end example |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2465 @end defun |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2466 |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2467 @code{equalp} can also provoke an error if handed a circular structure, |
|
95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4486
diff
changeset
|
2468 as with @code{equal}. |
