The design and implementation of implicit parameters to support function polymorphism

Loading...
Thumbnail Image
Date
1997-05-01T00:00:00Z
Authors
Dueck, Jason O.
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
In a programming language, functions that can be invoked with different numbers of arguments, different types of arguments, or can return results of different types are called polymorphic functions. An overview of polymorphism in modern languages is given. Partial valuation is a program optimization process which exploits values known at compile-time with the goal of producing a faster and sometimes smaller program. In the Safer$\sb{-}$C language, variables, parameters, and functions can be assigned an evaluation time by the programmer. When one or more parameters of a function have an evaluation time of compile-time, the function may be specialized for their values. Function specialization is one of the means through which Safer$\sb{-}$C will support function polymorphism. This thesis describes three new developments in this area: (1) Syntax for declaring implicit formal parameters, (2) Boolean conditions for type inference, and (3) Type manipulation functions. An extension of function specialization has been developed which allows functions to be specialized for types, as well as for values. Compile-time type and value information may be provided explicitly by the programmer, or it may be described abstractly in an implicit formal parameter list. An implicit parameter passing mechanism obtains the types and values described in such lists from the site of each function invocation. The programmer may place constraints on the specialization process by defining a conditional type matching expression for any explicit parameter. Such constraints provide a means to validate type-specific aspects of each function invocation. They also give the compiler a mechanism to support function overloading. Conditional type matching expressions and the implicit parameter passing mechanism were made possible through the creation of a set of compile-time type manipulation functions. These functions accept types as parameters and return a type or value as their result.
Description
Keywords
Citation