Lexical Modules Can't Wait

Kevin Smith zenparsing at gmail.com
Mon Apr 15 06:41:26 PDT 2013


I think we can all agree that, in principle, program structures which have
scope and define a namespace should be lexically identified and should
nest, unless there is some compelling reason otherwise.

A module, for any sane definition of the term in the context of Javascript,
has a scope and defines a namespace.  Therefore, unless we can provide some
overwhelming argument to the contrary, established design principles tell
us that modules should be lexically identified and should nest.

It has been suggested that we can postpone adding lexical modules until
ES7.  But to do so would be to postpone conceptual integrity, which is not
an available option.

By postponing at-names, for example, we only postpone the usability of
symbols-as-property-names.  But by postponing lexical modules, we postpone
the clarity of our design.  Indeed, there is nothing in ES6 which requires
more conceptual clarity than modules.  Modules should be the mountain
stream of ES6, because with modules we go from a splat of script tags, to a
universe of connected systems.

Finally, there are actual use cases which require lexical modules.  Let's
say that I want to develop a library where each module lives in its own
source file.  And let's say that I only want to expose a "main" module, and
hide the rest.  Without lexical modules, there is no straightforward build
process capable of encapsulating those internal modules.

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130415/6e869cb1/attachment.html>


More information about the es-discuss mailing list