Version 1 (modified by Simon Marlow, 11 years ago) (diff)

Array Indexing

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 (parterns 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.