comparison man/cl.texi @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents a86b2b5e0111
children
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
293 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
294 the Emacs name: 294 the Emacs name:
295 295
296 @example 296 @example
297 defun* defsubst* defmacro* function* 297 defun* defsubst* defmacro* function*
298 member* assoc* rassoc* remove* 298 member* assoc* rassoc* get*
299 delete* mapcar* sort* floor* 299 remove* delete* mapcar* sort*
300 ceiling* truncate* round* mod* 300 floor* ceiling* truncate* round*
301 rem* random* 301 mod* rem* random*
302 @end example 302 @end example
303 303
304 Internal function and variable names in the package are prefixed 304 Internal function and variable names in the package are prefixed
305 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}
306 prefixed by @code{cl-} which were not taken from Common Lisp: 306 prefixed by @code{cl-} which were not taken from Common Lisp:
1082 @smallexample 1082 @smallexample
1083 car cdr caar .. cddddr 1083 car cdr caar .. cddddr
1084 nth rest first .. tenth 1084 nth rest first .. tenth
1085 aref elt nthcdr 1085 aref elt nthcdr
1086 symbol-function symbol-value symbol-plist 1086 symbol-function symbol-value symbol-plist
1087 get getf gethash 1087 get get* getf
1088 subseq 1088 gethash subseq
1089 @end smallexample 1089 @end smallexample
1090 1090
1091 @noindent 1091 @noindent
1092 Note that for @code{nthcdr} and @code{getf}, the list argument 1092 Note that for @code{nthcdr} and @code{getf}, the list argument
1093 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
3216 Emacs 19. 3216 Emacs 19.
3217 3217
3218 @example 3218 @example
3219 (declaim (inline foo bar)) 3219 (declaim (inline foo bar))
3220 (eval-when (compile load eval) (proclaim '(inline foo bar))) 3220 (eval-when (compile load eval) (proclaim '(inline foo bar)))
3221 (proclaim-inline foo bar) ; XEmacs only 3221 (proclaim-inline foo bar) ; XEmacs only
3222 (defsubst foo (...) ...) ; instead of defun; Emacs 19 only 3222 (defsubst foo (...) ...) ; instead of defun; Emacs 19 only
3223 @end example 3223 @end example
3224 3224
3225 @strong{Please note:} This declaration remains in effect after the 3225 @strong{Please note:} This declaration remains in effect after the
3226 containing source file is done. It is correct to use it to 3226 containing source file is done. It is correct to use it to
3227 request that a function you have defined should be inlined, 3227 request that a function you have defined should be inlined,
3295 @noindent 3295 @noindent
3296 This package defines several symbol-related features that were 3296 This package defines several symbol-related features that were
3297 missing from Emacs Lisp. 3297 missing from Emacs Lisp.
3298 3298
3299 @menu 3299 @menu
3300 * Property Lists:: `getf', `remf' 3300 * Property Lists:: `get*', `remprop', `getf', `remf'
3301 * Creating Symbols:: `gensym', `gentemp' 3301 * Creating Symbols:: `gensym', `gentemp'
3302 @end menu 3302 @end menu
3303 3303
3304 @node Property Lists, Creating Symbols, Symbols, Symbols 3304 @node Property Lists, Creating Symbols, Symbols, Symbols
3305 @section Property Lists 3305 @section Property Lists
3306 3306
3307 @noindent 3307 @noindent
3308 These functions augment the standard Emacs Lisp functions @code{get} 3308 These functions augment the standard Emacs Lisp functions @code{get}
3309 and @code{put} for operating on properties attached to objects. 3309 and @code{put} for operating on properties attached to symbols.
3310 There are also functions for working with property lists as 3310 There are also functions for working with property lists as
3311 first-class data structures not attached to particular objects. 3311 first-class data structures not attached to particular symbols.
3312
3313 @defun get* symbol property &optional default
3314 This function is like @code{get}, except that if the property is
3315 not found, the @var{default} argument provides the return value.
3316 (The Emacs Lisp @code{get} function always uses @code{nil} as
3317 the default; this package's @code{get*} is equivalent to Common
3318 Lisp's @code{get}.)
3319
3320 The @code{get*} function is @code{setf}-able; when used in this
3321 fashion, the @var{default} argument is allowed but ignored.
3322 @end defun
3323
3324 @defun remprop symbol property
3325 This function removes the entry for @var{property} from the property
3326 list of @var{symbol}. It returns a true value if the property was
3327 indeed found and removed, or @code{nil} if there was no such property.
3328 (This function was probably omitted from Emacs originally because,
3329 since @code{get} did not allow a @var{default}, it was very difficult
3330 to distinguish between a missing property and a property whose value
3331 was @code{nil}; thus, setting a property to @code{nil} was close
3332 enough to @code{remprop} for most purposes.)
3333 @end defun
3312 3334
3313 @defun getf place property &optional default 3335 @defun getf place property &optional default
3314 This function scans the list @var{place} as if it were a property 3336 This function scans the list @var{place} as if it were a property
3315 list, i.e., a list of alternating property names and values. If 3337 list, i.e., a list of alternating property names and values. If
3316 an even-numbered element of @var{place} is found which is @code{eq} 3338 an even-numbered element of @var{place} is found which is @code{eq}
3333 3355
3334 @example 3356 @example
3335 (put sym prop val) @equiv{} (setf (getf (symbol-plist sym) prop) val) 3357 (put sym prop val) @equiv{} (setf (getf (symbol-plist sym) prop) val)
3336 @end example 3358 @end example
3337 3359
3338 The @code{get} function is also @code{setf}-able. The fact that 3360 The @code{get} and @code{get*} functions are also @code{setf}-able.
3339 @code{default} is ignored can sometimes be useful: 3361 The fact that @code{default} is ignored can sometimes be useful:
3340 3362
3341 @example 3363 @example
3342 (incf (get 'foo 'usage-count 0)) 3364 (incf (get* 'foo 'usage-count 0))
3343 @end example 3365 @end example
3344 3366
3345 Here, symbol @code{foo}'s @code{usage-count} property is incremented 3367 Here, symbol @code{foo}'s @code{usage-count} property is incremented
3346 if it exists, or set to 1 (an incremented 0) otherwise. 3368 if it exists, or set to 1 (an incremented 0) otherwise.
3347 3369
4629 @code{gethash}. If @var{key} already exists in the table, the 4651 @code{gethash}. If @var{key} already exists in the table, the
4630 corresponding value is changed to the stored value. If @var{key} 4652 corresponding value is changed to the stored value. If @var{key}
4631 does not already exist, a new entry is added to the table and the 4653 does not already exist, a new entry is added to the table and the
4632 table is reallocated to a larger size if necessary. The @var{default} 4654 table is reallocated to a larger size if necessary. The @var{default}
4633 argument is allowed but ignored in this case. The situation is 4655 argument is allowed but ignored in this case. The situation is
4634 exactly analogous to that of @code{get}; @pxref{Property Lists}. 4656 exactly analogous to that of @code{get*}; @pxref{Property Lists}.
4635 @end defun 4657 @end defun
4636 4658
4637 @defun remhash key table 4659 @defun remhash key table
4638 This function removes the entry for @var{key} from @var{table}. 4660 This function removes the entry for @var{key} from @var{table}.
4639 If an entry was removed, it returns @code{t}. If @var{key} does 4661 If an entry was removed, it returns @code{t}. If @var{key} does
5547 In Common Lisp, one traditionally uses @code{#'} notation when 5569 In Common Lisp, one traditionally uses @code{#'} notation when
5548 referring to the name of a function. In Emacs Lisp, it works 5570 referring to the name of a function. In Emacs Lisp, it works
5549 just as well to use a regular quote: 5571 just as well to use a regular quote:
5550 5572
5551 @example 5573 @example
5552 (loop for x in y by #'cddr collect (mapcar #'plusp x)) ; Common Lisp 5574 (loop for x in y by #'cddr collect (mapcar #'plusp x)) ; Common Lisp
5553 (loop for x in y by 'cddr collect (mapcar 'plusp x)) ; Emacs Lisp 5575 (loop for x in y by 'cddr collect (mapcar 'plusp x)) ; Emacs Lisp
5554 @end example 5576 @end example
5555 5577
5556 When @code{#'} introduces a @code{lambda} form, it is best to 5578 When @code{#'} introduces a @code{lambda} form, it is best to
5557 write out @code{(function ...)} longhand in Emacs Lisp. You can 5579 write out @code{(function ...)} longhand in Emacs Lisp. You can
5558 use a regular quote, but then the byte-compiler won't know that 5580 use a regular quote, but then the byte-compiler won't know that