From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kai Grossjohann Newsgroups: gmane.emacs.help Subject: Re: (list) and '(list) Date: Fri, 27 Apr 2007 12:25:56 +0200 Message-ID: <86slam9kqz.fsf@ketchup.de.uu.net> References: <9406124.888091177600624458.JavaMail.www@wwinf4203> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1177669944 4278 80.91.229.12 (27 Apr 2007 10:32:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 27 Apr 2007 10:32:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 27 12:32:23 2007 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 1HhNkU-0006v6-65 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 12:32:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhNqJ-0000Bz-3R for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Apr 2007 06:38:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HhNkf-0000Tx-LX for help-gnu-emacs@gnu.org; Fri, 27 Apr 2007 06:32:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HhNke-0000Rq-0F for help-gnu-emacs@gnu.org; Fri, 27 Apr 2007 06:32:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HhNkd-0000Rd-Nx for help-gnu-emacs@gnu.org; Fri, 27 Apr 2007 06:32:31 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HhNen-0000sR-7E for help-gnu-emacs@gnu.org; Fri, 27 Apr 2007 06:26:29 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1HhNeT-0007TG-Up for help-gnu-emacs@gnu.org; Fri, 27 Apr 2007 12:26:09 +0200 Original-Received: from de-lt-054776l.eu.frd.uu.net ([62.191.185.105]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Apr 2007 12:26:09 +0200 Original-Received: from kai by de-lt-054776l.eu.frd.uu.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Apr 2007 12:26:09 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: de-lt-054776l.eu.frd.uu.net User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux) Cancel-Lock: sha1:zIk2+28tgvw9iK6C64BahKgKgno= X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:43268 Archived-At: A Soare writes: > Can somebody tell me if there already is a code that makes the > distintion between a list that evaluates as a function like > > (function ... > > and between a list that evaluates to itself : > > '(list ... , and its aliases like (quote (list ... etc Like the others who responded, it is not clear to me what you want. Lisp normally reads code and then evaluates (evals) it. During reading, it performs some (few) conversions such as 'foo to (quote foo). During evaluation, the magic happens: - If we are looking at a number or a string, return that number or string. (Numbers and strings are said to be self-evaluating because they evaluate to themselves.) If we are looking at some special symbols (like t and nil), return those values. (t and nil are also self-evaluating.) - If we are looking at a list, look at the first element of the list. If it is a function, then eval all other elements of the list, then use the results as arguments to the function (call the function). Then return the result of the function call. - The first element can also be a special form. In this case, the other elements of the list are NOT evaled but instead passed to the special form verbatim. Popular special forms: defun, quote, if, setq So in a strict sense, what you can do is: (setq unevaled (read STREAM)) (setq evaled (eval unevaled)) (equal unevaled evaled) This is, read it first, then eval it and compare whether the result of reading and the result of evaling are equal. Perhaps what you want is to write a special form yourself? That can't be done in a strict sense, but you can use macros to approximate the effect. For example, to reverse the condition of `if' (proof of concept only, not production code): (defmacro ifnot (test no yes) (if (not test) no yes)) Does that help? Kai