On Mon, May 17, 2010 at 6:02 AM, David Herman <dher...@mozilla.com> wrote:
> This was the point I was explaining here:
>
>    https://mail.mozilla.org/pipermail/es-discuss/2010-May/011162.html
>
> Modules are static entities, whose structure is known at compile-time. The 
> "module" form creates these static bindings. But they can be reflected as 
> first-class values. (Similar to e.g. classes in Java and proposed ES4.)
>
> The "import" form, like "var" and "const" and "function" creates a binding to 
> a first-class value, whereas the "module" form creates a static module 
> binding.
>
> So when you write:
>
>    var x = Math;
>
> you create a variable binding to the reflected first-class module value. 
> Whereas when you write:
>
>    module x = Math;
>
> you are creating a static module binding x which is bound to the static 
> module bound to Math.
>


OK. On the simple_modules_examples wiki page:

Reflecting module instances as first-class objects

<script type="harmony">
// a static module reference
module M = Math;

// reify M as an immutable "module instance object"
alert("2π = " + M.sum(M.pi, M.pi));
</script>

Q: Why does referencing the module M's functions/constants - M.sum and
M.pi - 'reify' M as an object.(Is this the same process as generating
a 'reflected first-class module value'?)

I get the difference between lexical/source vs first class - but this
comment 'reify' genuinely confuses me. Why isn't the call to M.sum()
static - known at compile time.

--
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to