Remarks about module import

Ingvar von Schoultz ingvar-v-s at
Tue Aug 19 01:00:44 PDT 2008

ihab.awad at wrote:
> An importer could use this as follows --
>   var doc = ...;
>   var bg = ...;
>   import
>       of fetchModule(''),
>       with document: doc, background: bg
>       using t: toggle, s: set;

 From the descriptions it looks like this could instead use
a syntax based on destructuring assignment, if es-harmony
will have destructuring:

     var {toggle: t, set: s} = import
     (   fetchModule (''),
         {document: doc, background: bg}

One advantage would be that people would remember this syntax
easily, since it's useful elsewhere.

As a side effect, one could then choose to use the returned
object instead:

     var m = import
     (   fetchModule (''),
         {document: doc, background: bg}

Ingvar von Schoultz

More information about the Es-discuss mailing list