On Aug 1, 2006, at 1:38 PM, Leszek Gawron wrote:
Of course if state was declared like this:
var state = {}
so an "ordinary" variable then if the first continuation is reinvoked
the state.step will have the 'Step 2' value.
Quite so... thanks for amplifying my example.
BTW, resource considerations aside, you need "global"
(continuation-independent) state for things like being able to detect
when the user has re-submitted a form (e.g., the "Yes, charge my
credit card now!" form :-)
I know two ways of doing that:
1. simple one: redirect to a new page after the transaction has been
completed. This kills continuations continuity (and sucks) but saves
you from user pressing F5 and accidentaly resubmitting the whole form
(and reinvoking your transaction)
2. token based. Before you enter some form you generate a token that
is invalidated after transaction finishes. If user resubmits the form
- the token is already invalid and instead of rerunning the
transaction the user is informed that no action will take place.
Well of course one other way is to use a regular function-local
variable (although maybe that can be thought of as one way to implement
your Way #2)... that's why I brought up this example in this context,
because here is a place where even if full-closure continuation
semantics were feasible (from a resource perspective), you actually
wouldn't want it. So, createPageLocal() gives you the flexibility to
create the expensive continuation-bound objects when you need them,
which is not most of the time, and in fact there are times when you
need state that is not continuation-bound.
I do agree w/ the OP that the language in the docs is confusing... we
should probably clarify it and add a reference to createPageLocal()...
Cheers,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]