Poll: =undefined ?

Posted on
  • Does anyone actually like =undefined? Or should I just not display it if the result of the command you executed is undefined?

    Pros:

    • No special cases - it's obvious what was returned, even if it was nothing :)
    • It's slightly easier to control Espruino remotely, as you know that after executing a command, it'll return =

    Cons:

    • Gets in the way/looks ugly



    Ok, I lied. It's not a poll because I can't do those - but please post up what you think.

  • It's fine, and allows do distinguish between the empty string and undefined. I believe it's in the language, just live with it.

  • I think to someone who has not come from a JS background at first it did catch me off guard as I was thinking hmmm has something gone wrong here. However after reading up a bit on the site and realising why it was happening I'm quite comfortable with the output.

    As you say it can "look messy" but I'm not overly worried about that. I assume this question has come up a few times when doing demos/needed explanation?

  • To be fair, with these changes, empty string would return ="" but undefined would return nothing.

    Would you have a problem if it disappeared? Some people seem to get quite annoyed by it - I wonder if anyone would get annoyed if it wasn't there.

  • Is it a case of the message "undefined" is annoying and they would prefer something like "OK" which most of the AT command driven controllers use?

  • I think they'd prefer:

    >print("Hello")
    Hello
    >1+2
    =3
    

    Rather than:

    >print("Hello")
    Hello
    =undefined
    >1+2
    =3
    

    The issue has come up in a few e-mails I've got. I know, once you get used to it, it is fine. However maybe it's something that you shouldn't have to get used to!

  • Ahhh.. yes remove!

  • Yes, remove.

  • Remove.

  • Although this is standard in JS consoles (ex, in web browsers), I don't see much benefit to it being shown on the Espruino, since you know it did something, since it's showing the > - I think you can go ahead and remove it.

  • Personally I like the fact that it specifically says that the function returned undefined.

    In the print("Hello") example above I would be a bit confused about the "Hello" on the console - was is printed? Returned as a string? Or some object? Especially that this behaviour would be different than Node.js or JS console in the browser.

  • Hmm - it's a very good point about it being like node.js... Any thoughts? Seems a shame to be different.

    Interestingly, node outputs 'undefined' in grey text, so it fades into the background a bit more. I guess we could do that...

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

Poll: =undefined ?

Posted by Avatar for Gordon @Gordon

Actions