Read this article to see exactly what I've been talking about. I gotta run because I'm meeting a friend somewhere in a few minutes, but the gist of it is this...
The inclusion of iteration as a core concept represents Perl design at its finest. Instead of providing a clumsy mechanism in non-core code, as Java and C++ (through its standard template library) do, Perl incorporates this pattern into the core of the language.
So the iterator pattern from GoF is a core part of Perl we hardly think about. The next pattern might actually require us to do some work.
This is such huge BS. With the Java version he gives code for, you could be iterating over a database record, the lines in a file, stuff coming over a socket, user events, who knows. The Perl version isn't using a design pattern. It's not abstracting anything. It's just having everything return lists! Big deal. The java version is much more powerful.
He highlights that the Perl 6 version will be able to have lists built lazily, and I think that might be able to match the power of iterators in general in languages like Java or C++, or Ruby (which actually does let you abstract different things to use the same loop syntax), which is why I'm hopeful about Perl 6.
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):