B.2 Introduction

ML (historically, MetaLanguage) is, like Scheme, a language supporting primarily functional programming with some imperative features. It was developed by A. J. Robin Milner and others in the early 1970s at the University of Edinburgh. ML is a general-purpose programming language in that it incorporates functional features from Lisp, rule-based programming (i.e., pattern matching) from Prolog, and data abstraction from Smalltalk and C++. ML is an ideal vehicle through which to explore the language concepts of type safety, type inference, and currying. The objective here, however, is elementary programming in ML. ML also, like Scheme, is statically scoped. We leave the use of ML to explore these language concepts to the main text.

This appendix is an example-oriented avenue to get started with ML programming and is intended to get a programmer already familiar with the essential tenets of functional programming (Chapter 5) writing intermediate programs in ML; it is not intended as an exhaustive tutorial or comprehensive reference. The primary objective of this appendix is to establish an understanding of ML programming in readers already familiar with the essential elements of functional programming in preparation for the study of typing and type inference (in Chapter 7), currying and higher-order functions (in Chapter 8), and type systems (in Chapter 9)—concepts that are both naturally and conveniently explored through ML. This appendix should be straightforward for anyone familiar with functional programming in another language, particularly Scheme. We sometimes compare ML expressions to their analogs in Scheme.

We use the Standard ML dialect of ML, and the Standard ML of New Jersey implementation of ML in this text. The original version of ML theoretically expressed by Milner in 1978 used a slightly different syntax than Standard ML and lacked pattern matching. Note that – is the prompt for input in the Standard ML of New Jersey interpreter used in this text. A goal of the functional style of programming is to bring programming closer to mathematics. In this appendix, ML and its syntax as well as the responses of the ML interpreter make the connection between functional programming and mathematics salient.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.231.15