From: weber <hugows@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Scheme to elisp
Date: 16 May 2007 10:18:15 -0700 [thread overview]
Message-ID: <1179335895.203447.242300@y80g2000hsf.googlegroups.com> (raw)
In-Reply-To: <slrnf4maeu.1qg.joostkremers@j.kremers4.news.arnhem.chello.nl>
On 16 maio, 12:58, Joost Kremers <joostkrem...@yahoo.com> wrote:
> weber wrote:
> > Or in a simplified form, my problem is : why the snippet below does
> > not work?
>
> [note: the original indentation was confusing:]
>
> > (defun f (n)
> > (let ((g (lambda (x) (+ 5 x))))
> > (g (+ n 1))))
>
> > (f 1) -> void-function g
>
> well, elisp is a lisp2, rather than a lisp1 (as scheme is), so a symbol can
> have both a value as a variable *and* a function definition. with let, you
> assign g a value *as a variable*, it does not affect the *function*
> definition of the symbol g.
>
> it is possible to assign an anonymous function as the variable value of a
> symbol. if you do this, you can use either funcall or apply (they have
> different uses) to call the (anonymous) function stored in the variable,
> like this:
>
> (defun f (n)
> (let ((g (lambda (x) (+ 5 x))))
> (funcall g (+ n 1))))
>
> alternatively, if you use the common-lisp compatibility package, you can
> use either flet or labels to create function bindings:
>
> (defun f (n)
> (flet ((g (x) (+ 5 x)))
> (g (+ n 1))))
>
> note that with flet, you don't use anonymous functions. the syntax is:
>
> (flet ((<function_name> <arg_list> . <function_body>))
> (<flet_body>)
> ...)
>
> HTH
>
> --
> Joost Kremers joostkrem...@yahoo.com
> Selbst in die Unterwelt dringt durch Spalten Licht
> EN:SiS(9)
Thank you very much for the explanation...
It did helped!
-weber
prev parent reply other threads:[~2007-05-16 17:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-16 12:56 Scheme to elisp weber
2007-05-16 15:58 ` Joost Kremers
2007-05-16 17:18 ` weber [this message]
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=1179335895.203447.242300@y80g2000hsf.googlegroups.com \
--to=hugows@gmail.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).