I agree with your point in general, and I'm curious if it's a problem in Lobster. Here's one in Rust:
let i = 1;
let j = 1;
print!("i: {:?}\n", !i);
print!("j: {:?}\n", !j);
// pretend there's a lot of code here
// spooky action at a distance
let v = vec![1, 2, 3];
v[i];
You might think those two print statements would print the same value. They do not.
In Lobster you must initialize a variable declaration. Now you can produce your bad case with `var x = nil`, but that is undesirable because nil types must be explicitly checked at compile time, so typically you want to use as few nils as possible. More likely thus is `var x = ""` if you must initialize later.
For case like this, I'd say your text editor should definitely just be able to tell you right away that this variable is a "string" when you mouse over it.
harikb|6 months ago
imho, I don't consider Type-inference as a good thing when it happens from 50 lines ahead/below. How would regular people follow along?
Good case
x = "hello" // infer type as string - good thing.
Bad case
var/declare x;
50 lines later
if (....)
xscott|6 months ago
Aardappel|6 months ago
alain_gilbert|6 months ago