[stdlib] IntRange substring functions as get operators#5746
[stdlib] IntRange substring functions as get operators#5746JordanLongstaff wants to merge 1 commit intoJetBrains:masterfrom
Conversation
Code Owners
|
|
This gets very awkward. Pretty much every developer in every language is used to either indexed access ( |
Python: 'hello, world'[1:6]Rust: let a = "hello, world";
let b = &a[1..6];Ruby: "hello, world"[1..6]C#: "hello, world"[1..6]Julia: "hello, world"[1:6]and on… |
|
The literal form is probably fine and understandable. However once you extract the range into a separate variable it loses most of its sense and readability. |
|
Do you also switch to invoking the named function when your indexing value changes from a literal to a variable? It's just a variable naming problem. |
|
Index access has been there forever, so that point doesn't really make a lot of sense imo. |
|
I'm not sure what the age of the capability has to do with it. You claimed that when one transition's from a literal to a variable that the special syntax no longer makes sense and the named function should be used.
Surely that holds true for plain indexing then, too? |
When you see |
|
Hi all, what about this option? |
Not a huge motivation for this, call it syntactic sugar. I just don't know why this doesn't already exist.