From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Subject: Re: Elisp programming style Date: Fri, 28 Oct 2011 12:17:39 +0200 Message-ID: <8762j94dz0.fsf@gmail.com> References: <86obx2gvmd.fsf@googlemail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJjb2-0002LE-E4 for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 06:23:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJjb1-0002d0-B3 for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 06:23:32 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]:42202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJjb1-0002YW-3h for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 06:23:31 -0400 Received: by faat2 with SMTP id t2so1024400faa.0 for ; Fri, 28 Oct 2011 03:23:29 -0700 (PDT) In-Reply-To: <86obx2gvmd.fsf@googlemail.com> (Thorsten's message of "Thu, 27 Oct 2011 20:03:22 +0200") 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: Thorsten Cc: emacs-orgmode@gnu.org On Thu, 27 Oct 2011 20:03:22 +0200 Thorsten wrote: > Hi List,=20 > doing some Elisp programming (in an orgmode context) recently, the > following question with regards to the 'accepted programming style' for > Elisp concerned me: > > How independent and self-sustained should helper functions be?=20 > > I found some redundancy in elisp code, e.g. several (main and helper) > functions that do exactly the same thing to extract the same specific > args out of an argument list. My first reaction was, to factor out this > extraction into the main function, and then call the helper functions > from inside a (let ...) environment where the extracted args are stored > in a local variable. > > But then I recognised, that the helper functions cannot be called > independently anymore, but only make sense when called from this one > main function with its local bindings. > > Is there a kind of convention in a case like this? Like: "Make every func= tion, > even a helper function, independent, and don't care about redundancy"? > Just being curious Too bad you didn't give any concrete examples. In general, if the helper function is only used in a single place and isn't likely to be more generally useful, there might be no reason for it to be a standalone function at all (other than modular programming, which is always a good idea IMO). OTOH, if the helper function _is_ standalone and used in multiple places, then there is no "redundancy", so I'm really not sure what you mean. If I understand you correctly, you find multiple pairs of main and helper functions, where the helper does very similar things. In that case the right thing would seem to be to abstract all the helpers into a single helper and use that in all the main functions. [To clarify, this all is just an opinion of an interested Emacs and Org user who often pulls his hair when trying to make use of/fix bugs in existing code and bumping into lacks in modular design. The maintainers will perhaps provide more authoritative guidelines.] --=20 =C5=A0t=C4=9Bp=C3=A1n