Passing lispy code as data in Ruby
exploration of Ruby's parentage to discover powerful techniques
You have probably heard that Ruby has multiple parentages.
- LISP for it’s syntax tree and functional enumerators
- Smalltalk for it’s object orientation
- Eiffel for it’s blocks
- Perl for it’s regular expressions
Ruby has four parents, and it takes Matz’s favorite aspect of that language and blends them together into a hybrid, multi-paradigm, utility language that would do everything he wanted to do, and to say it with less ceremony.
Now Ruby certainly gets more ideas from each of these parents as listed above, but for a moment let’s focus on the most mind-blowing, language specific aspects of at least 3 of them.
In this chapter we will explore the first if them, LISP
Please note - for the experts in these languages
I am attempting to limit scope to what is important to the subject at hand. I am not an expert at these other languages by ANY means. I am a Rubyist with a bit of exposure to a few of these.
LISP is essentially boiled down into this for the Rubyist: you have lists, which can contain not just data, but code (functions), and to do that, sometimes a function can become a piece of data, be added to a list, queried as code again when the time calls for it. All in a lazy manner. Let me try to illustrate this for you in Ruby.