From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: How the backquote and the comma really work? Date: Wed, 12 Aug 2015 17:29:18 +0200 Message-ID: <87h9o4ed9t.fsf@web.de> References: <87vbebg1fs.fsf@mbork.pl> <87r3ozy9pf.fsf@web.de> <87si9ffys0.fsf@mbork.pl> <87d20jbqbj.fsf@web.de> <87pp4jfx9y.fsf@mbork.pl> <87615sxn1a.fsf@mbork.pl> <87zj318j7z.fsf@web.de> <87mvz1b16h.fsf@mbork.pl> <87k2u5azfi.fsf@mbork.pl> <87615mbo3z.fsf@mbork.pl> <877fptnoyu.fsf@web.de> <87k2tpyajy.fsf@web.de> <87h9o6gihr.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1439393398 24306 80.91.229.3 (12 Aug 2015 15:29:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2015 15:29:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 12 17:29:48 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZPXyM-0006t0-Ov for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 17:29:46 +0200 Original-Received: from localhost ([::1]:39109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPXyM-0004Dg-4x for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 11:29:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPXyB-0004C7-0g for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 11:29:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPXy6-00042C-Ph for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 11:29:34 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:53714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPXy6-00041s-Is for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 11:29:30 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZPXy4-0006gA-Hm for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 17:29:28 +0200 Original-Received: from ip-90-186-149-125.web.vodafone.de ([90.186.149.125]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Aug 2015 17:29:28 +0200 Original-Received: from michael_heerdegen by ip-90-186-149-125.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Aug 2015 17:29:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-149-125.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:B4Vze7UZLxkwH5XVkVGKbRbhWiQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106504 Archived-At: Marcin Borkowski writes: > Interestingly, there's a lot of buzz about Lisp /interpreter/ written > in Lisp, but not so much about Lisp /reader/ written in Lisp. In > fact, I didn't find one on the Internet. Good question. Maybe it's because doing such things is mainly for educational reasons, and when you want to learn how a language works, studying the interpreter is more beneficial. > What I found was Peter Norvig's tiny Lisp written in Python > (http://norvig.com/lispy.html). His reader is quite simple, but there > is an important difference: he reads all the tokens into a (Python) > list, and then he can "peek" at the next token without "consuming" it. > In my approach, this is not possible (well, it is of course possible, > but moving the point back so that the same token will be read again is > ugly). What disadvantages do you fear could your version have? On the page you cited, the flat list is only used as an intermediate step to produce the syntax tree. There is not much more you could do with it. And if you want to re-read any form in some buffer, putting point back to its beginning is a fast operation. > Now I'm wondering: is my approach (read one token at a time, but never > go back, so that I can't really "peek" at the next one) reasonable? > Maybe I should just read all tokens in a list? I do not like this > approach very much. I could also set up a buffer, which would contain > zero or one tokens to read, and put the already read token in that > buffer in some cases (pretty much what TeX's \futurelet does. Now > I appreciate why it's there...). I really don't get the point in which way the Python example would have advantages over yours. The only difference is that your version combines the two steps that are separate in the Python example. Your version is more efficient, since it avoids building a very long list that is not really needed and will cause a lot of garbage collection to be done afterwards. Regards, Michael.