help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defun vs lambda


From: Anselm Helbig
Subject: Re: defun vs lambda
Date: Fri, 24 Jul 2009 23:23:09 +0200

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]