Skip to main content

Towards a Unified Language Architecture for Reversible Object-Oriented Programming

  • Conference paper
  • First Online:
Reversible Computation (RC 2021)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 12805))

Included in the following conference series:

Abstract

A unified language architecture for an advanced reversible object-oriented language is described. The design and implementation choices made for a tree-walking interpreter and source-language inverter are discussed, as well as the integration with an existing monadic parser, type checker and PISA compiler backend. A demonstration of the web interface and the interactions required to interpret, compile and invert reversible object-oriented programs is given. Our aim is that this platform will make reversible programming approachable to a wider community.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Source code host: https://github.com/haysch/ROOPLPP.

  2. 2.

    Web interface: https://topps.di.ku.dk/pirc/roopl-playground.

  3. 3.

    Source code [3, 10] rehosted at: https://github.com/TueHaulund/PendVM.

  4. 4.

    https://topps.di.ku.dk/pirc/janus-playgroundhttps://github.com/mbudde/jana.

References

  1. Cservenka, M.H.: Design and implementation of dynamic memory management in a reversible OO programming lang. Master’s thesis, University of Copenhagen (2018)

    Google Scholar 

  2. Cservenka, M.H., Glück, R., Haulund, T., Mogensen, T.Æ.: Data structures and dynamic memory management in reversible languages. In: Kari, J., Ulidowski, I. (eds.) RC 2018. LNCS, vol. 11106, pp. 269–285. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-99498-7_19

    Chapter  MATH  Google Scholar 

  3. Frank, M.P.: Reversibility for efficient computing. Ph.D. thesis, MIT (1999)

    Google Scholar 

  4. Glück, R., Yokoyama, T.: A linear-time self-interpreter of a reversible imperative language. Comput. Softw. 33(3), 108–128 (2016)

    Google Scholar 

  5. Haulund, T.: Design and implementation of a reversible object-oriented programming language. Master’s thesis, University of Copenhagen (2016)

    Google Scholar 

  6. Haulund, T., Mogensen, T.Æ., Glück, R.: Implementing reversible object-oriented language features on reversible machines. In: Phillips, I., Rahaman, H. (eds.) RC 2017. LNCS, vol. 10301, pp. 66–73. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-59936-6_5

    Chapter  MATH  Google Scholar 

  7. Mezzina, C.A., et al.: Software and reversible systems: a survey of recent activities. In: Ulidowski, I., Lanese, I., Schultz, U.P., Ferreira, C. (eds.) RC 2020. LNCS, vol. 12070, pp. 41–59. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-47361-7_2

    Chapter  Google Scholar 

  8. Schultz, U.P., Axelsen, H.B.: Elements of a reversible object-oriented language. In: Devitt, S., Lanese, I. (eds.) RC 2016. LNCS, vol. 9720, pp. 153–159. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-40578-0_10

    Chapter  MATH  Google Scholar 

  9. Thomsen, M.K., Axelsen, H.B., Glück, R.: A reversible processor architecture and its reversible logic design. In: De. Vos, A., Wille, R. (eds.) RC 2011. LNCS, vol. 7165, pp. 30–42. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-29517-1_3

    Chapter  Google Scholar 

  10. Vieri, C.J.: Rev. computer engineering and architecture. Ph.D. thesis, MIT (1999)

    Google Scholar 

  11. Yokoyama, T., Axelsen, H.B., Glück, R.: Towards a reversible functional language. In: De. Vos, A., Wille, R. (eds.) RC 2011. LNCS, vol. 7165, pp. 14–29. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-29517-1_2

    Chapter  MATH  Google Scholar 

  12. Yokoyama, T., Glück, R.: A reversible programming language and its invertible self-interpreter. In: PEPM Proceedings, pp. 144–153. ACM (2007)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Lasse Hay-Schmidt .

Editor information

Editors and Affiliations

A Binary Search Tree Example

A Binary Search Tree Example

The ROOPL example program in this appendix is provided for the interested reader. It is based on a binary search tree example [2] and accessible in the Examples tab of the web interface as Binary Tree using Array. A binary search tree allows fast look up of data items given a node value (the key). The example constructs a binary search tree by inserting new nodes while preserving the invariant that all node values in a node’s left subtree are smaller and those in the node’s right subtree are not smaller than the node’s value. In our example, the node values are stored in an array and then iteratively inserted into the tree. Given the node values 3, 4, 2, 1, the resulting tree can be seen in Fig. 3.

1.1 A.1 Example Program

Appendix A.2 contains the complete source code for the example program. The class Program defines the main method of our program (lines 40–63). The method main is the program’s entry point and creates a new binary search tree. A new object of class Tree is created by statement new Tree tree, which sets variable tree to the new object’s reference (line 46). Similarly, a new array nodeVals is created and initialized with our four example values (lines 47–52).

The iteration over the example array is performed by a reversible loop (lines 54–62). It asserts that the initial value of index variable x is 0 and its final value is nodeCount. The control-flow operators in ROOPL are those of Janus; e.g. see [12]. The paired statements local and delocal open and close the scope of a variable by specifying its initial and final value, e.g. x has the initial value 0 (line 53). All method calls and uncalls refer to an object, e.g. call node::setValue(nodeVals[x]) sends method setValue to object node with a parameter being the value of an element in array nodeVals (line 58).

Class Node defines a labeled node as containing an integer value and links to the roots of its left and right subtree (lines 2–4). Usually, this class also defines the variables for the data items stored in a node. If there is no subtree then the corresponding link is nil. The class defines two methods: setValue reversibly updates the label of a node and insertNode recursively inserts a new node with a value newValue. The latter performs a recursive descent over the left or right subtree depending on the node value to be inserted.

A reversible conditional has two predicates that are evaluated at run time: an entry test at if (e.g., nodeValue< value at line 10) and an exit assertion at fi (e.g., left != nil at line 17). After executing the then-branch, the assertion must evaluate to true, and after executing the else-branch, it must evaluate to false; otherwise, an error occurs and an exception is raised.

Finally, class Tree defines the root of a binary search tree and provides a method for inserting nodes into the search tree. More variables can be added to this class, e.g. the number of nodes in a tree. Which of the two insert methods defined in the classes Node and Tree is invoked depends on the class of the object to which it is sent (e.g. root::insertNode(...) vs. tree::insertNode(...)).

1.2 A.2 Source Code

figure a

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Hay-Schmidt, L., Glück, R., Cservenka, M.H., Haulund, T. (2021). Towards a Unified Language Architecture for Reversible Object-Oriented Programming. In: Yamashita, S., Yokoyama, T. (eds) Reversible Computation. RC 2021. Lecture Notes in Computer Science(), vol 12805. Springer, Cham. https://doi.org/10.1007/978-3-030-79837-6_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-79837-6_6

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-79836-9

  • Online ISBN: 978-3-030-79837-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics