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: Sun, 12 Jul 2015 17:54:24 +0200 Message-ID: <87zj318j7z.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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436716509 14841 80.91.229.3 (12 Jul 2015 15:55:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Jul 2015 15:55:09 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 12 17:55:00 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 1ZEJak-0007eF-KV for geh-help-gnu-emacs@m.gmane.org; Sun, 12 Jul 2015 17:54:58 +0200 Original-Received: from localhost ([::1]:51143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEJaj-0008JK-SN for geh-help-gnu-emacs@m.gmane.org; Sun, 12 Jul 2015 11:54:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEJaa-0008JB-4n for help-gnu-emacs@gnu.org; Sun, 12 Jul 2015 11:54:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEJaV-00054O-5G for help-gnu-emacs@gnu.org; Sun, 12 Jul 2015 11:54:48 -0400 Original-Received: from mout.web.de ([212.227.17.12]:57931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEJaU-00053P-SJ for help-gnu-emacs@gnu.org; Sun, 12 Jul 2015 11:54:43 -0400 Original-Received: from drachen.dragon ([2.207.191.117]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LjJL9-1YhzZd2naZ-00dUPv; Sun, 12 Jul 2015 17:54:27 +0200 In-Reply-To: <87615sxn1a.fsf@mbork.pl> (Marcin Borkowski's message of "Fri, 10 Jul 2015 13:36:01 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:yxw73PZ5fTuf3UeBRZuwUiKBCUhyAipyz8ciru/BCkXUHnXZOX8 JpCI4/gIaC5fmS1FfW2zWZ6Kv1Fth0mEwG7q0LfXi/g9GI0/BlqFEp8vdHB3qo7JS6QNUSA 2v4BYam10mb+VpOa/PHTpU++hy4TKXuER/1xe2e5Uw0Syma9iHxKWPUQztK1TgBF6WQz86I DAHFmi9uNTOMtD6PFx6gA== X-UI-Out-Filterresults: notjunk:1;V01:K0:mG5BVUySSEs=:txcL0+gR3zeAkHsqpcoTzr E8fj04FvHmEJIJ7CubJpc1mNZQ0Y2815+XkfXFa7xqSYL8s3smYbjigQhCqwrFZeWLXgRGx7M yliT9kofY1cb1jNvznH4zS70bU51WLDCl5OKmQR3wN69IQIBy6XropdZQ0cdQ73j+qK6Zmlxg 846ymML79DXitQKYmKfFFdDFpcE4O6YHbqKHXQjGpHZfIsQkhkMpj4qO4q0KIzCzNqb1cxNaX oCHc7F9JN1L5PVw9o/JniJryrVmuTDy3p+73MAYwVUjOAYzdQ4Rwz+uFAAGygctsFhCp1NULK OcFHEsLSnZ7BijdGYKAEXHxHBOSjUTANEA/8v4+6zDaGZFYXGHwYGhlMRN7CumyAqwtI5BaR9 cOlSFoZjuuDuKfaZ25elzvNvMggmmUy5Xh8JLKFGkyWKD81iWQyjkGzggcEBWNrEzT5Csqrnh JjmSpm2bU/cwApUBRIa5VHaLqXiopQj89ebN7BEJn1ofSQRtiw7wPXQai6KApT50hPxqvrKH0 56ZQrVfICOhH8FRPxz3pifuEOrrmaWYD2D44gWqq6IGavKrDaWf/dHzW1TU0xFItR541dgk0y +CbdgS8g3xmEHcuZKQO8Q9duR+eQQMS72vIcWltHbNSkxhIPA9dJUE7mwv4P3HxqsV81JhP32 JaNNFNptSOUAeM0RhhKvdW9Lcbdo5hDwzRIFqYb+6i/u7D0nfpf2FroFwBFZnT8h+b4A= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 212.227.17.12 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:105633 Archived-At: Hi Marcin, sorry for the late reply. > So here's my humble attempt at the reader itself. It does nothing > with ticks, backticks and commas -- AFAIUC, it shouldn't be done at > this level anyway -- it just translates them to special forms (quote > ...), (quasi-quote ...) and (unquote ...). Yes, that's the right approach. You could of course translate into the symbols named "'", "`" and "," instead, like the Lisp reader does, but that's a detail. In Elisp, these aren't special forms. They could be in your interpreter, of course. > Do I get it correctly that it's the eval function which should handle > these? In Elisp, it's not directly handled by eval, since handling the backquote mechanism is not hardcoded. Instead, backquote is a macro written in Lisp. Dunno if your interpreter will support macros. If not, you could handle backquote directly in your interpreter. > (require 'anaphora) ; we'll use acase It would be good if you could drop this dependence. This would spare people from trying your code from installing additional stuff. > (defun mci/next-token () ... > (defun mci/read () ... > (defun mci/read-list-contents () ... That looks already very promising! I never tried to write a Lisp reader in Elisp, but the general approach seems to be appropriate (others might be able to give more and better comments -- Drew, Stefan, Lars, ... - anyone?). There is a problem though when the read expression is nested. I tried to `mci/read' this string for example: "(defun fac (x) (if (< 2 x) 1 (* x (fac (1- x)))))" and got (defun fac :open-paren x) as result. If you Edebug your functions, you can see what goes wrong. Please tell me if you need more hints... I guess you already know that you have not chosen the easiest way to understand backquote. Anyway, you learn a lot of stuff with your approach. Looking forward the next version! Regards, Michael.