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

Import Base.Iterators when IterTools is used #30

Open
rapus95 opened this issue Mar 28, 2018 · 10 comments
Open

Import Base.Iterators when IterTools is used #30

rapus95 opened this issue Mar 28, 2018 · 10 comments

Comments

@rapus95
Copy link

rapus95 commented Mar 28, 2018

If possible it would be nice if Base.Iterators-functions were imported automatically for cleaner code. Since lines like collect(Iterators.flatten(chain(1:9,reverse(11:20),10) would look cleaner if it was just flatten rather than Iterators.flatten.
When people import IterTools it seems to be clear that they intend to use them (alot) or like to go for functional programming and thus simplifying it sounds like a good idea to me.

@ararslan
Copy link
Member

We can probably do this with @reexport using Base.Iterators.

@iamed2
Copy link
Contributor

iamed2 commented Mar 29, 2018

We'll have to be more careful than that. There would be conflicts. But we should just clear up those conflicts I think.

@oxinabox
Copy link
Member

oxinabox commented Jan 9, 2019

I think this is a good idea,
and that we should also import the documentation for it too.

Then one would only need to look in Itertools,
rather than Itertools and Base.Iterators
when looking for a particular set of functionality.

@iamed2
Copy link
Contributor

iamed2 commented Jan 9, 2019

Conflicts between Iterators and IterTools were cleared up.

We can do this, but we won't be able to export everything (e.g., we can't export filter as it's different than Base.filter).

@oxinabox
Copy link
Member

oxinabox commented Jan 9, 2019

Can we export those things as ifilter to match to imap etc?

@rapus95
Copy link
Author

rapus95 commented Oct 9, 2019

Are there any news on this?

@oxinabox
Copy link
Member

oxinabox commented Oct 9, 2019

It is still desired but noone has gotten round to it.
It is a simple but mildly long PR if you are interested

@rapus95
Copy link
Author

rapus95 commented Oct 9, 2019

@oxinabox what would I have to change?

@oxinabox
Copy link
Member

oxinabox commented Oct 9, 2019

Add to the exports:

export ifilter, # etc

add to the code:

const ifilter = Iterators.filter
#etc

List of all of them is

 countfrom
 cycle
 drop
 flatten
 partition
 product
 repeated
 rest
 take

Working out which should be prefixed with i is the hard part.
Filter definately should.
The others? idk

@rapus95
Copy link
Author

rapus95 commented Oct 10, 2019

In my opinion we should either rename as few as necessary (thus only changing filter to ifilter) or switching all functions to a prefix i version, including the functions of IterTools.

Strategy A: Backwards Compatibility first
Pro : Full backwards compatibility while the lazy filter function only gets an additional name.
Con: Feels inconsistent

Strategy B: Consistency first
As for Strategy A but switched and negated.
In the long run this might help whenever Julia decides to switch to an Iterator-first or a Materialize-first manner.

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

No branches or pull requests

4 participants