[Python-Dev] accumulator display syntax
tim.one at comcast.net
Tue Oct 21 16:19:33 EDT 2003
> I expect that most iterator comprehensions (we need a better term!)
Well, calling it an iterator Aussonderungsaxiom would continue emphasizing
the wrong thing <wink>.
"Set comprehensions" in a programming language originated with SETL, and are
named in honor of the set-theoretic Axiom of Comprehension
(Aussonderungsaxiom). In its well-behaved form, that says roughly that
given a set X, then for any predicate P(x), there exists a subset of X whose
elements consist of exactly those elements x of X for which P(x) is true (in
its ill-behaved form, it leads directly to Russell's Paradox -- the set of
all sets that don't contain themselves).
So "comprehension" emphasizes the "if" part of list comprehension syntax,
which often isn't the most interesting thing. More interesting more often
are (a) the computation done on the objects gotten from the for-iterator,
and (b) that the results are generated one at a time.
Put that all in a pot and stir, and the name "generator expression" seems
natural and useful to me. In the Icon language, *all* expressions are
generators, so maybe I'm biased by that. OTOH, "the results are generated
one at a time" is close to plain English, and "generator expression" then
brings to my mind an expression capable of delivering a sequence of results.
Or you could call it an Orlijn flourish.
More information about the Python-Dev