-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Introduce negative indices #55
Comments
On general, I like this feature. About We can add |
The name for I was thinking more generally about all the places that accept an index. It changes not what functions do, but how positions are written. For example I understand this breaks functions for negative indices, on the other hand I don't know how much the API is fixed at this point or if you want to introduce new symbols instead (e.g. in alexandria no more new symbols are allowed because it is used a lot). Basically, I may be wrong but it seems to me that the library has still some capacity to change for those corner cases (provided the feature is wanted), so it might be worth considering having small breaking changes. It goes without saying that I am ok with whatever decisions you'll end up making about this. |
Also, this could be subject to another configuration variable: (1) this would avoid having breaking changes, and (2) the suggested |
substring -> slice+1 for insertlooks doable. With a warning first, and maybe with a key argument to control the behavior? If someone speaks up we can be more conservative. splitThe current start and end arguments are untouched. OK it can be a nice feature to have. Let's print a warning in case of negative indices for 3/4 Quicklisp releases then. New symbolsYes we can introduce new symbols. We can, and I don't think this little is By the way, we could make that a rule and then re-use reserved symbols from the I am not seduced by the |
Hi,
as an improvement, would you be interested in making indices accept negative numbers, which apparently is something that other languages (e.g. python) offer?
Based on the existing code in
cl-str
I propose the semantics of the index to be defined as follows:If you are interested, I can add a patch that process indices in the existing functions through
index
to support negative indices, something that should be backward compatible AFAIK.ok, this is not backward compatible considering
substring
clamps the index, so if some code relies on negative indices being clamped to zero, they'll have regressions.The text was updated successfully, but these errors were encountered: