From: Anselm Helbig <anselm.helbig+news2009@googlemail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: defun vs lambda
Date: Fri, 24 Jul 2009 23:23:09 +0200 [thread overview]
Message-ID: <874ot1ai82.wl%anselm.helbig+news2009@googlemail.com> (raw)
In-Reply-To: <b453056c-ef8e-47ba-aa45-1c90fef7233c@k1g2000yqf.googlegroups.com>
Hi!
> I know I can return a function from another function, like this:
>
> (setq f (lambda () 2))
>
> but I have to call it like (funcall f). Is there anyway that I could
> do:
>
> (setf f (defun () 2) and then be able to call (f) ?
In emacs lisp, you'd use fset to set the function value of a symbol:
(fset 'f (lambda () 2))
(f)
See (info "(elisp) Function Cells") for more details.
HTH,
Anselm
--
Anselm Helbig
mailto:anselm.helbig+news2009@googlemail.com
next prev parent reply other threads:[~2009-07-24 21:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-24 20:30 defun vs lambda weber
2009-07-24 21:23 ` Anselm Helbig [this message]
2009-07-24 21:46 ` Pascal J. Bourguignon
2009-07-31 11:41 ` weber
2009-07-31 12:56 ` Pascal J. Bourguignon
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=874ot1ai82.wl%anselm.helbig+news2009@googlemail.com \
--to=anselm.helbig+news2009@googlemail.com \
--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).