Yeah modules are a must. Right now we need to do the following,

imports.searchPath.unshift(".");

const ModName  = imports.filename


Then all functions, variables etc become available under our constant
*ModName,*which is not what we always want. Many modules might want to
expose just one or 2 objects/methods while keeping everything private. We
can do with closures, but certainly not a clean way.

This also has another problem, since there is no way to know the current
directory in which the file is situated, you really cannot have modules in
a subdirectory.

ES6 modules will solve this problem. But then what will happen to the
current method? It'll suck to use *imports* for the core libraries and
the *import
ModName from filename* syntax for third party libraries.


Satyajit Sahoo
UX Designer
Behance Profile <https://www.behance.net/satyajitha28c7>

We're all stories, in the end. Just make it a good one, eh? — The Doctor,
Season 5, Episode 13.

On 20 May 2015 at 19:39, Matěj Cepl <mc...@cepl.eu> wrote:

> On 2015-03-07, 19:54 GMT, Emmanuele Bassi wrote:
> >> it would be nice that developer documentation of gjs would be extended,
> >> also with examples of how to write a module in a *modern* and *easy*
> >> way...
> >
> > What do you mean "write a module in a modern and easy way"?
> > What kind of module?
> >
> > Not saying that the documentation is good — because it isn't — but it
> > would help to specify what you want to achieve, and what were the
> > obstacles you met. I'm sure we can make the documentation at least
> > passable, if not good.
>
> Perhaps he is talking about ES6? I believe when it will be in
> the Spidermonkey (or whatever monkey is now running underneath
> GJS) we will have modules, classes, etc. as well. See
> https://hacks.mozilla.org/category/es6-in-depth/ and
> https://bugzilla.mozilla.org/show_bug.cgi?id=694100
>
> I cannot get it soon enough, for example.
>
> Best,
>
> Matěj
> --
> http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
> GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
>
> Extremism in the defense of liberty is no vice; moderation in
> the pursuit of justice is no virtue.
>     -- Barry Goldwater (actually written by Karl Hess)
>
> _______________________________________________
> javascript-list mailing list
> javascript-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/javascript-list
>
_______________________________________________
javascript-list mailing list
javascript-list@gnome.org
https://mail.gnome.org/mailman/listinfo/javascript-list

Reply via email to