ML: the metalanguage

12
ML: the ML: the metalanguage metalanguage Drew Wyborski Drew Wyborski Programming Languages Programming Languages

description

ML: the metalanguage. Drew Wyborski Programming Languages. Introduction. Originally conceived to develop proof tactics Automatically infers types Focus on developing programs through a logical approach Used as the basis for several other languages and dialects. Functional Programming. - PowerPoint PPT Presentation

Transcript of ML: the metalanguage

Page 1: ML: the metalanguage

ML: the metalanguageML: the metalanguage

Drew WyborskiDrew Wyborski

Programming LanguagesProgramming Languages

Page 2: ML: the metalanguage

IntroductionIntroduction

• Originally conceived to develop proof tactics

• Automatically infers types

• Focus on developing programs through a logical approach

• Used as the basis for several other languages and dialects

Page 3: ML: the metalanguage

Functional ProgrammingFunctional Programming

• Logical analysis is simple and easy

• No reassignment or modification of types

• Can prove assertions about a program with ease

• Difficult to write programs that are illogical

• Lend themselves well of parallel execution

• Still retain all the useful components of a traditional language

Page 4: ML: the metalanguage

Functional vs. ImperativeFunctional vs. Imperative

• Development Cycle

• Development Language

• Run-time System

• FORTRAN, Pascal, C

• ML, Hope, Lisp

Page 5: ML: the metalanguage

Language OverviewLanguage Overview

• Call-by-value evaluation strategy

• Automatic memory allocation through garbage collection

• Parametric polymorphism

• Static typing

• Exception handling

• Pattern matching

Page 6: ML: the metalanguage

Development and CreationDevelopment and Creation

• Developed by Robin Milner in 1973 at Edinburgh University

• The goal behind ML

• The perfect language

Page 7: ML: the metalanguage

Standard MLStandard ML

• Standard ML ’90 & Standard ML ‘97

• Changes from original Edinburgh ML

• Standard ML-New Jersey

• Other popular versions– Moscow ML– ML Kit– MLton– PolyML

Page 8: ML: the metalanguage

CharacteristicsCharacteristics

• Safety through the type-checker

• Structures and signatures

• Flexibility of functions

• Call-by-value evaluation

• Polymorphism

• Compile-time type checking

• Type inference

Page 9: ML: the metalanguage

CharacteristicsCharacteristics

• Garbage collection

• Exemption handling

• Immutable data types

• Updating references

• Abstraction

• Parametric modules

• Formal definition

• Proof of completeness

Page 10: ML: the metalanguage

Data Type/OperatorsData Type/Operators

• Operators and types similar to C++/Java– int, string, bool and real remain the same– Operators have slight differences

• Additional Boolean types are included showing the rational/logical basis– andalso & orelse

Page 11: ML: the metalanguage

SyntaxSyntax

• Input is placed into user’s implementation• Machine responds with result of

expression• Specified layout for entry and output

– 3 + 4;– val it = 7 : int

• If an error is made in entry, the machine responds with an appropriate error

• The unit data type

Page 12: ML: the metalanguage

DefinitionsDefinitions

• Global constants– val PI = 3.4;– Help increase readability

• Functions– fun succ n = n+1;– val succ = fn : int int

• Extensions– if…then…else functions– Multiple input/output functions