Programming Languages Dan Grossman 2013 ML Expressions and Variable Bindings.

Slides:



Advertisements
Similar presentations
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists Dan Grossman Winter 2013.
Advertisements

Programming Languages Section 1 1 Programming Languages Section 1. SML Fundamentals Xiaojuan Cai Spring 2015.
Recap 1.Programmer enters expression 2.ML checks if expression is “well-typed” Using a precise set of rules, ML tries to find a unique type for the expression.
Scope Chapter Ten Modern Programming Languages.
Searching for Type-Error Messages Benjamin Lerner, Matthew Flower, Dan Grossman, Craig Chambers University of Washington.
CSE341: Programming Languages Lecture 1 Course Mechanics ML Variable Bindings Dan Grossman Fall 2011.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists Dan Grossman Fall 2011.
1 Scheme Scheme is a functional language. Scheme is based on lambda calculus. lambda abstraction = function definition In Scheme, a function is defined.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
CS 312 Spring 2004 Lecture 18 Environment Model. Substitution Model Represents computation as doing substitutions for bound variables at reduction of.
CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Winter 2013.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Syntax & Semantic Introduction Organization of Language Description Abstract Syntax Formal Syntax The Way of Writing Grammars Formal Semantic.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
CSE 341 : Programming Languages Lecture 1 Hello World! Welcome to ML Zach Tatlock Spring 2014.
CSE341: Programming Languages Lecture 1 Course Mechanics ML Variable Bindings Dan Grossman Spring 2013.
A Third Look At ML Chapter NineModern Programming Languages, 2nd ed.1.
CSE 341 : Programming Languages Lecture 2 Functions, Pairs, Lists Zach Tatlock Spring 2014.
CSE 130 : Spring 2011 Programming Languages Ranjit Jhala UC San Diego Lecture 5: Functions and Closures.
Today’s Agenda ML Development Workflow –Emacs –Using use –The REPL More ML –Shadowing Variables –Debugging Tips –Boolean Operations –Comparison Operations.
CSE341: Programming Languages Lecture 4 Records, Datatypes, Case Expressions Dan Grossman Spring 2013.
Programming Languages Dan Grossman 2013 Everything is an Object.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Spring 2016.
Programming Languages Dan Grossman 2013
CSE 341 Section 1 (9/28) With thanks to Dan Grossman, et. al. from previous versions of these slides.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Winter 2013.
CSE 341 Section 1 (9/28) With thanks to Dan Grossman, et. al. from previous versions of these slides.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Spring 2017.
CSE341: Programming Languages Lecture 15 Macros
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 1 Course Mechanics ML Variable Bindings Dan Grossman Spring 2017.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Autumn 2017.
Nicholas Shahan Spring 2016
CSE341: Programming Languages Lecture 15 Macros
CSE 341: Programming Languages Section 1
CSE 341: Programming Langs
CSE341: Programming Languages Section 1
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Winter 2013.
CSE341: Programming Languages Lecture 1 Course Mechanics ML Variable Bindings Dan Grossman Fall 2017.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Autumn 2018.
CSE 341 Section 1 Nick Mooney Spring 2017
CSE341: Programming Languages Section 1
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Spring 2013.
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Spring 2016.
CSE 341: Programming Languages Section 1
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
CSE341: Programming Languages Lecture 15 Macros
CSE341: Programming Languages Lecture 1 Course Mechanics ML Variable Bindings Dan Grossman Autumn 2018.
What is a programming language?
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Autumn 2018.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Let bindings Motivation: Functions without local variables can be poor style and/or really inefficient. Syntax: let b1 b2 ... bn in e end where each bi is.
CSE341: Programming Languages Lecture 15 Macros
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Autumn 2017.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
CSE341: Programming Languages Lecture 1 Course Mechanics ML Variable Bindings Dan Grossman Spring 2019.
What is a programming language?
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 8 Lexical Scope and Function Closures Dan Grossman Spring 2019.
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
CSE341: Programming Languages Section 1
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists
Product Training Program
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
CSE341: Programming Languages Lecture 15 Macros
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Spring 2019.
CSE341: Programming Languages Lecture 15 Macros
Presentation transcript:

Programming Languages Dan Grossman 2013 ML Expressions and Variable Bindings

Mindset “Let go” of all programming languages you already know For now, treat ML as a “totally new thing” –Time later to compare/contrast to what you know –For now, “oh that seems kind of like this thing in [Java]” will confuse you, slow you down, and you will learn less Start from a blank file… Jan-Mar 20132Dan Grossman, Programming Languages

A very simple ML program [The same program we just wrote in Emacs; here for conveniene if reviewing the slides] Jan-Mar 20133Dan Grossman, Programming Languages (* My first ML program *) val x = 34; val y = 17; val z = (x + y) + (y + 2); val q = z + 1; val abs_of_z = if z < 0 then 0 – z else z; val abs_of_z_simpler = abs z

A variable binding Syntax: –Keyword val and punctuation = and ; –Variable x –Expression e Many forms of these, most containing subexpressions Jan-Mar 20134Dan Grossman, Programming Languages val z = (x + y) + (y + 2); (* comment *) More generally: val x = e;

The semantics Syntax is just how you write something Semantics is what that something means –Type-checking (before program runs) –Evaluation (as program runs) For variable bindings: –Type-check expression and extend static environment –Evaluate expression and extend dynamic environment So what is the precise syntax, type-checking rules, and evaluation rules for various expressions? Good question! Jan-Mar 20135Dan Grossman, Programming Languages