this post was submitted on 28 Jul 2025
15 points (100.0% liked)
Programming
22529 readers
206 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
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Sorry for late reply. I actually like the idea to use words to indicate
start
andend
as well. But with additional "math like" features it gets a little bit complicated to parse for simple slicing as an option in a program. It makes much more sense to do this flexible thing in a language. BTW its shouldn't be needed to have anend
if you already have a negative number.I use the empty string as indicator for start or end
"..2"
(BTW I switched to..
separator after long thinking, reading arguments and debating with myself).Just as an idea, you could provide another variable
mid
so one could start counting from there(mid+2:end)
. And man the idea sounds really elegant to use[
or(
to indicate if the number is inclusive or exclusive. But I fear it could be a little bit confusing and people could forget which one is which. I would rather prefer special characters that are not used otherwise. In example both sides are always inclusive and there is a special character before or after the number to indicate its exclusion. A character that is not used otherwise in numbers or slices and is representing the exclusion unmistakably, and I have absolute no idea what this could be.I have to say the usage of brackets to indicate its inclusion or exclusion is creative thinking!