* Sam Liddicott wrote, On 20/10/08 07:24:
Yu Feng wrote:Probably because I'm trying to merge continuations, lambdas and closures into one, for use on libraries that support mere callbacks. I may not have made the breadth of my intentions clear, and only by reflecting on your message did it become that clear to me. Based on recent posts, I'm suggesting that the word "continue" be used to let a lambda's execution continue back into the enclosing function. Using examples from recent posts would give based on current syntax: client.post_request("GET ...",
(response) => {
debug("Hurrah!");
continue;
},
(second_callback) => {
debug("boo!");
return;
};
);
// continue carries on here
client.post_request("GET some more",....
or with the new suggested syntax:
client.post_request("GET ..."):
(response) => {
debug("Hurrah!");
continue;
},
(second_callback) => {
debug("boo!");
return;
};
client.post_request("GET some more",....
Combining with a previous suggestion of mine, if the first lambda is
nothing but a continue statement, then the inline psuedo function
definition "continue" can be used to declare the callback.client.post_request("GET ...",
continue(String response),
(second_callback) => {
debug("boo!");
return;
};
);
// continue carries on here
client.post_request("GET some more",....
And possible the String type specifier for the parameter can be missed
out if response is already declared, otherwise it declares a new
variable in the block of the continue target.Or maybe this notation is preferred: (response) => continue and (String response) => continue; // response not already declared Finally, as the function is supposed to return implicitly after the post_request, I would do it like this: return {
if (S_OK != client.post_request("GET ...",
continue(String response),
(second_callback) => {
debug("boo!");
return;
};
)) throw new Error(..);
return;
};
// continue carries on here
client.post_request("GET some more",....
The continuation point always being the end of the { } block that is
part of the return statement, avoiding the need for the ever-unpopular
labels.Sam |