amdjs / amdjs-api

Houses the Asynchronous Module Definition API
https://groups.google.com/group/amd-implement
4.31k stars 499 forks source link

Do change the name of the global "require" #11

Closed tlindig closed 11 years ago

tlindig commented 11 years ago

From the API Wiki:

This specification reserves the global variable "require" for use by module loaders.
Module loaders are free to use this global variable as they see fit. They may use the
variable and add any properties or functions to it as desired for module loader
specific functionality. They can also choose not to use "require" as well.

And also in the Module Specification we have a function require. But this both functions with the same name, are very different.

So I would suggest, that you do not take the same name for two different function. That is confusing and provokes misunderstandings.

Maybe you could call the global "require" instead "use" or "load".

jrburke commented 11 years ago

There have been threads about this on the amd-implement list: https://groups.google.com/group/amd-implement

but there are no plans to change this. Feel free to start a thread there again, but with inertia and ECMAScript modules on the horizon, it is more likely that AMD modules will just morph to use ECMAScript-compatible APIs.

unscriptable commented 11 years ago

Hey @tlindig,

I agree that it is confusing for newcomers. Many AMD environments declare -- and sometimes force -- an alternative variable. RequireJS has a requirejs variable, curl.js has a curl variable (and no global require), etc.

Documentation seems to be the key to solving this problem, imho.

-- John