Skip to main content
Log in

Intermediate Representation of Programs with Type Specification Based on Pattern Matching

  • Published:
Programming and Computer Software Aims and scope Submit manuscript

Abstract

In this paper, we present an intermediate representation (IR) language for the concise and generalized description of type system specification features in dynamically typed programming languages. The intermediate representation is based on pattern matching and features type-level computation. It is inspired by the intermediate representation “Assembly language” for Refal-2. In contrast to “Assembly language,” the proposed representation is based on the control flow graph, which preserves typing information, rather than on bytecode. In addition, we propose a modification of the Refal language that supports higher-order functions, closures, and “associative array” data type, as well as a transpiler of programs from the language into the intermediate representation. In terms of this language, we present two examples of type system specification: simple types and row polymorphism. These examples are of interest for describing type systems for dynamically typed programming languages.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1.
Fig. 2.
Fig. 3.
Fig. 4.
Fig. 5.
Fig. 6.
Fig. 7.
Fig. 8.
Fig. 9.

Similar content being viewed by others

REFERENCES

  1. Hufschmidt, T., A type-system for Nix. http://nixcon2017.org/schedule.nixcon2017.org/system/event_attachments/attachments/000/000/003/original/main.pdf.

  2. Siek, J. and Taha, W., Gradual typing for objects, Proc. European Conf. on Object-Oriented Programming (ECOOP), Ernst, E., Ed., Berlin: Springer, 2007, pp. 2–27.

  3. Levkivskyi, I., Lehtosalo, J., and Langa, L., PEP 544 – Protocols: Structural subtyping (static duck typing). http://www.python.org/dev/peps/pep-0544. Accessed January 10, 2019.

  4. Turchin, V.F., Meta-algorithmic language, Kibernetika, 1968, no. 4, pp. 45–54.

  5. Turchin, V.F., REFAL-5: Programming Guide and Reference Manual, Holyoke: New England, 1989.

  6. Vasenin, V.A. and Krivchikov, M.A., Methods for intermediate representation of programs, Program. Inzheneriya, 2017, vol. 8, no. 8, pp. 345–353.

    Article  Google Scholar 

  7. Romanenko, S.A., Machine-independent compiler from the recursive function language, Cand. Sci. (Fiz.-Mat.) Dissertation, Moscow: Inst. Prikl. Mat. Keldysha, 1978.

  8. Nemytykh, A.P., Superkompilyator SCP-4: obshchaya struktura (SCP-4 Supercompiler: General Structure), Moscow: Izd-vo LKI, 2007.

  9. Romanenko, S.A. and Gurin, R.F., Yazyk programmirovaniya Refal Plyus (Refal Plus Programming Language), Pereslavl’-Zalesskii: Univ. Pereslavlya im. A.K. Ailamazyana, 2006.

  10. Turchin, V.F., Ekvivalentnye preobrazovaniya rekursivnykh funktsii, opisannykh na yazyke REFAL (Equivalent Transformations of Recursive Functions Described in the REFAL Language), Kiev-Alushta, 1972, pp. 31–42.

    Google Scholar 

  11. Wand, M., Type inference for record concatenation and multiple inheritance, Inf. Comput., 1991, vol. 93, no. 1, pp. 1–15.

    Article  MathSciNet  Google Scholar 

  12. Stefik, A. and Siebert, S., An empirical investigation into programming language syntax, Trans. Comput. Educ., 2013, vol. 13, no. 4, pp. 19:1–19:40.

  13. Shelekhov, V.I., Verification and synthesis of efficient programs of standard functions in the predicate programming technology, Program. Inzheneriya, 2011, no. 2, pp. 14–21.

  14. Lisitsa, A.P. and Nemytykh, A.P., Verification as a parameterized testing (experiments with the SCP4 supercompiler), Program. Comput. Software, 2007, vol. 33, no. 1, pp. 14–23.

    Article  Google Scholar 

  15. Lisitsa, A.P. and Nemytykh, A.P., On one application of computations with oracle, Program. Comput. Software, 2010, vol. 36, no. 3, pp. 157–165.

    Article  MathSciNet  Google Scholar 

  16. Klyuchnikov, I.G. and Romanenko, S.A., Supercompilation for Martin-Lof’s type theory, Program. Comput. Software, 2015, vol. 41, no. 3, pp. 170–182.

    Article  MathSciNet  Google Scholar 

  17. Novikov, F.A. and Novoseltsev, V.B., Interpretable program specification language, Program. Comput. Software, 2010, vol. 36, no. 1, pp. 48–57.

    Article  MathSciNet  Google Scholar 

  18. Shankar, N. and Owre, S., Principles and pragmatics of subtyping in PVS, Recent Trends in Algebraic Development Techniques, Bert, D., Choppy, C., and Mosses, P.D., Eds., Springer, 1999, vol. 1827, pp. 37–52.

    MATH  Google Scholar 

Download references

Funding

This work was supported by the Russian Foundation for Basic Research, project no. 16-07-01178a.

Author information

Authors and Affiliations

Authors

Corresponding authors

Correspondence to V. A. Vasenin or M. A. Krivchikov.

Additional information

Translated by Yu. Kornienko

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Vasenin, V.A., Krivchikov, M.A. Intermediate Representation of Programs with Type Specification Based on Pattern Matching. Program Comput Soft 46, 57–66 (2020). https://doi.org/10.1134/S0361768820010077

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1134/S0361768820010077

Navigation