On May 10, 4:50 pm, Phrogz <g... / refinery.com> wrote:
> Using instance eval makes some DSLs (domain specific languages) easier
> to create, rather than having to use the object yielded to the block
> in every call.

Here's a real-world example of a DSL I created at work:

bp( 9 ){
  lopa( '02' ){
    sb "New Project Workflow.ppt"
      cr 1331

    sb "Add to Online Repository.ppt"
      crs 2216, 3560
      keywords "Workspace", "Phase 2"
  }
}

For both blocks, the function creates an instance of a particular
class and then uses instance_eval to ensure that the methods
referenced within that block are called on the appropriate object. If
I had not mucked about with the self inside the blocks, I would have
had to write something like:

bp( 9 ){ |blockpoint|
  blockpoint.lopa( '02' ){ |section|
    section.sb "New Project Workflow.ppt"
      section.cr 1331

    section.sb "Add to Online Repository.ppt"
      section.crs 2216, 3560
      section.keywords "Workspace", "Phase 2"
  }
}