emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thorsten <quintfall@googlemail.com>
To: Tom Prince <tom.prince@ualberta.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Elisp programming style
Date: Fri, 28 Oct 2011 20:05:22 +0200	[thread overview]
Message-ID: <86d3dhouu5.fsf@googlemail.com> (raw)
In-Reply-To: <8739edf1vx.fsf@hermes.hocat.ca> (Tom Prince's message of "Fri, 28 Oct 2011 13:43:14 -0400")

Tom Prince <tom.prince@ualberta.net> 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

  reply	other threads:[~2011-10-28 18:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 18:03 Elisp programming style Thorsten
2011-10-28 10:17 ` Štěpán Němec
2011-10-28 14:09   ` Thorsten
2011-10-28 14:31     ` Nick Dokos
2011-10-28 15:59       ` Thorsten
2011-10-29  2:13       ` Eric Abrahamsen
2011-10-28 14:34     ` Tassilo Horn
2011-10-28 14:40       ` Eric Schulte
2011-10-28 16:04       ` Thorsten
2011-10-28 14:35     ` Eric Schulte
2011-10-28 15:52       ` Thorsten
2011-10-28 17:43     ` Tom Prince
2011-10-28 18:05       ` Thorsten [this message]
2011-10-29  7:43         ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86d3dhouu5.fsf@googlemail.com \
    --to=quintfall@googlemail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tom.prince@ualberta.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).