# Paste: assignment syntax

Author: | kssreeram |

Mode: | text |

Date: | Tue, 19 Oct 2010 06:17:40 |

Plain Text |

Paul:
Have you considered using "=" for equality and ":=" for assignment?
Me:
I have thought about it, along with using <> for inequality. But,
I don't have a strong preference for one over the other. Do let me
know if you strongly prefer the syntax you suggested. A strong
preference from you will definitely count.
Paul:
I strongly prefer using "=" for equality -- this is such a
fundamental mathematical notation and it would be nice to bring it
over to programming. I don't feel strongly about inequality, but using
<> would be consistent with Pascal, which seems to be an inspiration
for other Clay syntax. By the way, I like your use of colon in
TypeSpecs -- again, it's closer to mathematical usage (and Pascal).
Me:
Regarding the operators for assignment and equality:
The compound assignment operators such as "+=", "-=", etc. are quite
useful. If ":=" were used as the assignment operator, then the usual
compound assignment operators don't match because they don't have a
colon character in them.
We could update them to include the colon too, but they all have shortcomings:
Both "a -:= b" and "a :-= b" look visually unpleasant. The third
option "a :=- b" looks much better, but the syntax conflicts with the
unary negation operator.
Do you have any solutions to this problem?
Paul:
ALGOL 68 has compound assignment operators, and may well have
been Dennis Richie's inspiration for C. It uses := for assignment, and
+:=, -:=, *:=, /:=, %:= and %*:= . In ALGOL 68, / is real division, %
is integer division, and mod or %* is the modulus operation. (Here's a
tutorial: http://www.xs4all.nl/~jmvdveer/a68g-doc.pdf; here's the
final revised reference manual:
http://www.softwarepreservation.org/projects/ALGOL/report/Algol68_revised_report-AB.pdf
.)
So if Clay followed ALGOL 68, there would be a precedent. I suggest
you think about this for a while. Sometimes a symbol or construct
looks strange at first, but looks fine after you get used to it.

## New Annotation