[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sweeter Emacs Lisp

From: Lars Magne Ingebrigtsen
Subject: Re: Sweeter Emacs Lisp
Date: Sun, 14 Jul 2013 16:22:39 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

address@hidden writes:

>   + The *threading* macros "->" and "->>":


>   (setq tag (cons "<p>" "</p>"))
>   (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.

>   + when-let, if-let:

Yes, `when-let' is pretty nice.

>   + *we need a built-in core mapcan (could be called mapcat), filter and
>   sequence concatenation (could be called cat?) function that doesn't
>   depends on cl-lib*. This is fundamental stuff isn't it? Why is such a
>   need to require a library for it?

Why not just use the cl functions?  

>   + Destructuring in defun and let: This looks weirder than I thought
>   because of our (ab)use of parens everywhere, but I feel this is
>   something brillant to have as part of the core language.

Destructuring lambda argument lists (a la Common Lisp) would be very
nice, yes, but is probably an uphill battle.

>   ;; let destructuring
>   (defun fmt-tag (tag)
>     (let (((open close) tag))
>       (format open close)))

This is just a different way to write `destructuring-bind', though.  I
don't see the point.

>   + 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

>   + 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 "</p>")
>   (puthash tags :span "</span>")
>   (gethash :span tags) ; -> "</p>"

That's painful?  It seems clear and nice to me.

>   ;; clojuresque version
>   (setq tags {:p "</p>" :span "</span>"})
>   (:p tags) ; -> "</p>"
>   (tags :p) ; -> "</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?

> [0] http://clojure.org/

If these are the bits that are exciting in Clojure, then Clojure doesn't
seem particularly exciting to me.  :-)

(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]