首页> 外文期刊>ACM Transactions on Programming Languages and Systems >Morphing: Structurally Shaping a Class by Reflecting on Others
【24h】

Morphing: Structurally Shaping a Class by Reflecting on Others

机译:变形:通过反思来在结构上塑造一个班级

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

摘要

We present MorphJ: a language for specifying general classes whose members are produced by iterating over members of other classes. We call this technique "class morphing" or just "morphing." Morphing extends the notion of genericity so that not only types of methods and fields, but also the structure of a class can vary according to type variables. This adds a disciplined form of metaprogramming to mainstream languages and allows expressing common programming patterns in a highly generic way that is otherwise not supported by conventional techniques. For instance, morphing lets us write generic proxies (i.e., classes that can be parameterized with another class and export the same public methods as that class); default implementations (e.g., a generic do-nothing type, configurable for any interface); semantic extensions (e.g., specialized behavior for methods that declare a certain annotation); and more. MorphJ's hallmark feature is that, despite its emphasis on generality, it allows modular type-checking: a MorphJ class can be checked independently of its uses. Thus, the possibility of supplying a type parameter that will lead to invalid code is detected early, an invaluable feature for highly general components that will be statically instantiated by other programmers. We demonstrate the benefits of morphing with several examples, including a MorphJ reimplementation of DSTM2, a software transactional memory library which reduces 1,484 lines of Java reflection and bytecode engineering library calls to just 586 lines of MorphJ code.
机译:我们介绍MorphJ:一种用于指定通用类的语言,该通用类的成员是通过迭代其他类的成员而产生的。我们称这种技术为“类变形”或“变形”。变形扩展了通用性的概念,因此不仅方法和字段的类型,而且类的结构都可以根据类型变量而变化。这在主流语言中增加了元编程的规范形式,并允许以高度通用的方式表达常见的编程模式,而常规技术不支持这种方式。例如,变形可让我们编写通用代理(即可以用另一个类进行参数化并导出与该类相同的公共方法的类);默认实现(例如,通用的虚无类型,可为任何接口配置);语义扩展(例如,声明特定注释的方法的特殊行为);和更多。 MorphJ的标志性功能是,尽管它强调通用性,但它允许模块化类型检查:MorphJ类可以独立于其用途进行检查。因此,提早发现了提供可能导致无效代码的类型参数的可能性,这是高度通用的组件的宝贵功能,该组件将由其他程序员静态实例化。我们通过几个示例演示了变形的好处,其中包括MorphJ重新实现DSTM2,一种软件事务存储库,该库将Java反射的1,484行减少到字节代码工程库调用减少到586行MorphJ代码。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号