all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs Lisp coding style question
@ 2014-07-02 12:47 Thorsten Jolitz
  2014-07-02 14:19 ` Grant Rettke
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2014-07-02 12:47 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

sometimes I wondered about the following coding style question, so I
decided to do it in public:

Often functions do a lot of work to gather some data and then do a
rather simple action with the gathered data:

#+begin_src emacs-lisp
  (defun foo ()
    (let* ((x (create-x))
          (y (create-y))
          (z (create-z x y))
          (u (create-u z))
          (v (create-v))
          (w (create-w u v)))
      (simple-action w)))
#+end_src

Thats the way I would do it, and I find it easy to write, read and
understand. 

But (without being able to give concrete examples right now) I noticed
that advanced Lispers tend to call this 'C-style', consider the let
bindings unnessesary since the local vars are only used once, and
prefer this style:

#+begin_src emacs-lisp
  (defun foo ()
    (simple-action
     (create-w
      (create-u
       (create-z (create-x) (create-y)))
      (create-v))))
#+end_src

This looks more 'lispy' and might have a slight performance
advantage. But when the 'create-xyz' expressions grow in size the
whole thing might start to look very complicated and it becomes hard to
recognize that its just about `simple-action' with some gathered
data. 

What would be the recommended style for Emacs Lisp, or is this just a
matter of taste?

-- 
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <mailman.4706.1404305298.1147.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2014-07-02 15:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-02 12:47 Emacs Lisp coding style question Thorsten Jolitz
2014-07-02 14:19 ` Grant Rettke
     [not found] <mailman.4706.1404305298.1147.help-gnu-emacs@gnu.org>
2014-07-02 12:56 ` Pascal J. Bourguignon
2014-07-02 13:14   ` Thorsten Jolitz
2014-07-02 13:50     ` Stefan Monnier
2014-07-02 14:04       ` Thorsten Jolitz
     [not found]     ` <mailman.4715.1404309100.1147.help-gnu-emacs@gnu.org>
2014-07-02 15:20       ` Barry Margolin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.