From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Subject: Re: Elisp programming style Date: Fri, 28 Oct 2011 17:52:41 +0200 Message-ID: <86k47pqfjq.fsf@googlemail.com> References: <86obx2gvmd.fsf@googlemail.com> <8762j94dz0.fsf@gmail.com> <86obx1qkcc.fsf@googlemail.com> <87fwiduqti.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJojt-00026t-IO for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 11:53:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJojs-0005u6-8G for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 11:53:01 -0400 Received: from lo.gmane.org ([80.91.229.12]:48493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJojr-0005tz-LX for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 11:53:00 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RJojj-0000x6-Ce for emacs-orgmode@gnu.org; Fri, 28 Oct 2011 17:52:51 +0200 Received: from g231224198.adsl.alicedsl.de ([92.231.224.198]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Oct 2011 17:52:51 +0200 Received: from quintfall by g231224198.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Oct 2011 17:52:51 +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 Eric Schulte writes: Hi Eric, > Hmmm, this looks suspiciously like the case in some Babel functions :) well ... ;) > in which we originally has instances of the first style and then had to > manually transition to the second. IMO the first is very poor form, the > variables are technically "free variables" when defined in the helper, > and just through undocumented variable capture does the execution work > out correctly, this can lead to unpleasant bugs. > > The means the helper may only be used when variables of certain names > are in scope. > > If you do want to use a helper which uses variables in scope which > aren't passed as arguments (again just my opinion) you should defined > the helper function using `flet' *inside* of the main function and the > scope of the variables. That sounds like an operational prescription to me, and I think will follow this advice in the future. >> Would that be considered bad style from the original author, or is that >> up to personal choice and not considered a problem? >> > > I don't believe we have an official canon of such rules, but personally > I would consider this to be bad style. If the helper function is only > used in one main function then it should be defined using flet, if it is > used across multiple functions then the in-scope variables should be > passed as explicit arguments (preferably with names other than those > which it has in scope so you can be sure you are actually using the > arguments). > > Finally, I believe the emacs-lisp compiler would complain about such > free variables. > > Hope this helps, Best -- Eric yes that helped, thanks cheers -- Thorsten