Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
what's the purpose of IRB.conf[:CONTEXT_MODE] and/or TOPLEVEL_BINDING?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ghorner  
View profile  
 More options May 21 2009, 2:43 am
Newsgroups: comp.lang.ruby
From: ghorner <gabriel.hor...@gmail.com>
Date: Wed, 20 May 2009 23:43:55 -0700 (PDT)
Local: Thurs, May 21 2009 2:43 am
Subject: what's the purpose of IRB.conf[:CONTEXT_MODE] and/or TOPLEVEL_BINDING?
Hi all,
  I'm peering into irb's internals and am wondering what's the purpose
of IRB.conf[:CONTEXT_MODE]? I understand most of the ruby code but all
my googling has yet to bring up _anyone_ who uses this. Here is a link
to the beginning of it's implementation in irb:
http://github.com/akitaonrails/ruby191-stable-mirror/blob/c1a8d6cd2bd...

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cldwalker  
View profile  
 More options May 22 2009, 2:17 pm
Newsgroups: comp.lang.ruby
From: cldwalker <gabriel.hor...@gmail.com>
Date: Fri, 22 May 2009 11:17:23 -0700 (PDT)
Local: Fri, May 22 2009 2:17 pm
Subject: Re: what's the purpose of IRB.conf[:CONTEXT_MODE] and/or TOPLEVEL_BINDING?
On May 21, 2:43 am, ghorner <gabriel.hor...@gmail.com> wrote:

I know some of irb's confusing, but is this really that confusing? Any
takers?
Gabriel

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »