A Gentle Introduction to Camelot

Hans-Wolfgang Loidl

   Institut für Informatik,
   Ludwig-Maximilians-Universität München

Kenneth MacKenzie

   Laboratory for the Foundations of Computer Science,
   Edinburgh University 

September 2004

Table of Contents
A Quick Introduction to Using Camelot
Camelot the Language
A more detailed example of Camelot in action
An Example of Object-Oriented Features
Camelot the System
A. Appendix

This document gives an introduction to the resource-safe functional programming language Camelot. No previous knowledge of functional programming is assumed. This is an early draft.


While functional programming languages are great in providing a high level of abstraction, their resource consumption is fairly hard to predict. A lot of effort has gone into devising sophisticated compilation techniques to reduce the resource consumption. However, these techniques follow an all-or-nothing approach: either the optimisation will kick in, reducing resource consumption significantly, or it won't. In the latter case, the user usually has no way of identifying the reason, or to help the compiler in optimising the code.

Camelot takes the approach of giving the programmer more control about the space consumption of a program. In particular, it provides a structured way of gaining direct access to memory locations, so as to formulate code for in-place update. An extended type system is used to guarantee that the usage of these extensions does not break the referential transparency of the language.

Camelot is a language of the ML family. It is strict, first-order but allows for use-only higher-order functions. It includes object-oriented extensions, mainly for creating and using objects in an existing class hierarchy. Programmers familiar with ML or Ocaml should have no problems understanding the basic language promitives. In this introduction we will focus on the extensions for gaining direct access to memory, and how to use these for writing efficient code. Finally, we will discuss how the type system can ensure that the code is still safe.

This document aims to give an introduction to using the language and system without trying to be a comprehensive discussion of either. For more in-depth discussions of the language the reader is refered to papers on the language (TFP03,OCamelot) and the Camelot manual (Manual). In this document we first give a quick introduction how to compile and execute a simple Camelot program (the Section called A Quick Introduction to Using Camelot). An example discusses the main characteristics of Camelot (the Section called A more detailed example of Camelot in action). Then we discuss the language in more detail (the Section called Camelot the Language). Finally, we give information on the system including profiling, tools etc (the Section called Camelot the System).