From: Ross Bamford Date: 2006-05-02T09:45:56+09:00 Subject: Re: from block to code (also: how to get the bindings of a block) On Tue, 2006-05-02 at 09:27 +0900, chiaro scuro wrote: > Not sure about the ATs. even if I don't mind them that much... if I unfocus > my eyes they look like bullet points ;-) > > I have got this one working.. see if you can guess how.. > > recipe "eggs and bacon" do > eggs = [2,:big] > bacon = 3 > the end > > I posted my solution here: > http://liquiddevelopment.blogspot.com/2006/04/way-of-meta-part-iv-hijacking-local.html > Without looking, I'd guess def the; binding; end ? (Quick look, done with alias, same difference I guess). It's a clever solution but it'd make the DSL sound a bit whimsical for my taste. Plus, I'd be either forgetting to put 'the' or resenting that I had to... :) Also, I think it might give unexpected results in some situations, e.g: some_other_var = :oops shopping_list "english breakfast" do tomatoes = 2, :green sausages = 3 eggs = 2, :big bacon = 4 the end shopping_list "banana milkshake" do milk = 1 bananas = 2 the end Gives output: to make english breakfast you should buy: * 2 green tomatoes * 3 sausages * oops some_other_var * 4 bacon * 2 big eggs to make banana milkshake you should buy: * 2 bananas * 1 milk * oops some_other_var Granted in a DSL this is less likely to occur, but guaranteed to leave users scratching their heads if (when?) it does. Generally I prefer if I can preserve normal, predictable behaviour for those times when you (or some power user of your system) might need it. -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk