|
From: | Joost Kremers |
Subject: | Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs] |
Date: | Mon, 11 May 2020 11:08:25 +0200 |
User-agent: | mu4e 1.4.4; emacs 27.0.91 |
On Mon, May 11 2020, Richard Stallman wrote:
> (print (eval (read))) > into: > (-> (read) > eval > print)The preference is a matter of taste. If you have a taste for Lisp, the formerseems totally natural. If you don't, maybe it seems strange.
IMHO it's not a matter of having a taste for Lisp or finding `(print (eval (read)))` 'natural' or not. I find it perfectly natural, but there are cases where it becomes difficult to read, especially when you nest not two or three but five or six function calls and/or when each function call has additional arguments, which may be function calls themselves.
You can use `let*` to lay out such structures in a way that make them more readable. `->` and `->>` are even better than `let*` in this particular case, because you don't need the intermediate names.
->> is natural enough, because it adds the carried-over argument at the end of the list. But -> is unnatural,since it adds the carried-over argument in the middle of the list(after the first element). I think that nested calls are cleaner than ->.
Well, let's agree to disagree on what 'natural' means when it comes to Lisp. :-) To me, Lisp is first and foremost a practical language and if there's more than one way to skin a cat, it's fine if there's more than one language construct to do so.
Unlike *some* languages where everything must be an object and you need to contort your mind to use an anonymous function, or where everything needs to be a pure function and doing basic file IO becomes a mountain to climb. (All IME, of course. :-/ )
-- Joost Kremers Life has its moments
[Prev in Thread] | Current Thread | [Next in Thread] |