Revisiting Parametric Types and Virtual Classes

  • Anders Bach Madsen
  • Erik Ernst
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6141)


This paper presents a conceptually oriented updated view on the relationship between parametric types and virtual classes. The traditional view is that parametric types excel at structurally oriented composition and decomposition, and virtual classes excel at specifying mutually recursive families of classes whose relationships are preserved in derived families. Conversely, while class families can be specified using a large number of F-bounded type parameters, this approach is complex and fragile; and it is difficult to use traditional virtual classes to specify object composition in a structural manner, because virtual classes are closely tied to nominal typing. This paper adds new insight about the dichotomy between these two approaches; it illustrates how virtual constraints and type refinements, as recently introduced in gbeta and Scala, enable structural treatment of virtual types; finally, it shows how a novel kind of dynamic type check can detect compatibility among entire families of classes.


Virtual Object Parametric Type Type Member Class Family Type Constraint 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Agesen, O., Freund, S.N., Mitchell, J.C.: Adding type parameterization to the Java language. In: Proceedings of OOPSLA ’97, pp. 49–65 (1997)Google Scholar
  2. 2.
    Altherr, P.: A typed intermediate language and algorithms for compiling scala by successive rewritings. PhD thesis, EPFL (2006),
  3. 3.
    Aracic, I., Gasiunas, V., Mezini, M., Ostermann, K.: An overview of CaesarJ. In: Rashid, A., Aksit, M. (eds.) Transactions on Aspect-Oriented Software Development I. LNCS, vol. 3880, pp. 135–173. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  4. 4.
    Bracha, G., Odersky, M., Stoutamire, D., Wadler, P.: Making the future safe for the past: adding genericity to the Java programming language. In: Proceedings of OOPSLA ’98, pp. 183–200 (1998)Google Scholar
  5. 5.
    Bruce, K.B., Odersky, M., Wadler, P.: A statically safe alternative to virtual types. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 523–549. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  6. 6.
    Canning, P., Cook, W., Hill, W., Olthoff, W.: F-bounded polymorphism for object-oriented programming. In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture ’89, pp. 273–280 (1989)Google Scholar
  7. 7.
    Ernst, E.: gbeta – a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Department of Computer Science, Aarhus University, Århus, Denmark (1999)Google Scholar
  8. 8.
    Ernst, E.: Propagating class and method combination. In: Guerraoui, R. (ed.) ECOOP 1999. LNCS, vol. 1628, pp. 67–91. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  9. 9.
    Ernst, E.: Family polymorphism. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 303–326. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  10. 10.
    Ernst, E.: Higher-order hierarchies. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 303–329. Springer, Heidelberg (2003)Google Scholar
  11. 11.
    Ernst, E.: Reconciling virtual classes with genericity. In: Lightfoot, D.E., Szyperski, C. (eds.) JMLC 2006. LNCS, vol. 4228, pp. 57–72. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  12. 12.
    Ernst, E., Ostermann, K., Cook, W.R.: A virtual class calculus. In: Proceedings of POPL ’06, pp. 270–282 (2006)Google Scholar
  13. 13.
    Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 3rd edn. Addison-Wesley, Reading (May 2005)Google Scholar
  14. 14.
    Herrmann, S.: Object teams: Improving modularity for crosscutting collaborations. In: Proceedings of Net. Object days, pp. 248–264 (2002)Google Scholar
  15. 15.
    Herrmann, S., Herrmann, S., Hundt, C., Hundt, C., Mehner, K., Mehner, K.: Translation polymorphism in object teams. Technical report, Technical University Berlin (2004)Google Scholar
  16. 16.
    Kennedy, A., Syme, D.: Design and implementation of generics for common language runtime. SIGPLAN Not. 36(5), 1–12 (2001)CrossRefGoogle Scholar
  17. 17.
    Madsen, O.L., Møller-Pedersen, B.: Virtual classes: A powerful mechanism in object-oriented programming. In: Proceedings of OOPSLA ’89, pp. 397–406 (1989)Google Scholar
  18. 18.
    Madsen, O.L., Nygaard, K., Møller-Pedersen, B.: Object-Oriented Programming in The Beta Programming Language. Addison-Wesley, Reading (1993)Google Scholar
  19. 19.
    Mezini, M., Ostermann, K.: Conquering aspects with Caesar. In: Proceedings of AOSD ’03, pp. 90–99 (2003)Google Scholar
  20. 20.
    Moors, A., Piessens, F., Odersky, M.: Generics of a higher kind. In: Proceedings of OOPSLA ’08, pp. 423–438 (2008)Google Scholar
  21. 21.
    Myers, A.C., Bank, J.A., Liskov, B.: Parameterized types for Java. In: Proceedings of POPL ’97, pp. 132–145 (1997)Google Scholar
  22. 22.
    Nielsen, A.B., Ernst, E.: Optimizing dynamic class composition in a statically typed language. In: Paige, R.F., Meyer, B. (eds.) TOOLS EUROPE 2008. LNBIP, vol. 11, pp. 161–177. Springer, Heidelberg (1974)Google Scholar
  23. 23.
    Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: OOPSLA ’04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pp. 99–115 (2004)Google Scholar
  24. 24.
    Nystrom, N., Qi, X., Myers, A.C.: J&: nested intersection for scalable software composition. In: Proceedings of OOPSLA ’06, pp. 21–36 (2006)Google Scholar
  25. 25.
    Nystrom, N., Saraswat, V., Palsberg, J., Grothoff, C.: Constrained types for object-oriented languages. In: Proceedings of OOPSLA ’08, pp. 457–474 (2008)Google Scholar
  26. 26.
    Odersky, M.: The Scala Language Specification. EPFL, Version 2.7 edn. (March 2009)Google Scholar
  27. 27.
    Odersky, M., Cremet, V., Röckl, C., Zenger, M.: A nominal theory of objects with dependent types. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 201–224. Springer, Heidelberg (2003)Google Scholar
  28. 28.
    Odersky, M., Wadler, P.: Pizza into Java: translating theory into practice. In: Proceedings of POPL ’97, pp. 146–159 (1997)Google Scholar
  29. 29.
    Odersky, M., Zenger, M.: Independently extensible solutions to the expression problem. In: Proc. FOOL 12 (January 2005)Google Scholar
  30. 30.
    Qi, X., Myers, A.C.: Sharing classes between families. In: Proceedings of PLDI ’09, pp. 281–292 (2009)Google Scholar
  31. 31.
    Russo, C.V.: First-class structures for Standard ML. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 336–350. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  32. 32.
    Saito, C., Igarashi, A., Viroli, M.: Lightweight family polymorphism*. Journal of Functional Programming 18(3), 285–331 (2008)zbMATHCrossRefMathSciNetGoogle Scholar
  33. 33.
    Ullman, J.D.: Elements of ML programming (ML97 ed.). Prentice-Hall, Inc, Upper Saddle River (1998)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Anders Bach Madsen
    • 1
  • Erik Ernst
    • 1
  1. 1.Department of Computer ScienceAarhus UniversityDenmark

Personalised recommendations