Steven Arnold wrote: > Hi, > > I have just recently learned Ruby and I really enjoy it. One thing I > have not found that would be nice is a facility for easily developing > little languages based on Ruby, sometimes referred to as a macro facility. > > I say "based on Ruby" because I would like to be able to specify that a > certain block is to be interpreted as standard Ruby. For example, it > might be nice if I could do something like: > > defworkflow MyAction > conditions > <std-ruby-expr> > end > action > <std-ruby-expr> > end > cleanup > <std-ruby-expr> > end > end You can do something like this in ruby quite easily: class WorkFlowSpec attr_reader :name def initialize name @name = name end def conditions(&block) block ? @conditions = block : @conditions end def action(&block) block ? @action = block : @action end def cleanup(&block) block ? @cleanup = block : @cleanup end end def defworkflow(name, &block) wf = WorkFlowSpec.new(name) wf.instance_eval(&block) wf end wf = defworkflow "MyAction" do conditions do puts "conditions" end action do puts "action" end cleanup do puts "cleanup" end end p wf.name # ==> "MyAction" wf.conditions.call # ==> conditions -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407