Re:Show HN: NodeScript- JavaScript Without the Variable Decl...
by pretodor on Monday February 20, 2017 @11:29AM
(#13688550)
Regarding the semicolons, due to the insertion mechanism JavaScript uses, lines starting with '[', '(', or '`' will get merged with the previous statement. So the example in the repo will get parsed in JavaScript as:
x = 10;
y = 20[x, y] = [y, x];
Your assumption is correct. NodeScript defaults to let-declarations. This leaves you with a block-scoped language and prevents leakage of global variables. If you want to make a global variable, you will have to explicitly write it as a property of the global object.Thanks for the kind words. I really appreciate it.
Re:Show HN: NodeScript- JavaScript Without the Variable Decl...
by sucrose on Monday February 20, 2017 @12:33PM
(#13689132)
Regarding semicolons, here's an interesting previous discussion: https://news.ycombinator.com/item?id=3842713
Re:Show HN: NodeScript- JavaScript Without the Variable Decl...
by krapp on Tuesday February 21, 2017 @07:07PM
(#13701543)
> Sounds like it would lead to subtle bugs but I guess it works ok.
It does lead to subtle bugs. The same kind of people who leave semicolons out of javascript write C but leave out the braces in statements wherever it's allowed - which also leads to subtle bugs.
I guess looking pretty and saving a couple of keystrokes is preferable to being explicit and not having to just trust that the compiler/browser/whatever is able to intuit what you want the code to be as opposed to what you wrote.
Re:Show HN: NodeScript- JavaScript Without the Variable Decl...
by pretodor on Wednesday February 22, 2017 @07:35AM
(#13704994)
> It does lead to subtle bugs.
Have you encountered any bugs so far while testing NodeScript out? I thought I have taken care of all the gotchas when it comes to semicolons.
Anyway, nice work in general! Assuming this only works with 'let' to avoid the weirdness around 'var' scoping?