tc39 / proposal-slice-notation

http://tc39.es/proposal-slice-notation/
MIT License
526 stars 19 forks source link

Stronger Motivation #40

Closed gsathya closed 1 year ago

gsathya commented 4 years ago

At the last TC39 meeting, there was strong pushback that this feature didn't really solve any problem.

The main motivation for me was developer ergonomics: shorter to type than slice(). And having a ton of other mainstream languages provide similar slicing capability showed the demand and value for this feature.

Both of these didn't seem to be convincing enough, are there other reasons to have this feature?

hax commented 4 years ago

The original proposal includes step, but it could be solved by add third param on slice method, so I am not sure whether it could make any difference.

Personally I think a[^1] (index from end syntax) is attractive, which solve the argument of a[0:-1] work but a[-1] not. If we could have a[^1] it may be have stronger motivation to have a[0:^1], and in a[0:^end] end could be 0, which same as a[0:(a.length)], this solve the slice issue: a.slice(0, -end) returns empty instead of whole array if end is computed to 0.

hax commented 2 years ago

I think we could extend the motivations to:

The gotchas:

Maybe we can not solve all gotchas , but we should at least have a try.

hax commented 1 year ago

As previous meeting, I don't think "stronger motivation" is the problem now. So I close this. See also https://github.com/tc39/proposal-slice-notation/issues/45#issuecomment-1835388392 .