[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function pointer
From: |
Harald Hanche-Olsen |
Subject: |
Re: Function pointer |
Date: |
Tue, 14 Apr 2009 10:02:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) |
+ Decebal <CLDWesterhof@gmail.com>:
> Is it possible to work with function pointers?
No. Pointers are a low level concept not supported by elisp.
> The following works:
> (a-function)
> but this does not work:
> (setq function 'a-function)
> (function)
> this gives wrong number of arguments.
Ah. So you're not after pointers, just a means of passing functions
around. You should be aware, then, that symbols can have two values
associated with them: The regular value, which is obtained by just using
the symbol, and the function value, which is consulted if the symbol is
in the function place of a for. You have assigned the symbol a-function
to the symbol function above, but that symbol also has a function value,
which you inadvertently used in the last line.
The elisp manual explains this. Go to node Symbols, then sub-node Symbol
Components.
The very short answer to your question: Use funcall, as in
(funcall function)
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
- Function pointer, Decebal, 2009/04/14
- Re: Function pointer,
Harald Hanche-Olsen <=