
Ruby 2.0 Refinements: Monkey patches done right - DanielRibeiro
http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/
======
petercooper
Or wrong. The current thinking is that they won't go in at all unless some
significant performance issues can be resolved, but separate to that, a _lot_
of people really dislike "refinements". Indeed, I've struggled to find anyone
on IRC to speak in support of it :-)

~~~
DanielRibeiro
Seriously? Open classes have some many problems[1], that making the scoped,
like implicits are in Scala, allow library creators to monkey patch to their
hearts content without messing up with gem creators.

The comments on the thread were quite positive as well (Charles Nutter did
raise some important questions though[2])

[1]
[http://metaphysicaldeveloper.wordpress.com/2010/03/31/improv...](http://metaphysicaldeveloper.wordpress.com/2010/03/31/improving-
ruby/)

[2] [https://groups.google.com/forum/#!msg/ruby-core-
google/8SCc2...](https://groups.google.com/forum/#!msg/ruby-core-
google/8SCc2rHOryg/PKLdBVk3zHwJ)

~~~
petercooper
There's also this recent ruby-core discussion:

[http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-
cor...](http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-
core/39986?39811-40261+split-mode-vertical)

~~~
DanielRibeiro
Great discussion. Thanks for the link. I understand the sentiment of adding
more and a bit complex features.

Of course, Ruby has continuations, which is probably one of the hardest things
to use correctly, and very few people use it.

The problem is that the alternatives, assuming the performance can be solved,
are worse: use class methods all over, wrapper objects for the pimped classes,
or just ignore safety and use Open Classes.

All of which are more complex to gem creators. The more complex and the less
fun we make it for people to create gems, the less gems we will have.

I'll see if I can use ruby macros to implement it on 1.8.7, and make a better
case for it.

