Iterators.jl icon indicating copy to clipboard operation
Iterators.jl copied to clipboard

capitalization convention

Open StefanKarpinski opened this issue 11 years ago • 7 comments
trafficstars

Once upon a time (truth be told, I can't find the email thread), it was decided that lowercase iterator functions would all be eager, while the corresponding uppercase name would be an Iterator object, which is thus lazy. After this was resolved and agreed to, it was immediately ignored, so we have kind of a free-for-all going on. I still think that was a good idea. Thus, Map(f,itr) would produce a Map iterator that does mapping lazily, whereas map(f,itr) is equivalent to collect(Map(f,itr)), but can of course be more efficient. Most iterators in this package define a type for lazy iteration and then immediately define a function that just constructs the type, thus constructing a lazy iterator. Of course, for many of the iterators in this package, it isn't even sensible to evaluate them eagerly. In any case, it would be nice to have some consistent convention about eager versus lazy iterator evaluation.

StefanKarpinski avatar Feb 27 '14 15:02 StefanKarpinski

Capitalization seems so subtle that I'm not surprised people ignored that rule.

johnmyleswhite avatar Feb 27 '14 16:02 johnmyleswhite

Maybe we should have some other convention then. It seems like the most sensible thing at the time since we need to have an iterator type to do lazy iteration anyway and those are capitalized.

StefanKarpinski avatar Feb 27 '14 16:02 StefanKarpinski

eachmap? mapitr?

johnmyleswhite avatar Feb 27 '14 16:02 johnmyleswhite

lazymap? On Feb 27, 2014 11:31 AM, "John Myles White" [email protected] wrote:

eachmap? mapitr?

Reply to this email directly or view it on GitHubhttps://github.com/JuliaLang/Iterators.jl/issues/19#issuecomment-36260744 .

quinnj avatar Feb 27 '14 16:02 quinnj

I personally like the capitalization convention.

Kevin

On Thursday, February 27, 2014, Jacob Quinn [email protected] wrote:

lazymap? On Feb 27, 2014 11:31 AM, "John Myles White" <[email protected]javascript:_e(%7B%7D,'cvml','[email protected]');

wrote:

eachmap? mapitr?

Reply to this email directly or view it on GitHub< https://github.com/JuliaLang/Iterators.jl/issues/19#issuecomment-36260744> .

— Reply to this email directly or view it on GitHubhttps://github.com/JuliaLang/Iterators.jl/issues/19#issuecomment-36263911 .

kmsquire avatar Feb 27 '14 17:02 kmsquire

I'm not saying I agree, but should we close the door on, doing same later:

Nim (formerly Nimrod): http://forum.nim-lang.org/t/182

"The reality is that Nimrod is case insensitive and that's one of the best thing Nimrod has."

[they also are agnostic to CamelCase vs camel_case..]

PallHaraldsson avatar Apr 22 '16 12:04 PallHaraldsson

One possibility is to have functions always return iterators when called on iterator objects, and provide a function (e.g., iter) that converts collections to iterators.

iamed2 avatar Sep 26 '16 20:09 iamed2