> Ok thanks. I assume your longer description notes what the state
> would be as seen from two independent usages of module Counter?
I may not have made this clear enough in the strawman. A module is evaluated
only once, so two independent usages will share state.
Now, this is "per context" -- the idea of our
not-yet-written-nor-even-fully-conceived strawman on isolation would be that
you could create a new Context in which modules could be independently
instantiated. But within a given context, modules are never instantiated more
than once.
> Also: Under your proposal, is it possible for the initial value of
> "counter" to be supplied by the client of the module?
Not directly; modules are not parameterized. If you want parameterization or
multiple independent stateful values, you just use functions, objects and
lexical scope, as usual:
module Counter {
export function makeCounter(initial) {
var state = initial;
return {
current: function() { return state },
inc: function() { return state++ }
};
};
}
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss