On Sat, 06 May 2006 21:19:58 -0400, Bill Atkins wrote: > There are also cases where a function is so trivial that the simplest > way to describe it is with its source code, where giving it a name and > putting it at the beginning of a function is just distracting and > time-consuming. E.g.: > > (remove-if (lambda (name) > (find #\- name :test #'char=)) > list-of-names) > > What's the sense of giving that function its own name? It's much > clearer to simply write it in place. Yes, it's _possible_ to use > named functions, but in this case its functionality is so simple that > it's clearer to simply type it in place. Why is this expressiveness a > bad thing, aside from its power to wreck an indentation-significant > language?
Well, you can do that with python's current, non-indentation-significance-wrecking, lambda syntax, so I don't think that's a particularly persuasive example. Note also that the only limitation python has on where you can define functions is that you can't define them inside expressions (they have to be statements), so you could define a named function right before the call to remove-if, which removes some of the advantage you get from the lambda (that is, the function definition is not very far from when it's used). Actually, I think the limitation on python that is operative here is not significant whitespace, but the distinction between statements and expressions. (crossposts trimmed) -- http://mail.python.org/mailman/listinfo/python-list