首页 | 本学科首页   官方微博 | 高级检索  
相似文献
 共查询到19条相似文献,搜索用时 140 毫秒
1.
对于泛型程序设计来说,类型理论中的参数化多态是其理论框架,因为参数化多态引入了类型变量,使得类型参数化,从而完全支持类型上的抽象.然而对于现行的泛型算法,无论是C 标准模版库中的泛型算法还是基于函数式程序设计语言的算法,函数功能的定义比较具体化、单一化,因而缺乏可扩展性和高度的复用性.将对递归算法进行抽象,构造原始递归构造子,使得一般的泛型算法都可以通过该算子来构造,从而加强泛型算法的可复用型与可扩展性.除此之外,分析了递归算法构造子与泛型程序设计中的iterator概念和用于描叙泛型概念的形式化语言Tecton中所提倡的reuse概念的一致性.也给出算法复杂度的定量分析,并用函数式语言ML来实现.  相似文献   

2.
对于泛型程序设计来说,类型的参数化多态是其理论框架,参数化多态引入了类型变量,使得类型参数化,支持类型上的抽象,从而可以大大提高软件的复用程度。泛型编程思想已经在多种语言中得到运用,并已取得了不小的成果。在函数式语言上进行泛型的研究与应用,Haskell语言是函数式语言中较为经典的一种语言,它的计算模型简单,语法清晰,易于编写,易于维护,拥有很大的发展空间。利用一些规则对Haskell语言的语法进行相关扩展,同时引入泛型的思想,研究与运用定义泛型函数的方法,在Haskell语言上实现了泛型功能。  相似文献   

3.
王朋  徐健  于尚超 《微机发展》2013,(7):92-95,100
泛型编程旨在编写一般化并可重复使用的算法,主要目的是提高程序的复用性,其效率与针对某特定数据类型而设计的算法相同。泛型编程可以使算法与数据结构完全分离,极大提高了程序的灵活性。在O’Caml语言中已经实现了类型标记函数和泛型函数,但泛型函数的类型参数只能是基本类型或实例化类型,不能使用抽象类型。"泛型抽象"是指使用抽象类型作为类型参数的函数定义方法,实现了"泛型编程"类型参数的多样化。文中在O’Caml语言上进行"泛型抽象"的研究,根据规则对O’Caml语言语法进行扩展,并在O’Caml语言中实现了"泛型抽象"函数定义。  相似文献   

4.
泛型编程旨在编写一般化并可重复使用的算法,主要目的是提高程序的复用性,其效率与针对某特定数据类型而设计的算法相同.泛型编程可以使算法与数据结构完全分离,极大提高了程序的灵活性.在O'Caml语言中已经实现了类型标记函数和泛型函数,但泛型函数的类型参数只能是基本类型或实例化类型,不能使用抽象类型.“泛型抽象”是指使用抽象类型作为类型参数的函数定义方法,实现了“泛型编程”类型参数的多样化.文中在O'Caml语言上进行“泛型抽象”的研究,根据规则对O'Caml语言语法进行扩展,并在O'Caml语言中实现了“泛型抽象”函数定义.  相似文献   

5.
基于源代码静态分析的C++0x泛型概念抽取   总被引:1,自引:0,他引:1  
使用泛型概念对领域知识进行抽象是泛型程序设计方法的基础.在新的C++0x标准中泛型概念将成为一个新的语言设施,这将为设计可复用、可扩展的泛型软件提供坚实的基础.为了更好地利用C++0x的新特性,有必要识别C++遗产代码中的泛型概念,并通过重构得到符合C++0x标准的代码.文中提出了一种基于代码静态分析的泛型概念自动识别方法,通过对泛型程序中类型参数的使用分析,从遗产代码中提取有效表达式约束和关联类型约束,进而推导出泛型概念.将该方法应用于C++标准模板库STL,可以识别出STL算法中绝大部分潜在的泛型概念,表明该方法有助于识别遗产代码中的泛型概念.  相似文献   

6.
泛型即通过参数化类型来实现在同一份代码上操作多种数据类型.泛型编程是一种编程范式,它利用“参数化类型”将类型抽象化,实现灵活的软件复用.泛型编程思想已经在多种语言中得到运用,并已取得了不小的成果.文中旨在Haskell语言上进行泛型的研究与应用,Haskell语言是一门广为流行的函数式语言,它的计算模型简单,程序语法清晰,易于编写,易于维护.文中利用一些规则对Haskell语言的语法进行扩展,同时引入泛型编程的思想来研究新的函数定义方法,最后在Haskell语言上实现泛型功能.  相似文献   

7.
刘未鹏 《程序员》2007,(12):90-92
动态多态与静态多态泛型编程的核心活动是抽象:将一个特定干某些类型的算法中那些类型无关的共性抽象出来,比如,在STL的概念体系里面,管你是一个数组还是一个链表,反正都是一个区间,这就是一层抽象。管你是一个内建函数还是一个自定义类,反正都是一个Callable(可调用)的对象(在C++里面通过仿函数来表示),这就是一层抽象。泛型编程的过程就是一个不断将这些抽象提升(lift)出来的过程,最终的目的是形成一个最大程度上通用的算法或类。  相似文献   

8.
面向对象、泛型程序设计与类型约束检查   总被引:7,自引:0,他引:7  
孙斌 《计算机学报》2004,27(11):1492-1504
该文对面向对象和泛型程序设计(generic programming)的核心思想和方法进行了较为深入的分析.阐明了各自的目标、技术特征及其优缺点所在.介绍了泛型程序设计针对对象技术的不足所引进的重大革新,即通过类型需求抽象来设计通用、高效的数据结构和算法;着重论述了作者在进一步增强泛型程序设计实际运用方面所提出的改进工作.以C 语言的一个泛型编程扩充语言C**为实施例,详细说明了如何通过一种叫做“命名类型约束”的新的机制来比较完整地实现静态类型需求的直接语言支持和编译检查,为当前泛型程序设计模型的首例编程语言实例.  相似文献   

9.
泛型编程是面向对象的进一步发展,从更高的角度对世界进行抽象,为面向对象的不足之处提供了解决之道.它可让你重复运用既有的算法,而不必在环境类似的情况下再重新撰写相同代码,使得处理的问题更加抽象化,是一种优美而又不失效率的通用型程序设计方法.JDK 1.5中引入了对Java语言的多种扩展,泛型(generics)即其中之一.本文讨论JDK 1.5的泛型实现.  相似文献   

10.
左正康  薛锦云 《软件学报》2015,26(6):1340-1355
泛型程序设计可大幅提高程序的可重用性、可靠性和开发效率.泛型约束机制是对泛型参数进行形式描述,并对其合法性进行检测及验证,从而保证泛型程序的可靠性和安全性.分析总结多种主流语言的泛型约束特性,存在难以描述及验证基于动态语义的复杂约束需求问题,与完整实现GP尚有距离;以抽象程序设计语言Apla为宿主语言,提出了基于代数结构及公理语义的泛型约束方法,给出了基本数据类型、自定义抽象数据类型和子程序的3类泛型约束机制,拓展了泛型程序设计约束的应用范围.同时,支持静态语法和动态语义层约束,提高了泛型约束的精确度;借助Isabelle定理证明器,设计了泛型约束匹配检测和验证算法;进一步设计了泛型约束机制在PAR平台的实现方案及其系统原型.实验部分给出了该泛型约束机制描述、检测及验证一系列复杂泛型约束问题的全过程,自动生成的C++模板程序的可靠性和安全性得到显著提高.  相似文献   

11.
Generic programming has been defined as ‘programming with concepts’ where a concept refers to a family of abstractions. The criteria for generic programming include independence of collections from data types, independence of algorithms that operate on the collection, and the adaptability of the collections. This paper examines and evaluates the support for generic programming in the Java Development Kit (JDK) in comparison to C++'s Standard Template Library (STL). The evaluation will consider both the ‘qualitative’ factors as well as certain ‘quantitative’ factors (i.e. factors that can be measured). The qualitative factors that are considered include: 1. a comparison of the structure and APIs; 2. homogeneity versus heterogeneity; and 3. ease of use (including ease of converting to collection classes, ease of changing collection type, and ease of error handling). The quantitative factors include: 1. compiled size; 2. runtime memory usage; and 3. performance. The results of our evaluative comparisons based on the above factors and certain other criteria are presented at the end. Based on the results, we conclude that the support provided for generic programming in C++'s STL is superior to that provided by JDK. Copyright © 2003 John Wiley & Sons, Ltd.  相似文献   

12.
设计模式和泛型技术在系统重构中的应用研究   总被引:1,自引:0,他引:1  
重构是在不改变代码外在行为的前提下,对代码做出修改,以改进程序内部结构的过程.设计模式是对被用来在特定场景下解决一般设计问题的类和相互通信的对象的描述.泛型编程专注于将型别抽象化,形成功能需求方面的一个精细集合,并利用这些需求来实现算法.以一个应用系统的数据采集子系统的系统重构为例,将设计模式应用于系统重构中设计阶段,将泛型技术应用于系统重构实现阶段;讨论设计模式技术和泛型技术的结合对系统重构的作用与意义.  相似文献   

13.
The Lambda Library (LL) adds a form of lambda functions to C++, which are common in functional programming languages. The LL is implemented as a template library using standard C++; thus no language extensions or preprocessing is required. The LL consists of a rich set of tools for defining unnamed functions. In particular these unnamed functions work seamlessly with the generic algorithms in the C++ Standard Library. The LL offers significant improvements, in terms of generality and ease of use, compared to the current tools in the C++ Standard Library. Copyright © 2003 John Wiley & Sons, Ltd.  相似文献   

14.
Generic programming is an especially attractive paradigm for developing libraries for high-performance computing because it simultaneously emphasizes generality and efficiency. In the generic programming approach, interfaces are based on sets of specified requirements on types, rather than on any particular types, allowing algorithms to inter-operate with any data types meeting the necessary requirements. These sets of requirements, known as concepts, can specify syntactic as well as semantic requirements. Besides providing a powerful means of describing interfaces to maximize software reuse, concepts provide a uniform mechanism for more closely coupling libraries with compilers and for effecting domain-specific library-based compiler extensions. To realize this goal however, programming languages and their associated tools must support concepts as first-class constructs. In this paper we advocate better syntactic and semantic support to make concepts first-class and present results demonstrating the kinds of improvements that are possible with static checking, compiler optimization, and algorithm correctness proofs for generic libraries based on concepts.  相似文献   

15.
O’Caml语言是一门优秀的函数式程序语言,具有计算模型简单、语法语义描述清晰等特点,而通用编程技术方法通过高度抽象算法、数据结构及其他软件组件可以避免功能相似代码的重复编写。针对如何将通用编程技术方法和O’Caml语言相结合来提高O’Caml程序复用程度的问题,通过对O’Caml语言语法进行扩展引入类型标记1函数,然后运用类型结构化转换和类型映射机制,实现通用函数,从而达到在O’Caml语言中引入通用编程技术的目的。实例结果表明,在O’Caml语言中实现通用编程技术,有效提高了编程效率和程序的通用性。  相似文献   

16.
本文就如何运用泛化思维进行可复用设计进行了研究,介绍了泛化的相关重要概念,并对泛化思维在设计模式中的应用进行了探索,最后以一种模式为例详细介绍了如何设计泛化模式。  相似文献   

17.
In C++, multi‐dimensional arrays are often used but the language provides limited native support for them. The language, in its Standard Library, supplies sophisticated interfaces for manipulating sequential data, but relies on its bare‐bones C heritage for arrays. The MultiArray library, a part of the Boost library collection, enhances a C++ programmer's tool set with versatile multi‐dimensional array abstractions. It includes a general array class template and native array adaptors that support idiomatic array operations and interoperate with C++ Standard Library containers and algorithms. The arrays share a common interface, expressed as a generic programming concept, in terms of which generic array algorithms can be implemented. We present the library design, introduce a generic interface for array programming, demonstrate how the arrays integrate with the C++ Standard Library, and discuss the essential aspects of their implementation. Copyright © 2004 John Wiley & Sons, Ltd.  相似文献   

18.
本文就如何运用泛化思维进行可复用设计进行了研究,介绍了泛化的相关重要概念,并对泛化思维在设计模式中的应用进行了探索.最后以一种模式为例详细介绍了如何设计泛化模式。  相似文献   

19.
In object programming languages, the Visitor design pattern allows separation of algorithms and data structures. When applying this pattern to tree‐like structures, programmers are always confronted with the difficulty of making their code evolve. One reason is that the code implementing the algorithm is interwound with the code implementing the traversal inside the visitor. When implementing algorithms such as data analyses or transformations, encoding the traversal directly into the algorithm turns out to be cumbersome as this type of algorithm only focuses on a small part of the data‐structure model (e.g., program optimization). Unfortunately, typed programming languages like Java do not offer simple solutions for expressing generic traversals. Rewrite‐based languages like ELAN or Stratego have introduced the notion of strategies to express both generic traversal and rule application control in a declarative way. Starting from this approach, our goal was to make the notion of strategic programming available in a widely used language such as Java and thus to offer generic traversals in typed Java structures. In this paper, we present the strategy language SL that provides programming support for strategies in Java. Copyright © 2012 John Wiley & Sons, Ltd.  相似文献   

设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号