Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support -1 in slice notation #113

Closed
sparkprime opened this issue Feb 29, 2016 · 2 comments
Closed

Support -1 in slice notation #113

sparkprime opened this issue Feb 29, 2016 · 2 comments

Comments

@sparkprime
Copy link
Member

Essentiually, finish off #106

@davidzchen
Copy link
Contributor

To recap from the offline discussion, @oconnorr brought up the point that having negative indices often results in error-prone code and that it would be better to not support them. I think that is a valid point and am also in favor in not adding negative indices.

@davidzchen davidzchen added the rfc label Mar 8, 2016
@sparkprime
Copy link
Member Author

Yep, let's leave them unsupported as we can simply do

local x = arr; x[length(x) - 1]

or

(function(x)x[length(x) - 1])(arr)

to represent

arr[-1]

Although it's more chars, it's not often that you need to use negative indexes whereas index arithmetic errors can happen anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants