3 ms·
There are also some really weird/powerful/voodoo things that you can do when that is combined with the first class environments. The "why Scheme didn't do this
by shagie 3y ago
There are also some really weird/powerful/voodoo things that you can do when that is combined with the first class environments.
The "why Scheme didn't do this": First-class environments - http://funcall.blogspot.com/2009/09/first-class-environments.html 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 https://youtu.be/vbX5BVCKiNs
Consider where you can slip in a block invocation and the following code:
def mal(&block)
block.call
block.binding.eval('a = 43')
end
a = 42
puts a
mal do
puts 1
end
puts a
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.