Skip to main content

Safely Composable Type-Specific Languages

  • Conference paper
ECOOP 2014 – Object-Oriented Programming (ECOOP 2014)

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

Included in the following conference series:

Abstract

Programming languages often include specialized syntax for common datatypes (e.g. lists) and some also build in support for specific specialized datatypes (e.g. regular expressions), but user-defined types must use general-purpose syntax. Frustration with this causes developers to use strings, rather than structured data, with alarming frequency, leading to correctness, performance, security, and usability issues. Allowing library providers to modularly extend a language with new syntax could help address these issues. Unfortunately, prior mechanisms either limit expressiveness or are not safely composable: individually unambiguous extensions can still cause ambiguities when used together. We introduce type-specific languages (TSLs): logic associated with a type that determines how the bodies of generic literals, able to contain arbitrary syntax, are parsed and elaborated, hygienically. The TSL for a type is invoked only when a literal appears where a term of that type is expected, guaranteeing non-interference. We give evidence supporting the applicability of this approach and formally specify it with a bidirectionally typed elaboration semantics for the Wyvern programming language.

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 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

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Adams, M.D.: Principled parsing for indentation-sensitive languages: Revisiting Landin’s offside rule. In: Principles of Programming Languages (2013)

    Google Scholar 

  2. Bravenboer, M., Vermaas, R., Vinju, J.J., Visser, E.: Generalized type-based disambiguation of meta programs with concrete object syntax. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 157–172. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  3. Clark, T., Sammut, P., Willans, J.S.: Beyond annotations: A proposal for extensible Java (XJ). In: Source Code Analysis and Manipulation (2008)

    Google Scholar 

  4. de Rauglaudre, D.: Camlp4 - Reference Manual (2003), http://caml.inria.fr/pub/docs/manual-camlp4/

  5. Diekmann, L., Tratt, L.: Parsing composed grammars with language boxes. In: Workshop on Scalable Language Specification (2013)

    Google Scholar 

  6. Erdweg, S., Rendel, T., Kästner, C., Ostermann, K.: SugarJ: library-based language extensibility. In: Object-Oriented Programming Systems, Languages, and Applications (2011)

    Google Scholar 

  7. Erdweg, S., Rieger, F.: A framework for extensible languages. In: Generative Programming: Concepts & Experiences (2013)

    Google Scholar 

  8. Green, T., Petre, M.: Usability analysis of visual programming environments: A ‘cognitive dimensions’ framework. Journal of Visual Languages and Computing 7(2), 131–174 (1996)

    Article  Google Scholar 

  9. Harper, R.: Practical Foundations for Programming Languages. Cambridge University Press (2012)

    Google Scholar 

  10. Harper, R., Stone, C.: A Type-Theoretic Interpretation of Standard ML. In: Proof, Language and Interaction: Essays in Honour of Robin Milner. MIT Press (2000)

    Google Scholar 

  11. Ichikawa, K., Chiba, S.: Composable user-defined operators that can express user-defined literals. In: Modularity (2014)

    Google Scholar 

  12. JetBrains. JetBrains MPS – Meta Programming System, http://www.jetbrains.com/mps/

  13. Karakoidas, V.: On domain-specific languages usage (why DSLs really matter). Crossroads 20(3), 16–17 (2014)

    Article  Google Scholar 

  14. Kats, L.C.L., Visser, E.: The Spoofax language workbench: Rules for declarative specification of languages and IDEs. In: Object-Oriented Programming Systems, Languages, and Applications (2010)

    Google Scholar 

  15. Krishnan, L., Van Wyk, E.: Termination analysis for higher-order attribute grammars. In: Czarnecki, K., Hedin, G. (eds.) SLE 2012. LNCS, vol. 7745, pp. 44–63. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  16. Lee, B., Grimm, R., Hirzel, M., McKinley, K.S.: Marco: Safe, expressive macros for any language. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 589–613. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  17. Leroy, X.: Formal verification of a realistic compiler. Communications of the ACM (2009)

    Google Scholar 

  18. Loh, A., van der Storm, T., Cook, W.R.: Managed data: Modular strategies for data abstraction. In: Onward! (2012)

    Google Scholar 

  19. Microsoft Corporation. Expression Trees (C# and Visual Basic), http://msdn.microsoft.com/en-us/library/bb397951.aspx

  20. Miller, H., Haller, P., Burmako, E., Odersky, M.: Instant pickles: Generating object-oriented pickler combinators for fast and extensible serialization. In: Object Oriented Programming Systems, Languages & Applications (2013)

    Google Scholar 

  21. Möller, E.: SRFI-49: Indentation-sensitive syntax (2005), http://srfi.schemers.org/srfi-49/srfi-49.html

  22. Nistor, L., Kurilova, D., Balzer, S., Chung, B., Potanin, A., Aldrich, J.: Wyvern: A simple, typed, and pure object-oriented language. In: MechAnisms for SPEcialization, Generalization and Inheritance (2013)

    Google Scholar 

  23. Omar, C., Chung, B., Kurilova, D., Potanin, A., Aldrich, J.: Type-directed, whitespace-delimited parsing for embedded DSLs. In: Globalization of Domain Specific Languages (2013)

    Google Scholar 

  24. Omar, C., Kurilova, D., Nistor, L., Chung, B., Potanin, A., Aldrich, J.: Safely Composable Type-Specific Languages. Technical Report CMU-ISR-14-106, Carnegie Mellon University (2014)

    Google Scholar 

  25. Omar, C., Yoon, Y., LaToza, T.D., Myers, B.A.: Active code completion. In: International Conference on Software Engineering (2012)

    Google Scholar 

  26. OWASP. OWASP Top 10 2013 (2013), https://www.owasp.org/index.php/Top_10_2013-Top_10

  27. Palmer, Z., Smith, S.F.: Backstage Java: Making a Difference in Metaprogramming. In: Object-Oriented Programming Systems, Languages, and Applications (2011)

    Google Scholar 

  28. Pierce, B.C., Turner, D.N.: Local type inference. ACM Trans. Program. Lang. Syst. 22(1), 1–44 (2000)

    Article  Google Scholar 

  29. Schwerdfeger, A.C., Van Wyk, E.R.: Verifiable composition of deterministic grammars. In: Programming Language Design and Implementation (2009)

    Google Scholar 

  30. Sheard, T., Jones, S.: Template meta-programming for Haskell. ACM SIGPLAN Notices 37(12), 60–75 (2002)

    Article  Google Scholar 

  31. Stoy, J.E.: Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press, Cambridge (1977)

    Google Scholar 

  32. Tatsubori, M., Chiba, S., Killijian, M.-O., Itano, K.: OpenJava: A Class-based Macro System for Java. In: Cazzola, W., Houmb, S.H., Tisato, F. (eds.) Reflection and Software Engineering. LNCS, vol. 1826, pp. 117–133. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  33. Tempero, E., Anslow, C., Dietrich, J., Han, T., Li, J., Lumpe, M., Melton, H., Noble, J.: Qualitas corpus: A curated collection of Java code for empirical studies. In: Asia Pacific Software Engineering Conference (2010)

    Google Scholar 

  34. Tratt, L.: Domain specific language implementation via compile-time meta-programming. ACM Trans. Program. Lang. Syst. 30(6) (October 2008)

    Google Scholar 

  35. van den Brand, M.G.J.: Pregmatic: A Generator for Incremental Programming Environments. PhD thesis, Katholieke Universiteit Nijmegen (1992)

    Google Scholar 

  36. Van Wyk, E.R., Schwerdfeger, A.C.: Context-aware scanning for parsing extensible languages. In: Generative Programming and Component Engineering (2007)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Omar, C., Kurilova, D., Nistor, L., Chung, B., Potanin, A., Aldrich, J. (2014). Safely Composable Type-Specific Languages. In: Jones, R. (eds) ECOOP 2014 – Object-Oriented Programming. ECOOP 2014. Lecture Notes in Computer Science, vol 8586. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-44202-9_5

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-44202-9_5

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-662-44201-2

  • Online ISBN: 978-3-662-44202-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics