------art_932_29786049.1321288653687
Content-Type: multipart/alternative; 
	boundary---art_933_4604775.1321288653687"

------art_933_4604775.1321288653687
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On Sunday, November 13, 2011 10:16:37 PM UTC-5, Josh Cheek wrote:
>
> Note I had to explicitly define this in Binding to avoid the private method
> invocation.
>
Sorry, I should have clarified that. Yes, that is the intent.
 

> > Now, it there a way to add a "yield" to the binding? I tried:
> >
> >   def with(_local_variables, &_yields)
> >     eval("lambda{ |#{_local_variables.keys.join(',')},&yields| binding
> > }").call(*_local_variables.values, &_yields)
> >   end
> >
> >     b  inding.with{ |x| x+x}
> >     b.eval('yields[1]')  #2
> >
> >
> Note that this didn't work for me unless I passed a hash to Binding#with,
> because otherwise the syntax it generates looks like `lambda{ |,&yields|
> binding }` which is a syntax error
>
Good point, thanks.



------art_933_4604775.1321288653687
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sunday, November 13, 2011 10:16:37 PM UTC-5, Josh Cheek wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>Note I had to explicitly define this in Binding to avoid the private method<br>invocation.</p></blockquote><div>Sorry, I should have clarified that. Yes, that is the intent.</div><div>&nbsp;<br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>&gt; Now, it there a way to add a "yield" to the binding? I tried:<br>&gt;<br>&gt; &nbsp;ef with(_local_variables, &amp;_yields)<br>&gt; &nbsp; &nbsp; eval("lambda{ |#{_local_variables.keys.join(<wbr>',')},&amp;yields| binding<br>&gt; }").call(*_local_variables.<wbr>values, &amp;_yields)<br>&gt; &nbsp; end<br>&gt;<br>&gt; &nbsp; &nbsp; b = binding.with{ |x| x+x}<br>&gt; &nbsp; &nbsp; b.eval('yields[1]') &nbsp;#=&gt; 2<br>&gt;<br>&gt;<br>Note that this didn't work for me unless I passed a hash to Binding#with,<br>because otherwise the syntax it generates looks like `lambda{ |,&amp;yields|<br>binding }`hich is a syntax error</p></blockquote><div>Good point, thanks.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p></p><p></p><p></p><p></p><p></p></blockquote>
------art_933_4604775.1321288653687--

------art_932_29786049.1321288653687--