wdte icon indicating copy to clipboard operation
wdte copied to clipboard

wdte: add syntactical support for array and string indexing

Open DeedleFake opened this issue 8 years ago • 1 comments

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 the std functions, 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.

DeedleFake avatar Oct 25 '17 02:10 DeedleFake

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.

DeedleFake avatar Oct 25 '17 02:10 DeedleFake