[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/3377555.3377901acmconferencesArticle/Chapter ViewAbstractPublication PagesccConference Proceedingsconference-collections
research-article

Relaxing the one definition rule in interpreted C++

Published: 24 February 2020 Publication History

Abstract

Most implementations of the C++ programming language generate binary executable code. However, interpreted execution of C++ sources has its own use cases as the Cling interpreter from CERN's ROOT project has shown. Some limitations are derived from the ODR (One Definition Rule) that rules out multiple definitions of entities within a single translation unit (TU). ODR is there to ensure uniform view of a given C++ entity across translation units. Ensuring uniform view of C++ entities helps when producing ABI compatible binaries. Interpreting C++ presumes a single ever-growing translation unit that define away some of the ODR use-cases. Therefore, it may well be desirable to relax the ODR and, consequently, to support the ability of developers to override any existing definition for a given declaration. This approach is especially well-suited for iterative prototyping. In this paper, we extend Cling, a Clang/LLVM-based C++ interpreter, to enable redefinitions of C++ entities at the prompt. To achieve this, top-level declarations are nested into inline namespaces and the translation unit lookup table is adjusted to invalidate previous definitions that would otherwise result in ambiguities. Formally, this technique refactors the code to an equivalent that does not violate the ODR, as each definition is nested in a different namespace. Furthermore, any previous definition that has been shadowed is still accessible by means of its fully-qualified name. A prototype implementation of the presented technique has been integrated into the Cling C++ interpreter, showing that our technique is feasible and usable.

Supplementary Material

Auxiliary Archive (cc20main-p125-p-aux.zip)
The `cc20main-p125-p_AE.pdf' file contains the Artifact appendix; the artifact itself may be downloaded from https://doi.org/10.5281/zenodo.3579301.

References

[1]
J. Akeret, L. Gamper, A. Amara, and A. Refregier. 2015. HOPE: A Python just-in-time compiler for astrophysical computations. Astronomy and Computing 10 (2015), 1 – 8.
[2]
I. Antcheva, M. Ballintijn, B. Bellenot, M. Biskup, R. Brun, N. Buncic, Ph. Canal, D. Casadei, O. Couet, V. Fine, L. Franco, G. Ganis, A. Gheata, D. Gonzalez Maline, M. Goto, J. Iwaszkiewicz, A. Kreshuk, D. Marcos Segura, R. Maunder, L. Moneta, A. Naumann, E. Offermann, V. Onuchin, S. Panacek, F. Rademakers, P. Russo, and M. Tadel. 2009. ROOT A C++ framework for petabyte data storage, statistical analysis and visualization. Computer Physics Communications 180, 12 (2009), 2499 – 2512.
[3]
Erik Azar and Mario Eguiluz Alebicto. 2016. Swift Data Structure and Algorithms. Packt Publishing.
[4]
Stefan Behnel, Robert Bradshaw, Craig Citro, Lisandro Dalcin, Dag Sverre Seljebotn, and Kurt Smith. 2011. Cython: The Best of Both Worlds. Computing in Science and Engg. 13, 2 (March 2011), 31–39.
[5]
Harry H. Cheng. 1993. Scientific Computing in the CH Programming Language. Scientific Programming 2, 3 (1993), 49–75.
[6]
QuantStack community. 2019. Xeus Cling. https://github.com/jupyterxeus/xeus-cling/
[7]
Steve Donovan. 2002. C++ by example (underc learning ed. ed.). Que, Indianapolis, IN. Accompanied by CD : CDR 01063.
[8]
Michael Foord and Christian Muirhead. 2009. IronPython in Action. Manning Publications Co., Greenwich, CT, USA.
[9]
Masaharu Goto. 1995. C++ Interpreter - CINT. CQ publishing.
[10]
ISO. 2017. ISO/IEC 14882:2017 Programming languages — C++. ISO, 1214 Vernier, Geneva, Switzerland. 1605 pages. https://isocpp.org/std/thestandard
[11]
Josh Juneau, Jim Baker, Frank Wierzbicki, Leo Soto, and Victor Ng. 2010. The Definitive Guide to Jython: Python for the Java Platform (1st ed.). Apress, Berkely, CA, USA.
[12]
Donald E. Knuth. 1968. Semantics of context-free languages. Mathematical systems theory 2, 2 (01 Jun 1968), 127–145.
[13]
Wim T.L.P. Lavrijsen and Aditi Dutta. 2016. High-performance PythonC++ bindings with PyPy and Cling. In PyHPC 16: Proceedings of the 6th Workshop on Python for High-Performance and Scientific Computing. IEEE Press.
[14]
Harri Luoma, Essi Lahtinen, and Hannu-Matti Järvinen. 2007. CLIP, a Command Line Interpreter for a Subset of C++. In Proceedings of the Seventh Baltic Sea Conference on Computing Education Research -Volume 88 (Koli Calling ’07). Australian Computer Society, Inc., Darlinghurst, Australia, Australia, 199–202. http://dl.acm.org/citation. cfm?id=2449323.2449351
[15]
James Martin. 1991. Rapid Application Development. Macmillan Publishing Co., Inc., Indianapolis, IN, USA.
[16]
Remigius Meier and Thomas R. Gross. 2019. Reflections on the Compatibility, Performance, and Scalability of Parallel Python. In Proceedings of the 15th ACM SIGPLAN International Symposium on Dynamic Languages (DLS 2019). ACM, New York, NY, USA, 91–103.
[17]
Martin Odersky and al. 2004. An Overview of the Scala Programming Language. Technical Report IC/2004/64. EPFL Lausanne, Switzerland.
[18]
T. E. Oliphant. 2007. Python for Scientific Computing. Computing in Science Engineering 9, 3 (May 2007), 10–20.
[19]
Guido Rossum. 1995. Python Reference Manual. Technical Report. Amsterdam, The Netherlands, The Netherlands.
[20]
PyPy Team. 2005. Complete python implementation running on top of cpython. Technical Report.
[21]
V Vasilev, Ph Canal, A Naumann, and P Russo. 2012. Cling – The New Interactive Interpreter for ROOT 6. Journal of Physics: Conference Series 396, 5 (dec 2012), 052071.

Cited By

View all
  • (2023)A Low-Level Virtual Machine Just-In-Time Prototype for Running an Energy-Saving Hardware-Aware Mapping Algorithm on C/C++ Applications That Use PthreadsEnergies10.3390/en1619678116:19(6781)Online publication date: 23-Sep-2023

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
CC 2020: Proceedings of the 29th International Conference on Compiler Construction
February 2020
222 pages
ISBN:9781450371209
DOI:10.1145/3377555
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication Notes

Badge change: Article originally badged under Version 1.0 guidelines https://www.acm.org/publications/policies/artifact-review-badging

Publication History

Published: 24 February 2020

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. C++
  2. Cling
  3. One-Definition-Rule
  4. interpreter

Qualifiers

  • Research-article

Funding Sources

  • Spanish Ministry of Economy and Competitiveness

Conference

CC '20
Sponsor:

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)23
  • Downloads (Last 6 weeks)3
Reflects downloads up to 14 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2023)A Low-Level Virtual Machine Just-In-Time Prototype for Running an Energy-Saving Hardware-Aware Mapping Algorithm on C/C++ Applications That Use PthreadsEnergies10.3390/en1619678116:19(6781)Online publication date: 23-Sep-2023

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media