Bug with Espruino IDE

Posted on
  • I noticed a possible bug with the IDE, either that or I really don't understanding what i'm doing wrong.
    If I open up the IDE for the first time (i.e. there is no code saved in the right hand window and the default blink function appears), if I delete the "1" assigned "var 1", then replace it with "1" again. I get an error.
    If I change the "var 1" to "var 2" I also get the same error.
    I uploaded a short screencast of the problem.

    Any idea whats wrong?
    https://www.youtube.com/watch?v=9YX4HVM9u6A

  • A variable can never be a literal number or begin with a digit (or sign or...) or be one of the language reserved words. So it is not an IDE thing, it is a language thing, and the IDE is so helpful to point the coding mistake out. Make it var v1 = false; or var v2 = false; - or even much better - some 'speaking' name, such as: var led1State = false;. Since long names eat up precious space / available RAM - though Pico has (much) more of that than the original board - you may end up (far down the lane) with something along the lines: l1S, but do not do that in the beginning. And there are even tools out there that minify - shrink wrap - the code for runtime: while coding/in source, the code is very human readable, and when uploaded and executed, it is extremely terse (some minifier replace then the variable names with _0, _1, _2,... , _a, _b, ..., _10, _11,... _0a, _0b, etc).

    PS: After reading your post and watching the video a second time closely, I notice, that you did not replace the 1 (one) with a 1 (one), you replaced the letter l (for led) with number 1. . Line 3 and 4 they all use letter l. If you change it there as well to one, IDE will complain there as well. I'm saddened(***) by font selections insensitive to this issue... sorry @Gordon for this rant - and for that one too: even though the forum does a mixed-better job with letter l and digit 1 - l1, l1,

    l1
    

    , it could do a better job with the o letters and 0 (zero) digit: Oo0, Oo0, and

    Oo0
    

    , it could be more pronounced. That's why the

    code format
    

    is there to avoid any ambiguity - more so for o and 0 with the dot in the center, a bit less the l and 1.

    (****) After being wasted over and over by similar font selections in the past, the politically correct I'm saddened feels more like I 'hate' insensitive font selection... nevertheless, for both you need a shrink to fix-ya, but with the latter you are left alone and get no empathy...

    Understanding now the challenge, I suggest that you - @JackJamesHoward - change the conversation title to - for example - Watch out, 1 (number/digit) looks like l (letter), but they are really not the same! - Mr Obvious ;-) - and it will become a great help for many others...


    2 Attachments

    • l1_1.png
    • l1_2.png
  • Thanks @allObjects, and @JackJamesHoward thanks for the video - it would have been way harder to spot otherwise!

    @allObjects if there's another font that could be used for CodeMirror and the terminal then I'm open to changing to it (as long as it's fixed-width!).

    I'll make sure that the next time I update the Web IDE I change the sample code to use on rather than l - I can see it looks quite confusing!

  • When reviewing my last post's code example, I felt a bit uncomfortable withe the choice of 'on' as a variable name. It became such an overloaded (prefix)word, so there may even a better solution.

    Btw, the example was not related to the font thing: I just verified my basic understanding of onInit() - save() code, re-plug power or press reset and see how Espruino 'reboots' and goes into my code - and it was still laying around in my scratch pad... and it became unintentionally the perfect match for situation. So only the last comment line was situation intended... ;)

    Other font for IDE: For sure it has to be fixed font... would have to look how it is pulled, because it should work nicely in available environments: Windows, OSX, Linux (even though OSX is a Unix as well, it goes its own ways).

    Regarding forum's font: I'm aware that the forum (code) was built for a different audience than programmers, and it turned out pretty good also for programmers, especially the letter o and digit 0 (zero) solution in text paragraphs, but not so much for the letter l and the digit 1 (one) in both text paragraphs and in code blocks. It's livable.

    @Gordon, btw, I knew that you could not have made that mistake in the 'get started sample', because I know that code you publish runs... because you ran it more that once... and I - and everyone else - appreciates this fact: it saves everyone aeons (cumulated) of time.

  • looks to me that the variable name was meant to be an 'l' (el) not a 1 (one)

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

Bug with Espruino IDE

Posted by Avatar for JackJamesHoward @JackJamesHoward

Actions