{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,10,2]],"date-time":"2026-10-02T07:49:08Z","timestamp":1790927348510,"version":"4.1.0"},"reference-count":93,"publisher":"Association for Computing Machinery (ACM)","issue":"4","content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["ACM Trans. Program. Lang. Syst."],"published-print":{"date-parts":[[2025,12,31]]},"abstract":"<jats:p>Inheritance is a key concept in many programming languages. Dynamically typed languages, such as JavaScript, often support powerful forms of dynamic inheritance. However, dynamic inheritance poses significant challenges for static typing. Most statically typed languages only provide static inheritance to achieve type safety at the cost of flexibility.<\/jats:p>\n                  <jats:p>\n                    This article presents a compiler for the CP language, which is a\n                    <jats:italic toggle=\"yes\">statically<\/jats:italic>\n                    typed language that supports\n                    <jats:italic toggle=\"yes\">dynamic<\/jats:italic>\n                    inheritance via a merge operator and also has an expressive form of parametric polymorphism. The merge operator enables a form of multiple inheritance and first-class classes, as well as virtual classes and family polymorphism. With these features, CP allows the development of highly modular and loosely coupled components. However, the efficient compilation of CP code is non-trivial, especially if separate compilation is desired. In particular, subtyping in CP is coercive for type safety, which poses significant challenges in obtaining an efficient compilation scheme. We show how CP is compilable to languages supporting extensible records or similar data structures, where record labels are generated from types for efficient lookup on merges. The main ideas of the compilation scheme are formalized in Coq and proven to be type-safe. The concrete implementation of the CP compiler targets JavaScript, where records are modeled as JavaScript objects. We conduct an empirical evaluation with various benchmarks and evaluate the impact of several CP-specific optimizations. With our optimizations, CP can be orders of magnitude faster than with a naive compilation scheme for merges, obtaining performance on par with class-based JavaScript programs.\n                  <\/jats:p>","DOI":"10.1145\/3765518","type":"journal-article","created":{"date-parts":[[2025,10,3]],"date-time":"2025-10-03T16:08:36Z","timestamp":1759507716000},"page":"1-70","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":1,"title":["Type-Safe Compilation of Dynamic Inheritance via Merging"],"prefix":"10.1145","volume":"47","author":[{"ORCID":"https:\/\/orcid.org\/0000-0002-7011-2441","authenticated-orcid":false,"given":"Yaozhu","family":"Sun","sequence":"first","affiliation":[{"name":"The University of Hong Kong, Hong Kong, China and National Institute of Informatics, Tokyo, Japan"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-8496-491X","authenticated-orcid":false,"given":"Xuejing","family":"Huang","sequence":"additional","affiliation":[{"name":"The University of Hong Kong, Hong Kong, China and Universit\u00e9 Paris Cit\u00e9, Paris, France"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-1846-7210","authenticated-orcid":false,"given":"Bruno C. D. S.","family":"Oliveira","sequence":"additional","affiliation":[{"name":"The University of Hong Kong, Hong Kong, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2025,12,15]]},"reference":[{"key":"e_1_3_3_2_1","doi-asserted-by":"publisher","unstructured":"Jo\u00e3o Alpuim Bruno C. d.\u00a0S. Oliveira and Zhiyuan Shi. 2017. Disjoint polymorphism. In ESOP. DOI: 10.1007\/978-3-662-54434-1_1","DOI":"10.1007\/978-3-662-54434-1_1"},{"key":"e_1_3_3_3_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-37521-7"},{"key":"e_1_3_3_4_1","doi-asserted-by":"publisher","DOI":"10.5381\/jot.2009.8.5.c5"},{"key":"e_1_3_3_5_1","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2011.120"},{"key":"e_1_3_3_6_1","doi-asserted-by":"publisher","DOI":"10.1007\/11561347_10"},{"key":"e_1_3_3_7_1","doi-asserted-by":"publisher","DOI":"10.1007\/11687061_5"},{"key":"e_1_3_3_8_1","doi-asserted-by":"publisher","DOI":"10.2307\/2273659"},{"key":"e_1_3_3_9_1","doi-asserted-by":"publisher","DOI":"10.1145\/236337.236343"},{"key":"e_1_3_3_10_1","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2004.23"},{"key":"e_1_3_3_11_1","doi-asserted-by":"publisher","DOI":"10.1007\/s00236-012-0173-z"},{"key":"e_1_3_3_12_1","doi-asserted-by":"publisher","DOI":"10.4230\/LIPIcs.ECOOP.2018.9"},{"key":"e_1_3_3_13_1","doi-asserted-by":"publisher","DOI":"10.4230\/LIPIcs.ECOOP.2018.22"},{"key":"e_1_3_3_14_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-030-17184-1_14"},{"key":"e_1_3_3_15_1","doi-asserted-by":"publisher","DOI":"10.4230\/LIPIcs.TLCA.2015.107"},{"key":"e_1_3_3_16_1","doi-asserted-by":"publisher","DOI":"10.1145\/97945.97982"},{"key":"e_1_3_3_17_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-14107-2_20"},{"key":"e_1_3_3_18_1","doi-asserted-by":"publisher","DOI":"10.1002\/j.1096-9942.1995.tb00019.x"},{"key":"e_1_3_3_19_1","volume-title":"Foundations of Object-Oriented Languages: Types and Semantics","author":"Bruce Kim\u00a0B.","year":"2002","unstructured":"Kim\u00a0B. Bruce. 2002. Foundations of Object-Oriented Languages: Types and Semantics. MIT press."},{"key":"e_1_3_3_20_1","doi-asserted-by":"publisher","DOI":"10.1006\/inco.1999.2829"},{"key":"e_1_3_3_21_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0960129500000049"},{"key":"e_1_3_3_22_1","doi-asserted-by":"publisher","DOI":"10.1145\/6041.6042"},{"key":"e_1_3_3_23_1","volume-title":"The Design and Implementation of the SELF Compiler, An Optimizing Compiler for Object-Oriented Programming Languages","author":"Chambers Craig","year":"1992","unstructured":"Craig Chambers. 1992. The Design and Implementation of the SELF Compiler, An Optimizing Compiler for Object-Oriented Programming Languages. Ph.\u2009D. Dissertation. Stanford University."},{"key":"e_1_3_3_24_1","doi-asserted-by":"publisher","DOI":"10.1145\/1218563.1218578"},{"key":"e_1_3_3_25_1","doi-asserted-by":"publisher","DOI":"10.1145\/74878.74922"},{"key":"e_1_3_3_26_1","doi-asserted-by":"publisher","DOI":"10.1145\/96709.96721"},{"key":"e_1_3_3_27_1","doi-asserted-by":"publisher","DOI":"10.1145\/115372.115320"},{"key":"e_1_3_3_28_1","doi-asserted-by":"publisher","DOI":"10.1007\/s00236-017-0293-6"},{"key":"e_1_3_3_29_1","first-page":"381","volume-title":"Indag. Math. (Proceedings)","volume":"75","author":"Bruijn N.\u00a0G. de","year":"1972","unstructured":"N.\u00a0G. de Bruijn. 1972. Lambda Calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indag. Math. (Proceedings) 75, 5 (1972), 381\u2013392. DOI: 10.1016\/1385-7258(72)90034-0"},{"key":"e_1_3_3_30_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-49538-X_13"},{"key":"e_1_3_3_31_1","doi-asserted-by":"publisher","DOI":"10.1145\/1119479.1119483"},{"key":"e_1_3_3_32_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796813000270"},{"key":"e_1_3_3_33_1","doi-asserted-by":"publisher","DOI":"10.1145\/3450952"},{"key":"e_1_3_3_34_1","unstructured":"ECMA. 1999. ECMA-262 3rd Edition ECMAScript Language Specification. Retrieved from https:\/\/ecma-international.org\/wp-content\/uploads\/ECMA-262_3rd_edition_december_1999.pdf"},{"key":"e_1_3_3_35_1","unstructured":"ECMA. 2015. ECMA-262 6th Edition ECMAScript 2015 Language Specification. Retrieved from https:\/\/262.ecma-international.org\/6.0\/"},{"key":"e_1_3_3_36_1","doi-asserted-by":"publisher","DOI":"10.7146\/dpb.v29i549.7654"},{"key":"e_1_3_3_37_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-45337-7_17"},{"issue":"3","key":"e_1_3_3_38_1","first-page":"191","article-title":"Safe dynamic multiple inheritance","volume":"9","author":"Ernst Erik","year":"2002","unstructured":"Erik Ernst. 2002. Safe dynamic multiple inheritance. Nordic J. Comput. 9, 3 (2002), 191\u2013208.","journal-title":"Nordic J. Comput"},{"key":"e_1_3_3_39_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-540-30554-5_11"},{"key":"e_1_3_3_40_1","doi-asserted-by":"publisher","DOI":"10.1145\/1111037.1111062"},{"key":"e_1_3_3_41_1","doi-asserted-by":"publisher","DOI":"10.4230\/LIPIcs.ECOOP.2022.18"},{"key":"e_1_3_3_42_1","volume-title":"A Polymorphic Type System for Extensible Records and Variants","author":"Gaster Benedict\u00a0R.","year":"1996","unstructured":"Benedict\u00a0R. Gaster and Mark\u00a0P. Jones. 1996. A Polymorphic Type System for Extensible Records and Variants. Technical Report NOTTCS-TR-96-3. University of Nottingham."},{"key":"e_1_3_3_43_1","doi-asserted-by":"publisher","DOI":"10.1145\/317636.317797"},{"key":"e_1_3_3_44_1","doi-asserted-by":"publisher","DOI":"10.1145\/3428217"},{"key":"e_1_3_3_45_1","doi-asserted-by":"publisher","DOI":"10.1109\/MC.2008.123"},{"key":"e_1_3_3_46_1","doi-asserted-by":"publisher","DOI":"10.1145\/99583.99603"},{"key":"e_1_3_3_47_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796821000186"},{"key":"e_1_3_3_48_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSR.1998.685738"},{"key":"e_1_3_3_49_1","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0057013"},{"key":"e_1_3_3_50_1","doi-asserted-by":"publisher","DOI":"10.1145\/503502.503505"},{"key":"e_1_3_3_51_1","doi-asserted-by":"publisher","DOI":"10.1016\/0167-6423(94)00005-0"},{"key":"e_1_3_3_52_1","doi-asserted-by":"publisher","DOI":"10.1145\/3649836"},{"key":"e_1_3_3_53_1","doi-asserted-by":"publisher","DOI":"10.1145\/2019136.2019142"},{"key":"e_1_3_3_54_1","doi-asserted-by":"publisher","DOI":"10.4230\/LIPIcs.ECOOP.2015.174"},{"key":"e_1_3_3_55_1","volume-title":"First-Class Labels for Extensible Rows","author":"Leijen Daan","year":"2004","unstructured":"Daan Leijen. 2004. First-Class Labels for Extensible Rows. Technical Report UU-CS-2004-051. Utrecht University."},{"key":"e_1_3_3_56_1","article-title":"Extensible records with scoped labels","author":"Leijen Daan","year":"2005","unstructured":"Daan Leijen. 2005. Extensible records with scoped labels. In TFP.","journal-title":"TFP"},{"key":"e_1_3_3_57_1","doi-asserted-by":"publisher","DOI":"10.1007\/11531142_8"},{"key":"e_1_3_3_58_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.ic.2012.10.020"},{"key":"e_1_3_3_59_1","doi-asserted-by":"publisher","DOI":"10.1145\/74877.74919"},{"key":"e_1_3_3_60_1","volume-title":"Object-Oriented Programming in the BETA Programming Language","author":"Madsen Ole\u00a0Lehrmann","year":"1993","unstructured":"Ole\u00a0Lehrmann Madsen, Birger M\u00f8ller-Pedersen, and Kristen Nygaard. 1993. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley."},{"key":"e_1_3_3_61_1","doi-asserted-by":"publisher","DOI":"10.1145\/3428274"},{"key":"e_1_3_3_62_1","doi-asserted-by":"publisher","DOI":"10.1145\/504282.504298"},{"key":"e_1_3_3_63_1","unstructured":"Microsoft. 2012. TypeScript. Retrieved from https:\/\/www.typescriptlang.org"},{"key":"e_1_3_3_64_1","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0054099"},{"key":"e_1_3_3_65_1","doi-asserted-by":"publisher","DOI":"10.1145\/1028976.1028986"},{"key":"e_1_3_3_66_1","doi-asserted-by":"publisher","DOI":"10.1145\/1167473.1167476"},{"key":"e_1_3_3_67_1","doi-asserted-by":"publisher","DOI":"10.1145\/1094811.1094815"},{"key":"e_1_3_3_68_1","doi-asserted-by":"publisher","DOI":"10.1145\/218570.218572"},{"key":"e_1_3_3_69_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-31057-7_2"},{"key":"e_1_3_3_70_1","doi-asserted-by":"publisher","DOI":"10.1145\/2951913.2951945"},{"key":"e_1_3_3_71_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-39038-8_2"},{"key":"e_1_3_3_72_1","volume-title":"Types and Programming Languages","author":"Pierce Benjamin\u00a0C.","year":"2002","unstructured":"Benjamin\u00a0C. Pierce. 2002. Types and Programming Languages. MIT Press."},{"key":"e_1_3_3_73_1","doi-asserted-by":"publisher","DOI":"10.1145\/345099.345100"},{"key":"e_1_3_3_74_1","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0053389"},{"key":"e_1_3_3_75_1","doi-asserted-by":"publisher","DOI":"10.1145\/2660193.2660237"},{"key":"e_1_3_3_76_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-1-4612-4118-8_9"},{"key":"e_1_3_3_77_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796807006405"},{"key":"e_1_3_3_78_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-15579-6_6"},{"key":"e_1_3_3_79_1","doi-asserted-by":"publisher","DOI":"10.1145\/3122948.3122949"},{"key":"e_1_3_3_80_1","doi-asserted-by":"publisher","DOI":"10.1145\/360204.360230"},{"key":"e_1_3_3_81_1","doi-asserted-by":"publisher","DOI":"10.1145\/2518189"},{"key":"e_1_3_3_82_1","volume-title":"Compositional Programming in Action","author":"Sun Yaozhu","year":"2025","unstructured":"Yaozhu Sun. 2025. Compositional Programming in Action. Ph.\u2009D. Dissertation. The University of Hong Kong. Retrieved from https:\/\/hub.hku.hk\/handle\/10722\/358307"},{"key":"e_1_3_3_83_1","doi-asserted-by":"publisher","DOI":"10.1145\/3563294"},{"key":"e_1_3_3_84_1","doi-asserted-by":"publisher","DOI":"10.2307\/2271658"},{"key":"e_1_3_3_85_1","doi-asserted-by":"publisher","DOI":"10.1145\/243439.243441"},{"key":"e_1_3_3_86_1","doi-asserted-by":"publisher","DOI":"10.1145\/2384616.2384674"},{"key":"e_1_3_3_87_1","doi-asserted-by":"publisher","DOI":"10.1145\/38765.38828"},{"key":"e_1_3_3_88_1","unstructured":"Philip Wadler. 1998. The expression problem. Posted on the Java Genericity mailing list. Retrieved from https:\/\/homepages.inf.ed.ac.uk\/wadler\/papers\/expression\/expression.txt"},{"key":"e_1_3_3_89_1","doi-asserted-by":"publisher","DOI":"10.1016\/0890-5401(91)90050-C"},{"key":"e_1_3_3_90_1","doi-asserted-by":"publisher","DOI":"10.4230\/LIPIcs.ECOOP.2020.27"},{"key":"e_1_3_3_91_1","doi-asserted-by":"publisher","DOI":"10.1145\/3571224"},{"key":"e_1_3_3_92_1","article-title":"Independently Extensible Solutions to the Expression Problem","author":"Zenger Matthias","year":"2005","unstructured":"Matthias Zenger and Martin Odersky. 2005. Independently Extensible Solutions to the Expression Problem. In FOOL@POPL.","journal-title":"FOOL@POPL"},{"key":"e_1_3_3_93_1","doi-asserted-by":"publisher","DOI":"10.1145\/3460228"},{"key":"e_1_3_3_94_1","doi-asserted-by":"publisher","DOI":"10.1145\/3133894"}],"container-title":["ACM Transactions on Programming Languages and Systems"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3765518","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,12,16]],"date-time":"2025-12-16T07:23:30Z","timestamp":1765869810000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3765518"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2025,12,15]]},"references-count":93,"journal-issue":{"issue":"4","published-print":{"date-parts":[[2025,12,31]]}},"alternative-id":["10.1145\/3765518"],"URL":"https:\/\/doi.org\/10.1145\/3765518","relation":{},"ISSN":["0164-0925","1558-4593"],"issn-type":[{"value":"0164-0925","type":"print"},{"value":"1558-4593","type":"electronic"}],"subject":[],"published":{"date-parts":[[2025,12,15]]},"assertion":[{"value":"2024-06-22","order":0,"name":"received","label":"Received","group":{"name":"publication_history","label":"Publication History"}},{"value":"2025-07-23","order":2,"name":"accepted","label":"Accepted","group":{"name":"publication_history","label":"Publication History"}},{"value":"2025-12-15","order":3,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}