by December 3, 2012on
Lately I wanted to implement a class that derives from
DynamicObject (in the
System.Dynamic namespace) and therefore I had to override the methods
TryGetMember. Especially the latter one forced me to look up on reference parameters in F#.
The method signature of
TryGetMember looks like the following (in C# syntax):
public virtual bool TryGetMember( GetMemberBinder binder, out object result )
In F# you have to declare the
result parameter as a reference type with
open System.Runtime.InteropServices override x.TryGetMember (binder : GetMemberBinder, [<Out>] result : byref<obj>) = raise <| NotImplementedException()
I am not quite sure if the
[<Out>] parameter attribute is really necessary since my project compiled just fine without it as well.