Open glhrmfrts opened 8 years ago
0
for a number, ""
for a string, "[]" for a list.if condition { let a = 1} else { let a =2 }; print(a)
.nil
value.Put it together:
if some_condition:
let a = "foo"
else
let a = 42
end
# what's the type of a? If we have a static linter, it's hard to lint the rest of code with operations to a.
So I think people will not write codes like this, declare the type of variable before assign value to it is acceptable in my opinion. And function scope is a bad choice I thought now (I think most static typed languages have block scope as I can remember).
And certainly the variables must be mutable above. Or we should write codes like this:
let a = if some_condition
return "foo"
else
return "bar"
end
This will hard to write code if we have a complex condition and multiple variable to assign, so I agree with you (mutable variable and immutable value like clojure dose).
I understand you now, it wouldn't be possible to analyze the program statically with uninitialized variables without a type or function scope.
So we have:
I think that's pretty good. I will leave this open for now though, we got a lot of work haha.
Hi can you open some issues about what to do, so people can join this repo quickly, thank you 😊
I saw the issues about what to do, some were to generic ...
I've added the most urgent thing right now (#77), when I have some more time I will add the rest.
:+1:
The parser already accepts
let
, so I was thinking something like Rust's:With type inference the type annotation is optional.
Uninitialized variables are also allowed:
However there's some decisions to be made:
if
,for
,while
, etc).I'm looking forward to discuss this so we can continue with Luna's development.