From: Dan Doel Date: 2003-12-10T00:55:44+09:00 Subject: Re: Adjusting the Scope of Blocks >I had never noticed that closures behave this way when >instance_eval'd. My initial reaction is dislike. To me it feels too >close to having the code in the block interpreted as an eval string. > >... > > >It feels non-closure-like to me. I don't see why a block should care >what 'self' is at the time it's called; I thought the point was for it >to preserve the context of its creation. > > Essentially it's not exactly a closure at that point. But that's not necessarily bad. After all, the point of any #eval or variation thereof is to execute the given code in the current context (where context might be scope, or merely with the current self). In other words, there's two ways to look at Proc objects. If you're using #call, a Proc is a closure. If you're using ?_eval a Proc is more along the lines of "just a section of code." This is the main reason I brought up dynamic scoping and an #eval that accepts Proc object to execute a few days ago. To me it seems more elegant to pass a "code section object" to #eval than it does to pass a String, and it isn't that inconsistant with what's already in place. - Dan