cse 321 programming languages so many topics
Download
Skip this Video
Download Presentation
CSE-321 Programming Languages (So Many Topics)

Loading in 2 Seconds...

play fullscreen
1 / 23

CSE-321 Programming Languages (So Many Topics) - PowerPoint PPT Presentation


  • 119 Views
  • Uploaded on

CSE-321 Programming Languages (So Many Topics). 박성우. POSTECH May 29, 2006. Outline for Today\'s Lecture. Existential types Dependent types Call-by-name and call-by-need CPS (Continuation-passing style) transformation Constructive logic Curry-Howard isomorphism

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CSE-321 Programming Languages (So Many Topics)' - galya


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
outline for today s lecture
Outline for Today\'s Lecture
  • Existential types
  • Dependent types
  • Call-by-name and call-by-need
  • CPS (Continuation-passing style) transformation
  • Constructive logic
  • Curry-Howard isomorphism
  • Module system of Standard ML
  • -calculus
  • LF type theory
  • Twelf for mechanizing proofs
list reversal in tml
List Reversal in TML

datatype list = Nil | Cons of (int * list);

valrec append =

fn Nil => (fn x => Cons (x, Nil))

| Cons (h, t) => (fn x => Cons (h, append t x));

valrec reverse =

fn Nil => Nil

| Cons (h, t) => append (reverse t) h;

val l = Cons (1, Cons (2, Cons (3, Cons (4, Nil))));

val id = fn x => x;

id reverse l

data constructors in tml
Data Constructors in TML

datatype list = Nil | Consof (int * list);

valrec append =

fn Nil => (fn x => Cons (x, Nil))

| Cons (h, t) => (fn x => Cons (h, append t x));

valrec reverse =

fn Nil => Nil

| Cons (h, t) => append (reverse t) h;

val l = Cons (1, Cons (2, Cons (3, Cons (4, Nil))));

val id = fn x => x;

id reverse l

patterns in tml
Patterns in TML

datatype list = Nil | Consof (int * list);

valrec append =

fnNil => (fn x => Cons (x, Nil))

| Cons (h, t) => (fn x => Cons (h, append t x));

valrec reverse =

fnNil => Nil

| Cons (h, t) => append (reverse t) h;

val l = Cons (1, Cons (2, Cons (3, Cons (4, Nil))));

val id = fn x => x;

id reverse l

more patterns in tml
More Patterns in TML

datatype list = Nil | Consof (int * list);

valrecappend =

fnNil => (fnx => Cons (x, Nil))

| Cons (h, t) => (fnx => Cons (h, append t x));

valrecreverse =

fnNil => Nil

| Cons (h, t) => append (reverse t) h;

vall = Cons (1, Cons (2, Cons (3, Cons (4, Nil))));

valid = fnx => x;

id reverse l

patterns
Patterns

val_ = 1;

val true = true;

val Cons (h, t) = Cons (1, Nil);

val (x, y) = (1, ~1);

val (x) = 1;

val (x : int) = 1;

match rule pat exp
Match Rule : pat => exp

datatype list = Nil | Cons of (int * list);

valrec append =

fnNil => (fn x => Cons (x, Nil))

| Cons (h, t) => (fn x => Cons (h, append t x));

valrec reverse =

fnNil => Nil

| Cons (h, t) => append (reverse t) h;

val l = Cons (1, Cons (2, Cons (3, Cons (4, Nil))));

val id = fnx => x;

id reverse l

outline
Outline
  • Patterns in TML V
  • Syntax of TML
  • Typing and translation
syntax for tml
Syntax for TML
  • scontype  ::= int  |  bool  |  unit
  • sconpat  ::= num  |  true  |  false  |  ()
  • scon  ::= num  |  true  |  false  |  () 
  • op  ::= +  |  -  | *  |  =  |  <>
  • ty  ::= scontype  |  tycon  |  (ty * ty)  | (ty -> ty)  |  (ty)
  • pat  ::= _  |  sconpat  |  vid <pat>  |  (pat,pat)  |  (pat)  |  (pat:ty)
  • num  ::= <integer constants>
  • tycon  ::= <alphanumeric identifiers>
  • vid  ::= <alphanumeric identifiers>
  • conbinding  ::= vid <ofty>
  • conbind  ::= conbinding <| conbind>
  • dec  ::= valpat = exp  |  val rec pat = exp  |  datatypetycon = conbind
  • mrule  ::= pat=>exp
  • match  ::= mrule <|match>
  • exp  ::= scon  |  vid  |  (exp,exp)  |  letdecinexpend   | (exp)  |  expexp   |  expopexp   |  (exp : ty) | fn match
  • dlist  ::= <dec;>*
  • program  ::= dlistexp
types
Types
  • scontype  ::= int  |  bool  |  unit
  • tycon  ::= <alphanumeric identifiers>
  • ty  ::= scontype  |  tycon  |  (ty * ty)  | (ty -> ty)  |  (ty)
patterns1
Patterns
  • sconpat  ::= num  |  true  |  false  |  ()
  • vid  ::= <alphanumeric identifiers>
  • pat  ::= _  |  sconpat  |  vid <pat>  |  (pat, pat)  |  (pat)  |  (pat:ty)
declarations
Declarations
  • vid  ::= <alphanumeric identifiers>
  • conbinding  ::= vid <ofty>
  • conbind  ::= conbinding <| conbind>
  • dec  ::= valpat = exp  |  val rec pat = exp  |  datatypetycon = conbind
expressions and programs
Expressions and Programs
  • scon  ::= num  |  true  |  false  |  () 
  • op  ::= +  |  -  | *  |  =  |  <>
  • mrule  ::= pat=>exp
  • match  ::= mrule <|match>
  • exp  ::= scon  |  vid  |  (exp,exp)  |  letdecinexpend   |(exp)  |  expexp   | expopexp   |  (exp : ty)| fn match
  • dlist  ::= <dec;>*
  • program  ::= dlistexp
outline1
Outline
  • Patterns in TML V
  • Syntax of TML V
  • Typing and translation
monomorphic typing
Monomorphic Typing
  • No polymoprhic types, i.e., no type variables
    • every expression has a unique monomorphic type

val id = fn x => x;

id 1

typing and translation
Typing and Translation
  • Ast.program
    • source program
  • Core.programty
    • program with type annotations
  • Mach.code
    • machine code
  • val tprogram : Ast.program -> Core.programty
  • val programty2code : Core.programty -> Mach.code
50 of assignment 8
50% of Assignment 8

type venv = (avid, loc) dict

type env = venv * int

val pat2code : Mach.label * Mach.label * loc -> Core.pat -> Mach.code * venv

val exp2code : env * Mach.label -> Core.exp -> Mach.code * Mach.rvalue

val dec2code : env * Mach.label -> Core.dec -> Mach.code * env

val matchty2code : env * Mach.label -> Core.matchty -> Mach.code

the remaining 49
The Remaining 49%
  • Representation for functions
  • Representation for recursive functions
  • Context switch
  • Function arguments and return values

) These questions test your understanding of closures.

the remaining 1
The Remaining 1%
  • Representation for pairs
  • Representation for data constructors
  • Registers
  • Heap
  • Optimizations
  • 하면서 보내 버리는 시간
  • ...
slide22
Don\'t get scared by Parjong\'s misleading message on the discussion board.

제 목: 허허허.. ㅠ_ㅠ

교수님 HW8.. 도저히.. -_-aa 그 시간에 끝낼 수 있을 거라는 생각이 안드는데요;;

    • Everyone of you can finish this assignment!
slide23
Assignment 8
    • will be the most fun of all the assignments this course offers.
    • will be the most rewarding experience you can have in this course.
  • Discuss with your classmates (not just with your partner)
  • Start early!
  • Sample solution: about 600 lines of code
    • You will write 300 ~ 500 lines of code.
ad