I think it would be good if the following three declarations were equivalent
let a: Int = 42
a: Int = 42
a := 42
and also the following two were.
let a: Int
a: Int
Then constant declarations become shorter than variable declarations.
It encourages people to use constants in preference to variables.
It also prevents repeating `let` for property declarations and makes
type declarations simpler.
struct Person {
firstName: String
lastName: String
age: Int
}
Omitting `let` is consistent with that we don't write `let` for
arguments of functions and iterated values in for-in loops.
Not `=` but `:=` for type inferences because `=` cannot distinguish
whether it means a constant declaration or an assignment to a variable
declared in an outer scope. I think `:=` is a natural notation for
type inferences because omitting the type from `a: Int = 42` makes
`a:= 42`. Because I have not strictly checked if it can be parsed in
Swift properly, it may have some other parsing issues.
What do you think about it?
-- Yuta
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution