From: TRANS Date: 2007-07-13T23:10:45+09:00 Subject: Re: Proposal: runtime-modifying Kernel methods should be keywords On 7/13/07, John Lam wrote: > > 3. These methods are exactly the ones that complicate optimizing Ruby in > > all implementations, including Ruby 1.9, Rubinius, JRuby, Ruby.NET, and > > others. They confound a compiler's efforts to optimize calls by always > > leaving open questions about the behavior of a method. Will it need > > access to a heap-allocated scope? Will it save off a binding or the > > current call frame? No way to know for sure, since they're methods. > > +1 > > We have a design (not implemented yet) to throw on an attempt to alias > Kernel#eval by default. We would enable aliasing eval with a command > line switch along the lines of /MakeItRunSlower :) We have a number of > optimizations for non-local control flow that take advantage of using > static analysis of a block/proc body. These optimizations simply > cannot work in cases where eval appears within the block/proc. If > folks could alias eval then we can't do any of the optimizations at > all, and that is clearly a bad thing. I think 'eval' is a clear choice for keyword. But I'm curious, how does that effect Binding#eval? As for the others, I don't think the criteria makes sense exactly. It's not that one would want to re-implement 'local_variables', for example, but rather just reuse the name for something else. Is that dangerous? Well, that's Ruby. There are lots of meta-methods that one would like to think are always there and always operating as one would expect, but you can't. We've had a number of discussions on ruby-talk about externalizing such calls in order to avoid overrides. Keywords are just another attempt at that. Just a couple of quick points about particular methods: - I hope block_given? ultimately goes away! - I wish public/private/protected could just be a matter of documentation and leave us too, but I realize that's not likely, so personally I'd rather do like Java: private def x() public def x() protected def x() - What about module_function as keyword? (another one I don't like) - You mention 'binding'. However I prefer my alias 'here'. How would I alias a keyword? T.