From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: richardeng <richardeng@foxmail.com>
Cc: Alan Mackenzie <acm@muc.de>,
Thierry Volpiatto <thierry.volpiatto@gmail.com>,
emacs-devel@gnu.org
Subject: Re: Elisp info request: function parameter passing
Date: Tue, 09 Dec 2008 14:44:36 -0500 [thread overview]
Message-ID: <jwv63ltxhi3.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <493EB229.20308@foxmail.com> (richardeng@foxmail.com's message of "Wed, 10 Dec 2008 02:00:09 +0800")
> I just found elisp is different in function parameter passing than C, or we
> can say elisp is reference passing style. That is, the variable in function
You are confused.
> (setq x '(1 2 3 "one" "two" "three"))
> (defun fun (arg)
> (if (eq arg x)
> (message "they are eq, the same one")
> (message "they are different")))
> (fun x)
Try the equivalent C code:
char *x = "hello";
fun (char *arg)
{
if (arg == x)
printf ("they are eq\n");
else
printf ("they are different\n");
}
main ()
{
fun (x);
}
-- Stefan
prev parent reply other threads:[~2008-12-09 19:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-09 18:00 Elisp info request: function parameter passing richardeng
2008-12-09 18:50 ` richardeng
2008-12-09 19:44 ` Stefan Monnier [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv63ltxhi3.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=richardeng@foxmail.com \
--cc=thierry.volpiatto@gmail.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.