From: Just Another Victim of the Ambient Morality Date: 2006-08-02T08:55:06+09:00 Subject: Re: I thought this was the one that worked? "Jacob Fugal" wrote in message news:507567670608011256r43f08bd5w3f5a43b00d80df32@mail.gmail.com... > > # 3) block yielded to > def baz > yield "world" > end > > David's point, however, is that in the third example, when yield is > used instead of converting it to a block, the code inside the block > never really leaves the context in which it is created, because of the > way non-converted blocks are implemented. More specifically, that > implementation doesn't need to store that environment. This is a > probable reason for the speed difference between converted blocks > (first class procs) and unconverted blocks (yield). Since the > environment is never stored, it's not really a closure *in the > implementation*. This is the hair that David was splitting. Maybe you know more about the implementation of blocks than I do but I find it hard to believe that yielded blocks don't store a reference to their environment. I mean, they were able to access it, right? How does it do that without that reference? > But semantically, whether a block is converted to a proc or just > yielded to, the behavior regarding variable scope is identical; so if > one is a closure, it's useful to refer to the other as a closure as > well, even if it's not implemented as a true closure. In this sense, > all blocks are closures. I believe that, when describing a programming language and its features, the behaviour of the language is more important than its implementation. I mean, the language is defined by its specification rather than some implementation, right?