Conversation
|
Oh, wait. That doesn’t work, nor does it make any sense. The "use strict" prevents ‘this’ from returning the global object. But in any case, you don’t even need this, since you are already defining a convnetjs variable. (The combined file begins with ‘var convnetjs’.) So I suspect that line can simply be deleted, but I am not certain. |
sacdallago
left a comment
There was a problem hiding this comment.
I don't see your point @cpansprout . Do you mean to say that in browser you want convnetjs to be a global var (accessed without going through the window var)?
| @@ -1,7 +1,7 @@ | |||
| (function(lib) { | |||
| "use strict"; | |||
| if (typeof module === "undefined" || typeof module.exports === "undefined") { | |||
There was a problem hiding this comment.
This already takes care of seeing if you are in browser env or not. Node env has module/module.exports, otherwise you are loading the lib from browser, thus window will be defined.
|
I am not using a browser. Nor am I using Node. I am embedding a JavaScript interpreter directly in my application. The JS environment contains only objects defined by the ECMAScript specification. This means I get an error when trying to run convnet.js, since it is trying to access nonexistent variables. (I happen to be using Duktape, but I could have used SpiderMokney or JE and the same problem would have occurred.) In a browser environment, BTW, the window is the global object, which happens to have a |
|
Thanks @cpansprout , I understand now. I don't know how to help you out there / how to debug as I've never run JS in such an environment. If you get around solving it, it'd be cool to make to look into the solution |
|
I have solved it locally by simply commenting out the line, which is actually unnecessary, as I don’t know how you update an existing pull request. |
|
@cpansprout you can do that by pulling your fork of the repo and checking out the patch-1 branch (this). Then you modify that, commit, push, and you should see the new commit appear here. |
‘window’ is specific to browser environments. The convnetjs variable has already been made into a global variable at this point, so the assignment is redundant. This allows it to work in non-browser environments other than node.
|
Thank you. That worked. |
‘window’ is specific to browser environments. ‘this’ (the global object is the default ‘this’ value) allows it to work in non-browser environments other than node.