15
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 28 Jul 2025
15 points (100.0% liked)
Programming
22057 readers
285 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
I've been working on this problem for my own language, and have landed on something more clear than just following a convention. Basically you use
[]
and()
to specify if the left and right bounds are included or not (based off of interval notation: https://en.wikipedia.org/wiki/Interval_(mathematics)#Including_or_excluding_endpoints). e.g. for your casepotentially not relevant to your case, but my version supports an
end
keyword which you can do math on, similar to python's negative indexingPersonally I'm a fan of 0 indexing, but for your context, I think it would depend on how the user sees what they're slicing. E.g. if it was pages with page numbers, the numbers would indicate if it was 0 or 1 index based. If there's nothing to actually show the user, I think picking something reasonable and documenting it well is probably the best bet.