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: Mon, 15 Jul 2013 07:20:07 +0400 Message-ID: <87r4f0wlug.fsf@yandex.ru> References: <8738rh6ftk.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1373858427 2984 80.91.229.3 (15 Jul 2013 03:20:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Jul 2013 03:20:27 +0000 (UTC) Cc: fgallina@gnu.org, emacs-devel To: Lars Magne Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 15 05:20:29 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 1UyZKu-0003Pa-IF for ged-emacs-devel@m.gmane.org; Mon, 15 Jul 2013 05:20:28 +0200 Original-Received: from localhost ([::1]:56988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyZKu-0005I2-1V for ged-emacs-devel@m.gmane.org; Sun, 14 Jul 2013 23:20:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyZKl-0005Hg-Np for emacs-devel@gnu.org; Sun, 14 Jul 2013 23:20:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyZKe-0004WL-Rn for emacs-devel@gnu.org; Sun, 14 Jul 2013 23:20:19 -0400 Original-Received: from mail-lb0-x236.google.com ([2a00:1450:4010:c04::236]:47017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyZKe-0004WF-K4; Sun, 14 Jul 2013 23:20:12 -0400 Original-Received: by mail-lb0-f182.google.com with SMTP id r11so8825819lbv.41 for ; Sun, 14 Jul 2013 20:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:x-antivirus:x-antivirus-status; bh=Ys85IK+5Bfo4PeVBOwLeNha4ZlFsZxyOrdU/WgrIOZE=; b=LzWlgb9Zhvy7cI6sqRNzVLAYMEHC/G7JPYBnwh8dIpVdH3kfhvMFWaVqEhxqzNG96Z WrIuGrEcP+tZrgGje8OquKJrTIFApy1WTgdBF9q6LINoxF/B5qfvKsykiPZalwW0ib4b jBtncvc07ZS8ph6NX8/KI6xFky1eVPdYuc+nxMFY4jXdZ6j8f/LeP8yk8GJiR5javG4R AwIIP4XXPUAgLVEQxx/JL8KsdgFoO2sg9sKMDKFaShCcxV83q2G+FgdQ73PQ9DGjVGW0 29rddVOVyIlEIW6mI8baUcvndq86jaCBYK3vA7uNGFgT2aI0kwRP1FoTfW2/aX9mrO0X jHCw== X-Received: by 10.152.22.232 with SMTP id h8mr23704164laf.37.1373858411546; Sun, 14 Jul 2013 20:20:11 -0700 (PDT) Original-Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPSA id t15sm17602562lbh.16.2013.07.14.20.20.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 14 Jul 2013 20:20:10 -0700 (PDT) In-Reply-To: (Lars Magne Ingebrigtsen's message of "Sun, 14 Jul 2013 16:22:39 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Antivirus: avast! (VPS 130714-1, 14.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:c04::236 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:161891 Archived-At: Lars Magne Ingebrigtsen writes: >> (setq tag (cons "

" "

")) >> >> (defun tag-desc (tag) >> (concat (upcase (car tag)) ".")) >> >> (defun tag-desc-stripped (tag) >> (upcase (replace-regexp-in-string "[<\\/> ]" "" (car tag)))) >> >> ;; with threading macros >> (defun tag-desc (tag) >> (-> (car tag) (upcase) (concat "."))) >> >> (defun tag-desc-strip (tag) >> (->> (car tag) (replace-regexp-in-string "[<\\/> ]" "") (upcase))) > > It's not clear what the point of these are. Just to make the code more > obscure and cool? The new forms (as demonstrated here) even leads to > longer code, in addition to being pretty opaque. While the "old" code > is obvious and easy to read. They're most useful with larger sequences of transformations. You may be used to reading the code "inside out" by now, but threading operators are easy to understand, and they make the flow of information much more obvious. >> + make `let` work like `let*`: "let's" stop confusing newcomers. > > I don't think it's that confusing. It would be more confusing having > let and let* work differently in Emacs Lisp than in other Lisps, I > think. I'd be willing to bet that Emacs Lisp newcomers originating from other Lisp backgrounds are a distinct minority. >> + hash-tables: how come that working with hash-tables is such a pain? >> I love how they are function of themselves in clojure and that >> there's reader syntax for them. >> >> (setq tags (make-hash-table)) >> (puthash tags :p "

") >> (puthash tags :span "") >> (gethash :span tags) ; -> "

" > > That's painful? It seems clear and nice to me. > >> ;; clojuresque version >> (setq tags {:p "

" :span ""}) >> (:p tags) ; -> "

" >> (tags :p) ; -> "

" >> (:html tags) ; -> nil > > This just seems like a "neat" way to write opaque code. Did the Clojure > people come from a Perl or Scheme background, by any chance? Most of the adopters come from Java and Ruby, AFAIK. And JavaScript, especially lately. But, FYI, the first version of Clojure was written in Common Lisp. I think the OP is missing the point here, though. While the combination of Lisp-1 and virtual dispatch looks pretty, it's a non-starter for a Lisp-2, which Emacs Lisp is. Clojure's standard library is great even without those, for example take a look at functions dealing with maps: http://clojure.org/data_structures#Data Structures-Maps (IPersistentMap) The API is quite dependent on maps being immutable, though, so it wouldn't be easy to bring them to Emacs either.