CSE 305 Introduc0on to Programming Languages Lecture 17 – Type System (4) CSE @ SUNY-­‐Buffalo Zhi Yang Courtesy of Professor Thomas Dilling Courtesy of Professor Alex Aiken No0ce Board • First, homework7 will be posted soon and you can schedule your 0me working on it accordingly. Our objec0ve • The first objec0ve of our class, is to comprehend a new programming language within very short 5me period, and because you have this ability to shorten your learning curve, you are going to manipulate the language with an insight learning. • The second objec0ve is to even engineer your own language! Review what we ve learnt and see future eg: Egyp0an Number System; Complement Number eg: Abacus Number System eg: Gate system, Including different underline device 1st Genera0on language: Machine Code eg: MIPS 2nd Genera0on language: Assembly Code eg: Fortran Regular Expression What s next ? 3rd Genera0on Language: Macro func0on Macro func5on Basic Calcula0on System Lexer Compiler System Virtual Machine Parser Push Down Automata Type Checking Context-­‐Free Grammar Lambda Calculus Theory A family tree of languages Cobol <Fortran> BASIC Algol 60 <LISP> PL/1 Simula <ML> Algol 68 C Pascal <Perl> <C++> Modula 3 Dylan Ada <Java> <C#> <Scheme> <Smalltalk> <Ruby> <Python> <Haskell> <Prolog> <JavaScript> Computa5on Seman5cs(Big Step and Small Step or BS and SS) Following equa0ons are demo of Big Step nota0on and Small Step nota0on: Example of nota5ons 1) Syntac0c categories e in Exp op in Op n in Num x in Var 2) Defini0ons op :: + | -­‐ | * | div E :: x | n | e op e Review nota0on for environment Review nota0on for environment Example for Environment (1) Example for Environment (2) Since: 5:Int Lambda x. x+2 : Int -­‐>Int So: 3:Int Lambda x. x+2 : Int -­‐>Int 3:Int ((Lambda x. x+2 ) 3) : Int Int-­‐>int-­‐>int Since: Lambda x: Int -­‐>Int.x So: (lambda x.x : Int-­‐>Int) Lambda y:Int.y Lambda x:Int-­‐>Int. lambda y:Int. (x y) : Int-­‐>Int-­‐>Int Lambda y:Int.y Reject Accept Accept Reject LAMBDA alpha. alpha Lambda x: Int Int (((LAMBDA alpha. Lambda x :alpha.x) Int) 3): Int .x 3 Thomas Dillig, � Over last several years, polymorphism has gone main stream � Many languages either substantially extend their treatment of polymorphism (C++) or added polymorphism (Java, C#) � However, polymorphism always tends to be a difficult addition to any language. � You either are already using it or will use it soon CS312: Programming Languages Lecture 11: Polymorphism 36/38