Why does jsvUnLock() not return the JsVar? #6482
Replies: 1 comment
-
Posted at 2015-11-02 by @gfwilliams Ahh, that's because doing:
Would introduce a bug. When you It's a bit like asking why you can't do:
There are a very few cases where you could do what you suggest, but 90% of the time it'll introduce a bug, which is why it got left off :) Posted at 2015-11-02 by Kolban This is great info ... it is demonstrating that I don't understand JsVars anywhere near as well as I thought I did. What is the algorithm on "UnLock"? Is it a counter? Is it a boolean? If it is a counter, is it considered "freed" if the count reaches zero? A discussion on JsVar usage would make a great session for board contributors. Posted at 2015-11-02 by @gfwilliams Well, there should really be more info in http://www.espruino.com/Internals There are 2 counters:
When you do And yes, when both hit 0 the variable is unallocated and added to the 'free list' of variables. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-10-31 by Kolban
I am wondering if there was a reason that
jsvUnLock()
does not return the JsVar that it is unlocking?If it did, it would seem to offer me a new way of coding. For example, today I have the option of coding:
while if jsvUnLock() returned its passed in JsVar, then I would appear to have the option:
Beta Was this translation helpful? Give feedback.
All reactions