Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

From ML to Ada: Strongly-typed language interoperability via source translation

Published: 01 July 1998 Publication History
  • Get Citation Alerts
  • Abstract

    We describe a system that supports source-level integration of ML-like functional language code with ANSI C or Ada83 code. The system works by translating the functional code into type-correct, ‘vanilla’ C or Ada; it offers simple, efficient, type-safe inter-operation between new functional code components and ‘legacy’ third-generation-language components. Our translator represents a novel synthesis of techniques including user-parameterized specification of primitive types and operators; removal of polymorphism by code specialization; removal of higher-order functions using closure datatypes and interpretation; and aggressive optimization of the resulting first-order code, which can be viewed as encoding the result of a closure analysis. Programs remain fully typed at every stage of the translation process, using only simple, standard type systems. Target code runs at speeds comparable to the output of current optimizing ML compilers, even though handicapped by a conservative garbage collector.

    References

    [1]
    Appel, A. W. (1992) Compiling with Continuations. Cambridge University Press.
    [2]
    Appel, A. W. and Jim, T. (1989) Continuation-passing, closure-passing style. 16th ACM Symp. on Principles of Programming Languages, pp. 293-302, New York. ACM Press.
    [3]
    Appel, A. W. and Jim, T. (1997) Shrinking lambda expressions in linear time. J. Functional Programming 7(5), 515-540.
    [4]
    Baker, H. G. (1990) Unify and conquer (garbage collection, updating, aliasing,.) in functional languages. Proc. 1990 ACM Conference on Lisp and Functional Programming, pp. 218-226.
    [5]
    Bell, J. M. (1994) An implementation of Reynold's defunctionalization method for a modern functional language. Master's thesis, Oregon Graduate Institute.
    [6]
    Bell, J. M., Bellegarde, F. and Hook, J. (1997) Type-driven defunctionalization. Proc. 2nd International Conference on Functional Programming, pp. 25-37.
    [7]
    Bellegarde, F. and Hook, J. (1994) Substitution: A formal methods case study using monads and transformations. Science of Computer Programming, 23(2-3), 287-311.
    [8]
    Boehm, H. -J. and Weiser, M. (1988) Garbage collection in an uncooperative environment. Software-Practice and Experience, 18(9), 807-820.
    [9]
    Bondorf, A. (1990) Automatic autoprojection of higher order recursive equations. Science of Computer Programming, 17(1-3), 3-34.
    [10]
    Bondorf, A. and Jørgensen, J. (1993) Efficient analyses for realistic off-line partial evaluation. J. Functional Programming, 3(3), 315-346.
    [11]
    Cardelli, L. (1984) Compiling a functional language. Proc. 1984 ACM Conference on Lisp and Functional Programming, pp. 208-217.
    [12]
    Cardelli, L. (1987) Basic polymorphic typechecking. Science of Computer Programming, 8, 147-172.
    [13]
    Chailloux, E. (1992) An efficient way of compiling ML to C. Proc. ACM Workshop on ML and its Applications, pp. 37-51.
    [14]
    Chin, W. -N. and Darlington, J. (1996) A higher order removal method. Lisp and Symbolic Computation, 9(4), 287-322.
    [15]
    Cridlig, R. (1992) An optimizing ML to C compiler. Proc. ACM Workshop on ML and its Applications, pp. 28-36.
    [16]
    Damas, L. (1984) Type Assignment in Programming Languages. PhD thesis, University of Edinburgh.
    [17]
    Flanagan, C., Sabry, A., Duba, B. F. and Felleisen, M. (1993) The essence of compiling with continuations. SIGPLAN Notices, 28(6), 237-247. (Proc. ACM SIGPLAN '93 Conference on Programming Language Design and Implementation.)
    [18]
    Hindley, R. (1969) The principal type-scheme of an object in combinatory logic. Trans. Am. Math. Soc., 146, 29-60.
    [19]
    Huelsbergen, L. (1996) A portable C interface for Standard ML of New Jersey. Available at http://cm.bell-labs.com/who/lorenz/papers/smlnj-c.ps.
    [20]
    Jagannathan, S. and Wright, A. K. (1996) Flow-directed inlining. Proc. ACM Conference on Programming Language Design and Implementation, pp. 193-205.
    [21]
    Jones, M. P. (1994) Dictionary-free overloading by partial evaluation. Proc. PEPM '94 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pp. 107-117.
    [22]
    Kelsey, R. A. (1995) A correspondence between continuation passing style and static single assignment form. Proc. ACM SIGPLAN Workshop on Intermediate Representations, pp. 13-22.
    [23]
    Kieburtz, R. B., Bellegarde, F., Bell, J., Hook, J., Lewis, J., Oliva, D., Sheard, T., Walton, L. and Zhou, T. (1995) Calculating software generators from solution specifications. TAPSOFT'95: Lecture Notes in Computer Science 915, pp. 546-560. Springer-Verlag.
    [24]
    Koch, M. and Olesen, T. H. (1996) Compiling a higher-order call-by-value functional programming language to a RISC using a stack of regions. Master's thesis, University of Copenhagen.
    [25]
    Kranz, D., Kelsey, R., Rees, J., Hudak, P., Philbin, J. and Adams, N. (1986) Orbit: An optimizing compiler for Scheme. SIGPLAN Notices, 21(7), 219-233. (Proc. ACM SIGPLAN '86 Symposium on Compiler Construction.)
    [26]
    Lawall, J. L. and Danvy, O. (1993) Separating stages in the continuation-passing style transformation. Conference Record of the Twentieth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 124-136, Charleston, SC.
    [27]
    Leroy, X. (1991) The ZINC experiment: an economical implementation of the ML language. Technical Report 117, INRIA, France.
    [28]
    Leroy, X. (1992) Unboxed object and polymorphic typing. Conference Record of the Nineteenth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 177-188.
    [29]
    Leroy, X. (1997) The Objective Caml System: Documentation and User's Manual, Version 1.07. INRIA, France.
    [30]
    Milner, R. (1978) A theory of type polymorphism in programming. J. Computer and System Sciences, 17, 348-375.
    [31]
    Milner, R., Tofte, M., Harper, R. and MacQueen, D. (1997) The Definition of Standard ML (Revised). MIT Press.
    [32]
    Minamide, Y., Morrisett, G. and Harper, R. (1996) Typed closure conversion. Conference Record of POPL '96: 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 271-283.
    [33]
    Morrisett, G. (1995) Compiling with Types. PhD thesis, Carnegie Mellon University. (Available as TR CMU-CS-95-226.)
    [34]
    Morrisett, G., Felleisen, M. and Harper, R. (1995) Abstract models of memory management. FPCA '95 SIGPLAN-SIGARCH-WG2.8 Conference on Functional Programming Languages and Computer Architecture, pp. 66-77.
    [35]
    Palsberg, J. (1995) Closure analysis in constraint form. ACM Trans. Programming Languages and Systems, 17(1), 47-62.
    [36]
    Peyton Jones, S. L. (1992) Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. J. Functional Programming, 127-202.
    [37]
    Peyton Jones, S. L. (1996) Compilation by transformation: A report from the trenches. Euro. Symposium on Programming (ESOP'96): Lecture Notes in Computer Science 1058, pp. 18-40. Springer-Verlag.
    [38]
    Peyton Jones, S. L., Hall, C., Hammond, K., Partain, W. and Wadler, P. (1993) The Glasgow Haskell compiler: a technical overview. Proc. UK Joint Framework for Information Technology (JFIT) Technical Conference, Keele.
    [39]
    Peyton Jones, S. L., Nordin, T. and Reid, A. (1997) Green Card: A foreign language interface for Haskell. Proc. ACM SIGLAN Haskell Workshop.
    [40]
    Reade, C. (1989) Elements of Functional Programming. Addison-Wesley.
    [41]
    Reynolds, J. C. (1972) Definitional interpreters for higher-order programming languages. In ACM National Conference, pp. 717-740. ACM.
    [42]
    Sestoft, P. (1988) Replacing function parameters by global variables. Master's thesis, University of Copenhagen. DIKU Master's thesis no. 254.
    [43]
    Shivers, O. (1991) Control-Flow Analysis of Higher-Order Languages. PhD thesis, Carnegie-Mellon University, Pittsburgh, PA. CMU-CS-91-145.
    [44]
    Steele, G. L. (1978) Rabbit: a compiler for Scheme. Technical Report AI-TR-474, MIT, Cambridge, MA.
    [45]
    Talpin, J. -P. and Jouvelot, P. (1992) Polymorphic type, region, and effect inference. J. Functional Programming, 2(3), 245-272.
    [46]
    Tarditi, D. (1996) Design and Implementation of Code Optimizations for a Type-Directed Compiler for Standard ML. PhD thesis, Carnegie Mellon University. Technical Report CMU-CS-97-108.
    [47]
    Tarditi, D., Lee, P. and Acharya, A. (1992). No assembly required: Compiling Standard ML to C. ACM Letters on Programming Languages and Systems, 1(2), 161-177.
    [48]
    Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R. and Lee, P. (1996) TIL: A type-directed optimizing compiler for ML. Proc. ACM SIGPLAN '96 Conference on Programming Language Design and Implementation, pp. 181-192.
    [49]
    Tofte, M., Birkedal, L., Elsman, M., Hallenberg, N., Olesen, T. H., Sestoft, P. and Bertelsen, P. (1997) Programming with regions in the ML Kit. Technical Report DIKU-TR-97/12, University of Copenhagen Department of Computer Science (DIKU).
    [50]
    Tofte, M. and Talpin, J.-P. (1997) Region-based memory management. Information and Computation, 132(2), 109-176.
    [51]
    Tolmach, A. (1997) Combining closure conversion with closure analysis using algebraic types. Workshop on Types in Compilation TIC97. Boston College Computer Science Technical Report BCCS-97-03.
    [52]
    Volpano, D. and Kieburtz, R. B. (1985) Software templates. Proc. 8th International Conference on Software Engineering, pp. 55-60. IEEE.
    [53]
    Volpano, D. and Kieburtz, R. B. (1989) The templates approach to software reuse. In: Biggesstaff, T. J. and Perlis, A. J., editors, Software Reusability, pp. 247-255. ACM Press.
    [54]
    Wadler, P. (1989) Theorems for free! Proc. 4th Int. Conf. on Functional Programming Languages and Computer Architecture, pp. 347-359.
    [55]
    Warren, D. (1982) Higher-order extensions to PROLOG: are they needed? In: Hayes, J., Michie, D. and Pao, Y.-H., editors, Machine Intelligence 10, pp. 441-454. Edinburgh University Press.
    [56]
    Wright, A. K. (1995) Simple imperative polymorphism. Lisp and Symbolic Computation, 8(4), 343-356.

    Cited By

    View all
    • (2024)Automatic Parallelism ManagementProceedings of the ACM on Programming Languages10.1145/36328808:POPL(1118-1149)Online publication date: 5-Jan-2024
    • (2023)Defunctionalization with Dependent TypesProceedings of the ACM on Programming Languages10.1145/35912417:PLDI(516-538)Online publication date: 6-Jun-2023
    • (2023)Tail Recursion Modulo Context: An Equational ApproachProceedings of the ACM on Programming Languages10.1145/35712337:POPL(1152-1181)Online publication date: 11-Jan-2023
    • Show More Cited By

    Index Terms

    1. From ML to Ada: Strongly-typed language interoperability via source translation
        Index terms have been assigned to the content through auto-classification.

        Recommendations

        Comments

        Information & Contributors

        Information

        Published In

        cover image Journal of Functional Programming
        Journal of Functional Programming  Volume 8, Issue 4
        July 1998
        125 pages

        Publisher

        Cambridge University Press

        United States

        Publication History

        Published: 01 July 1998

        Qualifiers

        • Article

        Contributors

        Other Metrics

        Bibliometrics & Citations

        Bibliometrics

        Article Metrics

        • Downloads (Last 12 months)0
        • Downloads (Last 6 weeks)0
        Reflects downloads up to 11 Aug 2024

        Other Metrics

        Citations

        Cited By

        View all
        • (2024)Automatic Parallelism ManagementProceedings of the ACM on Programming Languages10.1145/36328808:POPL(1118-1149)Online publication date: 5-Jan-2024
        • (2023)Defunctionalization with Dependent TypesProceedings of the ACM on Programming Languages10.1145/35912417:PLDI(516-538)Online publication date: 6-Jun-2023
        • (2023)Tail Recursion Modulo Context: An Equational ApproachProceedings of the ACM on Programming Languages10.1145/35712337:POPL(1152-1181)Online publication date: 11-Jan-2023
        • (2022)Analyzing binding extent in 3CPSProceedings of the ACM on Programming Languages10.1145/35476456:ICFP(650-678)Online publication date: 31-Aug-2022
        • (2020)Type- and Control-Flow Directed DefunctionalizationProceedings of the 32nd Symposium on Implementation and Application of Functional Languages10.1145/3462172.3462193(79-92)Online publication date: 2-Sep-2020
        • (2020)Featherweight goProceedings of the ACM on Programming Languages10.1145/34282174:OOPSLA(1-29)Online publication date: 13-Nov-2020
        • (2020)The history of Standard MLProceedings of the ACM on Programming Languages10.1145/33863364:HOPL(1-100)Online publication date: 12-Jun-2020
        • (2018)Finitary polymorphism for optimizing type-directed compilationProceedings of the ACM on Programming Languages10.1145/32367762:ICFP(1-29)Online publication date: 30-Jul-2018
        • (2017)Compiling without continuationsACM SIGPLAN Notices10.1145/3140587.306238052:6(482-494)Online publication date: 14-Jun-2017
        • (2017)Compiling without continuationsProceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3062341.3062380(482-494)Online publication date: 14-Jun-2017
        • Show More Cited By

        View Options

        View options

        Get Access

        Login options

        Media

        Figures

        Other

        Tables

        Share

        Share

        Share this Publication link

        Share on social media