es-discuss Digest, Vol 35, Issue 25

Wes Garland wes at page.ca
Mon Jan 18 13:08:46 PST 2010


>
> Precedent and developer conversations I've had strongly suggest that some
> code wants mutable primordials on the inside of a module that can be
> consumed without the mutations affecting the importer's primordials.
>

It would be *really* interesting to have  module-local prototypes -- and not
only the standard classes, but also for user-defined classes which originate
from other modules.

Imagine, if you will, that modules add an extra layer in the scope chain
which somehow intercepts and proxies prototypes, resolving prototype misses
up to the "real" prototype for said class -- analogous to the way property
misses are resolved in JavaScript.

moduleA.js:
Array.prototype.a = "hello";
exports.foo = [];

moduleB.js:
Array.prototype.a = "world";
exports.foo = [];

program.js:
print(require("moduleA").foo.a, require("moduleB").foo.a));
print(require("moduleA").foo instanceof Array, require("moduleB").foo
instanceof Array));
print(typeof Array.prototype.a);

output:
hello world
true true
undefined

Wes

-- 
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100118/cdd81c13/attachment.html>


More information about the es-discuss mailing list