unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Harald Hanche-Olsen <hanche@math.ntnu.no>
To: help-gnu-emacs@gnu.org
Subject: Re: Function pointer
Date: Tue, 14 Apr 2009 10:02:12 +0200	[thread overview]
Message-ID: <pcoy6u3k6ij.fsf@math.ntnu.no> (raw)
In-Reply-To: 43154d5e-b73a-4fd6-b4aa-3bb4027cb409@z9g2000yqi.googlegroups.com

+ 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


  reply	other threads:[~2009-04-14  8:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-14  7:20 Function pointer Decebal
2009-04-14  8:02 ` Harald Hanche-Olsen [this message]
2009-04-14  8:41   ` Decebal
2009-04-14 14:37     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pcoy6u3k6ij.fsf@math.ntnu.no \
    --to=hanche@math.ntnu.no \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).