/reasonable_ruby

Code from the "Keeping Ruby Reasonable" RubyConf presentation

Primary LanguageRuby

Reasonable Ruby

Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.

This little repository contains some of the code samples that I used in my presentation at RubyConf 2011 titled "Keeping Ruby Reasonable". You can find the slides for the presentation here, and the video of the presentation is available from Confreaks here.

Contents

Greetings

This is a simple example of the potential danger of Ruby's first-class environments. Since every closure in Ruby captures all elements of its environment, and since the captured environment is live and mutable, it is possible to "rewrite" parts of a program if you have a handle to a closure.

Capture the Flag

This is a simple little game to demonstrate the difference between Proc objects and Method objects in Ruby. Both can be used to extract first-class environments, but only those extracted from Proc objects can be used to modify the defining scope.