Variable declaration versus assignment syntax
- by rwallace
Working on a statically typed language with type inference and streamlined syntax, and need to make final decision about syntax for variable declaration versus assignment. Specifically I'm trying to choose between:
// Option 1. Create new local variable with :=, assign with =
foo := 1
foo = 2
// Option 2. Create new local variable with =, assign with :=
foo = 1
foo := 2
Creating functions will use = regardless:
// Indentation delimits blocks
square x =
x * x
And assignment to compound objects will do likewise:
sky.color = blue
a[i] = 0
Which of options 1 or 2 would people find most convenient/least surprising/otherwise best?