[闭包和SystemReflection] [英] [Closures and SystemReflection]

查看:90
本文介绍了[闭包和SystemReflection]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MS中传递事件机制,锁定发送/发布通知。我还没有传递Concurrent Collection。在定义问题时,考虑事件作为特定类型的代表。当调用声明的代表时,通讯方法被调用。假设调用 Annonymous Methods ,但是 - 建议将代码表示为 Lambda Expression,Closures和Functors .- .So ,我考虑用 SystemReflection命名空间评估 Closures .Intuitvly似乎SystemReflection为此提供了所有需要的东西。可以以某种方式评估 Closures

I pass Event mechanism in MS, locking send / publish notification .I do not pass Concurrent Collection yet. Consider, as definition ask, Events as a certain particular type of Delegates.When invoke declared Delegate,the correspondent method is invoked.Assume that invocation is made for Annonymous Methods, but - code for method is recommanded to be expressed much more as Lambda Expression, Closures and Functors.- .So,I consider evaluating Closures with SystemReflection namespace.Intuitvly seems that SystemReflection offer all need stuff for this.Can Closures be somehow different evaluated?

推荐答案

你不明白封闭是什么,所以这个问题根本没有意义,也没有你的目标。



关闭不是可以评估的东西。这是函数与其引用环境的并集。它的本质是即使在创建委托实例的代码超出范围之后,也允许委托访问局部变量。换句话说,闭包不是您可以获得或访问的某个特定对象,这在其实现层面上是一组技术上支持该概念的内部结构。你可以在这里阅读: http://en.wikipedia.org/wiki/Closure_%28computer_science%29 [ ^ ]。



如果你有一些由匿名委托实例引用的本地(堆栈)变量,那么与访问此变量相关的代码将被修改为提供的方式当该委托实例的可达性保留在应用程序中时,始终访问其对象。



很容易在.NET示例中演示闭包的效果,但我不确定你是否需要它。



-SA
You don't understand what a closure is, so this question makes no sense at all, as well as your goal.

Closure is not something which can be "evaluated". This is a union of a function with its reference environment. The essence of it is to allow the delegate to access the local variables even after the code creating the delegate instance goes out of the scope. In other words, closure is not some particular object you can obtain or access, this is, at the level of its implementation, a set of internal structures which supports the conception technically. You can read about it here: http://en.wikipedia.org/wiki/Closure_%28computer_science%29[^].

If you have some local (stack) variable which is referenced by some anonymous delegate instance, the code related to access to this variable is modified the way to provide access to its object for all the time when reachability of that delegate instance is kept in the application.

It's very easy to demonstrate the effect of a closure on a .NET example, but I'm not sure if you need that.

—SA


这篇关于[闭包和SystemReflection]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆