On Mon, Oct 24, 2011 at 10:29 PM, Charles Oliver Nutter <headius / headius.com
> wrote:

> 2011/10/1 SASADA Koichi <ko1 / atdot.net>:
> > - Remove Proc binding
>
> I added this one. Anyone who has ever attempted to optimize Ruby knows
> this is one of the biggest roadblocks. If any time, any local state
> can be seen by code you've passed a block to, you can't optimize any
> of that code in a way that would make it inaccessible.
>

One could also say the same thing with eval'ing strings, but I doubt that
folks have considered removing that.

Does anyone have statistics on how often binding is used and what the costs
is for not optimizing those portions?

Binding in Ruby is used by debuggers or other dynamic introspection tools to
give access to call stack objects. There are dynamic languages such as Perl
and some of the POSIX shells (bash and zsh but not more recent ksh) that
don't have something like binding; therefore debuggers in those languages
can't provide reliable info regarding certain variables on the call stack
other than the top-most frame.

Does it matter? Some probably would argue it doesn't. I think access to
locals on the call stack in a debugger is nice to have.


> I'd also argue it breaks encapsulation in the same awful way that "retry"
> did:
>
> def foo
>  password = get_password
>  transaction do
>    service.auth(password)
>    service.do_something
>  end
> end
>
> ...
>
> def transaction(&block) # my evil patch
>  steal_password eval('password', block)
> end
>
> Any library that can patch "transaction" can see the "password" local.
> Shouldn't local variable encapsulation be sacred?
>
> Get rid of it.
>
> > - Getting parse tree
>
> If something like this goes in, please don't make it like Ripper. You
> guys are killing us with MRI codebase-specific features like that.
> There's no way to support Ripper unless you *actually* use MRI's
> parser, which means we can't support it in JRuby. Please stop killing
> us.
>
> > - Getting source code
>
> This is a far, far better way to allow people access to AST. Give them
> access to the source for a given method or block and provide an
> implementation-independent parsing library. That's the Javascript way,
> and it should be the Ruby way too.
>
> - Charlie
>
>