JS function library

12 views
Skip to first unread message

wayne

unread,
Jan 20, 2011, 2:43:58 PM1/20/11
to GLUEscript
Is there any way to include a library of frequently used JS functions
other than using require()? (similar to "src=" in client side
programming)
wayne

Franky Braem

unread,
Jan 20, 2011, 2:55:16 PM1/20/11
to glues...@googlegroups.com
You can use the include() method. See the sample include.js for some
examples.

Franky

Op 20/01/2011 20:43, wayne schreef:

wayne

unread,
Jan 24, 2011, 2:49:26 PM1/24/11
to GLUEscript
Where does the include() function come from? (is it from gluescript or
spidermonkey?) I can't find any documentation on it.
Wayne

Franky Braem

unread,
Jan 25, 2011, 2:46:55 PM1/25/11
to glues...@googlegroups.com
include is part of the core glue which is always loaded when calling
GLUEscript. It's not part of SpiderMonkey. It seems that the
documentation is missing for these functions in the generated docs. I
will correct this in the next version.

Franky

Op 24/01/2011 20:49, wayne schreef:

wayne

unread,
Jan 25, 2011, 5:29:04 PM1/25/11
to GLUEscript
I'm probably missing something but from what I can see of the include
function in the example, this isn't the way most languages handle this
sort of thing. It looks a bit cumbersome to have to refer to your
custom function as a property of another another object.
eg
var script = include("print.js");
script.test(); ( instead of just being able to call test() )

Franky Braem

unread,
Jan 26, 2011, 1:05:06 PM1/26/11
to glues...@googlegroups.com
The problem when no object is used is that the global object will be
polluted with all defined variables and methods. That will cause errors
when two or more scripts are included and are using the same name of
variables or methods.

Franky.

Op 25/01/2011 23:29, wayne schreef:

wayne

unread,
Jan 26, 2011, 5:13:38 PM1/26/11
to GLUEscript
Ok I can see the value of that
Reply all
Reply to author
Forward
0 new messages