Lazy list/range comprehensions

bearophile bearophileHUGS at lycos.com
Sun Oct 3 11:24:56 PDT 2010


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.


> 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 :-) This too needs psychology experiments, but I need a backup life to find the time to perform 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.

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). 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.

Bye,
bearophile


More information about the Digitalmars-d mailing list