tag:blogger.com,1999:blog-2744072865491516720.post6884979879967308325..comments2023-05-03T06:35:33.259-04:00Comments on Higher Logics: Factoring Out Common Patterns in LibrariesSandro Magihttp://www.blogger.com/profile/05446177882449578817noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2744072865491516720.post-31076336510278420782012-02-04T00:41:01.037-05:002012-02-04T00:41:01.037-05:00What you're after are ad-hoc extensions. I exp...What you're after are ad-hoc extensions. I explained how to achieve <a href="http://higherlogics.blogspot.com/2011/11/ad-hoc-extensions-in-net.html" rel="nofollow">ad-hoc extensions in another post</a>.<br /><br />P.S. sorry for the double-post, chrome ad-blocker ate my first link.Sandro Magihttps://www.blogger.com/profile/05446177882449578817noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-9908067035077650202012-02-03T22:22:40.981-05:002012-02-03T22:22:40.981-05:00At least two new languages, Go and Rust, solve the...At least two new languages, Go and Rust, solve the problem of "a type that you can't change doesn't explicitly implement an interface, but has all the methods of the interface". Go interfaces are sorely missed in the .NET framework, since common collection patterns like IEnumerable+Count and IEnumerable+Count+indexer have no interface; and most collection classes that were written for .NET 1.0 still don't implement any generic interfaces at all.<br /><br />I made a general solution at http://www.codeproject.com/Articles/87991/Dynamic-interfaces-in-any-NET-language<br /><br />... but because it's relatively heavyweight, using a dynamic assembly and all, and because I'm a performance freak, I still tend to write specialized wrappers for common cases.Qwertiehttps://www.blogger.com/profile/04595705428290721343noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-23996159132912352542010-11-07T09:42:44.045-05:002010-11-07T09:42:44.045-05:00Agreed! We can sort of get around it though, in a ...Agreed! We can sort of get around it though, in a similar way to how I circumvented C#'s inability to specify Delegate, Enum, etc. as type constraints: a wrapper class and IL rewriting to erase the wrapping, and generate code for all the cases. <br /><br />It's not nearly as pretty as type classes though.Sandro Magihttps://www.blogger.com/profile/05446177882449578817noreply@blogger.comtag:blogger.com,1999:blog-2744072865491516720.post-34811043238586485162010-11-07T04:20:06.775-05:002010-11-07T04:20:06.775-05:00Too bad we don't have typeclasses in .Net, whi...Too bad we don't have typeclasses in .Net, which would enable us to factor out the similarities which BCL authors didn't.Anonymousnoreply@blogger.com