Objects of class Binding encapsulate the execution context at some
particular place in the code and retain this context for future use. The
variables, ***methods, value of self, and possibly an iterator block
that can be accessed in this context are all retained***. Binding
objects can be created using Kernel#binding, and **are made available to
the callback of Kernel#set_trace_func**.
can anyone help me to understand the fact by single examples of each the
*** lines above?
Why? To what purpose? What exactly are you doing? What does this apply to? What exactly are you trying to do? Show us the code where this would matter to you.
What *exactly* are you having trouble understanding? In what context did you run across this?
···
Love U Ruby <mailto:lists@ruby-forum.com>
March 26, 2013 2:33 AM
From the link -> Class: Binding (Ruby 2.0.0)
Objects of class Binding encapsulate the execution context at some
particular place in the code and retain this context for future use. The
variables, ***methods, value of self, and possibly an iterator block
that can be accessed in this context are all retained***. Binding
objects can be created using Kernel#binding, and **are made available to
the callback of Kernel#set_trace_func**.
can anyone help me to understand the fact by single examples of each the
*** lines above?
--
D. Deryl Downey
"The bug which you would fright me with I seek" - William Shakespeare - The Winter's Tale, Act III, Scene II - A court of Justice.
Objects of class Binding encapsulate the execution context at some
particular place in the code and retain this context for future use. The
variables, ***methods, value of self, and possibly an iterator block
that can be accessed in this context are all retained***. Binding
objects can be created using Kernel#binding, and **are made available to
the callback of Kernel#set_trace_func**.
Why? To what purpose? What exactly are you doing? What does this apply
to? What exactly are you trying to do? Show us the code where this would
matter to you.
What *exactly* are you having trouble understanding? In what context did
you run across this?
I have tried the below to understand the relationship between `eval` and
`Binding` object,with local variable context.
C:\>irb --simple-prompt
def display
eval("puts str",b)
^C
def display(b)
eval("puts str",b)
end
=> nil
str="hi"
=> "hi"
display(binding)
hi
=> nil
str = "hello"
=> "hello"
display(binding)
hello
=> nil
str = "good"
=> "good"
str="bad"
=> "bad"
display(binding)
bad
=> nil
The above is understood. But didn't make such simple example to
understand for **methods, value of self, and possibly an iterator block
that can be accessed in this context are all retained**. Thus asked you
like experts to give me such snippet to understand those inside the **.
Objects of class Binding encapsulate the execution context at some
particular place in the code and retain this context for future use. The
variables, ***methods, value of self, and possibly an iterator block
that can be accessed in this context are all retained***. Binding
objects can be created using Kernel#binding, and **are made available to
the callback of Kernel#set_trace_func**.
Here's an example of getting the iterator block from the binding, but
there is something puzzling:
Take the time to read through the excellent "Metaprogramming Ruby" by
Paolo Parrotta. Read it a few times. Work the examples, do the
quizzes.
···
On Tue, Mar 26, 2013 at 1:54 AM, Love U Ruby <lists@ruby-forum.com> wrote:
The above is understood. But didn't make such simple example to
understand for **methods, value of self, and possibly an iterator block
that can be accessed in this context are all retained**. Thus asked you
like experts to give me such snippet to understand those inside the **.