You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • Thr 2020.03.26

    'So i think i'am not affected by the problem with the left hand side problem. Right?'

    Not true as, @TheAkki, I agree your code file as is, causes ther error(s) you see.

    I stripped out some detail, and found the solution.

    'i'm new at using js and the web ide'

    As you have indicated new to JS and from your coding style, I believe your background is in C/C++ as I adopted the K&R style back in the 80's, and use many of the conventions, such as same column curly braces shown in your code.

    The WebIDE needs a minor change to that thinking in order to enter a line of code, or delimit a code block.

    See: 'When you hit 'enter' after the first line' just after fifth code snippet there
    https://www.espruino.com/Quick+Start+Cod­e

    See: Heading 'Is there a Coding Style I should use' near page end
    https://www.espruino.com/FAQ


    orig

    class Filter
    {
        constructor(size)
        {
          this.size = size;
          this.elements = [];
        }
    }
    

    fix

    class Filter {
        constructor(size) {
          this.size = size;
          this.elements = [];
        }
    }
    


    Do not follow the suggestion 'The easiest way to fix this is to write code in the K&R style:' that was provided in the post #2 link, as it is clearly an error, and even documented as such, when one follows the embedded link to the wiki destination. Anyone that actually read K&R would immediately recognize that statement error.

    correct at wiki article:
    'When following K&R, each function has its opening brace at the next line on the same indentation level as its header'

    (which the code snippet example does not follow)



    I, self taught 'C' reading the original K&R book back in the late seventies, before the schools even taught here locally, and was introduced to the opening curly brace on the same line Java variant in Steve McConnell (2004) Code Complete, and dismissed it as inconvenient. It wasn't until using the WebIDE forces this convention in order to make the distinction between the end/begin of a function and a code line, that using it became necessary. Still prefer K&R style BTW.


    'So i had copy it in an editor notepad++ and saved it.'

    During the copy-n-paste step into notepad++, there is a setting (which I haven't found yet) that auto completes code blocks, based on style. It appears that a new-line was added before each curly brace, thereby violating the WebIDE requirement in order for Espruino to recognize the difference.

    Simple fix, painful as re-editing it will be.

About

Avatar for Robin @Robin started