On 10/03/2010 01:24 PM, bearophile wrote:
Andrei Alexandrescu:
return reduce!("a+b")(map!("a*a")(sequence), 0);
That's many times worse than the Python syntax.
This entails there's a way to measure that. How?
Probably the only way good for you is to take a group of programmers
and perform some experiments of experimental psychology, similar to
the experiments of ergonomics done to find if the design of a car
gear shift stick is good enough for most users.
That's not the way for "me", it would be a simple application of the
scientific method that could impart credibility to the argument. And
it's more similar to the experiments done routinely in software
engineering research than in automotive industry.
You'd need to bring a pointer to a document that confirms that (and
how) array and range comprehensions have helping chunking as their
point.
It's a theory of mine :-)
Not labeling it as such hurts the quality of the conversation.
This too needs psychology experiments, but I need a backup life to
find the time to perform them.
Again, it's a common method in software engineering research. The point
is one shouldn't make claims without being able to substantiate them.
In my code I have seen that I need several tries to catch a correct
way to write those reduce!(...)..., while I don't have the same
problems in Python.
Alright, there's one user experience. A few more and we can collect some
statistics :o).
In Python3 they have even removed the built-in reduce (and moved it
into the standard library) because practical experience has shown
that many newbies and Python programmers find the semantics of
reduce() not so easy to understand (like when they read code written
by other people).
A link to a document that illustrates that motivation would be great.
For all I know Python 3 also transformed print from a statement into a
function, but for very different reasons.
S the usage of reduce() is a bit discouraged in
normal Python code. This is also why I have suggested
(http://d.puremagic.com/issues/show_bug.cgi?id=4725 ) to add a sum()
to Phobos2.
Yeah, sum() is probably popular enough to deserve a special case.
Anyway, I just changed filter:
http://www.dsource.org/projects/phobos/changeset/2081
in ways that it should allow:
assert(equal(compose!(map!"2 * a", filter!"a & 1")([1,2,3,4,5]),
[2,6,10]));
assert(equal(pipe!(filter!"a & 1", map!"2 * a")([1,2,3,4,5]),
[2,6,10]));
both of which group operations in separation from their inputs.
Andrei