Express What, not How.

Raffael Cavallaro raffaelcavallaro at junk.mail.me.not.mac.com
Fri Oct 17 01:47:00 EDT 2003


In article <87ekxciphd.wl at strelka.synthcode.com>,
 Alex Shinn <foof at synthcode.com> wrote:

> We use adjectives and adverbs to modify existing words
> without needing to come up with new words, and build further with noun
> clauses and prepositions.  So you can both "run quickly" and "swim
> quickly," which is analogous to a higher order function (quickly)
> working on two existing functions (run and swim).

I think you miss the point - "quickly" is itself a _name_ for an 
abstract modifier. If this is the analog of a higher order function, it 
is a _named_ higher order function, not an anonymous one.

We don't say "he ran (large distance covered/unit time)" or "he swam 
(large distance covered/unit time)." Instead, we give this abstraction, 
(large distance covered/unit time) a name, "quickly."

I am most definitely _not_ arguing against the use of higher order 
functions when appropriate. When dealing with concepts of the problem 
domain though, those higher order functions should probably have 
_names_. And when it is not possible to cast these HOFs in a _syntax_ 
that fits the usage of the problem domain, these named HOFs will 
naturally find their way into macros ;^)

One could conceive of a loose ranking of modes of expression and levels 
of abstraction. From lowest (least abstract) to highest:

language primitives
anonymous functions
named functions  and higher order anonymous functions
     (a tie here because naming is inherently more abstract
     than anonymity, and HOFs are of course more abstract
     than ordinary functions)
named higher order functions
macros




More information about the Python-list mailing list