Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-5nwft Total loading time: 0 Render date: 2024-06-02T16:43:07.785Z Has data issue: false hasContentIssue false

Appendix 2 - OCaml made light of

Published online by Cambridge University Press:  30 September 2009

John Harrison
Affiliation:
Intel Corporation, Portland, Oregon
Get access

Summary

This appendix summarizes the main things a reader needs to know about the programming environment we use. I hope it will provide a useful quick overview, but this appendix is no substitute for a textbook on functional programming like Cousineau and Mauny (1998) or Paulson (1991). There are numerous other texts on OCaml and CAML Light available online, e.g. a fairly comprehensive OCaml book and some old lecture notes on CAML Light by the present author.

Functional programming

OCaml supports several styles of programming, but its roots lie in functional programming, and almost all of our code is written in a purely functional style. In brief, the idea of functional programming is that a program is simply an expression, and execution means evaluation of the expression. Although this point of view may seem outlandish to those with experience of more traditional imperative programming, supported by common languages like C and Java, an expression-centric view is already familiar from other contexts such as spreadsheet programming.

The centrepiece of imperative programming is the successive modification, via assignment statements x = e or x := e, of a number of program variables, known collectively as the state. These assignment statements are invoked in a particular order using sequential execution (sometimes indicated by ‘;’) and built into more complex constructs using if tests, while loops and so on.

Functional programming represents a radical departure from this model.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2009

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • OCaml made light of
  • John Harrison
  • Book: Handbook of Practical Logic and Automated Reasoning
  • Online publication: 30 September 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511576430.010
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • OCaml made light of
  • John Harrison
  • Book: Handbook of Practical Logic and Automated Reasoning
  • Online publication: 30 September 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511576430.010
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • OCaml made light of
  • John Harrison
  • Book: Handbook of Practical Logic and Automated Reasoning
  • Online publication: 30 September 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511576430.010
Available formats
×