Why Argentum uses “=” to declare and “:=” to assign variables

There are four reasons for having = for variable introduction and := for mutation:

  1. From the math perspective x = x + 1 is just plain wrong, though x := x + 1 is ok.
  2. Mutation is a dangerous operation (a modern days goto), and as such should be minimized. Grammar should make it easier to introduce a new variable rather than to reuse some existing one (usually for slightly skewed purpose).
  3. Marking the mutation points with := makes them more visible. It's a similar concept as in LISP where we use "!" in function names to indicate mutations. For example, Scheme's "set!"
  4. The := syntax is aligned with other mutations +=,... >>=.
a = 42;   // declare `a`
a := 11;  // modify `a` value

Leave a Reply

Your email address will not be published. Required fields are marked *