我无法找到一个强有力的一般机会。 动态执行:谁能向我说一句话? 到目前为止,搜索只是转向玩具或特定目的的实施,但我要亲身对C#的静态动态实施(即处理抽签/所有案件,进行切身反响)作一比较(这是自我看C#静态动态以来的一段时期,因此,如果我关于其能力的说法不实,我会宽恕我)。
感谢!
我无法找到一个强有力的一般机会。 动态执行:谁能向我说一句话? 到目前为止,搜索只是转向玩具或特定目的的实施,但我要亲身对C#的静态动态实施(即处理抽签/所有案件,进行切身反响)作一比较(这是自我看C#静态动态以来的一段时期,因此,如果我关于其能力的说法不实,我会宽恕我)。
感谢!
有一个单元:FSharp.Interop.Dynamic,内容是关于核心的,应当利用dlr有力处理动态经营者。
It has several advantages over a lot of the snippets out there.
Add! 预设操作员处理直接援引动态物体和功能的问题,在操作时间,你没有这种类型。
开放源,阿帕奇许可证,你可以查阅lement/a>,其中包括单位测试
您永远不能完全全面执行<代码>?。 经营人可以不同类型地实施,视下列类型而定,可能需要做一些特殊的事情:
Dictionary<T, R>
, you d want it to use the lookup function of the dictionary如果你重新寻找使用反思的实施工作,那么你可以使用在F#中实施的对莫诺迪奥·迪奥普具有约束力的一例(上查阅。 它相当完整,处理财产存取、使用方法以及固定成员的问题。 (其他链接档案大量使用F#汇编器内部成员。) 它直接使用反省,因此相当缓慢,但相当具体。
另一种选择是将经营者置于顶端。 NET 4.0 动态语言运行时间(因此,它将在C#4中使用与dynamic
相同的对应文本)。 我不认为在其中某个地方执行这一规定,但这里是你如何能够做到的简单例子:
#r "Microsoft.CSharp.dll"
open System
open System.Runtime.CompilerServices
open Microsoft.CSharp.RuntimeBinder
let (?) (inst:obj) name (arg: T) : R =
// Create site (representing dynamic operation for converting result to R
let convertSite =
CallSite<Func<CallSite, Object, R>>.Create //
(Binder.Convert(CSharpBinderFlags.None, typeof< R>, null)) //
// Create site for the method call with single argument of type T
let callSite =
CallSite<Func<CallSite, Object, T, Object>>.Create //
(Binder.InvokeMember
( CSharpBinderFlags.None, name, null, null,
[| CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null);
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) |]))
// Run the method and perform conversion
convertSite.Target.Invoke
(convertSite, callSite.Target.Invoke(callSite, inst, arg))
let o = box (new Random())
let a : int = o?Next(10)
这种方法只能以单一论点为根据。 (通过研究C#汇编者为<代码>dynamic <>/code>在职业中产生的代码,可以发现如何做到这一点。) 我猜测,如果你(从头一开始)与使用德国航天中心(在第二种情况下)的做法混在一起,你会得到最有力的执行。
EDIT: I also posted the code to F# Snippets. Here is the version using DLR: http://fssnip.net/2U and here is the version from F# plugin (using .NET Reflection): http://fssnip.net/2V
I have a number of events that happen in a game. I want to control the time and order at which these events occur. For example: Event 1: Show some text on screen for N frames & play a sound ...
Is there an easy way to create Silverlight 3 applications with F# (October CTP)? I have seen the F# for Silverlight, but that only works with the May CTP. I am using Visual Studio Integrated Shell ...
In F# I want to transform a list of chars into a string. Consider the following code: let lChars = [ a ; b ; c ] If I simply do lChars.ToString, I get "[ a ; b ; c ]". I m trying to get "abc". I ...
I m reading a file(a flash swf) from .Net 3.5 that has a header which states whether the body of the file/Stream is compressed or not. However, I m having problems-after I rewrap the basic File ...
Let s say I have a binary tree data structure defined as follows type a tree = | Node of a tree * a * a tree | Nil I have an instance of a tree as follows: let x = Node (Node (...
(Background: I ve been thinking about doing a presentation on F# and functional programming. From experience, I think that the wow factor of pattern matching and type inference is not necessarily ...
I recently began to read some F# related literature, speaking of "Real World Functional Programming" and "Expert F#" e. g.. At the beginning it s easy, because I have some background in Haskell, and ...
As part of a project I have assigned myself as a way of improving my knowledge of F# and functional programming in general, I am attempting to write a string pattern-matching algorithm from scratch ...