On Thursday, August 7, 2003, at 11:32 PM, Dan Doel wrote: > def foo(cc, a, b) > puts a > cc.call b > end > > puts Continuation.run(method(:foo), 1, 2) > > Which prints > > 1 > 2 Wouldn't it print 1 and return 2? Anyhow, I think that's a worthwhile addition to the class. The only thing that concerns me a bit about that way of doing things is that it's not completely clear that "foo" is a function that has to accept a continuation as its first argument. You really want to not only check to see if the object responds to "call" but to see if it is a subtype of function that accepts a continuation as its first argument. This makes me think of Java threading stuff, where you commonly test to see if something implements the runnable interface. Maybe a better idea might be a class like ContinuationConsumer(?) that stores the continuation as a member variable: class ContinuationConsumer attr_accessor :cc def call(first, second) ... @cc.call( ... ) end end def Continuation.run(*args) callcc do |cc| if block_given? yield cc else func_or_obj, *rest = args if func_or_obj.respond_to? :call if func_or_obj.kind_of? ContinuationConsumer func_or_obj.cc = cc func_or_obj.call(*rest) else func_or_obj.call(cc, *rest) end end end end end I'm too tired to think this through properly right now, so I'm just tossing it out there as is. This isn't the duck-typing-ist way of doing things, so any suggestions to make it cleaner or just overall better would be welcome. > And like you, I'm not sure that I like Continuation.run as a name for > it, although I can't come up with a good name either. I'd say > Continuation.call, but I think that'd be too corn-fusing. Yeah, call is really what I keep wanting to name it, but I can't imagine it not being confusing. Maybe Continuation.use? Ben