ML: the metalanguage
-
Upload
mari-jefferson -
Category
Documents
-
view
22 -
download
1
description
Transcript of ML: the metalanguage
ML: the metalanguageML: the metalanguage
Drew WyborskiDrew Wyborski
Programming LanguagesProgramming Languages
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
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
Functional vs. ImperativeFunctional vs. Imperative
• Development Cycle
• Development Language
• Run-time System
• FORTRAN, Pascal, C
• ML, Hope, Lisp
Language OverviewLanguage Overview
• Call-by-value evaluation strategy
• Automatic memory allocation through garbage collection
• Parametric polymorphism
• Static typing
• Exception handling
• Pattern matching
Development and CreationDevelopment and Creation
• Developed by Robin Milner in 1973 at Edinburgh University
• The goal behind ML
• The perfect language
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
CharacteristicsCharacteristics
• Safety through the type-checker
• Structures and signatures
• Flexibility of functions
• Call-by-value evaluation
• Polymorphism
• Compile-time type checking
• Type inference
CharacteristicsCharacteristics
• Garbage collection
• Exemption handling
• Immutable data types
• Updating references
• Abstraction
• Parametric modules
• Formal definition
• Proof of completeness
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
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
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