F#'s dynamic support is more interesting than C#. Instead of giving you yet more special-case compiler rules, F# provides dynamic lookup and assignment operators, but you provide the implementation. That way you can implement what you'd like to happen in the scenarios where you want dynamic access with convenient syntax.
I've found MS's less-typed APIs like MVC to be more annoying to use. Taking "object" everywhere? Just means the tools (IntelliSense/compiler) can't provide the info I need, and I'm forced to go read documentation for small things.
Especially silly is the whole "use an anonymous type as a dictionary" idea. (E.g, SomeFunction(new { width=100, height=200, style="bla"}). The only reason I can see a need for this is because the language doesn't have handy list/sequence and tuple syntax.
There are good places for using dynamic typing. Unfortunately, it seems MS is mainly doing it for interop and as a patch for other annoyances.
In C# you can make your objects implement IDynamicObject with this signature ...
public interface IDynamicObject {
MetaObject GetMetaObject(Expression parameter);
}
That returned MetaObject is responsible for defining the runtime dispatching, and you can do it however you want. The "binders" defined in MetaObject are returning Expressions, which means that the DLR library also has a chance to do inline caching.
F# uses the same API.
> Just means the tools (IntelliSense/compiler) can't provide the info I need, and I'm forced to go read documentation for small things.
Yeah, reading documentation in this day and age. The horror!
Interesting, thank for the info on that interface. F# doesn't use that though; it simply has syntax support for a user-defined dynamic operator. That is, I can do foo?bar and I'll get bar as a string and do what I please. The types you mention don't even appear in the F# compiler source.
As far as reading documentation, I shouldn't be forced to lookup tiny things here and there because an API decides to use object type for each parameter.
I've found MS's less-typed APIs like MVC to be more annoying to use. Taking "object" everywhere? Just means the tools (IntelliSense/compiler) can't provide the info I need, and I'm forced to go read documentation for small things.
Especially silly is the whole "use an anonymous type as a dictionary" idea. (E.g, SomeFunction(new { width=100, height=200, style="bla"}). The only reason I can see a need for this is because the language doesn't have handy list/sequence and tuple syntax.
There are good places for using dynamic typing. Unfortunately, it seems MS is mainly doing it for interop and as a patch for other annoyances.