From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Subject: Re: Elisp programming style Date: Fri, 28 Oct 2011 20:05:22 +0200 Message-ID: <86d3dhouu5.fsf@googlemail.com> References: <86obx2gvmd.fsf@googlemail.com> <8762j94dz0.fsf@gmail.com> <86obx1qkcc.fsf@googlemail.com> <8739edf1vx.fsf@hermes.hocat.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:60686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJqnz-00042w-Qe for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 14:05:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJqny-0004d6-Jd for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 14:05:23 -0400 Received: from mail-bw0-f41.google.com ([209.85.214.41]:64432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJqny-0004cy-Dp for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 14:05:22 -0400 Received: by bkbzu5 with SMTP id zu5so2933483bkb.0 for ; Fri, 28 Oct 2011 11:05:20 -0700 (PDT) In-Reply-To: <8739edf1vx.fsf@hermes.hocat.ca> (Tom Prince's message of "Fri, 28 Oct 2011 13:43:14 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Tom Prince Cc: emacs-orgmode@gnu.org Tom Prince writes: > Perhaps > > ,----------------------------------------------------------- > | (defun main-function (args) > | (let ((var (assoc :key1 args))) ; extracting var once > | ... > | (helper-function1 ... var ...) ; inside let using var > | (helper-function2 ... var ...) ; inside let using var > | )) > | > | (defun helper-function1 (var') > | ... > | ) > | > | (defun helper-function2 (var') > | ... > | ) > `----------------------------------------------------------- > > or > > ,------------------------------------------------------------- > | (defun get-key1 (args) (assoc :key1 args)) > | (defun main-function (args) > | (let ((value (get-key1 args)) ; extracting var 1st time > | ... > | ) > | (helper-function1 ...) ; outside let > | (helper-function2 ...) ; outside let > | ) > | > | (defun helper-function1 (args) > | (let ((value (get-key1 args)) ; extracting var 2nd time > | ... > | )) > | > | (defun helper-function2 (args) > | (let ((value (get-key1 args)) ; extracting var 3rd time > | ... > | )) > `------------------------------------------------------------- > > > I likely wouldn't suggest the second, unless get-key1 was actually > something more complicated than your example. hmm ... I feel quite convinced now that having a standalone function is worth a bit of code duplication, and I start do discover that the cl package does have some nice functions (like flet). cheers -- Thorsten