From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@newcastle.ac.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal Date: Fri, 23 Jan 2015 11:53:35 +0000 Message-ID: <878ugtvhkw.fsf@newcastle.ac.uk> References: <54C15ECA.5050008@dancol.org> <87egqlvl86.fsf@newcastle.ac.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422014034 13528 80.91.229.3 (23 Jan 2015 11:53:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Jan 2015 11:53:54 +0000 (UTC) Cc: Daniel Colascione , Stefan Monnier , emacs-devel@gnu.org To: Oleh Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 23 12:53:53 2015 Return-path: Envelope-to: ged-emacs-devel@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 1YEco9-0007Uc-0y for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 12:53:49 +0100 Original-Received: from localhost ([::1]:58278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEco8-0001DT-DD for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 06:53:48 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEco3-0001DM-PL for emacs-devel@gnu.org; Fri, 23 Jan 2015 06:53:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEco0-0003Md-BM for emacs-devel@gnu.org; Fri, 23 Jan 2015 06:53:43 -0500 Original-Received: from cheviot12.ncl.ac.uk ([128.240.234.12]:36010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEco0-0003LY-5X for emacs-devel@gnu.org; Fri, 23 Jan 2015 06:53:40 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot12.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1YEcnw-0006r5-Bi; Fri, 23 Jan 2015 11:53:36 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1YEcnw-0008Dj-2q; Fri, 23 Jan 2015 11:53:36 +0000 In-Reply-To: (Oleh's message of "Fri, 23 Jan 2015 11:47:15 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181665 Archived-At: Oleh writes: >>> Maybe we could introduce a more limited form of reader macros. >>> E.g. allow # and make the reader return >>> >>> (funcall (cdr (assq reader-macro-alist)) ) >> >> Would it not be possible to have the reader return a macro which could >> do the cdr and assq at compile time and obviate the need for funcall? >> This would be faster. It means that changes to reader-macro-alist >> wouldn't be reflected in code till it was re-evaled. >> >> My main concern with this as a proposal is that is a fairly >> small namespace. There is a lot of possibility for pretty disasterous >> clashes if this gets used in the wild. > > How about this: > > #a(...) is (reader-macro-a ...) > #b(...) is (reader-macro-b ...) > > ... > > #z(...) is (reader-macro-z ...) > > This would be easy to implement, since this is just an extension of > the `backquote' and `short-lambda' method to 26 reader macros. That would work, but I don't think it's necessary -- if there is a compile time lookup, it's just as efficient. More over, it's not necessarily 26 macros -- if emacs is multi-byte then there are a lot of potential macros. It would even be possible to do #symbol
where symbol is any length, which would help to avoid the namespace problem -- this is pretty much the expressivity of tagged literals in Clojure. Although, my experience in Clojure is that few people use them, because they must be namespaced so take too long to type (and for other reasons I think). > The core could take over some of them, and leave the rest open to the > public. I'd agree that single (and probably two) letter symbols would have to be restricted to the core by convention. Phil