• Mon 2018.10.01

    Just attempted "compiled"; just after the function name line inside a class, as in the example.

    https://www.espruino.com/Compilation

    How do I use it?
    Simply get your function working as you want it to,
    and then add the string "compiled"; to the very front of it:

    foo(a,b) {
      "compiled";
    
    }
    

    But am faced with:

    1v99 (c) 2018 G.Williams
    >WARNING: Function marked with "compiled" uploaded in source form
    ---------------------------------------------------
                                     COMPILER MESSAGE
    ---------------------------------------------------
    Error: NewExpression is not implemented yet
    ---------------------------------------------------
    =undefined
    >
    


    Is this supported for class functions?

    1v99 on an authentic Pico



    EDIT Tue 2018.10.02

    After many divide and conquer attempts;

    "NewExpression" seems to refer to:

    var ary = new Uint8ClampedArray(16);

    and not "compiled"; despite the function actually working as expected.

  • Works as designed and implemented... AND as documented on page https://www.espruino.com/Compilation :

    JavaScript Compilation

    • ...
    • What works and what doesn't?
      • Works
        • ...
      • Doesn't Work
        • Creating objects with new
        • ...

    New is not implemented for various reasons...

  • Wed 2018.10.03

    Too many Windows containing reference documentation open and observed the contents under the wrong Caveats heading.

    Good catch @allObjects

  • I should add that the process of creating typed arrays can be quite slow (as Espruino has to search for a contiguous area of free memory) so if you want to get the best performance out of compiled code you're best off allocating them once, when the device initialises.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

"compiled"; Error: NewExpression is not implemented yet

Posted by Avatar for Robin @Robin

Actions