3 ms·
juxtaposition (i.e. syntax that has meaning when two identifiers stand together separated only by whitespace) is generally a problem for parsing. Basically, it
by tomp 5y ago
juxtaposition (i.e. syntax that has meaning when two identifiers stand together separated only by whitespace) is generally a problem for parsing. Basically, it introduces all kinds of parsing ambiguities. Compare the following:
a *b
a * b
a[n] x
b [n]
a<x> y
a < x > y
e(1) f
e (1)f
Even for C/C++ this is complicated (you need the symbol table when parsing, to know if an identifier is a type or not), but for more advanced languages, it's even worse (e.g. if you support pattern matching / destructuring assignment).
Declaring variables with var let's you also write let or const instead, giving the programmer more options (and making those options obvious as well).
You might not "like" type inference, but it really is superior to no-type-inference - you can always also write the expected type, if you want.
- layer8 5y ago> you can always also write the expected type, if you want. But you have to read the code of people who didn‘t.
- scoutt 5y agoExactly. Like when you see: var x = some_function(); What am I dealing with here? mmmmmm.... Ok... let's find some_function()... I hope my editor has "go to definition", otherwise "grep -r some_function ."...