Multi-stage programming with functors and monads: Eliminating abstraction overhead from generic code

被引:20
|
作者
Carette, Jacques [1 ]
Kiselyov, Oleg [2 ]
机构
[1] McMaster Univ, Dept Comp & Software, Hamilton, ON L8S 4K1, Canada
[2] FNMOC, Monterey, CA 93943 USA
基金
加拿大自然科学与工程研究理事会;
关键词
MetaOCaml; Linear algebra; Genericity; Generative; Staging; Functor; Symbolic; LANGUAGES; SYSTEMS;
D O I
10.1016/j.scico.2008.09.008
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
We use multi-stage programming, monads and Ocaml's advanced module system to demonstrate how to eliminate all abstraction overhead from generic programs, while avoiding any inspection of the resulting code. We demonstrate this clearly with Gaussian Elimination as a representative family of symbolic and numeric algorithms. We parameterize our code to a great extent - over domain, input and permutation matrix representations, determinant and rank tracking, pivoting policies, result types, etc. - at no run-time cost. Because the resulting code is generated just right and not changed afterward, MetaOCaml guarantees that the generated code is well-typed. We further demonstrate that various abstraction parameters (aspects) can be made orthogonal and compositional, even in the presence of name-generation for temporaries, and "interleaving" of aspects. We also show how to encode some domain-specific knowledge so that "clearly wrong" compositions can be rejected at or before generation time, rather than during the compilation or running of the generated code. (C) 2008 Elsevier B.V. All rights reserved.
引用
收藏
页码:349 / 375
页数:27
相关论文
共 50 条
  • [41] Dynamic programming algorithms for multi-stage safety stock optimization
    Minner, S
    OR SPEKTRUM, 1997, 19 (04) : 261 - 271
  • [42] Dynamic Programming Model for Multi-Stage Reliability Growth Planning
    Xu, Dong
    Li, Zhaojun 'Steven'
    2019 IEEE INTERNATIONAL CONFERENCE ON PROGNOSTICS AND HEALTH MANAGEMENT (ICPHM), 2019,
  • [43] Fuzzy multi-stage De-Novo programming problem
    Chen, Yuh-Wen
    Hsieh, Hung-En
    APPLIED MATHEMATICS AND COMPUTATION, 2006, 181 (02) : 1139 - 1147
  • [44] Supply chain planning using multi-stage stochastic programming
    Nagar, Lokesh
    Jain, Karuna
    SUPPLY CHAIN MANAGEMENT-AN INTERNATIONAL JOURNAL, 2008, 13 (03) : 251 - 256
  • [45] Metaphor: A multi-stage, object-oriented programming language
    Neverov, Gregory
    Roe, Paul
    Lect. Notes Comput. Sci., (168-185):
  • [46] Dynamic programming algorithms for multi-stage safety stock optimization
    Minner S.
    Operations-Research-Spektrum, 1997, 19 (4) : 261 - 271
  • [47] OPTIMAL DESIGN OF MULTI-STAGE FLASH EVAPORATORS BY DYNAMIC PROGRAMMING
    ITAHARA, S
    STIEL, LI
    DESALINATION, 1968, 4 (02) : 248 - &
  • [48] Lane recognition method using multi-stage dynamic programming
    Gao, Dezhi
    Duan, Jianmin
    Yang, Lei
    Yang, Xining
    Jixie Gongcheng Xuebao/Journal of Mechanical Engineering, 2011, 47 (08): : 141 - 145
  • [49] Metaphor: A multi-stage, object-oriented programming language
    Neverov, G
    Roe, P
    GENERATIVE PROGRAMMING AND COMPONENT ENGINEERING 2004, PROCEEDINGS, 2004, 3286 : 168 - 185
  • [50] A multi-stage stochastic programming approach in master production scheduling
    Koerpeoglu, Ersin
    Yaman, Hande
    Akturk, M. Selim
    EUROPEAN JOURNAL OF OPERATIONAL RESEARCH, 2011, 213 (01) : 166 - 179