Skip to content

[Discussion] Revisiting pattern matching on collections #1039

Answered by jcouv
DavidArno asked this question in General
Discussion options

You must be logged in to vote

@DavidArno I've just noticed this discussion. I think the latest iterations of list-patterns are getting pretty close to what you're proposing.

I've written a proposal for how we might implement list-patterns on enumerable types (ie. that are not indexable) without enumerating multiple times: https://github.com/dotnet/csharplang/blob/main/proposals/list-patterns-enumerables.md
In short, we'd generate a wrapper type around the enumerable and buffer a few elements. More elements need to be buffered if the list-patterns are longer and involve slices at the start. This type provides a count-in-progress and emulates indexers for start-indexes (such as 0) and end-indexes (such as ^1).

Regarding…

Replies: 16 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@julealgon
Comment options

@alrz
Comment options

Comment options

You must be logged in to vote
2 replies
@DavidArno
Comment options

@alrz
Comment options

Answer selected by DavidArno
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
10 participants
Converted from issue

This discussion was converted from issue #1039 on September 08, 2020 23:46.