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
21924 readers
794 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 know some programming languages use : for ranges and it is more legible if you support negative indices, but I think START-END is more natural reading and I’d use : for START:COUNT instead, e.g. 3:4 for 4 elements starting from 3, so elements 3,4,5,6 or 3-6.
You can even support both formats! (Feature creep warning)
A dash is a bit problematic from practical point of view. In example I allow single numbers without a colon like just
6
which would be interpreted as6:6
. And each element is optional as well, which would make-6
either be a negative number, an commandline option or a range? Some languages also use dots..
instead. If I want ever support negative numbers, then the hypen, dash or minus character would be in the way.I mean I could just do a duck typing like stuff, where I accept "any" non digit character (maybe except the minus and plus characters) with regex. Hell even a space could be used... But I think in general a standardized character is the better option for something like this. Because from practical point of view, there is no real benefit for the end user using a different character in my opinion. Initially I even thought about what format to use and a colon is pretty much set in stone for me.