Avatar for jtrick

jtrick

Member since Jan 2018 • Last active Jan 2018
  • 1 conversations
  • 2 comments

Most recent activity

    • 5 comments
    • 330 views
  • in JavaScript
    Avatar for jtrick

    You are right: It does compile! Thanks, and now I feel stupid for not verifying this myself first... Much appreciated :-)

  • in JavaScript
    Avatar for jtrick

    Hello,

    First, thank you for your amazing work. I love what you're doing, and the obvious emphasis on quality/elegance in all of the Espruino variants. I participated in the Pico Kickstarter, and have been intending to get more time in on my device ever since. I've gotten hung up several times on a simple issue that keeps stopping me from fully utilizing this awesome tool to its full potential...

    I use a particular shorthand in much of my code, that I'm just accustomed to and makes is quicker for me to write/maintain my apps. It is valid js, and works in every environment I work in -- though it trips up the Espruino compiler. Here's a simple example:

    var  on = false,
        run = 0;
    setInterval(function() {
      on = !on;
      run && LED1.write(on);  // Here is the key item.
    }, 500);
    

    I often rely on terse chains of logic like this to provide functionality for conditional checks. In our IDE, the following error is shown: "Expected an assignment or function call and instead saw an expression". Prepending the line as a return statement, or assigning the left-hand result to some other input resolves the issue, but is would be much preferred to allow this value to be passed to a null handler as it is in most other environments. Is this possible?

    I realize that there may be special considerations for Espruino's unique attributes, that could make this difficult or impossible to implement. It would make a huge difference to me to be able to code in my typical style however. I also know that many would consider this to be a minor point, but this streamlined approach is perfectly valid EcmaScript, and I would like to leverage my existing code that uses this construct.

    Thank you!

Actions