From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: How the backquote and the comma really work? Date: Tue, 11 Aug 2015 13:41:20 +0200 Message-ID: <87h9o6gihr.fsf@mbork.pl> 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1439293320 1717 80.91.229.3 (11 Aug 2015 11:42:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2015 11:42:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 11 13:41: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 1ZP7wC-0002Ei-8Z for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 13:41:48 +0200 Original-Received: from localhost ([::1]:33915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZP7wB-0004T2-Mp for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 07:41:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZP7vz-0004Sv-7K for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 07:41:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZP7vt-0008Mz-Bc for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 07:41:35 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:33354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZP7vt-0008Mt-3h for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 07:41:29 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 435216F2004 for ; Tue, 11 Aug 2015 13:41:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dTjcFQmMAJ9y for ; Tue, 11 Aug 2015 13:41:26 +0200 (CEST) Original-Received: from localhost (103-115.echostar.pl [213.156.103.115]) by mail.mojserwer.eu (Postfix) with ESMTPSA id ED4506F2003 for ; Tue, 11 Aug 2015 13:41:25 +0200 (CEST) In-reply-to: <87k2tpyajy.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:5e00:2:52::8 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:106464 Archived-At: On 2015-07-24, at 15:01, Michael Heerdegen wro= te: > Michael Heerdegen writes: > >> > Stupid me =E2=80=93 again;-). No wonder =E2=80=98mci/read-list-cont= ents=E2=80=99 appears >> > twice, once, once in =E2=80=98mci/read=E2=80=99 and once in =E2=80=98= mci/read-list-contents=E2=80=99 >> > =E2=80=93 it seems there=E2=80=99s no other way (though I can=E2=80=99= t prove it formally). >> >> I don't think every implementation needs to have it in two different >> defuns. > > For the record: Better make your `mci/read' read lists recursively. If > `mci/read' finds something that isn't a list, read that. If it finds a > list, `mci/read' all its members recursively and put the read objects > into a list. No need for a `mci/read-list-contents'. As you can see, I came back to this project, and I have further questions... 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. 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). 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...). Yet another approach would be not to signal an `error' in (mci/read) when the closing paren is encountered, but use `throw' and `catch'. Not the most elegant way, probably. So, does anyone know of a Lisp reader written in Lisp, so that I could learn how smarter people solved this problem? Anyway, it seems that the main purpose of my project turned out really well: I'm learning a lot. I'd love to grab some real book on language design/implementation, but I'd have to schedule considerable time for that... > Regards, > > Michael. Best, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University