|
|
|
|
|
by emodendroket
1135 days ago
|
|
Right, that’s monkey patching. You run into the real problems when you have multiple people wanting to add them. Ruby isn’t alone in supporting this functionality (you can fiddle with JavaScript prototypes, for instance), but I think it is unique how much it is encouraged (at least in Rails world). I think extension methods are a much better model to achieve something similar. |
|
The "why Scheme didn't do this": First-class environments - http://funcall.blogspot.com/2009/09/first-class-environments...
why Ruby did (and wasn't a good idea): Ruby Conf 2011 Keeping Ruby Reasonable https://youtu.be/vbX5BVCKiNs
Consider where you can slip in a block invocation and the following code:
and that that means that you've got full access to be able to inspect and manipulate all of the variables in scope at the time of the invocation. While that example is rather obvious, it can be done much more subtly too.The power of ruby to do meta programming and by extension some really neat DSLs also provides it with some dangerous tools that are otherwise rather difficult to track down.