diff options
| author | Eli Zaretskii | 2008-10-21 09:21:02 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2008-10-21 09:21:02 +0000 |
| commit | 834b54855c58b81c4274611ac75fa154fc540fc8 (patch) | |
| tree | 4e7ee64fb4908a22a461d857f2a171a31fe5f3bd | |
| parent | 10e187e823fc68c10d80c5015238d8cb150cea09 (diff) | |
| download | emacs-834b54855c58b81c4274611ac75fa154fc540fc8.tar.gz emacs-834b54855c58b81c4274611ac75fa154fc540fc8.zip | |
(Calling Functions): Use `defalias' instead of `fset'. Fix wording.
| -rw-r--r-- | doc/lispref/functions.texi | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index e420e932fc7..e64cc030d6d 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi | |||
| @@ -749,14 +749,17 @@ accepts @var{n} arguments, then a call to @code{apply-partially} with | |||
| 749 | @w{@code{@var{m} < @var{n}}} arguments will produce a new function of | 749 | @w{@code{@var{m} < @var{n}}} arguments will produce a new function of |
| 750 | @w{@code{@var{n} - @var{m}}} arguments. | 750 | @w{@code{@var{n} - @var{m}}} arguments. |
| 751 | 751 | ||
| 752 | Here's an example of using @code{apply-partially} to produce a variant | 752 | Here's how we could define the built-in function @code{1+}, if it |
| 753 | of the Emacs Lisp primitive @code{1+}, a function that increments its | 753 | didn't exist, using @code{apply-partially} and @code{+}, another |
| 754 | argument by one, based on the primitive @code{+}: | 754 | built-in function: |
| 755 | 755 | ||
| 756 | @example | 756 | @example |
| 757 | (fset 'incr-by-one (apply-partially '+ 1)) | ||
| 758 | @group | 757 | @group |
| 759 | (incr-by-one 10) | 758 | (defalias '1+ (apply-partially '+ 1) |
| 759 | "Increment argument by one.") | ||
| 760 | @end group | ||
| 761 | @group | ||
| 762 | (1+ 10) | ||
| 760 | @result{} 11 | 763 | @result{} 11 |
| 761 | @end group | 764 | @end group |
| 762 | @end example | 765 | @end example |