Swift静态和动态分发机制
来源:互联网 发布:淘宝客链接怎么生成 编辑:程序博客网 时间:2024/04/29 04:19
Free functions, and methods called on structs, are statically dispatched. This means the function that’ll be called is known at compile time. This also means the compiler might be able to inline the function, i.e. not call the function at all, but instead replace it with the code the function would execute. It can also discard or simplify code that it can prove at compile time won’t actually run.
全局函数和或者在结构上调用的方法使用的是静态分发的机制。这意味着函数调用在编译时已知。这同样表示编译器内联函数。举个例子,不是调用函数而是将其替换为函数本身的代码。他同样可以丢弃和简化编译时被证明实际不运行的代码。
Methods on classes or protocols might be dynamically dispatched. This means the compiler doesn’t necessarily know at compile time which function will run. This dynamic behavior is done either by using vtables (similar to how Java or C++ dynamic dispatch works), or in the case of @objc classes and protocols, by using selectors and objc_msgSend.
在类或协议上的方法是动态分发的。这意味着编译器并不一定知道在编译时刻哪个函数将会运行。这种动态行为用虚表(类似于Java或C++动态分发那样)或者在使用@objc修饰类或协议的情况下,使用选择器和objc_msgSend来完成。
- Swift静态和动态分发机制
- iOS事件的分发机制和响应者链(Swift)
- 静态库和动态库的制作(OC、Swift)
- 多态实现机制:静态分派和动态分派
- 静态(static binding) 和动态绑定机制(auto binding)
- android事件分发机制和消费机制
- Android事件分发机制(三)事件分发和消费
- Android事件分发和消费机制总结
- 服务器端的消息分发和路由机制
- touch事件的分发和消费机制
- Touch事件的分发和消费机制
- android 事件分发和消费机制
- Android事件分发机制和一些疑问
- Android_Touch事件的分发和消费机制
- Touch事件分发机制和专题
- ViewGroup和View的事件分发机制
- Android 事件的分发和消费机制
- Android43_Touch事件的分发和消费机制
- Problem C: 农夫果园
- UVa 1149 Bin Packing——优先队列
- 程序设计师真情忏悔录
- hive数据挖掘
- R语言基础
- Swift静态和动态分发机制
- Problem A: 家教课程
- map,set,multimap,multiset的异同
- 关于C++中的虚拟继承的一些总结
- Origin 求空域频率时 sample interval的设定
- build zxing-cpp
- 如何在mac的terminal安装Apache Tomcat
- 公积金单位账号和个人账号
- hdu4572_Bottles Arrangement_(思维+找规律)