Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Implement withFilter #145

Closed
julienrf opened this issue Jul 3, 2017 · 5 comments
Closed

Implement withFilter #145

julienrf opened this issue Jul 3, 2017 · 5 comments
Milestone

Comments

@julienrf
Copy link
Contributor

julienrf commented Jul 3, 2017

No description provided.

@julienrf julienrf added this to the 0.3.0 milestone Jul 3, 2017
@pnf
Copy link
Contributor

pnf commented Jul 4, 2017

withFilter always seemed to me to be a weird special case. I.e. why would one be concerned about creating a temporary collection when filtering but not anywhere else. Now that we have very lightweight, iterator-based views, wouldn't most uses of withFilter be better rewritten .view.filter....? I suppose I'm also suggesting changing the semantics of for desugaring to use views as much as possible.

@Ichoran
Copy link
Contributor

Ichoran commented Jul 4, 2017

@pnf - withFilter is a special hint that the contents are ultimately likely to be consumed in full and traversed exactly once. There are cases where this is very valuable information regarding performance. Because for desugaring is not specific to collections, it makes sense to retain this distinction (inasmuch as it ever did). We can implement withFilter as .view.filter, but we shouldn't use the collections rewrite as justification for removing withFilter.

@pnf
Copy link
Contributor

pnf commented Jul 5, 2017 via email

@julienrf
Copy link
Contributor Author

BTW, do we need FilterMonadic? I’m tempted to say no but maybe it is useful to “mark” that a computation is supposed to be used in for.

@odersky
Copy link
Contributor

odersky commented Jul 20, 2017

@julienrf Out of hand, I don't see a need of FilterMonadic.

Regarding withFilter, this discussion is also relevant: scala/scala3#2573.

If we follow the recommendations there, it would be good to have an empty in each collection (not in the companion object; in the collection itself). If we have that we could change the scheme for for-expression translation and phase out withFilter. All that would happen over time though, right now we definitely need to leave withFilter in. So my remark is about adding empty now, so that we can remove withFilter later.

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

No branches or pull requests

4 participants