Erik Meijer writes on his blog:
In principle there is nothing that prevents special list transformers and comprehensions from being introduced into imperative languages as well. We know how to do it. In fact, as is the case for many other features, Python has already taken the lead in this.
Python has limited syntax for iteration and unlimited classes that behave as iterators.
The less obvious, more expressive example is Smalltalk, which eschews special iteration syntax. This so called "pure" object-oriented language does not have any syntax for iteration. Everything is a message send, even conditionals and iterations.
A simple notation for a "block of code" object and a simple notation for keyword-based parameters/messages give you what you need without hidden machinery or a fixed syntax. Any of Smalltalk's flow of control mechanisms can be defined in Smalltalk itself. And more, to your heart's content.
BTW, Ruby is closer to Smalltalk than Python is to either in this regard.
No comments:
Post a Comment