|Version 3 (modified by igloo, 2 years ago) (diff)|
Array indexing currently uses the ! infix operator. However, ! is also used by the BangPatterns proposal, which leads to some interesting parsing issues if you try to combine the two (patterns are usually parsed as expressions in Haskell due to ambiguities).
Furthermore, it seems more consistent to reserve ! to mean "strict", which it does in other contexts: constructor field declarations, the $! operator, and BangPatterns. Later we might want to introduce ! as a general type operator.
If we remove ! as array indexing, what do we use instead? If the CompositionAsDot proposal is adopted, then that leaves . free to be used for "selection", and array indexing is definitely a form of selection, so perhaps one of the following syntaxes would be appropriate:
This is unambiguous if e.x is to be used for record field selection. An arbitrary expression would of course be allowed inside the parentheses.
Also unambiguous, but inconsistent with the use of  for lists.
This doesn't even require any new syntax, because .# is a valid infix operator.
Use of '!'
A more useful definition of '!' would be
f ! x = x seq f x
where '!' has the exact same fixity as function application. so
foo !x !y
could be used to call foo with x and y evaluated strictly beforehand.