[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About `funcall'
From: |
Pascal J. Bourguignon |
Subject: |
Re: About `funcall' |
Date: |
Mon, 04 Mar 2013 20:15:51 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
Xue Fuqiao <xfq.free@gmail.com> writes:
> In `yank-pop', there is an sexp about `funcall':
>
> (funcall (or yank-undo-function 'delete-region) (point) (mark t))
>
> IIRC the first argument for `funcall' should be a function, so I'm
> confused with this usage. Can somebody explain it to me? Thanks.
`or' returns the first argument that is not nil, or nil when all the
arguments are nil.
If the value bound to yank-undo-function is not nil, then it's returned,
else the symbol delete-region is returned (since it's not nil).
(or a b) <=> (let ((first-arg a))
(if first-arg
first-arg
b))
The temporary variable is needed for (let ((i 0)) (or (incf i) 42))
returns 1, not 2.
(defmacro .or (&rest args)
(if (null args)
'nil
(let ((var (gensym)))
`(let ((,var ,(first args)))
(if ,var
,var
(.or ,@(rest args)))))))
(macroexpand '(.or a b))
--> (let ((#1=#:G90861 a)) (if #1# #1# (\.or b)))
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.