Reflections in Opal - Meta Information in a Functional Programming Language

We report on an extension of the Opal system that allows the use of reflections. Using reflections, a programmer can query information like the type of an object at runtime. The type can in turn be queried for properties like the constructor and deconstructor functions, and the resulting reflected functions can be evaluated. These facilities can be used for generic meta-programming. We describe the reflection interface of Opal and its applications, and sketch the implementation. For an existing language implementation like Opal’s the extension by a reflection facility is challenging: in a statically typed language the management of runtime type information seems to be an alien objective. However, it turns out that runtime type information can be incorporated in an elegant way by a source-level transformation and an appropriate set of library modules. We show how this transformation can be done without changing the Opal core system and causing runtime overhead only where reflections are actually used.

[1]  Martin Wirsing,et al.  Algebraic Specification , 1991, Handbook of Theoretical Computer Science, Volume B: Formal Models and Sematics.

[2]  J. Van Leeuwen,et al.  Handbook of theoretical computer science - Part A: Algorithms and complexity; Part B: Formal models and semantics , 1990 .

[3]  José Meseguer,et al.  Principles of OBJ2 , 1985, POPL.

[4]  Wolfgang Grieskamp,et al.  OPAL: Design and Implementation of an Algebraic Programming Language , 1994, Programming Languages and System Architectures.

[5]  Martín Abadi,et al.  Dynamic typing in polymorphic languages , 1995, Journal of Functional Programming.

[6]  Peter Pepper Funktionale Programmierung in OPAL, ML, HASKELL und GOFER , 1999, Springer-Lehrbuch.

[7]  Marco Pil Dynamic Types and Type Dependent Functions , 1998, IFL.

[8]  Wolfgang Grieskamp,et al.  Programming in the Large: The Algebraic-Functional Language Opal 2alpha , 1997, Implementation of Functional Languages.

[9]  Simon L. Peyton Jones,et al.  Type Classes in Haskell , 1994, ESOP.

[10]  Xavier Leroy,et al.  Dynamics in ML , 1991, FPCA.

[11]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.

[12]  Rafael Dueire Lins,et al.  Benchmarking implementations of functional languages with ‘Pseudoknot’, a float-intensive benchmark , 1996, Journal of Functional Programming.