emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Elisp programming style


From: Thorsten
Subject: Re: [O] Elisp programming style
Date: Fri, 28 Oct 2011 20:05:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Tom Prince <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]