转换对象的代码重用
Code Reuse With Transformation Objects
摘要:
我们提出了一个轻量级的数据类型泛型编程的ObjectiveCaml程序设计语言,旨在更好的代码重用的方法。我们表明,通常通过递归函数与模式匹配表示的一大类变换可以使用单个每类型遍历函数和一组对象编码的变换来实现,我们称之为变换对象。对象编码允许以传统的面向对象方式修改、继承和扩展转换。然而,数据表示保持不变,这保留了以通常方式构造和模式匹配它的能力。我们的方法同样适用于常规和多态变体类型,这使得它可以结合数据类型和它们的转换从静态类型和单独编译的组件。我们还提出了一个实现,它允许我们自动派生的大部分功能,从一个稍微增强的类型描述。
英文摘要:
We present an approach for a lightweight datatype-generic programming in Objective Caml programming language aimed at better code reuse. We show, that a large class of transformations usually expressed via recursive functions with pattern matching can be implemented using the single per-type traversal function and the set of object-encoded transformations, which we call transformation objects. Object encoding allows transformations to be modified, inherited and extended in a conventional object-oriented manner. However, the data representation is kept untouched which preserves the ability to construct and pattern-match it in the usual way. Our approach equally works for regular and polymorphic variant types which makes it possible to combine data types and their transformations from statically typed and separately compiled components. We also present an implementation which allows us to automatically derive most functionality from a slightly augmented type descriptions.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。