Whitespace grouping

homeblogmastodonthingiverse



Consider: 1+2 * 3+4

The natural way to interpret this is (1+2)*(3+4). A compiler of course would interpret it as 1+(2*3)+4, based on precedence rules -- precendence rules which are simple for this case, but who remembers them for and and or and powers and so on? Not using whitespace grouping breaks a fundamental rule of language design: don't make me say it more than once.

Obvious parallels to python use of indenting for blocks.

More examples, meaning should be clear:

if a != b&mask: ...

(a+b * c)/(d*e + f) ^ 2

There is also the possibility of giving asymmetric spacing a special meaning, eg a modification to a variable. For example a- b could mean a -= b. This also disambiguates assignment (a= b or b =a) from equality testing (a = b or a=b).




[æ]