News for hackers. Stuff that matters.
Re:Kicking the Tires on Ruby 2.1 Preview by ufmace on Thursday September 26, 2013 @12:27PM (#6451819)
My understanding is that refinements are more of a limitation of existing monkeypatching functionality though. Like before, if you needed to monkeypatch something, you had to re-define the method system-wide. This seems like it allows you to have the monkeypatch only apply in the modules that you need it to, and to define it with a special refine keyword that's easy to search for.

Then again, many of the major gems that I've worked with so far define methods in various dynamic ways, making it challenging to figure out what code it's actually running. Hello ActiveRecord?

Re:Kicking the Tires on Ruby 2.1 Preview by ssmoot on Thursday September 26, 2013 @12:51PM (#6451981)
You could always extend the singleton object before to avoid global monkey-patching.

But the real lesson is probably just if you're not writing ActiveSupport, don't do global monkey patches at all. Favor inheritance and composition. Especially in your own libraries where it's easier to ensure a global patch doesn't break your code.

Re:Kicking the Tires on Ruby 2.1 Preview by dragonwriter on Thursday September 26, 2013 @02:02PM (#6452487)
> My understanding is that refinements are more of a limitation of existing monkeypatching functionality though.

They are an alternative rather than a limitation, since you can still do regular monkeypatching, you just now have an option to do things that are less intrusive.

Re:Kicking the Tires on Ruby 2.1 Preview by dewind on Thursday September 26, 2013 @01:49PM (#6452384)
I'll refer to Nutter on this one. Refinements appear to be a method caching nightmare.

http://blog.headius.com/2012/11/refining-ruby.html

Re:Kicking the Tires on Ruby 2.1 Preview by dragonwriter on Thursday September 26, 2013 @02:01PM (#6452476)
Those concerns voiced with 2.0's refinements before release were why they were marked as experimental, and were the driving force behind the changes made to refinements between 2.0 and 2.1.

On the 2.1, non-experimental version, he has said: "What we’re going to have as refinements in 2.1 is a paired down version that I think still provides the bulk of the functionality people wanted out of the feature without most of the pain that I was concerned about originally."

http://rubyrogues.com/124-rr-jruby-with-charlie-nutter/

Re:Kicking the Tires on Ruby 2.1 Preview by shawn42 on Thursday September 26, 2013 @01:56PM (#6452436)
2.1 changes how the method cache works. It is now hierarchical as opposed to the old global cache.