in reply to lazy evaluation of sub arg

I don't have time at the moment to check this out thoroughly, but I suspect the problem may lie with the order of declaration/definition and invocation of a prototyped function.

A prototyped function such as promise() is properly invoked only after the function is either declared or defined. In the code shown in your post, I see promise() invoked before the function is defined, and there is no prototype declaration for the function shown at all. This may just be an artifact of composing the post (an entirely self-contained executable example is always preferable), but it is something to consider.

Update: I posted this before I saw drbean's first reply. I think he or she is on the right track now.