3 ms·
Structural typing is different from dynamic typing. C# supports structural typing in the form of tuples and anonymous types. But you can't return an anonymous t
by goto11 7y ago
Structural typing is different from dynamic typing. C# supports structural typing in the form of tuples and anonymous types. But you can't return an anonymous type from a method. This is a significant limitation.
As for "free" functions: C# already recognizes the usefulness of this in the "using static" directive. This is useful for a lot more than "hello world".
- moron4hire 7y agoYou can't return an anonymous type, but the syntactic difference between an anon type and a tuple is two characters: parens instead of curly braces.
- Faark 7y agoAnd the little "new" in front of it. I actually preferred the curly braces version and would have loved for them improve it instead of creating a replacement. And well, I'd expect them to get it right eventually. It is at least their third evolution of that feature... there was a System.Tuple as well. Wonder if they ever come out and officially deprecate their earlier attempts.
- goto11 7y agoI don't think C# have ever deprecated language features. You can still use the old "delegate{}" syntax even though we have the more concise arrow syntax.
- SideburnsOfDoom 7y ago> Wonder if they ever come out and officially deprecate their earlier attempts. That (mostly) doesn't happen. I would say that .NET Core was the sole attempt to deprecate a lot of the framework. And most of it came back anyway; see the title of the parent article.
- manigandham 7y agoWhy are "free" functions useful? What actual real difference does it make compared to putting an extra word in front to call the method?
- goto11 7y agoYou don't need to put the extra word in front since "using static" was introduced. But you still need to define a useless static class.