From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Creating a list Date: Thu, 19 Nov 2009 14:59:38 +0100 Organization: Informatimago Message-ID: <873a4aipit.fsf@galatea.local> References: <87k4xnge1t.fsf@Traian.DecebalComp> <87y6m2kj3m.fsf@lola.goethe.zz> <874ooqhjaw.fsf@Traian.DecebalComp> <874ooqkah6.fsf@lola.goethe.zz> <873a4afyi0.fsf@Traian.DecebalComp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258642804 9359 80.91.229.12 (19 Nov 2009 15:00:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Nov 2009 15:00:04 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 19 15:59:56 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NB8U8-0002yq-Al for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 15:59:48 +0100 Original-Received: from localhost ([127.0.0.1]:42895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NB8U7-0006wG-UA for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 09:59:47 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 73 Original-X-Trace: individual.net dYNqM5abYjqgt5zCORdSKgga9c+r3BD4HJS6ePzP6c31VNpTfH Cancel-Lock: sha1:Njc1MmQ1YmNmZmNjNTU3YTRlYzAyNzQ1NWU3NmQ1ODM1YTI2MzQzOA== sha1:AFZU6ZtC8IXBAI5QOhdrXIsZ/ZM= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:174851 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69925 Cecil Westerhof writes: > David Kastrup writes: > >>>>> At the moment I create a list with: >>>>> (setq ret-val (cons total-amount (cons current-amount ()))) >>>>> I thought about doing it with: >>>>> (setq ret-val (cons total-amount '(current-amount))) >>>>> >>>>> But then the second value is the string current-amount >>>> >>>> Wrong. The _symbol_ current-amount. >>> >>> When evaluating I got: >>> (1570378.2570192777 current-amount) >>> That is why I thought I got the string. >> >> A string would have quote marks around it. > > Off course. > > But I have a few questions on my mind. > - Why is the first shown as value and the second as _symbol_? Both floating point numbers and symbols ARE VALUES! The first object is a floating point number, the second object is a symbol. Therefore it shows a floating point number and a symbol. The rules of evaluation of lisp include: (defun eval (expression) (cond ((symbolp expression) (symbol-value expression)) ; symbols evaluate to their value ((atom expression) expression)) ; atoms are self evaluating (t (case (first expression) ((quote) (second expression)) ; (quote x) returns x unchanged. ; ... other special operators (else (cond ((and (listp (first expression)) (eq 'lambda (first (first expression)))) ;; ... process ((lambda (...) ...) ...) ) ((macro-function (first expression)) ;; ... expand the macro call ) ((and (symbolp (first expression)) (fboundp (first expression))) (apply (symbol-function (first expression)) (mapcar (function eval) (rest expression)) ; evaluate the arguments ))))))) When you evaluate (cons current-amount ()), since cons is a symbol that is fbound, the arguments are evaluated: since current-amount is a symbol, its symbol-value is returned. since () is a symbol, its symbol-value is returned (it's nil). the function # is called with the above values. When you evalute (quote (current-value)), the list (current-value) is returned. The evaluation doesn't even look at what's inside the list! > - current-amount is a local variable. How is it possible that the symbol > is still defined? You exist. How is it possible your name still exists? -- __Pascal Bourguignon__