Strongly typed languages (like C, Java, etc.) provide very useful
about possible errors in code. Similarly, high-level, un-typed
languages like R, Matlab, Perl, Python avoid the need for
declarations, allow reuse of variable names, and generally make
interactive and prototyping use more productive and rapid. Ousterhout
wrote about the difference between the two. The Omegahat language and
several other languages have explored a potentially much richer
framework which represents a compromise between the two extremes -
optional typing. Essentially, we can add information about
parameter and return types for functions if we know it. Otherwise, we
can omit it. This can apply to individual parameters or individual
combinations of inputs. Developers that provide type information are
rewarded by having the interpreter perform run-time checking. The
information also can be used potentially in compilation
(e.g. generating byte code). And, importantly, it makes it
significantly easier or even feasible to export the functions to other
languages and computational interfaces. By annotating R functions, we
can export methodology to other languages in an automated manner.
The OptionalTyping package provides a prototype mechanism
of specifying optional type information about
parameters and return values of R functions.
In addition to merely specifying the types to
aid relectance and the generation of interfaces to these
functions, the package also provides an implementation
entirely in R of a type checking mechanism.
This allows us to experiment with and express different
semantics for the type validation.
Software
R Package - OptionalTyping_0.1-0.tar.gz
This can be installed as a regular R package:
R CMD INSTALL OptionalTyping_0.1-0.tar.gz
Documentation
-
- Some thoughts on aspects of the optional
typing approach
-
Duncan Temple Lang
<duncan@wald.ucdavis.edu>
Last modified: Fri Sep 30 21:44:35 PDT 2005