From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Elisp info request: function parameter passing Date: Tue, 09 Dec 2008 14:44:36 -0500 Message-ID: References: <493EB229.20308@foxmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1228851967 15651 80.91.229.12 (9 Dec 2008 19:46:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2008 19:46:07 +0000 (UTC) Cc: Alan Mackenzie , Thierry Volpiatto , emacs-devel@gnu.org To: richardeng Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 09 20:47:11 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LA8Xd-0006PV-I9 for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 20:46:45 +0100 Original-Received: from localhost ([127.0.0.1]:32998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LA8WS-00054W-FW for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 14:45:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LA8Vn-0004pr-S6 for emacs-devel@gnu.org; Tue, 09 Dec 2008 14:44:51 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LA8Vm-0004p1-3c for emacs-devel@gnu.org; Tue, 09 Dec 2008 14:44:51 -0500 Original-Received: from [199.232.76.173] (port=42150 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LA8Vl-0004ow-Sp for emacs-devel@gnu.org; Tue, 09 Dec 2008 14:44:49 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:55494) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LA8Vl-000496-G3 for emacs-devel@gnu.org; Tue, 09 Dec 2008 14:44:49 -0500 Original-Received: from alfajor.home (vpn-132-204-232-76.acd.umontreal.ca [132.204.232.76]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id mB9Jia4v004091; Tue, 9 Dec 2008 14:44:37 -0500 Original-Received: by alfajor.home (Postfix, from userid 20848) id 8BF2D1C91C; Tue, 9 Dec 2008 14:44:36 -0500 (EST) In-Reply-To: <493EB229.20308@foxmail.com> (richardeng@foxmail.com's message of "Wed, 10 Dec 2008 02:00:09 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3165=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106731 Archived-At: > 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