simple modules

Sam Tobin-Hochstadt samth at
Thu Feb 4 13:25:10 PST 2010

On Wed, Feb 3, 2010 at 2:10 PM, Kevin Curtis <kevinc1846 at> wrote:
> Is there a fundamental theoretical comp sci reason why module state is
> shared? Is the core idea of using lexical scoping in the simple_module
> proposal undermined by not having shared state.
> If not, could possibly non-shared state be the default behaviour. And shared
> state modules - which share state within contexts - are somehow marked as
> shared at module definition. e.g.
> module ModShared {
> "use shared" // or some mechanism to signify shared state

I want to give a little bit different answer to this, while still
agreeing with Brendan and Allen.

Shared state is important because in a language with state, you want
to be able to divide your program up into modules without changing its
behavior.  If you have a stateful piece of code, and you move it into
its own module, that shouldn't change things any more than any other
refactoring.  If you need to repeatedly create fresh state, ES
provides nice mechanisms for that as well.  Similarly, if you have one
module that imports A, and you divide it into two, both of which now
import A, that refactoring shouldn't change how your program works.

So rather than a fundamental CS reason, the decision is based in the
desire to support the way we think people will want to program.
Obviously, we might be wrong about that, but that's how I see it.
sam th
samth at

More information about the es-discuss mailing list