P
Patrik Sundberg
Hi,
I'm interested in figuring out a way to get a separate scope. I do not
need any other traditional sandbox features, i.e. any code goes, I
just want code evaluated in the scope to no affect the parent scope
(at all). Example illustrating what I am after:
a = 10
SeparatedScope.new do
a = a + 1
p a
end
p a
yielding:
11
10
I'd like it to have the same initialization/separation also for
instance variables and even global variables if possible.
Is something like that already available? If not, any good ideas for
how to implement it?
I did have a quick look at sandbox by _why, seems may do what I want
but not so keen on the interpreter patching etc so looking for
opportunities.
Regards,
Patrik
I'm interested in figuring out a way to get a separate scope. I do not
need any other traditional sandbox features, i.e. any code goes, I
just want code evaluated in the scope to no affect the parent scope
(at all). Example illustrating what I am after:
a = 10
SeparatedScope.new do
a = a + 1
p a
end
p a
yielding:
11
10
I'd like it to have the same initialization/separation also for
instance variables and even global variables if possible.
Is something like that already available? If not, any good ideas for
how to implement it?
I did have a quick look at sandbox by _why, seems may do what I want
but not so keen on the interpreter patching etc so looking for
opportunities.
Regards,
Patrik