and other languages…. writing programs that write programs (cool!) often used to create...

23
Ruby Metaprogramming and other languages…

Upload: aileen-munday

Post on 14-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

  • Slide 1

and other languages Slide 2 Writing programs that write programs (cool!) Often used to create domain-specific languages (DSL) Youve all heard of at least one DSL written in Ruby. Can you guess what it is? Slide 3 class Module private def readonly(*syms) # do nothing if no args return if syms.size == 0 # code starts as empty string code = "" # generate Ruby code to define # attr reader methods # Notice how the symbol is # interpolated into the code syms.each do |s| code