Of what use is 'lambda'???
Jonadab the Unsightly One
jonadab at bright.net
Mon Sep 25 03:37:40 CEST 2000
Erik Max Francis <max at alcyone.com> wrote:
> It doesn't "harm" them, but it sometimes makes things simpler. Often a
> module or library will have internal functions that the user _shouldn't_
> call. Using lambdas on the fly for these kind of applications
> eliminates the need to hide symbols from the user, because they never
> had symbols to begin with.
Encapsulation arguments never win any points with me. If
the user shouldn't call it, just give it the docstring
"internal function", but frankly I've not infrequently found
myself legitimately calling code that the author considered
to be internal and thought I shouldn't call. How do you
*know* what the user will need to do or not do? Can you
anticipate all circumstances? If a function has side-effects,
just document them, or if you don't have time to do that just
give the single cryptic "Careful; this has side-effects"
and let 'em figure it out. Encapsulation is essentially
saying "This is for my convenience, but if you need to
do the same thing you'll have to write your own code,
because I won't let you use mine." If that's your deal,
just ship a binary with no source code; then nobody can
mess with any of your subroutines. (Not that this never
makes sense; for commercial software in particular it
makes a lot of sense. That's not my point.)
The map/mapcar argument I still can't argue against,
because I have no experience with map/mapcar.
More information about the Python-list