是否可以通过Reflection来传递F#函数?是否有可能通过Reflection来传递F#函数?
(*in module A*)
type Foo() =
static member bar n = {1..n}
let functionUsingFoobar (x:(int -> #('a seq)) n =
let z = BarFoo.ofSeq (x n)
z.count
(* in module B
here is where I want to pass Foo.bar by reflection*)
let y = functionUsingFoobar Foo.bar 1000
我无法调用没有args参数的成员,所以通过InvokeMember的部分函数应用程序无法工作。
let foo = new Foo()
let z = foo.GetType().InvokeMember("bar", System.Reflection.BindingFlags.InvokeMethod, null, foo, [|1000|])
(*tried null, [||], [|null|] for args parameter*)
我的想法如何通过反射
我不明白你怎么第二个代码示例连接到第一个 - 什么是seqIntAsc? – kvb
糟糕 - 谢谢你指出。更正为“酒吧”。第二个代码示例调用Foo类型的“bar”成员,这不是我想要做的。我怀疑像部分函数那样传递函数是不可能的。 –
什么是实际_problem_?你有编译器错误还是运行时错误? – ildjarn