为什么多播代表仅支持无效返回类型? [英] Why Multicast Delegate Only Support Void Return Type Only?

查看:78
本文介绍了为什么多播代表仅支持无效返回类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么仅多播委托仅支持无效返回类型?

解决方案

因为它们是多播的,所以调用了多个方法.您将使用哪个返回值?您将如何组合它们(也就是说,框架将如何组合它们)?

出于相同的原因,您也不能使用refout参数.现在给出基本说明.

原因如下:我正在撰写有关动态方法分派器的文章,该文章将介绍从调用列表的所有元素返回的功能.为了允许每个单独的委托元素返回其单独的返回值,我必须将调用结果呈现为一个由所有单独的返回值组成的数组.您能看到这个主意吗?

我认为多播委托的开发人员发现此功能是多余的(坦率地说,我自己看不到该功能非常重要的用例).简化意味着根本没有调用链的返回值,因此是无效的.

—SA


Why Multicast Delegate Only Support Void Return Type Only?

解决方案

Because they are multicast, calling more than one method. Which return value would you use? How would you combine them (that is, how would the framework combine them)?

You can''t use ref or out arguments either, for the same reason.


Probably I will try to answer in more detail a little later, but I''ll give the basic explanation right now.

Here is why: I''m writing and article on dynamic method dispatcher which will features return from all the elements of the invocation list. To allow every individual delegate element to return its individual return value I had to present the result of invocation as an array composed of all the individual return values. Can you see the idea?

I think that the developer of multicast delegate found this feature redundant (frankly, I don''t see very important use cases for such feature myself). The simplification means not having a return value of invocation chain at all — hence void.

—SA


这篇关于为什么多播代表仅支持无效返回类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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