基于Camlp5的泛型编程“缺省情况”研究  

Research on Default Case of Generic Programming Based on Camlp5

在线阅读下载全文

作  者:王朋[1] 张兴元[2] 徐健[1] 

机构地区:[1]解放军理工大学指挥信息系统学院研究生2队,江苏南京210007 [2]解放军理工大学指挥信息系统学院

出  处:《军事通信技术》2013年第1期43-48,95,共7页Journal of Military Communications Technology

摘  要:"泛型编程"旨在编写一般化并可重复使用的算法,主要目的是提高程序的复用性,其效率与针对某特定数据类型而设计的算法相同。在书写泛型函数时经常会出现新的数据结构或类型,这些数据类型往往并不符合已有通用函数的计算方式,而要计算这些新的数据类型需要修改原有通用函数的定义,从而极大降低了程序的复用性。通过定义新函数来操作新的数据类型可以避免频繁修改原有通用函数。但是,新函数定义中必然会有大量与原有通用函数功能相似的重复冗余代码,因此,引入"缺省情况"使得新函数的定义可以通过调用原有通用函数而获得,这样即不对原有函数造成影响,又极大简化了针对新类型书写相关函数的复杂程度。文中利用Camlp5工具对O′Caml语法进行扩展,在原有"泛型编程"的基础上引入了"缺省情况",使该语言书写的泛型函数更加清晰、不易出错,从而极大提高了O′Caml中"泛型编程"的稳定性和复用性。The main idea of generic programming is to design a generic algorithm that can be reused. The purpose is to improve reuse of shuttering. The efficiency of the generic function is equal to the function designed for some special data type. Generic programming can completely separate the algorithm and the data type, and make the function more flexible. While one is interested in generic behavior for the large part of the datatypes involved, some particular types should be treated in a special way. Some datatypes hold variables. When defining the function for these datatypes, one need the function definition about the type variables. An already existing type indexed function can be extended, by default case, and the new clause has no influence on the existing type-indexed function. This makes the definition on the new type simple. It shows the extension of the grammar of O' Carol according to some rules, which also introduces the idea of default case.

关 键 词:泛型编程 函数式程序设计 语法扩展 缺省情况 

分 类 号:TP312[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象