handling of this strange(?) #187
Replies: 7 comments
-
Posted at 2013-12-29 by graf That's some dodgy code to me. Did you try to run it somewhere else? I did in my browser and I think it's not working like you would expect it. Unless its only purpose is to fail :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-29 by graf Ah so I've just noticed that you are saying that it is NOT failing. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-29 by JumJum I've had the problem in a big function and reduced to show the problem.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-29 by @gfwilliams When I run your code I get:
and if I type
So what's happening is that the setInterval is being run in the root scope (as 'this' isn't set for intervals iirc). That means that 'a' refers to a in the root scope, and 'this'==root, so In Espruino There may be something strange with the handling of scopes for intervals I guess. If you can come up with a simple test that works in jsconsole/jsfiddle but that doesn't work in Espruino then I'll try and track it down though. By the way, even if you delete the offending line |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-29 by @gfwilliams Just to add, if you do:
and compare, it looks like bugs: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-29 by JumJum Thanks for the explanation. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-06 by @gfwilliams I'd prefer just to add the error I think - something like "use strict" will just be more complication in the interpreter, and I doubt it will be used by too many people. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-28 by JumJum
trying this, I would expect an errormessage for incrementing a.
In Espruino, a is incremented twice, and in log there is 1 3 5 ....21 23
But by typing console.log(b.a) thje answer is 0, always.
I'm confused, so is the problem on my side or is it Espruino ?
Beta Was this translation helpful? Give feedback.
All reactions