Mμl:动态多方法的力量
Mμl: The Power of Dynamic Multi-Methods
摘要:
多方法是传统(单一)动态分派的直接扩展,这是大多数面向对象语言的核心。对于多方法,方法调用将根据多个参数的值选择适当的实现,而不仅仅是第一个/接收器。对单分派和多分派的语言支持通常被设计为与其他面向对象的功能(特别是类和继承)结合使用。但这些额外的功能真的有必要吗?Mμl是一种尽可能简单的动态语言,但仍然支持灵活的抽象和多态性。Mμl只提供了两种形式的抽象:(对象)身份和(多)方法。在Mμl中,方法调用是根据参数的身份以及在参数上定义的其他方法来分派的。为了保持Mμls设计的简单性,当多个方法定义适用时,选择最近定义的方法,而不是最具体的方法(如动态分派的常规方法)。在本文中,我们将展示如何通过在运行时定义方法,我们获得了大部分的类和Meta对象协议的权力,特别是能够动态地修改对象的“类”的状态和行为。
英文摘要:
Multi-methods are a straightforward extension of traditional (single) dynamic dispatch, which is the core of most object oriented languages. With multi-methods, a method call will select an appropriate implementation based on the values of multiple arguments, and not just the first/receiver. Language support for both single and multiple dispatch is typically designed to be used in conjunction with other object oriented features, in particular classes and inheritance. But are these extra features really necessary? Mμl is a dynamic language designed to be as simple as possible but still supporting flexible abstraction and polymorphism. Mμl provides only two forms of abstraction: (object) identities and (multi) methods. In Mμl method calls are dispatched based on the identity of arguments, as well as what other methods are defined on them. In order to keep Mμls design simple, when multiple method definitions are applicable, the most recently defined one is chosen, not the most specific (as is conventional with dynamic dispatch). In this paper we show how by defining methods at runtime, we obtain much of the power of classes and meta object protocols, in particular the ability to dynamically modify the state and behaviour of 'classes' of objects.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。