lec-sml - CMSC 22100/32100 Programming Languages An...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMSC 22100/32100: Programming Languages An Overview of Standard ML M. Blume October 2, 2008 Contents 1 What is SML 2 2 Integers, reals, booleans 2 3 Variables 3 4 Constructing new types 4 4.1 Option type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4.2 List type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4.3 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.4 Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.5 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5 Functions 9 5.1 Function values and function definitions . . . . . . . . . . . . . . . . . 9 5.2 Function application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 5.3 Curried function definitions . . . . . . . . . . . . . . . . . . . . . . . . 10 6 Other types 11 6.1 The unit type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 6.2 References—the ref type . . . . . . . . . . . . . . . . . . . . . . . . . 11 6.3 Text—the types char and string . . . . . . . . . . . . . . . . . . . . . 11 7 Block structure 12 7.1 Simultaneous bindings and mutual recursion . . . . . . . . . . . . . . . 13 8 Patterns and pattern matching 14 8.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 9 Other language features 18 9.1 Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 9.2 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 9.3 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 9.4 Infix declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 10 Using Files 21 10.1 Function use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 10.2 A note on polymorphism and type inference . . . . . . . . . . . . . . . 22 10.3 Generativity of datatype definitions . . . . . . . . . . . . . . . . . . . 22 10.4 CM — the SML/NJ compilation manager . . . . . . . . . . . . . . . . 23 1 A Reserved words 23 B Pre-defined infix operators 24 C Other restricted identifiers 24 1 What is SML Standard ML is a strongly typed, impure, strict functional language. Strongly typed: Every value, expression in the language has a type (int, real, bool etc. ). The compiler rejects a program that does not conform to the type system of the language. Functional: Each expression evaluates to a value . Some of these values are functions . In fact, every function in ML is a value. Like other values, functions can be bound to variables, passed as arguments to other func- tions, returned as values from function calls, and stored in data structures....
View Full Document

Page1 / 24

lec-sml - CMSC 22100/32100 Programming Languages An...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online