Re: [Python-ideas] Ruby-style Blocks in Python Idea

average wrote: Perhaps I've misunderstood, but both Perl and Javascript (highly popular languages by any standard) support "passing around code blocks" by defining anonymous functions. How can you say that most languages like Python have never experimented with this, when of the more popular programming languages, Javascript and Perl are the most obviously similar to Python (besides Ruby)?
You're likely right. And I'm probably being sloppier than I should. My point was really more about how the art of programming has yet to really explore the concept and power of code-blocks adequately. Most of us are comfortably stuck in our decades of procedural programming experience. What's misleading about framing this discussion is that all of us are [over]used to the "flatland" of the program editor. Code blocks appear on the screen like any other code, but the *critical* point is that LOGICALLY they are ORTHOGONAL to it. Where most of your code could be organized in a tree-like fashion rooted in your program's "main" node, code blocks are orthogonal and are really like leaves spanning back into the screen to a *different* tree's root (the *application's* surface) hence its subtlety. Hoping that analogy is more useful.... marcos

On Mon, Mar 9, 2009 at 1:22 PM, average <dreamingforward@gmail.com> wrote:
What's misleading about framing this discussion is that all of us are [over]used to the "flatland" of the program editor. Code blocks appear on the screen like any other code, but the *critical* point is that LOGICALLY they are ORTHOGONAL to it. Where most of your code could be organized in a tree-like fashion rooted in your program's "main" node, code blocks are orthogonal and are really like leaves spanning back into the screen to a *different* tree's root (the *application's* surface) hence its subtlety.
That's only one use of callbacks. One could claim that a confusing part of anonymous blocks (as used in SmallTalk and Ruby) is that they use the same syntax for both use cases: you can't tell from the syntax whether the block is executed in the place where you see it (perhaps in a loop or with an error handler wrapped around it, or conditionally like in SmallTalk's "if" construct), or squirreled away for later use (once or many times). The good thing about function syntax (as used in JavaScript's anonymous blocks) is that it leaves no doubt about these two different uses: at least by convention, anonymous functions are used for asynchronous programming, while in-line code uses regular block syntax. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (2)
-
average
-
Guido van Rossum