Module isolation

Mark S. Miller erights at google.com
Mon Jan 18 11:58:01 PST 2010


On Mon, Jan 18, 2010 at 10:25 AM, Brendan Eich <brendan at mozilla.com> wrote:

> On Jan 18, 2010, at 10:20 AM, Mark S. Miller wrote:
>
> I simply don't understand what you mean by the phrase "migrate into a
> module". What does this mean?
>
>
> Use on the inside of a module. I have code I want to put in a module. It
> uses Prototype. That's all.
>
> How would you express "putting code in a module"? I just don't have a
concrete idea what you mean. Could you show a program fragment?



> Why is this hard to understand? Are you assuming modules are small,
>

Or at least, that module boundaries coincide with boundaries between
separately written source files, as is the case with module systems I'm
familiar with from other languages. For example, Java classes-as-modules.



> and/or consisting of new code only?
>
> Or at least a new revision of old code, in order to repackage the code to
do module-based import/export linkage, rather than the current practice of
implicit linkage through shared global variables.

Since I do not yet understand what you are trying to say, I may be the wrong
person to guess why I'm finding it hard to understand ;). Altogether, my
best guess right now is that what you are calling a module is what I would
call a sandbox.


> /be
>
>
> On Mon, Jan 18, 2010 at 10:13 AM, Brendan Eich <brendan at mozilla.com>wrote:
>
>> On Jan 18, 2010, at 9:57 AM, Mark S. Miller wrote:
>>
>>  No, I wrote "migrate into a module" meaning be part of the inside of a
>>> module -- not be packaged as a module.
>>>
>>> I don't get it. What do you have in mind?
>>>
>>
>> What's not to get? If you use Prototype inside a module, it will mutate
>> "the primordials" -- whatever ones it finds on the global at the end of its
>> scope chain. If those primordials are frozen, game over.
>>
>> Tons of JS on the web mutates primordials, e.g.:
>>
>> http://www.google.com/codesearch?as_q=Array.prototype
>> .\w%2B+%3D+&btnG=Search+Code&hl=en&as_lang=javascript&as_license_restrict=i&as_license=&as_package=&as_filename=&as_case=
>>
>> http://www.google.com/codesearch?hl=en&lr=&q=%22extend%28Array.prototype%22&sbtn=Search
>>
>> For any such code to move into a module, that code wants mutable
>> primordials. For isolation these would be per-module, and to avoid problems
>> exporting functions, some kind of membrane to support virtualized mutation
>> or throw on mutation attempt would be required around any exposed objects
>> that lead back to in-module prototypes.
>>
>> Or we could say "rewrite all your code" or "forget it". But that is not a
>> given.
>>
>> /be
>>
>>
>
>
> --
>    Cheers,
>    --MarkM
>
>
>


-- 
   Cheers,
   --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100118/5ddcd5fd/attachment-0001.html>


More information about the es-discuss mailing list