csharplang icon indicating copy to clipboard operation
csharplang copied to clipboard

Update list-patterns-enumerables.md

Open alrz opened this issue 3 years ago • 5 comments

Rendered

alrz avatar Aug 11 '22 11:08 alrz

cc @jcouv @333fred

alrz avatar Aug 11 '22 11:08 alrz

@alrz what's the reason for the large amount of removals?

333fred avatar Aug 11 '22 19:08 333fred

Because we no longer need to deal with trailing patterns for enumerable types.

I confirmed with Julien if we want to do that, at least initially.

alrz avatar Aug 11 '22 19:08 alrz

I tried to keep things that are still relevant. Let me know if there's other things you'd like to keep.

alrz avatar Aug 11 '22 19:08 alrz

Because we no longer need to deal with trailing patterns for enumerable types.

I'm not sure what you mean by this?

333fred avatar Aug 11 '22 20:08 333fred

To not depend on the impl details, I think the compiler could only generate a typeclass for struct-enumerators by implementing:

interface Iterator<TSelf, T> {
  static abstract bool MoveNext(TSelf);
  static abstract T GetCurrent(TSelf);
}

and pass it on to the helper fucntion as a type argument.

A different overload could be used for IEnumerator<T> so we don't need to generate additional code for the base scenario.

alrz avatar Dec 17 '22 07:12 alrz