Re:Are dynamic languages going to replace static languages? ...
by ComputerGuru on Wednesday August 04, 2021 @03:33AM
(#28058299)
Dynamic didn’t really go anywhere, but more appropriate examples that have now pervaded the language are await in general and IDisposable for ref struct. If it has a GetAwaiter it can be awaited, with no interface. If it has a Dispose() it can be disposed with no interface.
[ Parent
| on HN ]
Re:Are dynamic languages going to replace static languages? ...
by mgdlbp on Wednesday August 04, 2021 @11:17AM
(#28061996)
Interestingly, this sort of structural typing was already present in C# 1.0 with the foreach statement allowing anything with a GetEnumerator() method that returns something that looks like an IEnumerator.
This was discussed in 2011 in a StackOverflow question [0], including a link to a blog post by one of the language designers [1].
[0] https://stackoverflow.com/questions/6368967/duck-typing-in-t...
[1] https://web.archive.org/web/20120126033827/http://blogs.msdn...
Re:Are dynamic languages going to replace static languages? ...
by UglyToad on Wednesday August 04, 2021 @08:41AM
(#28060311)
As far as I understand it it went to wherever there are still poor souls writing COM Interop stuff primarily. Luckily I've never had to touch it so outside of Dapper for SQL I've never really had cause to use dynamic. I imagine there are Windows shops using it heavily though.
Re:Are dynamic languages going to replace static languages? ...
by Zababa on Wednesday August 04, 2021 @04:08AM
(#28058511)
> If it has a GetAwaiter it can be awaited, with no interface. If it has a Dispose() it can be disposed with no interface.
I don't know much about C# but how is this dynamic? Are those methods often added at runtime?