wdte: add syntactical support for array and string indexing
Using a.at and str.at is rather annoying in a lot of situations, especially for something that is so common. A syntax for indexing would be useful, although the existing functions should probably be left in for easier use in the chains. If the syntax can support slicing, that would also be useful.
Unfortunately, due to the way the parse works, using [] for indexing is not really possible. Possible alternatives:
-
array[@i]. Possible, but a bit unwieldy. Definitely better than using thestdfunctions, though. -
array.i. Ambigous, but it should be possible. Doesn't really work for slicing, though. -
array.[i]. Possible, but only by making.[a single token. Probably the cleanest, though.
Alternative: Put an at function directly in std which can access indices of both strings and arrays. Not having to import it would be a bit easier, although it's potentially still a bit awkward. Might also want to put slice and len functions that would work on both strings and arrays.