Abstract
The code compiled from a non-strict functional program usually manipulates heap-allocated boxed numbers. Compilers for such languages often go to considerable trouble to optimise operations on boxed numbers into simpler operations on their unboxed forms. These optimisations are usually handled in an ad hoc manner in the code generator, because earlier phases of the compiler have no way to talk about unboxed values.
We present a new approach, which makes unboxed values into (nearly) first-class citizens. The language, including its type system, is extended to handle unboxed values. The optimisation of boxing and unboxing operations can now be reinterpreted as a set of correctness-preserving program transformations. Indeed the particular transformations required are ones which a compiler would want to implement anyway. The compiler becomes both simpler and more modular.
Two other benefits accrue. Firstly, the results of strictness analysis can be exploited within the same uniform transformational framework. Secondly, new algebraic data types with unboxed components can be declared. Values of these types can be manipulated much more efficiently than the corresponding boxed versions.
Both a static and a dynamic semantics are given for the augmented language. The denotational dynamic semantics is notable for its use of unpointed domains.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
Bibliography
AW Appel [1988], “Runtime tags aren't necessary,” CS-TR-142-88, Department of Computer Science, Princeton University.
AW Appel & T Jim [Jan 1989], “Continuation-passing, closure-passing, style,” in Proc ACM Conference on Principles of Programming Languages, ACM, 293–302.
TH Brus, MCJD van Eckelen, MO van Leer & MJ Plasmeijer [Sept 1987], “Clean — a language for functional graph rewriting,” in Functional programming languages and computer architecture, Portland, G Kahn, ed., LNCS 274, Springer Verlag, 364–384.
LMM Damas & R Milner [1982], “Principal type schemes for functional programs,” in POPL, 207–212.
P Fradet & D Le Metayer [1990], “Compilation of functional languages by program transformation,” IRISA, Campus de Beaulieu, Rennes.
P Fradet & D Le Metayer [June 1988], “Compilation of lambda-calculus into functional machine code,” INRIA.
[1986], in Abstract Interpretation of Declarative Languages, C Hankin & S Abramsky, eds., Ellis Horwood, Chichester, 246–265.
P Hudak, PL Wadler, Arvind, B Boutel, J Fairbairn, J Fasel, K Hammond, J Hughes, T Johnsson, R Kieburtz, RS Nikhil, SL Peyton Jones, M Reeve, D Wise & J Young [April 1990], “Report on the functional programming language Haskell,” Department of Computing Science, Glasgow University.
R Kelsey [May 1989], “Compilation by program transformation,” YALEU/DCS/RR-702, PhD thesis, Department of Computer Science, Yale University.
DA Kranz [May 1988], “ORBIT — an optimising compiler for Scheme,” PhD thesis, Department of Computer Science, Yale University.
X Leroy [April 1991], “Efficient data representations in polymorphic languages,” INRIA Research Report 1264, Rocquencourt.
E Moggi [June 1989], “Computational lambda calculus and monads,” in Logic in Computer Science, California, IEEE.
J Peterson [Sept 1989], “Untagged data in tagged environments: choosing optimal representations at compile time,” in Functional Programming Languages and Computer Architecture, London, Addison Wesley, 89–99.
SL Peyton Jones [1987], The implementation of functional programming languages, Prentice Hall.
SL Peyton Jones [Feb 1991], “The Spineless Tagless G-machine: a second attempt,” Department of Computing Science, University of Glasgow.
SL Peyton Jones & Jon Salkild [Sept 1989], “The Spineless Tagless G-machine,” in Functional Programming Languages and Computer Architecture, D Mac-Queen, ed., Addison Wesley.
DA Schmidt [1986], Denotational semantics: a methodology for language development, Allyn and Bacon.
MB Smyth & GD Plotkin [Nov 1982], “The category-theoretic solution of recursive domain equations,” SIAM Journal of Computing 11, 761–783.
GL Steele [1978], “Rabbit: a compiler for Scheme,” AI-TR-474, MIT Lab for Computer Science.
SR Thatte [1990], “Coercive type equivalence,” Department of Maths and Computer Science, Clarkson University NY.
P Wadler [1990], “Deforestation: transforming programs to eliminate trees,” Theoretical Computer Science 73, 231–248.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1991 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Jones, S.L.P., Launchbury, J. (1991). Unboxed values as first class citizens in a non-strict functional language. In: Hughes, J. (eds) Functional Programming Languages and Computer Architecture. FPCA 1991. Lecture Notes in Computer Science, vol 523. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3540543961_30
Download citation
DOI: https://doi.org/10.1007/3540543961_30
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-54396-1
Online ISBN: 978-3-540-47599-6
eBook Packages: Springer Book Archive