Electrical Engineering
      and Computer Sciences

Electrical Engineering and Computer Sciences

COLLEGE OF ENGINEERING

UC Berkeley

Type-Safe Compilation of Covariant Specialization: A Practical Case

John Boyland and Giuseppe Castagna

EECS Department
University of California, Berkeley
Technical Report No. UCB/CSD-95-890
November 1995

http://www.eecs.berkeley.edu/Pubs/TechRpts/1995/CSD-95-890.pdf

Despite its lack of type safety, some typed object-oriented languages use covariant specialization for methods. In this work, we show how one may modify the semantics of languages that use covariant specialization in order to improve their type safety. We demonstrate our technique using O2, a strongly and statically typed object-oriented database programming language which uses covariant specialization. We propose a modification to the O2 compiler that adds code to correct previously ill-typed computations that arise from the use of covariant specialization. The modification we propose does not affect the semantics of those computations without type errors. Furthermore, the new semantics of the previously ill-typed computations is defined in a very "natural" way and ensures the type safety (w.r.t. covariance) of the program. Since the solution consists of a conservative backward-compatible modification of the compiler, it does not require, unlike other solutions, any modification of existing O2 code. Our solution is based solely on a type-theoretic analysis and thus is general. Therefore, although this paper applies it to a particular programming language, the same ideas could easily be applied to other languages that uses covariant specialization.


BibTeX citation:

@techreport{Boyland:CSD-95-890,
    Author = {Boyland, John and Castagna, Giuseppe},
    Title = {Type-Safe Compilation of Covariant Specialization: A Practical Case},
    Institution = {EECS Department, University of California, Berkeley},
    Year = {1995},
    Month = {Nov},
    URL = {http://www.eecs.berkeley.edu/Pubs/TechRpts/1995/5737.html},
    Number = {UCB/CSD-95-890},
    Abstract = {Despite its lack of type safety, some typed object-oriented languages use covariant specialization for methods. In this work, we show how one may modify the semantics of languages that use covariant specialization in order to improve their type safety. We demonstrate our technique using O2, a strongly and statically typed object-oriented database programming language which uses covariant specialization. We propose a modification to the O2 compiler that adds code to correct previously ill-typed computations that arise from the use of covariant specialization. The modification we propose does not affect the semantics of those computations without type errors. Furthermore, the new semantics of the previously ill-typed computations is defined in a very "natural" way and ensures the type safety (w.r.t. covariance) of the program. Since the solution consists of a conservative backward-compatible modification of the compiler, it does not require, unlike other solutions, any modification of existing O2 code. Our solution is based solely on a type-theoretic analysis and thus is general. Therefore, although this paper applies it to a particular programming language, the same ideas could easily be applied to other languages that uses covariant specialization.}
}

EndNote citation:

%0 Report
%A Boyland, John
%A Castagna, Giuseppe
%T Type-Safe Compilation of Covariant Specialization: A Practical Case
%I EECS Department, University of California, Berkeley
%D 1995
%@ UCB/CSD-95-890
%U http://www.eecs.berkeley.edu/Pubs/TechRpts/1995/5737.html
%F Boyland:CSD-95-890