You are reading a single comment by @Robin and its replies.
Click here to read the full conversation.
-
statements (in level 0) are executed right away
Sun 2018.08.19
@allObjects I would like to learn more about 'level 0' as you indicate in #8 above:
Presumeably there are other levels?
I found an article, but no mention, so must not be clued in on the correct verabage to submit to a Google search.
http://davidshariff.com/blog/what-is-the-execution-context-in-javascript/
Thank you in advance, Robin
@Gordon,
is not good enough on page espruino.com/Saving for people who do not come from a world of Espruino where code is executed on reception, or Browser (editing/modifying the dom while receiving dhtml), or 'writing' Smalltalk (editing the *life image), or Basic, or Python, or any other language when in the interpreter mode / context (not in the OS or command context)... just like the ZX80 / 81, ommodore Pet world, or any os (DOS) after invoking the basic interpreter... which did not have OSes, that was.
Some more has to be explained there: ...uploading code means executing code on Espruino:
function abc(...) {...}
(in level 0) is also something like an immediately executed statement: assigning a function to a (global) variable w/ name as the function name, just like the alternate definition of a function usingvar abc = function() {...};
. (it tells Espruino to create a function with given code and store it in the global variables).Entering the JS expressions in the left side is the same as uploading code on the right side - with one little but very significant difference: before (and while code is about to be sent),
require(...
s are detected and module is sent to Espruino Modules cache, in order to have it ready when encountered (in level 0 code on receiving it by Espruino or 'deferred' when application actually will run).Opposite to the Browser where JS - all JS expressions - between the script tags are received and parsed as block ***before execution *** of the block***, Espruino executes after reception of every complete JS expression that very expression.