opal/opal — pull request #515 by mieko (2014-03-21 15:32:01+00:00)
Title: Allow arguments to String#to_proc result

Among other things, this allows binary operators to work:

```ruby
(:+).to_proc.call(1, 2) # => 3
```

This is most commonly encountered as a result of:

```ruby
[1, 2, 3].reduce(&:+) # => 6
```

(Note the ampersand: not using `inject`'s special-case Symbol handling.)

I originally implemented this by extending the JS escape:

```ruby
def to_proc
%x{
return function(recv) {
var meth = recv['$' + self];
var rest = $slice.call(arguments, 1);
return meth ? meth.apply(recv, rest)
: recv.$method_missing.apply(recv, [self].concat(rest));
};
}
end
```

Then I noticed the compiler does a damn-reasonable job at this, and it doesn't require scattering another `send` and `method_missing` dispatch around.