comparison man/cl.texi @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children a86b2b5e0111
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
5 @iftex 5 @iftex
6 @finalout 6 @finalout
7 @end iftex 7 @end iftex
8 8
9 @ifinfo 9 @ifinfo
10 @dircategory XEmacs Editor
11 @direntry
12 * Common Lisp: (cl). GNU Emacs Common Lisp emulation package.
13 @end direntry
14
10 This file documents the GNU Emacs Common Lisp emulation package. 15 This file documents the GNU Emacs Common Lisp emulation package.
11 16
12 Copyright (C) 1993 Free Software Foundation, Inc. 17 Copyright (C) 1993 Free Software Foundation, Inc.
13 18
14 Permission is granted to make and distribute verbatim copies of this 19 Permission is granted to make and distribute verbatim copies of this
288 case, a @samp{*} has been appended to the Common Lisp name to obtain 293 case, a @samp{*} has been appended to the Common Lisp name to obtain
289 the Emacs name: 294 the Emacs name:
290 295
291 @example 296 @example
292 defun* defsubst* defmacro* function* 297 defun* defsubst* defmacro* function*
293 member* assoc* rassoc* get* 298 member* assoc* rassoc* remove*
294 remove* delete* mapcar* sort* 299 delete* mapcar* sort* floor*
295 floor* ceiling* truncate* round* 300 ceiling* truncate* round* mod*
296 mod* rem* random* 301 rem* random*
297 @end example 302 @end example
298 303
299 Internal function and variable names in the package are prefixed 304 Internal function and variable names in the package are prefixed
300 by @code{cl-}. Here is a complete list of functions @emph{not} 305 by @code{cl-}. Here is a complete list of functions @emph{not}
301 prefixed by @code{cl-} which were not taken from Common Lisp: 306 prefixed by @code{cl-} which were not taken from Common Lisp:
1077 @smallexample 1082 @smallexample
1078 car cdr caar .. cddddr 1083 car cdr caar .. cddddr
1079 nth rest first .. tenth 1084 nth rest first .. tenth
1080 aref elt nthcdr 1085 aref elt nthcdr
1081 symbol-function symbol-value symbol-plist 1086 symbol-function symbol-value symbol-plist
1082 get get* getf 1087 get getf gethash
1083 gethash subseq 1088 subseq
1084 @end smallexample 1089 @end smallexample
1085 1090
1086 @noindent 1091 @noindent
1087 Note that for @code{nthcdr} and @code{getf}, the list argument 1092 Note that for @code{nthcdr} and @code{getf}, the list argument
1088 of the function must itself be a valid @var{place} form. For 1093 of the function must itself be a valid @var{place} form. For
3290 @noindent 3295 @noindent
3291 This package defines several symbol-related features that were 3296 This package defines several symbol-related features that were
3292 missing from Emacs Lisp. 3297 missing from Emacs Lisp.
3293 3298
3294 @menu 3299 @menu
3295 * Property Lists:: `get*', `remprop', `getf', `remf' 3300 * Property Lists:: `getf', `remf'
3296 * Creating Symbols:: `gensym', `gentemp' 3301 * Creating Symbols:: `gensym', `gentemp'
3297 @end menu 3302 @end menu
3298 3303
3299 @node Property Lists, Creating Symbols, Symbols, Symbols 3304 @node Property Lists, Creating Symbols, Symbols, Symbols
3300 @section Property Lists 3305 @section Property Lists
3301 3306
3302 @noindent 3307 @noindent
3303 These functions augment the standard Emacs Lisp functions @code{get} 3308 These functions augment the standard Emacs Lisp functions @code{get}
3304 and @code{put} for operating on properties attached to symbols. 3309 and @code{put} for operating on properties attached to objects.
3305 There are also functions for working with property lists as 3310 There are also functions for working with property lists as
3306 first-class data structures not attached to particular symbols. 3311 first-class data structures not attached to particular objects.
3307
3308 @defun get* symbol property &optional default
3309 This function is like @code{get}, except that if the property is
3310 not found, the @var{default} argument provides the return value.
3311 (The Emacs Lisp @code{get} function always uses @code{nil} as
3312 the default; this package's @code{get*} is equivalent to Common
3313 Lisp's @code{get}.)
3314
3315 The @code{get*} function is @code{setf}-able; when used in this
3316 fashion, the @var{default} argument is allowed but ignored.
3317 @end defun
3318
3319 @defun remprop symbol property
3320 This function removes the entry for @var{property} from the property
3321 list of @var{symbol}. It returns a true value if the property was
3322 indeed found and removed, or @code{nil} if there was no such property.
3323 (This function was probably omitted from Emacs originally because,
3324 since @code{get} did not allow a @var{default}, it was very difficult
3325 to distinguish between a missing property and a property whose value
3326 was @code{nil}; thus, setting a property to @code{nil} was close
3327 enough to @code{remprop} for most purposes.)
3328 @end defun
3329 3312
3330 @defun getf place property &optional default 3313 @defun getf place property &optional default
3331 This function scans the list @var{place} as if it were a property 3314 This function scans the list @var{place} as if it were a property
3332 list, i.e., a list of alternating property names and values. If 3315 list, i.e., a list of alternating property names and values. If
3333 an even-numbered element of @var{place} is found which is @code{eq} 3316 an even-numbered element of @var{place} is found which is @code{eq}
3350 3333
3351 @example 3334 @example
3352 (put sym prop val) @equiv{} (setf (getf (symbol-plist sym) prop) val) 3335 (put sym prop val) @equiv{} (setf (getf (symbol-plist sym) prop) val)
3353 @end example 3336 @end example
3354 3337
3355 The @code{get} and @code{get*} functions are also @code{setf}-able. 3338 The @code{get} function is also @code{setf}-able. The fact that
3356 The fact that @code{default} is ignored can sometimes be useful: 3339 @code{default} is ignored can sometimes be useful:
3357 3340
3358 @example 3341 @example
3359 (incf (get* 'foo 'usage-count 0)) 3342 (incf (get 'foo 'usage-count 0))
3360 @end example 3343 @end example
3361 3344
3362 Here, symbol @code{foo}'s @code{usage-count} property is incremented 3345 Here, symbol @code{foo}'s @code{usage-count} property is incremented
3363 if it exists, or set to 1 (an incremented 0) otherwise. 3346 if it exists, or set to 1 (an incremented 0) otherwise.
3364 3347
4646 @code{gethash}. If @var{key} already exists in the table, the 4629 @code{gethash}. If @var{key} already exists in the table, the
4647 corresponding value is changed to the stored value. If @var{key} 4630 corresponding value is changed to the stored value. If @var{key}
4648 does not already exist, a new entry is added to the table and the 4631 does not already exist, a new entry is added to the table and the
4649 table is reallocated to a larger size if necessary. The @var{default} 4632 table is reallocated to a larger size if necessary. The @var{default}
4650 argument is allowed but ignored in this case. The situation is 4633 argument is allowed but ignored in this case. The situation is
4651 exactly analogous to that of @code{get*}; @pxref{Property Lists}. 4634 exactly analogous to that of @code{get}; @pxref{Property Lists}.
4652 @end defun 4635 @end defun
4653 4636
4654 @defun remhash key table 4637 @defun remhash key table
4655 This function removes the entry for @var{key} from @var{table}. 4638 This function removes the entry for @var{key} from @var{table}.
4656 If an entry was removed, it returns @code{t}. If @var{key} does 4639 If an entry was removed, it returns @code{t}. If @var{key} does