mariusGundersen / website

My website
5 stars 2 forks source link

Add ref struct dispose in C# 8 and select/select many to Duck typing article #3

Open dzmitry-lahoda opened 5 years ago

dzmitry-lahoda commented 5 years ago

https://github.com/mariusGundersen/website/blob/master/article/duck-extensions/index.md

mariusGundersen commented 5 years ago

Do you have a reference or example?

dzmitry-lahoda commented 5 years ago

mentions Dispose (need to install beta of C# 8) and Deconstruct https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-with-patterns-in-c-8-0/

dzmitry-lahoda commented 5 years ago

SelectMany https://mikehadlow.blogspot.com/2011/01/monads-in-c-4-linq-loves-monads.html . Just put SelectMany or Select and LINQ will catch up.

dzmitry-lahoda commented 5 years ago

and it is called Structural Typing, not Duck.

Duck typing is similar to, but distinct from structural typing. Structural typing is a static typing system that determines type compatibility and equivalence by a type's structure, whereas duck typing is dynamic and determines type compatibility by only that part of a type's structure that is accessed during run time.

The OCaml, Scala, Go, Elm,[4], Gosu and PureScript languages support structural typing to varying degrees. 

Could we put C#[N] onto your article?

In C# duck is dynamic or reflection.

dzmitry-lahoda commented 5 years ago

I guess Next/Current to get foreach could also be structural(duck).

dzmitry-lahoda commented 5 years ago

I think there could be TaskLike(ValueTask and Task) stuff https://github.com/dotnet/roslyn/blob/master/docs/features/task-types.md. I guess i need the list of all such extension points. So may be or fork it.

dzmitry-lahoda commented 5 years ago

Next is also

        [EditorBrowsable(EditorBrowsableState.Never)]
        public ref readonly T GetPinnableReference();