Self function

Luis Alberto Zarrabeitia Gomez kyrie at uh.cu
Wed May 6 18:33:20 EDT 2009


Quoting Rhodri James <rhodri at wildebst.demon.co.uk>:

> >> I'm sorry, but while I'm mildly positive towards the proposal (and more
> >> so towards Aaron's decorator), I don't buy this argument at all.  What
> >> is broken about your editor's global search-and-replace function that
> >> makes it "usually useless" for making these name changes?
> >
> > It happened to me sometimes. If a module defines some functions, and it  
> > doesn't *use* them, why should I use a global search-and-replace to  
> > rename something? Modifying the "def" line should be enough - unless the  
> > function happens to be recursive.
> 
> So the answer to my question would be "nothing"?

Indeed, there is nothing broken with the search and replace feature of his
editor. When he is copying a non-recursive function, it is _useless_ to do a
search and replace. When he is copying a recursive function, it is _required_ to
do a search and replace.

So, the very same task requires you to either perform a task that will almost
always be useless (or even dangerous), or to read the source code to find out if
the function is recursive, so that you can use the search and replace only then.

(I know that the "problem" is present in almost all programming languages... but
that's not what is being discussed. Bearophile's concerns seem legitimate, and
you should not dismiss them so lightly just because there are ways to do more
work and hopefully avoid the problems. I'd say that the "problem" is even
aggravated in python, where the dynamic nature of the language makes it near to
impossible to build good refactoring tools) 

-- 
Luis Zarrabeitia
Facultad de Matemática y Computación, UH
http://profesores.matcom.uh.cu/~kyrie

-- 
Participe en Universidad 2010, del 8 al 12 de febrero de 2010
La Habana, Cuba 
http://www.universidad2010.cu




More information about the Python-list mailing list