Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-m8s7h Total loading time: 0 Render date: 2024-07-16T17:21:31.929Z Has data issue: false hasContentIssue false

11 - Evaluation

Published online by Cambridge University Press:  05 June 2012

Guy Cousineau
Affiliation:
Ecole Normale Supérieure, Paris
Michel Mauny
Affiliation:
Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt
Get access

Summary

In Chapter 3, we presented a model for evaluation of expressions; it was based on the idea of rewrites. This model defined a semantics to which every implementation had to refer. However, an implementation that actually used textual rewrites would be highly inefficient. To achieve reasonable efficiency, we must replace textual rewrites by some other mechanism that simulates it. One possibility is to introduce the idea of an environment.

In this chapter, we present evaluation based on environments. We will write an evaluation function that takes an environment and a Caml expression as its arguments and returns the value of this expression as its result. The ideas for implementing this evaluation function will be refined in Chapter 12 to produce a compiler.

Section 11.1 describes evaluation of expressions with the help of environments. As in Chapter 3, it uses inference rules corresponding to each construction in the language to do so. These inference rules define evaluation by value, the evaluation strategy adopted by Caml. Section 11.2 then shows how to translate these rules into an evaluator written in Caml. Finally, Section 11.3 shows how to modify that evaluator to take into account delayed evaluation rather than evaluation by value.

Evaluation with the Help of Environments

An environment may be regarded as a look-up table in which certain variables are bound to values.

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

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.

  • Evaluation
  • Guy Cousineau, Ecole Normale Supérieure, Paris, Michel Mauny, Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt
  • Translated by K. Callaway
  • Book: The Functional Approach to Programming
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139173018.016
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.

  • Evaluation
  • Guy Cousineau, Ecole Normale Supérieure, Paris, Michel Mauny, Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt
  • Translated by K. Callaway
  • Book: The Functional Approach to Programming
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139173018.016
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.

  • Evaluation
  • Guy Cousineau, Ecole Normale Supérieure, Paris, Michel Mauny, Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt
  • Translated by K. Callaway
  • Book: The Functional Approach to Programming
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139173018.016
Available formats
×