From: "ara.t.howard" Date: 2007-11-10T00:30:25+09:00 Subject: Re: local variables, eval, and parsing On Nov 9, 2007, at 5:55 AM, furtive.clown@gmail.com wrote: > Thanks for the response. Actually I previously abandoned this kind of > setup because it was inconsistent with the rest of my rakefile. I > don't want a clear distinction between config variables and regular > variables --- in fact, the blurrier the better. If I decide to move > one variable into the config section, there should be no associated > code changes. sounds very confusing to maintain to me, but it's your party > > One solution is to put all my variables in that config class, > whereupon I would call it class Stuff. But then the rakefile is > messier and harder to manage: "s.foo ; s.bar ;" instead of "foo ; > bar ;". I can avoid these "s." prefixes by putting everything inside > an instance_eval, but then I am back to exactly the same problem I had > in my second post in this thread. Namely, "foo = 99" creates a local > variable 'foo' instead of calling Stuff#foo=, whereupon I have two > 'foo's and all hell breaks loose. > not so, attributes allows a default block and getter as setter. so you don't need to say s.foo = 99 just foo 99 if you move your code to using attributes it's quite easy to to allow it to be externally configured. your other alternative is using @instance_vars. you cannot set a local variable via eval and ruby provides no #include syntax so simply cannot do what you are trying to do - it's swimming upstream. regards. a @ http://codeforpeople.com/ -- share your knowledge. it's a way to achieve immortality. h.h. the 14th dalai lama