From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tassilo Horn Subject: Re: Elisp programming style Date: Fri, 28 Oct 2011 16:34:46 +0200 Message-ID: <87fwiddw1l.fsf@thinkpad.tsdh.de> References: <86obx2gvmd.fsf@googlemail.com> <8762j94dz0.fsf@gmail.com> <86obx1qkcc.fsf@googlemail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:44543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJnWY-0000LS-Vd for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 10:35:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJnWX-0005ya-RL for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 10:35:10 -0400 Received: from lo.gmane.org ([80.91.229.12]:47821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJnWX-0005y1-HN for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 10:35:09 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RJnWT-0000wM-S6 for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 16:35:05 +0200 Received: from tsdh.uni-koblenz.de ([141.26.67.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Oct 2011 16:35:05 +0200 Received: from tassilo by tsdh.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Oct 2011 16:35:05 +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: emacs-orgmode@gnu.org Thorsten writes: >> Too bad you didn't give any concrete examples. > > The problem can be described easily: > > problem-specific helper-funcions (some redundancy avoided) > ,----------------------------------------------------------- > | (defun main-function (args) > | (let ((var (assoc :key1 args))) ; extracting var once > | ... > | (helper-function1 ...) ; inside let using var > | (helper-function2 ...) ; inside let using var > | )) > | > | (defun helper-function1 () > | ... > | ) > | > | (defun helper-function2 () > | ... > | ) > `----------------------------------------------------------- > > vs > > standalone helper-functions (but redundancy) > ,------------------------------------------------------------- > | (defun main-function (args) > | (let ((value (assoc :key1 args)) ; extracting var 1st time > | ... > | ) > | (helper-function1 ...) ; outside let > | (helper-function2 ...) ; outside let > | ) > | > | (defun helper-function1 (args) > | (let ((var (assoc :key1 args))) ; extracting var 2nd time > | ... > | )) > | > | (defun helper-function2 (args) > | (let ((var (assoc :key1 args))) ; extracting var 3rd time > | ... > | )) > `------------------------------------------------------------- That's still very vague. If `args' is some structure that has some meaning and its parts belong together, say, an org entry, then it makes sense to have the helper functions defined on that structure in order to provide a consistent interface throughout the library. And I wouldn't tell multiple similar let-bindings duplicate code. But again, that's only my very abstract point of view. Given a concrete example, my opinion might be completely upside-down. ;-) Bye, Tassilo