And other languages…. Writing programs that write programs (cool!) Often used to create...

23
Ruby Metaprogramming and other languages…

Transcript of And other languages…. Writing programs that write programs (cool!) Often used to create...

  • 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