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

SlicingIterator preserves keys: should it? #16

Open
morrisonlevi opened this issue Jul 26, 2013 · 5 comments
Open

SlicingIterator preserves keys: should it? #16

morrisonlevi opened this issue Jul 26, 2013 · 5 comments
Labels

Comments

@morrisonlevi
Copy link
Owner

My expectation on a slice is that the keys would be renumbered, since slicing something that doesn't really have an order is sort-of undefined. There needs to be some expectations clearly outlined on this somewhere, and I'm not sure what they should be.

@morrisonlevi
Copy link
Owner Author

Note that slice($start, $count) could be be implemented as:

function slice($start, $count) {
    return $this->skip($start)->limit($count);
}

Maybe that will help make semantic sense of everything, I'm not sure.

@morrisonlevi
Copy link
Owner Author

Whenever I have realizations like this I always want to implement it immediately. Implementing it as above could eliminate a class. It's a bit off topic for this issue, but I'll think about it.

@morrisonlevi
Copy link
Owner Author

I've decided that algorithms should preserve keys by default. Once keys are stripped one cannot magically get them back, but generally one easily re-assign the keys if desired. This ticket will remain open until I've fixed things to retain keys by default.

@hakre
Copy link

hakre commented Mar 30, 2015

This here probably is fixed? Also I wouldn't keep it open until the rest is fixed, but just state your decision and close it if implemented.

@morrisonlevi
Copy link
Owner Author

I am thinking that this repository will narrow its scope to remove methods like map, filter, etc on classes. This in turn obviates the need for these iterators. Will keep thinking about this.

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

No branches or pull requests

2 participants