Express What, not How.

Raffael Cavallaro raffaelcavallaro at junk.mail.me.not.mac.com
Wed Oct 15 15:11:21 EDT 2003


In article <bmjnle$olc$1 at f1node01.rhrz.uni-bonn.de>,
 Christian Szegedy <szegedy at nospam.or.uni-bonn.de> wrote:

> In functional languages, a lot of higher order functions are used for
> iterating over some container datastructure. E.g. map,iter,foldl,zip,...


As long as the same idiom is not used over and over again, in the same 
way, this is fine. Once you find that you are repeating the same idiom, 
I think it's time to name that idiom descriptively, and make it a named 
function or macro.

> 
> A lambda expression parameter of such functions plays the
> same role as a body of a "while" or "for" loop in C.
> Do you think that your criterions should be applied to blocks
> of codes in C also?

The problem with C is that it lacks a true macro system (as opposed to a 
simple token substitution system). This means that there will be cases 
where there is a frequently used idiom that could be abstracted in a 
lisp macro, but not in a C macro.

But, insofar as it is possible to abstract out repetition and unecessary 
implementation detail, it should be done in any language that supports 
named functions. Better still if the language supports macros for those 
cases that would require them.




More information about the Python-list mailing list