« More on the "handle ... with ..." construct | Main | Links on MacOS X »

Representable Continuations

(Remind me to explain this more clearly at some point). Why representable continuations are important for Links:
fun do_something()
{
  creds = validate_user();     # if the user isn't signed in, throw a login page, continue from here when finished
                                              # if user never validates, this never returns
  if (user_can_do_something(creds) then
    do_it()
  else display_error()
}

fun validate_user()
{
    user_cookie = get_cookie('user')
    (username, password) = regex.match("(.*):(.*)", user_cookie);
    if not valid_creds(username, password) then
        login_screen(handler) 
    else
        (username, password)
}

fun login_screen(handler) {
    throw_page(...)
}
This can't be done if the l:action must always be a complete expression. "validate_user" needs to be like a subroutine that can be invoked from anywhere, even though it has its own handler (its own l:action). That means the serialized form action must include the complete continuation, not just an expression.

Post a comment