计算机科学 > 程序设计语言
[提交于 2018年2月7日]
标题:Code Reuse With Transformation Objects
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读摘要: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.
提交历史
来自:Dmitry Boulytchev[v1] 2018年2月7日 星期三 00:00:00 UTC