首页> 外文期刊>Science of Computer Programming >EVL: A framework for multi-methods in C++
【24h】

EVL: A framework for multi-methods in C++

机译:EVL:C ++中的多方法框架

获取原文
获取原文并翻译 | 示例
           

摘要

Multi-methods are functions whose calls at runtime are resolved depending on the dynamic types of more than one argument. They are useful for common programming problems. However, while many languages provide different mechanisms to implement them in one way or another, there is still, to the best of our knowledge, no library or language feature that handles them in a general and flexible way. In this paper, we present the EVL (Extended Virtual function Library) framework which provides a set of classes in C++ aiming at solving this problem. The EVL framework provides a generalization of virtual function dispatch through the number of dimensions and the selection of the function to invoke using a so-called Function Comparison Operator. Our library provides both symmetric and asymmetric dispatch algorithms that can be refined by the programmer to include criteria other than class inheritance. For instance, the EVL framework provides multi-methods with predicate dispatch by defining a dedicated FCO based not only on the dynamic types of the arguments but also on their values. This flexibility greatly helps to resolve ambiguities without having to define new functions. Our multi-methods also unify dispatch tables and caching by introducing cache strategies for which the implementation is a balance between memory and speed. To define multi-methods in C++, we implement a non-intrusive reflection library providing fast dynamic casting and supporting dynamic class loading. Our multi-methods are policy-based class templates that support virtual but not repeated inheritance. They check the type compatibility of functions at compile-time, preserve type-safety and resolve function calls at runtime by invoking the cache or updating it by computing the selected function for the requested tuple of types. By default, our multi-methods handle dispatch errors at runtime by throwing exceptions but an error-code strategy can be set up by defining a dedicated policy class. Performance of our multi-methods is comparable with that of standard virtual functions when configured with fast cache.
机译:多方法是函数,它们的运行时调用取决于多个参数的动态类型。它们对于常见的编程问题很有用。但是,尽管许多语言提供了以一种或另一种方式实现它们的不同机制,但是据我们所知,仍然没有库或语言功能可以通用且灵活地处理它们。在本文中,我们提出了EVL(扩展虚拟函数库)框架,该框架提供了一组旨在解决此问题的C ++类。 EVL框架通过维数和使用所谓的功能比较运算符选择要调用的功能来提供虚拟功能分派的一般化。我们的库提供了对称和非对称调度算法,程序员可以对其进行完善,以包括除类继承之外的其他条件。例如,EVL框架通过不仅基于参数的动态类型而且还基于其值来定义专用的FCO,从而为多方法提供谓词调度。这种灵活性极大地有助于解决歧义,而无需定义新功能。我们的多种方法还通过引入缓存策略来统一调度表和缓存,而缓存策略的实现是内存和速度之间的平衡。为了在C ++中定义多种方法,我们实现了一个非介入式反射库,该库提供快速的动态转换并支持动态类加载。我们的多方法是基于策略的类模板,支持虚拟但不重复继承。它们在编译时检查函数的类型兼容性,保留类型安全性,并在运行时通过调用缓存或通过为请求的元组计算所选函数来更新函数来解析函数调用。默认情况下,我们的多方法通过抛出异常来在运行时处理调度错误,但是可以通过定义专用策略类来设置错误代码策略。当配置了快速缓存时,我们的多种方法的性能可与标准虚拟功能相媲美。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号