On Fri, Feb 17, 2012 at 8:38 AM, Dean Landolt <[email protected]> wrote:
>
>
> On Fri, Feb 17, 2012 at 11:19 AM, Mark Miller <[email protected]> wrote:
>>
>> [+dherman, +samth, +brendan]
>>
>> cc'ing David and Sam who are the champions of the module proposal. And
>> cc'ing Brendan.
>>
>> I was not aware that "module" was common in Node code, just that it was
>> present. I'm not sure any of us knew that it was common.
>>
>> Regardless, I have repeatedly raised the suggestion that ES6 adopt
>> "package" for the role currently played by "module", since "package" is
>> already reserved in strict mode. However, IIRC not a single other person on
>> the committee voiced any support for this -- for an understandable reason.
>> The term "package" is in use by Java for something different, but similar
>> enough to create confusion.
>>
>> Our latest agreement is that it be a context sensitive keyword, triggered
>> by syntax that today is necessarily rejected. So, technically at least there
>> is no conflict with Node *code*. Whether the co-existence of both uses of
>> this identifier in Node code makes this confusing is another matter. Once
>> ES6 rolls out, is it likely that both uses would co-exist in the same source
>> file? Or would it be more likely that source files using ES6 modules would
>> typically not need Node's existing use of "module" in that same file?
>
>
>
> AFAIK `module` has three uses in node: module.exports for setting the
> exports object; module === require.main for main module testing; and perhaps
> most rarely, module.require for contextual requires.
>
> I'm sure someone will set me strait if I missed any, but I wouldn't say
> module is all that common, and where it is used it's used is idiomatic. I
> don't see how `module` as a contextually reserved would be much of a
> problem.
It's provided to your code as an arg to the wrapper that your module's
code is executed within, viz:
(function (exports, require, module, __filename, __dirname) {
// your module's code here
});
so as far as your code is concerned, it's really a local variable (a
reference to your Module), with the normally associated scope.
I'd agree with the three main uses of 'module' in "normal" Node code.
The first (module.exports) is very widely used. I'd also add a fourth:
module.paths.
--
Martin Cooper
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en