From: David Fayram Date: 2003-08-06T23:39:02+09:00 Subject: Re: Class variables, module inclusion and instance_eval On Wednesday, August 6, 2003, at 6:41 AM, Tim Bates wrote: > Okay, this works. My immediate question is, why? That's not quite POLS. > I started out using the block form, because the stuff I was doing in it > wasn't dynamic. But as soon as I want to start substituting variables > into it, I'm going to be using the string form - and suddenly the > semantics of my code changes. What gives? Unless I'm mistaken, it's because, when you use the string form, you're delaying interpretation until the call, unlike the other way that interprets during declaration. When you interpret during the declaration of the class, you associate the scope of your variables with that class. This makes sense, more-or-less... variables are scoped where they are found. Evaluated strings don't have this attribute attached to them, it doesn't make sense to give a scope to the variables inside the string, until they're actually executed, then they should be associated where they land. Maybe it's because I've been playing with Ruby a lot lately, and look at the new interpreter's guts a lot of late, but I find that situation to contain a minimal amount of surprise. I expect declared variables to be scoped where they fall. --- Dave Fayram kirindave@lensmen.net dfayra00@umail.ucsb.edu Developer / Idealist ---