Re:CommonJS Is The Future For Rails JavaScript Packaging
by snprbob86 on Saturday July 02, 2011 @04:57PM
(#2722423)
With CoffeeScript's destructuring assignment, you can even simulate Python's "from" clause:
foo = require 'foo'
{Bar} = require 'bar'
{X, f} = require 'abc'
Compiles to: var Bar, X, f, foo, _ref;
foo = require('foo');
Bar = require('bar').Bar;
_ref = require('abc'), X = _ref.X, f = _ref.f;
Re:CommonJS Is The Future For Rails JavaScript Packaging
by joeyespo on Saturday July 02, 2011 @01:48PM
(#2722037)
I could be wrong, but I imagine he's referring to the module concept. Not CommonJS itself. (Or perhaps referring to skulpt.org, but I doubt that.)
Re:CommonJS Is The Future For Rails JavaScript Packaging
by maccman on Saturday July 02, 2011 @02:05PM
(#2722089)
Yes, that's correct. Importing is similar to require(), although there's no explicit exporting.
Re:CommonJS Is The Future For Rails JavaScript Packaging
by MBlume on Saturday July 02, 2011 @02:28PM
(#2722130)
setting module-level __all__ can modify what gets pulled in a wild import, but that's about it.
Re:CommonJS Is The Future For Rails JavaScript Packaging
by masklinn on Saturday July 02, 2011 @02:33PM
(#2722142)
It's also used by `help()` (and pydoc): if there's an __all__, help will only pull the docstrings of the stuff in __all__. `dir()`, on the other hand, does not care.
Re:CommonJS Is The Future For Rails JavaScript Packaging
by JonnieCache on Saturday July 02, 2011 @02:02PM
(#2722080)
CommonJS modules are modelled on python's I think.
Huh? Python, really?