-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
add some of Iterators.jl to Base? #10162
Comments
Could we rename |
Yes, that's a good idea. I expect that to work well, since the definitions for |
This would be great to have, I like option 2 for consistency. |
I think this is a great idea. |
👍 to option 2, unappealing names for uppercase |
Just out of curiosity, has anybody actually found it useful to refer to the iterator type names, |
There was a proposal in JuliaCollections/Iterators.jl#19 for capitalization to return iterators and lowercase to collect to vectors. I'm not sure I like it as it would make collecting to other container types forever second class, but it seems less confusing than the current case where |
Yes, I don't see a point in having both lazy-uppercase and eager-lowercase
versions of all iterators. Fortunately this problem is not widespread; I
think filter is the only function with this confusion. The Filter iterator
is also pretty slow. One option is to rename it filtered, like repeated.
|
That sounds good. Is a map (imap, etc.) iterator a candidate for Base now that the set of other basic iterators is more complete? |
It's not past tense, it's a participle. |
I'd prefer to just make all of these iterators lazy and get rid of the lowercase versions, but that would imply writing |
There's some evidence that it's good to have indirection between what you call and the actual type of iterator constructed. For example I would love to get rid of the lower/upper duplication one way or another though. |
I don't think uppercase looks too weird. In Python 3 and Julia, you are creating an object. It appears to be established standard practice in Julia that creation of an object is done with an uppercase constructor. I think people using iterators in Julia are prepared to use capital letters here. In general I think it's more important to be internally consistent then to maximize consistency with other languages. IMO |
If going the all-uppercase route, would exporting abstract supertypes (e.g. On Fri, Feb 13, 2015 at 11:45 AM, iamed2 notifications@github.com wrote:
|
I think it's difficult to be consistent in this case. It's hard to know which operations "create an object" by the standard of this convention, since almost every operation creates an object in some sense. Another example is |
I like Part of the same argument hold for For
As all types, the capitalized iterator names is used whenever you need to explicitly type an expression. Mostly that will be a function where you use multiple dispatch to do something different with a |
Yes, I think the type returned is often an implementation detail of a generic function. You call |
During interactive usage it's very annoying to do |
Independent of anything else, it sounds like a good idea to print |
Fixed the printing issue in 01a2fc8. It feels wrong that we have to export lots of type names for no reason but a convention that |
Can this be closed? |
I guess so; the lowercase/uppercase debate seems to be at a stalemate. |
If you want to compose more than one iterator, to me it seems more natural that they remain lowercase functions. |
Several of the types in the Iterators package are widely useful, plus have very small implementations that perform well. I would say these are: Count, Take, Drop, Cycle, Repeat, and RepeatForever. It would make sense to have these in Base.
Also, iterators are afflicted by a mild case of "lettercase hell". We export both
Enumerate
andenumerate
, etc. I would prefer to minimize the number of exported things that differ only in case. There are a few ways to deal with this:EnumerateIterator
so they are less easily confused.The text was updated successfully, but these errors were encountered: