How do I dynamically create functions without lambda?

Alan Morgan amorgan at xenon.Stanford.EDU
Wed Feb 1 16:29:12 EST 2006


In article <pan.2006.01.28.12.02.34.293286 at REMOVETHIScyber.com.au>,
Steven D'Aprano  <steve at REMOVETHIScyber.com.au> wrote:
>On Sat, 28 Jan 2006 00:13:28 -0800, Kay Schluehr wrote:
>
>[snip lambda calculus stuff]
>
>> In Python you can write:
>> 
>> Y = lambda g: (lambda f: g(lambda arg: f(f)(arg))) (lambda f: g(lambda
>> arg: f(f)(arg)))
>> 
>> This serves the purpose. Try Y(F) and see.
>
>
>Is any of this stuff maintainable in the real world of IT, where
>most programmers don't have computer science degrees? You come along six
>months after the project was finished to maintain this code and discover
>that the whiz-kid lambda calculus guy never commented anything because
>that would detract from the elegance of his one liners; what happens next?

Excessive cleverness can lead to unmaintainable code.  So can excessive stupidity.
Since there are a lot more stupid people than clever people out there I think
the more likely scenario is having to maintain unmaintainable code written by a
complete idiot whose programming knowledge comes solely from books whose titles
end with "In 7 Days". 

Oh, and I'd hope that code reviews, etc. would have kept lambda-boy from getting
too far down this path of self invocation.

Alan
-- 
Defendit numerus



More information about the Python-list mailing list