zoukankan      html  css  js  c++  java
  • 泛型编程沉思录—面向模版和参量化类型编程

    一、泛型的概念要素:

    模版类型 + 参量类型 + 类型约束 + 扩展;

    泛型编程是上述四个概念反复组合而形成的一种编程范式;

    泛型编程 = 模版类型 + 参量类型;

    模版类型:与引用类型无关的通用算法和结构;

    二、范型编程的目的:模版复用的复合类型

     产生功能模版复用的新类型;

    通过类型的组合产生新的类型;

    目的是通过类型组合产生新的类型;

    新类型的能力由模版类型和新类型双方决定;

    三、参量类型的选择与约束

     参量类型的选择:

    任意类型;

    约束类型、接口类型;

    参量类型本身是否参与运算;

    四、扩展、约束与随意多态

     随意多态 = 泛型+类型约束+扩展

    五、泛型与系统

    一个泛型模块就是一个系统;

    把握一个泛型的功能从两个方面入手:

    1、输入、输出;

    2、类型转换;

    Generic Programming is an Attitude¶

    From Mathematics to Generic Programming [SR14]

    Generic programming is an approach to programming that focuses on designing algorithms and data structures so that they work in the most general setting without loss of efficiency… Generic programming is more of an attitude toward programming than a particular set of tools.

    In that sense, it is important to think of generic programming as an interactive approach to uncover generality without compromising performance rather than as a set of rules

    As we will see, the core approach is to treat data structures and algorithms as loosely coupled, and is in direct contrast to the is-a approach of object-oriented programming

    https://lectures.quantecon.org/jl/generic_programming.html

  • 相关阅读:
    网络设备操作命令
    "Realtek PCIe GBE Family Controller"网卡抓带Vlan Tag的包
    ubuntu16.04 samba 配置
    readelf -s 命令‘symbol’名字显示不全
    APUE Unix环境高级编程读书笔记
    Jmeter之文件上传
    百度去广告chrome插件
    zookeeper的安装与使用
    spring中bean获取工具
    关于maven的一些记录
  • 原文地址:https://www.cnblogs.com/feng9exe/p/10984682.html
Copyright © 2011-2022 走看看