simple modules

Sam Tobin-Hochstadt samth at ccs.neu.edu
Tue Feb 2 13:50:40 PST 2010


On Tue, Feb 2, 2010 at 4:47 PM,  <ihab.awad at gmail.com> wrote:
> On Tue, Feb 2, 2010 at 9:00 PM,  <ihab.awad at gmail.com> wrote:
>> Create a context that allows *only* transitively immutable modules.
>
> And the static rules for making this work could be to *only* allow
> top-level function definitions in the module, and freeze the exports
> before returning them. So:
>
>    /* an ocap module must look like this */
>    export function pointCartesian(x, y) { ... };
>    export function pointPolar(r, t) { ... };
>
> but:
>
>    /* these are statically disallowed in an ocap module */
>    var x = 3;
>    const y = 4; // to be conservative
>    export var z = 5;
>    export const t = 3; // to be conservative

Note that disallowing const bindings is required, not just being
conservative, since const doesn't mean deeply immutable.
-- 
sam th
samth at ccs.neu.edu


More information about the es-discuss mailing list