• @Gordon,

    Saving code on Espruino
    When you upload code to Espruino normally, it is stored in Espruino's RAM. If you reset the board or power is lost, all your code will be lost.

    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:

    • statements (in level 0) are executed right away
    • function as specified 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 using var abc = function() {...};. (it tells Espruino to create a function with given code and store it in the global variables).
    • timeouts / intervals (set in level 0) will fire when time is up and upload has not completed yet...

    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.

About

Avatar for Robin @Robin started