Express What, not How.
Raffael Cavallaro
raffaelcavallaro at junk.mail.me.not.mac.com
Mon Oct 20 19:20:12 EDT 2003
In article <oprxcymd2n3seq94 at news.nscp.aoltw.net>,
David Rush <drush at aol.net> wrote:
> I have in a mail-processing application 2 functions IF-FROM-LINE (used in
> mbox file processing) and RFC822-COLLAPSE-HEADER (used in RFC822 header
> processing) which both implement algorithms which are parameterized
> by functions. This is vaguely similiar in spirit to the visitor pattern
> from OO land, but much more flexible. Both of these functions are used
> in multiple contexts where the anonymous functions contextualize the
> operations performed under specific conditions in their implemented
> algorithms. These operations have (so far) been strictly one-off animals.
I think you are in violent agreement with me.
I wrote:
> > The problem I see with the use of
> > the typical anonymous functional
^^^^^^^^^
> > style is twofold:
1. If-from-line is a _named_ function, not an anonymous function. My
only objection was to _anonymous_ functions replacing named
abstractions, not to functional programming itself.
> In the event that I ever feel a need to re-use one of them I will simply
> lift the anonymous function from its original source location, give it
> a top-level name et voila - instant reuse.
2. Which is precisely what I suggested in all of my previous posts.
I.e., if the anonymous function is used more than once, name it, and use
the name.
More information about the Python-list
mailing list