To summarize the implementation, IRB.conf[:CONTEXT_MODE] can be set to
one of 4 values: 0,1,2,3 (default is 3). Depending on the value, a
binding is created for use when evaluating a line in irb:
0: eval("proc{binding}.call", TOPLEVEL_BINDING ...)
1: creates a binding to a temporary file
2: thread friendly binding from an irb file
3: eval("def irb_binding; binding; end; irb_binding",
TOPLEVEL_BINDING ...)
Right off the bat, I don't know the use cases for cases 1 and 2. Is a
binding in a temporary file perhaps more secure? As for cases 0 and 3
rue on irc helped me understand the difference between them: case 0
the binding has access to local variables of TOPLEVEL_BINDING while
case 3 doesn't. But when I grep in ruby's source, the only mention of
TOPLEVEL_BINDING is in irb libs and erb.rb. So of what use is case 0
when almost no libraries use TOPLEVEL_BINDING and when the binding
could just very well be TOPLEVEL_BINDING itself?
Thoughts, insights?
Thanks,
Gabriel
I know some of irb's confusing, but is this really that confusing? Any
takers?
Gabriel