From: Logan Capaldo Date: 2006-06-03T03:39:24+09:00 Subject: Re: Tasks with Parameters: Can it be done? On Jun 1, 2006, at 8:47 PM, transfire@gmail.com wrote: > > Logan Capaldo wrote: >> On May 31, 2006, at 4:03 PM, transfire@gmail.com wrote: >> >> This may be the Lisp I just ate talking but... >> >> task :t1 => [ [:t2, arg1, arg2, argetc], [ :t3 ] ] do >> ... >> end >> >> task :t2 do |a1, a2, *aetc| >> ... >> end >> >> You can even do is_a? Symbol (I know, not ducktype-y enough) and not >> have to use a nested-array for tasks with no args >> e.g. >> >> task :t7 => [ :t1, :t3, [:t4, "one", "two"], :t6 ] do >> ... >> end > > Oh right. A clear solution that didn;t even occur to me (duh). But > that's probably b/c you are right. At that point it gets too Lispy. I > really would like a way to do it in the code of the method somehow > though. As I mentioned, using memoize get very close to such a > solution, but the trick is it has to be a sort of "relative cache" > i.e. > cacheing in a sort of namespace relative to the initiating task. And I > don't know if that's possible. I imagine trying to control it with > something lije this: > > task :t7 do > preq { t1; t2; t4("one", "two"); t6 } > ... > end > > But how would one monitor which methods have been executed? > > T. > > Maybe make tasks objects.... task :t7 do preq t1, t2, t4['one', 'two'], t6 end def preq(*args) args.each do |task| if task.executed? ... else task.call ... end end #[] can set some sort of @args var that gets nil-ed on execution. (Or maybe it returns a new object with references to the task and list of args).