Colon-Equals

Sometimes I think it's sad that the most popular programming languages use "=" for assignment rather than ":=" (like Pascal). Equality is a symmetrical relationship: "a equals b" means that a and b are the same thing or have the same value, and this is clearly the same as saying that "b equals a". Assignment isn't like that: putting the value b in a box named a isn't the same as putting the value a in a box named b!—surely an asymmetrical operation deserves an asymmetrical notation? Okay, so it is an extra character, but any decent editor can be configured to save you the keystroke.

I'd like to see the colon-equals assignment symbol more often in math, too. For example, shouldn't we be writing lower indices of summation like this?—

\sum_{j:=0}^n f(j)

—the rationale being that the text under the sigma isn't asserting that j equals zero, but rather that j is assigned zero as the initial index value of what is, in fact, a for loop:

sum = 0;
for (int j=0; j<=n; j++)
{
    sum += f(j);
}
return sum;

2 thoughts on “Colon-Equals

  1. The first point is good. I had always thought the colon-equals (used sparingly) was an excellent borrowing of notation from programming -- only to start learning programming and find no colon-equals in sight!

    OTOH, I'm not sure I can go along with using the colon-equals for variables of summation and the like. First of all, I think I'm pretty conservative about mathematical notation generally; I mostly prefer as few symbols/characters as possible, and especially like to keep imports of notation from other disciplines to a minimum. But more importantly, the use you propose is actually somewhat antithetical to the way the colon-equals is used in math. In math, the colon-equals is meant for definitions, and is thus inherently global in nature; if you write "j := 0", you are making the statement that henceforth, "for all time", the symbol "j" will be synonymous with the symbol "0". (Cf "f'(x) := lim_{h -> 0}...[etc]".) Whereas the "equality" of a variable of summation with its starting value (e.g. 0) is about the most local, temporary, contingent kind of equality there is.

    Of course, this is just one of many instances in mathematics where a statement about "equality" should be replaced with something more specific, like set membership. What we really mean is "for j in {0,1,...,n}".

  2. I guess that while writing the post, I was focusing on the distinction between "stating that two things are equal" and "naming something (whether or not you end up reassigning that name to something else in a moment)", but now that you mention it, that might not be quite the correct conceptual distinction to be paying attention to.

    Maybe I've been corrupted by Python, which lacks named constants; the idea of regarding a definition as a variable that you happen to never change doesn't seem to horrify me. (Contrast to the attitude of functional programming advocates: "If you say that a is 5, you can't say it's something else later because you just said it was 5. What are you, some kind of liar?")

Leave a Reply

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