From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Sweeter Emacs Lisp Date: Wed, 17 Jul 2013 00:23:29 +0400 Message-ID: <51E5ABC1.5040002@yandex.ru> References: <8738rh6ftk.fsf@gnu.org> <87r4f0wlug.fsf@yandex.ru> <8738rgtnwn.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1374006243 11409 80.91.229.3 (16 Jul 2013 20:24:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Jul 2013 20:24:03 +0000 (UTC) Cc: fgallina@gnu.org, Lars Magne Ingebrigtsen , emacs-devel To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 16 22:24:06 2013 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 1UzBn3-0004vj-PN for ged-emacs-devel@m.gmane.org; Tue, 16 Jul 2013 22:24:05 +0200 Original-Received: from localhost ([::1]:33202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzBn3-00020R-9F for ged-emacs-devel@m.gmane.org; Tue, 16 Jul 2013 16:24:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzBmp-0001zC-8C for emacs-devel@gnu.org; Tue, 16 Jul 2013 16:24:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzBmW-0006N2-B1 for emacs-devel@gnu.org; Tue, 16 Jul 2013 16:23:51 -0400 Original-Received: from mail-la0-x233.google.com ([2a00:1450:4010:c03::233]:36791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzBmK-0006EW-SO; Tue, 16 Jul 2013 16:23:21 -0400 Original-Received: by mail-la0-f51.google.com with SMTP id fq12so886577lab.38 for ; Tue, 16 Jul 2013 13:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-antivirus:x-antivirus-status; bh=kPzOb2pWSGGxfO7DE5p6Ts+I5DGqIyB1sV/Vw13a4rA=; b=dz6tph4g4IjzO0YKQvEjTjVQZSny3CU6v4byNLWCvKFTmfoaKzpgbEvdp1JJR6NJSh 1c6cUEngAIhj/QJ+8VQK1/WpcLuNd2OrO3bJwCAdlxqaCgDjWjQGpiUwE44RDay8foyd b6ts4NCWoW1oAM4hayOOg35wyArhEDUiwzp1XUhjVgn/c28wXj5BUIG4Kj+h6OCFNoVC /D9fTIxjFIGEZQVhHLLHn5Iwtcn9gB0D2pYeM6wnipFh2MIF8aQPA5EXIbnsPdAuWl/u sdiZ7xRNlfYzOx8vxnfwzDcKYqU4zb1mmUIevovwJ3hNtQmkSMyN3if8OsgXGTGs8VPL U2vg== X-Received: by 10.112.235.104 with SMTP id ul8mr1832214lbc.36.1374006199303; Tue, 16 Jul 2013 13:23:19 -0700 (PDT) Original-Received: from [127.0.0.1] ([178.252.98.87]) by mx.google.com with ESMTPSA id t15sm1612839lbh.16.2013.07.16.13.23.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Jul 2013 13:23:18 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: <8738rgtnwn.fsf@uwakimon.sk.tsukuba.ac.jp> X-Antivirus: avast! (VPS 130716-0, 16.07.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::233 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:161946 Archived-At: On 15.07.2013 9:03, Stephen J. Turnbull wrote: > If you find > > (defun tag-desc-stripped (tag) > (upcase (replace-regexp-in-string "[<\\/> ]" "" (car tag)))) > > hard to read, This is still a trivial example. And no, now I don't, having spent a couple of years or so writing Elisp. But I still remember that reading functions "from inside out" was one of the harder parts, especially with the level of nesting that one can often observe in core Emacs packages. Look, for example, at `calculate-lisp-indent'. Here are some appreciative opinions with better examples: http://blog.8thlight.com/colin-jones/2011/03/27/clojure-mad-science-an-evil-threading-macro-experiment.html http://debasishg.blogspot.ru/2010/04/thrush-in-clojure.html http://thecomputersarewinning.com/post/Clojure-Thrush-Operator/ > And this breaks C-x C-e badly. No more than using local variables, I'd say. Except when you're using something like `edebug' in dynamic scoping mode (with lexical scoping, `edebug' doesn't see local vars yet). > This isn't just a matter of loss of > convenience; it's a symptom of a major syntax change. It breaks *any* > code analysis tool. I don't see how. The analysis tools have to expand macros anyway, or they would stumble and break when encountering any macro not from a predefined set. > And it is unnecessary, except for saving some > keystrokes. You could imagine > > (defun threaded-apply-to-1 (arg &rest list-of-fun) > ;; actually, just `apply-to' is probably sufficiently mnemonic > (while list-of-fun > (setq arg (funcall (pop list-of-fun) arg))) > arg) > > (defun tag-desc-stripped (tag) > (threaded-apply-to-1 tag > #'car > (lambda (x) (replace-regexp-in-string "[<\\/> ]" "" x)) > #'upcase)) > > That style makes me slightly ill, but (1) it's more general than `->' > and `->>' combined, and (2) it doesn't turn malformed function calls > into curried functions implicitly. So it doesn't break C-x C-e and > other tools that depend on the simplicity of Lisp expression syntax. True, that's also an option. Here's an implementation in Clojure[0]: (defn thrush [a & args] ((apply comp (reverse args)) a)) Incidentally, Clojure has a shorter reader macro for anonymous functions. Yours would look like this: #(replace-regexp-in-string "[<\\/> ]" "" %) And being a Lisp-1, it doesn't need the hash-quotes before the other arguments. [0] http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/