当前位置: X-MOL 学术Sci. Comput. Program. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
A new modular implementation for stateful traits
Science of Computer Programming ( IF 1.5 ) Pub Date : 2020-04-29 , DOI: 10.1016/j.scico.2020.102470
Pablo Tesone , Stéphane Ducasse , Guillermo Polito , Luc Fabresse , Noury Bouraqadi

The term traits is overloaded in the literature. In this work we refer to traits as the stateless model and implementation described in Schaerli et al. articles.

Traits provide a flexible way to support multiple inheritance code reuse in the context of a single inheritance language. The Pharo programming language includes the second implementation of stateless traits based on the original version of Schaerli's one. Even if it is the second iteration of such an implementation, it presents several limitations. First, it does not support state in traits. Second, its implementation is monolithic i.e., it is deeply coupled with the rest of the language kernel: it cannot be loaded nor unloaded. Furthermore, trait support impacts all classes, even classes not using traits. In addition, while the development tools include full support to work with classes, trait support is more limited because classes and traits do not present the same Metaobject Protocol (MOP). Finally, being monolithic and integrated in the language kernel, it is difficult to extend this current implementation.

This article describes a new modular and extensible implementation of traits: it is easily loadable and unloadable as any other package. In addition, classes not using traits are not impacted. Finally, this new implementation includes a new and carefully designed Metaobject Protocol (MOP) that is compatible with both classes and traits. This allows one to reuse existing tools as they do not require special support for traits. Then, following the semantics proposed for stateful traits in [6], we present a new implementation of stateful traits. This implementation is an extension of our new modular implementation.

We implemented modular traits using specialized metaclasses as our main language extension mechanism. By replacing the implementation we reduced the Pharo Language Kernel size by 15%. This model and implementation are used in production since Pharo7.0 (January 2019).



中文翻译:

有状态特征的新模块化实现

特质一词在文献中过多。在这项工作中,我们将特征称为Schaerli等人所述的无状态模型和实现。文章。

特性提供了一种灵活的方法来在一种继承语言的上下文中支持多种继承代码重用。Pharo编程语言包括基于Schaerli的无状态特征的第二种实现。即使这是此实现的第二次迭代,也存在一些限制。首先,它不支持特质中的状态。其次,它的实现是单块的,它与语言内核的其余部分紧密相连:无法加载或卸载。此外,特质支持会影响所有班级,甚至是不使用特质的班级。此外,尽管开发工具包括与类一起使用的全面支持,但由于类和特性没有提供相同的元对象协议(MOP),因此对特性的支持更为有限。最后,由于是整体式且集成在语言内核中,因此很难扩展此当前实现。

本文介绍了trait的新的模块化可扩展实现:与其他任何软件包一样,它易于装载和卸载。此外,不使用特征的类不会受到影响。最后,此新实现包括精心设计的新的元对象协议(MOP),该协议与类和特征兼容。这样一来,就可以重复使用现有工具,因为它们不需要对特征的特殊支持。然后,按照[6]中针对有状态特征提出的语义,我们提出了有状态特征的新实现。此实现是我们新的模块化实现的扩展。

我们使用专门的元类作为主要语言扩展机制来实现模块化特征。通过替换实现,我们将Pharo语言内核的大小减少了15%。从Pharo7.0(2019年1月)开始在生产中使用此模型和实现。

更新日期:2020-04-29
down
wechat
bug