New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference a define within a define? #122

Closed
hisham opened this Issue Jun 23, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@hisham

hisham commented Jun 23, 2014

Can I do something like below. In this example, when I run the javascript, I get the following error when I try to do 'myLine.addPoint(5,5)':

     ReferenceError: Point is not defined
      at new constructor (eval at <anonymous> (node_modules/nools/lib/compile/common.js:33:72), <anonymous>:2:138)

javascript

var Line = flow.getDefined("Line")
var myLine = new Line();
myLine.addPoint(5,5);

define.nools

define Point {
  x: 0,
  y: 0,
  constructor: function(x, y) {
     this.x = x;
     this.y = y;
  }
}

define Line {
  points: null,
  constructor : function() {
      this.points = [];
  }
  addPoint: function(x, y) {
      this.points.push(new Point(x,y));
  }
}

@doug-martin doug-martin self-assigned this Jun 23, 2014

@doug-martin

This comment has been minimized.

Contributor

doug-martin commented Jun 23, 2014

Thats odd....it looks like Point may not be in scope for classes defined within a nools file, Ill investigate a little further.

doug-martin added a commit to doug-martin/nools that referenced this issue Feb 25, 2015

v0.4.0
* Fix for issue noolsjs#122 referencing defined class within another defined class
   * Also fixes accessing scoped functions within a defined class.
* Fix for issue noolsjs#119 window was removed from the nools.js file now it is called in the current scope of `this`.
* Allow session.halt even for `match()` noolsjs#143 - @raymondfeng
   * Now if you call `halt()` even if you did not call `matchUntilHalt()`
* Now you can use a function as a constraint (Only applies to rules defined programatically) noolsjs#142 - @raymondfeng
* You can now define types using scope [noolsjs#142](noolsjs#142) - @raymondfeng
* Fix for issue, is the dsl you do not have to escape `\` characters noolsjs#123

@doug-martin doug-martin referenced this issue Feb 25, 2015

Merged

v0.4.0 #144

doug-martin added a commit to doug-martin/nools that referenced this issue Feb 25, 2015

v0.4.0
* Fix for issue noolsjs#122 referencing defined class within another defined class
   * Also fixes accessing scoped functions within a defined class.
* Fix for issue noolsjs#119 window was removed from the nools.js file now it is called in the current scope of `this`.
* Allow session.halt even for `match()` noolsjs#143 - @raymondfeng
   * Now if you call `halt()` even if you did not call `matchUntilHalt()`
* Now you can use a function as a constraint (Only applies to rules defined programatically) noolsjs#142 - @raymondfeng
* You can now define types using scope [noolsjs#142](noolsjs#142) - @raymondfeng
* Fix for issue, is the dsl you do not have to escape `\` characters noolsjs#123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment