Abstract
The Go programming language is an increasingly popular language but some of its features lack a formal investigation. This article explains Go’s resolution mechanism for overloaded methods and its support for structural subtyping by means of translation from Featherweight Go to a simple target language. The translation employs a form of dictionary passing known from type classes in Haskell and preserves the dynamic behavior of Featherweight Go programs.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Technically, we are passing around interface-values wrapping dictionaries of methods.
- 2.
References
Ahmed, A.: Step-indexed syntactic logical relations for recursive and quantified types. In: Sestoft, P. (ed.) ESOP 2006. LNCS, vol. 3924, pp. 69–83. Springer, Heidelberg (2006). https://doi.org/10.1007/11693024_6
Alpern, B., Cocchi, A., Fink, S.J., Grove, D., Lieber, D.: Efficient implementation of java interfaces: invokeinterface considered harmless. In: Proceedings of OOPSLA 2001, ACM (2001)
Bottu, G.J., Xie, N., Marntirosian, K., Schrijvers, T.: Coherence of type class resolution. Proc. ACM Program. Lang. 3(ICFP), 1–28 (2019)
Chambers, C.: Object-oriented multi-methods in Cecil. In: Madsen, O.L. (ed.) ECOOP 1992. LNCS, vol. 615, pp. 33–56. Springer, Heidelberg (1992). https://doi.org/10.1007/BFb0053029
Driesen, K., Hölzle, U.: The direct cost of virtual function calls in C++. In: Proceedings of OOPSLA 1996, ACM (1996)
Gosling, J., et al.: The Java Language Specification, Java SE 16 edn (2021). https://docs.oracle.com/javase/specs/jls/se16/html/index.html
Griesemer, R., et al.: Featherweight go. Proc. ACM Program. Lang. 4(OOPSLA), 1–29 (2020)
Hall, C.V., Hammond, K., Peyton Jones, S.L., Wadler, P.L.: Type classes in Haskell. ACM Trans. Program. Lang. Syst. 18(2), 109–132 (1996)
Peyton Jones, S., Weirich, S., Eisenberg, R.A., Vytiniotis, D.: A reflection on types. In: Lindley, S., McBride, C., Trinder, P., Sannella, D. (eds.) A List of Successes That Can Change the World. LNCS, vol. 9600, pp. 292–317. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-30936-1_16
Läufer, K.: Type classes with existential types. J. Funct. Prog. 6(3), 485–518 (1996)
Malayeri, D., Aldrich, J.: Integrating nominal and structural subtyping. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 260–284. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-70592-5_12
Marlow, S.: Haskell 2010 language report (2010). https://www.haskell.org/onlinereport/haskell2010/
Mitchell, J.C., Plotkin, G.D.: Abstract types have existential type. ACM Trans. Program. Lang. Syst. 10(3), 470–502 (1988)
Morris, J.G.: A simple semantics for Haskell overloading. In: Proceedings of Haskell 2014, New York, ACM (2014)
Pierce, B.: Types and Programming Languages, 1st edn. MIT Press, Cambridge (2002)
Plotkin, G.: Lambda-definability and logical relations. Unpublished manuscript (1973)
Reppy, J.H.: Concurrent ML: design, application and semantics. In: Functional Programming, Concurrency, Simulation and Automated Reasoning, pp. 165–198. Springer, Heidelberg (1993)
Steele, G.L.: Common LISP: The Language, 2nd edn. Digital Press, Amsterdam (1990)
Sulzmann, M., Chakravarty, M.M.T., Jones, S.P., Donnelly, K.: System F with type equality coercions. In: Proceedings of TLDI 2007, New York, ACM (2007)
Tait, W.W.: Intensional interpretations of functionals of finite type I. J. Symb. Log. 32(2), 198–212 (1967)
Thatte, S.R.: Semantics of type classes revisited. In: Proceedings of LISP 1994, pp. 208–219. ACM (1994)
The Go programming language (2021). https://golang.org
Thiemann, P., Wehr, S.: Interface types for Haskell. In: Ramalingam, G. (ed.) APLAS 2008. LNCS, vol. 5356, pp. 256–272. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-89330-1_19
Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proceedings of POPL 1989, New York, ACM (1989)
Acknowledgments
We thank the APLAS’21 reviewers for their helpful and constructive feedback.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Sulzmann, M., Wehr, S. (2021). A Dictionary-Passing Translation of Featherweight Go. In: Oh, H. (eds) Programming Languages and Systems. APLAS 2021. Lecture Notes in Computer Science(), vol 13008. Springer, Cham. https://doi.org/10.1007/978-3-030-89051-3_7
Download citation
DOI: https://doi.org/10.1007/978-3-030-89051-3_7
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-89050-6
Online ISBN: 978-3-030-89051-3
eBook Packages: Computer ScienceComputer Science (R0)